You are on page 1of 2

Python Programming

CIE-I
Scheme and Solution
1.
 Simple and easy to learn
 Open source
 High level language
 Dynamically typed
 Platform independet
 Portable
 Procedure and Object oriented 2 marks

1 mark
Explaining PVM 2 marks
2.
Define iteration 1 mark

1 mark
While loop:
Syntax:
while condition:
statements
For loop:
Syntax:
For var in sequence:
statements
• Retrieves elements from a sequences and executes the statements.
• Statements are executed as many times as there are number of elements in the
sequences. 3 marks
3. Classification based on nature:
1. Arithmetic operator
2. Assignment operator
3. Unary operator
4. Relational operator
5. Logical operator
6. Boolean operator
7. Bitwise operator
8. Membership operator
9. Identity operator 2 marks

Explaining 3 marks

4. Syntax:
def function name (list of parameters):
body of the function 1 mark
Code to generate Fibonacci sequence:
def fib(n):
if n == 0 or n == 1:
return 1
else:
return fib(n-1)+fib(n-2)
for i in range(10):
print(fib(n)) 4 marks

5. def sumofsq(n):
sum = 0
for i in range(1, n+1):
sum+=i*i
return sum 3 marks

n = int(input(‘Enter value of n:’ ))


print(sumofsq(n)) 2 marks

6. x = int(input(‘Enter an integer:’))
ans = 0
while ans**3 < abs(x):
ans = ans+1
if ans**3 != abs(x):
print(x, ‘is not a perfect cube’)
else:
if x<0:
ans = -ans
print(‘cube root of’, x ‘is:’ ans) 5 marks

You might also like