@BroCodez

# type casting = The process of converting a value of one data type to another
#                          (string, integer, float, boolean)
#                          Explicit vs Implicit

name = "Bro"
age = 21
gpa = 1.9
student = True

# print(type(name))
# print(type(age))
# print(type(gpa))
# print(type(student)) 

age = float(age)
print(age)

gpa = int(gpa)
print(gpa)

student = str(student)
print(student)

name = bool(name)
print(name)

@abdulhannan-18

Basically bool is to check whether that INPUT IS GIVEN OR NOT.

userinput = input("Your name: ")
userinput = bool(userinput)
print(userinput)

if user give any input then True if user does not give any input then False.

#code1

name = "Bro"
name = bool(name)
print(name)

True

#code2

name = ""             #empty string. As there is nothing that's why it will be false.
name = bool(name)
print(name)

False

@abdulhannan-18

imp    Only strings can concatenate.

student = True

print(student)
print(type(student))

student = str(student)
print(student)
print(type(student))

print("Hello" + student)

True
<class 'bool'>
True
<class 'str'>
HelloTrue

@Jezza-u6t

This is absolutely insane. I understood moore about typecasting in 7 mins than university course. Brilliant!

@joysticksforjesuschrist

I love how bro almost put his GPA as 4.0 and then backspaced 😂

@DáUmMix

String: "I am so happy!"
Integers: 25
Float: 2.25
Boolean: is_sunday= True/False

@haltsmaul.

Probably important to note that in other programming languages such as Java, you can't just change the data type of a variable.

int num = 3;
num = (float) num;

This would throw an exception because you can't assign a float to an integer variable.

@HoseinKhoshhal-x4b

❤❤❤❤

@zahraalemi1872

usefull:goodvibes:

@st0kersenpai

in my pycharm version when i convert a float to string it just round offs the number like 4.9 becomes 5 and while converting boolean to an integer true becomes 1 and false becomes 0

@EthioMediaCorporation

Great explanation

@notfairytales18

Typecasting is the process of converting one data type into another but at the end during closure of the topic you mention "strings to integers" or stings to float is impossible as it a Value Error.

@curiosity-u2f

Liked yhe video

@doggo2571

wow very cool

@earth7641

I glad to see your channel grow and learning program from your channel, being game programmer is always my dream.

@abdulhannan-18

When typecasting an integer to bool, it is always True for any positive or negative number except for.
For zero, it is false.

#code
age = 19

age = bool(age)

print(age)

True

#code
age = 0

age = bool(age)
print(age)

False

@BurhanTosuner

helpfull and thankyou

@abdulhannan-18

student = True

print(student)
print(type(student))

student = str(student)
print(student)
print(type(student))


True
<class 'bool'>
True
<class 'str'>