본문 바로가기

학교수업/불교파이썬

중간고사 예상문제

#1. ch1 ex9 5개 원 그리기
import turtle
t = turtle.Turtle()
t.shape("turtle")

t.circle(100)
t.up()
t.goto(200,0)
t.down()
t.circle(100)
t.up()
t.goto(400,0)
t.down()
t.circle(100)
t.up()
t.goto(100,-100)
t.down()
t.circle(100)
t.up()
t.goto(300,-100)
t.down()
t.circle(100)
#2.ch2 create a robot jornalist 24페이지
location = input("Where is the stadium?")
win = input("Which team won?")
lost = input("Which team lost?")
best = input("Who is the best player?")
score = input("What is the best score?")
print("===================================================")
print("Today a basball game was played in ", location,".")
print(win, "and", lost, "fought a fierce battle.")
print(best, "did a great job on this one.")
print("eventually", win, "won against", lost, "to", score)
print("===================================================")
#3. 섭씨 화씨 변경하기
celsius_1 = float(input("Temperature value in degree Celsius: " ))  

Fahrenheit_1 = (celsius_1 * 1.8) + 32  

print("Fahrenheit temperature:", Fahrenheit_1)
#4. ch3 ex3
number=int(input("Enter the integer: "))
x=number%10
number=number//10
y=number%10
number=number//10
z=number%10
number=number//10
a=number%10
print("the sum of the digits of the integer: ", x+y+z+a)

 

#5. ch3 ex4
x1 = int(input("x1:"))
y1 = int(input("y1:"))
x2 = int(input("x2:"))
y2 = int(input("y2:"))
distance = ((x1-x2)**2+(y1-y2)**2)**0.5
print("the distance between two points: ",distance)
#6.ch2 ex5
import turtle
t = turtle.Turtle()
t.shape("turtle")
side=100
t.forward(side)
t.left(120)
t.forward(side)
t.left(120)
t.forward(side)
t.left(120)
#7.ch3 ex5
import turtle
t = turtle.Turtle()
t.shape("turtle")
t.forward(100)
t.left(90)
t.forward(100)
t.left(135)
t.forward(141)
t.up()
t.goto(0,0)
t.down()
t.setheading(0)
t.forward(100)
t.left(90)
t.forward(100)

#교수님 정답

t.left(45)
t.forward(141)
t.goto(0, 0)
t.setheading(0)
t.forward(100)
t.left(90)
t.forward(100)

 

#8.ch3 ex6
import time
fseconds = time.time()
print("current time (creenwich time,uk):",((fseconds//60)//60)%24,"o'clock", (fseconds//60)%60,"minutes")
#9.ch3 ex7
weight = int(input("Enter the weight of the object:"))
speed = int(input("Enter the object's speed m/s:"))
energy = 1/2*weight*speed**2
print("The object has", energy,"of energy")

 

#10. ch4 ex6
lst = []
a= int(input("Enter the number:"))
lst.append(a)
b= int(input("Enter the number:"))
lst.append(b)

c= int(input("Enter the number:"))
lst.append(c)

d= int(input("Enter the number:"))
lst.append(d)

print("list=",lst)
print(sum(lst))

그외 내가 모르는 것

import turtle
t=turtle.Turtle()
t.shape("turtle")
s= turtle.textinput("","enter your name:")
t.write("hello?dr"+s+", i'm turtle")
t.left(90)
t.forward(100)
t.left(90)
t.forward(100)
t.left(90)
t.forward(100)
t.left(90)
t.forward(100)
#lab ch4 2050년 나는 몇살일까?
import time
now = time.time()
thisyear = int((1970+now)//(365*24*3600))
print("this year is "+str(thisyear)+".")
age = int(input("how old are you?"))
print("in 2050, you will be "+ str(age+2050-thisyear))
#더 큰 수 작은수
print("larger number: ", max(p,q))
print("smaller number: ", min(p,q))
#리스트에 넣고 좌표값 소환
import turtle
t=turtle.Turtle()
t.shape("turtle")

list=[]

number=int(input("x1: "))
list.append(number)

number=int(input("y1: "))
list.append(number)

number=int(input("x2: "))
list.append(number)

number=int(input("y2: "))
list.append(number)

number=int(input("x3: "))
list.append(number)

number=int(input("y3: "))
list.append(number)

t.goto(list[2], list[3])
t.goto(list[4], list[5])
string1 = input("Please enter the symbol: ")
string2 = input("Please enter the string to be inserted in the middle: ")

string_length = len(string1)

if len(string1) % 2 == 0:
    string3 = string1[0:int(string_length/2)] + string2 + string1[int(string_length/2):]
print(string3)
import turtle
t=turtle.Turtle()
t.shape("turtle")

color1=input("Enter the color#1: ")

color2=input("Enter the color#2: ")

color3=input("Enter the color#3: ")

t.fillcolor(color1)
t.begin_fill()
t.circle(50)
t.end_fill()
t.up()

t.forward(100)
t.fillcolor(color2)
t.begin_fill()
t.down()
t.circle(50)
t.end_fill()
t.up()

t.forward(100)
t.fillcolor(color3)
t.begin_fill()
t.down()
t.circle(50)
t.end_fill()

'학교수업 > 불교파이썬' 카테고리의 다른 글

9주차 e-learning  (0) 2022.05.02
4월 26일 수업  (0) 2022.04.26