Table of Contents

Basic Programming Concepts

We need to understand basic programming concepts like input and output.

Program 1

Write a program that asks for your name, and then prints “Hello, Mr. <name>!”.

Step One: Basic Output

In python, the basic output is print().

print-1a.py


print("Hello, my name is Mr. Appledog!")
 

This allows you to print messages to the console.

Now lets explore what a variable is.

print-1b.py


name = "Appledog"

print("Hello, my name is Mr. " + name + "!")
 

Here we store some information and use it later. We store the name “Appledog” in a variable called “name”. You could also call the variable “x”, or any other word.

Step Two: Basic Input

print-1c.py


name = input("What is your name? ")

print("Hello, my name is Mr. " + name + "!")
 

This is the final version of the instruction program. Now we ask the students to write their own program:

Problem 1

Problem 1: Input your first name and last name, and write “Hello <firstname> <lastname>!”

Answer

print-1d.py


a = input("What is your first name? ")
b = input("What is your last name? ")

print("Hi, Mr. " + a + " " + c + ".")
 

Mark: 100%

Comment: Many students don't format the English correctly, or forget to include a space between the two words. In such a case they should lose 5% for the mistake.