commit ae7026c56ede6e09dff37e9cc72e5556fe2e82db Author: cheeks <134818917+leftovertoast@users.noreply.github.com> Date: Mon Jan 20 16:39:02 2025 -0500 Initialized Repository diff --git a/Chapter_01/README.md b/Chapter_01/README.md new file mode 100644 index 0000000..8b069da --- /dev/null +++ b/Chapter_01/README.md @@ -0,0 +1 @@ +Chapter one focuses on setup and no coding exercises really take place. See Chapter_02 folder for start of coding exercies. \ No newline at end of file diff --git a/Chapter_02/2-10_favoriteNumber.py b/Chapter_02/2-10_favoriteNumber.py new file mode 100644 index 0000000..677ca85 --- /dev/null +++ b/Chapter_02/2-10_favoriteNumber.py @@ -0,0 +1,5 @@ +# Exercise 2-10 Favorite Number +# Learning Objective: Set a "favorite" number as a variable and print it. + +myFavoriteNum = 1337 +print(f"My favorite number is {myFavoriteNum}!") \ No newline at end of file diff --git a/Chapter_02/2-11_addingComments.py b/Chapter_02/2-11_addingComments.py new file mode 100644 index 0000000..1ae66f1 --- /dev/null +++ b/Chapter_02/2-11_addingComments.py @@ -0,0 +1,3 @@ +# Exercise 2-11 Adding Comments +# Learning Objective: Add comments to previous programs. (Completed) +print("COMPLETE") \ No newline at end of file diff --git a/Chapter_02/2-12_zenOfPython.py b/Chapter_02/2-12_zenOfPython.py new file mode 100644 index 0000000..880e7d2 --- /dev/null +++ b/Chapter_02/2-12_zenOfPython.py @@ -0,0 +1,4 @@ +# Exercise 2-12 Zen of Python +# Learning Objective: See output of program. + +import this \ No newline at end of file diff --git a/Chapter_02/2-1_simpleMessage.py b/Chapter_02/2-1_simpleMessage.py new file mode 100644 index 0000000..cb702ae --- /dev/null +++ b/Chapter_02/2-1_simpleMessage.py @@ -0,0 +1,5 @@ +# Exercise 2-1 Simple Message +# Learning Objective: Use a variable. + +message = "Hello Python World" +print(message) diff --git a/Chapter_02/2-2_simpleMessages.py b/Chapter_02/2-2_simpleMessages.py new file mode 100644 index 0000000..d8b42f2 --- /dev/null +++ b/Chapter_02/2-2_simpleMessages.py @@ -0,0 +1,6 @@ +# Exercise 2-2 Simple Messages +# Learning Objective: Reassign Variables +message = "Hello" +print(message) +message = "Goodbye" +print(message) \ No newline at end of file diff --git a/Chapter_02/2-3_personalMessage.py b/Chapter_02/2-3_personalMessage.py new file mode 100644 index 0000000..00d04c4 --- /dev/null +++ b/Chapter_02/2-3_personalMessage.py @@ -0,0 +1,4 @@ +# Exercise 2-3 Personal Message +# Learning Objective: Use a variable in a string. +name = "mister cheeks" +print("Hello " + name.title() + "!") \ No newline at end of file diff --git a/Chapter_02/2-4_nameCases.py b/Chapter_02/2-4_nameCases.py new file mode 100644 index 0000000..de4cfd2 --- /dev/null +++ b/Chapter_02/2-4_nameCases.py @@ -0,0 +1,7 @@ +# Exercise 2-4 Name Cases +# Learning Objective: Use the lower, upper, and title methods on a string variable. +name = "mister cheeks" +print(name.lower()) +print(name.upper()) +print(name.title()) + diff --git a/Chapter_02/2-5_famousQuote.py b/Chapter_02/2-5_famousQuote.py new file mode 100644 index 0000000..5fa3c11 --- /dev/null +++ b/Chapter_02/2-5_famousQuote.py @@ -0,0 +1,4 @@ +# Exercise 2-5 Famous Quote +# Learning Objective: Proper quotation mark usage. +quote = 'Sun Tzu once said "If ignorant both of your enemy and yourself, you are certain to be in peril." ' +print(quote) \ No newline at end of file diff --git a/Chapter_02/2-6_famousQuote2.py b/Chapter_02/2-6_famousQuote2.py new file mode 100644 index 0000000..501adee --- /dev/null +++ b/Chapter_02/2-6_famousQuote2.py @@ -0,0 +1,8 @@ +# Exercise 2-6 Famous Quote 2 +# Learning Objective: Same as 2-5 however utilizing variables to build the string, +# careful attention to quotations. + +famous_person = "sun tzu" +quote = "If ignorant both of your enemy and yourself, you are certain to be in peril." +message = famous_person.title() + ' once said, ' + '"' + quote + '"' +print(message) \ No newline at end of file diff --git a/Chapter_02/2-7_strippingNames.py b/Chapter_02/2-7_strippingNames.py new file mode 100644 index 0000000..ee305d5 --- /dev/null +++ b/Chapter_02/2-7_strippingNames.py @@ -0,0 +1,8 @@ +# Exercise 2-7 Stripping Names +# Learning Objective: Utilize rstrip(), lstrip(), and strip() methods on a string variable. + +name = " \tcheeks\n " +print(name) +print(name.lstrip()) +print(name.rstrip()) +print(name.strip()) \ No newline at end of file diff --git a/Chapter_02/2-8_fileExtensions.py b/Chapter_02/2-8_fileExtensions.py new file mode 100644 index 0000000..56dd320 --- /dev/null +++ b/Chapter_02/2-8_fileExtensions.py @@ -0,0 +1,6 @@ +# Excercise 2-8 File Extensions +# Learning Objective: Utilize removesuffix() method. Additionally one could use removeprefix() as well. + + +filename = "python_notes.txt" +print(filename.removesuffix('.txt')) diff --git a/Chapter_02/2-9_numberEight.py b/Chapter_02/2-9_numberEight.py new file mode 100644 index 0000000..7813871 --- /dev/null +++ b/Chapter_02/2-9_numberEight.py @@ -0,0 +1,15 @@ +# Exercise 2-8 Number Eight +# Learning Objective: Use math operations. + +#Addition +print(5+3) + +#Subtraction +print(10-2) + +#Multiplication +print(4*2) + +#Division +print(16/2) + diff --git a/Chapter_03/3-1_names.py b/Chapter_03/3-1_names.py new file mode 100644 index 0000000..e829419 --- /dev/null +++ b/Chapter_03/3-1_names.py @@ -0,0 +1,9 @@ +# Exercise 3-1 Names +# Learning Objective: Create and print a list. + +names = ['Tim', 'Steve', 'Aaron', 'Paul', 'Luke', 'Derek'] +print(names[0]) +print(names[1]) +print(names[2]) +print(names[3]) +print(names[4]) diff --git a/Chapter_03/3-2_greetings.py b/Chapter_03/3-2_greetings.py new file mode 100644 index 0000000..03e9da5 --- /dev/null +++ b/Chapter_03/3-2_greetings.py @@ -0,0 +1,12 @@ +# Exercise 3-2 Greetings +# Learning Objective: Use f-strings to print customized greetings to list members. + +names = ['Tim', 'Steve', 'Aaron', 'Paul', 'Luke', 'Derek'] + + + +print(f"Hey there, {names[0]}.") +print(f"Hey there, {names[1]}.") +print(f"Hey there, {names[2]}.") +print(f"Hey there, {names[3]}.") +print(f"Hey there, {names[4]}.") \ No newline at end of file diff --git a/Chapter_03/3-3_myOwnList.py b/Chapter_03/3-3_myOwnList.py new file mode 100644 index 0000000..ab4af5e --- /dev/null +++ b/Chapter_03/3-3_myOwnList.py @@ -0,0 +1,9 @@ +# Exercise 3-3 Your Own List +# Learning Objective: Create and print out a list using f-strings. + +cars = ['Honda', 'BMW', 'Audi', 'Toyota'] + +print(f"I would like to own a {cars[0]}") +print(f"I would like to own a {cars[1]}") +print(f"I would like to own a {cars[2]}") +print(f"I would like to own a {cars[3]}") \ No newline at end of file diff --git a/Chapter_03/3-4_guestList.py b/Chapter_03/3-4_guestList.py new file mode 100644 index 0000000..dc2a644 --- /dev/null +++ b/Chapter_03/3-4_guestList.py @@ -0,0 +1,15 @@ +# Exercise 3-4 Guest List +# Learning Objective: Create a list of invites for dinner. Print an invitation to each person. + + +#Guest List Ex 3-4 +guests = ['Tim', 'Steve', 'Aaron', 'Paul', 'Luke', 'Derek'] + +print(f"Hi there {guests[0]} please come over for dinner!") +print(f"Hi there {guests[1]} please come over for dinner!") +print(f"Hi there {guests[2]} please come over for dinner!") +print(f"Hi there {guests[3]} please come over for dinner!") +print(f"Hi there {guests[4]} please come over for dinner!") +print(f"Hi there {guests[5]} please come over for dinner!") + + diff --git a/Chapter_03/3-5_changingGuestList.py b/Chapter_03/3-5_changingGuestList.py new file mode 100644 index 0000000..b19a752 --- /dev/null +++ b/Chapter_03/3-5_changingGuestList.py @@ -0,0 +1,25 @@ +# Exercise 3-5 Changing Guest List +# Learning Objective: Remove an item from a list utilizing pop() method. + + +#Guest List Ex 3-4 +guests = ['Tim', 'Steve', 'Aaron', 'Paul', 'Luke', 'Derek'] + +print(f"Hi there {guests[0]} please come over for dinner!") +print(f"Hi there {guests[1]} please come over for dinner!") +print(f"Hi there {guests[2]} please come over for dinner!") +print(f"Hi there {guests[3]} please come over for dinner!") +print(f"Hi there {guests[4]} please come over for dinner!") +print(f"Hi there {guests[5]} please come over for dinner!") + +#Changing Guest List Ex 3-5 +cantMakeIt = guests.pop(1) +print(f"Unfortunately {cantMakeIt} can't make it.") +print(f"Hi there {guests[0]} please come over for dinner!") +print(f"Hi there {guests[1]} please come over for dinner!") +print(f"Hi there {guests[2]} please come over for dinner!") +print(f"Hi there {guests[3]} please come over for dinner!") +print(f"Hi there {guests[4]} please come over for dinner!") + + + diff --git a/Chapter_03/3-6_moreGuests.py b/Chapter_03/3-6_moreGuests.py new file mode 100644 index 0000000..db73329 --- /dev/null +++ b/Chapter_03/3-6_moreGuests.py @@ -0,0 +1,40 @@ +# Exercise 3-6 More Guests +# Learning Objective: Utitlize insert() & append() methods on a list to modify it. + + +#Guest List Ex 3-4 +guests = ['Tim', 'Steve', 'Aaron', 'Paul', 'Luke', 'Derek'] + +print(f"Hi there {guests[0]} please come over for dinner!") +print(f"Hi there {guests[1]} please come over for dinner!") +print(f"Hi there {guests[2]} please come over for dinner!") +print(f"Hi there {guests[3]} please come over for dinner!") +print(f"Hi there {guests[4]} please come over for dinner!") +print(f"Hi there {guests[5]} please come over for dinner!") + +#Changing Guest list Ex 3-5 +cantMakeIt = guests.pop(1) +print(f"Unfortunately {cantMakeIt} can't make it.") +print(f"Hi there {guests[0]} please come over for dinner!") +print(f"Hi there {guests[1]} please come over for dinner!") +print(f"Hi there {guests[2]} please come over for dinner!") +print(f"Hi there {guests[3]} please come over for dinner!") +print(f"Hi there {guests[4]} please come over for dinner!") + +#More Guests Ex 3-6 +print("Hey we got a bigger table!") + +guests.insert(0, 'Joey') +guests.insert(3, 'Kate') +guests.append('Patti') + +print(f"Hi there {guests[0]} please come over for dinner!") +print(f"Hi there {guests[1]} please come over for dinner!") +print(f"Hi there {guests[2]} please come over for dinner!") +print(f"Hi there {guests[3]} please come over for dinner!") +print(f"Hi there {guests[4]} please come over for dinner!") +print(f"Hi there {guests[5]} please come over for dinner!") +print(f"Hi there {guests[6]} please come over for dinner!") +print(f"Hi there {guests[7]} please come over for dinner!") + + diff --git a/Chapter_03/3-7_shrinkingGuestList.py b/Chapter_03/3-7_shrinkingGuestList.py new file mode 100644 index 0000000..a331353 --- /dev/null +++ b/Chapter_03/3-7_shrinkingGuestList.py @@ -0,0 +1,60 @@ +# Exercise 3-7 Shrinking Guest List +# Learning Objective: Utitlize pop() and del methods to empty the list and inform guests. + + +#Guest List Ex 3-4 +guests = ['Tim', 'Steve', 'Aaron', 'Paul', 'Luke', 'Derek'] + +print(f"Hi there {guests[0]} please come over for dinner!") +print(f"Hi there {guests[1]} please come over for dinner!") +print(f"Hi there {guests[2]} please come over for dinner!") +print(f"Hi there {guests[3]} please come over for dinner!") +print(f"Hi there {guests[4]} please come over for dinner!") +print(f"Hi there {guests[5]} please come over for dinner!") + +#Changing Guest list Ex 3-5 +cantMakeIt = guests.pop(1) +print(f"Unfortunately {cantMakeIt} can't make it.") +print(f"Hi there {guests[0]} please come over for dinner!") +print(f"Hi there {guests[1]} please come over for dinner!") +print(f"Hi there {guests[2]} please come over for dinner!") +print(f"Hi there {guests[3]} please come over for dinner!") +print(f"Hi there {guests[4]} please come over for dinner!") + +#More Guests Ex 3-6 +print("Hey we got a bigger table!") + +guests.insert(0, 'Peter') +guests.insert(3, 'Karen') +guests.append('Perry') + +print(f"Hi there {guests[0]} please come over for dinner!") +print(f"Hi there {guests[1]} please come over for dinner!") +print(f"Hi there {guests[2]} please come over for dinner!") +print(f"Hi there {guests[3]} please come over for dinner!") +print(f"Hi there {guests[4]} please come over for dinner!") +print(f"Hi there {guests[5]} please come over for dinner!") +print(f"Hi there {guests[6]} please come over for dinner!") +print(f"Hi there {guests[7]} please come over for dinner!") + +#Shrinking Guest List 3-7 +guestOut = guests.pop() +print(f"Sorry {guestOut}, the dinner is cancelled") +guestOut = guests.pop() +print(f"Sorry {guestOut}, the dinner is cancelled") +guestOut = guests.pop() +print(f"Sorry {guestOut}, the dinner is cancelled") +guestOut = guests.pop() +print(f"Sorry {guestOut}, the dinner is cancelled") +guestOut = guests.pop() +print(f"Sorry {guestOut}, the dinner is cancelled") +guestOut = guests.pop() +print(f"Sorry {guestOut}, the dinner is cancelled") + +print(f"Hey {guests[0]}, the dinner is still on, please join {guests[1]} and I.") +print(f"Hey {guests[1]}, the dinner is still on, please join {guests[0]} and I.") + +del guests[1] +del guests[0] + +print(f"LIST: {guests}") \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..6e90c74 --- /dev/null +++ b/README.md @@ -0,0 +1 @@ +This is a repo for No Starch Press Python Crash Course book. diff --git a/bookmark.md b/bookmark.md new file mode 100644 index 0000000..fc506ba --- /dev/null +++ b/bookmark.md @@ -0,0 +1,2 @@ +## Left off: +### 3rd edition - Chapter 3 - Pg 45 - 3-8 Seeing the World - Try it yourself \ No newline at end of file