Question: Python function question: 1. Write an expression that computes the difference of the variables ending_time and starting_time. 2. Given a variable word that has been

Python function question:

1. Write an expression that computes the difference of the variables ending_time and starting_time.

2. Given a variable word that has been assigned a string value, write a string expression that parenthesizes the value of word. So, if word contains "sadly", the value of the expression would be the string "(sadly)"

3.Assume that print_todays_date is a function that uses no parameters and returns no value. Write a statement that calls (invokes) this function.

4. Write the code to call a function whose name is send_number. There is one argument for this function, which is an int. Send 5 as an argument to the function.

5.Write the code to call a function named send_variable and that expects a single int parameter. Suppose a variable called x refers to an int. Pass this variable as an argument to send_variable.

6. Write the code to call a function named send_two and that expects two parameters: a float and an int. Invoke this function with 15.955 and 133 as arguments.

7. Given that add, a function that expects two int parameters and returns their sum, and given that two variables, euro_sales and asia_sales, have already been defined:

Write a statement that calls add to compute the sum of euro_sales and asia_sales and that associates this value with a variable named eurasia_sales.

8. Assume that to_the_power_of is a function that expects two int parameters and returns the value of the first parameter raised to the power of the second parameter.

Write a statement that calls to_the_power_of to compute the value of cube_side raised to the power of 3 and that associates this value with cube_volume.

9. Write an expression whose value is the result of converting the int value 42 to a str (consisting of the digit 4 followed by the digit 2).

10. Write an expression whose value is the result of converting the str value associated with s to an int value. So if s were associated with "41" then the resulting int would be 41.

11. Write an expression whose value is the arithmetic sum of the int associated with x, and the all-digit str associated with s. (Hint: you will need to convert the str to an int.)

12. Write a statement to set the value of the variable popStr to a string representation of the value referenced by the variable pop

13. max is a function that expects two int parameters and returns the value of the larger one.

Two variables, population1 and population2, have already been defined and associated with int values.

Write an expression (not a statement!) whose value is the larger of population1 and population2 by calling max.

14. Write a definition of the function printDottedLine, which has no parameters and doesn't return anything. The function prints to standard output a single line consisting of 5 periods (".").

15. Write the definition of a function printGrade, which takes one parameter containing a string value and returns nothing. The function prints "Grade: " followed by the string parameter.

16. Write the definition of a function twice, that receives an int parameter and returns an int that is twice the value of the parameter.

17. Write the definition of a function oneLess which recieves a parameter containing an integer value and returns an integer whose value is one less than the value of the parameter.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!