Python Revision Tour Functions HW Worksheet 2 12E
Python Revision Tour Functions HW Worksheet 2 12E
1|Page
CS(083)-CLASS XII
n1, n2 = 0,1
count = 0
if n < = 0:
print(“Please enter positive number”)
elif _____ #1:
print(‘Fibonacci series upto”, n, “:”)
print(_____ #2)
else:
print(“Fibonacci sequence: “)
while count < n:
print(n1)
n3 = ______ #3
n1 = n2
n2 = ______ #4
count = _____ + 1 #5
7. Data types are the classification or categorization of data item. It represents the
kind of value that tells what operations can be performed on a particular data.
Since everything is an object in Python programming, data types are actually
classes, and variables are instance ( object ) of these classes.
Python has following built -in data types : Numeric, Sequence type, Boolean , set,
mapping.
1. What do you mean by sequence data types?
2. List the types of numeric data type,
3. How many values are there in Boolean data type?
4. What is the use of None?
5. Write the output of:
>>>type(“Apple”)
>>>list(“Apple”)
8. Write a python program to find the sum of the following series :
1 + 12 + 123 + 1234 + … upto N terms, using void function repeat(N)
9. Write a python program to find and display all the palindrome nos. from a tuple
elements.
10. Write a python program to count and display all the perfect nos. from a list of
elements using void function def LPerfect(L)
[Hint: Perfect no. – A perfect no. is a no. which is the sum of all its factors except
the no. itself. E.g. – 6 is a perfect no. Factors = 1,2,3. Sum of factors = 1 + 2 + 3 =
6]
Sample Input: L = [10,6,2,21,14,28]
Sample Output: Perfect numbers are = 6,28
Count = 2
2|Page
CS(083)-CLASS XII