Question: cs 121 The following two programs produce the same output. Which of the following is the benefit of writing code the second way? Example 1:



The following two programs produce the same output. Which of the following is the benefit of writing code the second way? Example 1: favorite = input("What's your favorite type of drink?") print("I say water and you say", favorite) if favorite = "water": print("We said the same thing!") healthy = input("What do you think is the healthiest type of drink?") print("I say water and you say", healthy) if heal thy = "water": print("We said the same thing!") Example 2: def say (drink): print("I say water and you say", drink) if drink = " "water": print("We said the same thing!") favorite = input("What's your favorite type of drink?") say(favorite) heal thy - input ("What do you think is the healthiest type of drink?") say(heol thy) The second way allows for user input, which cannot be done using the first way The second way allows code to be reused rather than rewritten Which of the following properly defines a function called which takes two numbers as parameters and prints which number is bigger. This function does not return anything. For example: bigger(10,50)bigger60,13)bigger(78,-3)bigger(9,18)#shouldprint"50isbigger"#shouldprint"60isbigger"#shouldprint"78isbigger"#shouldprint"-9isbigger" def bigger (10,50) : if 10>50: print ("x is bigger") elif 50>10: print (" y is bigger") def bigger (x,y) : if x>y: print (x, "is bigger") elif >>x : print (y, is bigger") else: print("Both values are", x) def bigger (x,y) : if x>y: return x, "is bigger" elif y>x : is bigger" return y, is bet else: return "Both values are", x Which of the following is NOT a valid value for ' x ' after this code is executed? import random x= random. randrange (1,10) 1 5 10 Question 4 0.4 pts Which of the following statements are true? math and random are the only python modules that exist Modules provide developers with added functions to use in addition to the built-in functions like print 0 The math module must be imported to be used, but the random module does not need to be imported Which of the following statements are true? math and random are the only python modules that exist Modules provide developers with added functions to use in addition to the built-in functions like print0 The math module must be imported to be used, but the random module does not need to be imported Question 5 0.4 pts Which of the following is the result of 20736.0 12 12.0 288
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
