# CS 101 Lab: Week # 3
The following has been covered during the second/third week of CS101 labs.
---
## Outline:
1. At first: short sum-up of the last one or two labs (depending on the group), with references to the lectures done by Profs. Dhande and Arya,
2. (again) Storing values into variables (`x = 0`, `name = "Superman"` etc), and getting numbers or values from the standard input from the user (with your keyboard, with `input` or `raw_input`). Simple interactive program for welcoming you *[ass.#2]*,
3. Using a method: basic use, example with strings (upper case, lower case, title case etc) *[ass.#1]*,
4. Simple interactive programs to compute and print the area of a square, a rectangle, a triangle and a circle if the user gives the important parameter(s). *[ass.#3]*
5. **Importing** the value of **pi** from the `math` module (`from math import pi`),
6. Using the *Python* [documentation](https://docs.python.org/2/) (within [*Spyder IDE*](https://pythonhosted.org/spyder/)) to discover more about mathematical functions (`math` and `cmath`),
7. **Complex numbers**: writing them, using them. Operations on complex numbers.
> And, receiving written homeworks from students, about what Prof. Dhande gave last week.
> [Cf this python file for a partial solution](../../solutions/homeworks/CS101_Homeworks_1_from_Prof_Dhande__solutions_by_Lilian_Besson.py).
### Bonus (if the time allows it)
1. Bonus: Quick eplanation of the difference between `raw_input` and `input`, and why `x = float(raw_input("x = "))` is better than `x = input("x = ")`...),
2. Bonus: introducing the use of a **module**, [math](https://docs.python.org/2/library/math.html) for math functions, [cmath](https://docs.python.org/2/library/cmath.html) for functions for complex numbers.
3. Bonus: Playing again with `float` numbers. [Floating Point Arithmetic: Issues and Limitations](https://docs.python.org/2/tutorial/floatingpoint.html)
4. Bonus: presentation of an if loop, and using it to convert a temperature to °F or °K depending on the choice of the user.
---
## Assignments (for next lab):
1. First, type in your first and last names in two separate variables, all in lowercase (`first = 'bruce'` and `last = 'wayne'`).
1. Print these variables such that the last name comes in the next line of the first name.
2. Then concatenate them into a single variable and print again (strings can be concatenated with the `+` operator).
3. Independently, print the two names in the same line to look exactly like the print of the concatenated variable.
4. Bonus: print the same using all uppercase, and all Title case. Try something like `first.upper()` or `str.title(last)`).
2. Write a (interactive) program using `raw_input` that prompts a user for his/her name and then welcomes the person with a *Hello* and a welcoming message of your choice on either side of the name, looking like `"Hello Superman, welcome to MEC's Python lab sessions!"`".
3. A person works on a job for one week at a certain rate of pay (i.e. Rupees per hour) and a certain number of hours in each day, for a 5-day week. Write a program that prompts the user to enter the rate, the hours, and then calculates how much the person earns during the week and prints it. Feed the rate as Rs 100/hour, and 8 hours in a day. Check if your result matches with Rs. 4000.
4. Interactive program to convert a temperature from °C to °F and to °K (Use the conversion formula **F = (9/5) * C + 32**),
5. Interactive program to ask the user for a complex number (e.g. `z = 4 + 5j`), compute and print the real part, imaginary part, modulus, main argument (*phase*). Bonus: print whether if the complex point is in the 1st, 2nd, 3rd of 4th quadrant (or 0, or x-axis or y-axis).
6. Bonus: find an interesting program you can try to write with the bases of Python covered from the first lab. *Be creative!*
---
## Example program (for the temperature assignment)
# -*- coding: utf-8 -*-
print "I will convert a temperature from °C to °F:"
temp_C = float(raw_input("Please give me a temperature in °C: T = "))
assert(-273.5 < temp_C)
temp_F = (9./5.) * temp_C + 32
# Are you sure about the order of operations?
temp_K = temp_C + 273.5
print "So this temperature of", temp_C, "°C, is ", temp_F, "°F and", temp_K, "°K. Cool."
---