Module 1: Your First Program | CMSC 105 Elementary Programming - Fall 2024

Module 1: Your First Program

Objectives

Experience writing a really simple program.

Hello World in Python

Here is the classic Hello World program in Python:

hello.py

print("Hello World!")

This is a simple program written in the Python programming language, possibly one of the smallest programs one can write, and a traditional starting point for learning programming.

Let’s point out a few things:

Thonny

What’s with printing the phrase “Hello World!”

It’s a tradition in computer science that your first program will print “Hello World!”

It’s meant to pretend that a program is a creature that’s itself communicating to the outside world by saying hello.

Hello World Variation

We will now spend a bit of time trying a few variations, and also examining what happens when typing mistakes are made.

Consider this program:

helloname.py

print("Hello World!")
print("My name is X")

What happens when things go (even slightly) wrong

We’ll now deliberately make a few tiny errors and see what happens:

Error #1: forgetting to type the closing parenthesis.

error1.py

print("Hello World!"

Note the missing right parenthesis at the end of the line.

Error #2: What happens if we forget the quotation marks?

error2.py

print(Hello World!)

Submission Instructions

Attach the files hello.py, helloname.py, error1.py, and error2.py to the Module 1 assignment on blackboard and submit the assignment.