Module 1: Programming Fundamentals
Module 1: Programming Fundamentals
Fundamentals
Objectives
Use IDLE to test Python expressions and statements in the interactive shell.
Learn how Python compiles and runs a program in terms of source code,
bytecode, and the virtual machine.
Ideas?
C++
Java
C#
Javascript
Python
Each Programming language
keywords have special meaning and can be used only in a specific way.
Keywords include Operators that represent special program functions such as addition,
subtraction, and multiplication
Enter Python code after the >>> prompt. Then, press Enter.
If you enter valid instruction that produces a result, the shell displays the
result.
print(“Hello World”)
How to create, open, save, and close source files
Use IDLE’s File menu and common techniques for your operating system.
Write Python code to print “Hello World” and “Have a fabulous day”
From the editor window, press the F5 key or select RunRun Module.
If IDLE displays a dialog box that indicates that you must save the program first, click Yes to save
it. Then, if the program doesn’t have any errors, IDLE runs the program in the interactive shell.
Activity: Create HelloWorld.py (contd)
Sample run
Activity: Run happynewyear.py
Open it in IDLE
In IDLE, create a new file and write a new Python program that
Sample run:
Compilers and Interpreters
Step 1 The programmer uses a text editor or IDE to enter and edit the
source code. Then, the programmer saves the source code to a file with a .py
extension.
Step 2 The source code is compiled by the Python interpreter into bytecode.
Syntax error:
It should:
Sample run: