Sunteți pe pagina 1din 4

Revision - Computer Literacy Class 9

1. Under what category of python can you group strings, lists and tuples ?
2. Create a string named subject and topic .
Assign the values Astrophysics, Galaxy
3.

Do the following commands :


a. subject[5:]+topic[0:3]
b. subject[5:]+topic[0:4]
c. topic+subject[5:]
d. subject[0:5]+"nomy"
e. subject[0:5]+"nomy"
f. Extract the word trophy from the string Subject
g. Extract the word Gala from the string Topic and make the string Galactic voyage
h. What will be the result of topic*3 ?
i. What happens when you give the statement subject[4]="a" ? What is the reason ?

4. Create a list named course with values Physics, Chemistry, Biology, Mathematics,
Commerce,Economics
5.

Do the following commands :


a) course[3:]
b) course[3:4]
c) course[1:3]*2
d) course[0]=subject
e) Now what will be the values in the list course ?
f) What do you conclude about lists from the above assignment ?
g) course[4:]*2

a.

Create an output statement Science students can opt for Biology or Mathematics

6.

Create a tuple myfriend with the name, age, hobby and address of your friend

7.

Create statements to generate the output as follows :

a.

My friend is

b.

He/she is

c.

He/she lives in

d.

years old

enjoys

8.

What is the difference between lists and tuples ?

9.

Create a tuple named marks with marks in 5 subjects of a student as

10.

Write a command to add all the marks and find the total.

11.

Now give the output as Your total score is

12.

Which function will you use to convert the number to a string ?

13.

Can you change the last value of marks from 310 to 330 ? Why ?

14.

Create a script named ex1.py using Input command accept First name, Last name and address of a
student with suitable prompts.

15.

Then generate the output as follows:


a. Your full name is

200,250,300,230,230 and 310

(where you show the total marks).

(Join the first name and last name)

b. You live in
16.

Create a script ex2.py and accept two positive integers a and b.

17.

This program should generate the output as follows :


a) The sum is
b) The difference is
c) The Product is
d) The quotient is
e) The square of the first number is

(Find the value of square of variable a)

18.

Name the function which you use to convert the input numbers into integers.

19.

When you join the string and the number you need to use the
function

20.

What is the difference between the int() and float() function ?

21.

In the above example when did you use the float() function ?

22.

Write the output of the following functions


(a) n = -100.5
print(abs(n))
print(math.floor(n))
(b)number = 1.23456
print(round(number))
print(round(number, 0))
print(round(number, 1))
print(round(number, 2))
print(round(number, 3))

23.

Input list as :
values = [0.9999999, 1, 2, 3]
Write the function to Sum values in list and store it in a variable add.

24.

Write a trunc function to truncate the value given in the variable value 1
value1 = 123.45
truncate1 = math.trunc(value1)
print(truncate1)

25.

Find the value of 2 raised to the power 3 using math.pow() method and also by using ** operator

26.

Store it in a variable called powerof and display the output.

27.

Give the output


a) value1 = 9
value2 = 16
value3 = 100
print(math.sqrt(value1))
print(math.sqrt(value2))
print(math.sqrt(value3))
b) list1, list2 = [123, 'xyz', 'zara'], [456, 'abc']
print "First list length

print "Second list length : "


c) list1=[123, 'xyz', 'zara', 'abc'],
d) list2 = [456, 700, 200]
print the Max value element list 1
print the Min value element list2
e) aList = [123, 'xyz', 'zara', 'abc', 'xyz'];
print alist in a reversed order
print alist after sorting
print "Count for 123 : "
print "Count for zara : "
28. s = "Kilometer"
Write python string function that return a copy of the string "Kilometer " as :
a) Lower case
b) Upper case
c) Capitalize
d) Title case

S-ar putea să vă placă și