Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Ask for room dimensions (x and y)
- while True:
- try:
- x = float(input("Enter the length of the room in meters: "))
- y = float(input("Enter the width of the room in meters: "))
- if x > 0 and y > 0:
- break
- else:
- print("Please enter positive values for room dimensions.")
- except ValueError:
- print("Invalid input. Please enter a number.")
- # Calculate the surface area
- surface_area = x * y
- print(f"The surface area of the room is {surface_area} square meters.")
- # Ask if user wants to add room height (z)
- while True:
- add_height = input("Do you want to add a room height? (yes/no): ")
- if add_height.lower() in ["yes", "no"]:
- break
- else:
- print("Invalid input. Please enter 'yes' or 'no'.")
- if add_height.lower() == "yes":
- # Ask for room height (z)
- while True:
- try:
- z = float(input("Enter the height of the room in meters: "))
- if z > 0:
- break
- else:
- print("Please enter a positive value for room height.")
- except ValueError:
- print("Invalid input. Please enter a number.")
- # Calculate the volume
- volume = x * y * z
- print(f"The volume of the room is {volume} cubic meters.")
- # Ask if user wants to know how many cubes fit in
- while True:
- add_cubes = input("Do you want to know how many 2x2 cubes fit in? (yes/no): ")
- if add_cubes.lower() in ["yes", "no"]:
- break
- else:
- print("Invalid input. Please enter 'yes' or 'no'.")
- if add_cubes.lower() == "yes":
- # Calculate the number of cubes that fit in
- num_cubes = volume / (2 ** 3)
- print(f"You can fit {int(num_cubes)} cubes of 2x2 meters in the room.")
- else:
- print("No height added.")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement