39 solutions available
Question 1Assertion (A): When a set of statements is indented under the same block, starting from the same indentation, it is said to be a compound...
Question 2Assertion (A): The conditional flow of control is implemented using if statement.Reasoning (R): if statements can only be used to execute a...
Question 4Assertion (A): When a Python code is unable to accept an input, it results in runtime error.Reasoning (R): Runtime error arises due to...
Question 5Assertion (A): The break and continue statements are known as jump statements.Reasoning (R): Jump statements are used only with looping...
Question 3What is nested loop? Explain with example.
Question 6Find error in the following code (if any) and correct it by rewriting the code and underline the corrections:code=input ("Enter season code...
Question 7(i)Write the output of the following:for i in '123': print("guru99",i,)
Question 7(ii)Write the output of the following:for i in [100,200,300] : print (i)
Question 7(iii)Write the output of the following:for j in range (10,6,-2) : print (j*2)
Question 7(iv)Write the output of the following:for x in range (1, 6) : for y in range (1, x+1): print (x, ' ', y)
Question 7(v)Write the output of the following:for x in range (10, 20): if (x == 15): break print(x)
Question 7(vi)Write the output of the following:for x in range (10, 20): if (x % 2 == 0): continue print (x)
Question 8Write the output of the following program on execution if x = 50:if x > 10: if x > 25: print ( 'ok' ) if x > 60:...
Question 9Write the output of the following code:for i in range (2) : for j in range (1) : if i+2 == j: print ("+",end=" ") else:...
Question 10(a)Give the output of the following when num1 = 4, num2 = 3, num3 = 2.num1 += num2 + num3 print(num1)
Question 10(b)Give the output of the following when num1 = 4, num2 = 3, num3 = 2.num1 = num1 ** (num2 + num3) print (num1)
Question 10(c)Give the output of the following when num1 = 4, num2 = 3, num3 = 2.num1 **= num2 + c print (num1)
Question 10(d)Give the output of the following when num1 = 4, num2 = 3, num3 = 2.num1 = '5' + '5' print (num1)
Question 10(e)Give the output of the following when num1 = 4, num2 = 3, num3 = 2.print(4.00 / (2.0+2.0))
Question 10(f)Give the output of the following when num1 = 4, num2 = 3, num3 = 2.num1 = 2 + 9 * ((3*12)-8)/10 print(num1)
Question 10(g)Give the output of the following when num1 = 4, num2 = 3, num3 = 2.num1 = float(10) print(num1)
Question 10(h)Give the output of the following:num1 = int(float('3.14')) print(num1)
Question 10(i)Give the output of the following:print (10 != 9 and 20 >= 20)
Question 10(j)Give the output of the following:print(5 % 10 + 10 < 50 and 29 <= 29)
Question 11What is the difference between else and elif constructs of if statement?
Question 12(a)Find the output of the following program segment:for i in range(20, 30, 2): print(i)
Question 12(b)Find the output of the following program segment:country = 'INDIA' for i in country: print (i)
Question 12(c)Find the output of the following program segment:i = 0; sum = 0 while i < 9: if i % 4 == 0: sum = sum + i i = i...
Question 13Write a program to check if the number is positive or negative and display an appropriate message.Solutionnumber = int(input("Enter a...
Question 14WAP to display even numbers between 10 and 20.Solutionfor num in range(10, 21): if num % 2 == 0: print(num)Output10 12 14 16...
Question 15WAP to perform all the mathematical operations of a calculator.Solutionprint("Select operation:") print("1. Add") print("2. Subtract")...
Question 16Write a program to accept a number and display the factorial of that number.Solutionnumber = int(input("Enter a number: ")) factorial = 1...
Question 17Write a function to display prime numbers below 30.Solutiondef prime_numbers(): for num in range(2, 30): for i in range(2,...
Question 18WAP to print the sum of the series 1 - x1/2! + x2/3! - x3/4! ............... xn/(n + 1)! — exponential series.Solutionx = int(input("Enter...
Question 19WAP to print the sum of the series 1 - x2/4! + x3/6! - x4/8! + x5/10! ............... xn/(2n)! — exponential series.Solutionx =...
Question 20WAP to display the sum of the given series:Sum = 1 + (1 + 2) + (1 + 2 + 3) + (1 + 2 + 3.....n)Solutionn = int(input("Enter the value of n:...
Question 21(a)WAP to print the following pattern:* * * * * * * * * * * * * * * Solutionn = 5 for i in range(1, n + 1): for j in range(i):...
Question 21(b)WAP to print the following pattern:A B B C C C D D D D E E E E E Solutionn = 5 for i in range(n): for j in range(i + 1):...
Question 21(c)WAP to print the following pattern:1 2 1 3 2 1 4 3 2 1 5 4 3 2 1 Solutionn = 5 for i in range(1, n + 1): for j in range(i, 0, -1):...