- Видео 99
- Просмотров 39 208
Learn IT today
Канада
Добавлен 1 сен 2022
You can find IT videos in our channel. I hope that they will be useful for you.
IB DP CS, IB CS, IB Computer Science, Computer science in DP
IB MYP Design, Design in the MYP, MYP Design, IB Middle Years Programme
International Baccalaureate Diploma's Computer Science resource channel
Programming in Java
Programming in Python
OOP - Object Oriented Programming
Arduino
Animations
OpenToonz
Blender
Inkscape
SketchUp
IB DP CS, IB CS, IB Computer Science, Computer science in DP
IB MYP Design, Design in the MYP, MYP Design, IB Middle Years Programme
International Baccalaureate Diploma's Computer Science resource channel
Programming in Java
Programming in Python
OOP - Object Oriented Programming
Arduino
Animations
OpenToonz
Blender
Inkscape
SketchUp
Видео
Vaze - an animation by Rayana
Просмотров 354 месяца назад
The vaze animation is made by Rayana Gilemkhanova. These frames represent the sequence of the actions in my animation. I am going to start with a frame with a title of the video and the vase at a large scale. The title will show the viewers the idea of the animation they will watch and the big size of the vase already makes the accent on it, showing that this vase is the key element of the vide...
Football tricks - a Blender animation Shafkatjohn animation
Просмотров 244 месяца назад
The Football tricks is a Blender animation by Shafkatjohn Ibragimov.
Jumpman LCD game - Arudino project Yasmina
Просмотров 1044 месяца назад
The jumpman LCD game is made by Yasmina Saetgaraeva. Create an interactive and entertaining game using an Arduino and an LCD screen. This project aims to combine hardware and software to build a simple yet engaging game that users can play using a button connected to the Arduino. The LCD screen will display the game environment and provide feedback to the player. Components: Arduino Board LCD S...
Memory game with Arduino - Maksim and Danis
Просмотров 3244 месяца назад
The memory game project is made by Maksim and Danis with Arduino. The game works by presenting the player with a sequence of colored buttons that light up in a specific order. The player must then replicate the sequence by pressing the buttons in the same order. If the player gets it right, the game adds an additional color to the sequence, making it more challenging. The game continues in this...
Dancing penguin - by Ellina and Liana.
Просмотров 184 месяца назад
The animation is made by Ellina and Liana. This concept seems most appealing to me as it meets the success criteria through its engaging storyline, captivating visuals, emotional impact, consistent style, and entertainment value. Moreover, this animation idea offers several advantages. For instance, the penguin's comical dance routine will introduce humor and entertainment. Setting the scene in...
Drifting car - 3D animation in Blender
Просмотров 384 месяца назад
This aniamtion is made by Nariman Shafikov. The "8" figure is drifted around the two cones by the automobile in this concept.The concept will result in an endless animation that demonstrates the proper drifting method. The car is clearly shown in the animation, making it easy to watch. Moreover, having some other physical objects shows the technique in a more convenient way, as long as there ar...
The importance of Education - 3D animation in Blender
Просмотров 214 месяца назад
This animation is made by Nikita Zavyalov. In the detailed illustration, a diverse group of animals including a wolf, hare, bear, and fox are depicted alongside a school building. The bear, wolf, and hare appear to be diligently focused on their studies, presumably with the intention of pursuing successful careers and financial stability. However, the fox stands out from the group as it lounges...
Physical exercises - 3D Animation in Blender
Просмотров 1094 месяца назад
This animation is made by Rodion Shatskikh. Choosing physical exercise as the theme for your animation is a commendable decision with several compelling reasons. Firstly, prioritizing utility and information over mere entertainment reflects a thoughtful approach. Physical exercise is a universally beneficial topic that aligns with the well-being of individuals. By focusing on exercises, your an...
Good things in life - 3d Animation in Blender
Просмотров 294 месяца назад
This aniamtion is made by Riana Galiaskarova. The animation is a colorful and happy 3D animated short film. It shows characters who are joyful and grateful for the good things in life. I think this is the best choice because it spreads a positive message that everyone can relate to. The film will focus on the characters doing things that make them happy, like dancing and playing. It will remind...
Overcome difficulties - 3D animation
Просмотров 74 месяца назад
This animation is made by Adelina Galautdinova. The project in Blender revolves around portraying Spidey, a determined spider, grappling with the challenge of climbing a slippery leaf, intending to convey a message of perseverance and determination. Through this animation, the goal is to realistically illustrate Spidey's struggle, aiming to evoke empathy and inspire viewers to persist in the fa...
Enjoy your time - 3D animation in Blender
Просмотров 114 месяца назад
This 3D animation is made by Samira Gabidullina. In these heartwarming animation frames, we can see a mother and her daughter whose bond shines brightly as they spend a day at the seaside. Their happy enthusiasm is captured in the 1st drawing as they run around on the sand, the light casting a warm glow across their faces. With laughter echoing in the air, they build a magnificent sandcastle to...
Do not throw anything from window - 3D Blender animation
Просмотров 64 месяца назад
This animation is made by Mark Semivolkov in Blender.
Going to sleep - Blender 3D animation
Просмотров 584 месяца назад
The 3D animation is made by Sophiya Suldina in Blender. This idea of a 3D animation in Blender which can solve my problem of people not getting enough sleep. The point here is that a human lays down on the bed and falls into his sleep. Overall, considering all of these factors the animation itself brings a really straight and clear meaning with no useless stuff, reminds and persuades you to go ...
Simon memory game - Arduino project
Просмотров 54 месяца назад
The Simon memoy game is made with Arduino by Adelina Galautdinova. The game works by presenting the player with a sequence of colored buttons that light up in a specific order. The player must then replicate the sequence by pressing the buttons in the same order. If the player gets it right, the game adds an additional color to the sequence, making it more challenging. The game continues in thi...
A 3D animation in Blender - Torou and Kurou
Просмотров 284 месяца назад
A 3D animation in Blender - Torou and Kurou
Blender Car Crash Animation - Careful and Furious
Просмотров 704 месяца назад
Blender Car Crash Animation - Careful and Furious
Designing a tabbed house using Inkscape
Просмотров 59210 месяцев назад
Designing a tabbed house using Inkscape
How to change the login password on Mac easily
Просмотров 15010 месяцев назад
How to change the login password on Mac easily
Constructing a Cultural House - Laser cutter
Просмотров 23111 месяцев назад
Constructing a Cultural House - Laser cutter
Automatic Pet waterer - Arduino project
Просмотров 10811 месяцев назад
Automatic Pet waterer - Arduino project
Living or non-living game - Python Project
Просмотров 3611 месяцев назад
Living or non-living game - Python Project
Mouse Attention game - Python Project
Просмотров 20011 месяцев назад
Mouse Attention game - Python Project
Why there's no explanation??
Thank you
How do you delete the frames? is there an updated tutorial? i cant seem to find the vertical strip.
Didn’t work 😢
I dont have the camra colume, How do I get it?
This helped so much!!! Tyy
I followed every step and it still doesn’t work 😭😭
When Picsart mobile has this feature enabled intrincally, meanwhile, I have to search for a damn tutorial to enable such a basic feature in this more professional software.
Nice project! btw make your videos louder ;)
Ураааа это то что мне нужно! Понять бы мне ещё англисский 🥲
в яндекс браузере синхронный перевод голосовой есть
Hi, can you make a tutorial how to do this?
actually good tutorial exact what I needed. Was trying to move a file from one folder to another. I don't know why macos isn't like windows where if you double click there should be a "send to" option, but this works just as good. Did not know about holding option to show the "move here" thing. I just knew about copy paste. Thank you 🙏
Thank you for your comment
Thank you.
You are welcome
BONE appetite 😂
Thank you for this breef tutorial, it’s really helpful to me
Thankyou!
thank you so much.
𝓯𝓻𝓮𝓪𝓴𝔂 ass font
Finally top content!!! Thank You!
Enjoy!
hello vro❤
vro i couldn't get it to work..can you explain it in fortnite terms?
@@amaurtinifunny so sometimes back in pleasant park there were these secret bunkers. and when you came into them they had chests and nobody knew about them. this font is like the chests since you have to do something secret in order to find it.
ahhh thanks for that 𝓕𝓻𝓮𝓪𝓴!
Do u fw me?
@@leguccisucc7478 i fw you heavy💛
can they edit it? if not how can I change it to where they can do that?
unfortunately you cannot edit that
Thanks, GOD bless you.
You too
Thanks
you are welcome
Thank you soooo much
You are welcome
Is there a way to move 2 guidelines at once?
Good video
Thanks for your good comment
ёкарный бабай
ёкалэменэ
ёшкин кот
ёмаё
iv done everything in this tutorial but it still doesn't work
still not working?
@@learnittoday yes :(
@@learnittoday not working for me either. no matter what i do, the "gif" "mov" "avi" "mp4" etc options do not appear. not sure how to go about this. this video was very clear, and i definitely followed all the steps, so i'm not sure what the problem could be.
🙂 *promosm*
You are welcome
Maşallah!
eyvallah
I'm Liking what I'm seeing, so far. :) I would Like to see what vision it is you have, for your channel. I Look forward to more content, in the future. I would Like to see you succeed. :) Just would Like to Leave a helpful suggestion. Try to slow down, you seemed nervous. i don't know how you do your process, obviously, but if you have a video editor, or some video editing skills, to work the software, (at least, it seems to be pretty complex software, to me, from what I've seen.) if not, it could be some helpful skills, to try to take some time, to try to Learn. :) Try recording the audio, then go back through and edit out your "uh's", and "Um's". You seemed, a bit, frantic. You're good. :) Should help you sound clearer, more concise, and confident, in your work. You have good hard skills, in the software programming, just a good polish up on your soft skills, learning to communicate effectively. :) To match your great skills. I wish you best of Luck, and Look forward, to where you go, with your channel. :)
Thanks for your good recomendations
import turtle import random # Set up the Turtle screen window = turtle.Screen() window.title("Math Quiz Game") window.bgcolor("lightblue") # Create a Turtle object for drawing pen = turtle.Turtle() pen.speed(0) pen.color("black") pen.penup() pen.hideturtle() # Function to display a question def display_question(question): pen.goto(0, 100) pen.clear() pen.write(question, align="center", font=("Arial", 24, "normal")) # Function to display a reward animation def display_reward(): pen.goto(0, -50) pen.clear() pen.color("green") pen.write("Correct!", align="center", font=("Arial", 24, "normal")) # Function to generate a math question def generate_question(): num1 = random.randint(1, 20) num2 = random.randint(1, 20) operator = random.choice(["+", "-"]) if operator == "+": answer = num1 + num2 else: answer = num1 - num2 question = f"What is {num1} {operator} {num2}?" return question, answer # Function to check the answer def check_answer(user_answer, correct_answer): return user_answer == correct_answer # Main game loop score = 0 for _ in range(5): # Ask 5 questions question, answer = generate_question() display_question(question) user_answer = turtle.numinput("Math Quiz", "Enter your answer:") if user_answer is not None: user_answer = int(user_answer) if check_answer(user_answer, answer): score += 1 display_reward() # Display the final score pen.goto(0, 0) pen.clear() pen.color("blue") pen.write(f"Your score: {score}/5", align="center", font=("Arial", 24, "normal")) # Close the game when clicked window.exitonclick()
Thanks
import turtle, time a = turtle.Screen() a.bgcolor("lightgreen") turtle.write('"Living or non-living"', align='center', font = ('Courier', 24, 'normal')) turtle.register_shape('a big tree.gif') turtle.register_shape('table.gif') turtle.register_shape('flowerrr.gif') turtle.register_shape('sofa.gif') turtle.register_shape('mashroom.gif') turtle.register_shape('nature.gif') a.screensize(500, 500) player = turtle.Turtle() player.color("black") player.shape("triangle") player.penup() speed = 1 score = 0 time.sleep(10) tree = turtle.Turtle() tree.shape('a big tree.gif') tree.setheading(50) tree.penup() tree.goto(0,0) d = input('Is it living or non-living? Answer:') if d == 'living': turtle.write('"It is correct"', align='center', font = ('Courier', 24, 'normal')) score = score + 1 else: turtle.write('"It is uncorrect"', align='center', font = ('Courier', 24, 'normal')) time.sleep(10) table = turtle.Turtle() table.shape('table.gif') table.setheading(50) table.penup() table.goto(0,0) m = input('Is it living or non-living? Answer: ') if m == 'non-living': turtle.write('"It is correct"', align='center', font = ('Courier', 24, 'normal')) score = score + 1 else: turtle.write('"It is uncorrect"', align='center', font = ('Courier', 24, 'normal')) time.sleep(10) flower = turtle.Turtle() flower.shape('flowerrr.gif') flower.setheading(50) flower.penup() flower.goto(0,-50) n = input('Is it living or non-living? Answer: ') if n == 'living': turtle.write('"It is correct"', align='center', font = ('Courier', 24, 'normal')) score = score + 1 else: turtle.write('"It is uncorrect"', align='center', font = ('Courier', 24, 'normal')) time.sleep(10) sofa = turtle.Turtle() sofa.shape('sofa.gif') sofa.setheading(50) sofa.penup() sofa.goto(0,0) k = input('Is it living or non-living? Answer: ') if k == 'non-living': turtle.write('"It is correct"', align='center', font = ('Courier', 24, 'normal')) score = score + 1 else: turtle.write('"It is uncorrect"', align='center', font = ('Courier', 24, 'normal')) time.sleep(10) mushroom = turtle.Turtle() mushroom.shape('mashroom.gif') mushroom.setheading(50) mushroom.penup() mushroom.goto(0,0) p = input('Is it living or non-living? Answer: ') if p == 'living': turtle.write('"It is correct"', align='center', font = ('Courier', 24, 'normal')) score = score + 1 else: turtle.write('"It is uncorrect"', align='center', font = ('Courier', 24, 'normal')) time.sleep(10) nature = turtle.Turtle() nature.shape('nature.gif') nature.setheading(50) nature.penup() nature.goto(0,0) if score > 0: turtle.write('"Cool, you win!"', align='center', font = ('Courier', 24, 'normal')) else: turtle.write('"Sorry, you lost"', align='center', font = ('Courier', 24, 'normal')) while True: player.forward(5)
Thanks
//Efficient Sequential Search int search = input.nextInt(); boolean found = false; int i=0; while (i<n && !found){ if (a[i] == search){ System.out.println("Found at the " + i + " index position"); found = true; } i++; } if (!found){ System.out.println("Not found"); }
int search = input.nextInt(); int left = 0; int right = 9; boolean found = false; while (!found && left<=right){ int middle = (left+right)/2; if (a[middle] == search){ System.out.println("Found at " + middle); found = true; }else if (search > a[middle]){ left = middle + 1; }else{ right = middle - 1; } } if (!found){ System.out.println("Not found"); }
Thanks
int i = 0; boolean swapped = true; while (i<n-1 && swapped){ int j = 0; swapped = false; while (j<n-1-i){ if (a[j] > a[j+1]){ int t = a[j]; a[j] = a[j+1]; a[j+1] = t; swapped = true; } j++; } i++; }
Thanks
printArray(a); //Selection Sort starts for (int i=0; i<n-1; i++){ int minpos = i; for (int j=i+1; j<n; j++){ if (a[j] < a[minpos]){ minpos = j; } } int t = a[i]; a[i] = a[minpos]; a[minpos] = t; } System.out.println("The Sorted Array:"); printArray(a);
Thanks
#length # mm = 1 # cm = 10*mm # meter = 100*cm # kilometer = 1000*meter # inch = 2.54*cm # foot = 0.3048006*meter # mile = 633600*inch #mass # mg = 1 # gram = 1000*mg # kg = 1000*gram # ton = 1000*kg # lbs = 0.453592*kg #volume # cubmtr = 1 # cubfoot = 0.0283168*cubmtr # liter = 0.001*cubmtr # cubcm = 0.000001*cubmtr #area # sqm = 1 # acre = 4046.873*sqm # sqcm = 0.001*sqm import customtkinter from tkinter import * from tkinter import messagebox win = customtkinter.CTk() win.title('Unit Konverter') win.geometry('500*500') win.config(bg='black') font1 = ('Arial', 30, 'bold') font2 = ('Arial', 25, 'bold') font3 = ('Arial', 15, 'bold') unit_options = ['Length', 'Mass', 'Volume', 'Area'] length_options = ['mm', 'cm', 'meter', 'kilometer', 'inch', 'foot', 'mile'] mass_options = ['mg', 'gram', 'kg', 'ton', 'lbs'] volume_options = ['cubmtr', 'cubfoot', 'liter', 'cubcm'] area_options = ['sqm', 'acre', 'sqcm'] variable1 = StringVar() variable2 = StringVar() variable3 = StringVar() def convert(): length_factors = {'meter': 1, 'cm': 0.01, 'mm': 0.001, 'kilometer': 1000, 'inch': 0.0254, 'foot': 3.28084, 'mile': 39370.1} mass_factors = {'kg': 1, 'gram': 0.001, 'mg': 0.000001, 'ton': 1000, 'lbs': 2.20462} area_factors = {'sqm': 1, 'sqcm': 0.001, 'acre': 4046.873} volume_factors = {'cubmtr': 1, 'cubfoot': 0.0283168, 'cubcm': 0.000001, 'liter': 0.001} if variable1.get() == 'Length': meters = float(value_entry.get())*length_factors[variable2.get()] converted_value = meters/length_factors[variable3.get()] elif variable1.get() == 'Mass': kg = float(value_entry.get())*mass_factors[variable2.get()] converted_value = kg/mass_factors[variable3.get()] elif variable1.get() == 'Volume': cubmtr = float(value_entry.get())*volume_factors[variable2.get()] converted_value = cubmtr/volume_factors[variable3.get()] elif variable1.get() == 'Area': sqm = float(value_entry.get())*area_factors[variable2.get()] converted_value = sqm/area_factors[variable3.get()] result_label.configure(text=f'{value_entry.get()} {variable2.get()} = {converted_value:.5f} {variable3.get()}') title_label = customtkinter.CTkLabel(win, font=font1, text='Unit Converter', text_color="#fff", bg_color='#020a24') title_label.place(x=150, y=20) unit_label = customtkinter.CTkLabel(win, font=font2, text='Unit', text_color="#fff", bg_color='#020a24') unit_label.place(x=180, y=100) unit_option = customtkinter.CTkComboBox(win, font=font3, text_color='#000', fg_color='#fff', dropdown_hover_color='#06911f', values=unit_options, variable=variable1, width=120) unit_option.place(x=180, y=130) from_label = customtkinter.CTkLabel(win, font=font2, text='From', text_color='#fff', bg_color='#020a24') from_label.place(x=20, y=180) from_option = customtkinter.CTkComboBox(win, font=font3, text_color='#000', fg_color='#fff', dropdown_hover_color='#06911f', variable=variable2, width=120) from_option.place(x=20, y=210) to_label = customtkinter.CTkLabel(win, font=font2, text="To", text_color='#fff', bg_color='#020a24') to_label.place(x=180, y=180) to_option = customtkinter.CTkComboBox(win, font=font3, text_color='#000', fg_color='#fff', dropdown_hover_color='#06911f', variable=variable3, width=120) to_option.place(x=180, y=210) value_label = customtkinter.CTkLabel(win, font=font1, text='Value', text_color='#fff', bg_color='#020a24') value_label.place(x=340, y=180) value_entry = customtkinter.CTkEntry(win, font=font3, text_color='#000', fg_color='#fff', border_color='#fff', width=150) value_entry.place(x=340, y=210) convert_button = customtkinter.CTkButton(win, command=convert, font=font2, text_color='#fff', text="Convert", fg_color='red', hover_color='orange', bg_color='red', cursor="hand2", corner_radius=10, width=200) convert_button.place(x=150, y=280) result_label = customtkinter.CTkLabel(win, text='', font=font2, text_color='#fff', bg_color='red') result_label.place(x=100, y=400) def update_options(*args): if variable1.get() == 'Length': from_option.configure(values=length_options) to_option.configure(values=length_options) from_option.set('meter') to_option.set('foot') elif variable1.get() == 'Mass': from_option.configure(values=mass_options) to_option.configure(values=mass_options) from_option.set('kg') to_option.set('lbs') elif variable1.get() == 'Area': from_option.configure(values=area_options) to_option.configure(values=area_options) from_option.set('sqm') to_option.set('acre') elif variable1.get() == 'Volume': from_option.configure(values=volume_options) to_option.configure(values=volume_options) from_option.set('cubmtr') to_option.set('cubfoot') variable1.trace("w", update_options) win.mainloop()
import turtle import random import tkinter screen = turtle.Screen() screen.setup(1000,1000) screen.title('Type n Fall') screen.bgcolor('black') #type any color you want screen.tracer(0,0) turtle.hideturtle() turtle.up() turtle.color('green') score_turtle = turtle.Turtle() score_turtle.color('green') score_turtle.up() score_turtle.hideturtle() turtle.goto(350,400) turtle.write('Score: ', align='center', font=('Courier',25,'normal')) min_speed = 1 #set the minimum speed here max_speed = 5 #set the maximum speed here letters = [] speeds = [] pos = [] lts = [] n = 10 game_over = False score = 0 def increase_difficulty(): #delete this function if you want the speed to be constant global min_speed, max_speed min_speed += 1 max_speed += 1 screen.ontimer(increase_difficulty,5000) def draw_game_over(): turtle.goto(0,0) turtle.color('green') turtle.write('GAME OVER', align='center', font=('Courier',50,'normal')) turtle.goto(0,-150) turtle.color('green') turtle.write('Your Score is {}'.format(score), align='center', font=('Courier',40,'normal')) screen.update() def draw_score(): score_turtle.clear() score_turtle.goto(420,400) score_turtle.write('{}'.format(score),align='center',font=('Courier',25,'normal')) screen.update() def draw_letters(): global game_over for i in range(len(letters)): lts[i].clear() lts[i].goto(pos[i]) lts[i].write(letters[i],align='center',font=('courier',20,'normal')) pos[i][1] -= speeds[i] if pos[i][1]<-500: game_over = True draw_game_over() return screen.update() screen.ontimer(draw_letters,50) def f(c): global score if c in letters: score += 1 k = letters.index(c) while True: l = chr(ord('a')+random.randrange(26)) if l not in letters: letters[k] = l break pos[k] = [random.randint(-450,450),500] speeds[k] = random.randint(min_speed,max_speed) else: score -= 1 draw_score() for _ in range(n): lts.append(turtle.Turtle()) while True: l = chr(ord('a')+random.randrange(26)) if l not in letters: letters.append(l) break speeds.append(random.randint(min_speed,max_speed)) pos.append([random.randint(-450,450),500]) for i in range(n): lts[i].speed(0) lts[i].hideturtle() lts[i].up() lts[i].color('green') draw_letters() #increase_difficulty() (optional) screen.onkey(lambda: f('a'), 'a') screen.onkey(lambda: f('b'), 'b') screen.onkey(lambda: f('c'), 'c') screen.onkey(lambda: f('d'), 'd') screen.onkey(lambda: f('e'), 'e') screen.onkey(lambda: f('f'), 'f') screen.onkey(lambda: f('g'), 'g') screen.onkey(lambda: f('h'), 'h') screen.onkey(lambda: f('i'), 'i') screen.onkey(lambda: f('j'), 'j') screen.onkey(lambda: f('k'), 'k') screen.onkey(lambda: f('l'), 'l') screen.onkey(lambda: f('m'), 'm') screen.onkey(lambda: f('n'), 'n') screen.onkey(lambda: f('o'), 'o') screen.onkey(lambda: f('p'), 'p') screen.onkey(lambda: f('q'), 'q') screen.onkey(lambda: f('r'), 'r') screen.onkey(lambda: f('s'), 's') screen.onkey(lambda: f('t'), 't') screen.onkey(lambda: f('u'), 'u') screen.onkey(lambda: f('v'), 'v') screen.onkey(lambda: f('w'), 'w') screen.onkey(lambda: f('x'), 'x') screen.onkey(lambda: f('y'), 'y') screen.onkey(lambda: f('z'), 'z') screen.listen() screen.mainloop()
import turtle screen = turtle.Screen() screen.setup(800,800) screen.title("Tic Tac Toe") screen.setworldcoordinates(-5,-5,5,5) screen.bgcolor('light gray') screen.tracer(0,0) turtle.hideturtle() def draw_board(): turtle.pencolor('green') turtle.pensize(10) turtle.up() turtle.goto(-3,-1) turtle.seth(0) turtle.down() turtle.fd(6) turtle.up() turtle.goto(-3,1) turtle.seth(0) turtle.down() turtle.fd(6) turtle.up() turtle.goto(-1,-3) turtle.seth(90) turtle.down() turtle.fd(6) turtle.up() turtle.goto(1,-3) turtle.seth(90) turtle.down() turtle.fd(6) def draw_circle(x,y): turtle.up() turtle.goto(x,y-0.75) turtle.seth(0) turtle.color('red') turtle.down() turtle.circle(0.75, steps=100) def draw_x(x,y): turtle.color('blue') turtle.up() turtle.goto(x-0.75,y-0.75) turtle.down() turtle.goto(x+0.75,y+0.75) turtle.up() turtle.goto(x-0.75,y+0.75) turtle.down() turtle.goto(x+0.75,y-0.75) def draw_piece(i,j,p): if p==0: return x,y = 2*(j-1), -2*(i-1) if p==1: draw_x(x,y) else: draw_circle(x,y) def draw(b): draw_board() for i in range(3): for j in range(3): draw_piece(i,j,b[i][j]) screen.update() # return 1 if player 1 wins, 2 if player 2 wins, 3 if tie, 0 if game is not over def gameover(b): if b[0][0]>0 and b[0][0] == b[0][1] and b[0][1] == b[0][2]: return b[0][0] if b[1][0]>0 and b[1][0] == b[1][1] and b[1][1] == b[1][2]: return b[1][0] if b[2][0]>0 and b[2][0] == b[2][1] and b[2][1] == b[2][2]: return b[2][0] if b[0][0]>0 and b[0][0] == b[1][0] and b[1][0] == b[2][0]: return b[0][0] if b[0][1]>0 and b[0][1] == b[1][1] and b[1][1] == b[2][1]: return b[0][1] if b[0][2]>0 and b[0][2] == b[1][2] and b[1][2] == b[2][2]: return b[0][2] if b[0][0]>0 and b[0][0] == b[1][1] and b[1][1] == b[2][2]: return b[0][0] if b[2][0]>0 and b[2][0] == b[1][1] and b[1][1] == b[0][2]: return b[2][0] p = 0 for i in range(3): for j in range(3): p += (1 if b[i][j] > 0 else 0) if p==9: return 3 else: return 0 def play(x,y): global turn i = 3-int(y+5)//2 j = int(x+5)//2 - 1 if i>2 or j>2 or i<0 or j<0 or b[i][j]!=0: return if turn == 'x': b[i][j], turn = 1, 'o' else: b[i][j], turn = 2, 'x' draw(b) r = gameover(b) if r==1: screen.textinput("Game over!","X won!") elif r==2: screen.textinput("Game over!","O won!") elif r==3: screen.textinput("Game over!", "Tie!") b = [ [ 0,0,0 ], [ 0,0,0 ], [ 0,0,0 ] ] draw(b) turn = 'x' screen.onclick(play) turtle.mainloop() # import turtle # import copy # import random # screen = turtle.Screen() # screen.setup(800,800) # screen.title("Tic Tac Toe - PythonTurtle.Academy") # screen.setworldcoordinates(-5,-5,5,5) # screen.bgcolor('pink') # screen.tracer(0,0) # turtle.hideturtle() # def draw_board(): # turtle.pencolor('purple') # turtle.pensize(10) # turtle.up() # turtle.goto(-3,-1) # turtle.seth(0) # turtle.down() # turtle.fd(6) # turtle.up() # turtle.goto(-3,1) # turtle.seth(0) # turtle.down() # turtle.fd(6) # turtle.up() # turtle.goto(-1,-3) # turtle.seth(90) # turtle.down() # turtle.fd(6) # turtle.up() # turtle.goto(1,-3) # turtle.seth(90) # turtle.down() # turtle.fd(6) # def draw_circle(x,y): # turtle.up() # turtle.goto(x,y-0.75) # turtle.seth(0) # turtle.color('yellow') # turtle.down() # turtle.circle(0.75, steps=100) # def draw_x(x,y): # turtle.color('light blue') # turtle.up() # turtle.goto(x-0.75,y-0.75) # turtle.down() # turtle.goto(x+0.75,y+0.75) # turtle.up() # turtle.goto(x-0.75,y+0.75) # turtle.down() # turtle.goto(x+0.75,y-0.75) # def draw_piece(i,j,p): # if p==0: return # x,y = 2*(j-1), -2*(i-1) # if p==1: # draw_x(x,y) # else: # draw_circle(x,y) # def draw(b): # draw_board() # for i in range(3): # for j in range(3): # draw_piece(i,j,b[i][j]) # screen.update() # # return 1 if player 1 wins, 2 if player 2 wins, 3 if tie, 0 if game is not over # def gameover(b): # if b[0][0]>0 and b[0][0] == b[0][1] and b[0][1] == b[0][2]: return b[0][0] # if b[1][0]>0 and b[1][0] == b[1][1] and b[1][1] == b[1][2]: return b[1][0] # if b[2][0]>0 and b[2][0] == b[2][1] and b[2][1] == b[2][2]: return b[2][0] # if b[0][0]>0 and b[0][0] == b[1][0] and b[1][0] == b[2][0]: return b[0][0] # if b[0][1]>0 and b[0][1] == b[1][1] and b[1][1] == b[2][1]: return b[0][1] # if b[0][2]>0 and b[0][2] == b[1][2] and b[1][2] == b[2][2]: return b[0][2] # if b[0][0]>0 and b[0][0] == b[1][1] and b[1][1] == b[2][2]: return b[0][0] # if b[2][0]>0 and b[2][0] == b[1][1] and b[1][1] == b[0][2]: return b[2][0] # p = 0 # for i in range(3): # for j in range(3): # p += (1 if b[i][j] > 0 else 0) # if p==9: return 3 # else: return 0 # def play(x,y): # global turn # if turn=='x': return # i = 3-int(y+5)//2 # j = int(x+5)//2 - 1 # if i>2 or j>2 or i<0 or j<0 or b[i][j]!=0: return # if turn == 'x': b[i][j], turn = 1, 'o' # else: b[i][j], turn = 2, 'x' # draw(b) # r = gameover(b) # if r==1: # screen.textinput("Game over!","X won!") # elif r==2: # screen.textinput("Game over!","O won!") # elif r==3: # screen.textinput("Game over!", "Tie!") # if r>0: turtle.bye() # _,move = max_node(b,-2,2) # b[move[0]][move[1]] = 1 # draw(b) # r = gameover(b) # if r==1: # screen.textinput("Game over!","X won!") # elif r==2: # screen.textinput("Game over!","O won!") # elif r==3: # screen.textinput("Game over!", "Tie!") # if r>0: turtle.bye() # turn = 'o' # b = [ [ 0,0,0 ], [ 0,0,0 ], [ 0,0,0 ] ] # draw(b) # turn = 'x' # screen.onclick(play) # #turtle.mainloop() # def max_node(b,alpha,beta): # r = gameover(b) # if r==1: return 1,None # elif r==2: return -1,None # elif r==3: return 0,None # score = -2 # # find all possible next moves # pm = list() # for i in range(3): # for j in range(3): # if b[i][j] == 0: pm.append((i,j)) # random.shuffle(pm) # for (i,j) in pm: # if b[i][j] == 0: # nb = copy.deepcopy(b) # nb[i][j] = 1 # cs,_ = min_node(nb,alpha,beta) # if score<cs: # score=cs # move = (i,j) # alpha = max(alpha,cs) # if alpha>=beta: return score,move # return score,move # def min_node(b,alpha,beta): # r = gameover(b) # if r==1: return 1,None # elif r==2: return -1,None # elif r==3: return 0,None # score = 2 # # find all possible next moves # pm = list() # random.shuffle(pm) # for i in range(3): # for j in range(3): # if b[i][j] == 0: pm.append((i,j)) # for (i,j) in pm: # if b[i][j] == 0: # nb = copy.deepcopy(b) # nb[i][j] = 2 # cs,_ = max_node(nb,alpha,beta) # if score>cs: # score=cs # move = (i,j) # beta = min(beta,cs) # if alpha>=beta: return score,move # return score,move # _,move = max_node(b,-2,2) # b[move[0]][move[1]] = 1 # draw(b) # turn = 1 # screen.mainloop()
Thanks
import turtle screen = turtle.Screen() screen.setup(800,800) screen.title("Tic Tac Toe") screen.setworldcoordinates(-5,-5,5,5) screen.bgcolor('light gray') screen.tracer(0,0) turtle.hideturtle() def draw_board(): turtle.pencolor('green') turtle.pensize(10) turtle.up() turtle.goto(-3,-1) turtle.seth(0) turtle.down() turtle.fd(6) turtle.up() turtle.goto(-3,1) turtle.seth(0) turtle.down() turtle.fd(6) turtle.up() turtle.goto(-1,-3) turtle.seth(90) turtle.down() turtle.fd(6) turtle.up() turtle.goto(1,-3) turtle.seth(90) turtle.down() turtle.fd(6) def draw_circle(x,y): turtle.up() turtle.goto(x,y-0.75) turtle.seth(0) turtle.color('red') turtle.down() turtle.circle(0.75, steps=100) def draw_x(x,y): turtle.color('blue') turtle.up() turtle.goto(x-0.75,y-0.75) turtle.down() turtle.goto(x+0.75,y+0.75) turtle.up() turtle.goto(x-0.75,y+0.75) turtle.down() turtle.goto(x+0.75,y-0.75) def draw_piece(i,j,p): if p==0: return x,y = 2*(j-1), -2*(i-1) if p==1: draw_x(x,y) else: draw_circle(x,y) def draw(b): draw_board() for i in range(3): for j in range(3): draw_piece(i,j,b[i][j]) screen.update() # return 1 if player 1 wins, 2 if player 2 wins, 3 if tie, 0 if game is not over def gameover(b): if b[0][0]>0 and b[0][0] == b[0][1] and b[0][1] == b[0][2]: return b[0][0] if b[1][0]>0 and b[1][0] == b[1][1] and b[1][1] == b[1][2]: return b[1][0] if b[2][0]>0 and b[2][0] == b[2][1] and b[2][1] == b[2][2]: return b[2][0] if b[0][0]>0 and b[0][0] == b[1][0] and b[1][0] == b[2][0]: return b[0][0] if b[0][1]>0 and b[0][1] == b[1][1] and b[1][1] == b[2][1]: return b[0][1] if b[0][2]>0 and b[0][2] == b[1][2] and b[1][2] == b[2][2]: return b[0][2] if b[0][0]>0 and b[0][0] == b[1][1] and b[1][1] == b[2][2]: return b[0][0] if b[2][0]>0 and b[2][0] == b[1][1] and b[1][1] == b[0][2]: return b[2][0] p = 0 for i in range(3): for j in range(3): p += (1 if b[i][j] > 0 else 0) if p==9: return 3 else: return 0 def play(x,y): global turn i = 3-int(y+5)//2 j = int(x+5)//2 - 1 if i>2 or j>2 or i<0 or j<0 or b[i][j]!=0: return if turn == 'x': b[i][j], turn = 1, 'o' else: b[i][j], turn = 2, 'x' draw(b) r = gameover(b) if r==1: screen.textinput("Game over!","X won!") elif r==2: screen.textinput("Game over!","O won!") elif r==3: screen.textinput("Game over!", "Tie!") b = [ [ 0,0,0 ], [ 0,0,0 ], [ 0,0,0 ] ] draw(b) turn = 'x' screen.onclick(play) turtle.mainloop() # import turtle # import copy # import random # screen = turtle.Screen() # screen.setup(800,800) # screen.title("Tic Tac Toe") # screen.setworldcoordinates(-5,-5,5,5) # screen.bgcolor('pink') # screen.tracer(0,0) # turtle.hideturtle() # def draw_board(): # turtle.pencolor('purple') # turtle.pensize(10) # turtle.up() # turtle.goto(-3,-1) # turtle.seth(0) # turtle.down() # turtle.fd(6) # turtle.up() # turtle.goto(-3,1) # turtle.seth(0) # turtle.down() # turtle.fd(6) # turtle.up() # turtle.goto(-1,-3) # turtle.seth(90) # turtle.down() # turtle.fd(6) # turtle.up() # turtle.goto(1,-3) # turtle.seth(90) # turtle.down() # turtle.fd(6) # def draw_circle(x,y): # turtle.up() # turtle.goto(x,y-0.75) # turtle.seth(0) # turtle.color('yellow') # turtle.down() # turtle.circle(0.75, steps=100) # def draw_x(x,y): # turtle.color('light blue') # turtle.up() # turtle.goto(x-0.75,y-0.75) # turtle.down() # turtle.goto(x+0.75,y+0.75) # turtle.up() # turtle.goto(x-0.75,y+0.75) # turtle.down() # turtle.goto(x+0.75,y-0.75) # def draw_piece(i,j,p): # if p==0: return # x,y = 2*(j-1), -2*(i-1) # if p==1: # draw_x(x,y) # else: # draw_circle(x,y) # def draw(b): # draw_board() # for i in range(3): # for j in range(3): # draw_piece(i,j,b[i][j]) # screen.update() # # return 1 if player 1 wins, 2 if player 2 wins, 3 if tie, 0 if game is not over # def gameover(b): # if b[0][0]>0 and b[0][0] == b[0][1] and b[0][1] == b[0][2]: return b[0][0] # if b[1][0]>0 and b[1][0] == b[1][1] and b[1][1] == b[1][2]: return b[1][0] # if b[2][0]>0 and b[2][0] == b[2][1] and b[2][1] == b[2][2]: return b[2][0] # if b[0][0]>0 and b[0][0] == b[1][0] and b[1][0] == b[2][0]: return b[0][0] # if b[0][1]>0 and b[0][1] == b[1][1] and b[1][1] == b[2][1]: return b[0][1] # if b[0][2]>0 and b[0][2] == b[1][2] and b[1][2] == b[2][2]: return b[0][2] # if b[0][0]>0 and b[0][0] == b[1][1] and b[1][1] == b[2][2]: return b[0][0] # if b[2][0]>0 and b[2][0] == b[1][1] and b[1][1] == b[0][2]: return b[2][0] # p = 0 # for i in range(3): # for j in range(3): # p += (1 if b[i][j] > 0 else 0) # if p==9: return 3 # else: return 0 # def play(x,y): # global turn # if turn=='x': return # i = 3-int(y+5)//2 # j = int(x+5)//2 - 1 # if i>2 or j>2 or i<0 or j<0 or b[i][j]!=0: return # if turn == 'x': b[i][j], turn = 1, 'o' # else: b[i][j], turn = 2, 'x' # draw(b) # r = gameover(b) # if r==1: # screen.textinput("Game over!","X won!") # elif r==2: # screen.textinput("Game over!","O won!") # elif r==3: # screen.textinput("Game over!", "Tie!") # if r>0: turtle.bye() # _,move = max_node(b,-2,2) # b[move[0]][move[1]] = 1 # draw(b) # r = gameover(b) # if r==1: # screen.textinput("Game over!","X won!") # elif r==2: # screen.textinput("Game over!","O won!") # elif r==3: # screen.textinput("Game over!", "Tie!") # if r>0: turtle.bye() # turn = 'o' # b = [ [ 0,0,0 ], [ 0,0,0 ], [ 0,0,0 ] ] # draw(b) # turn = 'x' # screen.onclick(play) # #turtle.mainloop() # def max_node(b,alpha,beta): # r = gameover(b) # if r==1: return 1,None # elif r==2: return -1,None # elif r==3: return 0,None # score = -2 # # find all possible next moves # pm = list() # for i in range(3): # for j in range(3): # if b[i][j] == 0: pm.append((i,j)) # random.shuffle(pm) # for (i,j) in pm: # if b[i][j] == 0: # nb = copy.deepcopy(b) # nb[i][j] = 1 # cs,_ = min_node(nb,alpha,beta) # if score<cs: # score=cs # move = (i,j) # alpha = max(alpha,cs) # if alpha>=beta: return score,move # return score,move # def min_node(b,alpha,beta): # r = gameover(b) # if r==1: return 1,None # elif r==2: return -1,None # elif r==3: return 0,None # score = 2 # # find all possible next moves # pm = list() # random.shuffle(pm) # for i in range(3): # for j in range(3): # if b[i][j] == 0: pm.append((i,j)) # for (i,j) in pm: # if b[i][j] == 0: # nb = copy.deepcopy(b) # nb[i][j] = 2 # cs,_ = max_node(nb,alpha,beta) # if score>cs: # score=cs # move = (i,j) # beta = min(beta,cs) # if alpha>=beta: return score,move # return score,move # _,move = max_node(b,-2,2) # b[move[0]][move[1]] = 1 # draw(b) # turn = 1 # screen.mainloop()
Here is the code: import turtle import time import random window = turtle.Screen() window.title("Snake Game") window.bgcolor("black") window.setup(width=600, height=600) window.tracer(0) score = 0 head = turtle.Turtle() head.speed(0) head.shape("square") head.color("green") head.penup() head.goto(0, 0) head.direction = "stop" food = turtle.Turtle() food.speed(0) food.shape("circle") food.color("red") food.penup() food.goto(0, 100) segments = [] score_display = turtle.Turtle() score_display.speed(0) score_display.color("white") score_display.penup() score_display.hideturtle() score_display.goto(0, 260) score_display.write("Score: {}".format(score), align="center", font=("Courier", 24, "normal")) def go_up(): if head.direction != "down": head.direction = "up" def go_down(): if head.direction != "up": head.direction = "down" def go_left(): if head.direction != "right": head.direction = "left" def go_right(): if head.direction != "left": head.direction = "right" def move(): global score if head.direction == "up": y = head.ycor() head.sety(y + 20) if head.direction == "down": y = head.ycor() head.sety(y - 20) if head.direction == "left": x = head.xcor() head.setx(x - 20) if head.direction == "right": x = head.xcor() head.setx(x + 20) window.listen() window.onkeypress(go_up, "Up") window.onkeypress(go_down, "Down") window.onkeypress(go_left, "Left") window.onkeypress(go_right, "Right") while True: window.update() if ( head.xcor() > 290 or head.xcor() < -290 or head.ycor() > 290 or head.ycor() < -290 ): time.sleep(1) head.goto(0, 0) head.direction = "stop" for segment in segments: segment.goto(1000, 1000) segments.clear() score = 0 if head.distance(food) < 20: x = random.randint(-290, 290) y = random.randint(-290, 290) food.goto(x, y) new_segment = turtle.Turtle() new_segment.speed(0) new_segment.shape("square") new_segment.color("green") new_segment.penup() segments.append(new_segment) score += 10 score_display.clear() score_display.write("Score: {}".format(score), align="center", font=("Courier", 24, "normal")) for index in range(len(segments) - 1, 0, -1): x = segments[index - 1].xcor() y = segments[index - 1].ycor() segments[index].goto(x, y) if len(segments) > 0: x = head.xcor() y = head.ycor() segments[0].goto(x, y) move() for segment in segments: if segment.distance(head) < 20: time.sleep(1) head.goto(0, 0) head.direction = "stop" for segment in segments: segment.goto(1000, 1000) segments.clear() score = 0 time.sleep(0.1)
Why did you import `math` and not use it? You don't need it for those simple calculations.
Math Methods Method Description math.acos() Returns the arc cosine of a number math.acosh() Returns the inverse hyperbolic cosine of a number math.asin() Returns the arc sine of a number math.asinh() Returns the inverse hyperbolic sine of a number math.atan() Returns the arc tangent of a number in radians math.atan2() Returns the arc tangent of y/x in radians math.atanh() Returns the inverse hyperbolic tangent of a number math.ceil() Rounds a number up to the nearest integer math.comb() Returns the number of ways to choose k items from n items without repetition and order math.copysign() Returns a float consisting of the value of the first parameter and the sign of the second parameter math.cos() Returns the cosine of a number math.cosh() Returns the hyperbolic cosine of a number math.degrees() Converts an angle from radians to degrees math.dist() Returns the Euclidean distance between two points (p and q), where p and q are the coordinates of that point math.erf() Returns the error function of a number math.erfc() Returns the complementary error function of a number math.exp() Returns E raised to the power of x math.expm1() Returns Ex - 1 math.fabs() Returns the absolute value of a number math.factorial() Returns the factorial of a number math.floor() Rounds a number down to the nearest integer math.fmod() Returns the remainder of x/y math.frexp() Returns the mantissa and the exponent, of a specified number math.fsum() Returns the sum of all items in any iterable (tuples, arrays, lists, etc.) math.gamma() Returns the gamma function at x math.gcd() Returns the greatest common divisor of two integers math.hypot() Returns the Euclidean norm math.isclose() Checks whether two values are close to each other, or not math.isfinite() Checks whether a number is finite or not math.isinf() Checks whether a number is infinite or not math.isnan() Checks whether a value is NaN (not a number) or not math.isqrt() Rounds a square root number downwards to the nearest integer math.ldexp() Returns the inverse of math.frexp() which is x * (2**i) of the given numbers x and i math.lgamma() Returns the log gamma value of x math.log() Returns the natural logarithm of a number, or the logarithm of number to base math.log10() Returns the base-10 logarithm of x math.log1p() Returns the natural logarithm of 1+x math.log2() Returns the base-2 logarithm of x math.perm() Returns the number of ways to choose k items from n items with order and without repetition math.pow() Returns the value of x to the power of y math.prod() Returns the product of all the elements in an iterable math.radians() Converts a degree value into radians math.remainder() Returns the closest value that can make numerator completely divisible by the denominator math.sin() Returns the sine of a number math.sinh() Returns the hyperbolic sine of a number math.sqrt() Returns the square root of a number math.tan() Returns the tangent of a number math.tanh() Returns the hyperbolic tangent of a number math.trunc() Returns the truncated integer parts of a number Math Constants Constant Description math.e Returns Euler's number (2.7182...) math.inf Returns a floating-point positive infinity math.nan Returns a floating-point NaN (Not a Number) value math.pi Returns PI (3.1415...) math.tau Returns tau (6.2831...)
What is this tool you use to write code?
Replit, it is an online editor
Pycharm is good as well
import math def add(x, y): return x + y def subtract(x, y): return x - y def multiply(x, y): return x * y def divide(x, y): return x / y print("Welcome to the simple calculator!") while True: print(" Please select an operation") print("1. Add") print("2. Subtract") print("3. Multiply") print("4. Divide") print("0. Exit") choice = input("Enter your choice (0-4): ") if choice == '0': print("Thank you for using the Simple calculator. Goodbye!") break if choice in ['1', '2', '3', '4']: num1 = float(input("enter the first number: ")) num2 = float(input("enter the second number: ")) if choice == '1': print("Result:", add(num1, num2)) elif choice == '2': print("Result:", subtract(num1, num2)) elif choice == '3': print("Result:", multiply(num1, num2)) elif choice == '4': if num2 != 0: print("Result:", divide(num1, num2)) else: print("Error: Cannot divide by zero!")
thanks for the code
Smart house👍
Thanks
It’s great! Thank you very much!
you are welcome