17 solutions available
Question 2Consider the following code fragment :n = 3 while n == 3 print n n = n - 1(a) What will be the output of above code?(b) What is the...
Question 7What is the output of following code ?while 3 >= 3 : print 33 is printed once3 is printed three times3 is printed infinitely until...
Question 1What are selection statements ? How are they useful ?
Question 3Differentiate between if and if-else statements.
Question 4Differentiate between for and while statements.
Question 5(a)Rewrite the following code fragments using for loopwhile num > 0 : print num % 10 num = num/10
Question 5(b)Rewrite the following code fragments using for loopi = 100 while (i > 0) : print i i -= 3
Question 7(a)Rewrite following code fragments using while loopsmin = 0 max = num if num < 0 : min = num max = 0 # compute sum of...
Question 7(b)Rewrite following code fragments using while loopsfor i in range(1, 16) : if i % 3 == 0 : print i
Question 8(i)Write a short program to print the following series :1 4 7 10 ........... 40.
Question 8(ii)Write a short program to print the following series :1 -4 7 -10 .......... -40
Question 9(a)Predict the output of the following code fragments :count = 0 while count < 10: print "Hello" count += 1
Question 9(b)Predict the output of the following code fragments :x = 10 y = 0 while x > y: print x, y x = x — 1 y = y + 1
Question 10What will be output of the following code if the user enters Principal amount as 20000 and Time as 10 years.#Considering Python 2.7 P =...
Question 11Write a Python script that asks the user to enter a length in centimetres. If the user enters a negative length, the program should tell...
Question 12Write a program that asks the user for two numbers and prints Close if the numbers are within .001 of each other and Not close otherwise.
Question 13Write a short program to print first n odd numbers in descending order.