Esempio n. 1
1
import turtle
t = turtle.Pen()
number = int(turtle.numinput("변 또는 동그라미의 수",
             "변 또는 동그라미의 수를 입력해 주세요:",6))
shape = turtle.textinput("어떤 모양을 원하십니까?",
                         "p는 세모,r는 동그라미:")
for x in range(number):
    if shape == 'r':
        t.circle(100)
    else:
        t.forward(150)
    t.left(360/number)

Esempio n. 2
0
def demanderLongueur():
    try:
        cote = int(turtle.textinput("Longeurs","Entrez une longueur en px qui constitura la taille de votre carré, tapez q pour quitter"))
        return cote
    except ValueError:
        print("Vous n'avez pas entré un nombre. Je quitte.")
        turtle.bye()
        sys.exit()
Esempio n. 3
0
def on_right():
    val = t.textinput('Right', "How much: ")
    if val:
        try:
            val = int(val)
            t.right(val)
        except ValueError:
            messagebox.showinfo('Error', 'Wrong value')
    t.listen()
Esempio n. 4
0
def on_forward():
    val = t.textinput('Forward', "How much: ")
    if val:
        try:
            val = int(val)
            t.forward(val)
        except ValueError:
            messagebox.showinfo('Error', 'Wrong value')
    t.listen()
Esempio n. 5
0
def playername():
    global highscorelist
    #får navn fra spiller og legger det til i highscore listen
    #returnerer spillernavn

    player =  turtle.textinput("player", "input your name")
    highscorelist[player] = 0
    #putter spiller in i player for å bruke den etterpå
    spiller = player
    return player
Esempio n. 6
0
 def __init__(self):
     tess = self.tess
     tess.degrees()
     tess.speed(1)
     tess.shape(CHAR)
     tess.shapesize(10, 10)
     tess.penup()
     while(self.name == ""):
         self.name = turtle.textinput("Name", "Type in your name")
     tess.write("Welcome, "+self.name, True, align="right", font=("Arial", 13, "bold"))
     tess.goto(0,0)
     time.sleep(1)
     tess.clear()
     
     wn.onkey(self.dig, "e")
     wn.onclick(self.go, btn=1, add=True)
     wn.onclick(self.cut, btn=3)
     wn.listen()
import turtle
t = turtle.Turtle()
t.shape("turtle")


s = turtle.textinput("??","입력하십시오")
n=int(s)


for i in range(n):
    t.forward(50)
    t.left(360/n)




Esempio n. 8
0
    m=gen_matr()
    t.pd()
    for k in path[d]:
        t.goto(m[k])
    t.pu()
    t.goto(m[1])    
    
    



t=turtle.Turtle()
t.pu()
t.bk(300)
t.pd()
s=30
x=turtle.textinput('Draw Digit','Enter number:')

if not x.isdigit():
    raise (ValueError("Bad Input"))
for c in x:
    write(t,c,s)
    t.fd(1.2*s)
    
turtle.done()    


    


Esempio n. 9
0
    t1.penup
    t1.setpos(-x,-y)
    t1.pendown()

    for s in range(size):
        t1.forward(s*2)
        t1.left(91)
        t1.penup()
        t1.setpos(x,-y)
        t1.pendown()
    for s in range(size):
        t1.forward(s*2)
        t1.left(91)
colors=["yellow","orange"]
family=[]
name=turtle.textinput("Eat", "
                      :")
                     
                     
while name !=" ":
    family.append(name)
    name=turtle.textinput("Yummy!","Bonus", "
                          :")
                         
for n in range(100):
    t1.pencolors(colors[n%len(family)])
    t1.penup()
    t1.forward(n*4)
    t1.pendown()
    t1.wrtie(family[n%len(family)])
    t1.left(360/len(family) + 2)
Esempio n. 10
0
    gotoxy(base_x + math.sin(phi_rad) * R, base_y + math.cos(phi_rad) * R + 60)
    draw_circle(22, 'yellow')

    return i % 7


turtle.speed(0)

draw_pistol(50, 20)

answer = ''
start = 0

while answer != 'n':
    answer = turtle.textinput('Проверим твою удачу?', 'y/n')

    if answer == 'y':
        start = rotate_pistol(50, 20, start)

        if start == 0:
            phi_rad = PHI * 0 * math.pi / 180.0
            gotoxy(50 + math.sin(phi_rad) * R, 20 + math.cos(phi_rad) * R + 60)
            draw_circle(22, 'red')
            gotoxy(-150, 250)
            turtle.write('В твоей голове новая дырка. Прощай неудачник!',
                         font=('Arial', 18, 'normal'))

    else:
        pass
Esempio n. 11
0
import turtle
pen = turtle.Pen()
turtle.bgcolor("black")
pen_color = "green"
pen.pencolor(pen_color)
pen.penup()
pen.forward(-300)
pen.pendown()
nam = "mathHomwork.py"
x = int((250 + 4) / 4)
pen.write(nam, font = ("Arial", x, "bold"))
problem = turtle.textinput("Enter a math problem","Enter a math problem, or 'q' to quit:   ")
while (problem != "q"):
    print("The answer to", problem,"is:", eval(problem))
    problem = turtle.textinput("Enter a math problem","Enter a math problem, or 'q' to quit:   ")

Esempio n. 12
0
import turtle
from math import sin, cos, pi, radians

R = int(turtle.textinput("Введите радиус: ", "Введите радиус: "))

turtle.left(90)
for i in range(10):
    turtle.circle(-R, 180)
    turtle.circle(-5, 180)
Esempio n. 13
0
import turtle
t = turtle.Pen()
turtle.bgcolor("black")
colors = [
    "red", "yellow", "blue", "green", "orange", "purple", "white", "brown",
    "gray", "pink"
]
family = []
name = turtle.textinput("My family", "Enter a name, or just [ENTER] to end:")
while name != "":
    family.append(name)
    name = turtle.textinput("My family",
                            "Enter a name, or just [ENTER] to end:")
for x in range(100):
    t.pencolor(colors[x % len(family)])
    t.penup()
    t.forward(x * 4)
    t.pendown()
    t.write(family[x % len(family)], font=("Arial", int((x + 4) / 4), "bold"))
    t.left(360 / len(family) + 2)
# CircleSpiralInput.py - Challenge Problem
import turtle   # set up turtle graphics
t=turtle.Pen()
t.speed(0)
turtle.bgcolor('black')
# Set up a list of any 8 valid Python color names
colors=['red', 'yellow', 'blue', 'green',
        'orange', 'purple', 'white', 'gray']
# Ask the user for the number of sides, between 1 and 8, default of 4
sides = int(turtle.numinput("Number of circles",
your_name = turtle.textinput("Enter your name", "What is your name?")                            "How many circles do you want (1-8)?", 4, 1, 8))
# Draw a colorful spiral with the user-specified number of circles
for x in range(180):
    t.pencolor(colors[x % sides])   # only use the right number of colors
    t.circle(x)                     
    t.left(360 / sides + 1)         # turn 360 degrees / # of sides, plus 1
    t.width(x * sides / 200)        # make the pen larger as it goes outward
    
Esempio n. 15
0
    t.left(60)
    t.forward(size)
    for i in range(2):
        t.right(120)
        t.forward(size)
    t.right(180)


def circle(step):
    # turtle.colormode(255)
    # t.begin_fill()
    for i in range(361):
        # t.color([random.randint(0, 255), random.randint(0, 255), random.randint(0, 255)])
        t.left(1)
        t.forward(step)
    # t.end_fill()


for c in ['red', 'green', 'yellow', 'blue', 'orange', 'purple', 'pink', 'navy']:
    t.color(c)
    t.forward(50)
    t.left(45)
t.color('red')
t.forward(100)
square(100)
t.color('navy')
triangle(50)
# circle(2)
turtle.textinput("NIM", "Name of first player:")
turtle.mainloop()
Esempio n. 16
0
import turtle
t = turtle.Turtle()
t.shape("turtle")

shape = str(turtle.textinput("","도형을 입력하시오."))

if shape == '사각형':
    width = int(turtle.textinput("","가로"))
    height = int(turtle.textinput("","세로"))
    t.forward(width)
    t.left(90)
    t.forward(height)
    t.left(90)
    t.forward(width)
    t.left(90)
    t.forward(height)
elif shape == '삼각형':
    length = int(turtle.textinput("","한 변의 길이"))
    t.forward(length)
    t.left(120)
    t.forward(length)
    t.left(120)
    t.forward(length)
else:
    radius = int(turtle.textinput("","반지름"))
    t.circle(radius)
Esempio n. 17
0
# RosetteGoneWild.py
import random
import turtle
t = turtle.Pen()
turtle.bgcolor('black')
t.speed(0)
t.width(3)
# Ask the user for the number of circles in their rosette, default to 6
listofcolors=[]

default_colors= turtle.textinput("Default colors", "Do you want to use the default colors (Y/N)?")

if default_colors=='Y':
    listofcolors=["green","blue","orange","purple","red","yellow"]
    numberofcolors=6
    
if default_colors=='N':
    numberofcolors= int(turtle.textinput("number of colors", " How many colors do you want"))
    for color in range (numberofcolors):
        tmpcolor= turtle.textinput("color", "What is the color #" + str(color+1))
        listofcolors.append(tmpcolor)                

number_of_circles = int(turtle.numinput("Number of circles", "How many circles in your rosette?", 6))
#c1 = turtle.textinput("first color", "what is the first color ")
#c2 = turtle.textinput("second color","what is the second color ",)
    
for x in range(number_of_circles):
    r = random.randint(0,numberofcolors-1)
    t.pencolor(listofcolors[r])
    
    t.circle(100)
Esempio n. 18
0
draw_line(-100, -10, -100, -50)

draw_line(-100, -10, -120, -20)
draw_line(-100, -10, -80, -20)

draw_line(-100, -50, -120, -60)
draw_line(-100, -50, -80, -60)


# from tkinter import SimpleDialog
# SimpleDialog.textinput()



answer = turtle.textinput("Играть?", "y/n")

if answer == 'n':
    sys.exit()

try_count = 0

while True:
    number = turtle.numinput("Угадайте", "Число", 0, 0, 100)

    if number == x:
        turtle.color('green')
        gotoxy(-150, 200)
        turtle.write("Ура! Вы победили!", 
                font=("Arial", 28, "normal"))
        break
Esempio n. 19
0
def new_game():

    """
    This method will set up a game of simon says.
    It requires a helper function "show_circle()", which
    draws the pattern as it gets larger.
    """

    # Stores the colors for the circles
    simon_colors = ["blue", "green", "red", "yellow"]
    scores_turtle = turtle.Turtle()

    try:
        with open("scores.txt", "rb") as myFile:  # Open file and store data in dictionary
            scores = pickle.load(myFile)
    except EOFError:  # If empty file give empty dictionary
        scores = {}

    shape_turtle = turtle.Turtle()  # Turtle that draws the circles

    while True:
        # Clears screen before each new game
        turtle.clearscreen()
        turtle.clear()
        turtle.reset()
        scores_turtle.clear()
        scores_turtle.reset()
        scores_turtle.hideturtle()

        # Prompts user to enter his/her name
        name = turtle.textinput("Simon Says game", "Enter your name and then press OK:")

        # Displays start screen instructions
        turtle.write("Hello " + name + " and welcome to Simon Says!\n\nA series of circles will"
        " be displayed on the screen.\nYour task, should you choose to accept, is to guess the pattern.\nEnter your guess in the text box."
        "\n\n(ex: if the pattern is blue red, enter br)\n\nHave fun!\n\n", align="center", font=("Arial", 14, "bold"))

        # Waits for 1 second so user can read instructions
        time.sleep(1)

        # User can enter anything here to start game
        # Game will only end here if the user clicks cancel
        instructions_input = turtle.textinput("Ready to play?", "Press OK to continue.")

        # Clears screen once user hits OK button
        if instructions_input.strip() == "":
            turtle.clear()
        else:
            turtle.clear()

        correct = True  # Checks if the answer is correct
        score = 0  # Stores user score
        answer = []  # Stores the correct answer pattern with each color
        answer_string = ""   # Stores the correct answer pattern with each starting letter

        # Keeps going while the answer is correct
        while correct:
            rand = random.randint(0, 3)  # Random number to generate a random color
            answer.append(simon_colors[rand])  # Adds the color to the answer list
            answer_string += answer[score][0]  # Adds the first letter of each color to answer_string

            # Draws the sequence of circles
            for i in range(0, len(answer)):
                show_circle(shape_turtle, [answer[i]])

                # Decreases sleep time as score goes up, stops at .3 seconds
                if score == 0:
                    time.sleep(1.5)
                elif score < 10:
                    time.sleep(1.5 - ((score + 1) * .1))
                else:
                    time.sleep(.3)

                shape_turtle.hideturtle()
                shape_turtle.clear()

            # Prompt user to guess
            user_guess = turtle.textinput("Answer", "Enter your guess:")
            user_guess = user_guess.strip().lower()  # Remove unnecessary white spaces and convert to lower case

            # If answer is not equal to the answer_string, stops game
            if user_guess != answer_string:
                correct = False
                scores[name] = score
                sorted_scores = sorted(scores.items(), key=operator.itemgetter(1))
                turtle.write("TOP SCORES\n\n", align="center", font=("Arial", 14, "bold"))
                for key, val in sorted_scores:
                    scores_turtle.write("\n")
                    scores_turtle.write(str(key) + ".    " + str(val), align="center", font=("Arial", 10))

            # Adds to user score each round they get one correct
            else:
                score += 1

        # Asks user if he/she wants to play again
        if not correct:
            continue_option = turtle.textinput("GAME OVER!", "Press OK to play again. Enter q and hit OK to quit:")
        # User quits the game
        if continue_option.strip() == "q" or continue_option.strip() == "Q":
            break
Esempio n. 20
0
import turtle # 기본준비과정
t = turtle.Pen()
turtle.bgcolor("black")
colors = ["red","yellow","blue","green","orange",
          "purple","white","brown","gray","pink" ]
family = []  # 빈 리스트 준비하기
name = turtle.textinput("나의 가족",
                        "이름을 적거나[ENTER]를 눌러서 나간다:")

while name != "":
    family.append(name)
    name = turtle.textinput("나의 가족",
                            "이름을 적거나[ENTER]를 눌러서 나간다:")

for x in range(100):
    t.pencolor(colors[x % len(family)])
    t.penup()
    t.forward(x*4)
    t.pendown()
    t.write(family[x%len(family)],font = ("Arial",int((x+4)/4),"bold"))
    t.left(360/len(family) + 2)

input("")
Esempio n. 21
0
    if (pos1 + 50) <= (x1) <= (pos1 + 150) and (pos2 + 50) <= (y1) <= (pos2 + 150):     #Turtle is in the small square
        Beans.write("You are in!")
        points += 2     #Add 2 points
        SCORE(points)
        
    elif (pos1 <= (x1) <= (pos1 + 200)) and (pos2 <= (y1) <= (pos2 + 200)):       #Used to see if the turtle is within the square
        Beans.write("Almost there!")
        points += 1     #Add a point
        SCORE(points)
        
    else:       #Turtle did not make it into or onto a square
        Beans.write("We missed you!")
        points -= 1     #Subtract a point
        SCORE(points)
    
    ans = turtle.textinput("Input", "Do you want to play again? Yes or No: ")   #Loop statement so user can play again
    if ans.lower() in ("yes"):
        Beans.reset()   #Clears the turtle drawings so it can go again on a clean slate
        
        start = 1   #Completes the loop
    else:       #Else clears everything but the score and says game over and leaves score in upper left hand corner
        Beans.reset()
        Beans.color("black")
        Beans.write("Game Over!", move=False, align="center", font=("Arial", 54, "normal"))     #This is to center the Text and make it large enough to properly read that the game is over on screen
        break
    
#-------------------------

turtle.mainloop()   #Keeps window on screen
    
Esempio n. 22
0
import turtle 
tartaruga = turtle.Turtle()
while True:
    certas = " "
    for letra in pcchoice:
        if letra in acertos:
            certas += letra
        else:
            certas += " "
    letrasacertadas(certas)
    if certas == pcchoice:
        tartaruga.pu()
        tartaruga.setpos(-150,100)
        tartaruga.write("Parabéns, você adivinhou!!", align = "left", font = ("Arial", 14, "bold"))
        break
    chance = turtle.textinput("Jogo da forca", "Chute uma letra:")
    if chance in chutes:
        continue
    else:
        chutes += chance
        letraschutadas(chutes)
        if chance in pcchoice:
            acertos += chance
        else:
            erros += 1
        if chance == "A":
            for i in range (0,len(A)-1):
                if A[i] in pcchoice:
                    acertos += A[i]
        if chance == "E":
            for i in range(0,len(E)-1):
Esempio n. 23
0
import turtle
name = turtle.textinput("name", "what is your name? ")
name = name.lower()
if name.startswith("mr"):
    print("hello sir! how are you?")
elif name.startswith("mrs") or name.startswith("miss") or name.startswith(
        "ms"):
    print("hello mam! how are you?")
else:
    name = name.capitalize()
    str = "Hi!" + name + "! how are you?"
    print(str)

turtle.exitonclick()
Esempio n. 24
0
##turtle을 움직이며 위치에 따른 학점을 출력한다.
t.goto(100,100)
t.write("A학점 입니다.")
t.goto(100,50)
t.write("B학점 입니다.")
t.goto(100,0)
t.write("C학점 입니다.")
t.goto(100,-50)
t.write("D학점 입니다.")
t.goto(100,-100)
t.write("F학점 입니다.")
t.goto(0,0)
t.pendown() #turtle의 움직임을 선으로 출력하도록 설정


##turtlr그래픽으로 점수를 입력하게 한다.
score = int(turtle.textinput("", "성적을 입력하시오"))

##입력받은 정수에 따라 turtle의 위치를 옮겨 학점을 나타낸다.
if score >= 90:
    t.goto(100,100)
elif score >= 80:
    t.goto(100,50)
elif score >= 70:
    t.goto(100,0)
elif score >= 60:
    t.goto(100,-50)
else:
    t.goto(100,-100)
Esempio n. 25
0
import random
import turtle
import time
bgcolor = turtle.textinput("offconsole", "Your BG for today: ")
color = turtle.textinput("offconsole", "Your favourite color: ")
t = turtle.Pen()
turtle.bgcolor(bgcolor)
t.pencolor(color)
a = ''
b = ''
c = ''
d = 0
e = 0
f = 0
cmd = '0'
z = 0
newgroup = ''
t.clear()
t.write("Welcome to offconsole! Read document with comands before use.")
time.sleep(3)
t.clear()
while cmd != 'stop':
    cmd = turtle.textinput("offconsole", "Your command:")
    if cmd == "write":
        yourgroup = turtle.textinput("offconsole", "Select group(a, b or c): ")
        yourtext = turtle.textinput("offconsole", "Text: ")
        if yourgroup == "a":
            a += yourtext
        elif yourgroup == "b":
            b += yourtext
        else:
Esempio n. 26
0
import turtle
t = turtle.Turtle()
t.shape("turtle")
t.penup()
t.goto(100,100)
t.write("거북이가 여기로 오면 양수입니다.")
t.goto(100,0)
t.write("거북이가 여기로 오면 0입니다.")
t.goto(100,-100)
t.write("거북이가 여기로 오면 음수입니다.")
t.goto(0,0)
t.pendown()


num =int(turtle.textinput("","정수를 입력하시오"))

if num>=0:
    if num==0:
        t.goto(100,0)
    else:
        t.goto(100,100)
else:
    t.goto(100,-100)
   
Esempio n. 27
0
#1.
import turtle
t = turtle.Turtle()
t.shape("turtle")

t.penup()
t.goto(100, 100)
t.write("거북이가 여기로 오면 양수입니다")
t.goto(100, 0)
t.write("거북이가 여기로 오면 0입니다")
t.goto(100, -100)
t.write('거북이가 여기로 오면 음수입니다.')

t.goto(0, 0)
t.pendown()
s = turtle.textinput("", "숫자를 입력하시오: ")
n = int(s)
if (n > 0):
    t.goto(100, 100)
if (n == 0):
    t.goto(100, 0)
if (n < 0):
    t.goto(100, -100)

#2.
age = int(input('나이를 입력하시오: '))
if (age >= 15):
    print('이 영화를 보실 수 있습니다')
else:
    print('이 영화를 보실 수 없습니다')
Esempio n. 28
0
##함수를 이용하여 터틀그래픽이 회전하며 도형을 그리도록 하는 프로그램

#터틀그래픽을 실행시킨다.
import turtle
t=turtle.Turtle()
t.shape("turtle")

#polygon함수를 정의하여 도형을 그리며 회전하도록 한다.
def polygon(n):
    for i in range(1,n+1,1):
        t.forward(80)
        t.left(360/n)

#사용자로부터 도형의 모양을 입력받는다.
n=int(turtle.textinput("","몇각형인가요?"))

#반복문을 이용하여 도형을 그린다.
for i in range(18):
    polygon(n)
    t.left(360/18)
 turtle.register_shape(imagePath + 'deck.gif')
 playerHand = turtle.Turtle(imagePath + 'deck.gif', visible=False)
 playerHand.pu()    
 playerHand.setposition(-150,0)
 playerHand.showturtle()
 
 if playerScore < 21 and dealerScore < 21:
     # used for dealing new cards
     playerHit = True
     dealerHit = False
     
     bet = (turtle.numinput('Bet','Enter your bet? ($1-$'+str(playerMoney)+')'
     ,minval=1, maxval=playerMoney))
     
     while playerHit:
         hit = (turtle.textinput('Hit','Hit or stay (h/s)?'))
         hit = hit.lower()
         
         if hit == 'h' and playerScore < 21:
             # adds a card to the hand and calculates score
             a.addCard(p.hand)
             playerScore = getScore(p.hand,playerScore)
             
             for i in p.hand:
                 if i[0] == 'A' and playerScore >= 21:
                     playerScore -= 10
             
             # creates new card
             turtle.register_shape(a.images[p.hand[-1]])
             playerHand = turtle.Turtle(a.images[p.hand[-1]], visible=False)
             playerHand.pu()  
Esempio n. 30
0
import turtle
t = turtle.Pen()
turtle.bgcolor("black")
colors = ["yellow", "red", "green", "blue", "orange", "white", "pink", "brown"]
name = turtle.textinput("input", "Enter a name or hit [Enter] to quit: ")
myFamily = []
while name != "":
    myFamily.append(name)
    #下面这句容易漏掉
    name = turtle.textinput("input", "Enter a name or hit [Enter] to quit: ")

#Draw the spiral
for x in range(40):
    lenFamily = len(myFamily)
    t.pencolor(colors[x % lenFamily])
    t.penup()
    t.forward(x * 5)
    t.pendown()

    #t.write(myFamily[x%lenFamily])--字体等大,螺旋效果需要把字体逐渐变大
    t.write(myFamily[x % lenFamily], font=("Arial", int((x + 20) / 4), 'bold'))
    #t.left(360/lenFamily)
    t.left(360 / lenFamily + 2)
Esempio n. 31
0

turtle.speed(0)
answer = 'y'
x_init = 0
y_init = 0
R = 50
r = 22
angle = 360 / 7
gotoxy(0, 0)
draw_circle(80, 'white')
gotoxy(0, 160)
draw_circle(5, 'red')

while answer not in ['N', 'n']:
    answer = turtle.textinput("Continue? ", "Y/N")
    if answer == 'y':
        for i in range(0, random.randrange(7, 100)):
            angle_rad = angle * i * math.pi / 180
            x_curr = R * math.sin(angle_rad)
            y_curr = R * math.cos(angle_rad)
            gotoxy(x_init + x_curr, y_init + y_curr + 60)
            draw_circle(r, 'red')
            draw_circle(r, 'white')

        gotoxy(x_init + x_curr, y_init + y_curr + 60)
        draw_circle(r, 'brown')

    else:
        pass
Esempio n. 32
0
a = range(10)  #a=0~9

b = range(2, 10, 2)  # b = 2,4,6,8,10  2부터 9까지 2씩 증가.

for i in range(2, 10, 2):
    print(i)

a = int(input("그릴 원의 개수를 입력하시오: "))
deg = 360 / a

for i in range(a):
    t.circle(100)
    t.right(deg)

A = [1, 5, 4, 3, 2]

for pknu in A:
    print(pknu)

# 정삼각형 그리기
for i in range(3):
    t.forward(100)
    t.left(360 / 3)

c = int(turtle.textinput("", "변의 개수를 입력하세요: "))
deg = int(360 / c)

for i in range(c):
    t.forward(100)
    t.left(deg)
Esempio n. 33
0
import turtle

turtle.bgcolor("black")
colors = ["blue", "yellow", "green", "red", "pink", "white"]

words = []
word = turtle.textinput("表白", "输入你想说的话或enter退出:")
while word != '':
    words.append(word)
    word = turtle.textinput("表白", "输入你想说的话或enter退出:")

for x in range(100):
    turtle.pencolor(colors[x % len(words)])
    turtle.penup()
    turtle.forward(x * 4)
    turtle.pendown()
    turtle.write(words[x % len(words)], font=("Arial", int((x + 4) / 4)))
    turtle.left(360 / len(words) + 2)
Esempio n. 34
0
    t.color("blue")
    t.pensize(2)        # 1 - 10 (I think)
    t.hideturtle()      # do not show turtle
    t.showturtle()      # show turtle
    t.shape("turtle")   # turtle shape (turtle, circle, etc.)
    t.speed(0)          # 0 - 10 scale, 0 is fastest
    return t


""" make the canvas and turtle """
wn = make_window()
tess = TurtleGTX()
tess.forward(50)
tess.jump(50)
print(tess.odometer)
a = turtle.textinput("Turtle command:", "What next?")

""" turtle movement """
# tess.penup()            # lift the pen so no line is drawn
# tess.pendown()          # lower the pen so a line is drawn
# tess.begin_fill()       # denotes the beginning of a fill area
# tess.end_fill()         # denotes end of fill area
# tess.goto(100, 100)     # goto x and y cooridnates
# tess.forward(100)       # go forward 100
# tess.backward(100)      # go backward 100
# tess.forward(-100)      # go backward 100
# tess.left(90)
# tess.right(90)
# tess.left(-90)
# tess.circle(40, 180)    # make a circle
Esempio n. 35
0
import turtle
t = turtle.Turtle()
t.shape("turtle")
t.speed(3)

#정수를 받기 전에 조건을 설정
t.up() #거북이가 그려지지 않게함
t.goto(100, 100)
t.write("거북이가 여기로 오면 양수입니다.")
t.goto(100, 0)
t.write("거북이가 여기로 오면 0입니다.")
t.goto(100, -100)
t.write("거북이가 여기로 오면 음수입니다.")

t.goto(0,0)
t.down()

num = int(turtle.textinput("", "정수를 입력해주세요")) #textinput 함수는 prompt와 출력 문자열을 필수 인자로 받는다
if num > 0 :
    t.goto(100,100)
elif num == 0 :
    t.goto(100,0)
else :
    t.goto(100, -100)

turtle.exitonclick()
Esempio n. 36
0
import turtle #터틀그래픽을 실행시킨다.
t=turtle.Turtle() #t를 선언하여 원할한 코딩을 이룬다.
t.shape("turtle") #움직이는 물체의 모양을 거북이로 바꾼다.
s = turtle.textinput("","이름을 입력하시오 : ") #사용자로부터 이름을 입력받는다.
t.write("안녕하세요? 터틀 인사드립니다.") #거북이에게서 문자를 출력시킨다.
t.forward(100)
t.right(90)
t.forward(100)
t.right(90)
t.forward(100)
t.right(90)
t.forward(100)
    #global title
    #title.clear()
    #title.write(y, move=False, align="center", font=("Comic Sans Ms", 60, "normal"))
    time.sleep(3)
    quit()


cleared_stamps = []
stamps = [
    stamp1, stamp2, stamp3, stamp4, stamp5, stamp6, stamp7, stamp8, stamp9
]
#turtles = [spliting1,spliting2,spliting3,spliting4,spliting5,spliting6,spliting7,spliting8,spliting9]
p = -280

for i in range(len(ques_list)):
    ans = turtle.textinput("Question " + str(i), ques_list[i])
    wrong = 0
    while ans != ans_list[i]:
        wrong += 1
        error.goto(p, -350)
        p += 60
        error.hideturtle()
        stamp10 = error.stamp()
        ans = turtle.textinput("Question " + str(i), ques_list[i])
        if wrong >= 10:
            q()

    choice = random.choice(stamps)
    while choice in cleared_stamps:
        choice = random.choice(stamps)
    if choice not in cleared_stamps:
DesenhaForca()
while True:
    senha=""
    for letra in palavra:
        if letra in acertos:
            senha += letra
        else:
           senha += " "
    LetrasAcertadas(senha)
    if senha == palavra:
        tartaruga.penup()
        tartaruga.setpos(-100,100)
        tartaruga.write("Você Acertou antes de ser Enforcado", align="left", font=("Arial", 15, "bold"))
        break
    tentativa=turtle.textinput("Jogo da Forca", "Digite uma Letra: ").upper().strip()
    if tentativa in digitadas:
        continue
    else:
        digitadas += tentativa
        LetrasDigitadas(digitadas)
        if tentativa in palavra:
            acertos += tentativa
        else:
            erros += 1
        VerificaCaracteresEspeciais(palavra, tentativa, acertos)
    if erros == 1:
        DesenhaBoneco(erros-1)
    if erros == 2:
        DesenhaBoneco(erros-1)
    if erros == 3:
Esempio n. 39
0
#     print("현재 날씨가 화창하징않습니다")

# if(time >= 6) and (time < 9) and sunny:
#     print("종달새가 노래를한다.")
# else:
#     print("종달새가 노래를 하지않는다")

# id =" i love python"
# s = input("아이디를 입력하시오")
# if s == id:
#     print("환영합니다")

# else:
#     print("아이디를 찾을수없습니다")

import turtle
t = turtle.Turtle()
t.shape("turtle")

s =turtle.textinput("", "도형을입력하시오")
if s =="사각형":
    s = turtle.textinput("","가로:")
    w = int(s)
    s = turtle.textinput("","세로")
    h = int(s)
    t.forward(w)
    t.left(90)
    t.forward(h)
    t.left(90)
    t.forward(w)
    t.left(90) t.forward(h)
Esempio n. 40
0
# PolygonOrRosette.py
import turtle
t = turtle.Pen()
# Ask the user for the number of sides or circles, default to 6
number = int(turtle.numinput("Number of sides or circles",
             "How many sides or circles in your shape?", 6))
# Ask the user whether they want a polygon or rosette
shape = turtle.textinput("Which shape do you want?",
                         "Enter 'p' for polygon or 'r' for rosette:")
for x in range(number):
    if shape == 'r':        # User selected rosette
        t.circle(100)
    else:                   # Default to polygon
        t.forward(150)
    t.left(360/number)


Esempio n. 41
0
        # правая нога
        draw_line(-100, -50, -80, -60)


x = random.randint(1, 100)

print('Случайное число: ', x)

turtle.speed(0)
turtle.color('blue')

gotoxy(-200, 250)
turtle.write('Я загадал число \n Попробуй угадать',
             font=('Arial', 18, 'normal'))

answer = turtle.textinput('Хотите поиграть?', 'y/n')
if answer == 'n':
    sys.exit(9)

hints = False
answer = turtle.textinput('Давать подсказки?', 'y/n')
if answer == 'y':
    hints = True

try_count = 0

while True:
    number = turtle.numinput('Попробуй угадать', 'Число', 0, -10, 100)

    if hints:
        gotoxy(100, 200 - try_count * 12)
Esempio n. 42
0
def text_input(env) -> "(title prompt -- s)":
    "Prompts for a string"
    title, prompt = env.stack.popN(2)
    res = turtle.textinput(title.val, prompt.val)
    env.stack.push(Token("lit_string", res if type(res) == str else ""))
Esempio n. 43
0
t.speed(10)

for i in range(200):
    t.fd(i)     # i 만큰 앞으로 이동. 반복할때 마다 선이 길어짐(1씩 증가함으로)
    t.lt(90)
    
--

# 사용자가 입력한 도형 그리기

import turtle as t
t.shape('turtle')
t.pensize(3)    #선굵기를 3으로 한다
t.shapesize(3,3)    #거북이를 3배 확대

n=t.textinput('창제목', '도형을 입력하세요: ') #도형을 입력받는다(문자형태로)

if n =='사각형':   # 직사각형이라면
    w = int(t.textinput('','가로: ')) #w변수에 가로변을 입력받는다(정수형태)
    h = int(t.textinput('','세로: ')) #h변수에 세로변을 입력받는다(정수형태)
    for i in range(2):
        t.fd(w) #가로
        t.lt(90)
        t.fd(h) #세로
        t.lt(90)
elif n=='원':
    size = int(t.textinput('','반지름: '))
    t.circle(size)
elif n=='별':
    size = int(t.textinput('','크기 : '))
    for i in range(5):
# SpiralMyName.py - prints a colorful spiral of the user's name
__author__ = 'Chris'

import turtle           # Set up turtle graphics
t = turtle.Pen()
turtle.bgcolor("black")
colors = ["red", "yellow", "blue", "green"]

# Ask the user's name using turtle's textinput pop-up window
your_name = turtle.textinput("Enter your name", "What is your name?")

# Draw a Spiral of the name on the screen, written 100 times
for x in range(100):
    t.pencolor(colors[x%4]) #Rotate through the four colors
    t.penup()               #Don't draw the regular spiral lines
    t.forward(x*4)          #Just move the turtle on the screen
    t.pendown()             #Write the user's name, bigger each time
    t.write(your_name, font = ("Arial", int((x + 4) / 4), "bold"))
    t.left(92)              #Turn left, just as in our other spirals
Esempio n. 45
0
 def ask(line,var):
     var=turtle.textinput("",line)
Esempio n. 46
0
import turtle
z = input('circle, name or line ')
x = eval(input('angle '))
color = input('PenColor ')
BGcolor = input('BgColor ')
dfg = eval(input('number angle '))
t=turtle.Pen()
t.pencolor(color)
turtle.bgcolor(BGcolor)
if    z == 'name':
    c = turtle.textinput('name','name')
for u in range(360000):
    for r in range(dfg):
        if    z == 'line':
            t.forward(u)
        if  z == 'name' :  
            t.penup()
            t.forward(u*4)
            t.pendown()
            t.write(c, font = ("Arial", int((u+4)/4), "bold"))
        if  z == 'circle':
            t.circle(u*4)
        t.left(x)

Esempio n. 47
0
def anime(start, x, y):
    for i in range(start, random.randrange(7, 100)):
        phi_rad = phi * i * math.pi / 180.0
        gotoxy(x + math.sin(phi_rad) * r, y + math.cos(phi_rad) * r + 60)
        draw_circle(22, "brown")
        draw_circle(22, "white")

    gotoxy(x + math.sin(phi_rad) * r, y + math.cos(phi_rad) * r + 60)
    draw_circle(22, "brown")

    start = i % 7
    if i % 7 == 0:
        gotoxy(-150, 250)
        turtle.write("You lost", font=("Arial", 18, "normal"))
    return start


start = 0

draw_drum(100, -100)

answer = ''
start = 0
while answer != 'n':
    answer = turtle.textinput("Хотите поиграть?", "y/n")
    if answer == 'y':
        start = anime(start, 100, -100)
    else:
        pass
#부호에 따라 거북이를 움직이자!!!!

import turtle

t = turtle.Turtle()
t.shape("turtle")

t.penup()
t.goto(100, 100)
t.write("거북이가 여기로 오면 양수입니다.")
t.goto(100, 0)
t.write("거북이가 여기로 오면 0입니다.")
t.goto(100, -100)
t.write("거북이가 여기로 오면 음수입니다.")

t.goto(0, 0)
t.pendown()
s = turtle.textinput("", "숫자를 입력하시오: ")
n = int(s)

if n > 0:
    t.goto(100, 100)
elif n == 0:
    t.goto(100, 0)
else:
    t.goto(100, -100)
Esempio n. 49
0
import turtle

t = turtle.Turtle()

s = turtle.textinput("", "도형을 입력하세요(사각형, 삼각형, 원)")
v = turtle.textinput("", "세로: ")
h = turtle.textinput("", "가로: ")

v = int(v)
h = int(h)

if s == "사각형":
    t.fd(h)
    t.lt(90)
    t.fd(v)
    t.lt(90)
    t.fd(h)
    t.lt(90)
    t.fd(v)
    t.lt(90)
elif s == "삼각형":
    t.fd(100)
    t.lt(120)
    t.fd(100)
    t.lt(120)
    t.fd(100)
    t.lt(120)
else:
    t.circle(50)
Esempio n. 50
0
    'chartreuse',
    'lime'
]

side_length = 500

turtle.bgcolor("black")  # делаем красоту
turtle.pencolor("white")
turtle.shape("turtle")

turtle.penup()  # прячем чюрюпаху и отбираем у неё карандаш
turtle.hideturtle()

choise = int(
    turtle.textinput(
        "Выбор фигуры",
        "Кол-во углов в фигуре, которая будет заполняться: 3, 4, 5, 6"))
# будет иметь значение после того, как я придумаю что делать с фигурами кроме треугольника

# if choise == 3:  # свич с вводом от пользователя с дефолтом в треугольник
#     apexes = triangle_base()
#     angles = 3
# elif choise == 4:
#     apexes = square_base()
#     angles = 4
# elif choise == 5:
#     side_length = 400
#     apexes = five_angle_base()
#     angles = 5
# elif choise == 6:
#     side_length = 300
Esempio n. 51
0
import tkinter as tk
import turtle
root = tk.Tk()
turtle.color("blue")
turtle.shape("turtle")
turtle.pencolor("blue")
turtle.speed(0)
sides = 6
colors = ["red", "orange", "yellow", "green", "blue", "purple"]
turtle.Screen().bgcolor("black")
your_name = turtle.textinput("Enter your name", "What is your name")
for x in range(0, 200):
    turtle.pencolor(colors[x % sides])
    turtle.penup()
    turtle.forward(((x * 3) / sides) + x + 5)
    turtle.pendown()
    turtle.write(your_name, font=("Comic Sans", int((x + 4) / 4), "bold"))
    turtle.left(360 / sides + 1)
    turtle.width(x * sides / 100)
Esempio n. 52
0
import turtle
t = turtle.Pen()
number = int(
    turtle.numinput("number of sides or circles",
                    "how many sides or circles in your shape?", 6))
shape = turtle.textinput("which shape do you want"
                         "enter 'p' for polygon or 'r' for rosette:")
for x in range(number):
    if shape == 'r':
        t.circle(100)
    else:
        t.forward(150)
    t.left(360 / number)
Esempio n. 53
0
'''
Using turtle to draw regular polygons
prompt user for the number of sides and the color components (r, g, b).
'''
import turtle

# Get the turtle ready in position
turtle.hideturtle()
turtle.up()
turtle.goto(-50, 5)
turtle.shape('turtle')
turtle.title('Labe 02 -- 2017')

# Ask the user for the number of poly's sides
sides = int(turtle.textinput("Lab 02", "The number of sides: "))

# User will input RGB values [0.0 - 1.0]
r = float(turtle.textinput("Lab 02", "Value of red [0.0 - 1.0]"))
g = float(turtle.textinput("Lab 02", "Value of green [0.0 - 1.0]"))
b = float(turtle.textinput("Lab 02", "Value of blue [0.0 - 1.0]"))

turtle.color(r, g, b)       # Assign the user specified color to turtle

deg = 360 / sides	        # Calculate the turn
length = 400 / sides
turtle.showturtle()
turtle.down()
for i in range(sides):
    turtle.forward(length)  # By using loop, turn and
    turtle.left(deg)        # Move the turtle forward
turtle.up()
Esempio n. 54
0
        turtle.write("Бах!", align='center', font=('Ubuntu', 24, 'normal'))
        helper.dupfiles_np('.')
    return sp


sectors = 7
phi = 360 / sectors
r = 50

turtle.speed(0)
turtle.title("Turtle + Python 3.x")

turtle_drawcircle(80, 1, 'white')
turtle_goto(0, 160)
turtle_drawcircle(5, 1, "red")

# Отрисовываем барабан
pistol_draw(0, -80)

answer = ''
start = 0

while answer != ("N" and 'n'):
    answer = turtle.textinput("Черепашка", "Нарисовать окружность?")
    if answer == ("Y" and "y"):
        start = pistol_roll(start)
        print("Рисование окончено")
    elif answer != ('N' and 'n'):
        print("Неверный вариант ответа!")
print("Завершение программы")
Esempio n. 55
0
import turtle
t=turtle.Turtle()
t.shape("turtle")
s=turtle.textinput("","이름을 입력하시오")
t.write("안녕하세요?"+s+"씨, 터틀 인사드립니다")
t.left(90)
t.forward(100)
t.left(90)
t.forward(100)
t.left(90)
t.forward(100)
t.left(90)
t.forward(100)
Esempio n. 56
0
import turtle

t = turtle.Pen()
turtle.bgcolor("black")

r1 = int(turtle.textinput('花瓣半径','请输入花瓣半径'))
num = int(turtle.textinput('输入边数','你想画瓣花?'))
r2 = int(turtle.textinput('花蕊半径','请输入花蕊半径'))
for i in range(num):
    print (i)
    t.pencolor("yellow")
    t.circle(r2)
    t.pencolor('red')
    t.circle(r1)
    t.left(360 / num)
Esempio n. 57
0
# SpiralFamily.py - prints a colorful spiral of names
import turtle     # Set up turtle graphics
t = turtle.Pen()  
turtle.bgcolor("black")
colors = ["red", "yellow", "blue", "green", "orange",
        "purple", "white", "brown", "gray", "pink" ]
family = []       # Set up an empty list for family names
# Ask for the first name
name = turtle.textinput("My family",
                        "Enter a name, or just hit [ENTER] to end:")
# Keep asking for names
while name != "":
    # Add their name to the family list
    family.append(name)
    # Ask for another name, or end
    name = turtle.textinput("My family",
                        "Enter a name, or just hit [ENTER] to end:")
# Draw a spiral of the names on the screen
for x in range(100):
    t.pencolor(colors[x%len(family)]) # Rotate through the colors
    t.penup()                         # Don't draw the regular spiral lines
    t.forward(x*4)                    # Just move the turtle on the screen
    t.pendown()                       # Draw the next family member's name
    t.write(family[x%len(family)], font = ("Arial", int((x+4)/4), "bold") )
    t.left(360/len(family) + 2)         # Turn left for our spiral

import turtle
t = turtle.Turtle()
t.shape("turtle")
t.fd(100)
name = turtle.textinput("제목입력칸 ", "이름을 입력하세요.")
t.write("안녕하세요? " + name + "인데요")
t.left(90)
t.forward(100)
t.left(90)
t.forward(100)
t.left(90)
t.forward(100)
t.left(90)
t.forward(100)
Esempio n. 59
0
for line in sv_coords:
    line = line.strip().split(',')
    nums = []
    for n in line:
        nums.append(int(n))
    sv_coords_list.append(nums)


turtle.color("green")
sv_elements[0]

input("Press any key")


while True:
    answer = turtle.textinput("Играть?", "y/n")
    if answer == "n":
        sys.exit()
    if answer == "y":
        eraser(-375, -75, 250, 250)
        break
    else:
        turtle.textinput("Ошибочка вышла!", "Только 'y' или 'n'")


#Svintus glade to play
gotoxy(-375, -5)
turtle.color("#287233")
turtle.write("Ура! Будем играть! :)", font=("Arial", 20))

# try_count = 0
Esempio n. 60
0
    turtle.forward(200)
    turtle.left(90)
    turtle.penup()
    turtle.goto((x1+50),(y1+50))        #Sends turtle to location to begin second square
    turtle.pendown()
    turtle.pencolor("Red")
    turtle.forward(100)
    turtle.left(90)
    turtle.forward(100)
    turtle.left(90)
    turtle.forward(100)
    turtle.left(90)
    turtle.forward(100)
    turtle.penup()
    x=turtle.numinput("Input","Enter x coordinate")     #Gets user input
    y=turtle.numinput("Input","Enter y coordinate")     #Gets user input
    turtle.goto(x,y)                                    #Sends turtle to user inputed coordinates
    if x >= (x1+50) and x <= (x1+150) and y >= (y1+50) and y <= (y1+150):   #If turtle is in smaller square.
        score = score + 2                                                   #2 points for turtle in smaller square
        turtle.write("  You are in!  Score: %d" %score)
    elif x >= x1 and x <= (x1 + 200) and y >= y1 and y <= (y1 + 200):       #If turtle is in larger square.
        score = score + 1                                                   #1 point for turtle in larger square.
        turtle.write("  Almost there!  Score: %d" %score)
    else:                                                #Turtle not in any square
        score = score - 1                                # - 1 point if turtle not in either square.
        turtle.write("  We missed you!  Score: %d" %score)
    game = turtle.textinput("Player Input", "Would you like to continue? (Y/N)") #Asks user to continue
turtle.clear()                                          #Clears all the squares
turtle.write("  Game Over.  Your Score is %d" %score)   #Gives final score
turtle.mainloop()                                       #Keeps turtle on screen