AutomateTheBoringStuff.Ch03 package
Submodules
AutomateTheBoringStuff.Ch03.P01_helloFunc module
Hello function
This program uses a function to say hello.
-
AutomateTheBoringStuff.Ch03.P01_helloFunc.
hello
() → None[source]
Hello
Prints hello three different ways.
Returns: | None. Only prints three statements. |
-
AutomateTheBoringStuff.Ch03.P01_helloFunc.
main
()[source]
AutomateTheBoringStuff.Ch03.P02_helloFunc2 module
Hello function 2.0
This program uses a function with an input argument to say hello to Alice and Bob.
-
AutomateTheBoringStuff.Ch03.P02_helloFunc2.
hello
(name: str) → None[source]
Hello
Says hello to a given name.
Parameters: | name – String containing name of person to say hello to. |
Returns: | None. Prints out a statement. |
-
AutomateTheBoringStuff.Ch03.P02_helloFunc2.
main
()[source]
AutomateTheBoringStuff.Ch03.P03_magic8Ball module
Magic 8 ball
This program answers your questions with a function that knows all.
-
AutomateTheBoringStuff.Ch03.P03_magic8Ball.
getAnswer
(answerNumber: int) → str[source]
Get answer
Uses if … elif sequence to return a response based on an inputted number.
Parameters: | answerNumber – Any integer between 1 and 9. |
Returns: | String containing a response based on the given number. |
-
AutomateTheBoringStuff.Ch03.P03_magic8Ball.
main
()[source]
AutomateTheBoringStuff.Ch03.P04_sameName module
Same name
This program uses the same variable name throughout.
-
AutomateTheBoringStuff.Ch03.P04_sameName.
eggs
String denoting global variable.
Note
Not recommended, but possible.
-
AutomateTheBoringStuff.Ch03.P04_sameName.
bacon
() → None[source]
Bacon
Prints its local variable called eggs and also calls spam()
.
Returns: | None. Prints local variables. |
-
AutomateTheBoringStuff.Ch03.P04_sameName.
main
()[source]
-
AutomateTheBoringStuff.Ch03.P04_sameName.
spam
() → None[source]
Spam
Prints its local variable called eggs.
Returns: | None. Prints the local variable. |
AutomateTheBoringStuff.Ch03.P05_sameName2 module
Same name 2.0
This program has only one variable.
-
AutomateTheBoringStuff.Ch03.P05_sameName2.
eggs
String denoting global variable.
-
AutomateTheBoringStuff.Ch03.P05_sameName2.
main
()[source]
-
AutomateTheBoringStuff.Ch03.P05_sameName2.
spam
() → None[source]
Spam
Reassigns global variable called eggs.
AutomateTheBoringStuff.Ch03.P06_sameName3 module
Same name 3.0
This program demonstrates global and local variable rules.
-
AutomateTheBoringStuff.Ch03.P06_sameName3.
eggs
Integer defining the answer to all life, universe, and everything.
-
AutomateTheBoringStuff.Ch03.P06_sameName3.
bacon
() → None[source]
Bacon
Assigns a local variable called eggs.
-
AutomateTheBoringStuff.Ch03.P06_sameName3.
ham
() → None[source]
Ham
Prints global variable called eggs.
Returns: | None. Prints global variable, eggs. |
-
AutomateTheBoringStuff.Ch03.P06_sameName3.
main
()[source]
-
AutomateTheBoringStuff.Ch03.P06_sameName3.
spam
() → None[source]
Spam
Reassigns the global variable called eggs.
AutomateTheBoringStuff.Ch03.P07_sameName4 module
Same name 4.0
This program produces an error trying to print a
local global variable while assigning a local variable with the same name.
-
AutomateTheBoringStuff.Ch03.P07_sameName4.
eggs
String denoting global variable.
-
AutomateTheBoringStuff.Ch03.P07_sameName4.
main
()[source]
-
AutomateTheBoringStuff.Ch03.P07_sameName4.
spam
() → None[source]
Spam
Attempts to print global variable, eggs, while assigning local variable, eggs.
AutomateTheBoringStuff.Ch03.P08_zeroDivide module
Zero Divide
This program also produces an error by dividing by zero.
-
AutomateTheBoringStuff.Ch03.P08_zeroDivide.
main
()[source]
-
AutomateTheBoringStuff.Ch03.P08_zeroDivide.
spam
(divideBy: int) → float[source]
Spam
Divides integer 42 by given integer.
Parameters: | divideBy – Integer to divide 42 by. |
Returns: | Float result of 42 divided by given integer. |
AutomateTheBoringStuff.Ch03.P09_zeroDivide2 module
Zero Divide 2.0
This program handles a ZeroDivisionError
.
-
AutomateTheBoringStuff.Ch03.P09_zeroDivide2.
main
()[source]
-
AutomateTheBoringStuff.Ch03.P09_zeroDivide2.
spam
(divideBy: int) → float[source]
Spam
Divides integer 42 by given integer, but also handles a ZeroDivisionError
.
Parameters: | divideBy – Integer to divide 42 by. |
Returns: | Float result of 42 divided by given integer. |
AutomateTheBoringStuff.Ch03.P10_zeroDivide3 module
Zero divide 3.0
This program also handles a ZeroDivisionError
, but in the main()
function.
-
AutomateTheBoringStuff.Ch03.P10_zeroDivide3.
main
()[source]
-
AutomateTheBoringStuff.Ch03.P10_zeroDivide3.
spam
(divideBy: int) → float[source]
Spam
Divides integer 42 by given integer.
Parameters: | divideBy – Integer to divide 42 by. |
Returns: | Float result of 42 divided by given integer. |
AutomateTheBoringStuff.Ch03.P11_guessTheNumber module
Guess the number
This is a guess the number game.
Note
Numbers between 1 and 20.
-
AutomateTheBoringStuff.Ch03.P11_guessTheNumber.
main
()[source]
Module contents