Category Archives: Uncategorized

Turtle graphics

 

Description:

This project is about  turtle forward a random distance between 0 and 150 pixels and 45 angle in red background. it make line randomly. HERE IS CODE FOR THIS PROJECT:

import turtle
import random

t = turtle.Turtle()
r = random.Random()

window = turtle.Screen()

window.bgcolor(‘red’)                                 # it’s for screen color.
t.pencolor(‘white’)                                        #it’s for pen color.

for x in range(100):                                        #range for x
angle = random.randint(0,45)
t.right(angle)                                                     # for angle
distance = random.randint(0,150)
t.forward (distance)
t.backward (distance)
distance = random.randint(0,150)
t.forward (distance)
t.backward (distance)
distance = random.randint(0,150)
t.forward (distance)
t.backward (distance)

 

Guess the number game

import random
randomNumber = random.randrange(0,100)
guessed = False
while guessed==False:
userInput = int(input(“Your guess please: “))
if userInput==randomNumber:
guessed = True
print(“congratulate”)
elif userInput>100:
print(“Our guess range is between 0 and 100, please try a bit lower”)
elif userInput<0:
print(“Our guess range is between 0 and 100, please try a bit higher”)
elif userInput>randomNumber:
print(“Try one more time, a bit lower”)
elif userInput < randomNumber:
print(“Try one more time, a bit higher”)

 

Description:

This is a guess game made by python program. Every time a user guess a number, If the user’s guess is higher that the random number the program should display “Too high, please try again.” and if it is lower that it will print too low and when user guess number matched with random number it will say congratulate.