Introduction to Python Programming

CSCI 1012

Prof. Joe Goldfrank

Why Are We Here?

Software is [still] Eating the World

(Marc Andreesen, 2011)

In 2025, software dominates:

  • Communication
  • Finance
  • Commerce
  • Industrial Automation
  • Scientific Research
  • Warfare

The Algorithm

  • Named after Muhammad ibn Musa al-Khwarizmi
  • Set of logical instructions and rules used to perform computation
    • Takes an input
    • Returns an output
  • You probably let one tell you what videos to watch
  • You might let one suggest what you write in messages to other people

Artificial Intelligence

(Use of “AI” tools is not allowed in this class)

What You Will Learn This Semester

  • How to program in Python:
    • How computers work “under the hood”
    • How computers are used to solve problems
  • How to solve problems with programming
    • What kinds of problems can be solved

Prerequisites: None!

You

Majors:

  • Economics
  • Data Science
  • Public Health
  • International Business
  • Systems Engineering
  • International Affairs
  • Civil Engineering
  • Neuroscience
  • Interaction Design
  • Physics
  • Political Science
  • Finance

Course Mechanics

How To Succeed

  • Pay Attention
  • Start Early
  • Do The Work
    • Yourself


  • Care

Course Website

Week-to-Week

  • Lectures: M 3:45-5:00 PM

  • Labs: W or F 3:45-5:00 PM

    • Guided practice problems
    • Homework help
    • Quiz
  • Two Midterm Exams (in lecture)

    • Open note
  • Final Exam (optional)

Grading

Each Unit:

  • Homework: 25%
  • Quizzes: 15%
  • Unit Exam: 60%

Participation:

  • 3% bonus

Grading

Unit 2 counts triple if it is higher than Unit 1

if unit2 > unit1:
  average = (unit2 * 0.75) + (unit1 * 0.25) + (participation * 0.03)
else:
  average = (unit2 * 0.5) + (unit1 * 0.5) + (participation * 0.03)

Final Exam:

  • Max grade 70%
  • Optional
  • Can only improve your grade

Attendance

Lecture:

  • Optional
  • Recommended
  • Assumed
  • Participation bonus:
    • In-class exercises
    • Only open during lecture

Attendance

Lab:

  • Quizzes

Drops:

  • One quiz per unit
  • One homework per unit
  • Grade replaced by next quiz/homework
    • Can’t drop last homework of the unit

Websites

Course Website | Grading Server | Ed Discussion Board

  • We don’t use Blackboard. You must make accounts on the grading server and Ed.
  • Use your @gwu.edu email address to register:
    • klara.dan@gwu.edu 👍
    • klara.dan@gwmail.gwu.edu 👎
    • g123456789@gwu.edu 👎

The Syllabus

  • Please read it!
  • All course policies applied evenly
    • We won’t deviate from the syllabus
  • Quiz 1 includes an acknowledgement
    • Write it yourself

Write It Yourself

  • Copying code (from anywhere!) is generally prohibited on homework problems

  • You can always use code provided by course

  • Document any help you receive when solving the homework problems

  • Do not use ChatGPT or anything similar.

    • Ever
  • Quizzes and exams based on your homework solutions.

Write It Yourself

  • Students who copy code in CSCI 1012:
    • Don’t learn the material 😔
    • Fail or withdraw 😔
    • Get caught 😔
      • Failure of assignment and full letter grade reduction
  • Hard to catch up after falling behind

Office Hours

  • Periodically throughout week
  • One-on-one/small group help from TAs and profs
  • Typically in SEH 4th Floor
  • Office hours are the best way to get help
    • Better than tutoring
    • Free!

Ed Discussion Board

  • Best place to ask general questions
  • Responses usually within 24h
  • Public posts: most questions
  • Private posts: your code
  • Posts can be anonymous
    • Only anonymous to other students

Contact Info

  • Shared inbox: cs4all@gwu.edu
  • We check this inbox and respond
    • All “logistical” issues via email
    • Please never email profs or TAs directly
  • Please do not use ChatGPT (etc.) to write notes to us
    • Usually makes the note longer than necessary
    • Hard to find your actual message 😔
  • Polite and concise is good 😌

Grading

  • Autograder
    • Multiple attempts!
    • Submit early and often
    • “Extra” attempt with TA
  • Homework grace days
  • Quizzes and Exams
    • “More points than you need”

Strategies for Success (TLDR)

  • Restate the problem in plain English
  • Break it down into sub-problems
  • Run your code frequently
    • Fix things that don’t work
  • Get stuck!
    • … and then ask for help
  • Understand how it works

Strategies for Success

Write code.

  • You will spend most of your time inside and outside of this class coming up with solutions to sample problems
    • Creativity and practice are necessary
    • Failure along the way is normal, and expected

Strategies for Success

Write code…

  • There are no notes, YouTube videos, or slides that can actually teach you how to code.
    • These things typically focus on syntax, not design
    • You can only learn how to code by creating and debugging code

Strategies for Success

Write code!

  • You will need help (from a TA/instructor/Ed) when you get stuck
    • We won’t give full solutions
    • This class is not about memorization
    • “What did you try?”

Strategies for Success

Write code!!!

  • Showing up to lecture, watching videos, or reading a textbook is not enough to do well in this class
  • You MUST plan to spend time working on solving problems
    • Don’t fall behind.

How Is This Class Different?

Your commitment to the course:

  • Time
  • Objectivity & Standards
    • No late work accepted
      • Except for grace days
    • There is no partial credit for wrong answers
      • …but there’s also no ambiguity.

How Is This Class Different?

Our commitment to you:

  • Lots of extra help available
    • We offer it because most students need it
  • We understand you will make mistakes
    • We teach you how to learn from them
  • Solve the problems yourself \(\rightarrow\) good end-of-semester grade

Python

What Is A Computer?

  • A device that performs computation
  • Early (digital) computers: sophisticated calculators
    • They got faster
    • We attached them to displays
    • We attached them to each other
    • We gave them touch screens
  • Inside the box: math engines

What Is Computation?

  • Very Basic:
    • Input
    • Math
    • Output

\(y = x + 1\)

What Is Computation?

  • More advanced:
    • Input
    • Repetition
    • Math
    • Output

\(y = \sum_{i=1}^5 i = 1 + 2 + 3 + 4 + 5\)

What Is Computation?

  • More advanced:
    • Input
    • Repetition
    • Math
    • Conditions
    • Output

\[ y = \begin{cases} x + 1, & \text{if $x$ is positive}\\ x - 1, & \text{if $x$ is negative}\\ x, & \text{if $x$ is 0}\\ \end{cases} \]

Programming Language

  • Specifies computation for the computer
  • As complicated as we need
  • Code can be reused
  • Very “low level”
    • Works with numbers and text
    • Output is ‘printed’ text

Python

print("Hello world.")
Hello world.



x = 1 + 2
print(x)
3

Instructions

  • Python is the language
  • We write instructions
  • Running code: the computer follows the instructions
    • Result: output
  • Code runs line by line, in order

Python

Code runs line by line, in order:

x = 1
print(x)
x = x + 2
print(x)
y = x + 3
print(y)
1
3
6

Python

Code runs line by line, in order:

x = 1
print(x)
x = x + 2
print(x)
y = x + 3
print(y)

Python

Code runs line by line, in order:

x = 1
print(x)
x = x + 2
print(x)
y = x + 3
print(y)
1

Python

Code runs line by line, in order:

x = 1
print(x)
x = x + 2
print(x)
y = x + 3
print(y)
1
3

Python

Code runs line by line, in order:

x = 1
print(x)
x = x + 2
print(x)
y = x + 3
print(y)
1
3
6

Tools

  • Editor
  • Interpreter
  • Visualizer


Visualizer Links!

This Week in Lab

  • Install editor
    • Get a basic program running
  • Make accounts:
    • Submit server
    • Ed discussion board
  • Quiz
    • Syllabus acknowledgement
    • Open book (all future quizzes closed book)

Next Week

Reading: Think Python Chapters 1 and 2

  • Readings are short
  • Do them with your computer open
  • Write code
  • Try things out!

Homework 1 due Sunday, 19 Jan 11:55 PM
20 Jan is a holiday - recorded lecture