Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions DDao_python/python/checkerboard/checker.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
for star in range(0, 3):
print "****\n ****"
21 changes: 21 additions & 0 deletions DDao_python/python/coin_tosses/cointosses.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import random
def coin_toss(flips):
head = 0
tails = 0
total_amnt = 0
attempts = 1
results = ""

for i in range(flips):
new_flip = random.randint(0,1)
if new_flip == 1:
head +=1
results = "head"
print "Attempt #", attempts, ": Throwing a coin...It's a ", results, "! Got ", head, "heads so far and", tails, "tails so far"
else:
tails += 1
results = "tail"
print "Attempt #", attempts, ": Throwing a coin... It's a ", results, "! Got ", head, "heads so far and", tails, "tails so far"
attempts += 1

coin_toss(5001)
27 changes: 27 additions & 0 deletions DDao_python/python/compare_lists/comparelists.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
list_one = [1,2,5,6,2]
list_two = [1,2,5,6,2]
if list_one == list_two:
print "The lists are the same."
else:
print "The lists are not the same."

list_one = [1,2,5,6,5]
list_two = [1,2,5,6,5,3]
if list_one == list_two:
print "The lists are the same."
else:
print "The lists are not the same."

list_one = [1,2,5,6,5,16]
list_two = [1,2,5,6,5]
if list_one == list_two:
print "The lists are the same."
else:
print "The lists are not the same."

list_one = ['celery','carrots','bread','milk']
list_two = ['celery','carrots','bread','cream']
if list_one == list_two:
print "The lists are the same."
else:
print "The lists are not the same."
6 changes: 6 additions & 0 deletions DDao_python/python/dictionary_basics/dictionary.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
dict = {"name": "Young", "age": "85", "country of birth": "USA", "favorite language": "Japanese"}

def dictionary():
for keys, values in dict.iteritems():
print 'My {} is {}'.format(keys, values)

16 changes: 16 additions & 0 deletions DDao_python/python/filterByType/filterbytype.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
x = 20
if x >= 100:
print "That's a big number"
elif x <= 100:
print "That's a small number"


myString = "hello guys"
if len(myString) >= 10:
print "Long sentence."
elif len(myString) <= 10:
print "Short"


list = [4,34,22,68,9,13,3,5,7,9,2,12,45,923]
print len(list)
15 changes: 15 additions & 0 deletions DDao_python/python/fun_with_functions/funwithfunctions.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
for x in range(0, 11):
if x%2 != 0:
print "Number is", x, "This is an odd number."
elif x%2 == 0:
print "Number is", x, "This is an even number."



def multiply(arr,num):
for i in range(len(arr)):
arr[i] *= num
return arr
i = [1,2,3,4,5]
b = multiply(i,5)
print b
11 changes: 11 additions & 0 deletions DDao_python/python/list_dict/list.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
name = ["Anna", "Eli", "Pariece", "Brendan", "Amy", "Shane", "Oscar"]
favorite_animal = ["horse", "cat", "spider", "giraffe", "ticks", "dolphins", "llamas"]


def make_dict(arr1, arr2):
new_dict = zip(name, favorite_animal)
new_dict2 = dict(new_dict)
print new_dict2


make_dict(name, favorite_animal)
19 changes: 19 additions & 0 deletions DDao_python/python/mulsumavg/practice.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
for x in range(1, 1000): #looping from 1 - 1000
if x%2 != 0: #if statement for odd nums
print x

count = 5
while count <= 100000000: #using while loop to get multiples of 5 to 1,000,000,000
print count
count +=5


a = [1, 2, 5, 10, 255, 3]
sum(a) #gets the sum of 'a'
print sum(a)


a = [1, 2, 5, 10, 255, 3]
print sum(a)/len(a) #telling it to print avg. You divide the sum by the length


43 changes: 43 additions & 0 deletions DDao_python/python/names/names.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
students = [
{'first_name': 'Michael', 'last_name' : 'Jordan'},
{'first_name' : 'John', 'last_name' : 'Rosales'},
{'first_name' : 'Mark', 'last_name' : 'Guillen'},
{'first_name' : 'KB', 'last_name' : 'Tonel'}
]



users = {
'Students': [
{'first_name': 'Michael', 'last_name' : 'Jordan'},
{'first_name' : 'John', 'last_name' : 'Rosales'},
{'first_name' : 'Mark', 'last_name' : 'Guillen'},
{'first_name' : 'KB', 'last_name' : 'Tonel'}
],
'Instructors': [
{'first_name' : 'Michael', 'last_name' : 'Choi'},
{'first_name' : 'Martin', 'last_name' : 'Puryear'}
]
}

def list_students(arr):
for data in students:
print data['first_name'], data['last_name']


def list_users(users):

for i in users:
counter = 0
print i
for person in users[i]:
counter += 1

first_name = person['first_name'].upper()
last_name = person['last_name'].upper()
length_name = len(first_name) + len(last_name)
print "{}-{} {}-{}".format(counter, first_name, last_name, length_name)


list_students(students)
list_users(users)
18 changes: 18 additions & 0 deletions DDao_python/python/score_and_grade/scoreandgrade.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import random

def score_grade(times):
print "Scores and Grades"
for i in range(1, times):
score = random.randint(60, 100)
if score >= 60 and score <= 69:
print "Score:", score, "Your grade is D."
elif score >= 70 and score <=79:
print "Score:", score, "Your grade is C"
elif score >= 80 and score <=89:
print "Score:", score, "Your grade is B"
elif score >= 90 and score <=100:
print "Score:", score, "Your grade is A"
else:
print "End of the program. Bye"

score_grade(11)
6 changes: 6 additions & 0 deletions DDao_python/python/stars/stars.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

def draw_stars(arr):
for i in arr:
print i*"*"
x = [4,2,7,4,5]
draw_stars(x)
4 changes: 4 additions & 0 deletions DDao_python/python/string_lists_practice/firstandlast.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
x = ["hello",2,54,-2,7,12,98,"world"]
print x[0], x[-1]
newList = x[0], x[-1]
print newList
2 changes: 2 additions & 0 deletions DDao_python/python/string_lists_practice/minandmax.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
x = [2,54,-2,7,12,98]
print min(x), max(x)
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
words = "It's thanksgiving day. It's my birthday,too!"
newWord = 'month'
print words.find('day')
print words.replace('day', newWord)
11 changes: 11 additions & 0 deletions DDao_python/python/tuples/tuples.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
my_dict = {
"Speros": "(555) 555-5555",
"Michael": "(999) 999-9999",
"Jay": "(777) 777-7777"
}

def tuple(dict):

print my_dict.items()

tuple(dict)
32 changes: 32 additions & 0 deletions DDao_python/python/typeList/typelist.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
mix_list = ['magical unicorns',19,'hello',98.98,'world']
int_list = [1,2,3,4,5]
str_list = ["Spiff", "Moon", "Robot"]


def identify_listType(list):
new_string = ''
total = 0


for value in list:
if isinstance(value, int) or isinstance(value, float):
total += value
elif isinstance(value, str):
new_string += value

if new_string and total:
print "The array you entered is of mixed type"
print "String:", new_string
print "Total:", total

elif new_string:
print "The array you entered is of string type"
print "String:",new_string

else:
print "The array you entered is of number(float or int) type"
print "Total:", total

print identify_listType(mix_list)
print identify_listType(int_list)
print identify_listType(str_list)
2 changes: 2 additions & 0 deletions DDao_python/python/word_list/wordlist.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
word_list = ['hello','world','my','name','is','Anna']
print [word for word in word_list if any(letter in word for letter in 'o')]
25 changes: 25 additions & 0 deletions DDao_python/python_flask/counter/server.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
from flask import Flask, render_template, request, redirect,session
app = Flask(__name__)
app.secret_key = "ThisisSecret"


@app.route('/')
def index():
if(session['counter'] != 0):
session['counter'] += 2

return render_template('counter.html')

@app.route('/reload', methods=['POST'])
def reload():
session['counter'] += 2

return redirect('/')

@app.route('/reset', methods=['POST'])
def reset():
session['counter'] = 0

return redirect('/')

app.run(debug=True)
19 changes: 19 additions & 0 deletions DDao_python/python_flask/counter/templates/counter.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<!DOCTYPE html>
<html>
<head>
<title>Counter</title>
</head>
<body>
<center><h1>Counter</h1></center>
<form action='/reload' method="post">
<br>
<center><button>+2</button></center>
<br>
</form>
<center>{{session['counter']}} :Times</center>
<form action='/reset' method="post">
<br>
<center><button>Return</button></center>
</form>
</body>
</html>
26 changes: 26 additions & 0 deletions DDao_python/python_flask/disappearing_ninja/server.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
from flask import Flask, render_template, request, redirect
app = Flask(__name__)

@app.route('/')
def index():
return render_template('index.html')

@app.route('/ninja')
def ninjas():
return render_template('ninjas.html')

@app.route('/ninja/<color>')
def show_turtle(color):
if color == "blue":
return render_template('blue.html')
elif color == "orange":
return render_template('orange.html')
elif color == "red":
return render_template('red.html')
elif color == "purple":
return render_template('purple.html')
elif color !="red" "purple" "blue" "orange":
return render_template('hack.html')


app.run(debug=True)
Empty file.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 12 additions & 0 deletions DDao_python/python_flask/disappearing_ninja/templates/blue.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="utf-8">
<title>It's ....</title>
<link rel="stylesheet" type="text/css" href="{{ url_for('static', filename='css/style.css') }}">
</head>
<body>
<img src="{{ url_for('static', filename='images/leonardo.jpg') }}">

</body>
</html>
13 changes: 13 additions & 0 deletions DDao_python/python_flask/disappearing_ninja/templates/hack.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="utf-8">
<title>It's ....</title>
<link rel="stylesheet" type="text/css" href="{{ url_for('static', filename='css/style.css') }}">
</head>
<body>
<h1>{{ blue }}</h1>
<img src="{{ url_for('static', filename='images/notapril.jpg') }}">

</body>
</html>
10 changes: 10 additions & 0 deletions DDao_python/python_flask/disappearing_ninja/templates/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="utf-8">
<title>Ninja Turtles</title>
</head>
<body>
<h1>No Ninjas here! AhAHahahahAaAHAHAHahaHAH!</h1>
</body>
</html>
13 changes: 13 additions & 0 deletions DDao_python/python_flask/disappearing_ninja/templates/ninjas.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="utf-8">
<title>Ninja Turtles Here</title>
<link rel="stylesheet" type="text/css" href="{{ url_for('static', filename='css/style.css') }}">
</head>
<body>
<div>
<img src="{{ url_for('static', filename='images/tmnt.png') }}">
</div>
</body>
</html>
Loading