Skip to content

Instantly share code, notes, and snippets.

@coffeechug
coffeechug / Lesson 2 - Increment a Variable
Created February 23, 2020 01:58
Simple code showcasing how to change value of a variable
lettuce = 23
print ("Lettuce is worth ", lettuce)
lettuce = lettuce + 1
print ("Lettuce is now worth ", lettuce)
@coffeechug
coffeechug / Challenge 2 - Knock Knock Joke
Created February 22, 2020 22:03
An example of a knock knock joke
print('Knock knock.')
while not input() == ("Who's there?"):
print('Knock knock')
print('Interrupting cow.')
while not input() == ("Interrupting cow who?"):
print('Interrupting cow.')
print('Interrupting cow who', end='')
print('MOO!')
@coffeechug
coffeechug / Challenge 1 - Year You Were Born
Created February 22, 2020 21:33
A challenge after the first 12 lessons of looking at Scratch vs. Python
name = input("What is your name?")
print("Hello " + name + ". It is nice to meet you")
age = input("How old are you?")
age = int(age)
print("You were born in "+ str(2020 - age))
correct = input("Is this correct? Y/N")
if correct == "Y":
print("Awesome")
else:
@coffeechug
coffeechug / Lesson 12 - Input
Created February 22, 2020 21:14
Example of using input command
name = input("Enter your name: ")
print("Hello", name)
@coffeechug
coffeechug / Lesson 11 - Index a List
Created February 22, 2020 20:33
How to access a specific object in a list
import random
value =['A', 'K', 'Q', 'J', '2', '3', '4', '5', '6', '7', '8', '9', '10']
suit =['Heart', 'Diamond', 'Club', 'Spade']
cardvalue = value[12]
cardsuit = suit[0]
specific_card = cardvalue+cardsuit
@coffeechug
coffeechug / Lesson 10 Concatenation
Created February 22, 2020 14:24
How to join two variables
a1 = input("What is your favorite color? ")
a2 = input("What is your favorite food? ")
print("Your favorite thing to eat is ", a1,""+a2)
@coffeechug
coffeechug / Lesson 9 Random Integer and Module
Created February 22, 2020 13:15
Exploring the Random Module to Choose a Random Number
import random #import the random module
#generate number in positive
positive = random.randint(0,100)
print("The random positive number is", positive)
#generate number in negative
negative = random.randint(-100,-1)
print("The random negative number is", negative)
import random
value =['A', 'K', 'Q', 'J', '2', '3', '4', '5', '6', '7', '8', '9', '10']
suit =['Heart', 'Diamond', 'Club', 'Spade']
random_value = random.choice(value)
random_suit = random.choice(suit)
random_card = random_value,random_suit