8000 Merge branch 'modules-and-packages-solutions' · cybryant/python-basics-exercises@d73b863 · GitHub
[go: up one dir, main page]

Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit d73b863

Browse files
committed
Merge branch 'modules-and-packages-solutions'
2 parents 30c3f99 + 8f87e0d commit d73b863

File tree

62 files changed

+66
-28
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+66
-28
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Ch 11.1 - Modules and Packages
2+
# Solution to Exercise 1
3+
4+
5+
def greet(name):
6+
print(f"Hello {name}!")
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Ch 11.1 - Modules and Packages
2+
# Solution to Exercise 2
3+
4+
import greeter
5+
6+
7+
greeter.greet("Real Python")
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Ch 11.2 - Working With Packages
2+
# __init__.py - Part of solution to Exercise 1
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Ch 11.2 - Working With Packages
2+
# helpers/math.py - Part of solution to Exercise 1
3+
4+
5+
def area(length, width):
6+
return length * width
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Ch 11.2 - Working With Packages
2+
# helpers/string.py - Part of solution to Exercise 1
3+
4+
5+
def shout(string):
6+
return string.upper()
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Ch 11.2 - Working With Packages
2+
# main.py - Solution to Exercise 2
3+
4+
from helpers.string import shout
5+
from helpers.math import area
6+
7+
8+
length = 5
9+
width = 8
10+
message = f"The area of a {length}-by-{width} rectangle is {area(length, width)}"
11+
print(shout(message))

ch11-file-input-and-output/2-working-with-file-paths-in-python.py renamed to ch12-file-input-and-output/2-working-with-file-paths-in-python.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# 11.2 - Working With File Paths in Python
1+
# 12.2 - Working With File Paths in Python
22
# Solutions to review exercises
33

44

ch11-file-input-and-output/3-common-file-system-operations.py renamed to ch12-file-input-and-output/3-common-file-system-operations.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# 11.3 Common File System Operations
1+
# 12.3 Common File System Operations
22
# Solutions to Exercises
33

44

ch11-file-input-and-output/4-challenge-move-all-image-files-to-a-new-directory.py renamed to ch12-file-input-and-output/4-challenge-move-all-image-files-to-a-new-directory.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# 11.4 Challenge: Move All Image Files To a New Directory
1+
# 12.4 Challenge: Move All Image Files To a New Directory
22
# Solution to Challenge
33

44
from pathlib import Path

ch11-file-input-and-output/5-reading-and-writing-files.py renamed to ch12-file-input-and-output/5-reading-and-writing-files.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# 11.5 - Reading and Writing Files
1+
# 12.5 - Reading and Writing Files
22
# Solutions to Exercises
33

44

ch11-file-input-and-output/6-read-and-write-csv-data.py renamed to ch12-file-input-and-output/6-read-and-write-csv-data.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# 11.5 Read and Write CSV Data
1+
# 12.5 Read and Write CSV Data
22
# Solutions to Exercises
33

44

ch11-file-input-and-output/7-challenge-create-a-high-scores-list.py renamed to ch12-file-input-and-output/7-challenge-create-a-high-scores-list.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# 11.7 Challenge: Create a High Scores List
1+
# 12.7 Challenge: Create a High Scores List
22
# Solution to Challenge
33

44
import csv

ch13-interact-with-pdf-files/1-extract-text-from-a-pdf.py renamed to ch14-interact-with-pdf-files/1-extract-text-from-a-pdf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# 13.1 - Extract Text From a PDF
1+
# 14.1 - Extract Text From a PDF
22
# Solutions to review exercises
33

44

ch13-interact-with-pdf-files/2-extract-pages-from-a-pdf.py renamed to ch14-interact-with-pdf-files/2-extract-pages-from-a-pdf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# 13.2 - Extract Pages From a PDF
1+
# 14.2 - Extract Pages From a PDF
22
# Solutions to review exercises
33

44
# ***********

ch13-interact-with-pdf-files/3-challenge-PdfFileSplitter-class.py renamed to ch14-interact-with-pdf-files/3-challenge-PdfFileSplitter-class.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# 13.5 - Challenge: PdfFileSplitter Class
1+
# 14.5 - Challenge: PdfFileSplitter Class
22
# Solution to challenge
33

44
from pathlib import Path

ch13-interact-with-pdf-files/4-concatenating-and-merging-pdfs.py renamed to ch14-interact-with-pdf-files/4-concatenating-and-merging-pdfs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# 13.4 - Concatenating and Merging PDFs
1+
# 14.4 - Concatenating and Merging PDFs
22
# Solutions to review exercises
33

44
# ***********

ch13-interact-with-pdf-files/5-rotating-and-cropping-pdf-pages.py renamed to ch14-interact-with-pdf-files/5-rotating-and-cropping-pdf-pages.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# 13.5 - Rotating and Cropping PDF pages
1+
# 14.5 - Rotating and Cropping PDF pages
22
# Solutions to review exercises
33

44
# ***********

ch13-interact-with-pdf-files/6-encrypting-and-decrypting-pdfs.py renamed to ch14-interact-with-pdf-files/6-encrypting-and-decrypting-pdfs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# 13.6 - Encrypting and Decrypting PDFs
1+
# 14.6 - Encrypting and Decrypting PDFs
22
# Solutions to review exercises
33

44
# ***********

ch13-interact-with-pdf-files/7-challenge-unscramble-a-pdf.py renamed to ch14-interact-with-pdf-files/7-challenge-unscramble-a-pdf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# 13.7 - Challenge: Unscramble a PDF
1+
# 14.7 - Challenge: Unscramble a PDF
22
# Solution to challenge
33

44
from pathlib import Path

ch14-sql-database-connections/1-use-sqlite.py renamed to ch15-sql-database-connections/1-use-sqlite.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# 14.1 - Use SQLite
1+
# 15.1 - Use SQLite
22
# Solutions to review exercises
33

44
import sqlite3

ch15-interacting-with-the-web/1-scrape-and-parse-text-from-websites.py renamed to ch16-interacting-with-the-web/1-scrape-and-parse-text-from-websites.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# 15.1 - Scrape and Parse Text From Websites
1+
# 16.1 - Scrape and Parse Text From Websites
22
# Solutions to review exercises
33

44
from urllib.request import urlopen

ch15-interacting-with-the-web/2-use-an-html-parser-to-scrape-websites.py renamed to ch16-interacting-with-the-web/2-use-an-html-parser-to-scrape-websites.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# 15.2 - Use an HTML Parser to Scrape Websites
1+
# 16.2 - Use an HTML Parser to Scrape Websites
22
# Solutions to review exercises
33

44
# Make sure BeautifulSoup is installed first with:

ch15-interacting-with-the-web/3-interact-with-html-forms.py renamed to ch16-interacting-with-the-web/3-interact-with-html-forms.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# 15.3 - Interact with HTML Forms
1+
# 16.3 - Interact with HTML Forms
22
# Solutions to review exercises
33

44
# Make sure BeautifulSoup is installed first with:

ch15-interacting-with-the-web/4-interact-with-websites-in-realtime.py renamed to ch16-interacting-with-the-web/4-interact-with-websites-in-realtime.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# 15.4 - Interact With Websites in Real-Time
1+
# 16.4 - Interact With Websites in Real-Time
22
# Solutions to review exercise
33

44
# Make sure BeautifulSoup is installed first with:

ch16-scientific-computing-and-graphing/1-use-numpy-for-matrix-manipulation.py renamed to ch17-scientific-computing-and-graphing/1-use-numpy-for-matrix-manipulation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# 16.2 - Use matplotlib for Plotting Graphs
1+
# 17.2 - Use matplotlib for Plotting Graphs
22
# Solution to review exercise #2
33

44
# Setup

ch16-scientific-computing-and-graphing/2-use-matplotlib-for-plotting-graphs.py renamed to ch17-scientific-computing-and-graphing/2-use-matplotlib-for-plotting-graphs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# 16.3 - Use matplotlib for Plotting Graphs
1+
# 17.3 - Use matplotlib for Plotting Graphs
22
# Solution to review exercise #2
33

44
# Graph pirates versus global warming

ch17-graphical-user-interfaces/1-add-gui-elements-with-easygui.py renamed to ch18-graphical-user-interfaces/1-add-gui-elements-with-easygui.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# 17.1 - Add GUI Elements with EasyGUI
1+
# 18.1 - Add GUI Elements with EasyGUI
22
# Review Exercises
33

44
import easygui as gui

ch17-graphical-user-interfaces/10-challenge-return-of-the-poet.py renamed to ch18-graphical-user-interfaces/10-challenge-return-of-the-poet.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# 17.10 - Challenge: Return of the Poet
1+
# 18.10 - Challenge: Return of the Poet
22
# Solution to challenge
33

44
# Please note that there are many ways to solve this challenge. The code

ch17-graphical-user-interfaces/2-example-app-pdf-page-rotator.py renamed to ch18-graphical-user-interfaces/2-example-app-pdf-page-rotator.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# 17.2 - Example App: PDF Page Rotator
1+
# 18.2 - Example App: PDF Page Rotator
22
# Review Exercise #1
33

44
import easygui as gui

ch17-graphical-user-interfaces/3-challenge-use-gui-elements-to-help-a-user-modify-files.py renamed to ch18-graphical-user-interfaces/3-challenge-use-gui-elements-to-help-a-user-modify-files.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# 17.3 - Challenge: Use GUI Elements to Help a User Modify Files
1+
# 18.3 - Challenge: Use GUI Elements to Help a User Modify Files
22
# Solution to challenge
33

44
# save part of a PDF based on a user-supplied page range using a GUI

ch17-graphical-user-interfaces/4-introduction-to-tkinter.py renamed to ch18-graphical-user-interfaces/4-introduction-to-tkinter.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# 17.4 - Introduction to Tkinter
1+
# 18.4 - Introduction to Tkinter
22
# Review exercises
33

44
import tkinter as tk

ch17-graphical-user-interfaces/5-working-with-widgets.py renamed to ch18-graphical-user-interfaces/5-working-with-widgets.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# 17.4 - Introduction to Tkinter
1+
# 18.4 - Introduction to Tkinter
22
# Review exercises
33

44
import tkinter as tk

ch17-graphical-user-interfaces/6-control-layout-with-geometry-managers.py renamed to ch18-graphical-user-interfaces/6-control-layout-with-geometry-managers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# 17.6 - Control Layout With Geometry Managers
1+
# 18.6 - Control Layout With Geometry Managers
22
# Review Exercise #2
33

44
# NOTE: The first exercise in this section is instructional and does

ch17-graphical-user-interfaces/7-make-your-applications-interactive.py renamed to ch18-graphical-user-interfaces/7-make-your-applications-interactive.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# 17.7 - Make Your Applications Interactive
1+
# 18.7 - Make Your Applications Interactive
22
# Review Exercises
33

44

0 commit comments

Comments
 (0)
0