[Type B] Chapter– 1 Class 12 CS – Sumita Arora Assignment | Q/A

Here is class 12 computer science Unit 1 [Type B] solutions for Sumita Arora back exercise assignment. Below includes both textual and video solutions wherever required. View all the answers in assignment for chapter 1 and for all chapters here.

Watch all tutorials for chapter 1: Python Revision Tour – 1.

Q1: Fill in the missing lines of code in the following code. The code reads in a limit amount and a list of prices and prints the largest price that is less than the limit. You can assume that all prices and the limit are positive numbers. When a price 0 is entered the program terminates and prints the largest price that is less than the limit.

Solution:

limit = float(input("Enter the limit"))
max_price = 0
next_price = float(input("Enter a price or 0 to stop:"))
while next_price > 0:
if next_pricemax_price and next_price>max_price:
max_price =next_price
next_price = float(input("Enter a price or 0 to stop:"))
if max_price > 0:
print('The largest price', max_price)
else :
print("No! price satisfy the condition")
Q2: Predict the outputs of the following programs:

Solution:

Q3: Find and write the output of the following python code:

Solution:

Jayes
Finished!
Ramya
Finished!
Taruna
Got it!
Q4: How many times will the following for loop execute and what’s the output?

Solution:

(a) No output
Reason: In proper range() parameter passed.

(b) output is follow:
*
*
*
*
*
In total loop execute total 5 times.
Q5: Is the loop in the code below infinite? How do you know (for sure) before you run it?

Solution:

No, the loop is not infinite and the conclusion is come into account through limit of while loop and terminating case in that.

Clear Doubts with Computer Tutor
In case you’re facing problems in understanding concepts, writing programs, solving questions, want to learn fun facts | tips | tricks or absolutely anything around computer science, feel free to join CTs learner-teacher community: students.computertutor.in