Today's Agenda
4:30 - 4:45PM: Log on & Ice breakers
4:45 - 5:05PM: Definitions
Python: is considered one of the most popular programming languages in the world.
Variables: Variables are containers for storing data values.
Functions: is a group of related statements that performs a specific task.
Indentation: refers to the spaces at the beginning of a code line
5:05 - 5:10 PM: Bio Break & Guided Python instruction
5:10 - 5:30PM: Guided Python instruction
5:30 - 6:00 PM: Save & Share!
Creating a simple rock paper scissors (RPS) game!
In this course, you will learn the basics of Python programming. We will meet every Tuesday at 4:30pm to 6:00pm. You don't need any previous programming experiences and all you need to code in Python is a web browser (www.replit.com). Mr. Steven will teach you all the core aspects of the Python programming and I will simplify the more complex topics.
Python is considered one of the most popular programming languages in the world.
Python excels in a wide variety of scenarios such as:
Data Visualization
Task Automation
Web Development and more!
We will use a replit which is an online IDE that allows users to code and run programs in a variety of different languages all in a web browser. You should be able to get your own login from your TKU staffs!
Now that you're logged into replit. You can click the create button on the top left corner of your browser.
Please select "Python". You don't have to worry about the other Python versions or other programming languages. Press " + Create Repl" button to create your first Python script!
You will see three sections. The middle section is where we're going to create our Python code. Right section is where we can see the output/results and lastly your left section is you can create different files. Don't worry about other icons on the left side. We won't be using it for this course. We will be mainly going to use this main.py program.
I'm going to start off by showing you how to create a variable. Variables are containers for storing data values. Since we are making a Rock Paper Scissors (RPS) game and a player is going to have a choice and a computer is going to have a choice.
Let's write our first line of code
player_choice = "rock"
Let's take a look at this code.
The variable name is "player_choice". In Python, we use an underscore for any space between words.
" = " equal assign is the assign operator where we assign it to a string
string is a word or collection of characters like rock. We are going to put quotation marks around it.
Let's write:
computer_choice = "paper" in line 2
A function is a set of code which only runs when it is called. So, I will show you how to put these variables into a function.
Python indentation is very important. I'll show you by creating a new line of code at the top and I'm going to call it get_choice():
A function is a set of code which only runs when it is called. So, I will show you how to put these variables into a function.
Python indentation is very important. I'll show you by creating a new line of code at the top and I'm going to call it get_choice():
Let's add:
return computer_choice
Press "Play" button and see what happens!
Mr. Steven will be explaining line by line and discuss what each lines do.
We will write a win logic for player and computer.
Line 11: Debugging with variables
Line 13 - 18: If-elif logics
choices() will trigger get_choice() method. See line 3
result will produce player's and computer's choice.
print the results
We will learn more about if-else statment (logics)
The rules of Rock Paper Scissors
Rock wins against scissors.
Scissors win against paper.
Paper wins against rock.