0% found this document useful (0 votes)
59 views10 pages

Cs Hello

This document contains a student's computer science practical file submitted under the guidance of their teacher, Mrs. Sapna Sarraf. It includes 10 programming problems solved in Python with the code and output for each. The problems cover basics of Python like input/output, calculations, conditional statements, loops, and random numbers. For each problem, the student has provided the code, output, and received the teacher's remark.

Uploaded by

BHAKTI SAGAR
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
59 views10 pages

Cs Hello

This document contains a student's computer science practical file submitted under the guidance of their teacher, Mrs. Sapna Sarraf. It includes 10 programming problems solved in Python with the code and output for each. The problems cover basics of Python like input/output, calculations, conditional statements, loops, and random numbers. For each problem, the student has provided the code, output, and received the teacher's remark.

Uploaded by

BHAKTI SAGAR
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

Saint Xavier’S School, Bhiwadi

(Session 2021-2022)
C.S Practical File

Submitted By
Name: - Tanishk Goyal
Class: - 11 A
Roll No. - 48

UNDER THE GUIDANCE OF

Mrs. Sapna Sarraf


Faculty of Computer Science
Index
S.NO. Topic Teacher’s
Remark
1 W.a.p to obtain three numbers and
print their sum.
2 W.a.p to obtain length and breadth of
a rectangle and calculate its area.
3 The radius of the sphere is 7.5 metres.
Write Python script to calculate it’s are
and volume.
4 W.a.p to generate a random floating
number between 45.0 and 95.0. Print
this number along with its nearest
integer greater than it.

5 W.a.p to accept three integers and


print the largest of the three. Make use
of only if statement.
6 W.a.p display a menu for calculating
area of a circle or perimeter of a circle.
7 W.a.p to print table of a number, say 5.

8 W.a.p to print sum of natural numbers


between 1 and 7. Print the sum
progressively, i.e., after adding each
natural number, print sum so far.

9 W.a.p to input two string. If string 1 is


contained in string 2 then create a
third string with first four character of
string2 added with word “RESTORE”

10 W.a.p to input a string and check if it is


a palindrome string using a string slice.
Practical 1
Question: - Program to obtain three numbers and print
their sum.
Program-
Num1=int(input(“Enter number 1 : ”))
Num2=int(input(“Enter number 2 : ”))
Num3=int(input(“Enter number 3 : ”))
Sum=Num1+Num2+Num3
print(“Three numbers are : ”, Num1, Num2, Num3)
print(“Sum is : ”, Sum)

Output-
Enter number 1 : 7
Enter number 2 : 3
Enter number 3 : 13
Three numbers are : 7 3 13
Sum is : 23
Practical 2
Question: - Program to obtain length and breadth of a
rectangle and calculate its area.
Program-
Length=float(input(“Enter length of the rectangle : ”))
Breadth=float(input(“Enter breadth of the rectangle : ”))
Area=Length*Breadth
print(“Rectangle specifications ”)
print(“Length = ”, Length ,end= ‘’)
print(“Breadth =”, Breadth)
print(“Area =”, Area)

Output-
Enter length of the rectangle : 8.75
Enter breadth of the rectangle : 35:0
Rectangle specifications
Length= 8.75
Breadth= 35.0
Area= 306.25
Practical 3
Question: - The radius of the sphere is 7.5 metres.
Write Python script to calculate it’s are and volume.
Program-
import math
r=7.5
area=math.pi*r*r
volume=4*math.pi*math.pow(r,3)
print(“Radius of the sphere :”, r, “metres”)
print(“Area of the sphere :”, area, “units square”)
print(“Volume of the sphere :”, volume, “units cube”)

Output-
Radius of the sphere : 7.5 metres
Area of the sphere : 176.71458676442786 units square
Volume of the sphere : 5301.437602932776 units cube
Practical 4
Question: - 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.
Program-
import random
import math
fnum = random.random()*(95-45)+45
inum = math.ceil(fnum)
print(“Random numbers between 45..95:”)
print(fnum)
print(“Nearest higher integer :”, inum)

Output-
Random numbers between 45..95
48.24212504903489
Nearest higher integer : 49
Practical 5
Question- Program to accept three integers and print
the largest of the three. Make use of only if statement.
Program-
x=y=z=0
x=float(input(“Enter first number :”))
y=float(input(“Enter second number :”))
z=float(input(“Enter third number :”))
max=x
if y>max:
max=y
if z>max:
max=z
print(“Largest number is”, max)

Output-
Enter first number : 7.235
Enter second number : 6.99
Enter third number : 7.533
Largest number is 7.533
Practical 6
Question: - Program to display a menu for calculating area
of a circle or perimeter of a circle.
Program-
radius=float(input(“Enter radius of the circle :”)
print(“1. Calculate Area”)
print(“2. Calculate Perimeter”)
choice=int(input(“Enter your choice (1 or 2) :”))
if choice==1 :
area=3.14156*radius*radius
print=(“Area of circle with radius”, radius, ‘is’, area)
else:
perm=2*3.14156*radius
print(“Perimeter of circle with radius”, radius, ‘is’,prem)

Output-
Enter radius of the circle : 2.5
1. CalculateArea
2. Calculate Perimeter
Enter your choice (1 or 2) : 1
Area of circle with radius 2.5 is 19.6349375
Practical 7
Question- Program to print table of a number, say 5.
Program-
num=5
for a in range(1,11) :
print (num, ‘x’, a, ‘=’, num*a)

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
Practical 8
Question- Program to print sum of natural numbers
between 1 and 7. Print the sum progressively, i.e., after
adding each natural number, print sum so far.
Program-
Sum=0
For n in range(1,8) :
Sum += n
Print (“Sum of natural numbers ,=”, n, “is”, sum)

Output-
Sum of natural numbers <= 1 is 1
Sum of natural numbers <= 2 is 3
Sum of natural numbers <= 3 is 6
Sum of natural numbers <= 4 is 10
Sum of natural numbers <= 5 is 15
Sum of natural numbers <= 6 is 21
Sum of natural numbers <= 7 is 28

You might also like