This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pgzrun | |
WIDTH = 1000 | |
HEIGHT = 700 | |
player = Actor('playership') | |
player.x = WIDTH / 2 | |
player.y = HEIGHT - 50 | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random | |
values = [1, 2, 3, 4, 5, 6] | |
result = random.choice(values) | |
print("Result of dice rolling is :", result) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' | |
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' | |
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") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' | |
using while loop to print numbers 1 to 10 | |
''' | |
i = 1 | |
while i <= 10: | |
print(i) | |
i = i+1 | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from flask import Flask, render_template,request | |
app = Flask(__name__) | |
@app.route('/', methods=["GET", "POST"]) | |
def index(): | |
if request.method == "POST": | |
from_currency = request.form["from_currency"] | |
to_currency = request.form["to_currency"] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from flask import Flask, render_template, redirect, url_for, request, session, flash | |
from datetime import timedelta | |
from db_functions import get_password, insert_user | |
app = Flask(__name__) | |
app.secret_key = "123@abc" | |
app.permanent_session_lifetime = timedelta(minutes=5) | |
def set_session(email): #{"logged_in": True, "email"='[email protected]'} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from flask import Flask, render_template, redirect, url_for, request, session | |
from datetime import timedelta | |
from db_functions import get_password, insert_user | |
app = Flask(__name__) | |
app.secret_key = "123@abc" | |
app.permanent_session_lifetime = timedelta(minutes=5) | |
def set_session(email): #{"logged_in": True, "email"='[email protected]'} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from flask import Flask, render_template, redirect, url_for, request, session | |
from db_functions import get_password, insert_user | |
app = Flask(__name__) | |
app.secret_key = "123@abc" | |
def set_session(email): #{"logged_in": True, "email"='[email protected]'} | |
session["logged_in"] = True | |
session["email"] = email |