Python Week 4 Quiz Answers
Disclaimer for Pruto-ai
If you require any more information or you have any problem regarding Copyright or have any questions about our site’s disclaimer, please feel free to contact us by email at contact@prutor-ai.com.
All the information on this website is published in good faith and for general information and educational purpose only. Prutor-ai does not make any warranties about the completeness, reliability, and accuracy of this information. Any action you take upon the information you find on this website (Prutor-ai.blogspot.com), is strictly at your own risk. will not be liable for any losses and/or damages in connection with the use of our website.
In this students get weekly assignments that they have to complete every week. Here we will show you or give you all the answers for the python quiz, These answers are for all those who have confusion in the questions or they don’t want to submit wrong answers.
Q:1. How do you declare a dictionary in python ?
·
dict [“key”:”value”]
·
dict = {“key”:”value”}
·
Dict = {“key” - “value”}
·
Dict = [“key”:”value”]
Answer: dict = {“key”:”value”}
Reason: Dictionary id listed
in curly brackets inside these curly brackets, key and value are declared, each
key is separated from its value by a colon (:), while commas separate each
element.
Q:2. What will be the output of the following code:
dict = { x:x
for x in range(1,2) }
print(dict)
·
{}
·
{x:x,x:x,x:x}
·
{1: 1, 2: 2}
·
{1: 1}
Answer: {1: 1}
Reason: As the for loop runs
upto one hence {1:1} will print.
Q:3. In python 3.x, Which of the following statement is true
for following code:
age = input
(“Please enter your age”)
·
Age will be integer type.
·
It removes trailing spaces.
·
age variable's type will be Whatever type is
given to it
·
None of the above
Answer: None of the above
Reason: We are asking for the
age in the age = input("Please enter your age"), hence none of the
above statement is true hence answer is none of the above.
Q:4. What will be the output of the following program ?
int =5
while int
<=-1:
print
(int)
int = int
-1
·
3
2
·
blank(nothing will be printed)
·
5
4
3
·
5
4
3
2
1
Answer: blank(nothing will be printed)
Reason: As in the program
while condition is not true hence it will not run, and out side the while loop
nothing is printed therefore second option is correct.
Q:5. What will be the output of the following program ?
int =3
while int
>=2:
print (int)
int = 1
·
3
·
2
·
3 2
·
Error in code
Answer: 3
Reason: while condition is
satisfied hence it will print 3 as it declared above. But in end int = 1 it
will not print as print statement is not written.

Social Plugin