python Tutorial

Lewis Kim·2020년 1월 21일
0
post-custom-banner

What I learned from Tutorial
1. Literal String Interpolation

lsi = "Literal String Interpolation
print(f""" This is tutorial for {lsi}. """)

=> This is tutorial for Literal String Interpolation

image.png

Literal String is the python's enhancement tool for styling (It is similar to es6 grammer tool in Javascript!)
There are several ways to format text strings 1) %-formating 2) str.format() 3) string template
Each of them have advantages and disadvantages. This PEP proposed to add a new string formatting mechanism

  1. Math Expression
    Using input() function, I have to calculate basic expression "add", "subtract", "multiply", "division"

my code is following

image.png

I thought to show string format + number type, Number type should be transformed into str format. However, there's a better way to do this.

Screen Shot 2020-01-21 at 3.36.40 pm.png

You can use Literal String Interpolation. By doing this, use can use it without chage the type of it.

  1. Advacned Math Expression
  • % Modulo Expression (Remainder)
  • && Modulo Expression (Quotient)
  • ** (Exponentiation)
post-custom-banner

0개의 댓글