0% found this document useful (0 votes)
6 views11 pages

Python Programs for Basic Calculations

Uploaded by

2401200010
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views11 pages

Python Programs for Basic Calculations

Uploaded by

2401200010
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

num=int(input("Enter The Number...

"))

a=num*2

b=num*3

c=num*4

d=num*5

e=num*6

s=(a+b+c+d+e/5)

print('1st multiple is....',a)

print('2nd multiple is....',b)

print('3rd multiple is....',c)

print('4th multiple is....',d)

print('5th multiple is....',e)

print("The average of the multiples of",num,"is",s)


QUESTION : Write a python code to obtain a number from the user and generate
its five next consecutive multiple and their averages.
p=int(input('Enter the marks in phy...'))

c=int(input("enter the marks in chem..."))

m=int(input("enter the marks in maths..."))

cs=int(input('enter the marks in cs...'))

eng=int(input("enter the marks in eng..."))

count=0

subject=['physics', 'chemistry', 'maths', 'cs','eng']

if p>=33:

count=count+1

else:

flag=0

if c>=33:

count=count+1

else:

flag=1

if m>=33:

count=count+1

else:

flag=2

if cs>=33:
count=count+1

else:

flag=3

if eng>=33:

count=count+1

else:

flag=4

if count==5:

print('pass')

if count==4:

print('compartment in',subject[flag])

if count<4:

print('fail')
QUESTION: Write a python program to input the marks of five subjects and
display pass fail or compartment.
f=int(input('Enter the first number...'))

s=int(input('Enter the second number...'))

t=int(input('Enter the third number...'))

lg=f

if s>lg:

lg=s

if t>lg:

lg=t

print('the largest number is',lg)


Question. Write a python code to input three numbers from the user and check
which number is the largest number.
num1=int(input("Enter The Number 1..."))

num2=int(input("Enter The Number 2..."))

if num1%num2==0:

num=num1

num1=num2

num2=num

print("the swaped numbers are",num1,",",num2)

else:

a=num1*2

b=num2*2

print("the double of numbers",a,",",b)


QUESTION: Write the code to obtain two numbers from the user and then
interchange their values if the first number is divisible by second
number ,otherwise double the value of both numbers
a = float(input("Enter num 1:"))

b = float(input("Enter num 2:"))

add = a + b

sub = a - b

pro = a * b

div = a / b

floor_division = a // b

exponents = a ** b

mod = a % b

print('Addition of' ,a,'and',b,'is', add)

print('Subtraction of ',a,'and',b,'is', sub)

print('Product of ',a,'and',b,'is',pro)

print('Division of' ,a,'and',b,'is', div)

print('Floor division of',a,'and',b,'is',floor_division)

print('Exponents of',a,'and',b,'is',exponents)

print('Modulus of ',a,'and',b,'is', mod)


Question. Write the basic calculator in python.

You might also like