DAY1: Python day 1&2
Tags: 100daysofcode, python
Published: 2023-11-03 15:48:31

Today, I start my programming journey. I will study on Thursdays, Fridays, and weekends every week, documenting what I've learned along the way. 
I will start with a Udemy 100-day Python course and a Harvard CS50 course. 
Hope I can get this through. 

## GETTING STARTED ON PYTHON

**print() function**

- output something you put in the parenthesis. 

- for `String`, quotation marks needed around the argument. 


**String manipulation**

`\n` within the quotation.


- can combine Strings by using `+` sign.

- when combined, there is no space in between; there are three ways to add it. 

**input() function**

- inside the parenthesis, we add a prompt for the user to answer.

- the code gets replaced with the user input.

**len() function**

- returns the number of characters in a `String`.

**Python variables**

- variable helps to refer to a piece of data.

- can later give a variable a different piece of data to hold onto.

- in order to make code readable, try to name a variable in a way that makes sense. 

- can separate words in multiple ways: 

```

myVariableName = "John" #Camel Case 
MyVariableName = "John" #Pascal Case
my_variable_name = "John" #Snake Case

```

**End of the lesson project: band name generator**

```
#1. Create a greeting for your program.
print("Hello There")
#2. Ask the user for the city that they grew up in.
city = input("Which city did you grow up in?\n")
#3. Ask the user for the name of a pet.
pet_name = input("What is the name of your pet?\n")
#4. Combine the name of their city and pet and show them their band name.
print ("Your band name could be " + city + " " + pet_name + ".")
```

##Python Day2##
I already knew these, so I decided to swiftly go through the second lesson as well. 

**String**

- subscripting: getting the position of the character in a `String`

- you can put in a number starting from 0 in `[]`to get the corresponding character.

- as long as capped within a quote, numbers are also considered a `String`.

**Integer**

- whole numbers.

- to create an `int`, write the number without anything else.

- large integers can be written with underscores (used like a comma), which will be automatically ignored. 
 
**Floating point number**

- a number with a decimal point

**Boolean**

- `True` or `False` 

**type() function**

- checks type of data of something inside the bracket. 

**Type conversion**

- can use `str()`, `int()`, `float()` to convert data into another data type.

**Mathematical operations**

- addition `+`

- subtractions `-`

- multiplications `*`

- divisions `/`

- exponent `**`

**Rounding in Python**

- `round(number, number of digits of precision)`
-floor division`//`; returns `int` value.

**f-Strings**

- add `f` in front of the `String`

- add in variables with different data types in `{}`

**End of the lesson project: tip calculator**

```
print("Welcome to the tip calculator.")
total = input("What was the total bill? $")
percentage = input("What percentage tip would you like to give? 10, 12, or 15? ")
people = input("How many people to split the bill? ")
tip = float(total)/int(people)*(1 + int(percentage)/100)
rounded_tip = round(tip, 2)
print(f"Each person should pay:${rounded_tip}")
```