From 921dc7d612c07d3358858a0820471da0bfe30225 Mon Sep 17 00:00:00 2001 From: martin-martin Date: Wed, 2 Aug 2023 12:58:04 +0200 Subject: [PATCH 1/5] Fix typos in comments --- ch08-conditional-logic/6-recover-from-errors.py | 2 +- .../8b-challenge-simulate-a-coin-toss-experiment.py | 2 +- .../8c-challenge-simulate-a-coin-toss-experiment.py | 4 ++-- ch08-conditional-logic/9a-challenge-simulate-an-election.py | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/ch08-conditional-logic/6-recover-from-errors.py b/ch08-conditional-logic/6-recover-from-errors.py index 157536d..250144b 100644 --- a/ch08-conditional-logic/6-recover-from-errors.py +++ b/ch08-conditional-logic/6-recover-from-errors.py @@ -15,7 +15,7 @@ # Exercise 2 -# Print character and specifid index in string +# Print character and specified index in string input_string = input("Enter a string: ") diff --git a/ch08-conditional-logic/8b-challenge-simulate-a-coin-toss-experiment.py b/ch08-conditional-logic/8b-challenge-simulate-a-coin-toss-experiment.py index a01a8ce..9f3effe 100644 --- a/ch08-conditional-logic/8b-challenge-simulate-a-coin-toss-experiment.py +++ b/ch08-conditional-logic/8b-challenge-simulate-a-coin-toss-experiment.py @@ -31,7 +31,7 @@ def coin_flip(): first_flip = coin_flip() flips = flips + 1 # Continue flipping the coin and updating the tally until - # a different result is returned by coin_flips() + # a different result is returned by coin_flip() while coin_flip() == first_flip: flips = flips + 1 # Increment the flip tally once more to account for the diff --git a/ch08-conditional-logic/8c-challenge-simulate-a-coin-toss-experiment.py b/ch08-conditional-logic/8c-challenge-simulate-a-coin-toss-experiment.py index 5d1e075..753e91d 100644 --- a/ch08-conditional-logic/8c-challenge-simulate-a-coin-toss-experiment.py +++ b/ch08-conditional-logic/8c-challenge-simulate-a-coin-toss-experiment.py @@ -16,9 +16,9 @@ def single_trial(): - """Simulate repeatedly a coing until both heads and tails are seen.""" + """Simulate repeatedly flipping a coin until both heads and tails are seen.""" # This function uses random.randint() to simulate a single coin toss. - # randing(0, 1) randomly returns 0 or 1 with equal probability. We can + # randint(0, 1) randomly returns 0 or 1 with equal probability. We can # use 0 to represent heads and 1 to represent tails. # Flip the coin the first time diff --git a/ch08-conditional-logic/9a-challenge-simulate-an-election.py b/ch08-conditional-logic/9a-challenge-simulate-an-election.py index 2b46837..a9ef523 100644 --- a/ch08-conditional-logic/9a-challenge-simulate-an-election.py +++ b/ch08-conditional-logic/9a-challenge-simulate-an-election.py @@ -26,7 +26,7 @@ else: votes_for_B = votes_for_B + 1 - # Determine who wins the erd region + # Determine who wins the 3rd region if random() < 0.17: votes_for_A = votes_for_A + 1 else: From d65ea99c4bfac477e0d94c3450a2ba02480bc8be Mon Sep 17 00:00:00 2001 From: martin-martin Date: Wed, 2 Aug 2023 13:03:08 +0200 Subject: [PATCH 2/5] One more typo --- .../7-simulate-events-and-calculate-probabilities.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ch08-conditional-logic/7-simulate-events-and-calculate-probabilities.py b/ch08-conditional-logic/7-simulate-events-and-calculate-probabilities.py index 29de41f..d7b939f 100644 --- a/ch08-conditional-logic/7-simulate-events-and-calculate-probabilities.py +++ b/ch08-conditional-logic/7-simulate-events-and-calculate-probabilities.py @@ -6,7 +6,7 @@ # Exercise 1 -# Write a function that simulatee the roll of a die. +# Write a function that simulates the roll of a die. def roll(): """Return random integer between 1 and 6""" return randint(1, 6) From c4edec716060fe93a465c3955f61628ae716308e Mon Sep 17 00:00:00 2001 From: Martin Breuss Date: Sun, 15 Oct 2023 13:37:50 +0200 Subject: [PATCH 3/5] Fix technical typo --- .../3-manipulate-strings-with-methods.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ch04-strings-and-string-methods/3-manipulate-strings-with-methods.py b/ch04-strings-and-string-methods/3-manipulate-strings-with-methods.py index a37fed6..79b6279 100644 --- a/ch04-strings-and-string-methods/3-manipulate-strings-with-methods.py +++ b/ch04-strings-and-string-methods/3-manipulate-strings-with-methods.py @@ -27,7 +27,7 @@ string3 = " Cheeseburger " print(string1.strip()) # Could also use .lstrip() -print(string1.strip()) # Could also use .rstrip() +print(string2.strip()) # Could also use .rstrip() print(string3.strip()) From d97fbe0ccdd17ea3e10271cd2da05065d255a0af Mon Sep 17 00:00:00 2001 From: Dan Bader Date: Tue, 7 Nov 2023 09:49:42 +0100 Subject: [PATCH 4/5] Expand ch10-3 solution --- ch10-primer-on-oop/3-inherit-from-other-classes.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ch10-primer-on-oop/3-inherit-from-other-classes.py b/ch10-primer-on-oop/3-inherit-from-other-classes.py index 06a0cb4..36efe49 100644 --- a/ch10-primer-on-oop/3-inherit-from-other-classes.py +++ b/ch10-primer-on-oop/3-inherit-from-other-classes.py @@ -41,4 +41,7 @@ def __init__(self, side_length): square = Square(4) -print(square.area()) +print(square.area()) # 16 + +square.width = 5 # Modifies .width but not .length +print(square.area()) # 20 From fe1ec67dd6aa5202b09c2fa4d30b531f168e753f Mon Sep 17 00:00:00 2001 From: Martin Breuss Date: Tue, 12 Dec 2023 13:10:34 +0100 Subject: [PATCH 5/5] Fix typo --- .../1-tuples-are-immutable-sequences.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ch09-lists-tuples-and-dictionaries/1-tuples-are-immutable-sequences.py b/ch09-lists-tuples-and-dictionaries/1-tuples-are-immutable-sequences.py index 6f0f1ff..1b0bcf0 100644 --- a/ch09-lists-tuples-and-dictionaries/1-tuples-are-immutable-sequences.py +++ b/ch09-lists-tuples-and-dictionaries/1-tuples-are-immutable-sequences.py @@ -23,7 +23,7 @@ # Create a tuple containing the letters of your name from a string my_name = tuple("David") -# Exercide 5 +# Exercise 5 # Check whether or not x is in my_name print("x" in my_name)