python:dierbach:chapter_1_python_first_steps
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionNext revisionBoth sides next revision | ||
python:dierbach:chapter_1_python_first_steps [2016/07/26 05:14] – mithat | python:dierbach:chapter_1_python_first_steps [2016/07/28 02:25] – [IDLE] mithat | ||
---|---|---|---|
Line 3: | Line 3: | ||
====== Python first steps ====== | ====== Python first steps ====== | ||
Mithat Konar\\ | Mithat Konar\\ | ||
- | from Dierbach' | + | based on Dierbach' |
===== The Python language ===== | ===== The Python language ===== | ||
* Syntax is easy to read. | * Syntax is easy to read. | ||
- | * Interpreted | + | * Interpreted |
+ | * Can be executed interactively. | ||
* Huge community. | * Huge community. | ||
* Lots of support. | * Lots of support. | ||
Line 15: | Line 16: | ||
===== IDLE ===== | ===== IDLE ===== | ||
- | * IDLE is Python' | + | * [[https:// |
* Good for starting to learn Python. | * Good for starting to learn Python. | ||
* Many [[https:// | * Many [[https:// | ||
Line 50: | Line 51: | ||
</ | </ | ||
- | ===== The standard library and '' | + | ===== The standard library and import ===== |
* Python' | * Python' | ||
- | * Add functionality by '' | + | * Add functionality by importing |
* Lots of modules in the [[https:// | * Lots of modules in the [[https:// | ||
<code python> | <code python> | ||
Line 170: | Line 171: | ||
> I need an exponent calculator. | > I need an exponent calculator. | ||
- | Solution: Write a program that allows the user to enter any integer base and integer exponent, and displays the value of the base raised to that exponent. | + | * Solution: Write a program that allows the user to enter any integer base and integer exponent, and displays the value of the base raised to that exponent. |
- | Observations: | ||
- | Proposed interaction: | + | |
+ | ===== Define the problem ===== | ||
+ | * Observations: | ||
+ | * The user will enter the values from the keyboard. | ||
+ | * It would be good if the user got feedback when the result is printed. | ||
+ | * I will use Python because it will be easy to implement the solution with it. | ||
+ | * Proposed interaction: | ||
< | < | ||
What base? 10 | What base? 10 | ||
Line 185: | Line 191: | ||
- Get the base from the user. | - Get the base from the user. | ||
- Get the exponent from the user. | - Get the exponent from the user. | ||
- | - Calculate | + | - Calculate |
- | - Print "// | + | - Print "// |
===== Code the solution ===== | ===== Code the solution ===== | ||
Line 204: | Line 210: | ||
<code python> | <code python> | ||
- | Enter the base: 10 | + | >>> |
- | Enter the exponent: 4 | + | >>> |
Traceback (most recent call last): | Traceback (most recent call last): | ||
File "/ | File "/ | ||
Line 230: | Line 236: | ||
<code python> | <code python> | ||
- | Enter the base: 10 | + | >>> |
- | Enter the exponent: 4 | + | >>> |
Traceback (most recent call last): | Traceback (most recent call last): | ||
File "/ | File "/ | ||
Line 256: | Line 262: | ||
<code python> | <code python> | ||
- | Enter the base: 10 | + | >>> |
- | Enter the exponent: 4 | + | >>> |
- | 10 to the power of 4 is 10000 | + | >>> |
</ | </ | ||
Line 265: | Line 271: | ||
===== Document the solution ===== | ===== Document the solution ===== | ||
- | * In this case, we began documenting the program right from the start: | + | * In this case, we began **documenting the program right from the start**. |
* Writing out details of the problem. | * Writing out details of the problem. | ||
* Writing out the design of the solution. | * Writing out the design of the solution. | ||
* Using comments in the source code. | * Using comments in the source code. | ||
* Do this. | * Do this. | ||
- | * Every. Single. Time. | + | |
python/dierbach/chapter_1_python_first_steps.txt · Last modified: 2016/07/28 04:26 by mithat