From 2f5e0c98b85423556c6ad4bff13b4bc583015023 Mon Sep 17 00:00:00 2001 From: pankace <44595774+pankace@users.noreply.github.com> Date: Mon, 2 Oct 2023 10:14:44 +0700 Subject: [PATCH 1/9] this coffeeeeeeeeeeeeeeeeeeeeeeeeee --- 1.py | 72 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 71 insertions(+), 1 deletion(-) diff --git a/1.py b/1.py index fd6cfeb..eb9070d 100644 --- a/1.py +++ b/1.py @@ -29,4 +29,74 @@ 'water': 300, 'milk': 300, 'money': 0, -} \ No newline at end of file +} + + +class Coffee_Machine: + def __init__(self): + self.money = 0 + self.inventory = INVENTORY + self.menu = MENU + self.is_on = True + + def report(self): + print(f"Water: {self.inventory['water']}ml") + print(f"Milk: {self.inventory['milk']}ml") + print(f"Coffee: {self.inventory['coffee']}g") + print(f"Money: ${self.money}") + + def check_resources(self, drink): + for item in self.menu[drink]['ingredients']: + if self.inventory[item] < self.menu[drink]['ingredients'][item]: + print(f"Sorry there is not enough {item}.") + return False + return True + + def clean_input_money(input): + if input.isdigit() == False: + return 0 + else: + return input + + def process_coins(self): + print("Please insert coins.") + total = 0 + total += int(Coffee_Machine.clean_input_money(input("How many quarters?: "))) * 0.25 + total += int(Coffee_Machine.clean_input_money(input("How many dimes?: "))) * 0.1 + total += int(Coffee_Machine.clean_input_money(input("How many nickles?: "))) * 0.05 + total += int(Coffee_Machine.clean_input_money(input("How many pennies?: "))) * 0.01 + return total + + def make_coffee(self, drink): + for item in self.menu[drink]['ingredients']: + self.inventory[item] -= self.menu[drink]['ingredients'][item] + self.money += self.menu[drink]['price'] + print(f"Here is your {drink}. Enjoy!") + + def turn_off(self): + self.is_on = False + + +def __main__(): + coffee_machine = Coffee_Machine() + while coffee_machine.is_on: + choice = input("What would you like? (espresso/latte/flat white): ").lower() + if choice != 'espresso' and choice != 'latte' and choice != 'flat white' and choice != 'off' and choice != 'report': + print('your choise is not valid, please try again') + __main__() + if choice == 'off': + coffee_machine.turn_off() + elif choice == 'report': + coffee_machine.report() + else: + if coffee_machine.check_resources(choice): + payment = coffee_machine.process_coins() + if payment < coffee_machine.menu[choice]['price']: + print("Sorry that's not enough money. Money refunded.") + else: + change = round(payment - coffee_machine.menu[choice]['price'], 2) + print(f"Here is ${change} in change.") + coffee_machine.make_coffee(choice) + + +__main__() \ No newline at end of file From 7158878ac24e30e7c898605a20bb8a1100548c37 Mon Sep 17 00:00:00 2001 From: pankace <44595774+pankace@users.noreply.github.com> Date: Mon, 2 Oct 2023 10:16:34 +0700 Subject: [PATCH 2/9] this coffeeeeeeeeeeeeeeeeeeeeeeeeee --- 1.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/1.py b/1.py index eb9070d..3847ed9 100644 --- a/1.py +++ b/1.py @@ -52,11 +52,11 @@ def check_resources(self, drink): return False return True - def clean_input_money(input): - if input.isdigit() == False: + def clean_input_money(input_): + if input_.isdigit() == False: return 0 else: - return input + return input_ def process_coins(self): print("Please insert coins.") From 625a3f56a2d2018b9187856b6616d4247b157167 Mon Sep 17 00:00:00 2001 From: pankace <44595774+pankace@users.noreply.github.com> Date: Mon, 2 Oct 2023 11:42:48 +0700 Subject: [PATCH 3/9] this coffeeeeeeeeeeeeeeeeeeeeeeeeee --- 2.py | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/2.py b/2.py index bc686dd..8f03cdf 100644 --- a/2.py +++ b/2.py @@ -16,18 +16,30 @@ def send_email(msg, email): """ ... -# Solution goes here +class Patient(object): + def __init__(self, first_name, last_name, title, date, email, phone, mobile_phone): + self.first_name = first_name + self.last_name = last_name + self.title = title + self.date = date + self.email = email + self.phone = phone + self.moble_phone = mobile_phone + + def greeting(self): + return f"Hello, {self.title} {self.last_name}!" + patient1 = Patient( - 'John', - 'Doe', - 'mr.', + "John", + "Doe", + "mr.", datetime(1990, 2, 28), - 'john.doe@gmail.com', - '+3345451555', - '+6693932030', + "john.doe@gmail.com", + "+3345451555", + "+6693932030", ) print(patient1.greeting()) -patient1.send_appointment_reminder(datetime(2023, 10, 13, 13, 0)) +#patient1.send_appointment_reminder(datetime(2023, 10, 13, 13, 0)) From 7b17fea945b525eb6d0c68c010913f30405f91b9 Mon Sep 17 00:00:00 2001 From: pankace <44595774+pankace@users.noreply.github.com> Date: Mon, 2 Oct 2023 11:43:08 +0700 Subject: [PATCH 4/9] toooooooooooooo --- 2.py | 1 + 1 file changed, 1 insertion(+) diff --git a/2.py b/2.py index 8f03cdf..0c8c797 100644 --- a/2.py +++ b/2.py @@ -40,6 +40,7 @@ def greeting(self): "+6693932030", ) + print(patient1.greeting()) #patient1.send_appointment_reminder(datetime(2023, 10, 13, 13, 0)) From 6741931e236ff0cfe7a6791375b2dae563032691 Mon Sep 17 00:00:00 2001 From: pankace <44595774+pankace@users.noreply.github.com> Date: Mon, 2 Oct 2023 12:18:51 +0700 Subject: [PATCH 5/9] dsjfsjkooooooooo --- 2.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/2.py b/2.py index 0c8c797..3157f54 100644 --- a/2.py +++ b/2.py @@ -2,7 +2,7 @@ def send_sms(msg, phone): - """Sends a given message to a given phone via SMS. + """Sends a given message to a given phone number as SMS. You don't have to implement this function. """ @@ -21,14 +21,23 @@ def __init__(self, first_name, last_name, title, date, email, phone, mobile_phon self.first_name = first_name self.last_name = last_name self.title = title - self.date = date + self.age = datetime.now() - date self.email = email self.phone = phone - self.moble_phone = mobile_phone + self.mobile_phone = mobile_phone def greeting(self): return f"Hello, {self.title} {self.last_name}!" + + def send_sms(self, msg): + send_sms(msg, self.mobile_phone) + + def send_email(self, msg): + send_email(msg, self.email) + def send_appointment_reminder(self, time): + send_sms(f"Hi {self.first_name}, you have an appointment tomorrow at {time}.", self.mobile_phone) + send_email(f"Hi {self.first_name}, you have an appointment tomorrow at {time}.", self.email) patient1 = Patient( "John", @@ -43,4 +52,4 @@ def greeting(self): print(patient1.greeting()) -#patient1.send_appointment_reminder(datetime(2023, 10, 13, 13, 0)) +patient1.send_appointment_reminder(datetime(2023, 10, 13, 13, 0)) From 9ea93f0633cc24e23a2e70e1236e3e940284b74d Mon Sep 17 00:00:00 2001 From: pankace <44595774+pankace@users.noreply.github.com> Date: Tue, 3 Oct 2023 09:49:25 +0700 Subject: [PATCH 6/9] dsjfsjkooooooooo --- oop-coffee-machine-start.zip | Bin 0 -> 2083 bytes .../oop-coffee-machine-start/coffee_maker.py | 29 +++++++++++++ .../oop-coffee-machine-start/main.py | 25 +++++++++++ .../oop-coffee-machine-start/menu.py | 34 +++++++++++++++ .../oop-coffee-machine-start/money_machine.py | 39 ++++++++++++++++++ 5 files changed, 127 insertions(+) create mode 100644 oop-coffee-machine-start.zip create mode 100644 oop-coffee-machine-start/oop-coffee-machine-start/coffee_maker.py create mode 100644 oop-coffee-machine-start/oop-coffee-machine-start/main.py create mode 100644 oop-coffee-machine-start/oop-coffee-machine-start/menu.py create mode 100644 oop-coffee-machine-start/oop-coffee-machine-start/money_machine.py diff --git a/oop-coffee-machine-start.zip b/oop-coffee-machine-start.zip new file mode 100644 index 0000000000000000000000000000000000000000..aaaf8fa1de993d642147845bcb3a825bb4ceb2ca GIT binary patch literal 2083 zcma)-4Kx$#AIE35{%k_5kx3D*E+7&ipYL1qW3UyS=;n9|-PK%qTNk&)ZmF$R<1(K*0 z;05rR`c&Gu`B!3L3~EF=V`Y{t4S84TbhFr?R|2rg(9f*};#8<{9>p~q8Ejof4DnN(dWRy za%?p6e5-!s(EYcVN7q7@sTbcasG15EW-sp}btFRQD*fQYQPp6K$Gs zuY&Hn;2Bb=ypMAhaVK+hgg>&evFy$jiH_BDPMT+V4K48Wc>_11E+w{}1x(P;Z`4jigdxGUUc@*b)d zZ`9c>!j*wau)_8(TteP9HAzB}9N^0|4h~EVw8&Uw$ynSv4LXw}OCvkejX7wpnjp1l zi#0~WUl9!3A9dC2h~PnCq)N);qMa5-^|W+-xFBqfod?( zE7(X|n5qVC`Z+ofn4iXg>lPDXYz!ANNg}&(o~v^N>2b2vy2Lve&6D)8cLxRZ@qFtE!Vj)J5$j5qkMYNA z&9q_B?rl*n4h=$6`wv>iAO4$F?RM)w)FqVFNdCjVIXX>hRDVvuzoYE{R_{@CC*9`F zuGu~tCo`YK?*LcDCn^($ks6W$ACjNDbpJy(e)#ZP0PnV()~#CT!KT8 zU)OQt2yy+zy5m|+Ha8r6+WOmAUjo3|br~}&1E4|%!2T^cWHIScGB5gMP%;v(5*WcU z64q~1LX)0lpix0oiqe2)Q31Egc!Fd^)70e$8)R0RVL0fjoL~Vhr&K2 z#gn1lq_OoYDZXFxG@yGAH4e_0{vg`(Ep&SO)FUzFVdko6)UI0m z$kUFmmy)a`_*_f5!q}6A9cP_Q-@Mni9f)V?5s9mFW(%k+-E^+9H^di7qCzT*Rtel&hOu?nWLM-QXx;2(%?0!KItyO`RR?b%_$jC zev>Adj-EfI$E*nrp<2X(R%>f}rhGAN_^9yZzTT=`ex>2oIa2$=vaxfVtO3eP11*Vq zy=`eVd))g~!wHQk#tQmo< self.resources[item]: + print(f"Sorry there is not enough {item}.") + can_make = False + return can_make + + def make_coffee(self, order): + """Deducts the required ingredients from the resources.""" + for item in order.ingredients: + self.resources[item] -= order.ingredients[item] + print(f"Here is your {order.name} ☕️. Enjoy!") diff --git a/oop-coffee-machine-start/oop-coffee-machine-start/main.py b/oop-coffee-machine-start/oop-coffee-machine-start/main.py new file mode 100644 index 0000000..3101ffc --- /dev/null +++ b/oop-coffee-machine-start/oop-coffee-machine-start/main.py @@ -0,0 +1,25 @@ +from menu import Menu, MenuItem +from coffee_maker import CoffeeMaker +from money_machine import MoneyMachine + +def __main__(): + coffee_maker = CoffeeMaker() + menu = Menu() + money_machine = MoneyMachine() + is_on = True + + while is_on: + options = menu.get_items() + choice = input(f"What would you like? ({options}): ") + if choice == "off": + is_on = False + elif choice == "report": + coffee_maker.report() + money_machine.report() + else: + drink = menu.find_drink(choice) + if coffee_maker.is_resource_sufficient(drink) and money_machine.make_payment(drink.cost): + coffee_maker.make_coffee(drink) + +if __name__ == "__main__": + __main__() \ No newline at end of file diff --git a/oop-coffee-machine-start/oop-coffee-machine-start/menu.py b/oop-coffee-machine-start/oop-coffee-machine-start/menu.py new file mode 100644 index 0000000..549d5b4 --- /dev/null +++ b/oop-coffee-machine-start/oop-coffee-machine-start/menu.py @@ -0,0 +1,34 @@ +class MenuItem: + """Models each Menu Item.""" + def __init__(self, name, water, milk, coffee, cost): + self.name = name + self.cost = cost + self.ingredients = { + "water": water, + "milk": milk, + "coffee": coffee + } + + +class Menu: + """Models the Menu with drinks.""" + def __init__(self): + self.menu = [ + MenuItem(name="latte", water=200, milk=150, coffee=24, cost=2.5), + MenuItem(name="espresso", water=50, milk=0, coffee=18, cost=1.5), + MenuItem(name="cappuccino", water=250, milk=50, coffee=24, cost=3), + ] + + def get_items(self): + """Returns all the names of the available menu items""" + options = "" + for item in self.menu: + options += f"{item.name}/" + return options + + def find_drink(self, order_name): + """Searches the menu for a particular drink by name. Returns that item if it exists, otherwise returns None""" + for item in self.menu: + if item.name == order_name: + return item + print("Sorry that item is not available.") diff --git a/oop-coffee-machine-start/oop-coffee-machine-start/money_machine.py b/oop-coffee-machine-start/oop-coffee-machine-start/money_machine.py new file mode 100644 index 0000000..09ca70a --- /dev/null +++ b/oop-coffee-machine-start/oop-coffee-machine-start/money_machine.py @@ -0,0 +1,39 @@ +class MoneyMachine: + + CURRENCY = "$" + + COIN_VALUES = { + "quarters": 0.25, + "dimes": 0.10, + "nickles": 0.05, + "pennies": 0.01 + } + + def __init__(self): + self.profit = 0 + self.money_received = 0 + + def report(self): + """Prints the current profit""" + print(f"Money: {self.CURRENCY}{self.profit}") + + def process_coins(self): + """Returns the total calculated from coins inserted.""" + print("Please insert coins.") + for coin in self.COIN_VALUES: + self.money_received += int(input(f"How many {coin}?: ")) * self.COIN_VALUES[coin] + return self.money_received + + def make_payment(self, cost): + """Returns True when payment is accepted, or False if insufficient.""" + self.process_coins() + if self.money_received >= cost: + change = round(self.money_received - cost, 2) + print(f"Here is {self.CURRENCY}{change} in change.") + self.profit += cost + self.money_received = 0 + return True + else: + print("Sorry that's not enough money. Money refunded.") + self.money_received = 0 + return False From 137ed3157ff0770e8f94b40553d076b15d4c0dd8 Mon Sep 17 00:00:00 2001 From: pankace <44595774+pankace@users.noreply.github.com> Date: Tue, 3 Oct 2023 09:49:57 +0700 Subject: [PATCH 7/9] oompaloompa --- oop-coffee-machine-start/oop-coffee-machine-start/main.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/oop-coffee-machine-start/oop-coffee-machine-start/main.py b/oop-coffee-machine-start/oop-coffee-machine-start/main.py index 3101ffc..f0810d6 100644 --- a/oop-coffee-machine-start/oop-coffee-machine-start/main.py +++ b/oop-coffee-machine-start/oop-coffee-machine-start/main.py @@ -2,6 +2,7 @@ from coffee_maker import CoffeeMaker from money_machine import MoneyMachine + def __main__(): coffee_maker = CoffeeMaker() menu = Menu() @@ -18,8 +19,11 @@ def __main__(): money_machine.report() else: drink = menu.find_drink(choice) - if coffee_maker.is_resource_sufficient(drink) and money_machine.make_payment(drink.cost): + if coffee_maker.is_resource_sufficient( + drink + ) and money_machine.make_payment(drink.cost): coffee_maker.make_coffee(drink) + if __name__ == "__main__": - __main__() \ No newline at end of file + __main__() From dbf26b38b3515ebcd9f419416e6d7861cd1e2288 Mon Sep 17 00:00:00 2001 From: pankace <44595774+pankace@users.noreply.github.com> Date: Wed, 4 Oct 2023 11:39:53 +0700 Subject: [PATCH 8/9] quiz --- quiz-game-start.zip | Bin 0 -> 995 bytes quiz-game-start/data.py | 14 ++++++++++++ quiz-game-start/main.py | 18 +++++++++++++++ quiz-game-start/question_model.py | 4 ++++ quiz-game-start/quiz_brain.py | 36 ++++++++++++++++++++++++++++++ 5 files changed, 72 insertions(+) create mode 100644 quiz-game-start.zip create mode 100644 quiz-game-start/data.py create mode 100644 quiz-game-start/main.py create mode 100644 quiz-game-start/question_model.py create mode 100644 quiz-game-start/quiz_brain.py diff --git a/quiz-game-start.zip b/quiz-game-start.zip new file mode 100644 index 0000000000000000000000000000000000000000..f546395432745aa5903b01fdaedfbccb7032753d GIT binary patch literal 995 zcmWIWW@Zs#-~hro5m|u@NPr#4PDw0D)GMfL4L+H5$3bB4Z*8vFXGTw?IG!jti%mW& zpsv^=khRM@$at;ZPVpx*C)A&REqR-B7Gr!%RrS|tt8Oc4TJ!GLNnbYo%i~Aolb`CD z>#xYv{CR1;Q0|^ps?%5WD?N z@!T`*?1O1uZ*F+FKIl62eaF5QJ6i+)JpJQ`{Y>+3RL_brJM45YbM9(~`>O=wW8cIU z>{+Hi|F-GQzOtx}-oh}Z42Qc9R>kvAJFCb4)lcPcVeKB?URk9DYo=6kADqc1%b)#l zxoPw1YThtrk3H2-3_h4}&I#W1?&9I?QI{M)n7Y5OU^!kdv!UQ-_uBj!L2edTrYcPQ zd#K;IGw$iDm7n9PX7IOgHocqtJB5WUp>VCC_#FKQesBNs31_=kCUWb!rEjuo_d4ZT zl6O+XBzWe#aPy)Z#c<0OXTm&S1cSicP#Ey_i?(q-;wE+uEwFgjkWEQ zc1$r${W52hw5qPg{E7F1)QvMa*_d0s(gGImTNdrDuu3;+b!YMt+nRUc6Wqo1>i)3? zc(ZfFG#9L3Wny3mWno|lfTkPCqpK)sf o`4XWiAE*h7pK)sk`4XXh9auYxpIO;J(kwvu1W3OGDqvs$0DUPx{{R30 literal 0 HcmV?d00001 diff --git a/quiz-game-start/data.py b/quiz-game-start/data.py new file mode 100644 index 0000000..b5b46ec --- /dev/null +++ b/quiz-game-start/data.py @@ -0,0 +1,14 @@ +question_data = [ +{"text": "A slug's blood is green.", "answer": "True"}, +{"text": "The loudest animal is the African Elephant.", "answer": "False"}, +{"text": "Approximately one quarter of human bones are in the feet.", "answer": "True"}, +{"text": "The total surface area of a human lungs is the size of a football pitch.", "answer": "True"}, +{"text": "In West Virginia, USA, if you accidentally hit an animal with your car, you are free to take it home to eat.", "answer": "True"}, +{"text": "In London, UK, if you happen to die in the House of Parliament, you are entitled to a state funeral.", "answer": "False"}, +{"text": "It is illegal to pee in the Ocean in Portugal.", "answer": "True"}, +{"text": "You can lead a cow down stairs but not up stairs.", "answer": "False"}, +{"text": "Google was originally called 'Backrub'.", "answer": "True"}, +{"text": "Buzz Aldrin's mother's maiden name was 'Moon'.", "answer": "True"}, +{"text": "No piece of square dry paper can be folded in half more than 7 times.", "answer": "False"}, +{"text": "A few ounces of chocolate can to kill a small dog.", "answer": "True"} +] \ No newline at end of file diff --git a/quiz-game-start/main.py b/quiz-game-start/main.py new file mode 100644 index 0000000..c441008 --- /dev/null +++ b/quiz-game-start/main.py @@ -0,0 +1,18 @@ +import question_model +import quiz_brain +import data + +question_bank = [] + +for question in data.question_data: + question_text = question["text"] + question_answer = question["answer"] + new_question = question_model.Question(question_text, question_answer) + question_bank.append(new_question) + +quiz = quiz_brain.QuizBrain(question_bank) + +while quiz.still_has_questions(): + quiz.next_question() + +print("You've completed the quiz") \ No newline at end of file diff --git a/quiz-game-start/question_model.py b/quiz-game-start/question_model.py new file mode 100644 index 0000000..bc103a2 --- /dev/null +++ b/quiz-game-start/question_model.py @@ -0,0 +1,4 @@ +class Question: + def __init__(self, q_text, q_answer): + self.text = q_text + self.answer = q_answer diff --git a/quiz-game-start/quiz_brain.py b/quiz-game-start/quiz_brain.py new file mode 100644 index 0000000..955ea29 --- /dev/null +++ b/quiz-game-start/quiz_brain.py @@ -0,0 +1,36 @@ +class QuizBrain: + def __init__(self, q_list): + self.question_number = 0 + self.question_list = q_list + self.score = 0 + + def next_question(self): + current_question = self.question_list[self.question_number] + self.question_number += 1 + user_answer = input(f"Q.{self.question_number}: {current_question.text} (True/False)?: ") + self.check_answer(user_answer, current_question.answer) + + def still_has_questions(self): + return self.question_number < len(self.question_list) + + def check_answer(self, user_answer, correct_answer): + if user_answer.lower() == correct_answer.lower(): + print("You got it right!") + else: + print("That's wrong.") + print(f"The correct answer was: {correct_answer}.") + print(f"Your current score is: {self.score}/{self.question_number}") + print("\n") + + def start(self): + while self.still_has_questions(): + self.next_question() + print("You've completed the quiz.") + print(f"Your final score was: {self.score}/{self.question_number}") + print("\n") + + + + + + From d9e964c0e211a4b06e73f972e1100b23adadd9b3 Mon Sep 17 00:00:00 2001 From: pankace <44595774+pankace@users.noreply.github.com> Date: Thu, 5 Oct 2023 11:17:09 +0700 Subject: [PATCH 9/9] turt --- turt/Spirograph.py | 16 ++++++++++++++++ turt/dottedline.py | 13 +++++++++++++ turt/randomwalk.py | 19 +++++++++++++++++++ turt/squre.py | 10 ++++++++++ turt/triangles.py | 29 +++++++++++++++++++++++++++++ 5 files changed, 87 insertions(+) create mode 100644 turt/Spirograph.py create mode 100644 turt/dottedline.py create mode 100644 turt/randomwalk.py create mode 100644 turt/squre.py create mode 100644 turt/triangles.py diff --git a/turt/Spirograph.py b/turt/Spirograph.py new file mode 100644 index 0000000..3e87e4a --- /dev/null +++ b/turt/Spirograph.py @@ -0,0 +1,16 @@ +import turtle as t +import random + +t.colormode(255) +tim = t.Turtle() +tim.speed("fastest") +tim.shape("turtle") + +for _ in range(72): + tim.color((random.randint(0, 255), random.randint(0, 255), random.randint(0, 255))) + tim.circle(100) + tim.left(5) + +screen = t.Screen() +screen.exitonclick() + diff --git a/turt/dottedline.py b/turt/dottedline.py new file mode 100644 index 0000000..c3d9409 --- /dev/null +++ b/turt/dottedline.py @@ -0,0 +1,13 @@ +import turtle + +def dottedline(t, length): + for i in range(4): + t.fd(length) + t.up() + t.fd(length) + t.down() + +bob = turtle.Turtle() +dottedline(bob, 100) +turtle.mainloop() + diff --git a/turt/randomwalk.py b/turt/randomwalk.py new file mode 100644 index 0000000..04cea0c --- /dev/null +++ b/turt/randomwalk.py @@ -0,0 +1,19 @@ +import turtle as t +import random + +t.colormode(255) +tim = t.Turtle() +tim.speed("fastest") +tim.shape("turtle") +colors = ["CornflowerBlue", "DarkOrchid", "IndianRed", "DeepSkyBlue", "LightSeaGreen", "wheat", "SlateGray", "SeaGreen"] +directions = [0, 90, 180, 270] + + +for _ in range(200): + tim.pensize(random.randint(1, 10)) + tim.color(random.choice(colors)) + tim.forward(30) + tim.setheading(random.choice(directions)) + +screen = t.Screen() +screen.exitonclick() \ No newline at end of file diff --git a/turt/squre.py b/turt/squre.py new file mode 100644 index 0000000..4863ab6 --- /dev/null +++ b/turt/squre.py @@ -0,0 +1,10 @@ +import turtle + +def square(t, length): + for i in range(4): + t.fd(length) + t.lt(90) + +bob = turtle.Turtle() +square(bob, 100) +turtle.mainloop() \ No newline at end of file diff --git a/turt/triangles.py b/turt/triangles.py new file mode 100644 index 0000000..5a6225a --- /dev/null +++ b/turt/triangles.py @@ -0,0 +1,29 @@ +import turtle + +def polygon(t, n, length): + angle = 360 / n + for i in range(n): + t.fd(length) + t.lt(angle) + +def nangle(t, n, length): + for i in range(n): + polygon(t, n, length) + t.lt(360 / n) + +def change_color_each_pulygon(t, n, length): + for i in range(n): + t.color("red") + polygon(t, n, length) + t.color("blue") + t.lt(360 / n) + +def main(): + bob = turtle.Turtle() + bob.speed(0) + bob.hideturtle() + change_color_each_pulygon(bob, 10, 50) + turtle.mainloop() + +if __name__ == "__main__": + main() \ No newline at end of file