This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
illegalCitizen = True | |
#inverses the boolean value | |
canBePresident = not illegalCitizen | |
print("Can be president: " str(canBePresident)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
older35 = True | |
citizen = False | |
#compares the two operands to see if one or more is True | |
canBePresident = older35 or citizen | |
print("Can be president: " str(canBePresident)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
older35 = True | |
citizen = False | |
# compares the two operands to see if both are True | |
canBePresident = older35 and citizen | |
print("Can be president: " str(canBePresident)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# create a variable containing a True boolean | |
canBePresident = True | |
# print the boolean value along with a message | |
print("You can be president: " + str(canBePresident)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# We start of with 12.00 | |
money = 12.00 | |
# We update the value and change it to 1200.00 | |
money = 1200.00 | |
# We print the new value, which is 1200.00 | |
print("$" + str(money)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
num1 = 6 | |
num2 = 5 | |
sum = num1 + num2 | |
print(sum) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# creates a variable called money and sets it equal to the string "12.50" | |
money = "12.50" | |
# creates a variable called moneyLeft and is equal to the string money converted to a float, minus 3. | |
moneyLeft = float(money) - 3 | |
# prints "Money Left: " followed by however much money they have left. | |
print("Money left: $" + str(moneyLeft)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This is a float (a decimal number) | |
money = 120.42 | |
# This is a boolean (True or False) | |
answer = True | |
# This is a string (It's in quotes) | |
greeting = "Hello... " | |
# This is also a string even though it's number | |
stringNum = "42" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# this is a comment | |
print("This is not") | |
# print("This line won't get run because it has a comment before it") | |
print("If you add a # in a print() function, it still get's printed") | |
print("You can add comments at the end of a line as well, like this --> ") # This is a comment |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# The print() function displays the argument the is passed into it | |
print("Hello, world!") |