Python Quiz:- 4
Q:1. How do you declare a dictionary in python?
1.
2.
3.
4.
Reason:- In Python Dictionary declare by curly braces{} and it holds pair of value, one will be the key and other corresponding element is its key:value . So the answer is Dict={"key":"value"}.
Q:2. What will be the output of the following code:
dict = { x:x for x in range(1,2) }
print(dict)
1.
2.
3.
4.
Q:3. In python 3.x, Which of the following statement is true for the following code:
age = input (“Please enter your age”)
1.
2.
3.
4.
Q:4. What will be the output of the following program ?
int =5
while int <=-1:
print (int)
int = int -1
1.
2.
3.
4.
Answer is 2.
Reason:- Here, int =5 and according to the condition while int<=-1 which will never true and blank will be printed.
Q:5. What will be the output of the following program ?
int =3
while int >=2:
print (int)
int = 1
1.
2.
3.
4.
1 Comments
please provide solution of quiz 5 and 6
ReplyDelete