[Python] 코드아카데미 따라하기 - chapter.1 Syntax_Tip Calculator

in #kr8 years ago

안녕하세요? 지금부터 저번 강좌인 Syntax의 팁 강의인 Tip Calculator 강좌를 시작하겠습니다.

1. The Meal

Now let's apply the concepts from the previous section to a real world example.
(자 이제부턴 이전 강좌의 개념을 실제로 반영할 수 있습니다.)
You've finished eating at a restaurant, and received this bill:
(당신은 막 식당에서 밥을 다 먹고 이 계산서를 받았습니다.)
Cost of meal: $44.50
Restaurant tax: 6.75%
Tip: 15%

You'll apply the tip to the overall cost of the meal (including tax).
(당신은 식사의 총액에 대한 팁(세금을 포함한)을 적용할 겁니다. )

Instructions

First, let's declare the variable meal and assign it the value 44.50.
(첫번째로, 변수 meal을 선언하고 44.50 값을 할당합시다. )

2. The Tax

Good! Now let's create a variable for the tax percentage.
(잘했습니다! 지금부터 세금 %를 위한 변수를 만들어봅시다.)
The tax on your receipt is 6.75%.
(당신이 받은 영수증에서 세금은 6.75%입니다.)
You'll have to divide 6.75 by 100 in order to get the decimal form of the percentage. (See the Hint if you would like further explanation.)
(당신은 %의 십진수를 얻기 위해 6.57를 100으로 나누어야합니다.(더 자세한 설명을 원하시면 힌트를 보세요.))

Instructions

Create the variable tax and set it equal to the decimal value of 6.75%.
(tax라는 변수를 만들고 6.75%의 십진수 값으로 해주세요.)

3. The Tip

Nice work! You received good service, so you'd like to leave a 15% tip on top of the cost of the meal, including tax.
(잘하셨어요! 당신은 좋은 서비스를 받아서 세금을 포함해서 식사의 가장 높은 가격에서 15%를 팁으로 주려고합니다.)
Before we compute the tip for your bill, let's set a variable for the tip.
(당신의 계산서에 대한 팁을 계산하기 전에 팁에 대한 변수를 만들어봅시다. )
Again, we need to get the decimal form of the tip, so we divide 15.0 by 100.
(다시 우리는 팁에 대한 십진수 폼이 필요합니다. 그러므로 15를 100으로 나눕니다.)

Instructions

Set the variable tip to decimal value of 15% on line 5.
(다섯번째 라인에 15%에 대한 십진수인 tip이라는 변수를 만듭니다.)

4. Reassign in a Single Line

Okay! We've got the three variables we need to perform our calculation, and we know some arithmetic operators that can help us out.
(자! 우리가 계산을 하기위한 세 개의 변수를 가지고 있습니다. 그리고 우리를 도와줄 산술 연산자를 알고 있습니다.)
We saw in Lesson 1 that we can reassign variables.
(우리는 변수를 재할당할 수 있다는 것을 강좌 1에서 봤습니다. )
For example, we could say spam = 7, then later change our minds and say spam = 3.
(예를 들어, spam=7로 했다고 마음이 바껴서 spam=3이라고 합니다.)

Instructions

On line 7, reassign meal to the value of itself + itself * tax.
(라인 7에서, meal을 meal + meal * tax로 재할당합니다.)
And yes, you're allowed to reassign a variable in terms of itself!
(그래요 그러면 당신은 이 변수의 관점에서 변수를 재할당할 수 있습니다.)
We're only calculating the cost of meal and tax here. We'll get to the tip soon.
(우리는 단지 식사와 세금의 가격을 계산하고 있습니다. 우리는 곧 팁을 얻을 수 있습니다.)

5. The Total

Now that meal has the cost of the food plus tax, let's introduce on line 8 a new variable, total, equal to the new meal + meal * tip.
(이제 meal은 음식 + 세금을 포함한 가격입니다, 라인8의 새로운 변수 total에 대해 소개합니다. total은 meal + meal * tip과 같습니다.)
The code on line 10 formats and prints to the console the value of total with exactly two numbers after the decimal. (We'll learn about string formatting, the console, and print in Unit 2!)
(라인 10에 있는 코드는 십진수 뒤에 정확히 소수점 2개가 붙는 total 값을 콘솔에 구성하고 출력합니다.(우리는 Unit2에서 문자열 구성, 콘솔, 출력에 대해 배울 겁니다.))

Instructions

Assign the variable total to the sum of meal + meal * tip on line 8. Now you have the total cost of your meal!
(라인 8에 meal + meal * tip으로 변수 total에 할당해주세요. 그러면 당신은 식사의 총 가격을 갖습니다.)

다음 강좌는 Strings & Console Output 입니다.

Coin Marketplace

STEEM 0.28
TRX 0.11
JST 0.030
BTC 68434.91
ETH 3745.67
USDT 1.00
SBD 3.66