diff --git a/sami/learn-python-the-hard-way/ex1.py b/sami/learn-python-the-hard-way/ex1.py new file mode 100644 index 0000000..e48aeab --- /dev/null +++ b/sami/learn-python-the-hard-way/ex1.py @@ -0,0 +1,8 @@ + +print("Hello World!") +print("Hello Again") +print("I like typing this.") +print("This is fun.") +print('Yay! Printing.') +print("I'd much rather you 'not'.") +print('I "said" do not touch this.') diff --git a/sami/learn-python-the-hard-way/ex2.py b/sami/learn-python-the-hard-way/ex2.py new file mode 100644 index 0000000..6f3b06c --- /dev/null +++ b/sami/learn-python-the-hard-way/ex2.py @@ -0,0 +1,9 @@ +# A comment, this is so you can read your program later. +# Anything after the # is ignored by python. + +print("I could have code like this.") # and the comment after is ignored + +# You can also use a comment to "disable" or comment out code: +# print("This won't run.") + +print("This will run.") diff --git a/sami/learn-python-the-hard-way/ex3.py b/sami/learn-python-the-hard-way/ex3.py new file mode 100644 index 0000000..8b294b5 --- /dev/null +++ b/sami/learn-python-the-hard-way/ex3.py @@ -0,0 +1,30 @@ +print("I will now count my chickens:") + + +print("Hens", 25 + 30 / 6) +print("Roosters", 100 - 25 * 3 % 4) + + +print("Now I will count the eggs:") + + +print(3 + 2 + 1 - 5 + 4 % 2 - 1 / 4 + 6) + + + +print("Is it true that 3 + 2 < 5 - 7?") + +print(3 + 2 < 5 - 7) + + + +print("What is 3 + 2?", 3 + 2) +print("What is 5 - 7?", 5 - 7) + +print("Oh, that's why it's False.") + +print("How about some more.") + +print("Is it greater?", 5 > -2) +print("Is it greater or equal?", 5 >= -2) +print("Is it less or equal?", 5 <= -2) diff --git a/sami/learn-python-the-hard-way/ex4.py b/sami/learn-python-the-hard-way/ex4.py new file mode 100644 index 0000000..d398aa3 --- /dev/null +++ b/sami/learn-python-the-hard-way/ex4.py @@ -0,0 +1,16 @@ +cars = 100 +space_in_a_car = 4.0 +drivers = 30 +passengers = 90 +cars_not_driven = cars - drivers +cars_driven = drivers +carpool_capacity = cars_driven * space_in_a_car +average_passengers_per_car = passengers / cars_driven + +print("There are", cars, "cars available.") +print("There are only", drivers, "drivers available.") +print("There will be", cars_not_driven, "empty cars today.") +print("We can transport", carpool_capacity, "people today.") +print("We have", passengers, "to carpool today.") +print("We need to put about", average_passengers_per_car, +"in each car.") diff --git a/sami/learn-python-the-hard-way/ex5.py b/sami/learn-python-the-hard-way/ex5.py new file mode 100644 index 0000000..c7cc314 --- /dev/null +++ b/sami/learn-python-the-hard-way/ex5.py @@ -0,0 +1,18 @@ +my_name = 'Zed A. Shaw' +my_age = 35 # not a lie +my_height = 74 # inches +my_weight = 180 # lbs +my_eyes = 'Blue' +my_teeth = 'White' +my_hair = 'Brown' + +print(f"Let's talk about {my_name}.") +print(f"He's {my_height} inches tall.") +print(f"He's {my_weight} pounds heavy.") +print("Actually that's not too heavy.") +print(f"He's got {my_eyes} eyes and {my_hair} hair.") +print(f"His teeth are usually {my_teeth} depending on the coffee.") + +# this line is tricky, try to get it exactly right +total = my_age + my_height + my_weight +print(f"If I add {my_age}, {my_height}, and {my_weight} I get {total}.") diff --git a/sami/learn-python-the-hard-way/ex6.py b/sami/learn-python-the-hard-way/ex6.py new file mode 100644 index 0000000..78bb00b --- /dev/null +++ b/sami/learn-python-the-hard-way/ex6.py @@ -0,0 +1,26 @@ +types_of_people = 10 +x = f"There are {types_of_people} types of people." + +binary = "binary" +do_not = "don't" +y = f"Those who know {binary} and those who {do_not}." + +print(x) +print(y) + +print(f"I said: {x}") +print(f"I also said: '{y}'") + + +hilarious = False + + +joke_evaluation = "Isn't that joke so funny?! {}" + + +print(joke_evaluation.format(hilarious)) + +w = "This is the left side of..." +e = "a string with a right side." + +print(w + e) diff --git a/sami/learn-python-the-hard-way/ex7.py b/sami/learn-python-the-hard-way/ex7.py new file mode 100644 index 0000000..bcbd941 --- /dev/null +++ b/sami/learn-python-the-hard-way/ex7.py @@ -0,0 +1,22 @@ +print("Mary had a little lamb.") +print("Its fleece was white as {}.".format('snow')) +print("And everywhere that Mary went.") +print("." * 10) +# what'd that do? + +end1 = "C" +end2 = "h" +end3 = "e" +end4 = "e" +end5 = "s" +end6 = "e" +end7 = "B" +end8 = "u" +end9 = "r" +end10 = "g" +end11 = "e" +end12 = "r" + +# watch end = ' ' at the end. try removing it to see what happens +print(end1 + end2 + end3 + end4 + end5 + end6, end=' ') +print(end7 + end8 + end9 + end10 + end11 + end12) diff --git a/sami/learn-python-the-hard-way/learn-python3-the-hard-way-nov-15-2018.pdf b/sami/learn-python-the-hard-way/learn-python3-the-hard-way-nov-15-2018.pdf new file mode 100644 index 0000000..c366f39 Binary files /dev/null and b/sami/learn-python-the-hard-way/learn-python3-the-hard-way-nov-15-2018.pdf differ diff --git a/sami/learn-python-the-hard-way/python.org b/sami/learn-python-the-hard-way/python.org new file mode 100644 index 0000000..eb95b25 --- /dev/null +++ b/sami/learn-python-the-hard-way/python.org @@ -0,0 +1,4 @@ +* Python +** Numbers and Math: Every programming language has some kind of way doing numbers and math +** Variables and Names : we need to use underscore with means an imaginary space between words in variable names +** a variable is nothing more than a name for something.