You are on page 1of 12

PRACTICAL FILE

Subject - Computer Science

Name – Bhavay Rustagi

Roll no.- 11

Class - 11th Science A1

Submitted To – Mr. Saurabh


Bhatnagar
CH-7- PYTHON FUNDAMENTALS

# SIMPLE INPUT AND OUTPUT

OUTPUT:

enter youe name:BHAVAY RUSATGI


BHAVAY RUSATGI

CH-8- DATA HANDLING

# OPERATORS
QUES:What will be the output produced by the
following code ?
an.rwer.

OUTPUT:
2.3 2.0
16.0
10.0
1.2
# WORKING WITH MATH MODULE OF PYTHON

QUES:The radius ofa sphere is 7.5 meters. Write


python script to calculate its area and volume ?
an.rwer.

Output:

radius of the sphere: 7.5 meters


area of the sphere: 176.71458676442586 units square
volume of the sphere: 5301.437602932776 units cube

#USING RANDOM MODULE


QUES:Write a code fragment to generate a random
floating number between 45.0 and 95.0 .Print this
number along with its nearest integer greater than
it .
an r.

Output:
random numbers between 45..95:
83.62339196051849
nearest higher integer: 84
CH-9-FLOW OF CONTROL

#THE IF STATEMENT OF PYTHON


QUES:Program that takes a number and checks
whether the given number is odd or even .
an.rwer.

Output:
enter an integer:8
8 is even number

# ITERATION / LOOPING STATEMENTS


QUES:Program to print table of a number,say 5 .
an.rwer.

Output:
5x1=5
5 x 2 = 10
5 x 3 = 15
5 x 4 = 20
5 x 5 = 25
5 x 6 = 30
5 x 7 = 35
5 x 8 = 40
5 x 9 = 45
5 x 10 = 50
CH-10-STRING MANUPULATION

# TRAVERSING A STRING

Output:
B -H -A -V -A -Y - -R -U -S -T -A -G -I -

# STRING OPERATORS
QUES:Write a program that asks a user for a
user name and a code.Ensure that the user
dosen’t use their username as a part of their
code.
an.rwer.

Output:
enter user name:kobe
enter a code:mykobeworld
your code should not contain user name.
thank you

# STRING SLICES
QUES:Write a program to input two string1 is
contained in string2 then create a third string
with first four character of string2’added with
word ‘Restore’.
an.rwer.
Output:
enter string 1:rin
enter string 2:shagrin
original string : rin shagrin
final string : rin shagrestore

# STRING FUNCTION AND METHODS


QUES:Program that reads a line and a substring.
It should then display the number of
occurrences of the given substring in the line.
an.rwer.

Output:
enter line:jingle bells jingle bells jingle all
the way
enter substring:jingle
No. of occurrences of jingle : 3
CH-11-LIST MANIPULATION

#LIST OPERATIONS
QUES:Write a program to create a copy of a
list.In the list’s copy,add 10 to its first and
last elements.Then display the lists.
an.rwer.

Output:
original list: [17, 24, 15, 30, 34, 27]
created copy of the list: [17, 24, 15, 30, 34, 27]
copy of the list after changes: [27, 24, 15, 30, 34, 37]
original list: [17, 24, 15, 30, 34, 27]

#LIST FUNCTION AND METHODS


QUES:Write a program to sorted a list and
reverse it also.
an.rwer.

Output:
sorted: [15, 17, 24, 30]
reverse: [30, 24, 17, 15]
#NESTED LOOP

QUES:Program to create a 2D list.


an.rwer.

Output:

How many rows? :3


How many columns? :3
ELEMENT 0,0:2
ELEMENT 0,1:3
ELEMENT 0,2:4
ELEMENT 1,0:22
ELEMENT 1,1:32
ELEMENT 1,2:43
ELEMENT 2,0:50
ELEMENT 2,1:60
ELEMENT 2,2:70
list created is : [[2, 3, 4], [22, 32, 43], [50, 60, 70]]

#WORKING WITH LISTS (LIST MANIPULATION


QUES:Write a program that ask the user to input
a number a list to be appended to an existing
list.Whether the user enters a single number or
a list of number,the program should append the
list accordingly.an.rwer.
Output:
Existing list is: [2, 4, 6]
Enter a number or a list to be appended:17
Appended list is : [2, 4, 6, 17]

CH-12-TUPLES

#TUPLE OPERATORS
QUES:Write a program to input a tuple and
create two new tuples from it,one containing
its every 3rd elements in reverse order,
starting from the last elements another
containing every alternate elements lying
between 3rd to 9th elements.
an.rwer.

Output:
Enter input for tuples:1,2,3,4,5,6,7,8,9,10,11
Two created tuples are:
tuple 1 : (11, 8, 5, 2)
tuple 2 : (3, 5, 7)

#TUPLE FUNCTION AND METHODS


QUES:A tuple t1 stores(11,21,31,42,51),where
its second last element is mistyped.Write a
program to created its second last element as
41.
an.rwer.
Output:
Modified tuple: (11, 21, 31, 41, 51)

#NESTED TUPLES
QUES:A student’s roll number,name and marks in
5 subjects are available in the form of a tuple
as shown here:student(11,’Ria’(67,77,78,82,80))
Write a program to print the minimum and
maximum marks along with total marks obtained
by the student.
an.rwer.

Output:
Minimum marks obtained : 67
Maximin marks obtained : 82
Total marks obtained : 384

CH-13-DICTIONARIES

#WORKING WITH DICTIONARIES


QUES:Write a program to create a dictionary
namely Numerals from following two lists.
an.rwer.
Output:
Given two lists are: ['one', 'two', 'three'] [1, 2, 3]
Dictionary created with these lists is
{'one': 1, 'two': 2, 'three': 3}

#DICTIONARY FUNCTIONS AND METHODS


QUES:Write a program to print the
maximum,minimum,sum of keys of numbers
dictionary as given below.
numbers={1:111,2:222,3:333,4:444}
Also individually find minimum,maximum and sum
of values.
an.rwer.

Output:
Given dictionary is : {1: 111, 2: 222, 3: 333, 4: 444}
Maximum and Minimum keys: 4 1
Maximum and Minimum values 444 111
Sum of dictionary's keys : 10
Sum of dictionary's values: 1110

You might also like