0% found this document useful (0 votes)
14 views8 pages

Few Python Problems

The document contains a series of Python code snippets that demonstrate various programming concepts such as input handling, arithmetic operations, conditional statements, and class definitions. Each snippet is attributed to a different individual or scenario, showcasing different functionalities like calculating area, volume, salary, and checking eligibility. Overall, it serves as a collection of beginner-level Python exercises.

Uploaded by

Pro minded Robin
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)
14 views8 pages

Few Python Problems

The document contains a series of Python code snippets that demonstrate various programming concepts such as input handling, arithmetic operations, conditional statements, and class definitions. Each snippet is attributed to a different individual or scenario, showcasing different functionalities like calculating area, volume, salary, and checking eligibility. Overall, it serves as a collection of beginner-level Python exercises.

Uploaded by

Pro minded Robin
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

LEVEL 1 python

1. selvan

length = int(input())

width = int(input())

height = int(input())

print(2 * (width * length + length * height + height * width))

2. Sajid

x, y, z = input().split()

print(int(x)+int(y)+int(z))

3. Thanvi's maths teacher

rad = float(input())

volume = 4/3*3.142*(rad**3)

print(volume)

4. Electricity officer

x = int(input())

y = int(input())

tot = x**y

print(tot)

[Link] of triangle

import math

s1 = float(input())

s2 = float(input())

s3 = float(input())

s = (s1+s2+s3) / 2

area = [Link](s * (s - s1) * (s - s2) * (s - s3))

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


6. Laasya

r = float(input())

pi = 3.14

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

7. Athika and Ritu

basic=float(input())

HRA=float(0.8*basic)

DA=float(0.4*basic)

Salary= basic+HRA+DA

print('%.2f' %Salary)

[Link]

num1 = int(input())

num2 = int(input())

print("Addition : " + str(num1 + num2))

print("Subtraction : " + str(num1 - num2))

print("Multiplication : " + str(num1 * num2))

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

[Link]

bill = int(input())

tax = bill * 0.18

tip = bill * 0.05

total = bill + tax + tip

print("The Tax is", format(tax, ".2f"))

print("The Tip is", format(tip, ".2f"))

print("Total Bill With Tax and Tip is", format(total, ".2f"))


10. Nancy

amtgiven = int(input())

billamt = int(input())

quotient = amtgiven / billamt

remainder = amtgiven % billamt

print("Quotient:" + str(int(quotient)))

print("Remainder:" + str(remainder))

[Link] varma

op = input()

x = float(input())

y = float(input())

if op == "+":

print(x+y)

elif op == "-":

print(x-y)

elif op == "/":

print(x/y)

elif op == "*":

print(x*y)

else:

print("Invalid Input")

[Link] swathy

a=int(input())

b=int(input())

c=int(input())

d=int(input())

e=int(input())

avg=(a+b+c+d+e)/5
if avg>=90:

print(f"{avg:0.2f}", "Percent\nGrade A")

elif avg>=80:

print(f"{avg:0.2f}", "Percent\nGrade B")

elif avg>=70:

print(f"{avg:0.2f}", "Percent\nGrade C")

elif avg>=60:

print(f"{avg:0.2f}", "Percent\nGrade D")

elif avg>=50:

print(f"{avg:0.2f}", "Percent\nGrade E")

#else

13. Three brothers

h1=int(input())

h2=int(input())

h3=int(input())

max = 0

if h1>h2 and h1>h3:

max = h1

elif h2>h3 and h1>h3:

max = h2

else:

max = h3

print(max)

14. Caleb and Irfan

a=int(input())

b=int(input())

c=int(input())

if b>a and c>b:

print("Fit into Budget")


else:

print("Doesn't fit into Budget")

15. Selvan

a = input()

if [Link]():

print("NOT AN ALPHABET")

else:

print("ALPHABET")

16. Aarav

a=int(input())

b=int(input())

if a>b:

print("Lo")

else:

print("Profit")

17. Election committee

n=int(input())

if n<18:

print("Not Eligible")

else:

print("Eligible")

18. A team from roya

x = int(input())

y = int(input())

if (1<x<=120) and (25<=y<=85):

print("Eligible for Donation")

else:
print("Not Eligible for Donation")

[Link]

a = float(input())

b = int(input())

c = int(input())

real = -b / (2 * a)

imag = ((b ** 2 - 4 * a * c) ** 0.5) / (2 * a) if (b ** 2 - 4 * a * c) >= 0 else ((4 * a * c - b ** 2) ** 0.5) /


(2 * a)

if b ** 2 - 4 * a * c >= 0:

root1 = real + imag

root2 = real - imag

print(f"{root1} and {root2}")

else:

print(f"{real:.2f} + i{imag:.2f} and {real:.2f} - i{imag:.2f}")

20. Ganapathy

n = int(input())

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

if i % 2 == 1:

word = "Pass"

else:

word = "Fail"

for j in range(i):

print(word, end=" ")

print() # move to next line

21. Kurukshetra

n = int(input())

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


for j in range(i):

print("*", end=" ")

print()

22.. Akash the die heart

n = int(input())

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

for j in range(i):

print(i, end=" ")

print()

23. Adam

class Operation:

def __init__(self, a, b):

self.a = a

self.b = b

def addition(self):

return self.a + self.b

def subtraction(self):

return self.a - self.b

a = int(input())

b = int(input())

obj = Operation(a, b)

print([Link]())

print([Link]())
24. Nathan

class NumberChecker:

def __init__(self, n):

self.n = n

def check_number(self):

if self.n > 0:

return "+ve"

elif self.n < 0:

return "-ve"

else:

return "zero"

n = int(input())

obj = NumberChecker(n)

print(obj.check_number())

#class check:

#def check(self):

You might also like