This file contains 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
# This program is chapter 14 challenge one: | |
class Shape(): | |
def __init__(self, shape): | |
self.shape = shape | |
def what_am_i(self): | |
print("I am a {}".format(self.shape)) |
This file contains 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
function getMiddle(s){ | |
var m = s.length / 2 | |
if (s.length % 2 == 0){ | |
return s.slice(m - 1, m + 1) | |
} | |
return s.slice(m, m + 1) | |
} |
This file contains 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 | |
def rock_paper_scissors(): | |
options = ["rock", "paper", "scissors"] | |
wins = {"rock": "scissors", "scissors": "paper", "paper": "rock"} | |
player_wins = 0 | |
comp_wins = 0 | |
player_pick = None | |
name = input("What is your name?") |
This file contains 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 json, requests | |
resp = requests.get(url=url, params=params) | |
data = json.loads(resp.text) |
This file contains 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
extends signin-layout | |
block content | |
script(src="https://cdn.firebase.com/libs/firebaseui/2.4.1/firebaseui.js") | |
link(href='https://cdn.firebase.com/libs/firebaseui/2.4.1/firebaseui.css', rel='stylesheet') | |
script. | |
// FirebaseUI config. | |
var uiConfig = { | |
signInSuccessUrl: '/login', | |
signInOptions: [ |
This file contains 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
router.post('/login', function (req, res, next) { | |
var uid = req.body.uid // query | |
var displayName = req.body.display_name | |
var photoURL = req.body.photo_url | |
var email = req.body.email | |
var accessToken = req.body.authToken | |
if (uid != null) { | |
req.session.uid = uid | |
req.session.accessToken = accessToken |
This file contains 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
script(src="https://cdn.firebase.com/libs/firebaseui/2.4.1/firebaseui.js") | |
link(href='https://cdn.firebase.com/libs/firebaseui/2.4.1/firebaseui.css', rel='stylesheet') | |
script. | |
// FirebaseUI config. | |
var uiConfig = { | |
signInSuccessUrl: '/login', | |
signInOptions: [ | |
// Leave the lines as is for the providers you want to offer your users. | |
//firebase.auth.GoogleAuthProvider.PROVIDER_ID, | |
firebase.auth.FacebookAuthProvider.PROVIDER_ID, |
This file contains 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
def hangman(word): | |
wrong = 0 | |
stages = ["", | |
"________ ", | |
"| ", | |
"| | ", | |
"| 0 ", | |
"| /|\ ", | |
"| / \ ", | |
"| " |
This file contains 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
while wrong < len(stages) - 1: | |
print("\n") | |
msg = "Guess a letter" | |
char = input(msg) | |
if char in remaining_letters: | |
cind = remaining_letters.index(char) | |
board[cind] = char | |
remaining_letters[cind] = '$' | |
else: | |
wrong += 1 |
This file contains 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
if not win: | |
print("\n".join(stages[0: wrong])) | |
print("You lose! It was {}.".format(word)) | |
OlderNewer