Aug 21: Welcome and Getting Started with Thonny
Learning Objectives
After today's class, you should be able to:
- Open, edit, save, and run a program in Thonny.
- Submit a homework exercise on using canvas.
- Ask and answer questions (later) on Piazza.
- Use your online textbook and complete activities
Lesson Outline¶
Welcome!
- Name tents; get to know other students at your table
- About the course; introductions by professor and TA
- Syllabus
- Canvas
- Introduction
Textbook and first assignment in canvas
- Runestone Python Textbook In canvas, complete the book registration assignment to gain access to our textbook. It is a free book.
- Textbook reading with activities are due every Tuesday by 3pm
Mini Lab
- Demonstration of Thonny Python IDE (see code below). Work on lab machines
- Walk-through of how to submit "Lab 1" on canvas and the role of gradescope. The python code for lab 1 is below. The python file must be named hello_world.py
- You will need to install Thonny on your laptop by next class. Installing Thonny, ruff. You need to setup a folder called 'CS149' and then subfolders for each assignment.
- Demonstration of Runestone:
- Log into canvas
- Select our CS149 course
- Select Assignments, then select register for book and follow the directions
- After registering for the book, select the assignment Week 1 Reading
Always go through our canvas course for reading assignments
Activity
- Introduction to Python
– see Activity code below
- If you are absent today, complete this activity at home
- Bring your completed activity to class or office hours
Lecture
Getting Help
- Click the Piazza link in Canvas
- What questions do you have about the syllabus/course?
Wrap-Up
- Explanation of "your to-do list" below (rest of the week)
Your To-Do List¶
Complete by tomorrow, Friday Aug 22nd
- Pre-Survey: Please submit this "quiz" if you haven't already!
- Submit Lab1 to canvas
Complete by Monday Aug 25th
- Install Thonny on your laptop
Complete by Tuesday Aug 26th by 3pm
- Register for the textbook
- Week 1 Complete week 1 reading and complete activities.
DUE Wednesday Aug 27th
Example Code¶
Here is the solution for today's mini-lab. Notice how lines 1–6 are formatted. When you submit to canvas, always include (1) a short description, (2) your name, and (3) the date. These lines must be formatted exactly as shown. See requirements
hello_world.py | |
---|---|
1 2 3 4 5 6 7 |
|
Here is a more interesting example that uses turtle graphics. If you have time during/after class, try extending the following code to draw a picture. Check out Trinket's Visual Introduction to Python for ideas.
hello_turtle.py | |
---|---|
1 2 3 4 5 6 7 8 9 10 11 |
|
Code for Activity¶
Model 1 – copy into the editor, save as hello.py
# display a welcome message
print("Welcome to Python 3!")
# give the user a compliment
name = input("What's your name? ")
print(name, "is a great name!")
Model 2 – copy one line at a time into the shell
input("enter the mass in grams: ")
mass = input("enter another mass in grams: ")
mass
unit = input("enter the units for mass: ")
print(mass, unit)
print(mass / 2)
ten = 10
print(ten / 2)
abs(-1)
abs(-1 * ten)