> For the complete documentation index, see [llms.txt](https://www.cps3320.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://www.cps3320.com/unit-2/source-code.md).

# Source Code

## Example 1

```python
# example 1
num = int(input("Give me a number: "))
if num > 0:
    print(str(num) + " is positive.")
if num < 0:
    print(str(num) + " is negative.")
if num == 0:
    print(str(num) + " is zero.")
```

## Example 2

```python
# example 2
hot = input("Is it hot today? ")
if hot == "Yes":
    print("It's always hot in NJ")
if hot == "No":
    print("It's never hot in NJ")
```

## Example 3

```python
# example 3
num = int(input("Number: "))
if num % 2 == 0:
    print("Even")
if num % 2 == 1:
    print("Odd")
```

## Example 4

```python
# example 4
money = float(input("How much money do you have? "))
if money >= 999.99:
    print("You're rich!")
if money < 999.99:
    print("You're not rich!")
```

## Example 5

```python
# example 5
hot = input("Is it hot? [Yes/No] ")
# version 1
isHot = False
if hot == "Yes":
    isHot = True
```

## Example 5 v2

```python
# example 5
hot = input("Is it hot? [Yes/No] ")
# version 2
isHot = True if hot == "Yes" else False
```

## Example 6

```python
# example 6
commute = int(input("How long is your commute? "))
if commute <= 30:
    print("not bad")
else:
    print("too much")
```

## Example 7

```python
# example 7
age = int(input("What is your age? "))
if age <= 1:
    print("Infant")
elif age < 13:
    print("Child")
elif age < 20:
    print("Teenager")
```

## Example 8

```python
# example 8
hungry = input("Are you hungry? ")
if hungry == "Yes":
    food = input("What kind of food do you want? ")
    if food == "American":
        print("Let's goto McDonalds")
    else:
        print("Let's try new food!")
else:
    print("Sorry you're not hungry!")
```

## Example 9

```python
# example 9
print(True and True)
print(True and False)
print(False and True)
print(False and False)
```

## Example 10

```python
# example 10
knowledgeTest = input("Did you pass the knowledge test? ")
roadTest = input("Did you pass the road test? ")
if knowledgeTest == "Yes" and roadTest == "Yes":
    print("You can drive!")
else:
    print("Not yet!")
```

## Example 11

```python
# example 11
print(True or True)
print(True or False)
print(False or True)
print(False or False)
```

## Example 12

```python
# example 12
day = input("What day is it? ")
if day == "Saturday" or day == "Sunday":
    print("Weekend")
else:
    print("Weekday")
```

## Example 13

```python
# example 13
age = int(input("How old are you? "))
if not(age > 18):
    print("not over 18")
else:
    print("over 18")
```

## Example 14

```python
# example 14
print(num := 99)
```

## Example 15

```python
# example 15
weather = input("What's the weather? ")
match weather:
    case "sunny":
        print("It's a beautiful day!")
    case "rainy":
        print("Don't forget an umbrella!")
    case "snowy":
        print("It's going to be snowy")
    case _:
        print("The outlook is uncertain")

```
