Posts

Turtle_race_game python

 Turtle_Race_Game   import turtle import random # create window wn = turtle . Screen () wn . title ( "Turtle_Race" ) wn . bgcolor ( "blue" ) #turtle turtle . color ( 'white' ) turtle . speed ( 0 ) turtle . penup () turtle . goto (- 140 , 140 ) for i in range ( 15 ):     turtle . write ( i )     turtle . right ( 90 )     turtle . forward ( 10 )     turtle . pendown ()     turtle . forward ( 350 )     turtle . penup ()     turtle . backward ( 360 )     turtle . left ( 90 )     turtle . forward ( 20 ) # players 1 to 5 player1 = turtle . Turtle () player1 . color ( "red" ) player1 . shape ( "turtle" ) player1 . shapesize ( 2 ) #player1.speed(0) player1 . penup () player1 . goto (- 170 , 100 ) player1 . pendown ()\ player2 = turtle . Turtle () player2 . color ( "green" ) player2 . shape ( "turtle" ) player2 . shapesize ( 2 ) #player2.speed(0) player2 . penup () player2 . goto (- 170 , 40 ) player2 . pendown () playe

Python_Task_Assignment

Python_Task_Assignment Task 1 We have declared a tuple containing five same elements as following: T = (‘python’, ‘python’, ‘python’, ‘python’, ‘python’). Re-write the same code in an optimal/simple way that fetches the same result ?. # Tuple having names my_tuple = ( 'python' , ) * 5 print ( my_tuple )   ('python', 'python', 'python', 'python', 'python') Task 2 Write code to print characters from a string that are present at an even index number. For example, if your input string is "python", the output characters will be (p,t,o). # read a string str = input ( "Enter a string \n " ) # create a string with characters at multiples of 2 modified_string = str [:: 2 ] print ( modified_string ) pto Task 3 Write a function that calculates the average of the elements of the list:elements = [5, 7, 4, 9, 2] elements = [ 5 , 7 , 4 , 9 , 2 ] # using sum() method count = sum ( elements ) # finding average avg = count / len (

PYTHON QUIZ GAME GUI FROM SHRIHITH A

PYTHON QUIZ GAME GUI FROM SHRIHITH A import tkinter from tkinter import * from tkinter import font import random questions = [     "Total keywords in python ?" ,     "which of the following function takes A console in python ?" ,     "Output of 2**3  ?" ,     "Which of the following is must to execute a python code ?" ,     "Output of np.arrange(1,5) ?" ,     "The append Method adds value to the list at the ?" ,     "Keyword use to declare function ?" ,     "Output of 2*21  ?" ,     "Which of the following keyword is used to create a function in Python ?" ,     "To Declare a Global variable in python we use the keyword ?" , ] answer_choice = [     [ '33' , '31' , '30' , '32' ],     [ 'get()' , 'input()' , 'gets()' , 'scan()' ],     [ '6' , '8' , '9' , '12' ],     [ 'TURBO c'