*Use code for exercises 1.1-1.3*

Use function *print* to print `"Daniel"`

. On a new line, print his occupation - `"Lecturer"`

. Finish by printing another new line with his favorite TAs - `"Jessica"`

, `"Jess"`

and `"Jessica Lee"`

.

Given the code below, print `x`

, `y`

, and `z`

on three different lines.

In [ ]:

```
x = 17
y = 19
z = 42
```

Given the code below, print `u`

, `v`

, and `w`

on the same line.

In [ ]:

```
u = [3, 5, 8]
v = True
w = 3.14
```

*Use code for exercises 2.1-2.3*

Given the list `list1`

, print the first element.

In [ ]:

```
list1 = ["coder", 2018, "addis"]
```

Given the list `list2`

, print the last element in two ways.

In [ ]:

```
list2 = ['apple', 'orange', 'banana', 'pear', 'dragonfruit', 'lychee', 'starfruit']
```

In [ ]:

```
list3 = [True, False, True, True, True, False, True, True, True, False]
```

Given `list4`

print the last 5 elements in two ways.

In [ ]:

```
list4 = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144]
```

Given `list5`

, create the list `[4,3,"hello world", "Jelani"]`

using one line of code. How do you know you've succeeded?

*Hint: print out the list to check*

In [ ]:

```
list5 = [4, 3, 7, 'Jelani']
```

Given `str1`

, create the string `cat`

by using slicing.

In [ ]:

```
str1 = "caterpillar"
print(str1[:]) # modify this line
```

Try executing the code below. Can you change the output by changing only 1 character (there may be multiple solutions)?

In [ ]:

```
x = 42
y = 111
print(x < y)
```

What is different in the case below?

```
x = "42"
y = "111"
print(x < y)
```

Construct an 4 digit number and a 5 digit number such that the 4 digit number is greater than the 5 digit number when they are of type string.

What would be the result of the following operations?

```
'A' == 'a'
'Brunch'< 'banana'
'coffee' < 'Coffee'
'Dog' > 'cat'
'Daniel' != 'daniel'
'jessica' > 'jess'
'CORINA' < 'CORONA'
```

Check your answer in the box below. Can you figure out the rules for string comparisons?

In [ ]:

```
# Explore here
# print('A' == 'a')
```

Write a function that takes `x`

as an argument, and returns `5 * x`

.

In [ ]:

```
def multFive(x):
return # place code here
```

Write a function that takes `x`

as an argument and returns `x + 2`

.

In [ ]:

```
def addTwo(x):
return # place code here
```

Write a function that returns `5 * x + 2`

, without using any arithmetic operations.

*Hint: use multFive and addTwo. Please run the cells for exercises 4.1 and 4.2 before running this cell.*

Write a function called `addXtoY`

that takes two arguments `x`

and `y`

, and returns their sum.

Write a function called `multiplyXandY`

that takes two arguments `x`

and `y`

, and returns their product.

Use the functions from 5.1 and 5.2, and add at least 3 functions similar to those above that simulate a calculator's functions.

Use your calculator functions to write a function that represents $ f(x) = 5x + 4 $.

In [ ]:

```
def f(x):
return # place code here
```

Write a function called `concatXandY`

that takes two strings `x`

and `y`

, and concatenates them together.

Write a function `concatXYZ`

that takes three strings `x`

, `y`

, and `z`

, and concatenates them together without using any arithmethic operations.

Write a function `cToF`

that converts Celsius to Fahrenheit using the equation $F = C \times \frac{9}{5} + 32$.

Write a function `fToC`

that converts Fahrenheit to Celsius using the equation $C = (F - 32) \times \frac{5}{9}$.

What happens when you call `cToF(fToC(x))`

? Try for a few values of `x`

. Can you prove it?

Write a function called `pythagoreanTriplet`

that takes in 3 integers which will represent triangle side lengths and returns a bool, to determine if it forms a right-angled triangle. The arguments are guaranteed to be sorted in increasing order.

*Hint: A triangle is a right-angled when side lengths a, b, and c satisfy $ a^{2} + b^{2} = c^{2}$.*

In [ ]:

```
# write function here
# some unit tests
print(pythagoreanTriplet(3, 4, 5))
```

A palindrome is a string that is the same when read forwards and backwards. For example, "madam", "alabala", and "12321" are palindromes but "daniel", "hello", and "1234" are not. Write a function `threePalindrome`

that takes in a THREE-LETTER string, and returns a boolean that is `True`

when the string is palindrome, and `False`

when it is not.

Write a function `fourPalindrome`

that checks if a four-letter string is a palindrome.

Look at the function below. Without running it, can you predict the outcomes of calling `funkyFunc(100)`

, `funkyFunc(123456)`

, and `funkyFunc(420)`

?

```
def funkyFunc(x):
z = x * 10
x = x % 10
z = z + x
return z
```

In [ ]:

```
# for x = 100, funkyFunc(x) = ??
# for x = 123456, funkyFunc(x) = ??
# for x = 420, funkyFunc(x) = ??
# Check your answers below:
```

Can you write a function `funkierFunc`

which takes one argument and for which the following equation is true for any $x>0$:

`funkierFunc ( funkyFunc(x) ) = x`