Question

In: Computer Science

Implement the following function in the PyDev module functions.py and test it from a PyDev module...

Implement the following function in the PyDev module functions.py and test it from a PyDev module named :

def wind_speed(speed):
    """
    -------------------------------------------------------
    description
    Use: category = wind_speed(speed)
    -------------------------------------------------------
    Parameters:
        speed - wind speed in km/hr (int >= 0)
    Returns:
        category - description of wind speed (str)
    ------------------------------------------------------
    """

Wind speeds are categorized as:

Wind speed (km/h) Category
< 39 Breeze
39 - 61 Strong Wind
62 - 88 Gale Winds
89 - 117 Whole Gale
> 117 Hurricane

The function should return 'unknown' for a negative wind speed.

Sample testing:

Wind speed (km/h): 95
Category: Whole Gale

Solutions

Expert Solution

Make a module in PyDev in this manner:

1) Go to Window> Perspective> Open Perspective > PyDev(default)

2) Create a new package File> new > PyDev package

Check if .py files are associated with Python editor by going to: Windows> Preferences>General>Editors>File Asociations

3) Go to File> New> PyDev Module and fill module name

4) Press Finish

Here is the function:

def wind_speed(speed):

  if speed<39:

    category='Breeze'

  elif speed>=39 and speed<=61:

    category='Strong Wind'

  elif speed>=62 and speed<=88:

     category='Gale Winds'

  elif speed>=89 and speed<=117:

    category="Whole Gale"

  elif speed>117:

    category="Hurricane"

  elif speed<0:

    category="unknown"

  return category

For calling the function:

speed=int(input("Enter wind speed"))

print(type(speed))

category=wind_speed(speed)

print("Wind speed(km/h",speed)

print("Category:",category)

This will return the sample output:

Wind speed (km/h): 95
Category: Whole Gale

Related Solutions

Implement the following function in the PyDev module functions.py and test it from a PyDev module...
Implement the following function in the PyDev module functions.py and test it from a PyDev module named : def statistics(n): """ ------------------------------------------------------- Asks a user to enter n values, then calculates and returns the minimum, maximum, total, and average of those values. Use: minimum, maximum, total, average = statistics(n) ------------------------------------------------------- Parameters: n - number of values to process (int > 0) Returns: minimum - smallest of n values (float) maximum - largest of n values (float) total - total of...
Implement the following function in the PyDev module functions.py and test it from a PyDev module...
Implement the following function in the PyDev module functions.py and test it from a PyDev module named : def gym_cost(cost, friends): """ ------------------------------------------------------- Calculates total cost of a gym membership. A member gets a discount according to the number of friends they sign up. 0 friends: 0% discount 1 friend: 5% discount 2 friends: 10% discount 3 or more friends: 15% discount Use: final_cost = gym_cost(cost, friends) ------------------------------------------------------- Parameters: cost - a gym membership base cost (float > 0) friends...
Implement the following function in the PyDev module functions.py and test it from a PyDev module...
Implement the following function in the PyDev module functions.py and test it from a PyDev module named : def fast_food(): """ ------------------------------------------------------- Food order function. Asks user for their order and if they want a combo, and if necessary, what is the side order for the combo: Prices: Burger: $6.00 Wings: $8.00 Fries combo: add $1.50 Salad combo: add $2.00 Use: price = fast_food() ------------------------------------------------------- Returns: price - the price of one meal (float) ------------------------------------------------------- """ Sample testing: Order B...
Implement the following function in the PyDev module functions.py and test it from a PyDev module...
Implement the following function in the PyDev module functions.py and test it from a PyDev module named : def is_divisible(n, i, j): """ ------------------------------------------------------- Determines if n is evenly divisible by both i and j. Use: result = is_divisible(n, i, j) ------------------------------------------------------- Parameters: n - the number to check for divisibility (int) i - one of the values to divide n by (int) j - another value to divide n by (int) Returns: result - True if n is evenly...
Create a C module convertTo_csv.c that will implement the function loadAndConvert(const char* file) The code must...
Create a C module convertTo_csv.c that will implement the function loadAndConvert(const char* file) The code must be split into 2 files (.h file and a .c file). The convertTo_csv.c will have the function implementation in ti and the The convertTo_csv.h file will have the declaration. One argument will be given to the function, that is the name of the input file that needs to be converted. A function will create a new csv file called output.csv Know that the loadAndConvert...
Kernal Modul Programing Quenstion : Implement the following 4 conditions in kernel module programming. 1. Implement...
Kernal Modul Programing Quenstion : Implement the following 4 conditions in kernel module programming. 1. Implement a timer module using the timer function provided by the file LINUX/timer.h 2. In module_init, the timer is initialized using setup_timer and called mod_timer to start the timer. 3. Call back function my_timer_callback when timer expires. 4. When you remove a module, delete the timer.
Implement a function to remove a leaf node from a binary search tree. Using the following...
Implement a function to remove a leaf node from a binary search tree. Using the following class and function definition: class BTNode { public: int item; BTNode *left; BTNode *right; BTNode(int i, BTNode *l=nullptr, BTNode *r=nullptr):item(i),left(l),right(r){} }; BTNode *root = nullptr; BTNode * remove_leaf(int item, bool &removed) { // implement } The remove function will return the node with the item if it's present in the tree. If the node is a leaf node and is removed by the function,...
Write the MIPS assembly codes to implement the following function: copy a block of words from...
Write the MIPS assembly codes to implement the following function: copy a block of words from one address to another. Assume that the starting address of the source block be in register $t1 and that the destination address be in $t2. The instruction also requires that the number of words to copy in $t3 (which is >0, that means how many words are needed to copy). Furthermore, assume that the values of these registers as well as register $t4 can...
Write a Python module that must satisfy the following- Define a function named rinsert. This function...
Write a Python module that must satisfy the following- Define a function named rinsert. This function will accept two arguments, the first a list of items to be sorted and the second an integer value in the range 0 to the length of the list, minus 1. This function shall insert the element corresponding to the second parameter into the presumably sorted list from position 0 to one less than the second parameter’s index.   Define a function named rinsort. This...
Using your solution or your instructor's solution from the Module 8 ungraded practice exercise, implement a...
Using your solution or your instructor's solution from the Module 8 ungraded practice exercise, implement a unit test for the Pair class by adding a main method. Create three small constituent classes (I created PeanutButter, Jelly, and Mustard classes) and insert various combinations of them into an array of Pair objects. Thoroughly test the equals(), hashCode(), and toString() methods from the Pair class with your main method. Note: override the toString() method in each of your constituent classes so they...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT