본문 바로가기

여러가지/Python

Day 1 - 줄바꿈, 연결, 입출력, 주석, 변수, 내장함수 str(), len()

● 개발환경

URL : https://replit.com/@uyijune15

 

uyijune15

Run code live in your browser. Write and run code in 50+ languages online with Replit, a powerful IDE, compiler, & interpreter.

replit.com

 

 

● 학습 내용

 

1) 줄바꿈

print("Hello World!\nHello World!\nHello World!")

 

2) 연결

print("Hello" + " " +  "June")

 

3) 입력

input("What is your name?")

: input 함수 안의 문장이 출력되고 입력을 받는다.

 

4) 출력 + 입력

print("Hello, " + input("What is your name? ") + "!")

: input 함수 안의 문장이 출력되고 입력을 받은 후에, print 함수 안의 문장이 출력된다. 즉, Hello, June!이 출력된다.

 

5) 주석

# 이것은 주석이다.

< command + / > : 주석 & 해제

< command + z > : 해제

 

6) 변수

name = input("What's your name? ")
print("name: " + name)
print("count: " + str(len(name)))

# len(): 문자열 글자 수 세는 내장 함수

# str(): 정수나 실수를 문자열 형태로 바꾸는 내장 함수

 

 

● Day 1 프로젝트

city_name = input("What's name of the city you grew up in?\n")
pet_name = input("What's your pet's name?\n")
print("Your Band Name: " + city_name + " " + pet_name)

 

 

[참고] Thonny

: 코드 실행순서에 따라 실행

URL : https://thonny.org/

 

Thonny, Python IDE for beginners

Thonny 4 is dedicated to Ukraine fighting the Russian invasion. 🇺🇦 Please support Ukraine! 🇺🇦 Download version 4.1.3 for  •   •  For the curious: 4.1.4 Thonny Python IDE for beginners Features Easy to get started. Thonny comes with Pyth

thonny.org