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

Program_1

The document contains a series of 15 Python programs, each demonstrating different functionalities such as finding the largest and smallest numbers, converting units, calculating BMI, checking for prime numbers, generating Fibonacci sequences, and more. Each program includes user input and outputs results based on the computations performed. The programs cover basic programming concepts and operations like loops, conditionals, and mathematical calculations.

Uploaded by

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

Program_1

The document contains a series of 15 Python programs, each demonstrating different functionalities such as finding the largest and smallest numbers, converting units, calculating BMI, checking for prime numbers, generating Fibonacci sequences, and more. Each program includes user input and outputs results based on the computations performed. The programs cover basic programming concepts and operations like loops, conditionals, and mathematical calculations.

Uploaded by

Hari Kishan
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 7

Program 1

a=int(input("Enter number 1"))

b=int(input("Enter number 2"))

c=int(input("Enter number 3"))

print("Largest Number ",max(a,b,c))

print("Smallest Number ",min(a,b,c))

OUPUT

Program 2

tonns=int(input("Enter Value in Tonnes"))

quint=tonns*10

kg=tonns*1000

print("Quintals ",quint)

print("Kilograms ",kg)

OUPUT

Program 3

N=int(input("Enter Number"))

print("Qube is ",N**3)

OUPUT
Program 4

for i in range(1,6):

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

print("*",end="\t")

print()

OUPUT

Program 5

n=int(input("Enter Value for N"))

x=int(input("Enter Value for x"))

sum=0

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

sum=sum+x**i

print("The sum is",sum)

OUPUT

Program 6

weight=int(input("Enter your weight in kg"))

height=float(input("Enter your height in meters"))

BMI=weight/(height**2)

print("Your BMI is",BMI)

OUPUT
Program 7

n=int(input("Enter any Number"))

fact=0

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

if n%i==0:

fact=fact+1

if fact==2:

print("Number is Prime")

else:

print("Number is Composite")

OUPUT

Program 8

a=0

b=1

sum=0

print(a," ",b,end=' ')

for i in range(1,11):

sum=a+b

print(" ",sum,end=' ')

a=b

b=sum

OUPUT
Program 9

n=int(input("Enter Any Number"))

a=0

sum=0

num=n

while n>0:

a=n%10

sum=sum+(a**3)

n=n//10

if num==sum:

print("Number is Armstrong")

else:

print("Number is Not Armstrong")

OUPUT

Program 10

import math

print("The gcd of 60 and 48 is : ", end="")

print(math.gcd(60, 48))

OUPUT

Program 11
n=eval(input("Enter Any Number"))

lst=list(n)

for i in range(0,len(lst)-1,2):

s=lst[i+1]

lst[i+1]=lst[i]

lst[i]=s

print(lst)

OUPUT

Program 12

n=eval(input("Enter Any Number"))

lst=list(n)

element=int(input("Enter Element for search"))

print(element in lst)

OUPUT

Program 13

clas={"Ram":[54,96,75,48,88],"shyam":[65,66,98,95,74],"rohit":[87,99,41,25,68],"Mohit":
[99,74,58,65,87],"Kisahan":[78,44,98,95,90]}

for i in clas:

m=clas[i]

avg=sum(m)/5

print(i," Average Marks ",avg)

OUPUT
Pr ogram 14

import random

min_value=1

max_value=6

roll_again = "yes"

while roll_again == "yes" or roll_again == "y":

print("Rolling the dices...")

print("The values are....")

value1=random.randint(min_value, max_value)

value2=random.randint(min_value, max_value)

print(value1,value2)

roll_again = input("Press 'y' or 'yes' to roll the dices again.")

print("Have a good day.")

OUTPUT

Rolling the dices...


The values are....
64
Press 'y' or 'yes' to roll the dices again.y
Rolling the dices...
The values are....
14
Press 'y' or 'yes' to roll the dices again.y
Rolling the dices...
The values are....
51
Press 'y' or 'yes' to roll the dices again.yes
Rolling the dices...
The values are....
52
Press 'y' or 'yes' to roll the dices again.N
Have a good day.
Program 15

import random

n=random.randrange(1,10)

while True:

a=int(input("Enter A Number from 1 to 10 "))

if a==n:

print("You Win ")

break

elif a>n:

print("Number is Greater")

else:

print("Number is smaller")

OUPUT

You might also like