0% found this document useful (0 votes)
46 views2 pages

Python Exp4.5

Uploaded by

rafeulhasan2625
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)
46 views2 pages

Python Exp4.5

Uploaded by

rafeulhasan2625
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

[Link] user input of room temperature .

If the temperature is above 30 degree Celsius show a


message “It’s a hot [Link] plenty of water “. And if the temperature is less than 30 degree
Celsius the show a message “It’s a lovely day”.
Python input Python output

temperature = float(input("Enter the room temperature in Celsius: Enter the room temperature in Celsius:
")) 35

It's a hot day. Drink plenty of water.

# Check if temperature is above 30 degrees Celsius

if temperature > 30:

print("It's a hot day. Drink plenty of water.")

else:

print("It's a lovely day.")

2. Write a python program to convert a given weight to pound or kg according to user preference . Show the output
with convert unit.

Python input Python output

def kg_to_pounds(weight_kg):
Enter the weight:77
return weight_kg * 2.20462 Enter the unit(lb/kg):70
Invalid [Link] enter ‘lb’ or ‘kg’.

def pounds_to_kg(weight_pounds):

return weight_pounds * 0.453592

# Take user input for weight

weight = float(input("Enter the weight: "))

unit = input("Enter the unit (kg or lbs): ")

if [Link]() == 'kg':

weight_in_pounds = kg_to_pounds(weight)

print(f"{weight} kg is equal to {weight_in_pounds} pounds.")

elif [Link]() == 'lbs':

weight_in_kg = pounds_to_kg(weight)

print(f"{weight} pounds is equal to {weight_in_kg} kg.")

else:

print("Invalid unit. Please enter 'kg' or 'lbs'.")


[Link] a program in python to take user input for a single character and perform the following
operations based on the character.
If the character is a digit, check if it is even or odd and display the result.
If the character is an uppercase letter, display its corresponding lowercase letter .
If the character is a lowercase letter, display is corresponding uppercase letter.
If the character is a special character(not a digit or letter),display an error message.

Python input Python output

def kg_to_pounds(weight_kg): Enter a single character:5

return weight_kg * 2.20462 5 is an odd number.

def pounds_to_kg(weight_pounds):

return weight_pounds * 0.453592

# Take user input for weight

weight = float(input("Enter the weight: "))

unit = input("Enter the unit (kg or lbs): ")

if [Link]() == 'kg':

weight_in_pounds = kg_to_pounds(weight)

print(f"{weight} kg is equal to {weight_in_pounds} pounds.")

elif [Link]() == 'lbs':

weight_in_kg = pounds_to_kg(weight)

print(f"{weight} pounds is equal to {weight_in_kg} kg.")

else:

print("Invalid unit. Please enter 'kg' or 'lbs'.")

You might also like