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

25th Jun 2017, 11:12 PM
Harry
5 odpowiedzi
+ 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.
25th Jun 2017, 11:26 PM
LordHill
LordHill - avatar
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?
25th Jun 2017, 11:28 PM
Harry
0
yes. "Harry" == "Harry" is True "Harry" == "Travis" is False
25th Jun 2017, 11:31 PM
LordHill
LordHill - avatar
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:"))
25th Jun 2017, 11:38 PM
LordHill
LordHill - avatar
0
Okay thank you just need to keep practicing and absorbing. Thanks for taking your time to elaborate for me.
27th Jun 2017, 9:49 PM
Harry