Notes

Python Syntax Overview

Edit on GitHub

Python
 1# Hello World
 2print("Hello world")
 3
 4# Functions
 5def main(): # define a function, call it main (by convention)
 6    print("Hello World")
 7
 8if __name__ == "__main__":
 9    main()
10
11# Conditionals
12if x < y:
13    print("x is less than y")
14elif x > y:
15    print("x is greater than y")
16else:
17    print("x is equal to y")
  • def define a function

-CS50 2017 - Lecture 8 - Python