Question

Using python language 1- Write a function for checking the speed of drivers with 3 different...

Using python language

1- Write a function for checking the speed of drivers with 3 different speeds: 55, 90, 160.
If the return result is 0, it should print “Good”.
If the return is not zero but less then 12, it should print: ‘Too fast“ if the return is  greater than 70, then print “Your license is suspended!”


2- Write a function that takes a series of numbers as parameters to check if the driver is speeding up or slowing down. If the numbers are increasing, return 1, if decreasing -1, if neither, return 0. So, if you invoke the function with the parameters (25, 27, 34, 45), it will return 1; if (75, 67, 23), -1; but if (34, 60, 78, 69) then 0. Staying the same would be increasing if the speed was increasing before, decreasing if it was not. Hint: use *arg for variable number of parameters.

Homework Answers

Answer #1

I have written the program using PYTHON PROGRAMMING LANGUAGE.

Note : Question 1 is not so clear so please mention the question properly .

ANSWER for the question 2 :

OUTPUT :

CODE :

#function definition for SpeedRecognize

def SpeedRecognize(*arg):

if(list(arg) == sorted(list(arg),reverse = False)):

return 1#return 1

elif(list(arg) == sorted(list(arg),reverse = True)):

return -1#return -1

else:

0#return 0

#calling SpeedRecognize and storing the output in the variable called result

result = SpeedRecognize(34, 60, 78, 69)

if(result ==1) :

print("Speed is Up!!!")

elif(result == -1):

print("Speed is down!!!")

else:

print("Speed is neither Up nor Down!!!")

Thanks..

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
TO BE DONE IN PYTHON: Write a function `lowest_integer()` which takes 2 input arguments: 1)a function...
TO BE DONE IN PYTHON: Write a function `lowest_integer()` which takes 2 input arguments: 1)a function `g` representing an increasing function g(x) 2) a number `gmin`, and returns an integer `nmin` such that nmin>0 is the smallest integer that satisfies g(nmin)>gmin. test: def g(n): return 2*n print(lowest_integer(g, 10)) Output: 6
Please use Python 3+ Write a function called let_to_num. It should take a word and encode...
Please use Python 3+ Write a function called let_to_num. It should take a word and encode it into a series of numbers and dashes, with the numbers corresponding to the position of the letter in the alphabet (regardless of casing). If the character is not a letter, then ignore it. Examples of outputs: print(let_to_num('AZ')) # -> 1-26 print(let_to_num('')) # -> (empty string) print(let_to_num('A?Z')) # -> 1-26 print(let_to_num('AZ?')) # -> 1-26 print(let_to_num('AbzC')) # -> 1-2-26-3
This is an intro to Python question: #Write a function called linear() that takes two parameters...
This is an intro to Python question: #Write a function called linear() that takes two parameters #- a list of strings and a string. Write this function so #that it returns the first index at which the string is #found within the list if the string is found, or False if #it is not found. You do not need to worry about searching #for the search string inside the individual strings within #the list: for example, linear(["bobby", "fred"], "bob") #should...
Write a Python function which receives 3 lists as its input parameters and combines the lists...
Write a Python function which receives 3 lists as its input parameters and combines the lists and remove repeated numbers from the combined list and return the combined list. For instance, if the input is [1,2,3,4,2,3] and [3,4,6,7] and [-1,0,23,4] the result is [1,2,3,4,6,7,-1,0,23] - Note, the order the lists are combined together does not matter. Use main function.
Python: Write a function called sum_odd that takes two parameters, then calculates and returns the sum...
Python: Write a function called sum_odd that takes two parameters, then calculates and returns the sum of the odd numbers between the two given integers. The sum should include the two given integers, if they are odd. You can assume the arguments will always be positive integers, and the first smaller than or equal to the second. To get full credit on this problem, you must define at least 1 function, use at least 1 loop, and use at least...
PYTHON 3 Write a program that prints the count of all prime numbers between A and...
PYTHON 3 Write a program that prints the count of all prime numbers between A and B (inclusive), where A and B are defined as follows: A = 21212 B = A + 5000 Just a recap on prime numbers: A prime number is any number, greater or equal to 2, that is divisible ONLY by 1 and itself. Here are the first 10 prime numbers: 2, 5, 7, 11, 13, 17, 19, 23, and 29. Rules: You should first...
Python #Write a function called are_anagrams. The function should #have two parameters, a pair of strings....
Python #Write a function called are_anagrams. The function should #have two parameters, a pair of strings. The function should #return True if the strings are anagrams of one another, #False if they are not. # #Two strings are considered anagrams if they have only the #same letters, as well as the same count of each letter. For #this problem, you should ignore spaces and capitalization. # #So, for us: "Elvis" and "Lives" would be considered #anagrams. So would "Eleven plus...
Function Example: Write a Python function that receives two integer arguments and writes out their sum...
Function Example: Write a Python function that receives two integer arguments and writes out their sum and their product. Assume no global variables. def writer(n1, n2): sum = n1 + n2 product = n1*n2 print("For the numbers", n1, "and", n2) print("the sum is", sum) print("and the product is", product) ... 1) Create a PYHW2 document that will contain your algorithms in flowchart and pseudocode form along with your screen shots of the running program. 2) Create the algorithm in both...
Write a Python function count_bigger that takes two parameters, a nested list of objects and a...
Write a Python function count_bigger that takes two parameters, a nested list of objects and a threshold number. It returns an integer specifying how many of the objects anywhere in the nested list are numbers that are larger than the threshold. (For our purposes, "numbers" are either integers or floats.) There may be objects in the list other than numbers, in which case you would simply ignore them. Here are a couple of examples of how the function should behave...
Write a program in python that prints the count of all prime numbers between A and...
Write a program in python that prints the count of all prime numbers between A and B (inclusive), where A and B are defined as follows: A = The 5 digit unique number you had picked at the beginning of the semester B = A + 5000 Just a recap on prime numbers: A prime number is any number, greater or equal to 2, that is divisible ONLY by 1 and itself. Here are the first 10 prime numbers: 2,...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT