LogoLogo
Terminal
  • Attic Lab
  • Getting Started
  • Crest Gold
  • Crest Silver
  • Videos on Computation
  • PI PICO (CIRCUITPYTHON)
    • Getting Started
    • Pin Out Diagram
    • Breadboards
    • 1. Led Blink
    • 2. RGB
    • 3. OLED
    • 4. Sensors
    • 5. Wifi
    • 6. Servos
  • Arduino
    • Getting Started
    • Pin Out Diagrams
      • Mega2560 R3
    • Programming
      • Arduino C - Cheat Sheet
    • Buttons
      • Momentary Switches
    • Display
      • LEDs
      • 7 Segment Displays
      • LCD Displays (GPIO)
      • LCD Displays (SPI)
      • OLEDs
    • Communication
      • Antenna Theory
      • Lora
      • Wifi
        • Boards
    • Project Ideas
    • Motion
      • DC Motors
      • Servo Motors
      • Stepper Motors
  • Microsoft Office
    • Word
    • Powerpoint
    • Excel
  • The Terminal
    • Basics
    • Cheat Sheet
    • Games
      • Level 1 - Bashcrawl
      • Level 2 - Bandit
  • TinkerCad
    • Gallery
    • Getting Started
    • Basic Operations
    • Basic Skills
    • Projects
      • Locking Container
  • Python
    • Hello World
    • Turtle Graphics
      • Strings in Turtle Graphics
      • Cheat Sheet
    • Variables
    • Loops
    • If Statements
    • Functions
    • Games
      • Pong
  • Raspberry Pi
    • Setup
      • Changing The Hostname
      • Headless Setup
      • Kiosk Mode
    • Remote Connections
    • Displays
      • Memory
        • External HD
      • HyperPixel 4.0
  • Ultimaker 3D Printing
    • The Thingiverse
    • Preparing the File
    • Printing
    • Calibration Prints
    • Print Set
  • Fusion 360
    • Getting Started
    • Design Tutorials
      • Tweezers
      • Mars Rover Wheel
    • Surface Modeling
  • Electronics
    • References
    • Antenna Theory
    • LoRa
  • PCB Milling
    • FlatCam
    • Candle
    • PCB Milling
  • Projects
  • Projects
    • Star Map Necklace
    • Ideas Respository
  • Latex
    • What is LaTeX?
    • Getting Started
    • Structure
    • Page Size & Margins
    • Styling
    • Images
    • Lists
    • Tables
    • Mathematics
      • Superscript and Subscripts
      • List of Symbols
      • Fractions and Binomials
      • Integrals, Sums & Limits
    • Colors
  • Web Development
    • The Internet
    • Intro to HTML
    • Basic Elements
    • Basic Styling
Powered by GitBook
On this page
  • Installation
  • Hello World
  • Programming in a File
  • Challenge
  • Word Play

Was this helpful?

  1. Python

Hello World

PreviousLocking ContainerNextTurtle Graphics

Last updated 5 years ago

Was this helpful?

Installation

Download version 3 of Python for your operating system from www.python.org

Install Python then search for an open the Idle Python application.

Hello World

The screen that you see in Idle lets you run one line of Python code at a time.

It is a tradition amongst programmers that the first program that you write in any language is the Hello World program.

In Idle type:

print("Hello World")

and press return.

Congratulations. You've written your first program!

Programming in a File

Obviously you'll want to write programs that are bigger than one line. To do this we need to create a Python file.

Python files always end in .py

In Idle, go to File > New and save the file to your OneDrive folder. Call it YourName.py

The program that we're going to write will ask you for your name before then saying hello.

In your Python file, write out the following code:

 # YourName.py
 name = input("What is your name?\n")
 print("Hi, ", name)

Lets take a closer look at this program line by line:

  1. A # hash at the start of a line means that it is a comment and not an instruction for the computer

  2. Input means that a user should input some text. This is saved into a variable called name. The \n in the text tells python to move down a line (like pressing return in word)

  3. Terms separated by a comma , in print are joined together when they are printed.

To run your program, click Run > Run Modules or press Fn-5

Play: Can you modify your program to write your name 5 times? How about asking for someone else's name.

Challenge

Word Play

Create a file that asks the user for a noun, adjective and verb ending in ed before printing it with the command

print('The', adjective, noun, verb, ' caused a rather unfortunate incident.')

Welcome to Python.orgPython.org
Logo