1 of 37

OpenBrackets

Beginning Programming

Week 1 Day 1

Welcome!

2 of 37

Welcome to class!

This is the Starting Programming class

  • 5 - 6:30pm : 5 min break towards the middle�
  • Teachers and TAs are:
    • Aidan, Kevin, Rohan, and Sean

  • No grades - but the more we can help each other learn as a group, the better

3 of 37

Have a question?

Ask a teacher or TA

Type in chat

Or

  1. Click Reactions
  2. Click Raise Hand

Or un-mute and speak up

4 of 37

Introduce yourself!

Say your name and age in chat! If you want, you can say a fun fact as well!

5 of 37

Programming directs automatic action online and with robots

  • Robot that vacuums the floor
  • Discord chatbot that responds to commands
  • Robot that processes COVID PCR tests
  • Twitter bot that posts jokes
  • Robot that detects cats, shoots lasers
  • Websites, apps, computers, phones

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

6 of 37

We're using Python for this course

Python is easier to read/write��but ... every character (letters and symbols) still matters!

7 of 37

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:

  • write code
  • run code
  • share code
  • ... host webpages? ( in our web design course! )

8 of 37

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

9 of 37

Let's make our own account

  1. Go to Repl.it
  2. Make an account under “Sign Up”
  3. You don’t need to answer their questions, but you can if you want

You can switch away from this zoom window to make it easier

  • Take your time
  • We’ll be here for a few minutes to make sure everyone has an account
  • If you need any help or have questions, please ask!

10 of 37

Making a Rep.it

11 of 37

click this button to make a new repl

that is running Python

12 of 37

Click this button to make a new repl

You can name it

if you want to - be organized

13 of 37

Click Create, when done it'll look like the below:

14 of 37

Typing =

15 of 37

Typing (

16 of 37

Typing )

17 of 37

Typing _ (underscore)

18 of 37

Typing #

19 of 37

Typing :

20 of 37

Typing TAB

21 of 37

Working together by sharing

No such thing as a lone genius programmer

  • everyone draws on the knowledge of their community
  • sharing knowledge builds a smart community, �more capable programers, get more stuff done
  • open-source always beats closed-source
  • asking questions sharpens the answers

Need help, a pointer? �Try Discord server (https://discord.gg/exTcPsgYaq), email, �other students, search engine, StackOverflow��We are a learning community

22 of 37

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 ''

23 of 37

What did you find out?

Points to hit:

  • `print` is important to print anything out
  • what you print is between the parentheses ( and )
  • you need to have "" or '' around what's in the ()

`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

24 of 37

Congratulations! You unlocked errors

  • Errors are computers’ complaints that they don’t understand your instructions
  • Try to understand the type of error and where it came from
  • ^ points to the most likely place where the error is (or nearby)

What errors have people found?

What kinds of errors are these?

Errors are very useful! Embrace errors.

25 of 37

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:

  • something
  • "something"
  • print "something"
  • print("something")

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?

26 of 37

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

27 of 37

Typing #

28 of 37

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!

29 of 37

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

30 of 37

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

31 of 37

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”

32 of 37

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”

33 of 37

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

34 of 37

More sharing - how to copy and paste text

This is a super useful trick

  • Highlight some text (like in the chat) by clicking and dragging using your mouse or trackpad
  • Then, press Ctrl (control key) and 'c'. �This copies the text.
  • Then, click where you want the new text to go. �Make sure it is a place where you could type.
  • Then, press Ctrl (control key) and 'v'. �This pastes the text.

35 of 37

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)

36 of 37

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

  • https://discord.gg/ZRtk534

The age restriction is because of Discord’s Terms of Service

37 of 37

Thanks for coming to class!

Please let us know if you have any questions!