External Exam Download Resources Web Applications Games Recycle Bin
Hello World
from flask import Flask
app = Flask(__name__)

@app.route("/")
def urlTriggerThis():
    return "<h1>hello world</h1>"

app.run(host= '0.0.0.0')

Heads Tails (web based)
from flask import Flask
app = Flask(__name__)
import random

@app.route("/")
def urlTriggerThis():
    tempNum = random.randint(1, 2)
    coinFace = flipCoinFunc(tempNum)
    markup = "<h1>"+coinFace+"</h1>"
    return markup

def flipCoinFunc(x):
    if(x==1):
        return "heads"
    else:
        return "tails"

app.run(host='0.0.0.0', port=5000)

Challenges
to refresh your python knowledge:
  1. change the coin flip app (above) to a dice roll
  2. say ready to takeoff, then use a loop to count down from 10 to 1, then say blastoff   help
  3. create the following pattern resembling a 10-pin bowling lane in the most efficient way possible:
    *
    * *
    * * *
    * * * *
  4. define a function processArray() that processes a list of 4 elements and writes them to the screen in reverse order   help
  5. challenge: currency value to text: Write a program that converts any integer or floating point value to a currency string, e.g. 4 = “four dollars”