1 - Basics
1 - Basics
Ice Breakers
Introduce yourself!
Files
Here
There are four basic types of data you can work with in python.
Print if the following statement is true or false in the console: You can surround a string
with single and double quotes interchangeably.
Make a shape using multiple strings stacked on top of one another. (Triangle, square,
empty square, smiley face if you’re feeling spicy).
Practice:
Make a number between 0 and 1, then print the number that is 10 times that.
Print if the following statement is true or false in the console: boolean values have to be
capitalized
Make a shape using multiple strings stacked on top of one another. (Triangle, square,
empty square, smiley face if you’re feeling spicy).
Print() Statement:
Function: Syntax:
print(“This is a message”)
The print() statement
prints a value in the
console.
MD: Print how many desks are in the classroom using one print statement. (Commas
separating the number and strings)
CH: Print the current date on one line using multiple print statements
Practice:
MD: Print how many windows are in the classroom using one print statement. (Commas
separating the number and strings) Output should be: Number of windows is 2
CH: Ask the user for their name and say hello to them. (You may need to use input())
ASCII Art:
Code:
Different Print statements print
on different lines.
The operators:
+ Addition
- Subtraction
* Multiplication
/ Division
% Modulo (Remainder)
Variables are containers that store data. You take a value and give it a name.
It can be thought of as a box with a label that you store something in:
Referencing the name of the variable will reference it’s value. The value also can
change.
Variables:
name = Value
The name must not have spaces, and has to start with a letter.
Some languages require the type of data to be declared before the name. This is not the case in
Python.
player_level = 42
print(player_level)
In here, a variable named “player_level” is created to store the level “42” (an int). It can then be printed,
which will print the value stored.
Also worth a mention:
None/Null:
← None
EZ: Make some variables for various ASCII shapes or drawings. (Now how do you include
a multi-line ASCII as one variable?)
MD: Print out the date using some variables for the various parts, and change them a bit.
(Now how do you print the numbers and slashes together?)
CH: Make a little mad libs program (just a couple sentences) where you ask the user for
various words and adjectives then give them a story. (Now how do you take those inputs?)
Practice:
EZ: Save your name, age, and if you can code in two languages into three variables
EZ: Draw a square, triangle, and trapezoid with ASCII art. (Then try it with one print
statement each).
MD: Ask the user to input the day, month, and year, then print the date in the standard
format MM/DD/YY.
MD: Ask the user for their name, grade, and favorite color then print out a short description
using those variables.
CH: Ask the user for a Celsius temperature value and print the Fahrenheit counterpart
(now how do you take the string input and make it a number?)
Practice:
Given a number, print the difference between that number and 21.
Take in a user’s string and print that string surrounded by “<<>>” (EX: bear → <<bear>>)
Given a string, print that string three times. For a challenge, take an input number and print
it that many times.
Ask the user for their eye color, hair color, and favorite color and print a short description
of them using those.
CH: Using a date in MLA format, change it to a MM/DD/YY and DD/MM/YY format.