Mishthi (Roll No-05)
Mishthi (Roll No-05)
PROJECT
NAME-MISHTHI
CLASS-XI A
ROLL NO-05
Practical Questions:
Ques1- Write a program to check whether a person is above 18. If he/she is
if Age>18:
print("You are above 18")
elif Age==18:
print("You are currently 18")
else:
print("You are below 18")
Output
if Age>=18:
print("You are eligible ")
else:
Output
*Enter the age of a person:45
else:
print("num2 is greater")
OUTPUT
*Enter the first number:56
Enter the second number:99
num2 is greater
Else:
print("num3 is greater")
Output
*Enter the first number:45
num3 is greater
*Enter the first number:45
Enter the second number:99
Enter the third number:56
num2 is greater
*Integer
x=45
print("Id of x is:",id(x))
print("Type of x is :",type(x))
*Float
y=35.5
print("Id of y is :",id(y))
print("Type of y is: ",type(y))
*String
z="Hello"
print("Id of z is :",id(z))
print("Id of z is :",type(z))
OUTPUT
Interger
Id of x is: 139706839979464
Type of x is : <class 'int'>
Float
Id of y is : 139706828840656
Type of y is: <class 'float'>
String
Id of z is : 139706829080944
Id of z is : <class 'str'>
INPUT
num1=int(input("Enter the Number:"))
if (num1%2)==0:
print("Even Number")
else:
print("Odd Number")
OUTPUT
print('A')
elif perc>70 and perc<=85:
print('B')
else:
print('E')
OUTPUT
python()
> python()
Enter the perc:49
D
> python()
Enter the perc:99
A
> python()
INPUT
def python():
salary=int(input("Enter salary of a person:"))
if salary>70000:
tax=0.08*salary
else:
tax=0.05*salary
print("Salary",salary,"Tax",tax)
OUTPUT
*python()
Enter salary of a person:65000
* python()
Enter salary of a person:22000
Salary 22000 Tax 1100.0
INPUT
def python():
print("num1 is Even")
elif num1==0:
print("num1 is Zero")
else:
print("num1 is Odd")
OUTPUT
*python()
Enter the Number:45
num1 is Even
* python()
Enter the Number:0
num1 is Zero
*python()
Enter the Number:-33
num1 is Odd
Ques10. Write a program that creates a new list from existing list using slicing...
INPUT
list1=[1,2,3,4,5]
print("list1 is:",list1)
list2=list1[:]
print("list2 is:",list2)
OUTPUT
Ques11.Write a program to convert a string into list and display all the elements
using transversal..
INPUT
list1=list(str(input("Enter a String:")))
print(list1)
for i in list1:
print(i)
OUTPUT
Enter a String:COMPUTER
P
T
E
R
Ques12.Write a program to to check a given element is present in list or not...
INPUT
list1=list(str(input("Enter a String:")))
print(list1)
print('O'in list1)
print('S'in list1)
print(1 in list1)
print('C' in list1)
OUTPUT
Enter a String:COMPUTER
['C', 'O', 'M', 'P', 'U', 'T', 'E', 'R']
True
False
False
True
Ques13. Write a program to inputs principal rate and time and calculte simple
interest and amount..
INPUT
principal=float(input("Enter Principal:"))
rate=float(input("Enter rate:"))
time=5
Simple_interest=principal*rate*time/100
Amount=principal+Simple_interest
print("Simple_interest=Rs.",Simple_interest)
print("Amount=Rs.",Amount)
OUTPUT
Enter Principal:65
Enter rate:4
Simple_interest=Rs. 13.0
Amount=Rs. 78.0
INPUT
cel=float(input("Enter temperature in Celcius:"))
print("Temperature in Celcius=",cel)
f=cel*9/5+32
print("Temperature in fahrenheit=", f)
OUTPUT
INPUT
#Display sum of 1-x+x**2-x**3+...+x**n
sum=1
for i in range(1,n+1):
if i%2==0:
sum=sum+x**i
else:
sum=sum-x**i
print("Sum of the series is:",sum)
OUTPUT
Enter base number:5
OUTPUT
6X1=6
6 X 2 = 12
6 X 3 = 18
6 X 4 = 24
6 X 5 = 30
6 X 6 = 36
6 X 7 = 42
6 X 8 = 48
6 X 9 = 54
6 X 10 = 60
#Concatination of strings
x="COMPUTER"
y="PYTHON"
print(x+y)
print("SCHOOL"+"BUS")
s="LAP"+"TOP"
print(s)
OUTPUT
COMPUTERPYTHON
SCHOOLBUS
LAPTOP
INPUT
num=int(input("Enter non negative no to take factorial of:"))
fact=1
for i in range(num):
fact=fact*(i+1)
print('Factorial of ',num,'=',fact)
OUTPUT
sum=0
if num<=0:
n2=sum
sum=n1+n2
OUTPUT
summ=0
for i in range(1,n+1):
summ+=x/i
print("The sum is:",summ)
OUTPUT
Enter the value of x:10
OUTPUT
Cube of 1 is 1
Cube of 2 is 8
Cube of 3 is 27
Cube of 4 is 64
Cube of 5 is 125
Cube of 6 is 216
Cube of 7 is 343
Cube of 8 is 512
Cube of 9 is 729
Cube of 10 is 1000
Cube of 11 is 1331
Cube of 12 is 1728
Cube of 13 is 2197
Cube of 14 is 2744
Cube of 15 is 3375
Ques22.Write a program to take side of a triangle and print its area using
A=(s*(s-a)*(s-b)*(s-c))**0.5
print("Area of a traingle =",A)
OUTPUT
OUTPUT
Enter
the first number:36
Enter the second number:64
Ques24. Write a program that input string from user and counts the
number of vowels,consonants,digits,upper and lowercase letter..
INPUT
consonants=0
uppercase=0
lowercase=0
for i in range(0,len(str)):
if(str[i].isupper()):
uppercase=uppercase+1
elif((str[i].islower())):
lowercase=lowercase+1
str=str.lower()
for i in range(0,len(str)):
if ((str[i]=='a'or str[i]=='e'or str[i]=='i'or str[i]=='o'or str[i]=='u')):
vowels=vowels+1
else:
consonants=consonants+1
print("Vowels:",vowels);
print("Consonants:",consonants);
print("Uppercase:",uppercase);
print("Lowercase:",lowercase);
OUTPUT
Uppercase: 4
Lowercase: 8
INPUT
str=input("Enter the String :")
s=(str[::-1])
if str==s:
print("It is palindrome")
else:
for i in str:
if char==i:
count=count+1
print("Number of occurance of character is:",count)
OUTPUT
Enter the string : Corporation
QUES27. Write a program that count and display even and odd
number...
INPUT
num=int(input("Enter any Number:"))
if num%2==0:
print("Number is Even")
else:
print("Number is odd")
OUTPUT
*Enter any Number:887
Number is odd
INPUT
List=[1,2,3,4,5,6]
Search=int(input("Enter a search number:"))
print("Not found")
OUTPUT
t=(10,20,30,40,50)
print(t)
print("Maximum of t :",max(t))
print("Minimum of t :",min(t))
print("Sum of t :",sum(t))
s=10+20+30+40+50/5
print("Average of t:",s)
OUTPUT
Minimum of t : 10
Sum of t : 150
Average of t: 110.0
INPUT
t1=(10,20)
t2=(30,'Ram')
print("Concatination :",t1+t2)
OUTPUT
Concatination : (10, 20, 30, 'Ram')
2) REPETITION
INPUT
t1=(10,20)
print("Repetition:",t1*3)
OUTPUT
Repetition: (10, 20, 10, 20, 10, 20)
3)MEMBERSHIP
INPUT
t1=(10,20)
print(10 in t1)
OUTPUT
True
True
False
4)INDEXING
INPUT
t1=(10,20,30,40,50)
print(t1[3])
print(t1[0])
print(t1[-1])
OUTPUT
40
10
50
5) SLICING
INPUT
t1=(10,20,30,40,50)
print(t1[0:2:1])
print(t1[::-1])
print(t1[0:4:2])
print(t1[0:3:1])
OUTPUT
(10, 20)
(50, 40, 30, 20, 10)
(10, 30)
(10, 20, 30)
INPUT
no_of_std=int(input("Enter number of students :"))
result={}
for i in range(no_of_std):
std_name=input("Student Name:")
marks=int(input("Marks:"))
result[roll_no]=[std_name,marks]
print(result)
Student Name:Eva
Marks:89
Student Name:Olaf
Marks:56
Student Name:Harry
Marks:90
Enter the details of student no. 5
Roll no :05
Student Name:Maria
Marks:55
{1: ['John', 78], 2: ['Eva', 89], 3: ['Olaf', 56], 4: ['Harry', 90], 5: ['Maria', 55]}
INPUT
d1={1:10,2:20,3:30,4:40,5:50}
d2={6:60,7:70,8:80,9:90,10:100}
d1.update(d2)
print(d1)
print(d2)
d2.update(d1)
print(d2)
print(d1)
OUTPUT
{1: 10, 2: 20, 3: 30, 4: 40, 5: 50, 6: 60, 7: 70, 8: 80, 9: 90, 10: 100}
{1: 10, 2: 20, 3: 30, 4: 40, 5: 50, 6: 60, 7: 70, 8: 80, 9: 90, 10: 100}
INPUT
n=int(input("Enter the length of fibonacci sequence:"))
n1=0
n2=1
count=2
if n<0:
elif n==1:
print(n1)
else:
print(n1)
print(n2)
while count<n:
n3=n1+n2
print(n3)
count+=1
n1=n2
n2=n3
OUTPUT
Enter the length of fibonacci sequence:8
0
1
1
2
3
5
8
13
1)ARITHMETIC OPERATION
INPUT
print("18+5 =",18+5) #addition
OUTPUT
18+5 = 23
15-3 = 12
16*2 = 32
47/5 = 9.4
47//5 = 9
27%5 = 2
3**3 = 27
-2**4 = -16
2)CONCATINATIONAL OPERATION
INPUT
print("Hello"+"Python")
print("'How'+'are'+'you?':",'How'+'are'+'you?')
print("Python*3 :",'Python'*3)
OUTPUT
HelloPython
'How'+'are'+'you?': Howareyou?
Python*3 : PythonPythonPython
3)Relational Operation
INPUT
41>50 : False
41<=50 : True
41>=50 : False
41==41 : True
41!=50 : True
4)SHORTHAND OPERATIONS
INPUT
a=6
a+=5 #addition
print(a)
a-=5 #subtraction
print(a)
a*=3 #multiplication
print(a)
a/=2 #division
print(a)
a%=2 #modulus
print(a)
a**=2 #exponention
print(a)
a//=2 #integeral division
print(a)
OUTPUT
11
6
18
9.0
1.0
1.0
0.0