0
completely lost
I am a noob to orogramming but was understanding everything up to this point. What exactly is the determining factor in deciding if something is true or false
5 Respuestas
+ 1
One way, you can assign it a value of True or False
running = True
now the variable running is true.
Some things are just simply true or false
if 1 == 1:
This returns True because 1 is in fact equal to 1.
if 1 == 2:
This returns False because 1 does not equal 2.
0
Oh so same thing with a string then?
So like Harry == Harry that's why that's true
But Harry == Travis is false cause not the same or doesn't cancel each other out?
0
yes.
"Harry" == "Harry" is True
"Harry" == "Travis" is False
0
one thing to keep in mind.. Python takes input() as a string by default. so if you say something like
age=input("Enter Age:")
if age==18:
//Do Stuff
This will always return false even if 18 is entered. It will be checking the string "18" instead of the number 18. To do that you would typically take the input as an int. There are other ways, but here is the most common
age=int(input("Enter Age:"))
0
Okay thank you just need to keep practicing and absorbing. Thanks for taking your time to elaborate for me.