π Hello again, World!
November 21, 2016π― Learning Target
I can create variables in Python.
π Do Now
Fill in as much of this Venn Diagram as you can:
return
to Python
Remember this?
Why does it say Let's review Python
?
Last year, we used Python 2. This year, we will be using Python 3. There are a few important differences, but for today, the most important is this:
# in PYthon 3, print is a FUNCTION:
print("hello there")
# ^ parentheses ^
Variables
Store a variable under a name.
Name | ONE Equal sign | Value |
---|---|---|
name | = | SK |
grade | = | 9 |
Rules for Variable Name
- Contains letters, numbers, and underscores ( _ )
- Cannot start with number
- Cannot contain spaces (you can use underscores used to separate words)
- Cannot use keywords
πwords
Each programming language has a set of words that are reserved by the language for programmatic purposes.
Some Keywords in Python are : print
, False
, True
, else
, if
Rules of π for Variable Names
- Pick names that make sense. Someone besides you should be able to figure out what your variables mean.
- Use underscores to separate words
- Python is CASE SENSITIVE which means
Num_marbles = 10
andnum_marbles = 10
are different.
Datatypes
Type | Description | Example |
---|---|---|
String | Any characters inside "" |
This is a string. |
Integer | Whole numbers | 3 ,42 ,-1002 |
Float | Numbers with decimals. | 3.42 , -10.02 |
Boolean | Only two values | True , False , 3>42 , 3.42>-10.02 |
βͺ Python Review
π Join our repl classroom.
- Create a variable called
my_name
and store your name in it. Then print the variable. - Create a variable called
multiply
that is the product of a negative number and a positive number with a decimal (not a whole number). Print the variable. - Store a message in a variable. Then print the message.
- Create a variable that stores a Boolean value. Print the variable.
- Create a variable that stores a message. Then store another message in the same variable. Print the message.
πΆ
Create a variable that is the quotient of two other variables (hint: you will need to store values in that variable first).
πΆπΆπΆ
The operations between boolean values are AND and OR. Create a variable that store the value of True or False and then prints it. Create another value that stores the value of True and False. Print the variable.