Search
  • Rachael Kim

Our First Summer Meeting!

Updated: 3 days ago

On July 1, 2020, Phillips Exeter Academy Girls who Code had our first meeting of our summer program with five of our wonderful students!

We started off by introducing ourselves to each other. Then we went over the brief history of Python and its increasing usage in the industry and among the programmers. The materials we went over can be viewed in the powerpoint attached below:

Python Class 1
.pptx
Download PPTX • 4.53MB

Recap of our first class:


1. Installing Python IDLE

https://www.python.org/downloads/

Go to this link, and download Python that matches your OS (Operating System - Mac, Windows, Linux, etc.)

After you finish the download, open the file and start installing Python on to your computer.


2. Open IDLE

If you are a Mac user, you will see this icon appearing in your Applications. Click on this.

If you are a Windows user, do a search and look for 'Python IDLE.'

If you have opened correctly, you should see 'Python Shell' as the name of the new window.


3. Python Syntax 1 - Print statement

Python is a high-level language, which means that its commands are similar to human language - in this case, English! So, you can probably understand what each python command does just by looking at it.

A print statement in Python literally prints the statement you specify on to your screen.

To write a print statement, you do:

print(some statement)

This is a classic example:

>>> print ("Hello, world!")
Hello, world!

Notice that the statement is in quotation marks. This is because Python needs a way to tell the difference between a normal text and Python commands. By using quotation marks around the text, we tell Python that it is a text input, not a Python command.

Try with your own statement


4. Python Syntax 2 - Math Operators

Just like how we do math in our classes, we can use Python to do some math - and use it like a calculator!

These are the math operators we use in Python:

Addition: +
>>> 3 + 2
5

Subtraction: -
>>> 3 - 2
1

Multiplication: *
>>> 3 * 2
6

Division: /
>>> 4 / 2
2

Exponent: **
>>> 2**2
4

5. Basic data types in Python

There are different types in Python - just like how we have number, text, etc.

Integer (Whole number): int
String (Text): str
Float (numbers like 2.5, 5.49, etc.): float
Boolean (True/False): bool

You do not have to know the abbreviations (like int, str) for now.

Doing the following tells you the type of your input:

type(something)

>>> type(3)
<class 'int'>
>>> type("hello")
<class 'str'>

6. Comparison Operators

Comparison operators let you compare different things of the same type.

If you compare two things of different type (for example, 3 and "hello"), you will get an error.

Operators will return results in boolean - either True or False.

 Equal: ==
 Not equal: !=
 Greater than/Smaller than: > or <
 Greater than or equal to/Smaller than or equal to: >= or <=
 
 >>> "hello" == "hello"
 True
 >>> 3 == 1
 False

Note that unlike in math, you use == to check if two objects are equal, not =.

Generally in programming, = is used for setting values for variables.

pig = 3

This line of code sets the value of variable pig to 3.


7. Conditional statements

Conditional statements evaluate the statement you have input and runs the commands within it ONLY IF the statement is TRUE.

In English, you often say sentences with if, just like this example:

If you play the piano for me, I will get you a cookie.

You can do a similar thing in programming languages. You specify a certain condition after 'If,' and the statements you write within the curly brackets that follow if will only be executed if the condition is met.

General If statement structure in Python:

If (condition):
    do something
elif (condition):
    do something
else:
    do something

elif in Python means 'else if' in English.

Elif statement will only be evaluated if If statement is false. Similarly, else will only be evaluated if both if and elif statements are false.

For example,

if (3 < 2):
    print ("2 is bigger than 3")
elif (3 > 2):
    print ("3 is bigger than 2")
else:
    print("3 is equal to 2")
    
3 is bigger than 2

Quick Note: Make sure you run this in a Python file not a shell. (If you are a Mac user, do File > New File) Then you save the file and do Run > Run Module.

For those who weren't able to come to our first meeting:


You can still sign up for our summer program!

Sign up, and let me (Rachael Kim, skim1@exeter.edu) or Mana Vale (nvale@exeter.edu) know if you need to schedule a make-up session for classes you missed. If you already know these basic syntax, that's also cool! We will be learning graphic libraries of Python such as tkinter, turtle, etc. in the upcoming weeks, so you should join us in the journey!



59 views

Recent Posts

See All

End of our Summer Program

Our Summer Program has officially ended on August 19, 2020. Our girls presented their final projects that they have worked on for a couple of weeks. We were impressed by their creativity and improveme

Phillips Exeter Academy Girls Who Code

Phillips Exeter Academy

20 Main Street

Exeter, NH 03833

Quick Links

© 2020 by Exeter Girls Who Code

This site was designed with the
.com
website builder. Create your website today.
Start Now