Posts

Number Guessing Game in Python

 Number Guessing Game Introduction of game:   Very simple game in python which is suitable for beginners of python learner. The user makes a guess and the system tell whether the guess is high or low? and this process continues until the user makes it right under the given chances. There are basically two level of game, Hard and Easy: in the hard level user will get 5 chances and on the Easy level user will have 10 chances.  First   #Create main.py file and paste the following code from art import logo from random import random import math print(logo) print("Welcome to the Number Guess Game!") print("I think of a number between 1 and 100") HARD_LEVEL_CHANCE = 5 EASY_LEVEL_CHANCE = 10 difficulty_level = input("Choose level, 'hard' or 'easy':\n").lower() answer = math.ceil(random()*100) end = False def check_answer(guess, answer, count): print(f"{level - count} times remaning") if guess > answer: return "Too high...

Chrome: Hack Dino Game

Image
Dinosaurs game hack in chrome: We can easily hack the dino game in chrome on the client-side by manipulating its speed. Now let's start hack: follow these steps to hack the game, Step 1: Right-click on your (Mouse or touchpad) Now you can see few options like back, forward, reload, save as .... Ignore all these and  goto  Step 2: Inspect, or Inspect element Then the developer tab will appear shortly,  Step 3: Go to the "console" menu Step 4: Type the following code and hit enter   Runner.instance_.setSpeed(2000) Step 5: Hit Enter Now you can play the game at a much higher speed, where no obstacle will hinder you. 

Bounce Ball Game in Python

  Create main.py file and paste the following code from turtle import Turtle, Screen from paddle import Paddle from ball import Ball import time from score_board import ScoreBoard screen = Screen() screen.listen() screen.setup(height=600, width=1000) screen.title( "PinPong Game" ) screen.bgcolor( "Black" ) screen.tracer(0) r_paddle = Paddle((480, 0)) l_paddle = Paddle((-490, 0)) ball = Ball((0, 0)) screen.onkey(r_paddle.move_up, "Up" ) screen.onkey(r_paddle.move_down, "Down" ) screen.onkey(l_paddle.move_up, "w" ) screen.onkey(l_paddle.move_down, "s" ) score = ScoreBoard() game_on = True while game_on: screen.update() time.sleep(ball.bounce_speed) ball.change_location() if ball.ycor() < -275 or ball.ycor() > 280: ball.bounce_on_wall() elif ball.distance(l_paddle) < 50 and ball.xcor() < -460: score.score_update_l() ball.bounce_on_peddle() elif ball.distance(r_paddle) ...

Simple Snake Game in Python

 Create main.py  file and paste the following code import turtle as t import time import snake from food import Food screen = t.Screen() screen.setup(height=600, width=600) screen.bgcolor( "black" ) screen.title( "Snake Game" ) screen.tracer(0) screen.listen() cobra = snake.Snake() food = Food() screen.onkey(cobra.up, "Up" ) screen.onkey(cobra.down, "Down" ) screen.onkey(cobra.left, "Left" ) screen.onkey(cobra.right, "Right" ) while True : screen.update() time.sleep(0.1) cobra.snake_move() if food.distance(cobra.segment[0]) < 15: food.refresh() screen.exitonclick() Create Food.py file and paste the following code from turtle import Turtle import random class Food(Turtle): def __init__(self): super().__init__() self.shape( "circle" ) self.penup() self.color( "Yellow" ) self.shapesize(stretch_len=0.5, stretch_wid=0.5) self.speed( ...

Simple Turtle Race Game with Python

 Create main.py file and paste the following code import turtle as t screen = t.Screen() screen.setup( height = 500 , width = 600 ) uer_bet = screen.textinput( prompt = "Guess, which turtle would win the race?" , title = "Input color name" ) colors = [ "red" , "brown" , "cyan" , "green" , "orange" , "pink" ] y_position = [ 0 , - 30 , 30 , - 60 , 60 , 90 ] import random all_turtles = [] run = True for turtle in range ( 0 , 6 ): turtles = t.Turtle( shape = "turtle" ) turtles.penup() turtles.goto( x =- 250 , y =y_position[turtle]) turtles.color(colors[turtle]) all_turtles.append(turtles) turtle_speed = [ 10 , 15 , 20 , 25 , 30 , 5 ] def random_walk(turtles): global run for turtle in turtles: turtle.forward(random.choice(turtle_speed)) if turtle.xcor() > 250 : run = False while run: random_walk(all_turtles) screen.exitonclick() # Thats it,...

Coffee machine coding in Python

 Create main.py file and paste the code below from menu import Menu, MenuItem from coffee_maker import CoffeeMaker from money_machine import MoneyMachine menu = Menu() coffeemaker = CoffeeMaker() moneymachine = MoneyMachine() # menuitem = MenuItem() machine_on = True while machine_on: user_input = input("What would you like to have? ") if user_input == 'report': print(coffeemaker.report()) elif user_input == 'off': machine_on = False else: item = menu.find_drink(user_input) is_available = coffeemaker.is_resource_sufficient(item) if is_available: recieve_money = moneymachine.make_payment(item.cost) if recieve_money: coffeemaker.make_coffee(item) Create Coffeemaker.py file and paste the code below class CoffeeMaker: """Models the machine that makes the coffee""" def __init__(self): self.resources = { "water": 300, "milk"...

Quiz game in Python

 Create main.py and paste code below from game_data import data import random from art import logo, vs from replit import clear def get_random_account(): """Get data from random account""" return random.choice(data) def format_data(account): """Format account into printable format: name, description and country""" name = account["name"] description = account["description"] country = account["country"] # print(f'{name}: {account["follower_count"]}') return f"{name}, a {description}, from {country}" def check_answer(guess, a_followers, b_followers): """Checks followers against user's guess and returns True if they got it right. Or False if they got it wrong.""" if a_followers > b_followers: return guess == "a" else: return guess == "b" def game(): print(logo) score = 0 game_sh...