Module 02
Basic Program Structure and Input/Output
Learn how Python programs are written, how output is displayed, and how input is read dynamically.
01
What is a Program?
Learn what a Python program is, why we write one, and why files use the .py extension.
02
Interactive Approach
Run one Python statement at a time in the command prompt or IDLE shell — useful for testing, not for large apps.
03
Batch Mode Approach
Save optimized instructions in a .py file such as addex3.py and run them with python addex3.py — the industry way to build apps.
04
Variables and Their Limitations
Store values in named variables, follow naming rules, and understand what variables can and cannot do in beginner Batch Mode programs.
05
Display Results with print()
Use print() to show values, string messages, and mixed messages-plus-values on the console.
06
print() with format() and Format Specifiers
Format console output with str.format() and with %d, %f, and %s specifiers.
07
print() with end=
Keep print() output on the same line by passing end with a space, arrow, or comma delimiter.
08
Reading Keyboard Input
Read data from the keyboard with input() and input(Message). Both return str.
09
Input with Type Casting
Convert keyboard strings to numbers with float() and multiply two values. Several compact input styles.
10
Adding Two Numbers
Three batch-mode programs: hard-coded add, labeled print(), then dynamic float input.
11
Practice Programs: Swap, Interest, Circle, Rectangle
Apply input() and print() to swap values, simple interest, and area/perimeter of a circle and rectangle.