Initialized Repository

This commit is contained in:
cheeks 2025-01-20 16:39:02 -05:00
commit ae7026c56e
22 changed files with 249 additions and 0 deletions

1
Chapter_01/README.md Normal file
View File

@ -0,0 +1 @@
Chapter one focuses on setup and no coding exercises really take place. See Chapter_02 folder for start of coding exercies.

View File

@ -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}!")

View File

@ -0,0 +1,3 @@
# Exercise 2-11 Adding Comments
# Learning Objective: Add comments to previous programs. (Completed)
print("COMPLETE")

View File

@ -0,0 +1,4 @@
# Exercise 2-12 Zen of Python
# Learning Objective: See output of program.
import this

View File

@ -0,0 +1,5 @@
# Exercise 2-1 Simple Message
# Learning Objective: Use a variable.
message = "Hello Python World"
print(message)

View File

@ -0,0 +1,6 @@
# Exercise 2-2 Simple Messages
# Learning Objective: Reassign Variables
message = "Hello"
print(message)
message = "Goodbye"
print(message)

View File

@ -0,0 +1,4 @@
# Exercise 2-3 Personal Message
# Learning Objective: Use a variable in a string.
name = "mister cheeks"
print("Hello " + name.title() + "!")

View File

@ -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())

View File

@ -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)

View File

@ -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)

View File

@ -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())

View File

@ -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'))

View File

@ -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)

9
Chapter_03/3-1_names.py Normal file
View File

@ -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])

View File

@ -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]}.")

View File

@ -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]}")

View File

@ -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!")

View File

@ -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!")

View File

@ -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!")

View File

@ -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}")

1
README.md Normal file
View File

@ -0,0 +1 @@
This is a repo for No Starch Press Python Crash Course book.

2
bookmark.md Normal file
View File

@ -0,0 +1,2 @@
## Left off:
### 3rd edition - Chapter 3 - Pg 45 - 3-8 Seeing the World - Try it yourself