Python syntax here : 2.7 - online REPL
Javascript ES6 via Babel transpilation - online REPL
import math
""" | |
pirple.com/python | |
Homework #1: Variables | |
The purpose of this file is to get familiar with the variables and how we assign different values to them. | |
Additionally you get to know how single and multiline comments work in Python. | |
Run this file from terminal: python3 main.py | |
""" |
""" | |
pirple.com/python | |
Homework Assignment #3: "If" Statements | |
If conditionals. | |
Create a function that accepts 3 parameters and checks for equality between any two of them. | |
Your function should return True if 2 or more of the parameters are equal, | |
and false is none of them are equal to any of the others. |
""" | |
pirple.com/python | |
Homework Assignment #4: Lists | |
Create a global variable called myUniqueList. It should be an empty list to start. | |
Next, create a function that allows you to add things to that list. | |
Anything that's passed to this function should get added to myUniqueList, | |
unless its value already exists in myUniqueList. | |
If the value doesn't exist already it should be added and the function should return True. |
""" | |
pirple.com/python | |
Python Home Assignment #5: Basic Loops | |
You're about to do an assignment called "Fizz Buzz", which is one of the classic programming challenges. | |
It is a favorite for interviewers, and a shocking number of job-applicants can't get it right. | |
But you won't be one of those people. Here are the rules for the assignment (as specified by Imran Gory): | |
- Write a program that prints the numbers from 1 to 100. | |
- But for multiples of three print "Fizz" instead of the number and for the multiples of five print "Buzz". |
""" | |
A collection of useful tips when working with Python 3 | |
""" | |
import json | |
# from collections import Hashable | |
from random import choice, randrange | |
# Check if sth is "hashable" cause Sets only store unique and hashable items | |
# Whereas Lists can store anything | |
# print("Is empty object {} hashable? -> {0:b} ") |
""" | |
pirple.com/python | |
Python Homework Assignment #7: Dictionaries and Sets | |
Details: | |
Return to your first homework assignments, when you described your favorite song. | |
Refactor that code so all the variables are held as dictionary keys and value. | |
Then refactor your print statements so that it's a single loop that passes through each item in the dictionary | |
and prints out it's key and then it's value. |
""" | |
pirple.com/python | |
Python Homework Assignment #6: Advanced Loops | |
Details: | |
Create a function that takes in two parameters: rows, and columns, both of which are integers. | |
The function should then proceed to draw a playing board (as in the examples from the lectures) | |
the same number of rows and columns as specified. After drawing the board, your function should return True. |
""" | |
Python Homework Assignment #8: Input and Output (I/O) | |
Details: | |
Create a note-taking program. When a user starts it up, it should prompt them for a filename. | |
If they enter a file name that doesn't exist, it should prompt them to enter the text they want to write to the file. After they enter the text, it should save the file and exit. | |
If they enter a file name that already exists, it should ask the user if they want: | |
A) Read the file | |
B) Delete the file and start over |
Python syntax here : 2.7 - online REPL
Javascript ES6 via Babel transpilation - online REPL
import math
import { useState, useEffect } from 'react'; | |
// Usage | |
function App() { | |
// Call our hook for each key that we'd like to monitor | |
const happyPress = useKeyPress('h'); | |
const sadPress = useKeyPress('s'); | |
const robotPress = useKeyPress('r'); | |
const foxPress = useKeyPress('f'); |