Skip to content

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

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy