files
This commit is contained in:
17
python/1-js-variables/README.md
Normal file
17
python/1-js-variables/README.md
Normal file
@ -0,0 +1,17 @@
|
||||
###Javascript Variables, Lists and Objects
|
||||
|
||||
Create a variable named byte and set it equal to "school".
|
||||
|
||||
Create an array named instructors and have it contain the strings "Armen", "Chris", and "Greg"
|
||||
|
||||
Create an array named students and have it contain the strings "Adolfo", "Benny", "Billy", "Brendan"
|
||||
|
||||
Create an object with the following key-value pairs- "byteAcademy":byte, "instructors":instructors, "students":students
|
||||
|
||||
Append the contents of the object to the "printout" div element. It should read like this:
|
||||
|
||||
byteAcademy - School
|
||||
|
||||
instructors - Armen, Chris, Greg
|
||||
|
||||
students - Adolfo, Benny, Billy, Brendan
|
18
python/1-js-variables/index.html
Normal file
18
python/1-js-variables/index.html
Normal file
@ -0,0 +1,18 @@
|
||||
<!doctype HTML>
|
||||
<html>
|
||||
<head>
|
||||
<link rel="stylesheet" type="text/css" href="reset.css">
|
||||
<link rel="stylesheet" type="text/css" href="main.css">
|
||||
<script src="http://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
|
||||
<script type="text/javascript" src="main.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div class = "container">
|
||||
<nav id="top">
|
||||
<h1>Javascript Variables and Objects</h1>
|
||||
</nav>
|
||||
<div id = "printout"></div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
36
python/1-js-variables/main.css
Normal file
36
python/1-js-variables/main.css
Normal file
@ -0,0 +1,36 @@
|
||||
body{
|
||||
background-color: #D1D1D1
|
||||
}
|
||||
|
||||
nav{
|
||||
position: absolute;
|
||||
background-color: black;
|
||||
width: 100%;
|
||||
height: 4em;
|
||||
top: 0;
|
||||
text-align: center;
|
||||
line-height: 4em;
|
||||
}
|
||||
|
||||
nav h1{
|
||||
font-size: 3em;
|
||||
font-family: monospace;
|
||||
color: white;
|
||||
}
|
||||
|
||||
#printout{
|
||||
width: 800px;
|
||||
min-height: 1000px;
|
||||
background-color: white;
|
||||
margin: 5em auto 0 auto;
|
||||
color: black;
|
||||
text-indent: 1em;
|
||||
}
|
||||
|
||||
#printout p{
|
||||
font-size: 2em;
|
||||
}
|
||||
|
||||
#printout p:nth-child(even) {
|
||||
background-color: #D1D1D1;
|
||||
}
|
8
python/1-js-variables/main.js
Normal file
8
python/1-js-variables/main.js
Normal file
@ -0,0 +1,8 @@
|
||||
// set your variables below
|
||||
|
||||
// all jquery dom actions can only be called inside document ready. Print your variables
|
||||
// inside document ready.
|
||||
|
||||
$(document).ready(function(){
|
||||
|
||||
})
|
47
python/1-js-variables/reset.css
Normal file
47
python/1-js-variables/reset.css
Normal file
@ -0,0 +1,47 @@
|
||||
/**
|
||||
* Eric Meyer's Reset CSS v2.0 (http://meyerweb.com/eric/tools/css/reset/)
|
||||
* http://cssreset.com
|
||||
*/
|
||||
html, body, div, span, applet, object, iframe,
|
||||
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
|
||||
a, abbr, acronym, address, big, cite, code,
|
||||
del, dfn, em, img, ins, kbd, q, s, samp,
|
||||
small, strike, strong, sub, sup, tt, var,
|
||||
b, u, i, center,
|
||||
dl, dt, dd, ol, ul, li,
|
||||
fieldset, form, label, legend,
|
||||
table, caption, tbody, tfoot, thead, tr, th, td,
|
||||
article, aside, canvas, details, embed,
|
||||
figure, figcaption, footer, header, hgroup,
|
||||
menu, nav, output, ruby, section, summary,
|
||||
time, mark, audio, video {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
border: 0;
|
||||
font-size: 100%;
|
||||
font: inherit;
|
||||
vertical-align: baseline;
|
||||
}
|
||||
/* HTML5 display-role reset for older browsers */
|
||||
article, aside, details, figcaption, figure,
|
||||
footer, header, hgroup, menu, nav, section {
|
||||
display: block;
|
||||
}
|
||||
body {
|
||||
line-height: 1;
|
||||
}
|
||||
ol, ul {
|
||||
list-style: none;
|
||||
}
|
||||
blockquote, q {
|
||||
quotes: none;
|
||||
}
|
||||
blockquote:before, blockquote:after,
|
||||
q:before, q:after {
|
||||
content: '';
|
||||
content: none;
|
||||
}
|
||||
table {
|
||||
border-collapse: collapse;
|
||||
border-spacing: 0;
|
||||
}
|
39
python/10-reverse-polish-notation/README.md
Normal file
39
python/10-reverse-polish-notation/README.md
Normal file
@ -0,0 +1,39 @@
|
||||
Reverse Polish Notation
|
||||
=======================
|
||||
|
||||
You've never done it until you've done it reverse polish.
|
||||
|
||||
I don't know what that means, but check this out on [reverse polish notation](http://en.wikipedia.org/wiki/Reverse_Polish_notation).
|
||||
|
||||
Reverse polish notation is a mathematical notation in which every operator follows all of its operands. For example:
|
||||
|
||||
3 4 + >>> 7
|
||||
4 2 / >>> 2
|
||||
10 7 2 - * 5 / >>> 10
|
||||
|
||||
Write a program that accepts a RPN equation as a command line argument, such that you would execute your program:
|
||||
|
||||
python3 rpn_calc.py 10 9 - 5 +
|
||||
|
||||
Which would then return you 6, the result of that equation.
|
||||
|
||||
###ARGV
|
||||
|
||||
To run the program like this you need to import the sys library and access sys.argv.
|
||||
|
||||
ARGV gives us the arguments used to launch the program as an array. The first position is always the application name / file. The next are all others divided by spaces.
|
||||
|
||||
Read about sys.argv [here](http://www.pythonforbeginners.com/system/python-sys-argv)
|
||||
|
||||
Sandbox with this so you know what you are getting as an input.
|
||||
|
||||
Here's a nice hint - we can "slice" arrays in Python like in JS just by doing:
|
||||
|
||||
array = ['hi', 'wut', 'm8', 'lol', 'doge']
|
||||
array[2:4] ### returns ['m8', 'lol']
|
||||
|
||||
###Testing
|
||||
|
||||
Write some assert statements after you've solved the challenge.
|
||||
|
||||
NOTE: You might need to escape the multiplication operator * when you pass it in.
|
0
python/10-reverse-polish-notation/rpncalc.py
Normal file
0
python/10-reverse-polish-notation/rpncalc.py
Normal file
20
python/11-factorial/README.md
Normal file
20
python/11-factorial/README.md
Normal file
@ -0,0 +1,20 @@
|
||||
Factorial!
|
||||
==========
|
||||
|
||||
Get the factorial of a given number. Using sys.argv, pass in a number and return it's factorial.
|
||||
|
||||
To calculate the factorial of 5, for example, the equation is:
|
||||
|
||||
5 * 4 * 3 * 2 * 1 ###120
|
||||
|
||||
###Iterative
|
||||
|
||||
Write the equation iteratively, using a for or while loop. How to use loops in Python is well documented [here](https://docs.python.org/3.4/tutorial/controlflow.html)
|
||||
|
||||
###Recursive
|
||||
|
||||
Now write this function recursively. If you run into difficulty, think about how your stack will develop as your function recurses and remember to define your base case.
|
||||
|
||||
Write assert statements to test your code in both cases.
|
||||
|
||||
[Wikipedia on Factorials](http://en.wikipedia.org/wiki/Factorial)
|
13
python/11-factorial/factorial_iterative.py
Normal file
13
python/11-factorial/factorial_iterative.py
Normal file
@ -0,0 +1,13 @@
|
||||
import sys
|
||||
|
||||
def factorial(num):
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#write assert statements below
|
||||
|
||||
assert(factorial(5) == 120), "5! should return 120"
|
||||
assert(factorial(20) == 2432902008176640000), "Well that escalated quickly"
|
13
python/11-factorial/factorial_recursive.py
Normal file
13
python/11-factorial/factorial_recursive.py
Normal file
@ -0,0 +1,13 @@
|
||||
import sys
|
||||
|
||||
def factorial(num):
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#write assert statements below
|
||||
|
||||
assert(factorial(5) == 120), "5! should return 120"
|
||||
assert(factorial(20) == 2432902008176640000), "Well that escalated quickly"
|
16
python/12-is-palindrome/README.md
Normal file
16
python/12-is-palindrome/README.md
Normal file
@ -0,0 +1,16 @@
|
||||
Sarah Palindrome
|
||||
============
|
||||
|
||||
Write a function that when given a word or sentence returns True if it is a palindrome and False if it isn't.
|
||||
|
||||
Your program should accept input using sys.argv.
|
||||
|
||||
python3 palindrome.py Taco Cat ###returns true
|
||||
|
||||
###OOP
|
||||
|
||||
Let's make sure this program adheres to good object oriented design. Your main function should ONLY check if it is a palindrome and return True or False. Any other functions you might need, like string operations - should be seperated. Every function should do only one thing.
|
||||
|
||||
|
||||
Make the asserts pass and write more assert statements to test your code.
|
||||
|
14
python/12-is-palindrome/palindrome.py
Normal file
14
python/12-is-palindrome/palindrome.py
Normal file
@ -0,0 +1,14 @@
|
||||
import sys
|
||||
|
||||
def is_palindrome(string):
|
||||
pass
|
||||
##this function should only check validity of the string, and rely on other functions for string operations
|
||||
|
||||
|
||||
|
||||
|
||||
#assert statements
|
||||
|
||||
assert(is_palindrome('greg is the man') == False), "Presumably random sentence should return false"
|
||||
|
||||
assert(is_palindrome('No Mel Gibson is a casino’s big lemon') == True), "Palindrome should return true"
|
9
python/13-string-scramble/README.md
Normal file
9
python/13-string-scramble/README.md
Normal file
@ -0,0 +1,9 @@
|
||||
String Scramble
|
||||
===============
|
||||
|
||||
Write an algorithm that takes a string, and checks if all of the letters of the string are inside of a second string. For example:
|
||||
|
||||
string_scramble('hello', 'goodbye') ##false
|
||||
string_scramble('hello', 'lolfrhe') ##true
|
||||
|
||||
Write your own assert statements.
|
2
python/13-string-scramble/scramble.py
Normal file
2
python/13-string-scramble/scramble.py
Normal file
@ -0,0 +1,2 @@
|
||||
def string_scramble(string_one, string_two):
|
||||
pass
|
9
python/14-largest-prime-factor/README.md
Normal file
9
python/14-largest-prime-factor/README.md
Normal file
@ -0,0 +1,9 @@
|
||||
Largest Prime Factor
|
||||
====================
|
||||
|
||||
Write a function that takes a number as input, and returns the largest prime factor of a given number. If the number is prime itself, then it's largest prime factor is itself.
|
||||
|
||||
largest_prime(15) ### 5
|
||||
largest_prime(18) ### 3
|
||||
largest_prime(19) ### 19
|
||||
largest_prime(302) ### 151
|
1
python/14-largest-prime-factor/primes.py
Normal file
1
python/14-largest-prime-factor/primes.py
Normal file
@ -0,0 +1 @@
|
||||
def largest_prime(number):
|
12
python/15-sieve-of-eratosthenes/README.md
Normal file
12
python/15-sieve-of-eratosthenes/README.md
Normal file
@ -0,0 +1,12 @@
|
||||
Sieve of Eratosthenes
|
||||
=====================
|
||||
|
||||
The [Sieve of Eratosthenes](http://en.wikipedia.org/wiki/Sieve_of_Eratosthenes) is an algorithm used to determine all the prime numbers below a given number.
|
||||
|
||||
###Pseudocode
|
||||
|
||||
Use the wikipedia explanation above (under the "Example" header) to write some pseudocode to solve this problem. Here is a [pseudocode refresher](http://www.unf.edu/~broggio/cop2221/2221pseu.htm). Write this in comments at the top of the sieve.py file.
|
||||
|
||||
###Solve in Python
|
||||
|
||||
Write a function that implements this algorithm to determine all the prime numbers below a given number. The program should take a number as an argument, and return an array of all the primes.
|
6
python/15-sieve-of-eratosthenes/sieve.py
Normal file
6
python/15-sieve-of-eratosthenes/sieve.py
Normal file
@ -0,0 +1,6 @@
|
||||
###PSEUDOCODE HERE
|
||||
|
||||
|
||||
|
||||
|
||||
###real code below
|
21
python/16-benchmark/README.md
Normal file
21
python/16-benchmark/README.md
Normal file
@ -0,0 +1,21 @@
|
||||
Benchmarking your Code
|
||||
=======================
|
||||
|
||||
How fast is your code? Do you want to find out? Yes!
|
||||
|
||||
###Write a Benchmark function
|
||||
|
||||
Write a Benchmark function that takes the following as inputs:
|
||||
|
||||
-the function you want to benchmark
|
||||
- the amount of times you want it to run
|
||||
|
||||
and have your Benchmark function return the total amount of time it took.
|
||||
|
||||
The datetime library is imported at the top of the file. Look it up and how it's going to help you solve this problem. Do not import any other libraries.
|
||||
|
||||
###Test your Factorial Functions
|
||||
|
||||
Test your Iterative Factorial function versus your recursive - which is faster??
|
||||
|
||||
Import this file into atleast one other of your assignments today and test some of your functions.
|
6
python/16-benchmark/benchmark.py
Normal file
6
python/16-benchmark/benchmark.py
Normal file
@ -0,0 +1,6 @@
|
||||
import datetime
|
||||
import imp
|
||||
##what is this code doing? figure out how to call your fibonacci functions in this file.
|
||||
fibonacci = imp.load_source('fibonacci', '../2-is-fibonacci/fibonacci.py')
|
||||
|
||||
def benchmark(func, times):
|
20
python/2-js-objects/README.md
Normal file
20
python/2-js-objects/README.md
Normal file
@ -0,0 +1,20 @@
|
||||
###Javascript Objects In Depth
|
||||
|
||||
Model these people as objects:
|
||||
|
||||
Name: Michaela
|
||||
Gender: Female
|
||||
Height in cm: 178
|
||||
Job: Visual Artist
|
||||
Parents: Aimee, Louis
|
||||
Pets: Fezzy, Rufus
|
||||
|
||||
Name: Steve
|
||||
Gender: Male
|
||||
Height in cm: 160
|
||||
Job: Graphic Designer
|
||||
Nickname: The Cow
|
||||
Friends: Stephen, Stephanie, Stefan
|
||||
Jobs: Graphic Designer at Acme Corp, Bartender at Banter
|
||||
|
||||
Write them to the "printout" div similarly to how they are listed above.
|
18
python/2-js-objects/index.html
Normal file
18
python/2-js-objects/index.html
Normal file
@ -0,0 +1,18 @@
|
||||
<!doctype HTML>
|
||||
<html>
|
||||
<head>
|
||||
<link rel="stylesheet" type="text/css" href="reset.css">
|
||||
<link rel="stylesheet" type="text/css" href="main.css">
|
||||
<script src="http://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
|
||||
<script type="text/javascript" src="main.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div class = "container">
|
||||
<nav id="top">
|
||||
<h1>Javascript Objects In Depth</h1>
|
||||
</nav>
|
||||
<div id = "printout"></div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
36
python/2-js-objects/main.css
Normal file
36
python/2-js-objects/main.css
Normal file
@ -0,0 +1,36 @@
|
||||
body{
|
||||
background-color: #D1D1D1
|
||||
}
|
||||
|
||||
nav{
|
||||
position: absolute;
|
||||
background-color: black;
|
||||
width: 100%;
|
||||
height: 4em;
|
||||
top: 0;
|
||||
text-align: center;
|
||||
line-height: 4em;
|
||||
}
|
||||
|
||||
nav h1{
|
||||
font-size: 3em;
|
||||
font-family: monospace;
|
||||
color: white;
|
||||
}
|
||||
|
||||
#printout{
|
||||
width: 800px;
|
||||
min-height: 1000px;
|
||||
background-color: white;
|
||||
margin: 5em auto 0 auto;
|
||||
color: black;
|
||||
text-indent: 1em;
|
||||
}
|
||||
|
||||
#printout p{
|
||||
font-size: 2em;
|
||||
}
|
||||
|
||||
#printout p:nth-child(even) {
|
||||
background-color: #D1D1D1;
|
||||
}
|
8
python/2-js-objects/main.js
Normal file
8
python/2-js-objects/main.js
Normal file
@ -0,0 +1,8 @@
|
||||
// set your variables below
|
||||
|
||||
// all jquery dom actions can only be called inside document ready. Print your variables
|
||||
// inside document ready.
|
||||
|
||||
$(document).ready(function(){
|
||||
|
||||
})
|
47
python/2-js-objects/reset.css
Normal file
47
python/2-js-objects/reset.css
Normal file
@ -0,0 +1,47 @@
|
||||
/**
|
||||
* Eric Meyer's Reset CSS v2.0 (http://meyerweb.com/eric/tools/css/reset/)
|
||||
* http://cssreset.com
|
||||
*/
|
||||
html, body, div, span, applet, object, iframe,
|
||||
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
|
||||
a, abbr, acronym, address, big, cite, code,
|
||||
del, dfn, em, img, ins, kbd, q, s, samp,
|
||||
small, strike, strong, sub, sup, tt, var,
|
||||
b, u, i, center,
|
||||
dl, dt, dd, ol, ul, li,
|
||||
fieldset, form, label, legend,
|
||||
table, caption, tbody, tfoot, thead, tr, th, td,
|
||||
article, aside, canvas, details, embed,
|
||||
figure, figcaption, footer, header, hgroup,
|
||||
menu, nav, output, ruby, section, summary,
|
||||
time, mark, audio, video {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
border: 0;
|
||||
font-size: 100%;
|
||||
font: inherit;
|
||||
vertical-align: baseline;
|
||||
}
|
||||
/* HTML5 display-role reset for older browsers */
|
||||
article, aside, details, figcaption, figure,
|
||||
footer, header, hgroup, menu, nav, section {
|
||||
display: block;
|
||||
}
|
||||
body {
|
||||
line-height: 1;
|
||||
}
|
||||
ol, ul {
|
||||
list-style: none;
|
||||
}
|
||||
blockquote, q {
|
||||
quotes: none;
|
||||
}
|
||||
blockquote:before, blockquote:after,
|
||||
q:before, q:after {
|
||||
content: '';
|
||||
content: none;
|
||||
}
|
||||
table {
|
||||
border-collapse: collapse;
|
||||
border-spacing: 0;
|
||||
}
|
73
python/3-conditionals-and-for-loops/README.md
Normal file
73
python/3-conditionals-and-for-loops/README.md
Normal file
@ -0,0 +1,73 @@
|
||||
####Conditionals and For Loops
|
||||
|
||||
Get ready for FizzBuzz!
|
||||
|
||||
This is a classic programming test - that yes, you will actually see at job interviews.
|
||||
|
||||
It basically just checks if you can write a for loop and if you know what [modulo](http://en.wikipedia.org/wiki/Modulo_operation) is.
|
||||
|
||||
###For Loop
|
||||
|
||||
This is the most basic loop we write in Javascript, and most languages for that matter. The ubiquitous For Loop.
|
||||
|
||||
for(var i = 0; i<=100; i++){ console.log(x) }
|
||||
|
||||
In the first argument, we declare an incrementing variable, i, and where it will start. We could have called it anything.
|
||||
|
||||
In the second argument, we state the conditions under which the following code should be executing. In this case, it is while i is less than or equal to 100.
|
||||
|
||||
In the third argument, we say that every time the code is run, i should increment by 1. i++ is shorthand, also known as [syntactic sugar](http://en.wikipedia.org/wiki/Syntactic_sugar) for i += 1, or i = i + 1. They all do the same thing.
|
||||
|
||||
To get a slightly different view of it, we could do it this way.
|
||||
|
||||
for(var x = 500; x > 150; x-=5){ console.log(x) }
|
||||
|
||||
Try it in your browser or node console and watch it work. What is the last number it prints? Why?
|
||||
|
||||
###Conditionals - If / Else
|
||||
|
||||
The most simple conditional statement is the if statement. This is also ubiquitous across many programming languages.
|
||||
|
||||
Basically it is written like this:
|
||||
|
||||
if(some condition){
|
||||
do this
|
||||
}
|
||||
|
||||
You can make it more powerful by specifying an else. This is a catch all for things to do if the first condition isnt met. For example:
|
||||
|
||||
if(cute store clerk has brown hair){
|
||||
give phone number
|
||||
} else {
|
||||
leave store
|
||||
}
|
||||
|
||||
Finally, we can specify multiple outcomes using an else if.
|
||||
|
||||
if(cute clerk has brown hair){
|
||||
give phone number
|
||||
} elseif(cute clerk has blond hair) {
|
||||
get phone number
|
||||
} else {
|
||||
buy playstation
|
||||
}
|
||||
|
||||
Instead of this plain english example, also known as [Pseudocode](http://en.wikipedia.org/wiki/Pseudocode)
|
||||
|
||||
Get the idea?
|
||||
|
||||
###Fizzbuzz
|
||||
|
||||
Ok, now onto FizzBuzz.
|
||||
|
||||
Open the main.js file and find the loop inside the document ready.
|
||||
|
||||
Write code that does the following:
|
||||
|
||||
if i is divisable by 3, append a line that reads "Fizz"
|
||||
|
||||
if i is divisable by 5, append a line that reads "Buzz"
|
||||
|
||||
if i is divisable by 3 & 5, append a line that reads "FizzBuzz"
|
||||
|
||||
All this should be done as usual, to the printout div.
|
18
python/3-conditionals-and-for-loops/index.html
Normal file
18
python/3-conditionals-and-for-loops/index.html
Normal file
@ -0,0 +1,18 @@
|
||||
<!doctype HTML>
|
||||
<html>
|
||||
<head>
|
||||
<link rel="stylesheet" type="text/css" href="reset.css">
|
||||
<link rel="stylesheet" type="text/css" href="main.css">
|
||||
<script src="http://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
|
||||
<script type="text/javascript" src="main.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div class = "container">
|
||||
<nav id="top">
|
||||
<h1>FizzBuzz</h1>
|
||||
</nav>
|
||||
<div id = "printout"></div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
36
python/3-conditionals-and-for-loops/main.css
Normal file
36
python/3-conditionals-and-for-loops/main.css
Normal file
@ -0,0 +1,36 @@
|
||||
body{
|
||||
background-color: #D1D1D1
|
||||
}
|
||||
|
||||
nav{
|
||||
position: absolute;
|
||||
background-color: black;
|
||||
width: 100%;
|
||||
height: 4em;
|
||||
top: 0;
|
||||
text-align: center;
|
||||
line-height: 4em;
|
||||
}
|
||||
|
||||
nav h1{
|
||||
font-size: 3em;
|
||||
font-family: monospace;
|
||||
color: white;
|
||||
}
|
||||
|
||||
#printout{
|
||||
width: 800px;
|
||||
min-height: 1000px;
|
||||
background-color: white;
|
||||
margin: 5em auto 0 auto;
|
||||
color: black;
|
||||
text-indent: 1em;
|
||||
}
|
||||
|
||||
#printout p{
|
||||
font-size: 2em;
|
||||
}
|
||||
|
||||
#printout p:nth-child(even) {
|
||||
background-color: #D1D1D1;
|
||||
}
|
12
python/3-conditionals-and-for-loops/main.js
Normal file
12
python/3-conditionals-and-for-loops/main.js
Normal file
@ -0,0 +1,12 @@
|
||||
// set your variables below
|
||||
|
||||
// all jquery dom actions can only be called inside document ready. Print your variables
|
||||
// inside document ready.
|
||||
|
||||
$(document).ready(function(){
|
||||
|
||||
for(var i = 0; i<=100; i++){
|
||||
|
||||
}
|
||||
|
||||
})
|
47
python/3-conditionals-and-for-loops/reset.css
Normal file
47
python/3-conditionals-and-for-loops/reset.css
Normal file
@ -0,0 +1,47 @@
|
||||
/**
|
||||
* Eric Meyer's Reset CSS v2.0 (http://meyerweb.com/eric/tools/css/reset/)
|
||||
* http://cssreset.com
|
||||
*/
|
||||
html, body, div, span, applet, object, iframe,
|
||||
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
|
||||
a, abbr, acronym, address, big, cite, code,
|
||||
del, dfn, em, img, ins, kbd, q, s, samp,
|
||||
small, strike, strong, sub, sup, tt, var,
|
||||
b, u, i, center,
|
||||
dl, dt, dd, ol, ul, li,
|
||||
fieldset, form, label, legend,
|
||||
table, caption, tbody, tfoot, thead, tr, th, td,
|
||||
article, aside, canvas, details, embed,
|
||||
figure, figcaption, footer, header, hgroup,
|
||||
menu, nav, output, ruby, section, summary,
|
||||
time, mark, audio, video {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
border: 0;
|
||||
font-size: 100%;
|
||||
font: inherit;
|
||||
vertical-align: baseline;
|
||||
}
|
||||
/* HTML5 display-role reset for older browsers */
|
||||
article, aside, details, figcaption, figure,
|
||||
footer, header, hgroup, menu, nav, section {
|
||||
display: block;
|
||||
}
|
||||
body {
|
||||
line-height: 1;
|
||||
}
|
||||
ol, ul {
|
||||
list-style: none;
|
||||
}
|
||||
blockquote, q {
|
||||
quotes: none;
|
||||
}
|
||||
blockquote:before, blockquote:after,
|
||||
q:before, q:after {
|
||||
content: '';
|
||||
content: none;
|
||||
}
|
||||
table {
|
||||
border-collapse: collapse;
|
||||
border-spacing: 0;
|
||||
}
|
72
python/4-while-loops-and-for-each/README.md
Normal file
72
python/4-while-loops-and-for-each/README.md
Normal file
@ -0,0 +1,72 @@
|
||||
####While and For Each Loops
|
||||
|
||||
In this challenge, we're going to write a while loop, a For In loop, and nest them.
|
||||
|
||||
###While Loops
|
||||
|
||||
A while loop iterates until a condition is no longer true. For example:
|
||||
|
||||
while(greg == alive){
|
||||
live_year(1)
|
||||
age++
|
||||
}
|
||||
|
||||
Seemingly, a while loop could be endless. In that case, we have to break it. Take the following example:
|
||||
|
||||
i = 0
|
||||
|
||||
while(true){
|
||||
i++
|
||||
print("I'm an endless loop")
|
||||
if(i >= 50){
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
This will run exactly 50 times.
|
||||
|
||||
###For In
|
||||
|
||||
A For In loop iterates through each index in the data structure. In an array, an index is an integer, that starts at 0. Take this example:
|
||||
|
||||
var array = ['john', 'bobby', 'homa', 'stevie', 'rob']
|
||||
|
||||
for(var i in array){
|
||||
console.log(i) // prints 0, 1, 2, 3, 4
|
||||
}
|
||||
|
||||
In an object however, the index is a string. Check this out:
|
||||
|
||||
var obj = {'john': 'student', 'bobby': 'programmer', 'homa': 'actress', 'stevie': 'gamer'}
|
||||
|
||||
for(var k in obj){
|
||||
console.log(k) // prints 'john', 'bobby', 'homa', 'stevie'
|
||||
}
|
||||
|
||||
###Sandbox
|
||||
|
||||
Try this on your own in your node console or browser console. Declare some objects, iterate through them, print them out.
|
||||
|
||||
Also check out [.forEach](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/forEach)
|
||||
|
||||
###Multiplication Tables
|
||||
|
||||
Using any loop / loops of your choosing, write code that prints the multiplication tables up to a number input by the user in a form.
|
||||
|
||||
Create the form that gets the user input yourself above the #printout div, and append the result to the printout div.
|
||||
|
||||
Bonus if you actually use a table.
|
||||
|
||||
Your return should look something like this:
|
||||
|
||||
// userinput = 7
|
||||
|
||||
0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 |
|
||||
1 | 1 | 2 | 3 | 4 | 5 | 6 | 7 |
|
||||
2 | 2 | 4 | 6 | 8 | 10| 12| 14|
|
||||
3 | 3 | 6 | 9 | 12| 15| 18| 21|
|
||||
4 | 4 | 8 | 12| 16| 20| 24| 28|
|
||||
5 | 5 | 10| 15| 20| 25| 30| 35|
|
||||
6 | 6 | 12| 18| 24| 30| 36| 42|
|
||||
7 | 7 | 14| 21| 28| 35| 42| 49|
|
||||
|
18
python/4-while-loops-and-for-each/index.html
Normal file
18
python/4-while-loops-and-for-each/index.html
Normal file
@ -0,0 +1,18 @@
|
||||
<!doctype HTML>
|
||||
<html>
|
||||
<head>
|
||||
<link rel="stylesheet" type="text/css" href="reset.css">
|
||||
<link rel="stylesheet" type="text/css" href="main.css">
|
||||
<script src="http://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
|
||||
<script type="text/javascript" src="main.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div class = "container">
|
||||
<nav id="top">
|
||||
<h1>Multiplication Tables</h1>
|
||||
</nav>
|
||||
<div id = "printout"></div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
36
python/4-while-loops-and-for-each/main.css
Normal file
36
python/4-while-loops-and-for-each/main.css
Normal file
@ -0,0 +1,36 @@
|
||||
body{
|
||||
background-color: #D1D1D1
|
||||
}
|
||||
|
||||
nav{
|
||||
position: absolute;
|
||||
background-color: black;
|
||||
width: 100%;
|
||||
height: 4em;
|
||||
top: 0;
|
||||
text-align: center;
|
||||
line-height: 4em;
|
||||
}
|
||||
|
||||
nav h1{
|
||||
font-size: 3em;
|
||||
font-family: monospace;
|
||||
color: white;
|
||||
}
|
||||
|
||||
#printout{
|
||||
width: 800px;
|
||||
min-height: 1000px;
|
||||
background-color: white;
|
||||
margin: 5em auto 0 auto;
|
||||
color: black;
|
||||
text-indent: 1em;
|
||||
}
|
||||
|
||||
#printout p{
|
||||
font-size: 2em;
|
||||
}
|
||||
|
||||
#printout p:nth-child(even) {
|
||||
background-color: #D1D1D1;
|
||||
}
|
8
python/4-while-loops-and-for-each/main.js
Normal file
8
python/4-while-loops-and-for-each/main.js
Normal file
@ -0,0 +1,8 @@
|
||||
// set your variables below
|
||||
|
||||
// all jquery dom actions can only be called inside document ready. Print your variables
|
||||
// inside document ready.
|
||||
|
||||
$(document).ready(function(){
|
||||
|
||||
})
|
47
python/4-while-loops-and-for-each/reset.css
Normal file
47
python/4-while-loops-and-for-each/reset.css
Normal file
@ -0,0 +1,47 @@
|
||||
/**
|
||||
* Eric Meyer's Reset CSS v2.0 (http://meyerweb.com/eric/tools/css/reset/)
|
||||
* http://cssreset.com
|
||||
*/
|
||||
html, body, div, span, applet, object, iframe,
|
||||
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
|
||||
a, abbr, acronym, address, big, cite, code,
|
||||
del, dfn, em, img, ins, kbd, q, s, samp,
|
||||
small, strike, strong, sub, sup, tt, var,
|
||||
b, u, i, center,
|
||||
dl, dt, dd, ol, ul, li,
|
||||
fieldset, form, label, legend,
|
||||
table, caption, tbody, tfoot, thead, tr, th, td,
|
||||
article, aside, canvas, details, embed,
|
||||
figure, figcaption, footer, header, hgroup,
|
||||
menu, nav, output, ruby, section, summary,
|
||||
time, mark, audio, video {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
border: 0;
|
||||
font-size: 100%;
|
||||
font: inherit;
|
||||
vertical-align: baseline;
|
||||
}
|
||||
/* HTML5 display-role reset for older browsers */
|
||||
article, aside, details, figcaption, figure,
|
||||
footer, header, hgroup, menu, nav, section {
|
||||
display: block;
|
||||
}
|
||||
body {
|
||||
line-height: 1;
|
||||
}
|
||||
ol, ul {
|
||||
list-style: none;
|
||||
}
|
||||
blockquote, q {
|
||||
quotes: none;
|
||||
}
|
||||
blockquote:before, blockquote:after,
|
||||
q:before, q:after {
|
||||
content: '';
|
||||
content: none;
|
||||
}
|
||||
table {
|
||||
border-collapse: collapse;
|
||||
border-spacing: 0;
|
||||
}
|
19
python/5-triangles-part-1/README.md
Normal file
19
python/5-triangles-part-1/README.md
Normal file
@ -0,0 +1,19 @@
|
||||
####Print a Triangle
|
||||
|
||||
##Using nested for loops, print a triangle like so:
|
||||
|
||||
`*`
|
||||
`**`
|
||||
`***`
|
||||
`****`
|
||||
`*****`
|
||||
`******`
|
||||
`*******`
|
||||
`********`
|
||||
`*********`
|
||||
`**********`
|
||||
|
||||
This triangle is 10 high, but I want the ability to make it as high as I want by setting one variable.
|
||||
|
||||
You can print this to the console or to the printout div.
|
||||
|
18
python/5-triangles-part-1/index.html
Normal file
18
python/5-triangles-part-1/index.html
Normal file
@ -0,0 +1,18 @@
|
||||
<!doctype HTML>
|
||||
<html>
|
||||
<head>
|
||||
<link rel="stylesheet" type="text/css" href="reset.css">
|
||||
<link rel="stylesheet" type="text/css" href="main.css">
|
||||
<script src="http://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
|
||||
<script type="text/javascript" src="main.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div class = "container">
|
||||
<nav id="top">
|
||||
<h1>Triangles Part 1</h1>
|
||||
</nav>
|
||||
<div id = "printout"></div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
41
python/5-triangles-part-1/main.css
Normal file
41
python/5-triangles-part-1/main.css
Normal file
@ -0,0 +1,41 @@
|
||||
body{
|
||||
background-color: #D1D1D1
|
||||
}
|
||||
|
||||
nav{
|
||||
position: absolute;
|
||||
background-color: black;
|
||||
width: 100%;
|
||||
height: 4em;
|
||||
top: 0;
|
||||
text-align: center;
|
||||
line-height: 4em;
|
||||
}
|
||||
|
||||
nav h1{
|
||||
font-size: 3em;
|
||||
font-family: monospace;
|
||||
color: white;
|
||||
}
|
||||
|
||||
#numberform{
|
||||
margin: 5em auto 0 auto;
|
||||
width: 20%;
|
||||
}
|
||||
|
||||
#printout{
|
||||
width: 800px;
|
||||
min-height: 1000px;
|
||||
background-color: white;
|
||||
margin: 1em auto 0 auto;
|
||||
color: black;
|
||||
text-indent: 1em;
|
||||
}
|
||||
|
||||
#printout p{
|
||||
font-size: 2em;
|
||||
}
|
||||
|
||||
#printout p:nth-child(even) {
|
||||
background-color: #D1D1D1;
|
||||
}
|
6
python/5-triangles-part-1/main.js
Normal file
6
python/5-triangles-part-1/main.js
Normal file
@ -0,0 +1,6 @@
|
||||
// all jquery dom actions can only be called inside document ready.
|
||||
|
||||
$(document).ready(function(){
|
||||
|
||||
|
||||
})
|
47
python/5-triangles-part-1/reset.css
Normal file
47
python/5-triangles-part-1/reset.css
Normal file
@ -0,0 +1,47 @@
|
||||
/**
|
||||
* Eric Meyer's Reset CSS v2.0 (http://meyerweb.com/eric/tools/css/reset/)
|
||||
* http://cssreset.com
|
||||
*/
|
||||
html, body, div, span, applet, object, iframe,
|
||||
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
|
||||
a, abbr, acronym, address, big, cite, code,
|
||||
del, dfn, em, img, ins, kbd, q, s, samp,
|
||||
small, strike, strong, sub, sup, tt, var,
|
||||
b, u, i, center,
|
||||
dl, dt, dd, ol, ul, li,
|
||||
fieldset, form, label, legend,
|
||||
table, caption, tbody, tfoot, thead, tr, th, td,
|
||||
article, aside, canvas, details, embed,
|
||||
figure, figcaption, footer, header, hgroup,
|
||||
menu, nav, output, ruby, section, summary,
|
||||
time, mark, audio, video {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
border: 0;
|
||||
font-size: 100%;
|
||||
font: inherit;
|
||||
vertical-align: baseline;
|
||||
}
|
||||
/* HTML5 display-role reset for older browsers */
|
||||
article, aside, details, figcaption, figure,
|
||||
footer, header, hgroup, menu, nav, section {
|
||||
display: block;
|
||||
}
|
||||
body {
|
||||
line-height: 1;
|
||||
}
|
||||
ol, ul {
|
||||
list-style: none;
|
||||
}
|
||||
blockquote, q {
|
||||
quotes: none;
|
||||
}
|
||||
blockquote:before, blockquote:after,
|
||||
q:before, q:after {
|
||||
content: '';
|
||||
content: none;
|
||||
}
|
||||
table {
|
||||
border-collapse: collapse;
|
||||
border-spacing: 0;
|
||||
}
|
24
python/6-triangles-part-2/README.md
Normal file
24
python/6-triangles-part-2/README.md
Normal file
@ -0,0 +1,24 @@
|
||||
Print a Mario End of Level Stairs
|
||||
=======================================
|
||||
|
||||
Remember this from Mario?
|
||||
<img src = 'http://www.nintendoninja.com/images/stairs.png'></img>
|
||||
|
||||
###Create it!
|
||||
|
||||
*
|
||||
**
|
||||
***
|
||||
****
|
||||
*****
|
||||
******
|
||||
*******
|
||||
********
|
||||
*********
|
||||
**********
|
||||
|
||||
This triangle is 10 high, but I want the ability to make it as high as I want by setting one variable. You must print this in the console.
|
||||
|
||||
###Stretch
|
||||
Make it awesome! Download some images and use jQuery to print them and get an actual set of mario stairs on the page. Feel free to remove the printout div or whatever you might have to do to make the images fit.
|
||||
|
18
python/6-triangles-part-2/index.html
Normal file
18
python/6-triangles-part-2/index.html
Normal file
@ -0,0 +1,18 @@
|
||||
<!doctype HTML>
|
||||
<html>
|
||||
<head>
|
||||
<link rel="stylesheet" type="text/css" href="reset.css">
|
||||
<link rel="stylesheet" type="text/css" href="main.css">
|
||||
<script src="http://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
|
||||
<script type="text/javascript" src="main.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div class = "container">
|
||||
<nav id="top">
|
||||
<h1>Triangles Part 2</h1>
|
||||
</nav>
|
||||
<div id = "printout"></div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
41
python/6-triangles-part-2/main.css
Normal file
41
python/6-triangles-part-2/main.css
Normal file
@ -0,0 +1,41 @@
|
||||
body{
|
||||
background-color: #D1D1D1
|
||||
}
|
||||
|
||||
nav{
|
||||
position: absolute;
|
||||
background-color: black;
|
||||
width: 100%;
|
||||
height: 4em;
|
||||
top: 0;
|
||||
text-align: center;
|
||||
line-height: 4em;
|
||||
}
|
||||
|
||||
nav h1{
|
||||
font-size: 3em;
|
||||
font-family: monospace;
|
||||
color: white;
|
||||
}
|
||||
|
||||
#numberform{
|
||||
margin: 5em auto 0 auto;
|
||||
width: 20%;
|
||||
}
|
||||
|
||||
#printout{
|
||||
width: 800px;
|
||||
min-height: 1000px;
|
||||
background-color: white;
|
||||
margin: 1em auto 0 auto;
|
||||
color: black;
|
||||
text-indent: 1em;
|
||||
}
|
||||
|
||||
#printout p{
|
||||
font-size: 2em;
|
||||
}
|
||||
|
||||
#printout p:nth-child(even) {
|
||||
background-color: #D1D1D1;
|
||||
}
|
6
python/6-triangles-part-2/main.js
Normal file
6
python/6-triangles-part-2/main.js
Normal file
@ -0,0 +1,6 @@
|
||||
// all jquery dom actions can only be called inside document ready.
|
||||
|
||||
$(document).ready(function(){
|
||||
|
||||
|
||||
})
|
47
python/6-triangles-part-2/reset.css
Normal file
47
python/6-triangles-part-2/reset.css
Normal file
@ -0,0 +1,47 @@
|
||||
/**
|
||||
* Eric Meyer's Reset CSS v2.0 (http://meyerweb.com/eric/tools/css/reset/)
|
||||
* http://cssreset.com
|
||||
*/
|
||||
html, body, div, span, applet, object, iframe,
|
||||
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
|
||||
a, abbr, acronym, address, big, cite, code,
|
||||
del, dfn, em, img, ins, kbd, q, s, samp,
|
||||
small, strike, strong, sub, sup, tt, var,
|
||||
b, u, i, center,
|
||||
dl, dt, dd, ol, ul, li,
|
||||
fieldset, form, label, legend,
|
||||
table, caption, tbody, tfoot, thead, tr, th, td,
|
||||
article, aside, canvas, details, embed,
|
||||
figure, figcaption, footer, header, hgroup,
|
||||
menu, nav, output, ruby, section, summary,
|
||||
time, mark, audio, video {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
border: 0;
|
||||
font-size: 100%;
|
||||
font: inherit;
|
||||
vertical-align: baseline;
|
||||
}
|
||||
/* HTML5 display-role reset for older browsers */
|
||||
article, aside, details, figcaption, figure,
|
||||
footer, header, hgroup, menu, nav, section {
|
||||
display: block;
|
||||
}
|
||||
body {
|
||||
line-height: 1;
|
||||
}
|
||||
ol, ul {
|
||||
list-style: none;
|
||||
}
|
||||
blockquote, q {
|
||||
quotes: none;
|
||||
}
|
||||
blockquote:before, blockquote:after,
|
||||
q:before, q:after {
|
||||
content: '';
|
||||
content: none;
|
||||
}
|
||||
table {
|
||||
border-collapse: collapse;
|
||||
border-spacing: 0;
|
||||
}
|
24
python/7-todo-list/README.md
Normal file
24
python/7-todo-list/README.md
Normal file
@ -0,0 +1,24 @@
|
||||
To Do List
|
||||
==========
|
||||
|
||||
When it comes to learning new web languages, the todo list has become a "Hello World". So expect to revisit this in Python.
|
||||
|
||||
But until then, we will do it in front-end Javascript.
|
||||
|
||||
You will find the toDoList prototype and constructor at the top of the main.js file.
|
||||
|
||||
###Create the List
|
||||
|
||||
The add method adds a todo to the list, using the text input and form.
|
||||
|
||||
The complete method marks the appropriate todo item complete. The user wants to click the item itself and strike the item, noting it done.
|
||||
|
||||
Use toggle to toggle it done struck and unstruck.
|
||||
|
||||
Feel free to add any other methods, lists or objects you may want. You will want a separate function to print the list to the #printout div.
|
||||
|
||||
###Woah! Client's demands have changed
|
||||
|
||||
Now the client who was going to buy your sweet todo list wants a new feature. Is it going to break your whole code, or is your code modular and extendable?
|
||||
|
||||
They want it so after a user completes a task, it is displayed struck for 10 seconds, but then disappears from your list. Google the setTimeout method.
|
22
python/7-todo-list/index.html
Normal file
22
python/7-todo-list/index.html
Normal file
@ -0,0 +1,22 @@
|
||||
<!doctype HTML>
|
||||
<html>
|
||||
<head>
|
||||
<link rel="stylesheet" type="text/css" href="reset.css">
|
||||
<link rel="stylesheet" type="text/css" href="main.css">
|
||||
<script src="http://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
|
||||
<script type="text/javascript" src="main.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div class = "container">
|
||||
<nav id="top">
|
||||
<h1>To Do List</h1>
|
||||
</nav>
|
||||
<form id="todoform" action="#" method="post">
|
||||
<input type="text" id= "todo" name="todo" placeholder="Enter Your Todo">
|
||||
<input type="submit" value="Add" id="addTodo">
|
||||
</form>
|
||||
<div id = "printout"></div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
|
41
python/7-todo-list/main.css
Normal file
41
python/7-todo-list/main.css
Normal file
@ -0,0 +1,41 @@
|
||||
body{
|
||||
background-color: #D1D1D1
|
||||
}
|
||||
|
||||
nav{
|
||||
position: absolute;
|
||||
background-color: black;
|
||||
width: 100%;
|
||||
height: 4em;
|
||||
top: 0;
|
||||
text-align: center;
|
||||
line-height: 4em;
|
||||
}
|
||||
|
||||
nav h1{
|
||||
font-size: 3em;
|
||||
font-family: monospace;
|
||||
color: white;
|
||||
}
|
||||
|
||||
#todoform{
|
||||
margin: 5em auto 0 auto;
|
||||
width: 20%;
|
||||
}
|
||||
|
||||
#printout{
|
||||
width: 800px;
|
||||
min-height: 1000px;
|
||||
background-color: white;
|
||||
margin: 1em auto 0 auto;
|
||||
color: black;
|
||||
text-indent: 1em;
|
||||
}
|
||||
|
||||
#printout p{
|
||||
font-size: 2em;
|
||||
}
|
||||
|
||||
#printout p:nth-child(even) {
|
||||
background-color: #D1D1D1;
|
||||
}
|
20
python/7-todo-list/main.js
Normal file
20
python/7-todo-list/main.js
Normal file
@ -0,0 +1,20 @@
|
||||
// all jquery dom actions can only be called inside document ready.
|
||||
|
||||
function toDoList(){
|
||||
|
||||
}
|
||||
|
||||
toDoList.prototype.add = function(todo){
|
||||
|
||||
}
|
||||
|
||||
toDoList.prototype.complete = function(todo){
|
||||
|
||||
}
|
||||
|
||||
var myList = new toDoList();
|
||||
|
||||
$(document).ready(function(){
|
||||
|
||||
|
||||
})
|
47
python/7-todo-list/reset.css
Normal file
47
python/7-todo-list/reset.css
Normal file
@ -0,0 +1,47 @@
|
||||
/**
|
||||
* Eric Meyer's Reset CSS v2.0 (http://meyerweb.com/eric/tools/css/reset/)
|
||||
* http://cssreset.com
|
||||
*/
|
||||
html, body, div, span, applet, object, iframe,
|
||||
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
|
||||
a, abbr, acronym, address, big, cite, code,
|
||||
del, dfn, em, img, ins, kbd, q, s, samp,
|
||||
small, strike, strong, sub, sup, tt, var,
|
||||
b, u, i, center,
|
||||
dl, dt, dd, ol, ul, li,
|
||||
fieldset, form, label, legend,
|
||||
table, caption, tbody, tfoot, thead, tr, th, td,
|
||||
article, aside, canvas, details, embed,
|
||||
figure, figcaption, footer, header, hgroup,
|
||||
menu, nav, output, ruby, section, summary,
|
||||
time, mark, audio, video {
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
border: 0;
|
||||
font-size: 100%;
|
||||
font: inherit;
|
||||
vertical-align: baseline;
|
||||
}
|
||||
/* HTML5 display-role reset for older browsers */
|
||||
article, aside, details, figcaption, figure,
|
||||
footer, header, hgroup, menu, nav, section {
|
||||
display: block;
|
||||
}
|
||||
body {
|
||||
line-height: 1;
|
||||
}
|
||||
ol, ul {
|
||||
list-style: none;
|
||||
}
|
||||
blockquote, q {
|
||||
quotes: none;
|
||||
}
|
||||
blockquote:before, blockquote:after,
|
||||
q:before, q:after {
|
||||
content: '';
|
||||
content: none;
|
||||
}
|
||||
table {
|
||||
border-collapse: collapse;
|
||||
border-spacing: 0;
|
||||
}
|
10
python/8-fizz-buzz-again/README.md
Normal file
10
python/8-fizz-buzz-again/README.md
Normal file
@ -0,0 +1,10 @@
|
||||
I'm Fizz Buzzing Bro
|
||||
====================
|
||||
|
||||
Write a function that takes a positive number, and returns you the sum of all multiples of 3 and 5, but not numbers that are multiples of 15.
|
||||
|
||||
In Python, here is how we define a function:
|
||||
|
||||
def multiples(num):
|
||||
algorithm ##indentation is mandatory
|
||||
return(sum) ##this is it, no closure!
|
1
python/8-fizz-buzz-again/multiples.py
Normal file
1
python/8-fizz-buzz-again/multiples.py
Normal file
@ -0,0 +1 @@
|
||||
def multiples(number):
|
17
python/9a-temperature-converter/README.md
Normal file
17
python/9a-temperature-converter/README.md
Normal file
@ -0,0 +1,17 @@
|
||||
Temperature Converters
|
||||
======================
|
||||
|
||||
###Fahrenheit to Celsius
|
||||
Write a function that converts fahrenheit temperatures to celsius. The equation to do this is:
|
||||
|
||||
C = (F - 32) * 5/9
|
||||
|
||||
###Celsius to Fahrenheit
|
||||
|
||||
Write a similar function that converts celsius to fahrenheit. The equation:
|
||||
|
||||
F = (C * 9/5) + 32
|
||||
|
||||
###Testing
|
||||
|
||||
Make sure the tests pass. Write 3 of your own tests.
|
12
python/9a-temperature-converter/temp.py
Normal file
12
python/9a-temperature-converter/temp.py
Normal file
@ -0,0 +1,12 @@
|
||||
def fahrenheit_to_celsius(temp):
|
||||
pass
|
||||
|
||||
def celsius_to_fahrenheit(temp):
|
||||
pass
|
||||
|
||||
|
||||
assert(fahrenheit_to_celsius(32) == 0), "Freezing temp should return true"
|
||||
assert(fahrenheit_to_celsius(212) == 100), "Boiling temp should return true"
|
||||
assert(fahrenheit_to_celsius(-13) == -25), "Negative number should return true"
|
||||
assert(celsius_to_fahrenheit(37) == 98.6), "Body temp should return true"
|
||||
assert(celsius_to_fahrenheit(10) == 50), "Random temp should return true"
|
14
python/9b-is-fibonacci/README.md
Normal file
14
python/9b-is-fibonacci/README.md
Normal file
@ -0,0 +1,14 @@
|
||||
##The Fibonacci Sequence
|
||||
|
||||
The fibonacci sequence are the numbers in the following integer sequence:
|
||||
|
||||
0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, ...and so on
|
||||
|
||||
Write a function that detects whether its input is a fibonacci number or not.
|
||||
|
||||
Make sure the assert statements all pass. Write two of your own Python assert statements.
|
||||
|
||||
Resources
|
||||
=========
|
||||
[Fibonacci Numbers](http://en.wikipedia.org/wiki/Fibonacci_number)
|
||||
[Fibonacci in Nature](http://jwilson.coe.uga.edu/emat6680/parveen/fib_nature.htm)
|
16
python/9b-is-fibonacci/fibonacci.py
Normal file
16
python/9b-is-fibonacci/fibonacci.py
Normal file
@ -0,0 +1,16 @@
|
||||
def fibonacci(num):
|
||||
pass
|
||||
|
||||
|
||||
|
||||
# FOR TESTING ONLY
|
||||
import random
|
||||
def random_fibonacci():
|
||||
fib = [0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181, 6765, 10946, 17711, 28657, 46368, 75025]
|
||||
return random.sample(fib, 1)[0]
|
||||
|
||||
assert(fibonacci(random_fibonacci()) == True), "Random Fibonacci number should return true"
|
||||
assert(fibonacci(50) == False), "50 should return false"
|
||||
assert(fibonacci(97450) == False), "50 should return false"
|
||||
assert(fibonacci(1) == True), "1 should return true"
|
||||
assert(fibonacci(7540113804746346429) == True), "A massive number in sequence should return true"
|
Reference in New Issue
Block a user