Python weight conversion exercise 🏋️

preview_player
Показать описание
#Python #course #tutorial

Python exercises for beginners

# Python weight converter

weight = float(input("Enter your weight: "))
unit = input("Kilograms or Pounds? (K or L): ")

if unit == "K":
weight = weight * 2.205
unit = "Lbs."
print(f"Your weight is: {round(weight, 1)} {unit}")
elif unit == "L":
weight = weight / 2.205
unit = "Kgs."
print(f"Your weight is: {round(weight, 1)} {unit}")
else:
print(f"{unit} was not valid")
Рекомендации по теме
Комментарии
Автор

# Python weight converter

weight = float(input("Enter your weight: "))
unit = input("Kilograms or Pounds? (K or L): ")

if unit == "K":
weight = weight * 2.205
unit = "Lbs."
print(f"Your weight is: {round(weight, 1)} {unit}")
elif unit == "L":
weight = weight / 2.205
unit = "Kgs."
print(f"Your weight is: {round(weight, 1)} {unit}")
else:
print(f"{unit} was not valid")

BroCodez
Автор

Every thing is easy when your teacher is an alpha✌

siddharthsingh
Автор

I like those, keep going, I was learing python but I can't keep on cause school, but I sill watch your vids and love them bro!

bashar
Автор

I added a twist by creating a bmi calculator which includes a weight and height converter, if the bmi is above 25 it prints "ur fat haha"

alisajjad
Автор

Radhe Radhe
Sanatan Hi Satya Hai
Jai To All Gods & Godesses
Jai Baba Farid Ji
Radhaswami Ji

aijazbirsfun
Автор

I have started to learn Python and i would like to tell you that you are one of the best i have watched.
You explain it very simply and clearly, this shows me that you know what you are doing.
On the occasion that you started Python videos again, i would like to suggest that you also make some multimedia videos, for example, How you can create in the right way many images audio and video objects and place them in the right way in your window and when you maximize the window they are placed in the right positions automatically.

I hope i didn't tire you. Thank you again.

panagiotiskougioumtzidis
Автор

Data Structures and Algorithm with Python please 🥺

iamfkhn
Автор

I've been following this series for a couple of days now...i tend to write the code as explained orally before Bro writes his own and I actually wrote a shorter code than Bro's with the unit (kg /lb) within the print line. This made me so proud of myself! 😇🥳

hamzazad
Автор

Just a question why does he use Phycharm rather than using phyton? (phyton IDLE)

johnavon
Автор

#Python temp convertion
temp = float(input('enter temp'))
typeoftemp = input('is it in (c or f ?)')
temp1 = (temp *(9/5))+32
temp2 = (temp -32)*(5/9)
if typeoftemp == 'f' :
print(f' the temp is{temp2}')
elif typeoftemp == 'c' :
print(f'the temp is {temp1}')
else:
print(f'type of temp {typeoftemp} is incompatible')

leprot.h
Автор

Bro can u explain leetcode problems please

sasikiranvvrm
Автор

You're pretty much the only youtuber i feel obliged to donate to, do you have a patreon link or something like that?

tboleon
Автор

im new but what application is this? Im not sure where to write my code

Benny-kjhh
Автор

Honest question here, why don't you just use exit??

zahranurrohma
Автор

height = float(input(" Enter you height: "))
print("Centimeters -> (Cm)")
print("Feet -> (Ft)")
unit = (input("Enter the unit of your height: "))
if unit.lower() == "cm":
ft = height / 30.48
print(f"Your height in ft equals: {round(ft, 2)} ft")
elif unit.lower() == "ft":
cm = height * 30.48
print(f"Your unit in cm equal: {round(cm, 2)} cm")
else:
print("This is not a proper unit.")

niceballz
Автор

What is the function for having f in print(f"{unit etc etc. Thanks! Love your videos btw Bro Code!

shocky
Автор

i have a question. when the user puts the wrong weight unit, how can you loop it back to the second question? thank you

ronnipas
Автор

Very nicely explained and very good example to convert any kind of measurement. In between I have small query. If I want to type K or L beside the value, how to create the command. Say for example I want to type 70K. Instead typying K in second line. Please anybody help me on this?

sunilpinto
Автор

i tried making this without watching the video first. heres what i made

weight = float(input("Enter your weight: "))
unit = input("Enter your unit (KG, LB): ")
if unit == "KG":
result = weight * 2.20462
print(f"{weight}kg converted to pounds is {round(result, 3)}lbs!")
elif unit == "LB":
result = weight * 0.45359237
print(f"{weight}lbs converted to kilograms is {round(result, 3)}kgs!")
else:
print("The unit you have entered is not valid.")


is this as good as what bro code made?

viazer
Автор

weight = float(input("Enter the weight: "))
unit = input("kilograms or pounds or grams? (kg or lb or g): ")

if unit == "kg":
result = weight * 2.204623
result2 = weight * 1000
print(f"The weight is {round(result, 3)} lbs")
print(f"The weight is {round(result2, 3)} g")
elif unit == "lb":
result = weight * 0.45359
result2 = weight * 453.5924
print(f"The weight is {round(result, 3)} kg")
print(f"The weight is {round(result2, 3)} g")
elif unit == "g":
result = weight * 0.001
result2 = weight * 0.002204623
print(f"The weight is {round(result, 3)} kg")
print(f"The weight is {round(result2, 3)} lbs")
else:
print(f"{unit}: Please enter a valid unit")

soupdog