Skip to main content
MahiDev — Learn. Build. Become AI-ready.

Module 02

Basic Program Structure and Input/Output

Learn how Python programs are written, how output is displayed, and how input is read dynamically.

Beginner3 hours11 lessons

01

What is a Program?

Learn what a Python program is, why we write one, and why files use the .py extension.

Beginner10 min

02

Interactive Approach

Run one Python statement at a time in the command prompt or IDLE shell — useful for testing, not for large apps.

Beginner10 min

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.

Beginner15 min

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.

Beginner15 min

05

Display Results with print()

Use print() to show values, string messages, and mixed messages-plus-values on the console.

Beginner15 min

06

print() with format() and Format Specifiers

Format console output with str.format() and with %d, %f, and %s specifiers.

Beginner20 min

07

print() with end=

Keep print() output on the same line by passing end with a space, arrow, or comma delimiter.

Beginner10 min

08

Reading Keyboard Input

Read data from the keyboard with input() and input(Message). Both return str.

Beginner15 min

09

Input with Type Casting

Convert keyboard strings to numbers with float() and multiply two values. Several compact input styles.

Beginner15 min

10

Adding Two Numbers

Three batch-mode programs: hard-coded add, labeled print(), then dynamic float input.

Beginner15 min

11

Practice Programs: Swap, Interest, Circle, Rectangle

Apply input() and print() to swap values, simple interest, and area/perimeter of a circle and rectangle.

Beginner20 min