Python
import matplotlib.pyplot as plt

countries=['panda nation','gramophone','ice-creamers','shinnnn','shinx world']
literacy=[54,89,62,81,99]
plt.bar(countries,literacy,color=['black','pink','yellow','red','blue'])
plt.title('Literacy rate')
plt.xlabel('Countries')
plt.ylabel('Population (%)')
plt.show()
Python
import matplotlib.pyplot as plt
pokemon=['snorlax','amaura','meowha','chespin','shinx']
captured=[45,32,67,78,54]
plt.bar(pokemon,captured,color=['grey','purple','yellow','green','blue'])
plt.title('Pokemons Captured')
plt.xlabel('Pokemon')
plt.ylabel('No. of Captured')
plt.show()
Python
import matplotlib.pyplot as plt
month=['March','April','May','June','July','August']
jeans=[1500,3500,6500,6700,6000,6800]
tshirt=[4400,4500,5500,6000,5600,6300]
shirt=[6500,5000,5800,6300,6200,4500]
plt.plot(month,jeans,marker='o')
plt.plot(month,tshirt,marker='o')
plt.plot(month,shirt,marker='o')
plt.title("Ajio")
plt.xlabel("Months")
plt.ylabel("Garments")
plt.legend(["Jeans","T-Shirt","Shirt"], loc="lower right")
plt.show()
Python
import matplotlib.pyplot as plt
years=['2019','2020','2021','2022','2023','2024']
newjeans=[56,68,89,60,95,78]
ateez=[42,63,48,52,75,64]
ive=[60,42,63,60,42,90]
plt.plot(years,newjeans,marker='o',linestyle='dashed')
plt.plot(years,ateez,marker='o',linestyle='dashed')
plt.plot(years,ive,marker='o',linestyle='dashed')
plt.title("Growth of K-Pop Bands")
plt.xlabel("Subscribers")
plt.ylabel("Bands")
plt.legend(["newjeans","ateez","ive"], loc="lower right")
plt.show()
Python
# No. of Child Birth in a year in india, pakistan, china
import matplotlib.pyplot as plt
year=["2019","2020","2021","2022","2023","2024"]
india=[85,74,90,92,99,99]
pakistan=[86,76,89,85,89,93]
china=[90,87,79,85,90,97]
plt.plot(year,india,marker='o')
plt.plot(year,pakistan,marker='o')
plt.plot(year,china,marker='o')
plt.title("Child Birth In Different Countries")
plt.xlabel("Countries")
plt.ylabel("Child Birth")
plt.legend(["India","Pakistan","China"], loc="lower right")
plt.show()
Python
import numpy as np
L=[]
n=int(input("Enter no. of elements"))
for i in range (n):
    val=int(input("enter value"+str(i+1)+":"))
    L.append(val)
    arr=np.array(L)
print ("Array:", arr)
Array: [26 45 15 32 32 45 25 95]
Python
import numpy as np
arr=np.arange(11,28,2)
arr=arr.reshape(3,3)
print (arr)
[[11 13 15]
 [17 19 21]
 [23 25 27]]
Python
import statistics
L=[2,4,6,5,7,8,9,10,3,5,4,7,8,3,2,5,6]
print("Mean Value:%.2f"%statistics.mean(L))
print("Mode Value:%.2f"%statistics.mode(L))
print("Median Value:%.2f"%statistics.median(L))
Mean Value:5.53
Mode Value:5.00
Median Value:5.00
Python
import statistics
L=[33,44,55,67,54,22,33,44,56,78,21,31,43,90,21,33,44,55,87] 
print("Variance:%.2f"%statistics.variance(L))				
print("Standard Deviation:%.2f"%statistics.stdev(L))
Variance:5.76
Standard Deviation:2.40
Python
# Write a program to check whether the given character is an uppercase letter or
# lowercase letter or a digit or a special character.
x=input("Enter Any Character:")
if x.isupper(): 
    print(x, " is an upper case letter") 
elif x.islower(): 
    print(x, " is a lower case letter") 
elif x.isdigit(): 
    print(x, " is a digit") 
elif x.isspace(): 
    print(x, " is a space") 
else: 
    print(x," is a special character")
is a space
Python
# Write a program to check whether the entered number is Armstrong or not
n=int(input("Enter number to check:")) 
t=n 
s=0 
while n!=0: 
    r=n%10 
    s=s+(r**3) 
    n//=10
if t==s: 								
    print(s," is Armstrong number") 
else: 
    print(s," is not an Artmstrong number")
559  is not an Artmstrong number
Python
n=int(input("Enter number for multiplication:"))
for i in range (1,11):
    print (n, "x", i, "=", n*i)
8 x 1 = 8
8 x 2 = 16
8 x 3 = 24
8 x 4 = 32
8 x 5 = 40
8 x 6 = 48
8 x 7 = 56
8 x 8 = 64
8 x 9 = 72
8 x 10 = 80
find maximum value from a list of numbers
ask for the number of subjects. Then ask the marks scored in each subject and find the maximum
Python
n = int(input("Enter the number of subjects: "))
marks = []

for i in range(n):
    m = int(input(f"Enter marks for subject {i + 1}: "))
    marks.append(m)

max_value = max(marks)

print("Maximum marks scored:", max_value)
Maximum marks scored: 56
Python
fruits=['banana','mango','strawberry','watermelon']
print (fruits)
print (fruits[0])
print (fruits[2])
fruits[1]='kiwi'
print (fruits)
fruits.append('guava')
vegetable=['bottleguard','potato']
fruits.extend(vegetable)
fruits.insert(2, 'pineapple')
print (fruits)
fruits.remove('strawberry')
del fruits [1]
fruits.pop(3)
fruits.pop()
print (fruits)
print (fruits[1:3])
print (fruits[1:])
print (fruits[:3])
print (len(fruits))
print ('watermelon' in fruits)
print ('pineapple' not in fruits)
['banana', 'mango', 'strawberry', 'watermelon']
banana
strawberry
['banana', 'kiwi', 'strawberry', 'watermelon']
['banana', 'kiwi', 'pineapple', 'strawberry', 'watermelon', 'guava', 'bottleguard', 'potato']
['banana', 'pineapple', 'watermelon', 'bottleguard']
['pineapple', 'watermelon']
['pineapple', 'watermelon', 'bottleguard']
['banana', 'pineapple', 'watermelon']
4
True
False
Python
subjects=['maths','science','social science']
subjects.insert (2, 'art')
print (subjects)
print (subjects[1:3]) #in between 
print (subjects[:1]) #from starting
print (subjects[2:]) #from something to end
subjects[2]='architecture'
print (subjects)
del subjects[2]
print (subjects)
subjects.pop()
print (subjects)
print ('kiwi' in subjects)
print ('maths' in subjects)
print ('maths' not in subjects)
print (len(subjects))
print (subjects[0])
subjects.append('design')
print (subjects)
languages=['English','Hindi','Sanskrit','French']
subjects.extend(languages)
print (subjects)
subjects.remove ('Sanskrit')
print (subjects)
['maths', 'science', 'art', 'social science']
['science', 'art']
['maths']
['art', 'social science']
['maths', 'science', 'architecture', 'social science']
['maths', 'science', 'social science']
['maths', 'science']
False
True
False
2
maths
['maths', 'science', 'design']
['maths', 'science', 'design', 'English', 'Hindi', 'Sanskrit', 'French']
['maths', 'science', 'design', 'English', 'Hindi', 'French']
Python
numbers=[1,2,3,4,5]
for i in numbers:
    print (i)
1
2
3
4
5