[Python Bootcamp] Day2

Yul·2024년 9월 22일

Python Bootcamp

목록 보기
3/7
post-thumbnail

1. 배운 것

  • 데이터 타입
    • string, integers, floats, boolean
    • 문자 연결인 '+'는 문자+숫자에는 사용 불가함.

      print("Number of letters in your name: " + len(input("Enter your name"))) >> 숫자라 오류

  • 숫자연산자
    • +,-,*,/,//,%
  • int 함수
  • round 함수
  • 할당연산자
    • +=, -=, *=, /=
  • f-string

    age = 12
    print(f"I am {age} years old")


    print("I am {0} years old".format(age))


    print("I am %d years old." %age)

2. 프로젝트 : 팁 계산기

print("Welcome to the tip calculator!")
bill = float(input("What was the total bill? $"))
tip = int(input("What percentage tip would you like to give? 10 12 15 "))
people = int(input("How many people to split the bill? "))

pay=round(bill*(1+tip*0.01)/people,2)

print(f"Each person should pay : {pay}")

profile
이것저것 공부하는 중

0개의 댓글