● 학습 내용
1) 모듈
[참고] 사이트
AskPython - Python Tutorials for Beginners and Experienced Programmers
Python Tutorials for Beginners and Experienced Programmers
www.askpython.com
2) Random
3) 리스트
names = ["Korea", "Japan", "US", "Canada"]
ex) 누가 점심을 살까요?
import random
names = names_string.split(", ")
num = random.randint(0,len(names)-1)
print(f"{names[num]} is going to buy the meal today!")
# names = names_string.split(", ")
=> 여러 명의 이름을 ,를 사용하여 입력
# len(names): list의 항목 수 셀 때도 사용
[참고] 튜토리얼
https://docs.python.org/3.8/tutorial/introduction.html
3. An Informal Introduction to Python — Python 3.8.17 documentation
3. An Informal Introduction to Python In the following examples, input and output are distinguished by the presence or absence of prompts (>>> and …): to repeat the example, you must type everything after the prompt, when the prompt appears; lines that d
docs.python.org
ex) 보물 찾기
https://github.com/yooyijun15/Python/tree/main/Day4
# index(): 인덱스 찾는 내장 함수, 리스트 값의 인덱스도 찾음
(가위바위보)
● GIT URL : https://github.com/yooyijun15/Python/tree/main/Day4
'여러가지 > Python' 카테고리의 다른 글
Day 6 - 사용자 함수 정의(def), 함수 호출, while 반복문 (1) | 2023.12.08 |
---|---|
Day 5 - for 반복문, shuffle(리스트 섞는 함수) (2) | 2023.12.07 |
Day 3 - 조건문 if, 관계연산자, 내장함수 count() (1) | 2023.12.01 |
Day 2 - 내장함수 type(), int(), float(), round(), 연산, f 문자열 (1) | 2023.11.29 |
Day 1 - 줄바꿈, 연결, 입출력, 주석, 변수, 내장함수 str(), len() (0) | 2023.11.21 |