1. What is the value of x after this sequence of instructions is carried out?
x=0
for i in range(10):
x=x+1
a. 10
b. 11
c. 12
d. 13
2. What is the correct syntax to take input from user in Python?
a. x=input()
b. x-input
c. x=input_user
d. input(x)
3. What is the value of a after this sequence of instructions is carried out?
a=0
while(a<10)
a=a+1
a. 9
b. 10
c. 11
d. 12
4. What is the output of the following snippet if 5 is given as the input?
c=input("Enter a number")
print(c*3)
a. 15
b. 555
c. 5
d. 3
5. What is the value of k at the end of the following sequence of instructions?
k=20
x=9
x=x*3
k=x+5
a. 20
b. 32
c. 0
d. 9
Answers
(1) Option(a)
There should be print statement.
x = 0
for i in range(10);
x = x + 1.
print(x)
Output:
1
2
3
4
5
6
7
8
9
10
(2) Option(a)
The correct syntax is x = input()
Example: x = input("Enter your name: ")
print(x)
(3) Option(b)
Note: There should be print statement.
a=0
while(a<10)
print (a)
a=a+1
Output:
0
1
2
3
4
5
6
7
8
9
(4) Option(b)
c = input("Enter a number")
print(c*3)
Output:
Enter a number: 5
555
(5) Option (B):
k = 20
x = 9
x = x*3
k=x+5
Output:
x = 9 * 3 = 27
k = x + 5 = 27 + 5 = 32
<!Hope it helps!>
1.Option(a)
There should be print statement.
x = 0
for i in range(10);
x = x + 1.
print(x)
Output:
1
2
3
4
5
6
7
8
9
10
(2) Option(a)
The correct syntax is x = input()
Example: x = input("Enter your name: ")
print(x)
(3) Option(b)
Note: There should be print statement.
a=0
while(a<10)
print (a)
a=a+1
Output:
0
1
2
3
4
5
6
7
8
9
(4) Option(b)
c = input("Enter a number")
print(c*3)
Output:
Enter a number: 5
555
(5) Option (B):
k = 20
x = 9
x = x*3
k=x+5
Output:
x = 9 * 3 = 27
k = x + 5 = 27 + 5 = 32
#skb