Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
43 views

XI PythonReview

This document provides a review of key concepts in Python including the interactive shell, data types, operators, conditional statements, loops, functions, modules and classes. It contains multiple choice questions to test understanding with answers provided.

Uploaded by

Annmary Joseph
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
43 views

XI PythonReview

This document provides a review of key concepts in Python including the interactive shell, data types, operators, conditional statements, loops, functions, modules and classes. It contains multiple choice questions to test understanding with answers provided.

Uploaded by

Annmary Joseph
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

International Indian School Jeddah b. Z=x*x*x+y*y*y-math.

sqrt(xy)/2a
Review of Python c. Z=x*xx+yy*y-sqrt(xy)/2a
1. __________ is command line shell which d. Z=x*x*x+y*y*y-math.sqrt(x*y)/2*a
gives immediate result for each 8. Write the equivalent python expression
statement. for the following:
a. Script mode Z= log(√ a3 +b 3)
b. Interactive mode a. math.log(math.sqrt(math.pow(a,3)+
c. Interpreter math.pow(b,3)))
d. Compiler b. math.log(math.sqrt(pow(a,3)+pow(b,
2. “>>>” is called _________ which indicates 3)))
that you are in interactive mode. c. log(sqrt(math.pow(a,3)+math.pow(b,
a. Byte code 3)))
b. Keyword d. math.log(math.sqrt(math.pow(3)+ma
c. Script th.pow(3)))
d. Python prompt
3. print(“My Escape \\ Character”) 9. Will the following program execute
a. My Escape character successfully? If not, state the reasons.
b. My Escape \\ character s1=s2=0
c. My Escape \ character for x in range(0,11):
d. Type error num=int((“Enter the number:”))
4. Identify a suitable data type for the value (num>0)
 4+22j. s1=s1+num
a. Integer number else:
b. Floating point number s2=s2/num
c. Complex number print(“%d %d” %(s1,s2))
d. String 10. Find the output for the following :
5. A python list can have heterogeneous str='aNDarIeL'
data. (T/ F) nstr=""
6. Which of the following are tokens of for i in range(len(str)):
python? if str[i].isupper():
a. Keywords, identifiers, literals, nstr=nstr+str[i].lower()
punctuators else:
b. Keywords, identifiers, iterators, nstr=nstr+str[i].upper()
conditional statements print(nstr)
c. Keywords, identifiers, separators, a. False
literals b. AndARiEl
d. All of the above c. ANdaRieL
7. Write the equivalent python expression d. True
for the following: 11. Find the output for the following code:
Z= x 3+ y 3-√ xy / 2a t=['L','A','N','D']
Assume that x=3 and y=4 x=0
a. Z=x*x*x+y*y*y-sqrt(xy)/2a while(x<4):
y=0 # Program to find the sum of geometric
while(y<=x): series
print(t[y],end=' ') import math
y=y+1 a=int(input("Enter the term:"))
x=x+1 r=int(input("Enter the common ratio of
print() the term:"))
12. Which string method is used to n=int(input("Enter total terms:"))
implement the following : s=0
a. To count the number of characters in i=1
the string. while(i<=n):
b. To change the first character of the pw=__________________ # Power of a
string in capital letter. number r
c. To check whether given character is a s=____________________
letter or a number. i=_____________________
d. To change lower case to upper case print("Sum =", s)
letter. 16. Rewrite the following loops into while
e. To change one character into another loops:
character. a. for a in range(25,500,25):
13. A __________ is a container of unordered print(a)
set of elements. They are python’s b. for a in range(90,9,-9):
mapping type. print(a)
a. List 17. write the output for the following code:
b. Tuple s='IndianFESTIVALS'
c. Dictionary i=0
14. Find the output for the following code: while i<len(s):
n=3 if(s[i].islower()):
x=5 print(s[i].upper(), end='')
p=1.0 if(s[i].isupper()):
sum1=1.0 print(s[i].lower(),end='')
for i in range(1,n): i+=1
f=1 18. Write the output for the following string
for j in range(1,i): functions:
f=f*j s=’congratulations’
p=p*x a. print(s.capitalize)
p1=p/f ___________________
sum1=sum1+p1 b. print(s.replace(‘a’,’@’))____________
print("%.2f" %sum1) c. print(s.swapcase())________________
15. Below is a program to generate the given d. print(s.partition('t'))_______________
series. e. print(s.split('ul',7))________________
S=a + ar + ar 2+ ar 3 +…..+ ar n f. print(s.split('a'))__________________
Complete the missing lines of code. 19. Find the output of the following code:
n=7
for i in range(0,n+1,2): d. Alternate characters from reversed s
for j in range(0,i+1,2): 27. Find the output for the following :
print(i,end='') s="hello"
print() rs="_"
20. Write pattern generated through the for ch in s:
following code: rs=ch+rs
n=int(input("enter the limit:")) print(s+rs)
for i in range(1,n+1):
for k in range(n-i,0,-1):
28. Carefully go through the code given
print(' ',end=' ')
for j in range(1,i+1): below and answer the questions based on
print("*",end=' ') it:
print(" ") inputStr=input("Give me a string")
21. How many times the following loop will bigInt=0
execute: littleInt=0
i=4
otherInt=0
while(i<25):
print(i) for ele in inputStr:
i+=4 if ele>='a' and ele<= 'm': # Line 1
littleInt=littleInt+1
22. Which list method is used to implement elif ele> 'm' and ele <= 'z':
the following? bigInt=bigInt+1
a. To remove an individual item or to else:
remove all items identified by a slice.
otherInt=otherInt+1
b. To remove a single element and
return it. print(bigInt) # Line 2
23. Keys are mutable in Dictionaries print(littleInt) # Line 3
(True/False) print(otherInt) # Line 4
24. State true or false if the syntax and print(inputStr.isdigit()) # Line 5
output below is correct: a. Given the input 1+2=3 what output is
>>> T1=’hello\ produced by Line 5?
World
1. 0 2. 1 3. True 4.
>>> T1
‘helloWorld’ False
25. Write a program to generate the b. Given the input Hi Mom what output is
following pattern: produced by Line 4?
2 1. 1 2. 2 3. 3 4. None of
22
222 these
2222
29. Predict the output:
22222
dct={}
dct[1]=1
dct['1']=2
dct[1.0]=4
26. Given a string s, write expression to print: sum1=0
a. First five character of s for k in dct:
b. Ninth character of s print(k,"\t",sum1)
c. Reversed s
sum1+=dct[k]
print(sum1)

30. Predict the output:


box={}
container={}
jars={'Jam':4}
crates={}
box['biscuit']=1
box['cake']=3
container['box']=box
container['jars']=jars
print(len(container['box']))

31. Which of the following are the possible


outcomes of the code given below?
import random
r=random.random()*10
print(r,end=' ')
r=random.random()*10
print(r,end=' ')
r=random.random()*10
print(r)

a. 0.5 1.6 9.8


b. 10.0 1.0 0.0
c. 10.0 5.6 8.7
d. 0.0 7.9 10.0
32. Find the correct output for the code given
below:
import statistics as st
v=[7,8,8,11,7,7]
m1=st.mean(v)
m2=st.mode(v)
m3=st.median(v)
print(m1,m2,m3)

a. 7 8 7.5
b. 8 7 7
c. 8 7 7.5
d. 8.5 7 7.5

You might also like