0% found this document useful (0 votes)
4 views

codes

Uploaded by

Anwesha Shukla
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

codes

Uploaded by

Anwesha Shukla
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Codes

1. Scatter chat

import matplotlib.pyplot as plt

x = [2, 9, 8, 5, 6]

y = [5, 10, 3, 7, 18]

plt.scatter(x,y)

plt.title('Scatter Chart')

plt.xlabel('X-axis')

plt.ylabel('Y-axis')

plt.show()

2. Bar chart

import matplotlib.pyplot as py

over=[1,2,3,4]

runs=[6,8,9,7]

c= ['yellow', 'blue', 'black', 'orange']

py.title("t20 match")

py.xlabel("over")

py.ylabel("runs")

py.bar(over,runs, color=c)

py.show()

3. Armstrong number

num = int(input("Enter a number: "))

sum = 0

temp = num

while temp > 0:

digit = temp % 10

sum += digit ** 3
temp //= 10

if num == sum:

print(num,"is an Armstrong number")

else:

print(num,"is not an Armstrong number")

4. Reversal

num = int(input("Enter a number: "))

reversed_num = int(str(num)[::-1])

print("Reversed number:", reversed_num)

5. Palindrome

num=int(input("Enter the number:"))

temp=num

rev=0

while(num>0):

digit=num%10

rev=rev*10+digit

num=num//10

if(temp==rev):

print("The number is a palindrome!")

else:

print("The number isn't a palindrome!")

6. Pyramids

num = int(input("Enter a number: "))

for i in range(1, num + 1):

for j in range(1, i + 1):

print(j, end=' ')

print()
7. Repetitive pyramid

rows = int(input("enter number: "))

num = rows

for i in range(rows, 0, -1):

for j in range(0, i):

print(num, end=' ')

print("\r")

You might also like