Skip to content

Instantly share code, notes, and snippets.

@shinysu
shinysu / game.py
Created September 18, 2021 09:25
space shoopter - Creating bullets
import pgzrun
WIDTH = 1000
HEIGHT = 700
player = Actor('playership')
player.bottom = HEIGHT
player.x = WIDTH / 2
def draw():
@shinysu
shinysu / game.py
Created September 18, 2021 07:35
Space shooter game _final gist_multiple players
import pgzrun
WIDTH = 1000
HEIGHT = 700
player = Actor('playership')
player.x = WIDTH / 2
player.y = HEIGHT - 50
@shinysu
shinysu / game.py
Created September 18, 2021 07:28
player colliding with enemy
import pgzrun
WIDTH = 1000
HEIGHT = 700
player = Actor('playership')
player.x = WIDTH / 2
player.y = HEIGHT - 50
@shinysu
shinysu / game.py
Created September 18, 2021 06:46
create enemies
import pgzrun
WIDTH = 1000
HEIGHT = 700
player = Actor('playership')
player.x = WIDTH / 2
player.y = HEIGHT - 50
@shinysu
shinysu / game.py
Created September 18, 2021 06:21
space shooter - Creating bullets
import pgzrun
WIDTH = 1000
HEIGHT = 700
player = Actor('playership')
player.x = WIDTH / 2
player.y = HEIGHT - 50
@shinysu
shinysu / rolling_dice1.py
Created September 13, 2021 12:38
rolling dice
import random
values = [1, 2, 3, 4, 5, 6]
result = random.choice(values)
print("Result of dice rolling is :", result)
@shinysu
shinysu / minimum.py
Created August 16, 2021 09:36
Day 9 Problems using lists
'''
find the minimum value in the given list
'''
def find_minimum(numbers):
minimum = numbers[0]
for x in numbers:
if x < minimum:
minimum = x
return minimum
'''
check if an element is present in the list
you can use 'in' operator to check if the element is present and 'not in' operator to check if the element is not present
'''
cart = ['ice cream', 'chocolates', 'bread', 'jam', 'butter']
item = input("Enter the element you want to search: ")
if item in cart:
print("yes, the element is present")
'''
using while loop to print numbers 1 to 10
'''
i = 1
while i <= 10:
print(i)
i = i+1
@shinysu
shinysu / app.py
Created June 19, 2021 11:06
currency_converter
from flask import Flask, render_template, request
import requests
API_KEY = 'ea23bb1bdf8801bbe0b5a7da925461ca'
app = Flask(__name__)
def convert_currency(from_currency, to_currency, amount):
url = 'http://data.fixer.io/api/latest?access_key='+API_KEY
data = requests.get(url).json()