Practile CS
Practile CS
:- 02
Code :-
a=int(input('Enter the first integer:'))
b=int(input('Enter the second integer:'))
Sum=a+b
Output :-
PRACTILE NO. :- 03
Code :-
r= int(input('Enter the radius of circle:'))
Area= 3.14*r*r
print('The area of the circle is:', Area)
Output :-
PRACTILE NO. :- 05
Problem Statement :- Write a program that accepts base and height and
calculate the area of triangle.
Code :-
b= float(input('Enter the base of triangle:'))
h= float(input('Enter the height of triangle:'))
Area= (1/2)*b*h
Output :-
PRACTILE NO. :- 11
Code :-
a=int(input('Enter the number:'))
if a%2==0:
print('The number is even')
else:
print('The number is odd')
Output :-
PRACTILE NO. :- 08
Code :-
a=int(input('Enter the first integer:'))
b=int(input('Enter the second integer:'))
c=int(input('Enter the third integer:'))
Output :-
PRACTILE NO. :- 23
Code :-
W = float(input('Enter the weight in Kg:'))
H = float(input('Enter height in meters:'))
BMI=W/(H**2)
Output :-
PRACTILE NO. :- 19
Code :-
a=float(input('Enter the marks of first subject:'))
b=float(input('Enter the marks of second subject:'))
c=float(input('Enter the marks of third subject:'))
d=float(input('Enter the marks of fourth subject:'))
e=float(input('Enter the marks of fifth subject:'))
Average=(a+b+c+d+e)/5
print('The average marks are:', Average)
Output :-
PRACTILE NO. :- 14
Problem Statement :- Write a program that reads the number n and prints
the value of n², n³ and n⁴.
Code :-
a=float(input('Enter the value of n:'))
b=a**2
c=a**3
d=a**4
print('The value of n² is:', b)
print('The value of n³ is:', c)
print('The value of n⁴ is:', d)
Output :-
PRACTILE NO. :- 17
Code :-
a=int(input('Enter the year:'))
if a%4==0:
print('This year is a leap year')
else:
print('This year is not a leap year')
Output :-
PRACTILE NO. :- 12
Code :-
num=int(input('Enter the number:'))
for i in range(2,num//2+1):
if num%i==0:
print('It is not a prime no.')
break
else:
print('It is a prime number')
Output :-
PRACTILE NO. :- 15
Code :-
num=int(input('Enter a number:'))
fact=1
a=1
while a<=num:
fact*=a
a+=1
print('The factorial of',num,'is',fact)
Output :-
PRACTILE NO. :- 24
Code :-
for a in range(3,10,2):
print()
for b in range(1,a,2):
print(b, end=' ')
print()
Output :-
PRACTILE NO. :- 34
Problem Statement :- Program that reads a line and print its statistics like - Number
of uppercase letters, Number of lowercase letters, Number of alphabets and Number of
digits.
Code :-
line=input('Enter a line:')
lowercount=uppercount=0
digitcount=alphacount=0
for a in line:
if a.islower():
lowercount+=1
elif a.isupper():
uppercount+=1
elif a.isdigit():
digitcount+=1
if a.isalpha():
alphacount+=1
Code :-
for i in range(4):
for j in range(4,i,-1):
print(j,end=' ')
else:
print()
Output :-
PRACTILE NO. :- 27
Code :-
t=tuple()
n=int(input("How many values you want to enter: "))
for i in range(n):
a=input("Enter Number: ")
t=t+(a,)
print("Entered Numbers are: ")
print(t)
Output :-
PRACTILE NO. :- 28
Code :-
tuplex = "l","e","a","r","n","p","y","t","h","o","n","4","c","b","s","e"
print("Tuple Before Removing an item")
print(tuplex)
listx = list(tuplex)
listx.remove("4")
tuplex = tuple(listx)
print("Tuple After Removing an item '4'")
print(tuplex)
Output :-
PRACTILE NO. :- 01
Code :-
print(“Welcome”)
Output :-
PRACTILE NO. :- 04
Code :-
a=float(input('Enter the value of side:'))
A=a**2
Output :-
PRACTILE NO. :- 09
Code :-
a=int(input('Enter the first integer:'))
b=int(input('Enter the second integer:'))
c=int(input('Enter the third integer:'))
Output :-
PRACTILE NO. :- 18
Code :-
print('Enter the marks of three subject out of 100')
a=float(input('Enter the marks of first subject:'))
b=float(input('Enter the marks of second subject:'))
c=float(input('Enter the marks of third subject:'))
P=(a+b+c)/3
print('The percentage marks are:', P,'%')
Output :-
PRACTILE NO. :- 21
Code :-
a=float(input('Enter your height in centimeters:'))
Feet=a*0.032
Inch=a*0.393
Output :-
PRACTILE NO. :- 22
Problem Statement :- Write a program that accepts the age and print if one
is eligible to vote or not.
Code :-
a=int(input('Enter your age:'))
if a>=18:
print('You are eligible to vote')
else:
print('You are not eligible to vote')
Output :-
PRACTILE NO. :- 13
Problem Statement :- Write a program that accepts two numbers and check
if the first number is fully divisible by second number or not.
Code :-
a=float(input('Enter the first number:'))
b=float(input('Enter the second number:'))
if a%b==0:
print('The first number is fully divisible by second number')
else:
print('The first number is not fully divisible by second number')
Output :-
PRACTILE NO. :- 10
Code :-
a=float(input('Enter the number:'))
if a>=0:
if a==0:
print('The number is zero')
else:
print('The number is a positive number')
else:
print('The number is a negative number')
Output :-
PRACTILE NO. :- 20
Code :-
a=float(input('Enter the percentage marks:'))
if a>=90:
print('The student has got an A grade')
elif a>=75 and a<90:
print('The student has got a B grade')
elif a>=60 and a<75:
print('The student has got a C grade')
else:
print('The student has got a D grade')
Output :-
PRACTILE NO. :- 16
Code :-
import math
print('For quadratic equation, ax²+bx+c=0,enter coefficents below')
a=int(input('Enter a:'))
b=int(input('Enter b:'))
c=int(input('Enter c:'))
if a==0:
print('Value of a should not be zero')
else:
d=b*b-4*a*c
if d>0:
root1=(-b+math.sqrt(d))/(2*a)
root2=(-b-math.sqrt(d))/(2*a)
print('Roots are real and unequal')
print('Root1=',root1,',Root2=',root2)
elif d==0:
root1=-b/2*a
print('Roots are real and equal')
print('Root1=',root1,',Root2=',root1)
else:
print('Roots are complex and imaginary')
Output :-
PRACTILE NO. :- 29
Code :-
L1 = ['Red','Green','Blue']
L2 = ['Cyan', 'Magenta', 'Yellow','Black']
print(L1+L2)
print(L1*3)
print(len(L2))
print(L1[0:2])
Output :-
PRACTILE NO. :- 26
Code :-
for i in range(1,6):
print()
for j in range(1,i):
print('*',end=' ')
Output :-
PRACTILE NO. :- 06
Code :-
angle1=float(input('Enter the first angle:'))
angle2=float(input('Enter the second angle:'))
angle3=float(input('Enter the third angle:'))
if angle1+angle2+angle3==180:
print('The angles form a triangle')
else:
print('The angles do not form a triangle')
Output :-
PRACTILE NO. :- 07
Code :-
b=float(input('Enter the base of parallelogram:'))
w=float(input('Enter the width of parallelogram:'))
h=float(input('Enter the height of parallelogram:'))
Area=b*h
Perimeter=2*(b+w)
Output :-
PRACTILE NO. :- 33
Code :-
dict2= {'Raman': 76, 'Suman': 56, 'Sahil': 34, 'Amit': 85}
print(dict2)
Output :-
PRACTILE NO. :- 31
Problem Statement :- Enter a string and make ever letter capital of that
string.
Code :-
a = input("Enter a string:")
b = a.upper()
print(b)
Output :-
PRACTILE NO. :- 30
Code :-
dict1= {'Raman': 76, 'Suman': 56, 'Sahil': 34, 'Amit': 85}
dict1['John'] = 77
dict1['Sahil'] = 50
del dict1['Suman']
print(dict1)
Output :-
PRACTILE NO. :- 35
Code :-
import statistics
a = [2,5,3,3,10,3,67,5,2,1]
x= statistics.mean(a)
y= statistics.median(a)
z= statistics.mode(a)
Output :-
PRACTILE NO. :- 32
Code :-
tuple1 =(('Physics',89),('Chemistry',93),('Maths',96), ('Comp.Sc.',83))
print(tuple1[3])
print(tuple1[0:2])
print(tuple1[-3])
print(tuple1[0:4:2])
Output :-
Computer Science
Practical File…
By,
DHRUV DEV KHEDKAR
Class 11th A
Roll No. 19
THANK
YOU…