PYTHON PROGRAMMING LAB EXERCISES

PYTHON PROGRAMMING LAB EXERCISES 

LAB 1: Print your name

print("My name is Alex")

 LAB 2: Input and print a message

name = "Write your name: "

print("Hello,", name)

 LAB 3: Add Two Numbers

a = 10

b = 5

print(a + b)

 LAB 4: Simple Interest

p = 1000

r = 5

t = 2

si = (p*r*t)/100

print("Simple Interest =", si)

 LAB 5: Even or Odd

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

if num % 2 == 0:

    print("Even")

else:

    print("Odd")

 LAB 6: Multiplication Table

n = 7

for i in range(1, 11):

    print(n, "x", i, "=", n*i)

 LAB 7: Largest of Two Numbers

a = int(input("Enter first number: "))
b = int(input("Enter second number: "))
if a > b:
    print(a, "is larger")
elif b > a:
    print(b, "is larger")
else:
    print("Both numbers are equal")

LAB 8. Reverse a word

word = input("Enter a word: ")

print(word[::-1])

 LAB 9. Largest of three numbers

a = 10

b = 25

c = 7

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

 LAB 10. Simple calculator

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

b = int(input("Enter second number: "))

print("Addition:", a + b)

print("Subtraction:", a - b)

print("Multiplication:", a * b)

print("Division:", a / b)


Post a Comment

0 Comments
* Please Don't Spam Here. All the Comments are Reviewed by Admin.