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
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
This is absolutely insane. I understood moore about typecasting in 7 mins than university course. Brilliant!
I love how bro almost put his GPA as 4.0 and then backspaced 😂
String: "I am so happy!" Integers: 25 Float: 2.25 Boolean: is_sunday= True/False
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.
❤❤❤❤
usefull:goodvibes:
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
Great explanation
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.
Liked yhe video
wow very cool
I glad to see your channel grow and learning program from your channel, being game programmer is always my dream.
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
helpfull and thankyou
student = True print(student) print(type(student)) student = str(student) print(student) print(type(student)) True <class 'bool'> True <class 'str'>
@BroCodez