Uploaded by csmith

Computer Science Python Basics

advertisement
Computer Science Quiz One
Name:
Score:
1. Convert the number 67 to binary (2 points)
2. Convert the number 101100 to decimal (2 points)
3. What does the operation “modulus” do? If I write 17%10 what is my answer? What
about 17%2? (2 points)
4. Consider this expression:
X=7
Y = X + 2.0
X = “dog”
Y=Y+1
Z = X + “house”
Print (x, y, z)
a) What gets printed to the screen by Print(x, y, z)? (3 points)
b) In the expression X = 7, what is X called? (2 points)
c) Is 7 a float number or an integer? (2 points)
d) In the expression Y = X + 2.0, is 2.0 a float or an integer? (2 points)
e) In the expression X = “dog”, is X an integer type or a string type? (2 points)
f) What is the name of the operation performed by + in the expression Z = X +
“house”? (2 points)
g) What is it called when we give a variable a value? (2 points)
h) Define function. Are these lines of code considered functions? (2 points)
Match these operations with their symbols (4 points):
a) Divide, multiply
b) Addition, subtraction
_______ + _______ %
c) Exponent
_______ / *
d) Modulus
_______ **
Consider the following code snippets. Are they proper functions? If they are not, what are they
missing? What do the print when we execute them?
a) Def first():
Print (“I am a function”)
2 points
b) Def second
Print (“I am a function”)
2 points
c) Def main():
String = First()
Print (string + “that calls on another function”)
2 points
Download