0% found this document useful (0 votes)
13 views3 pages

XII Cs

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views3 pages

XII Cs

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Q1.

a. What will be the output of the following code:

(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

(iii) Status = False 2


y = 200
while Status :
print (y)
y = y – 10
if x < 50 :
Status = True

(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

c. answer = input("Do you like Python? ") 2


if answer == "yes":
print "That is great!"
else:
print "That is disappointing!"

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 )

(iii) for z in range ( -100 , 100 , 100 ) : 1


print ( z )

b. Explain pass and continue with suitable examples. 3

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

b. Write a Python code to display the word ‘ WELCOME ‘ letter by letter. 2

c. Write a Python code to display the string ‘ GOOD DAY ‘ in block letters. 2

d. ‘ + ‘ operator ___________ the strings on both sides of the operator. 1

e. Write short notes on Comments in Python. 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

You might also like