Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
2 views

LAB 1 Python code

Uploaded by

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

LAB 1 Python code

Uploaded by

naveendeswal180
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Naveen , Naveen AERE 1610 Sprig 2025 Date: 4/11/2025

LAB 1 PYTHON

Problem 1 :

Input : # Naveen , Naveen , AERE 1610 , LAB 1 Python

# Prompt the user to enter an integer

number = int(input("Enter an integer: "))

# Check if the number is zero, even, or odd

if number == 0:

print("The number is zero.")

elif number % 2 == 0:

print("The number is even.")

else:

print("The number is odd.")

Output :

runfile('C:/Users/navee/.spyder-py3/untitled0.py', wdir='C:/Users/navee/.spyder-py3')

Enter an integer: 3

The number is odd.

Problem 5 :

Input : #Naveen, Naveen , AERE 1610 , Problem #5 # Lab 1

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.")

elif choice == '2':


radius = float(input("radius of the circle (in inches): "))
#Area of circle:
area = math.pi * radius**2
print(f" area of the circle is: {area:.2f} square inches.")

elif choice == '3':


length = float(input("length of the rectangle (in inches): "))
width = float(input("width of the rectangle (in inches): "))
#The area is defined as
area = length * width
print(f" area of the rectangle is: {area:.2f} square inches.")

else:
# show invalid choice when entered a different number.
print("Error: Invalid choice.enter 1, 2, or 3.")

#call the function to calculate the area of these three polygons.

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

Please choose one (1, 2, or 3): 7

Error: Invalid choice.enter 1, 2, or 3.

2. Circle

3. Rectangle

Please choose one (1, 2, or 3): 1

radius of the cylinder : 2

height of the cylinder : 3

The surface area of the cylinder is: 62.83 square inches.

runfile('C:/Users/navee/.spyder-py3/untitled0.py', wdir='C:/Users/navee/.spyder-py3')

Menu

1. Cylinder

2. Circle

3. Rectangle

Please choose one (1, 2, or 3): 5

Error: Invalid choice.enter 1, 2, or 3.

You might also like