OpenBrackets
Beginning Programming
Week 1 Day 1
Welcome!
Welcome to class!
This is the Starting Programming class
Have a question?
Ask a teacher or TA
Type in chat
Or
Or un-mute and speak up
Introduce yourself!
Say your name and age in chat! If you want, you can say a fun fact as well!
Programming directs automatic action online and with robots
All of these are instructed by programs
Humans wrote these programs
You can write programs to run websites, analyze data, and make apps or tools or games
We're using Python for this course
Python is easier to read/write��but ... every character (letters and symbols) still matters!
repl.it is an easy-to-use python coding environment
Account is free, but you do need to register with an email
You can use Repl to:
Yes you can make games
We'll focus on text games for now - simpler
Here's one game
To run, click the green arrow
Also, you can see how it's written
Let's make our own account
You can switch away from this zoom window to make it easier
Making a Rep.it
click this button to make a new repl
that is running Python
Click this button to make a new repl
You can name it
if you want to - be organized
Click Create, when done it'll look like the below:
Typing =
Typing (
Typing )
Typing _ (underscore)
Typing #
Typing :
Typing TAB
Working together by sharing
No such thing as a lone genius programmer
Need help, a pointer? �Try Discord server (https://discord.gg/exTcPsgYaq), email, �other students, search engine, StackOverflow��We are a learning community
Example of a function and a value
print("hello world")
print�is a function
functions require a ( and a )
a string value is letters between two "" or ''
What did you find out?
Points to hit:
`print()` is what's called a function, you can tell because they have a parentheses right behind them
you can also put `print` in the console and it will tell you what it is
Congratulations! You unlocked errors
What errors have people found?
What kinds of errors are these?
Errors are very useful! Embrace errors.
Group exercise
Can you write code in the editor and run it so that the Console prints out "hello world" ?
Try typing into the editor and running code that looks like:
Do you get an error? We'll talk about that after the exercise
( if you run into an error, it will stop, so you should remove error lines )
Work together. Try different things to see what works and what doesn't ! �Can you print other things? Can you print numbers? Do you need quotes? Parentheses?
Use comments to explain and plan
Computer ignores everything on a line after a #
These are called comments - and ignored
# This prints hello world
print("hello world")
### Game idea ###
# we draw the world
# for each monster we make a monster
# then we make a player character
# then we equip the player with a bouquet of pretty flowers
# when all monsters are cheered up, the game ends
Typing #
Another function is input
input()
input() just waits for you to press enter...
Great way to make the program pause
We will use this to get user input, later!
How to use Input()
You need a variable (something to store the value of the input)
If you want to store a name, then call the variable “name”
How do you make a variable?
name = input(“What is your name? ”)��Now you have a variable called name which stores the name the user enters when asked the question
Break down of input
name = input(“What is your name? ”)
This is the variable, you can name it whatever you like
This is the input function
This is the question you ask
How to use the stored values
Now that you have the name stored in the variable you can print the variable
print(name)
This will print the name the user entered
If they entered: “John”
This will return: “John”
How to use stored values Part 2
Another way to use the variable is to put it in a sentence
print(“I like your name “ + name)
This will print the sentence and the user’s name
If they entered: “John”
This will print: “I like your name John”
How to use stored values Part 2
print(“I like your name “ + name)
The “+” sign is what allows us to add variables to sentences
We can add text before and after the variable to get different results:
print(“I like your name “ + name + “it is cool”)
If they enter: “John”
This returns: “I like your name John it is cool
More sharing - how to copy and paste text
This is a super useful trick
Copy+paste can help you share repls
Click to highlight
then press
ctrl+c
Click in chat box and
press ctrl+v
(but just to a TA/teacher)
When you need help outside class
Email openbracketscoding@gmail.com and say what class and teacher you have, or Email rruta@openbrackets.us
If you are age 13 or older, you can try Discord
The age restriction is because of Discord’s Terms of Service
Thanks for coming to class!
Please let us know if you have any questions!