XII Cs
XII Cs
(i) a = 3 - 4 + 10 2
b=5*6
c = 7.0/8.0
print ( "These are the values:", a, b, c )
(ii) 12 + ( 3 % 4 ) // 2 + 6 2
(iv) a , b = 12 , 13 2
c,b=a*2,a/2
print ( a , b , c )
b. Mark True/False: 2
(i) While statements gets executed at least once
(ii) The break statement allows us to come out of a loop
(iii) The continue and break statement have same effect
(iv) We can nest loops
(v) We cannot write a loop that can execute forever.
(vi) Checking condition in python can be done by using the if-else statement
Modify the program so that it answers "That is great!" if the answer was "yes", "That is
disappointing" if the answer was "no" and "That is not an answer to my question." otherwise.
Q2.
a. Predict the output of the following code: 2
(i) x = 3
if x > 2 or x < 5 and x = = 6 :
print ( “TRUE” )
else :
print ( “FALSE” )
(ii) x = 2 2
y=3
for i in range ( y * 2 – x ) :
print ( i )
c. Which is said to be entry controlled loop? Why? Write its syntax with suitable example. 4
Q3.
a. Consider the string str = “ Green#Revolution “. Write statements in Python to implement the
following: ( # represents space ) 4
(i) To display the last character.
(ii) To display the first character
(iii) To find the length
(iv) To repeat / display the string 3 times
c. Write a Python code to display the string ‘ GOOD DAY ‘ in block letters. 2
Q4.
a. Write a program that asks two people for their names; store the names in variables called name1 and
name2; Say hello to both of them. 2
b. Write a script that asks a user for a number. Then add 3 to that number, and then multiply the result
by 2, Subtract twice the original number, then print the result. 4
c. Print all multiples of 10 that are smaller than 100. Use the range function in the following manner:
range (start, end, step) where "start" is the starting value of the counter, "end" is the end value and
"step" is the amount by which the counter is increased each time. 4