Skip to content

Instantly share code, notes, and snippets.

View lbattaglioli2000's full-sized avatar
🏠
Working from home

Luigi Battaglioli lbattaglioli2000

🏠
Working from home
View GitHub Profile
@lbattaglioli2000
lbattaglioli2000 / adventure.py
Created February 6, 2016 03:27
Our take on Will Crowther's text adventure game.
def takeCanoe():
print("hi")
def keepWalking():
print("After walking for another mile, you encounter a tombstone.")
print("At the base of the tombstone, there is a ferrel cat playing with a coin.")
print("The cat paws the coin in your direction, almost telling you to look at the coin.")
print("You look at the coin and notice it's not a real coin. It appears as if there is a map engraved "
"on it.")
print("")
@lbattaglioli2000
lbattaglioli2000 / print.py
Created March 7, 2016 03:37
Sample print function
# The print() function displays the argument the is passed into it
print("Hello, world!")
@lbattaglioli2000
lbattaglioli2000 / comments.py
Created March 7, 2016 03:41
Sample comments
# 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
@lbattaglioli2000
lbattaglioli2000 / variables.py
Created March 7, 2016 19:09
Intro example to variables
# 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"
# 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))
num1 = 6
num2 = 5
sum = num1 + num2
print(sum)
# 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))
# create a variable containing a True boolean
canBePresident = True
# print the boolean value along with a message
print("You can be president: " + str(canBePresident))
older35 = True
citizen = False
# compares the two operands to see if both are True
canBePresident = older35 and citizen
print("Can be president: " str(canBePresident))
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))