DEV Community

loading...
Cover image for Day 2 of 100DaysofCode: Tip Calculator 🧮

Day 2 of 100DaysofCode: Tip Calculator 🧮

fatihms profile image Fatih Mustafa Sağır ・1 min read

Hi there! Today is Day 2 of 100 Days of code.

I really enjoyed developing applications with python for the last 2 days and I believe, every day will be like this. 😎

In today's lessons, I've learned about datatypes, numbers, operations, type conversion, and f-strings.

Here is some code,

Datatypes

"Hello" # String
15 # Integer
9.3241 # Float
True, False # Boolean
Enter fullscreen mode Exit fullscreen mode

Numbers

x = 1 # int
y = 2.8 # float
Enter fullscreen mode Exit fullscreen mode

Operations

2 + 5 # Add
5 - 1 # Subtract
6 * 5 # Multiply
8 / 4 # Divide
12 ** 4 # Exponent
Enter fullscreen mode Exit fullscreen mode

Type Conversion

s = "25" 
type(s) # print <class 'str'>
new_s = int(s) # converting to int 
print(new_s) # resul 25
type(s) # print <class 'int'> 
Enter fullscreen mode Exit fullscreen mode

F-strings

name = "Fatih"
print(f"Hello, {name}") # print Hello, Fatih
Enter fullscreen mode Exit fullscreen mode

At the end of the day, I made a calculator with everything I learned in the previous lesson and the previous day.

Project

Tip Calculator 🧮

Alt Text

Here's the Github repo and repl.

Discussion (1)

pic
Editor guide
Collapse
chrisgreening profile image
Chris Greening

Awesome!! Keep up the great work 🙌