Computer Lab Practtical 1.ipynb - Colaboratory
Computer Lab Practtical 1.ipynb - Colaboratory
ipynb - Colaboratory
my first program
print("Welcome to World of programming!!!")
print("Name \t:\t Ms Niti Arora")
a=int(input("enter the number"))
b=a*2
c=a*3
d=a*4
e=a*5
f=a*6
print(b)
print(c)
print(d)
print(e)
print(f)
wap to accept name and basic salary of an employee. calculate and display??
HRA 32% of basic salary
DA 45% of basic salary
PF 12% of basic salary
GROSS basic + HRA + DA
NET SALARY GROSS - PF
N=input("Enter name:")
BS=int(input("Enter basic salary:"))
HRA=BS*.32
DA=BS*.45
PF=BS*.12
GROSS=BS+HRA+DA
NS=GROSS-PF
print("Name\t:\t",N)
print("BS\t:\t",BS)
print("HRA\t:\t",HRA)
print("DA\t:\t",DA)
print("PF\t:\t",PF)
print("GROSS\t:\t",GROSS)
print("NS\t:\t",NS)
Enter name:20
Enter basic salary:45000
Name : 20
BS : 45000
HRA : 14400.0
DA : 20250.0
PF : 5400.0
GROSS : 79650.0
NS : 74250.0
a=int(input("Enter your Na"))
if a>100:
print("3 digits number")
https://colab.research.google.com/drive/1XK3gprSuaLoPn-DhxU0z-HUUPlyCTCsl#printMode=true 1/14
1/31/23, 6:27 PM Computer Lab Practical 1.ipynb - Colaboratory
else :
print("less than 3 digit number")
Enter your Na45
less than 3 digit number
a=int(input("Enter Your Number"))
if a%2==0:
print("The Number Is Even")
else:
print("The Number Is Odd")
a=int(input("Enter Your Number"))
if a%3==0:
print("The Number is divisible by 3")
else:
print("The Number is not divisible by 3")
WAP to accept the marks in a subject and name and display his/her Grades
a=input("Enter Your Name")
b=int(input("Enter Your Marks"))
if b>=90:
print("Grades = A+ : PASS")
elif 80<=b<90:
print("Grades = A : PASS")
elif 70<=b<80:
print("Grades = B : PASS")
elif 60<=b<70:
print("Grades = C : PASS")
elif 50<=b<60:
print("Grades = D : JUST PASS")
elif 30<=b<50:
print("Grades = E : FAIL")
year=int(input("Enter Year : "))
if year %100==0 and year %400==0:
print("Year : Is A Leap Century Leap Year ")
elif year %100!=0 and year %4==0:
print("Year : It is A Leap Year")
else:
print("Year : Is Not A Leap Year")
a=int(input("Enter Number Here : "))
b=(a+1)
https://colab.research.google.com/drive/1XK3gprSuaLoPn-DhxU0z-HUUPlyCTCsl#printMode=true 2/14
1/31/23, 6:27 PM Computer Lab Practical 1.ipynb - Colaboratory
for c in range (1,b):
print(c)
Enter Number Here : 34
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
a=int(input("Enter Your Number : "))
for c in range (a,0,-1):
print(c)
a=int(input("Enter Your Number : "))
b=2*a+1
for c in range(2,b,2):
print(c)
a=int(input("Enter Your Number : "))
for c in range (2,2*a+1,2):
print(c, end=',')
a=int(input("Enter Your Number : "))
for c in range (1,2*a-1,2):
print(c, end=',')
https://colab.research.google.com/drive/1XK3gprSuaLoPn-DhxU0z-HUUPlyCTCsl#printMode=true 3/14
1/31/23, 6:27 PM Computer Lab Practical 1.ipynb - Colaboratory
a=int(input("Enter Your Number : "))
for c in range (2,2*a,2):
print(c, end=',')
a=int(input("Enter Your Number : "))
for c in range (2,2*a-1,1):
print (c, end=',')
x=int(input("Enter Your Number : "))
s=0
for x in range(1,11):
s+=x
print('sum=',s)
a=int(input("Enter Your Number : "))
s=0
for a in range(1,a+1):
s+=a
print('sum=',s)
n=int(input("Enter Your Number : "))
for n in range (1,11):
print(n,"*",x,"=",n*x)
a=int(input("Enter Your Number : "))
b=int(input("Enter Second Number : "))
c=int(input("Enter Third Number : "))
if a>b and a>c:
print("a is the Greatest Number")
if a<b and b>c:
print("b is the Greatest Number")
if a<c and b<c:
print("c is the Greatest Number")
a=int(input("Enter Your Number : "))
if a/3:
print("a is divisible by 3")
if a/5:
print("a is divisible by 5")
else:
print("a is not divisible by 3 nor 5")
WAP to accept the number and check if it is positive even number or negative even number, positive odd or negative od or zero.
https://colab.research.google.com/drive/1XK3gprSuaLoPn-DhxU0z-HUUPlyCTCsl#printMode=true 4/14
1/31/23, 6:27 PM Computer Lab Practical 1.ipynb - Colaboratory
a=int(input("Enter Your Number : "))
if a%2==0 and a>0:
print("The Number Is Positive Even")
else:
print("The Number Is Positive Odd")
a=int(input("Enter Your Number : "))
if a%-2==0 and a<0:
print("The Number Is Negative Even")
else:
print("The Number Is Negative Odd")
a=int(input("Enter Your First Number : "))
b=int(input("Enter Your Second Number : "))
operand=input("Enter Your Operator : ")
if operand =='+':
print(a+b)
if operand =='-':
print(a-b)
if operand =='*':
print(a*b)
if operand =='/':
print(a/b)
a=int(input("Enter your First Number : "))
b=int(input("Enter Your Second Number : "))
a , b = b , a
print(a,b)
WAP a programme that takes the name and age of the user as input and display a message whether the user is eligible to apply for driving
lisence or not.
a=input("Enter User's Name : ")
b=int(input("Enter User's Age : "))
if b>18:
print("User Is Eligible For Driving License")
if b<18:
print("User Is NOT Eligible For Driving License")
celsius_1 = float(input("Temperature value in degree Celsius: " ))
# For Converting the temperature to degree Fahrenheit by using the above
# given formula
Fahrenheit_1 = (celsius_1 * 1.8) + 32
# print the result
print('The %.2f degree Celsius is equal to: %.2f Fahrenheit'
%(celsius_1, Fahrenheit_1))
print("----OR----")
celsius_2 = float (input("Temperature value in degree Celsius: " ))
Fahrenheit_2 = (celsius_2 * 9/5) + 32
# print the result
print ('The %.2f degree Celsius is equal to: %.2f Fahrenheit'
%(celsius_2, Fahrenheit_2))
https://colab.research.google.com/drive/1XK3gprSuaLoPn-DhxU0z-HUUPlyCTCsl#printMode=true 5/14
1/31/23, 6:27 PM Computer Lab Practical 1.ipynb - Colaboratory
x = int(input("Enter base number:"))
n=int(input("Enter exponent:"))
z=x**n
print(z)
for a in range(1,51):
print(a,end=",")
for b in range(2,51):
print(b,end=",")
for c in range(1,50):
print(c,end=",")
WAP to accept the maximum number value and print natural number from 1 to n
n=int(input("Enter Your Number : "))
for a in range(2,n+2,2):
print(a,end=",")
n=int(input("Enter Your Number : "))
for a in range(2,n+2,2):
print(a,end=",")
n=int(input("ENTER YOUR NUMBER : "))
for b in range(1,n+2,2):
print(b,end=",")
import matplotlib.pyplot as M
import numpy as N
import pandas as P
X=["Ajay","Raj","Deepak","Sumit"]
Y=[75,90,45,30]
print(X)
print(Y)
M.plot(X,Y)
import matplotlib.pyplot as M
import numpy as N
import pandas as P
X=["Ajay","Raj","Deepak","Sumit"]
Y=[75,90,45,30]
print(X)
https://colab.research.google.com/drive/1XK3gprSuaLoPn-DhxU0z-HUUPlyCTCsl#printMode=true 6/14
1/31/23, 6:27 PM Computer Lab Practical 1.ipynb - Colaboratory
print(Y)
M.bar(X,Y)
import matplotlib.pyplot as plt
import numpy as np
x = np.random.normal(170, 10, 250)
plt.hist(x)
plt.show()
import matplotlib.pyplot as plt
import numpy as np
x=["Ajay","Raj","Deepak","Sumit"]
y = np.array([50, 50, 25, 25])
e=[0.1,0.1,0.1,0.1]
plt.pie(y,labels=x,explode=e)
plt.show()
import matplotlib.pyplot as plt
import numpy as np
X=["Arjit","Vanshika","Ruchit","Ansh"]
Y=[75,90,45,30]
print(X)
print(Y)
plt.plot(X,Y, marker="*", ms=20, mfc='r')
import matplotlib.pyplot as M
import numpy as N
import pandas as P
X=["Arjit","Vanshika","Ruchit","Ansh"]
Y=[100,90,45,30]
c=["yellow","red","green","pink"]
print(X)
print(Y)
M.bar(X,Y ,color=c)
print("Enter Five Numbers Below")
num1=float(input("Enter First No : "))
num2=float(input("Enter Second No : "))
num3=float(input("Enter Third No : "))
num4=float(input("Enter forth No : "))
num5=float(input("Enter Fifth No : "))
divisor=float(input("Enter divisor Number : "))
count=0
print("Multiples of",divisor,"are : ")
remainder=num1%divisor
if remainder==0:
print(num1,sep="")
count+=1
remainder=num2%divisor
if remainder==0:
print(num2,sep="")
count+=1
remainder=num3%divisor
if remainder==0:
print(num3,sep="")
count+=1
remainder=num4%divisor
if remainder==0:
print(num4,sep="")
count+=1
https://colab.research.google.com/drive/1XK3gprSuaLoPn-DhxU0z-HUUPlyCTCsl#printMode=true 7/14
1/31/23, 6:27 PM Computer Lab Practical 1.ipynb - Colaboratory
remainder=num5%divisor
if remainder==0:
print(num5,sep="")
count+=1
print()
print(count,"multiples of",divisor,"found")
x=int(input("Enter The Value of X : "))
n=int(input("Enter The Value of N : "))
S=x
sign=+1
for a in range(2,n+1):
f=1
for i in range(1,a+1):
f*=1
term=((x**a)*sign)/f
S+=term
sign*=-1
print("sum of first",n,"terms :",S)
WAP to accept a list of n numbers and find their sum and average
WAP to accept a list of n names and count names that starts with a vowel
WAP to accept a list of n names and display names tha ends with a vowel
WAP to accept a list of n numbers and count numbers of even and odd in the list
n=int(input("Enter Value of n : "))
L=[]
for a in range(n):
a=int(input("Enter Data : "))
L.append(a)
counte=0
counto=0
for a in L:
if a%2==0:
counte+=1
else:
counto+=1
print("Number is Even",counte)
print("Number is Odd",counto)
Enter Value of n : 6
Enter Data : 12
Enter Data : 13
Enter Data : 45
Enter Data : 67
Enter Data : 22
Enter Data : 26
Number is Even 3
Number is Odd 3
n=int(input("Enter Value of n : "))
L=[]
for a in range(n):
a=input("Enter Data : ")
L.append(a)
for a in L:
if a[-1] in'aeiouAEIOU':
print(a)
Enter Value of n : 3
Enter Data : arjit
Enter Data : bhuwan
https://colab.research.google.com/drive/1XK3gprSuaLoPn-DhxU0z-HUUPlyCTCsl#printMode=true 8/14
1/31/23, 6:27 PM Computer Lab Practical 1.ipynb - Colaboratory
Enter Data : aditya
aditya
n=int(input("Enter Value of n : "))
L=[]
for a in range(n):
a=int(input("Enter Data : "))
L.append(a)
s=0
for a in L:
s+=a
print("sum=",s)
Enter Value of n : 6
Enter Data : 34
Enter Data : 35
Enter Data : 36
Enter Data : 37
Enter Data : 38
Enter Data : 39
sum= 219
n=int(input("Enter Value of n : "))
L=[]
for c in range(n):
a=int(input("Enter Data : "))
L.append(a)
Max=L[0]
for a in L:
if a>Max:
Max=a
print("Maximum",Max)
Enter Value of n : 6
Enter Data : 34
Enter Data : 35
Enter Data : 36
Enter Data : 37
Enter Data : 38
Enter Data : 39
Maximum 39
n=int(input("Enter The Value of n : "))
L=[]
for a in range(n):
a=int(input("Enter Data : "))
L.append(a)
s=0
for a in L:
s+=a
print("Average=",s/n)
n=int(input("Enter Value of n : "))
L=[]
for a in range(n):
N=input("Enter Name : ")
L.append(N)
for a in L:
if a[0] in 'aeiouAEIOU':
print(a)
Enter Value of n : 3
Enter Name : Maloy
Enter Name : Arjit
Enter Name : Ansh
Arjit
Ansh
L1=eval(input("Enter List 1 : "))
L2=eval(input("Enter List 2 : "))
https://colab.research.google.com/drive/1XK3gprSuaLoPn-DhxU0z-HUUPlyCTCsl#printMode=true 9/14
1/31/23, 6:27 PM Computer Lab Practical 1.ipynb - Colaboratory
if L1>L2:
print(L1)
elif L2>L1:
print(L2)
else:
print("Equal")
Enter List 1 : ["ajay","amit"]
Enter List 2 : ["Amit","Ajay"]
['ajay', 'amit']
WAP to accept n numbers and find 3 largest among them (WITHOUT ANY SORT)
n=int(input("Enter Value of n : "))
L=[]
for x in range(n):
a=int(input("Enter Data : "))
L.append(a)
Max=L[0]
for x in L:
if x>Max:
Max=x
print("Max No.=",Max)
Enter Value of n : 5
Enter Data : 456
Enter Data : 789
Enter Data : 234
Enter Data : 666
Enter Data : 111
Enter Data : 4567
Enter Data : 678
---------------------------------------------------------------------------
KeyboardInterrupt Traceback (most recent call last)
<ipython-input-17-6bc0e591aea3> in <module>
6 L=[]
7 for a in range(n+1):
----> 8 a=int(input("Enter Data : "))
9 L.append(a)
10 Max=L[0]
1 frames
/usr/local/lib/python3.8/dist-packages/ipykernel/kernelbase.py in
_input_request(self, prompt, ident, parent, password)
902 except KeyboardInterrupt:
903 # re-raise KeyboardInterrupt, to truncate traceback
--> 904 raise KeyboardInterrupt("Interrupted by user") from None
905 except Exception as e:
906 self.log.warning("Invalid Message:", exc_info=True)
n=int(input("Enter Value of n : "))
L=[]
L1=[]
for x in range(n):
i=int(input("Enter Value : "))
L.append(i)
L1=[]
for x in range(3):
max=0
for a in L:
if a>max and a not in L1:
max=a
L1.append(max)
print("max no.=",L1)
Enter Value of n : 5
Enter Value : 45
Enter Value : 67
Enter Value : 12
Enter Value : 89
Enter Value : 39
max no.= [89, 67, 45]
https://colab.research.google.com/drive/1XK3gprSuaLoPn-DhxU0z-HUUPlyCTCsl#printMode=true 10/14