LAB 1 Python code
LAB 1 Python code
LAB 1 PYTHON
Problem 1 :
if number == 0:
elif number % 2 == 0:
else:
Output :
runfile('C:/Users/navee/.spyder-py3/untitled0.py', wdir='C:/Users/navee/.spyder-py3')
Enter an integer: 3
Problem 5 :
import math
def areaMenu(): # Display the menu print("Menu") print("1. Cylinder") print("2. Circle")
print("3. Rectangle")
# Make a choice
choice = input("Please choose one (1, 2, or 3): ")
if choice == '1':
radius = float(input("radius of the cylinder : "))
height = float(input("height of the cylinder : "))
area = 2 * math.pi * radius * (radius + height)
print(f"The surface area of the cylinder is: {area:.2f} square
inches.")
else:
# show invalid choice when entered a different number.
print("Error: Invalid choice.enter 1, 2, or 3.")
areaMenu()
Output :
runfile('C:/Users/navee/.spyder-py3/untitled0.py', wdir='C:/Users/navee/.spyder-py3')
Menu
1. Cylinder runfile('C:/Users/navee/.spyder-py3/untitled0.py',
wdir='C:/Users/navee/.spyder-py3')
Menu
1. Cylinder
2. Circle
3. Rectangle
2. Circle
3. Rectangle
runfile('C:/Users/navee/.spyder-py3/untitled0.py', wdir='C:/Users/navee/.spyder-py3')
Menu
1. Cylinder
2. Circle
3. Rectangle