In: Computer Science
In Python
Dividing by zero is an example of which type of error?
| a. | 
 runtime  | 
b. | 
 syntax  | 
c. | 
 logic  | 
d. | 
 None of the previous  | 
In the statement:age = input('Enter your age: '), the string 'Enter your age: ' is called a(n) _____.
| a. | 
 prompt  | 
|
| b. | 
 prefix  | 
|
| c. | 
 variable  | 
|
| d. | 
 assignment  | 
|
| e. | 
 None of the above  | 
Fill in the blank so that the loop displays all odd numbers from 1 to 100.
i = 1
while i <= 100:
    print(i)
    i = _____
| a. | 
 1  | 
|
| b. | 
 i + 1  | 
|
| c. | 
 2  | 
|
| d. | 
 i + 2  | 
|
| e. | 
 None of the above  | 
How many times does the following loop iterate?
i = 5
while i < 10:
    print(i)
    i = i + 1
| a. | 
 0  | 
|
| b. | 
 4  | 
|
| c. | 
 5  | 
|
| d. | 
 6  | 
|
| e. | 
 None of the above  | 
Hi,
Please find answers for your questions.
Hope this answers helps you.
Q) Dividing by zero is an example of which type of error?
Ans :- a) Runtime ( When Python script executes and try to divide 2 numbers for e.g. a/b where denominator (b) is zero then ZeroDivision Exception can be occurred. So this values are depends on user input and python will know at a time of script execution only that's why its is Runtime )
Q) In the statement:age = input('Enter your age: '), the string 'Enter your age: ' is called a(n) _____.
Ans:- a) prompt (Python has input method which takes user input and 'prompt' represents default message before input )
Q) Fill in the blank so that the loop displays all odd numbers from 1 to 100.
i = 1
while i <= 100:
    print(i)
    i = _____
Ans:- d) i+ 2
( So in question i start with 1 and goes in while loop till i does met i<=100 condition. so in first loop it prints 1 and i=i+2 will increment i to 3 which odd number in next loop it will print 3 and again increase i = i+2 i.e. 5 and this will happen till i <= 100 and prints all odd numbers)
Q) How many times does the following loop iterate?
i = 5
while i < 10:
    print(i)
    i = i + 1
Ans :- c) 5 ( so in question i starts from 5 till i<10 in while loop i keep incrementing by 1 using i=i + 1 statement that means this condition satisfy for 5,6,7,8,9 and for 10 it won't and exit the loop)