5

## [自學Python紀錄] HackerRank 新手30天挑戰-Day01

Hi there! 我是嘟嘟~受到前輩啟發，想說可以紀錄一下自己練習的過程，小女子為程式超超菜鳥，此系列非教學文，僅為個人解題筆記，可能有錯誤或未補充詳盡之處，歡迎前輩們不吝指教！也歡迎正在自學的夥伴一起討論學習～

## Day 1: Data Types

### 樣本輸入

``````12
4.0
is the best place to learn and practice coding!
``````

### 樣本輸出

``````16
8.0
HackerRank is the best place to learn and practice coding!
``````

### 初始格式

``````i = 4
d = 4.0
s = 'HackerRank '
# Declare second integer, double, and String variables.

# Read and save an integer, double, and String to your variables.

# Print the sum of both integer variables on a new line.

# Print the sum of the double variables on a new line.

# Concatenate and print the String variables on a new line
# The 's' variable above should be printed first.
``````

### 我的解答

``````i = 4
d = 4.0
s = 'HackerRank '

a = int(i) + int(input())
b = float(d) + float(input())
c = s + input()

print(a)
print(round(b,1))
print(c)
``````

## 補充:

• 此處`double`指的是C++語言中的雙倍精度浮點數，類似於Python的`float`浮點數的意思。

• 題目有寫印出的第二個浮點數要取到小數點第一位，打文章才發現，故加上`round()`，可以參考文章【Python如何控制小數點後面的小數位數