Question
1.Write a Python comment line to include your full name in it. my name is john smith. 2.What will be printed by the following code
1.Write a Python comment line to include your full name in it. my name is john smith.
2.What will be printed by the following code segment?
a = 1
b = 2
a = 3 + 4 / b
print(a)
3.What will be printed by the following code segment?
a = 3
b = 4
a = 5 % b
print(a)
4.What will be printed by the following code segment?
a = 5
b = 6
a += (b-1) * 7
print(a)
5.What will be printed by the following code segment?
x, y = 33, 11
print(float(x/y))
6.What will be printed by the following code segment?
x, y = 33, 22
print(int(x/y))
7.Base on the variable declarations below, determine if the following expression will yield the value True or False.
x, y, i, j = 0, 10, 20, 30
print((i > j) and (x <= y % 10))
8.Base on the variable declarations below, determine if the following expression will yield the value True or False.
x, y, i, j = 30, 20, 10, 0
print((x < y) or (j >= i % 10))
9.Construct a Python statement that implement the formula:
x=(y-123) * 9/5 + 321
10.Construct a Python statement for assigning r the remainder of dividing the sum of a and b by the difference of m and n.
11.What will be printed by the following code segment?
fname = "Barack"
lname = "Obama"
print(fname, end=$)
print(lname)
12.What will be printed by the following code segment?
fname = "George"
lname = "Bush"
print(fname+lname+Jr)
13.What will be printed by the following code segment?
fname = "Bill"
lname = "Clinton"
print(lname+str(11+22)+str(33))
14.What will be printed by the following code segment?
pi = 3.141592
print(pi is %6.4f % (pi))
15.What will be printed by the following code segment?
x = CIS300 Python
print(x[1:5])
16.What will be printed by the following code segment?
x = (1, 2, 3, 4, 5, 6)
print(x[-1])
17.What will be printed by the following code segment?
emp = (Bill, 21, CIS, 18.95)
(name, age, field, wage) = emp
print(field)
18.What will be printed by the following code segment?
def hello():
print(Hello)
print(World!)
19.What will be printed by the following code segment?
x = 33
if (x >= 22):
print("ASU")
if (x == 33):
print("COBA")
20.What will be printed by the following code segment?
x = 33;
if (x >= 22):
print("ASU")
else:
if (x == 33):
print("COBA")
21.What will be printed by the following code segment?
grade = 99
if (grade >= 70):
print("C")
elif (grade >= 80):
print("B")
else:
print("A")
22.What will be printed by the following code segment?
x = 3
if (x < 2):
if (x > 1):
print("good")
else:
if (x != 0):
print("bad")
else:
print("ugly")
23.What will be printed by the following code segment?
x = 3
if (x < 3):
if (x > 1):
print("good")
elif (x > 0):
if (x < 2):
print("bad")
else:
print("ugly")
24.What will be printed by the following code segment?
x = 1
y = 2
z = 3
if (x-y+z != 0):
if (y-z != 0):
z /= x
else:
z /= y
print(z)
25.What will be printed by the following code segment?
x = 1
y = 2
z = 3
if (x+y-z != 0):
if (y-z != 0):
z /= x
else:
z /= y
print(z)
26.A Python program may consist of many functions. The one function that you must have is called main() that your program wont run without it. true or false
27.What will be printed by the following code segment?
a = 11
b = 22
print(a+b)
28.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 will be +age+ next year.)
29.What will be printed by the following code segment?
print(5 * )
30.Python supports several advanced data structures that not available in other languages. A _____ is used to map or associate things you want to store and the keys you need to get them. The variable age shown below is an example.
age = {Bill: 18, Jim: 21, Donald: 73, Jean: 25}
31.What will be printed by the following code segment?
def square(x):
y = x * x
print(square(10))
32.What will be printed by the following code segment?
x = 123
if (x > 321):
print("ACT")
print("MGT")
print("CIS")
33.What will be printed if x has the value 2?
if 'bar' in {'foo': 1, 'bar': 2, 'baz': 3}:
print(1)
print(2)
if 'a' in 'qux':
print(3)
print(4)
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