36 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): A statement or statements (block of code)...
Question 6Assertion (A): The range() method is used with both for and while loops.Reasoning (R): By default, the values for start and step are 0...
Question 3Find error in the following code (if any) and correct it by rewriting the code and underline the corrections:code=input ("Enter season code...
Question 4(a)Give the output of the following when num1 = 4, num2 = 3, num3 = 2.num1 += num2 + num3 print(num1)
Question 4(b)Give the output of the following when num1 = 4, num2 = 3, num3 = 2.num1 = num1 ** (num2 + num3) print (num1)
Question 4(d)Give the output of the following when num1 = 4, num2 = 3, num3 = 2.num1 = '5' + '5' print (num1)
Question 4(e)Give the output of the following when num1 = 4, num2 = 3, num3 = 2.print(4.00 / (2.0+2.0))
Question 4(f)Give the output of the following when num1 = 4, num2 = 3, num3 = 2.num1 = 2 + 9 * ((3*12)-8)/10 print(num1)
Question 4(g)Give the output of the following when num1 = 4, num2 = 3, num3 = 2.num1 = float(10) print(num1)
Question 4(h)Give the output of the following when num1 = 4, num2 = 3, num3 = 2.num1 = int('3.14') print(num1)
Question 4(i)Give the output of the following:print (10 != 9 and 20 >= 20)
Question 4(j)Give the output of the following:print(5 % 10 + 10 < 50 and 29 <= 29)
Question 5What is the difference between else and elif constructs of if statement?
Question 6(a)Find the output of the following program segment:for i in range(20, 30, 2): print(i)
Question 6(b)Find the output of the following program segment:country = 'INDIA' for i in country: print (i)
Question 6(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 7(a)Write the output of the following:for i in '123' : print ("Message",i,)
Question 7(b)Write the output of the following:for i in [100,200,300] : print (i)
Question 7(c)Write the output of the following:for j in range (10,6,-2) : print (j*2)
Question 7(d)Write the output of the following:for x in range (1, 6) : for y in range (1, x+1): print (x, ' ', y)
Question 7(e)Write the output of the following:for x in range (10, 20): if (x == 15): break print(x)
Question 7(f)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 10WAP 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 11WAP to perform all the mathematical operations of a calculator.Solutionprint("Select operation:") print("1. Add") print("2. Subtract")...
Question 12WAP to convert binary number to decimal number.Solutionbinary = input("Enter a binary number: ") decimal = 0 for digit in binary:...
Question 13WAP to find the sum of the digits of a number.Solutionnumber = int(input("Enter a number: ")) sum_of_digits = 0 while number > 0:...
Question 14Write a function to display prime numbers below 30.Solutiondef prime_numbers(): for num in range(2, 30): for i in range(2,...
Question 15WAP to print the sum of the series 1 - x1/2! + x2/3! - x3/4! ............... xn/(n + 1)! — exponential series.Solutionx = int(input("Enter...
Question 16WAP to print the sum of the series 1 - x2/4! + x3/6! - x4/8! + x5/10! ............... xn/(2n)! — exponential series.Solutionx =...
Question 17WAP 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 18(a)WAP to print the following pattern:* * * * * * * * * * * * * * * Solutionn = 5 for i in range(1, n + 1): for j in range(i):...
Question 18(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 18(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):...