Initialized Repository
This commit is contained in:
commit
ae7026c56e
1
Chapter_01/README.md
Normal file
1
Chapter_01/README.md
Normal 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.
|
||||
5
Chapter_02/2-10_favoriteNumber.py
Normal file
5
Chapter_02/2-10_favoriteNumber.py
Normal 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}!")
|
||||
3
Chapter_02/2-11_addingComments.py
Normal file
3
Chapter_02/2-11_addingComments.py
Normal file
@ -0,0 +1,3 @@
|
||||
# Exercise 2-11 Adding Comments
|
||||
# Learning Objective: Add comments to previous programs. (Completed)
|
||||
print("COMPLETE")
|
||||
4
Chapter_02/2-12_zenOfPython.py
Normal file
4
Chapter_02/2-12_zenOfPython.py
Normal file
@ -0,0 +1,4 @@
|
||||
# Exercise 2-12 Zen of Python
|
||||
# Learning Objective: See output of program.
|
||||
|
||||
import this
|
||||
5
Chapter_02/2-1_simpleMessage.py
Normal file
5
Chapter_02/2-1_simpleMessage.py
Normal file
@ -0,0 +1,5 @@
|
||||
# Exercise 2-1 Simple Message
|
||||
# Learning Objective: Use a variable.
|
||||
|
||||
message = "Hello Python World"
|
||||
print(message)
|
||||
6
Chapter_02/2-2_simpleMessages.py
Normal file
6
Chapter_02/2-2_simpleMessages.py
Normal file
@ -0,0 +1,6 @@
|
||||
# Exercise 2-2 Simple Messages
|
||||
# Learning Objective: Reassign Variables
|
||||
message = "Hello"
|
||||
print(message)
|
||||
message = "Goodbye"
|
||||
print(message)
|
||||
4
Chapter_02/2-3_personalMessage.py
Normal file
4
Chapter_02/2-3_personalMessage.py
Normal 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() + "!")
|
||||
7
Chapter_02/2-4_nameCases.py
Normal file
7
Chapter_02/2-4_nameCases.py
Normal 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())
|
||||
|
||||
4
Chapter_02/2-5_famousQuote.py
Normal file
4
Chapter_02/2-5_famousQuote.py
Normal 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)
|
||||
8
Chapter_02/2-6_famousQuote2.py
Normal file
8
Chapter_02/2-6_famousQuote2.py
Normal 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)
|
||||
8
Chapter_02/2-7_strippingNames.py
Normal file
8
Chapter_02/2-7_strippingNames.py
Normal 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())
|
||||
6
Chapter_02/2-8_fileExtensions.py
Normal file
6
Chapter_02/2-8_fileExtensions.py
Normal 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'))
|
||||
15
Chapter_02/2-9_numberEight.py
Normal file
15
Chapter_02/2-9_numberEight.py
Normal 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
9
Chapter_03/3-1_names.py
Normal 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])
|
||||
12
Chapter_03/3-2_greetings.py
Normal file
12
Chapter_03/3-2_greetings.py
Normal 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]}.")
|
||||
9
Chapter_03/3-3_myOwnList.py
Normal file
9
Chapter_03/3-3_myOwnList.py
Normal 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]}")
|
||||
15
Chapter_03/3-4_guestList.py
Normal file
15
Chapter_03/3-4_guestList.py
Normal 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!")
|
||||
|
||||
|
||||
25
Chapter_03/3-5_changingGuestList.py
Normal file
25
Chapter_03/3-5_changingGuestList.py
Normal 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!")
|
||||
|
||||
|
||||
|
||||
40
Chapter_03/3-6_moreGuests.py
Normal file
40
Chapter_03/3-6_moreGuests.py
Normal 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!")
|
||||
|
||||
|
||||
60
Chapter_03/3-7_shrinkingGuestList.py
Normal file
60
Chapter_03/3-7_shrinkingGuestList.py
Normal 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
1
README.md
Normal file
@ -0,0 +1 @@
|
||||
This is a repo for No Starch Press Python Crash Course book.
|
||||
2
bookmark.md
Normal file
2
bookmark.md
Normal file
@ -0,0 +1,2 @@
|
||||
## Left off:
|
||||
### 3rd edition - Chapter 3 - Pg 45 - 3-8 Seeing the World - Try it yourself
|
||||
Loading…
x
Reference in New Issue
Block a user