> Dear Heavenly Father,
We start this day asking for your joy and strength in this moment when we are practicing these programming skills.
Please let this be a moment of true fellowship and character building in our community of learning.
Be with us in any difficulties we face. Give us a disposition to help, and humility to be helped.
Give us wisdom to discern your beauty and justice as we write these Python programs.
May everything we do and learn here be offered to you in praise, gratitude and service to our neighbors.
In Jesus' name we pray. Amen.
# Object Types in Python
- Python syntax specifies some ways to represent different types of data. A data representation in Python is called an "object".
| Type | Object type in Python | Example |
|---------------------------------|-----------------------|------------------|
| Integer number | `int` | `123` |
| Decimal number (floating point) | `float` | `3.14` |
| Logic value | `bool` | `True`, `False` |
| Text | `string` | `"Hello World!"` |
# Variables
- Variables are names we set to refer to objects.
- A metaphor: objects are houses, variables are addresses of these houses
```python
x = 123 # a variable x that contains the integer value 123
x = x + 1 # x is updated with the value of x + 1, becoming 124
hello = "Hello World!" # a variable that contains the string "Hello World!"
is_done = True # a variable is_done with the logic value True
```
## Objects x variables
- It is **very important** to differentiate!
- Which of the following are variables and which are objects?
`"hello"`
`hello`
`132`
`var_1`
`truev`
`True`
## Variable naming conventions in Python
- They MUST start with a letter or with \_ (underline)
- They are case sensitive ('C' is different from 'c')
- They can't contain: `{ ( + - * / \ ; . , ?`
- They can't have names of words already reserved for other purposes in Python:

# Input and Output
- Programming is nothing without the design of an **interface**!
- I have to be able to **input** data in the program, and
- I have to be able to get results (**output**) from the program.
## Graphical input/output
- Also called Graphical User Interface (GUI
- Kind of mimics the way we use mechanical input and output
- Traditionally, [WIMP](https://www.interaction-design.org/literature/book/the-glossary-of-human-computer-interaction/wimp) (Windows, Icons, Menus and Pointers)

## Text input/output
- Even simpler, however, it is a good start for programming!
```python
name = input("Please enter your name:")
reverse = name[::-1]
print("Your name in reverse is", reverse)
```
The command-line interface will ask for input from our keyboard, and then:

# Python text input: `input()`
- The command waits until the user types some text in the command-line interface and finishes with ENTER
- The term `input()` "turns" into the text entered, and is **ALWAYS** an object the type `string`!
- Thus, it needs to be saved into a variable: `x = input()`
- After the user types "Hi", for example, it is as if: `x = "Hi"`
- You can customize an input message by passing a string:
```python
x = input("Please enter your name: ")
```
## Input of numeric values
- Now, suppose we want to calculate the sum of two numbers:
```python
x = input("Please enter first number: ")
y = input("Please enter second number: ")
z = x + y
print("The sum is", z)
```
What happened???
## Converting strings to numbers
- You can convert a string to a number using the methods `int()` and `float()`
- The string that goes inside the parentheses (which we call the "argument" of the method) will be turned to an integer/float
```python
xstring = input("Please enter your age: ")
x = int(xstring)
print("Your age is ", x)
```
- Just make things shorter by chaining one method into another!
```python
x = int(input("Please enter your age: "))
print("Your age is ", x)
```
# Python text output: `print()`
- Put what you want to print between the parentheses: `print("Hello World")`
- If you want to jump to a new line, use `\n`: `print("Hello\nWorld")`
- You can also pass multiple arguments by separating them with commas: `print("x has the value:", x, "\nand y has the value:", y)`
## Formatting floats with decimal precision
- Method 1: `format()`
```python
value = 123.456789
print("Number is {:.2f}".format(value)) # Output: 'Number is 123.46'
```
- Method 2: `f-strings`
```python
value = 123.456789
print(f"Number is {value:.2f}") # Output: 'Number is 123.46'
```
# Some practice exercises
### Calculator
Write a program that:
1. Asks the user for two numbers (as input).
2. Converts these inputs into floats.
3. Outputs the sum, difference, product, and quotient (with 2 decimal places) of the two numbers using formatted output.
### Shopping receipt
Write a program that:
1. Asks the user for the name and price of three items.
2. Calculates and displays the total cost with two decimal places.
3. Displays the item names, prices, and total cost in a formatted receipt, aligning names and prices in two columns for easy reading.
For example:
```
Item Price
------------------
Apples $1.50
Bananas $0.75
Oranges $1.25
------------------
Total $3.50
```