Sie sind auf Seite 1von 3

Q:

What is the output of the following Python statement?


print ( 6 // 5 + 1)

a) 4
b) 5
c) 2
d) 0

Q: What is the output of the following algorithm if the user gives input as 1?

Start
Read x
x -= 1
Write x
Stop

a) 1
b) -1
c) 0
d) x

Q: What is the output of the following Python statements?

str="Hi,My name is Sarah"
print (str[0:3]+str[14:])

a) Hi, Sarah
b) Hi
c) Hi Sarah
d) Error

Q: Select a valid identifier that can be used as a Python variable
a) 44Var
b) 6MySum
c) True
d) Sum

Q: Select the Python statement that will print,

Hi-Sarah-

a) print(Hi, -, Sarah)
b) print(Hi- , -Sarah-)
c) print(Hi- + -Sarah-)

Q: What is the type of the variable iNum in the statement below?



iNum = 2

a) Boolean
b) Integer
c) Float
d) String
e) None of the above
Q: What would be the output of the following algorithm?
1) Start
2) iNum1 = 1
3) iNum2 = -1
4) iNum3 = 0
5) iNum2 = (iNum1 * iNum2) * 1
6) iNum2 = iNum3 - (iNum2 * iNum1)
7) Write iNum2
8) Stop

a) 0
b) 2
c) -1
d) 3


Q: What is the output of the following Python statement?

str="Sarah"
print (str[:1])

a) s
b) Sa
c) Sarah
d) None of the above


Q: What is the output of the following Python statements?

word = "Hi Sarah"
word = word.replace("Hi", "Salam Aleykoum")

print(len("word"))

a) 8
b) 21
c) 17
d) 19

Q: What will the following code print if x = 0, y = 1, and z = -1?

if x < y and x < z:
print("a")
elif y < x and y < z:
print("b")
else:
print("c")

a) a
b) b
c) c


Q: Assume x = 0 and y = 1, Which of the following is true?
a) x < 2 or y < 2
b) x < 2
c) A and B are correct
d) None of the above is correct


Program:

Q: Write a Python program that ask a user to input his/her name and age. Then, check the age. If
age is greater than or equal to 18 years old, the program should print the following two messages:

I am <Name> and I am <Age> years old.
I am old enough to get driving license.

Otherwise, the program should print the following two messages:

I am <Name> and I am <Age> years old.
I am NOT old enough to get driving license.

Das könnte Ihnen auch gefallen