Question
34 STUDY GUIDE QUESTIONS TO HELP ME STUDY FOR NEXT WEEKS TEST THANK YOU SO MUCH FOR THE HELP AND I WILL THUMBS UP! PLEASE
34 STUDY GUIDE QUESTIONS TO HELP ME STUDY FOR NEXT WEEKS TEST THANK YOU SO MUCH FOR THE HELP AND I WILL THUMBS UP! PLEASE NUMBER THE ANSWERS ACCORDINGLY!
1. What will be printed by the following code segment?
def otherMethod(num1):
num2 = 3
print(num1)
num1, num2 = 1, 2
print(num1)
otherMethod(num2)
2.What will be printed by the following code segment?
def otherMethod():
num2 = 3
print(num2)
num1 = 1
num2 = 2
print(num1)
otherMethod()
3.What will be printed by the following code segment?
major = "CIS"
for x in major:
print(x)
4.first_name = "Donald"
last_name = "Trump"
Write a print() statement to print the person's full name as "Trump, Donald".
5.majors = ("ACT", "FIN", "CIS", "MGT", "MKT")
Consider the tuple above, write the necessary code (e.g., a for ... loop) to print the individual tuple elements in separate lines.
6.What will be printed by the following code segment?
pi = 3.14159
print("%4.2f is the %s value." % (pi,"pi"))
7.Write a statement to get the user's age and store it in variable age. (Make sure the value in age is an integer.)
8.Write a print() statement to print the sentence
She said "Thank you!" to me.
9.The following loop will execute _____ times.
x = 200
while (x > 100):
x /= 2
10.How many times the word "Hello" will be printed by the following code segment?
x = 0
while (x < 10):
print("Hello")
11.What will be printed by the following code segment?
emp = ('Bill', 21, 'CIS', 18.95)
(name, age, field, wage) = emp
print(emp[4])
12.What will be printed by the following code segment?
def math(x,y):
return x ** y
math(10,3)
13.What will be printed by the following code segment?
def hello():
print("Hello")
hello()
print("World!")
14.Write an if...else... statement to print "Fail" if grade is less than 70 or "Pass" otherwise.
15.What will be printed by the following code segment?
python, java = 300, 304
if (python < java):
print("%d is better than %d" % (java, python))
16.What will be the result of running the code segment below?
python, java = 300, 304
if (python < java):
print("java is a better language")
17.A Python program is executed by _____.
A.the Operating System (e.g., Windows, Linux)
B.the Python language interpreter
C.the web browser (e.g., Internet Explorer, Chrome)
D.none of the above
18.the following for ... loop will execute Blank 1 times.
for i in range(2,6):
print(i)
19.How many times "OK" will be printed by the loop below? Blank 1
meals = \["breakfast", "lunch", "dinner"\]
for d in range(1,7+1):
for m in meals:
print("OK")
20.What will be printed by the following code segment? Blank 1
fruits = \["apple", "banana", "cherry"\]
for f in fruits:
if (f == "banana"):
break
print(f)
21.the following for ... loop will execute Blank 1 times.
for i in range(2,6,2):
print(i)
22.What will be printed by the code segment below? Blank 1
university = "ASU"
for i in university:
print(i, end="")
23.What will be printed by the following code segment?
a = "11"
b = "22"
print(a+b)
A.22
B.33
C.1122
D.syntax error
24.Suppose the user will enter 17 as his/her age. What will be printed by the following code segment?
age = input("How old are you? ")
age += 1
print("You were "+age+" last year.")
A.You were 18 last year.
B.You will be 18 next year.
C.You were 16 last year.
D.syntax error
25.What will be printed by the following code segment?
print(" " * 5)
A." " * 5
B." "" "" "" "" "
C.5 blanks
D.syntax error
26.How many numbers will be printed by the following code segment? Blank 1
for n in range(300,304):
if (n % 5 == 0):
continue
print(n)
27.What will be printed by the following code segment? Blank 1
x = (1, 2, 3, 4, 5, 6)
print(x\[3\])
28.A Python dictionary is used to map or associate things you want to store and the keys you need to get them. What will be printed by the following code segment? Blank 1
age = {'Bill': 18, 'Jim': 21, 'Donald': 73, 'Jean': 25}
print(age\['Donald'\])
29.What will be printed by the following code segment?
x = 123
if (x < 321):
print("ACT")
print("MGT")
print("CIS")
A.ACT
MGT
CIS
B.ACT
MGT
C.CIS
D.It doesn't generate any output
30.What will be printed by the following code segment?
if 'cis' in {'act': 1, 'cis': 2, 'mgt': 3}:
print(1)
print(2)
if 'a' in 'cis':
print(3)
print(4)
A.1
2
3
4
B.1
2
4
C.4
D.It doesn't generate any output
31.What will be printed by the following code segment? Blank 1
x, y, z = 101, 202, 303
if (x > y or z > y):
print("great")
else:
print("not bad")
32.What will be printed by the following code segment? Blank 1
x = 303
if (x > 202):
print("ASU")
else:
if (x == 303):
print("COBA")
33.What will be printed by the following code segment? Blank 1
x = 3
if (x <= 3):
if (x > 0):
print("good")
else:
if (x == 3):
print("bad")
else:
print("ugly")
34.What will be printed by the following code segment? Blank 1
x = 0
if (x <= 3):
if (x < 2):
print("good")
elif (x < 1):
if (x <= 0):
print("bad")
else:
print("ugly")
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started