본문 바로가기

기록/Python

두근두근파이썬 2장 연습문제

 

1.

name=str(input("이름을 입력:"))
age=int(input("나이를 입력:"))
year=2019+100-age
print(name,"씨는",year,"년에 100살입니다")

2.

one=int(input("첫번째 값 입력:"))
two=int(input("두번째 값 입력:"))
three=int(input("세번째 값 입력:"))
total=(one+two+three)/3
print(one, two, three,"입력된값의 평균값은",total, "입니다.")

3.

radius=int(input("반지름을 입력하시오:"))
area=radius*radius*3.141592
print("반지름이",radius,"인 원의 넓이 =",area)

4.

from turtle import*
shape("turtle")
radius = 50
circle(radius)
up()
goto(100,0)
down()
circle(radius+20)
up()
goto(200,0)
down()
circle(radius+40)

5.

from turtle import*
shape("turtle")
side=100
angle=120
for i in range(3):
    fd(side)
    lt(angle)

6.

from turtle import*
shape("turtle")
side=200
angle=120
for i in range(3):
    fd(side)
    lt(angle)

7.

from turtle import*
shape("turtle")
side = 50
angle = 90 
for a in range(4):
   for b in range(3):
      fd(side)
      lt(angle)
   fd(side)

'기록 > Python' 카테고리의 다른 글