1. ์๋์ ์ ์๋ ๋ค์๊ณผ ๊ฐ๋ค. ์ ์์ ํ๊ท ์ ์ถ๋ ฅํ์์ค.
๊ตญ์ด : 90์ , ์ํ : 56์ , ์์ด : 34์
korean = 90
math = 56
english = 34
print((korean + math + english) / 3)

2. ์๋์ ์ฃผ๋ฏผ๋ฑ๋ก๋ฒํธ๋ "041205-4234567'์ด๋ค. ์๋์ ์ฃผ๋ฏผ๋ฑ๋ก๋ฒํธ๋ ์๋ ์์ผ ๋ถ๋ถ๊ณผ ์๋ ๋ถ๋ถ์ผ๋ก ๋๋์ด ์ถ๋ ฅํ์์ค. (์ฌ๋ผ์ด์ฑ ์ฌ์ฉ)
code = "041205-4234567"
print(code[:6])
print(code[7:])

3. ๋ฌธ์์ด "707"์ ๊ฐ๊ฐ ์ ์ํ, ์ค์ํ, ๋ฌธ์ํ์ผ๋ก ๋ณํํ์ฌ ๋ค์๊ณผ ๊ฐ์ด ์ถ๋ ฅํ์์ค. (๋จ, ๊ฒฐ๊ณผ๋ ํ ์ค๋ก ์ถ๋ ฅํ์์ค.)
a = "707"
print("์ ์ํ :", int(a), ", ์ค์ํ :", float(a), ", ๋ฌธ์ํ :", a)

4. ๋ค์ ๋ฌธ์์ด "dhasfjHappyanrlods"์์ "Happy" ๋ฌธ์์ด๋ง ์ถ๋ ฅํ์์ค.
str = "dhsafjHappyanrlods"
print(str[6:-7])

5. ๋ค์ ๋ฆฌ์คํธ cities = ["์์ธ", "๋ถ์ฐ, "์ธ์ฒ", "๋๊ตฌ," ๋์ ", "๊ด์ฃผ", "์ธ์ฐ", "์์"]์์ ๋ถ์ฐ๊ณผ ์ธ์ฒ ์ฌ์ด์ "์ธ์ข "์ ์ถ๊ฐํ๊ณ "๋์ ์ ์ ๊ฑฐํ ํ ์ถ๋ ฅํ์์ค.
cities = ["์์ธ", "๋ถ์ฐ", "์ธ์ฒ", "๋๊ตฌ", "๋์ ", "๊ด์ฃผ", "์ธ์ฐ", "์์"]
cities.insert(2, "์ธ์ข
")
cities.remove("๋์ ")
print(cities)

6. ๋ค์๊ณผ ๊ฐ์ด ์ฝ๋๋ฅผ ์์ฑํ์ ๋, ์คํ ๊ฒฐ๊ณผ๋ก ์๋ง์ ๊ฒ์?
fruit1 = ["orange", "melon", "strawberry"]
fruit2 = ["watermelon", "grape"]
fruit2.remove("grape")
fruit1.append(fruit2)
print(fruit1)
๋ต : 3๋ฒ

7. ๋ค์๊ณผ ๊ฐ์ด ์ฝ๋๋ฅผ ์์ฑํ์ ๋, ์คํ ๊ฒฐ๊ณผ๋ฅผ ์ฐ์์ค.
fruits = ["apple", "banana", "cherry", "grape", "orange", "strawberry", "melon"]
print(fruits[-3:], fruits[1::3])
๋ต : ['orange', 'strawberry', 'melon'] ['banana', 'orange']

8. ๋ค์๊ณผ ๊ฐ์ด ์ฝ๋๋ฅผ ์์ฑํ์ ๋, ์คํ ๊ฒฐ๊ณผ๋ก ์๋ง์ ๊ฒ์?
fruit = ["orange", "lemon", "strawberry", "cherry"]
number = ["1", "2", "3"]
first, second, third = number
print(second * fruit.index("strawberry"))
๋ต : 1๋ฒ
'๐ ์คํฐ๋ > ํ์ด์ฌ ์คํฐ๋ ๊ณผ์ ์ ์ถ' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[1ํ/๊น์ํ] 2์ฐจ์ ํ์ด์ฌ ๊ณผ์ - ์๋ฃํ (0) | 2023.03.17 |
---|---|
[2ํ/์ด์ ์ง] 2์ฐจ์ ํ์ด์ฌ ๊ณผ์ - ์๋ฃํ (0) | 2023.03.17 |
[1์กฐ/์ด๋์ฐ] 2์ฐจ์ ํ์ด์ฌ ๊ณผ์ - ์๋ฃํ (0) | 2023.03.17 |
[4ํ/์์์ฐ] 2์ฐจ์ ํ์ด์ฌ ๊ณผ์ - ์๋ฃํ (0) | 2023.03.17 |
[4ํ/๊น์ ๊ฒฝ] 1์ฐจ์ ํ์ด์ฌ ๊ณผ์ - ์ ์ถ๋ ฅ (0) | 2023.03.15 |