Test 2: Edhesive Questions & Answers
Which line of code outputs the decimal portion of a float stored in the variable x? - ✔✔print (x -
int(x))
Three of the following values could be stored as strings. When would you
...
Test 2: Edhesive Questions & Answers
Which line of code outputs the decimal portion of a float stored in the variable x? - ✔✔print (x -
int(x))
Three of the following values could be stored as strings. When would you NOT use a string
command? - ✔✔To store decimal values.
Consider the following code:
x = int(input("Enter a number: "))
print (x)
What happens if the user types in A? - ✔✔It prints 65.
Which of the following is NOT a data type in Python? - ✔✔decimal
Which of the following numbers might this code generate: random.randint(1,9)? - ✔✔1
What is NOT a built-in function in python? - ✔✔string()
To generate integers between and including -10 to 10 you would use: - ✔✔random.randint(-10,
10)
Consider the following code:
a = 3
b = 2
print (a ** b)
What is output? - ✔✔9
What is output?
print (12 % 5) - ✔✔2
Consider the following code:
x = 9
y = -2
z = 2
print (x + y * z)
What is output? - ✔✔5
You need to find the square root of a value. Which of the following functions would you use? -
✔✔sqrt
You need to make sure a number the user types in is non-negative. Which of the following
functions would you use? - ✔✔fabs
Consider the following code:
x = 5
x = x * 3
print (x)
What is output? - ✔✔15
The following code is intended to find the average of three numbers entered from the keyboard.
What is wrong with the code?
print ("Enter 3 numbers: ")
n1 = float(input ("Enter a number: "))
n2 = float(input ("Enter a number: "))
n3 = float(input ("Enter a number: ")) print (n1 + n2 + n3 /3) - ✔✔The code is missing
parentheses around n1 + n2 + n3 in the last line.
What is the output for the following?
x = 7
print ("The number is: " + x * 2) - ✔✔None, there is an error.
Which of the following calculates to 10? - ✔✔(3 * 6 + 2) /2
Which of the following would be the best variable name to store the value of your English letter
grade? - ✔✔letter_Grade
Why can it be helpful to perform mathematical calculations using programming? Choose the best
answer. - ✔✔Because computers can quickly do calculations much larger and complex than
humans.
Consider the following code:
x = 19
y = 5
print (x % y)
What is output? - ✔✔4
Consider the following code:
print (min("whom", "carton", "landform", "apron", "deposit", "become"))
What is output? - ✔✔apron
Function - ✔✔A collection of commands given a name, for example, input( ).?
Module - ✔✔A collection of code and functions that perform similar tasks.
Modular Division - ✔✔A calculation which gives the remainder of integers which have been
divided.
Min - ✔✔Command that finds the smallest value in a set of values.
Big Data - ✔✔Data sets that are too large and complex for traditional data processing
applications.
Max - ✔✔Command that finds the largest value in a set of values.
Assignment - ✔✔The process of storing a value in a variable.
Terabyte - ✔✔2^40 or one million million (10^12) bytes.
Import - ✔✔Command that pulls in code to add functions to your code.
random - ✔✔A module used to create random numbers in programs. The numbers generated are
not really random.
Operator - ✔✔A symbol that defines a math operation.
[Show More]