Python type cast 💱

preview_player
Показать описание
Python type cast conversion tutorial explained

#Python #type #cast

#type casting = convert the data type of a value to another data type.

x = 1 #int
y = 2.0 #float
z = "3" #str

x = int(x)
y = int(y)
z = int(z)

x = float(x)
y = float(y)
z = float(z)

x = str(x)
y = str(y)
z = str(z)

print(x)
print(y)
print(z*3)
Рекомендации по теме
Комментарии
Автор

#type casting = convert the data type of a value to another data type.

x = 1 #int
y = 2.0 #float
z = "3" #str

x = int(x)
y = int(y)
z = int(z)

x = float(x)
y = float(y)
z = float(z)

x = str(x)
y = str(y)
z = str(z)

print(x)
print(y)
print(z*3)

BroCodez
Автор

Are there any disadvantages in using print (''X is'', x) instead of print (''X is '' + str(x))
Here we don't convert x to a string, however the code does print due to the comma. But what actually happens?

Will this lead to possible errors in later stages of our learning process? Both examples will print, however the first one is easier.

ivvwfvh
Автор

Great python lessons ! for many students

udomtipparach
Автор

Thank you for your help and your extremely on how you explain everything!!

tamekkaknuth
Автор

Thank you Bro Code for these lessons. ☺️

kiso
Автор

Why is java so hard in compared to python ?? Seriously tho, java been giving me headaches for days.

Caleepo
Автор

Is anyone else self-teaching themselves? I'm only a few days in

DavyDavePapi
Автор

tell me plz why i cant name a int class i typed school, class, good = "xyz", 10, False and it shoed me error thats class is not write plz anser me

davinho
Автор

Hey, what would be int(2.6)? would it be rounded up to 3 or just remain 2?

arkamukhopadhyay