Conditional and Looping Constructs Preeti Arora Class 11 Information Practices Solution
Note :- Please Click on Question to Answer of that Question !!!
Q1. What are compound statements?
Q2. What are jump statements?
Q3. What is nested loop? Explain with an example.
Q4. What is the significance of updating loop control variable in while
statements?
Q5. Construct a logical expression to represent each of the following
conditions:
(i) Mark is greater than or equal to 100 but less than
70
(ii) Num is between 0 and 5 but not equal to 2
(iii) Answer
is either 'N' OR 'n'
(iv) Age is greater than equal to 18 and gender
is male.
(v) City is either 'Kolkata' or 'Mumbai'.
Q6. Find error in the following code (if any) and correct it by rewriting
the code and underline the corrections:
code = input ("Enter season
code: ")
if code = w:
print "winter
season"
elif code == r:
PRINT "rainy season"
else:
Print 'summer
season'
Q7. Write the output of the following:
(i)
for i in '123':
print ("guru99", i,)
(ii)
for i in [100, 200,300]:
print (i)
(iii)
for j in range (10, 6,-2):
print (j*2)
(iv)
for x in range (1, 6):
for y in range (1, x+1):
print (x, ' ', y)
(v)
for x in range (10, 20):
if (x == 15):
break
print (x)
(vi)
for x in range (10, 20):
if (x % 2 == 0):
continue
print (x)
Q8. Write the output of the following program on execution if x = 50.
if
x >10:
if x >25:
print('ok')
if x >60:
print ("good")
elif x >40:
print("average")
else:
print ("no output")
Q9. Write the output of the following code:
if i in range (2):
for j in range (1):
if i+2
== j:
print ("+", end = "")
else:
print("o", end = "")
Q10. Draw a flow chart to find all the roots of a quadratic equation
ax²+bx+c=0.
Q11. What is a flow chart? Explain its various symbols with their
associated task.
Q12. Which of the following Python snippet (code) given below implements
the control flow graph shown?
(a)
while True:
n = int(input ("Enter an integer: "))
if n ==
a1:
continue
elif n == a2:
break
else:
print ("what")
print
("ever"}
(b)
while True:
n = int(input
("Enter an integer: "))
if n == a1:
continue
elif n == a2:
break
else:
print("what")
else:
print ("ever")
(c)
while
True:
n == int(input ("Enter an integer: "))
if n == a1:
continue
elif n == a2:
break
print
("what")
print ("ever")
Q13. Write a program to check if a number is positive or negative and
display an appropriate message.
Q14. WAP to convert temperature in Fahrenheit into Celsius.
Q15. WAP to display even numbers between 10 and 20. Draw its flow chart
also.
Q16. WAP to perform mathematical calculator.
Q17. Write a program along with the flow chart to accept a number and
display the factorial of a number.
Q18. WAP to convert a binary number into decimal number.
Q19. WAP to find the sum of the digits of a number.
Q20. Write a function to display prime numbers below 30. Give its flow
chart also.
Q21. WAP to print the sum of the series 1-x¹/2! + x²/3!-x/4…..xn/(n + 1)!
exponential series.
Q22. WAP to print the sum of the series 1-x²/4! + x3/6! –x4/8! +
x5/10!......xn/(2n)!- exponential series.
Q23. WAP to display the sum of the given series:
Sum=1 + (1+2) +
(1+2+3) + (1+2+ 3.....n)
Q24. WAP to print the following pattern:
*
**
***
****
*****
Q25. WAP to print the following pattern:
A
BB
CCC
DDDD
EEEEE
Q26. WAP to print the following pattern:
1
21
321
4321
54321
Q27. What is the following code doing? What would it print if input is
3?
n = int(input ("Enter an integer: "))
if n < 1:
print ("Invalid value")
else:
for i in range
(1, n + 1):
print ( i *
1)
Q28. Rewrite the code fragments using while loops:
(a)
min
=0
sum =0
max = num
if num < 0:
min = num #compute sum of integers from min to max
max =0
for i
in range (min, max + 1):
Sum += i
(b)
for
i in range (1, 16):
if i % 3 == 0:
print (i)
(c)
for i in range (4):
for j
in range (5):
if i + 1 ==
j or j + i == 4:
print ("+", end = ;)
else:
print("o", end = "")
print ()
Q29. Write a Python script that asks the user to enter length in
centimetres. If the user enters a negative length the program should tell
the user that the entry is invalid. Otherwise, the program should convert
the length to inches and print out the result. There are 2.54 centimetres
in an inch.
Q30. A year is a leap year if it is divisible by 4, except for those
years that are divisible by 100, unless they are also divisible by 400.
Write a program that asks the user for a year and print out whether it is
a leap year or not.
Q31. Write a program to input length of three sides of a triangle. Then
check if these sides will form a triangle or not. (Rule is: a+b> c;
b+c>a; c+a> b)
Q32. Write a short program to find the largest number out of a list of
numbers entered through the keyboard.
Q33. Write a Python program to print every integer between 1 and n
divisible by m. Also report whether the number that is divisible by m is
even or odd.
Q34. Write a program to accept the age of n employees and count the
number of persons in the following age group:
(i) 26-35
(ii)
36-45
(iii) 46-55
Q35. Given three numbers A, B and C, write a program to write their
values in ascending order.
For example:- if A=12, B-10 and C= 15,
your program should print out:
Smallest number = 10
Next higher
number = 12
Highest number = 15
Q36. Write a program to calculate correlation coefficient
after collecting data about 10 of your classmates in the form of:
Q37. Write a program to calculate standard deviation for a batsman's
score in 10 matches.
Post a Comment
You can help us by Clicking on ads. ^_^
Please do not send spam comment : )