Week 1 - Functions, logic, conditionals discussion#

Goals#

  • Learn the basic constructs of Python programming

  • Create a program that plays a variant of Rock-Paper-Scissors

Functions#

Functions#

  1. What is the advantage of functions?

Visualizing functions#

  1. How can visualizing functions help us?

More operations#

  1. What are the following libraries good for?

    • random

    • simplegui

    • math

  2. What is the difference between / and //?

  3. How can we model the wraparound of the spaceship in the game Asteroids

Logic and conditionals#

Logic and comparisons#

  1. What is a Boolean variable?

  1. Why are conditionals important in programming?

  1. Is there an alternative logic to describe the truth (of an event)?

Conditionals#

  1. Which control flow statements exist in Python?

Programming Tips - 1#

Mini-project #1 - Rock-paper-scissor-lizard-Spock#

  1. The description states that the computer must choose its weapon randomly. How is player’s weapon chosen if we do not use any keyboard input in the game?

  2. How did you implement the win/loss logic, in other words how do you decide if a weapon wins against another?