26 solutions available
Question 1Consider the following code fragment :while n = 3 print n == 3(a) What will be the output of above code ?(b) What is the reason...
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 1Which of the following are invalid conditional statements of Python?IFTest ifif-elseif-elififif-elif-else
Question 2Which of the following is/are not a valid Python loop ?forwhileiterrepeat
Question 3Which of the following is used to define a block of code (e.g., body of if or body of a loop) in Python ?{ }( )indentationQuotation
Question 4What is the output of following code ?if None : print "Up" else: print "Down"UpDownNo outputUp Down
Question 5What will be the output of following code ?for i in range(1) : print i01No outputError in code
Question 6What will the output of following code ?for i in range(1, 0) : print i01No outputError in code
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 2What are looping 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 6What is following code doing ? What would it print for input as 3 ?n = input( "Enter an integer:" ) if n < 1 : print "invalid value"...
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.