python_test_1.py

Created by mrpiay

Created on November 30, 2020

716 Bytes


#Introduction to Python

from turtle import *
from random import *

def draw_pol(sides,length):
  for n in range(sides):
    forward(length)
    left(360/sides)

def enter_pol():
  print("Sides:")
  your_sides=int(input())
  print("Length:")
  your_length=int(input())
  draw_pol(your_sides,your_length)
  
def enter_key():
  secret_key=randint(1,3)
  your_key=-1
  while your_key!=secret_key:
    print("Enter the secret key:")
    your_key=int(input())
    check_value(your_key,1,3)

def check_value(val,min_val,max_val):
  if val<min_val or val>max_val:
    print("Invalid value!")

def start_prog():
  print("Hello!")
  enter_key()
  enter_pol()
  print("Bye!")

start_prog()

#end of script

During your visit to our site, NumWorks needs to install "cookies" or use other technologies to collect data about you in order to:

With the exception of Cookies essential to the operation of the site, NumWorks leaves you the choice: you can accept Cookies for audience measurement by clicking on the "Accept and continue" button, or refuse these Cookies by clicking on the "Continue without accepting" button or by continuing your browsing. You can update your choice at any time by clicking on the link "Manage my cookies" at the bottom of the page. For more information, please consult our cookies policy.