Elab Python 1 | PDF | Area | Arithmetic
50% found this document useful (4 votes)
7K views

Elab Python 1

The document contains examples of programs that take user input, perform calculations and logical operations, and output results. The programs demonstrate concepts like loops, arrays, matrices, conditional statements, and string formatting. Various math, statistical and geometric concepts are also explained through these examples.

Uploaded by

vaishnav.261204
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
50% found this document useful (4 votes)
7K views

Elab Python 1

The document contains examples of programs that take user input, perform calculations and logical operations, and output results. The programs demonstrate concepts like loops, arrays, matrices, conditional statements, and string formatting. Various math, statistical and geometric concepts are also explained through these examples.

Uploaded by

vaishnav.261204
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 16

Input

Level 1
Athika and Ritu got a nice job
basic=float(input())
sal=basic+(basic*0.8)+(basic*0.4)

print(f"{sal:.2f}")

Subash wants to find


pi= 3.142

r=float(input(""))

print("The area of the circle with radius",r,"is:",pi*r**2)

Compute the Area of the triangle


import math

s1=float(input(""))

s2=float(input(""))

s3=float(input(""))

s=(s1+s2+s3)/2

area=math.sqrt(s*(s-s1)*(s-s2)*(s-s3))

print("The area of triangle is",area)

Vignesh wants to display


name=input()

degree=input()

print("Name: {}\nDegree: {}".format(name,degree))

Pinnacio went to the school


G=int(input())

S=int(input())

print("The Range of given data =",G-S)

Aaron took his girl friend Binita


bill=int(input())

print("The Tax is {:.2f}\nThe Tip is {:.2f}\nTotal Bill With Tax and Tip
is{:.2f}".format(bill*0.18,bill*0.05,(bill+bill*0.18+bill*0.05)))
Vetrivel wants to convert
days=int(input())

hours=int(input())

minutes=int(input())

seconds=int(input())

print(days*86400+hours*3600+minutes*60+seconds)

Arif planned to make a room


l=float(input())

b=float(input())

print("{:.2f}".format(l*b))

Thanvi’s maths teacher taught


r=float(input())

pi=3.142

print(4/3*pi*r**3)

Nancy bought apples

n1=int(input())

n2=int(input())

print("QuoƟent:{}\nRemainder:{}".format(int(n1/n2),n1%n2))

Rathik organized technical round


num1=int(input())

num2=int(input())

print("Addition : ", num1+num2)

print("Subtraction : ", num1-num2)

print("Multiplication :", num1*num2)

print("Division:",round (num1/num2,3))

In geometry,the area
r=float(input())

print("The area of the circle with radius",r,"is: ",3.142*r*r)

Timothy Boon having the


frame=input()
name=input()

print("Hello", Iname, frame)

Selvan was playing with


I=int( input ())

w=int( input ())

h=int( input ())

print ((2*(w*l+1*h+h*w)))

Binita was travelling


time=int( input ()) min-time`

hrs = (time - min) / 66

print(f"prime prime \{hrs / 0 * f\} Hours and", min, "Minutes")

Level 2
Caleb is a physicist
import math

d=float(input())

print("{:.2f} m/s".format(math.sqrt(2*d*9.8)))

Arav was a popular maths trainer


num=int(input())

print(num%10)

Surya was used to wear


time = int(input())

hour = int(time / 3600)

time %= 3600

minutes = int(time / 60) time %= 60

print("{}H:{}M:{}S".format( hour, minutes, time))

Arul and Kani own the farm


r=float(input())

pi=3.14

print(f"{(pi*r**2):.2f}\n{(2*pi*r):.2f}")
Isaac loved to work
Sq_feet = float(input())

acres = sq_feet / 43560

print(f"{sq_feet} sq.ft is equal to {acres:.2f} acres")

Nancy is a data scientist


lst=input().split()

print(f"EmployeeID : {lst[2]}\nArea Code : {lst[3]}\nHouse Number : {lst[0]}\nPincode : {lst[1]}")

Program to compute a+aa+aaa+aaaa


a=input()

print(int(a)+int(a+a)+int(a+a+a)+int(a+a+a+a))

Flipkart announced the year end


n=int(input())

print(f"{n} {n**2} {n**3}")

Nedumaran Rajangam is an visionary


n=int(input())*185

print(f"Regular Price={n}\nAmount Discounted={n*0.6:.2f}\nAmount to be paid={n*0.4:.2f}")

Jannu and Preethi both went to Egypt


b,h=map(float, input().split(" "))

print(f"{b*h/2:.3f}")

Arulmozhivarman's Dream
import math

b=int( input ())

da=int( input ())

hra=int( input ())

g=(b+(da * b / 100 )+ (hra*b/100))

print (math.floor(g))

Karthik was working


hrs=float(input())

s=float(input(

print (f"{hrs * s:.2f} ")


Level 3
Vignesh wants to format
txt=input().split(" ")

print("I have {} dollars so I can buy {} football for {:.2f} dollars.".format(txt[1],txt[0],float(txt[2])))

Janaki wants to convert


print((int(input()))+2)

Thanvi is a SSLC student


ap=input().split(",")

t=int(input())

print(int(ap[1])-int(ap[0])+int(ap[t-2]))

Bitwise XOR of integers


xor=input().split(" ")

print(int(xor[0])^int(xor[1]))

Ford once was going down


time = int(input())

day = int(time / (24 * 3600))

time = time % (24 * 3600)

hour = int(time / 3600)

time %= 3600

minutes = int(time / 60)

time %= 60

print("The DuraƟon is {} days {} hours {} minutes {} seconds".format(day, hour, minutes, time))

Tina successfully completed


basicPay = float(input())

employeeFund = 17.5

employerFund = 23.5

employeeShare = (basicPay * 17.5) / 100

employerShare = (basicPay * 23.5) / 100

print("{:.2f}".format(employeeShare)) print("{:.2f}".format(employerShare))

Johnson was working as a captain


n=int(input())

y=int(n/365)

d=n%365

m=int(d/30)

print("{} Y(s) {} M(s) {} D(s)".format(y,m,m%30))

Sudan had a task


x1, y1 = map(float, input().split(','))

x2, y2 = map(float, input().split(','))

x3, y3 = map(float, input().split(','))

x = (x1 + x2 + x3) / 3

y = (y1 + y2 + y3) / 3

print(f"({x:.2f},{y:.2f})")

Sathya is an mathematical
expert base=float(input())

exp=float(input())

print(f"{base**exp:.2f}")

Krishna has just arrived in the city of Madhura


ap=input().split(",")

t=int(input())

print(int(ap[1])-int(ap[0])+int(ap[t-2]))

Madhan was working


km=float(input())

print (f" {km*1000:.2f} m")

print (f" {km*3280.84:.2f} ft")

print (f" {km*39370.1:.2f} in")

print (f" (km*100000:.2f} cm")

Shiva is part of
b1, b2,h=map (float, input().split())

print (f" (((b1+b2)/2)*h:.2f}")


Vignesh wants to formate
i, d1, d2-map (int, input().split())

print("I have", d1, "dollars so I can buy",i,f" football for {d2:.2f} dollars.")

Raja is statistician
m, n=map (float, input().split())

Mode=(3*m)-(2*n)

print (f"Mode={Mode: .2f}")

Janaki wants to Convert


a=int(input())

print(a+2)

Flow Control & Operators


LEVEL 1
Mrs.swathy is the principal
a=float(input())

b=float(input())

c=float(input())

d=float(input())

e=float(input())

g=((a+b+c+d+e)/500)*100

print(f"{g:.2f} Percent")

if g>=90:

print("Grade A")

elif g>=80:

print("Grade B")

elif g>=70:

print("Grade C")

elif g>=60:

print("Grade D")

elif g>=40:

print("Grade E")
else:

print("Grade F")

Selvan is working as a QC
a=input()

if a.isalpha():

print("ALPHABET")

else:

print("NOT AN ALPHABET")

A team from the royal


a=int(input())

w=int(input())

if 1<=a<=120:

if 25<=w<=85:

print("Eligible for Donation")

else:

print("Not Eligible for Donation")

else:

print("Not Eligible for Donation")

Caleb and salima


a=int(input())

b=int(input())

if a>b:

print(a-b)

else:

print(a+b)

Celeb and Irfan


a1=int(input())

a2=int(input())

a3=int(input())

if a1<a2 & a2<a3:


print("Fit into Budget")

else :

print("Doesn't fit into Budget")

Yasir a techie working


a=int(input())

if 0<a:

print("POSITIVE")

else:

print("NEGATIVE")

Simon was working


a=int(input())

if 0<a:

print("POSITIVE")

else:

print("NEGATIVE")

MR.issac the head


f=float(input())

c=(f-32)*(5/9)

print(f"{c:.2f} Centigrade")

if c>=150:

print("Very Hot")

elif c>=100:

print("Hot")

else:

print("Moderate")

Atifa would like to withdraw


w = int(input())

i = float(input())

if(w%5==0 and w<i):

t = i-w-0.5
print("Current Balance :","%.2f"%t)

print("Initial Balance :","%.2f"%i)

elif(w>i):

print("Invalid Withdrawal Request")

print("Initial Balance :","%.2f"%i)

else:

print("Invalid Withdrawal Request")

Arav and Aaron are


a=int(input())

b=int(input())

if a>b:

print(a-b)

else :

print(b-a)

The paytm announced


a=int(input())
b=a%2
if b ==0:
print("Even Currency")
else:
print("Odd Currency")

shree and Harry


value1 = float(input())
value2 = float(input())
if value1 > value2 and value1-value2 ==0.5:
print("Approximate Number")
if value2 > value1 and value2-value1 ==0.5:
print("Approximate Number")
else:
print("Not an Approximate Number");

salima was working


a=int(input())
b=float(input())
c=int(input())
discriminant=(b**2)-(4*a*c)
if discriminant>0:
root1=(-b+(discriminant**0.5))/(2*a)
print(f"{root1:.2f},{root2:.2f}")
else:
real_part=-b/(a)
imaginary_part=(abs(discriminant)**0.5)/(2*a)
print(f"{real_part/2:.2f} + i{imaginary_part:.2f} and {real_part/2:.2f} - i{imaginary_part:.2f}")

Arulmozhivarman the famous


c=input()
a=float(input())
b=float(input())
if c=="*":
print(a*b)
elif c=="+":
print(a+b)
elif c=="-":
print(a-b)
elif c=="/":
print(a/b)
else :
print("Invalid Input")

Arrays & Loops


Level 1
Akarh the die heart
n = int(input())
for i in range(n, 0, -1):
for j in range(i):
print(i, end=" ")
print()

Mathematics teacher gave


row = int(input())
col = int(input())
a1 = []
a2 = []
result = []
for i in range(row):
a1.append([])
for j in range(col):
l = int(input())
a1[i].append(l)
for i in range(row):
a2.append([])
for j in range(col):
l = int(input())
a2[i].append(l)
for i in range(row):
result.append([])
for j in range(col):
result[i].append(a1[i][j] + a2[i][j])
for i in range(row):
for j in range(col):
print(result[i][j], end=" ")
print()

Thanos and iron man


n = int(input())
numbers =[]
odd=[]
even=[]
for i in range(0,n):
numbers.append(int(input()))
for j in range(0,n):
if numbers[j]%2==0:
even.append(numbers[j])
else:
odd.append(numbers[j])
for i in range(0,len(even)):
print(even[i],end=" ")
print()
for j in range(0,len(odd)):
print(odd[j],end=" ")

In the battle of Kurukshetra


a = int(input())
for i in range(0,a+2):
for j in range(i-1):
print("*",end=" ")
print("")

In our institution
rows = int(input())
pattern_list = []
for i in range(1, rows + 1):
line = []
for j in range(ord('a'), ord('a') + i):
line.append(chr(j))
pattern_list.append(line)
for line in pattern_list:
print(" ".join(line),"")

Ganapathy the Mathematics


n = int(input())
for i in range(1, n + 1):
for j in range(i):
if i % 2 == 1:
print("Pass", end=" ")
else:
print("Fail", end=" ")
print()

Yogesh booked the ticket


num_lines = int(input())
for i in range(1, num_lines + 1):
for j in range(i):
print(i, end=" ")
print()

Matrix is a rectangle
r = int(input())
c = int(input())
matrix = []
for j in range(r):
a = []
for j in range(c):
a.append(int(input()))
matrix.append(a)
for j in range(c):
for i in range(r):
print(matrix[i][j], end=" ")
print()

Matrix is a rectangle
r = int(input())
c = int(input())
matrix = []
for j in range(c):
a = []
for j in range(r):
a.append(int(input()))
matrix.append(a)
for i in range(c):
for j in range(r):
print(matrix[i][j],end=" ")
print()

For calculating median


n=int(input())
lst=[]
for i in range(n):
a=int(input())
lst.append(a)
lst1=lst.sort()
if n%2==0:
sum=lst[int(n/2)-1]+lst[int(n/2)]
med=sum/2
else:
med=lst[int(n/2)]
print(med)

Euler asked the question


n = int(input())
fac=[]
for i in range(n):
if i % 3 == 0 or i % 5 == 0:
fac.append(i)
sum = 0
for i in fac:
sum = sum + i
print(sum)

Mukesh and Salima


n = int(input())
a=[]
count = 0
for i in range(0, n):
l = int(input())
a.append(l)
for i in range(0, n):
for j in range(i+1, n):
if a[i] == a[j]:
count = count + 1
break
print(count)

Strings
Level 1
There are N students
t=int(input())
while t>0:
s=input()
p,res=0,0
while p+1<len(s):`
if(s[p]!=s[p+1]):
res=res+1
p=p+1
p=p+1
print(res)
t=t-1
# students=str(input())
# i=len(students)
# else

You might also like