diff --git a/DDao_python/python/checkerboard/checker.py b/DDao_python/python/checkerboard/checker.py new file mode 100644 index 0000000..f5fb8af --- /dev/null +++ b/DDao_python/python/checkerboard/checker.py @@ -0,0 +1,2 @@ +for star in range(0, 3): + print "****\n ****" \ No newline at end of file diff --git a/DDao_python/python/coin_tosses/cointosses.py b/DDao_python/python/coin_tosses/cointosses.py new file mode 100644 index 0000000..c76ea07 --- /dev/null +++ b/DDao_python/python/coin_tosses/cointosses.py @@ -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) diff --git a/DDao_python/python/compare_lists/comparelists.py b/DDao_python/python/compare_lists/comparelists.py new file mode 100644 index 0000000..a8a7dc0 --- /dev/null +++ b/DDao_python/python/compare_lists/comparelists.py @@ -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." \ No newline at end of file diff --git a/DDao_python/python/dictionary_basics/dictionary.py b/DDao_python/python/dictionary_basics/dictionary.py new file mode 100644 index 0000000..2a4caa0 --- /dev/null +++ b/DDao_python/python/dictionary_basics/dictionary.py @@ -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) + diff --git a/DDao_python/python/filterByType/filterbytype.py b/DDao_python/python/filterByType/filterbytype.py new file mode 100644 index 0000000..971d3b8 --- /dev/null +++ b/DDao_python/python/filterByType/filterbytype.py @@ -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) \ No newline at end of file diff --git a/DDao_python/python/fun_with_functions/funwithfunctions.py b/DDao_python/python/fun_with_functions/funwithfunctions.py new file mode 100644 index 0000000..e9ab653 --- /dev/null +++ b/DDao_python/python/fun_with_functions/funwithfunctions.py @@ -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 diff --git a/DDao_python/python/list_dict/list.py b/DDao_python/python/list_dict/list.py new file mode 100644 index 0000000..d526856 --- /dev/null +++ b/DDao_python/python/list_dict/list.py @@ -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) \ No newline at end of file diff --git a/DDao_python/python/mulsumavg/practice.py b/DDao_python/python/mulsumavg/practice.py new file mode 100644 index 0000000..fe2ebf2 --- /dev/null +++ b/DDao_python/python/mulsumavg/practice.py @@ -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 + + diff --git a/DDao_python/python/names/names.py b/DDao_python/python/names/names.py new file mode 100644 index 0000000..0a9830f --- /dev/null +++ b/DDao_python/python/names/names.py @@ -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) diff --git a/DDao_python/python/score_and_grade/scoreandgrade.py b/DDao_python/python/score_and_grade/scoreandgrade.py new file mode 100644 index 0000000..9bcd2b8 --- /dev/null +++ b/DDao_python/python/score_and_grade/scoreandgrade.py @@ -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) \ No newline at end of file diff --git a/DDao_python/python/stars/stars.py b/DDao_python/python/stars/stars.py new file mode 100644 index 0000000..1a25c56 --- /dev/null +++ b/DDao_python/python/stars/stars.py @@ -0,0 +1,6 @@ + +def draw_stars(arr): + for i in arr: + print i*"*" +x = [4,2,7,4,5] +draw_stars(x) diff --git a/DDao_python/python/string_lists_practice/firstandlast.py b/DDao_python/python/string_lists_practice/firstandlast.py new file mode 100644 index 0000000..5811434 --- /dev/null +++ b/DDao_python/python/string_lists_practice/firstandlast.py @@ -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 \ No newline at end of file diff --git a/DDao_python/python/string_lists_practice/minandmax.py b/DDao_python/python/string_lists_practice/minandmax.py new file mode 100644 index 0000000..eaa190c --- /dev/null +++ b/DDao_python/python/string_lists_practice/minandmax.py @@ -0,0 +1,2 @@ +x = [2,54,-2,7,12,98] +print min(x), max(x) \ No newline at end of file diff --git a/DDao_python/python/string_lists_practice/stringlistspractice.py b/DDao_python/python/string_lists_practice/stringlistspractice.py new file mode 100644 index 0000000..1c8f3ec --- /dev/null +++ b/DDao_python/python/string_lists_practice/stringlistspractice.py @@ -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) \ No newline at end of file diff --git a/DDao_python/python/tuples/tuples.py b/DDao_python/python/tuples/tuples.py new file mode 100644 index 0000000..340d54f --- /dev/null +++ b/DDao_python/python/tuples/tuples.py @@ -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) \ No newline at end of file diff --git a/DDao_python/python/typeList/typelist.py b/DDao_python/python/typeList/typelist.py new file mode 100644 index 0000000..b2509d0 --- /dev/null +++ b/DDao_python/python/typeList/typelist.py @@ -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) \ No newline at end of file diff --git a/DDao_python/python/word_list/wordlist.py b/DDao_python/python/word_list/wordlist.py new file mode 100644 index 0000000..5539e08 --- /dev/null +++ b/DDao_python/python/word_list/wordlist.py @@ -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')] \ No newline at end of file diff --git a/DDao_python/python_flask/counter/server.py b/DDao_python/python_flask/counter/server.py new file mode 100644 index 0000000..0fed769 --- /dev/null +++ b/DDao_python/python_flask/counter/server.py @@ -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) \ No newline at end of file diff --git a/DDao_python/python_flask/counter/templates/counter.html b/DDao_python/python_flask/counter/templates/counter.html new file mode 100644 index 0000000..cae6cc9 --- /dev/null +++ b/DDao_python/python_flask/counter/templates/counter.html @@ -0,0 +1,19 @@ + + +
+
+
+
+
\ No newline at end of file
diff --git a/DDao_python/python_flask/disappearing_ninja/templates/hack.html b/DDao_python/python_flask/disappearing_ninja/templates/hack.html
new file mode 100644
index 0000000..6137bc9
--- /dev/null
+++ b/DDao_python/python_flask/disappearing_ninja/templates/hack.html
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/DDao_python/python_flask/disappearing_ninja/templates/index.html b/DDao_python/python_flask/disappearing_ninja/templates/index.html
new file mode 100644
index 0000000..330edf3
--- /dev/null
+++ b/DDao_python/python_flask/disappearing_ninja/templates/index.html
@@ -0,0 +1,10 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/DDao_python/python_flask/disappearing_ninja/templates/purple.html b/DDao_python/python_flask/disappearing_ninja/templates/purple.html
new file mode 100644
index 0000000..7a6de72
--- /dev/null
+++ b/DDao_python/python_flask/disappearing_ninja/templates/purple.html
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/DDao_python/python_flask/disappearing_ninja/templates/red.html b/DDao_python/python_flask/disappearing_ninja/templates/red.html
new file mode 100644
index 0000000..030b2a9
--- /dev/null
+++ b/DDao_python/python_flask/disappearing_ninja/templates/red.html
@@ -0,0 +1,13 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/DDao_python/python_flask/dojo_survey/server.py b/DDao_python/python_flask/dojo_survey/server.py
new file mode 100644
index 0000000..2e4d7a4
--- /dev/null
+++ b/DDao_python/python_flask/dojo_survey/server.py
@@ -0,0 +1,19 @@
+from flask import Flask, render_template, request, redirect
+app = Flask(__name__)
+
+
+@app.route('/')
+def dojo_survey():
+ return render_template('dojo.html')
+
+@app.route('/result', methods=['POST'])
+def results():
+
+ name = request.form['name']
+ location = request.form['location']
+ language = request.form['language']
+ comment = request.form['comment']
+ return render_template('result.html', name=name, location=location, language=language, comment=comment)
+ return redirect('/')
+
+app.run(debug=True)
diff --git a/DDao_python/python_flask/dojo_survey/static/style.css b/DDao_python/python_flask/dojo_survey/static/style.css
new file mode 100644
index 0000000..e69de29
diff --git a/DDao_python/python_flask/dojo_survey/templates/dojo.html b/DDao_python/python_flask/dojo_survey/templates/dojo.html
new file mode 100644
index 0000000..e725842
--- /dev/null
+++ b/DDao_python/python_flask/dojo_survey/templates/dojo.html
@@ -0,0 +1,30 @@
+
+
+
+
+ Name: {{ name }}
+Dojo Location: {{ location }}
+Favorite Language: {{ language }}
+Comment: {{ comment }}
+ + + \ No newline at end of file diff --git a/DDao_python/python_flask/dojo_survey_val/server.py b/DDao_python/python_flask/dojo_survey_val/server.py new file mode 100644 index 0000000..0fe7e18 --- /dev/null +++ b/DDao_python/python_flask/dojo_survey_val/server.py @@ -0,0 +1,32 @@ +from flask import Flask, render_template, request, redirect, session, flash +import re +app = Flask(__name__) +app.secret_key = "KeepItSecret!" + +@app.route('/') +def dojo_survey(): + return render_template('index.html') + +@app.route('/result', methods=['POST']) +def results(): + + name = request.form['name'] + location = request.form['location'] + language = request.form['language'] + comment = request.form['comment'] + + if len(request.form['name']) < 1: + flash("Name cannot be empty!") + elif len(request.form['comment']) > 120: + flash("Comment cannot be more than 120 characters.") + else: + return render_template('result.html', name=name, location=location, language=language, comment=comment) + + + return redirect('/') + +@app.route('/reset') +def back(): + return render_template('index.html') + +app.run(debug=True) \ No newline at end of file diff --git a/DDao_python/python_flask/dojo_survey_val/templates/index.html b/DDao_python/python_flask/dojo_survey_val/templates/index.html new file mode 100644 index 0000000..6345c5d --- /dev/null +++ b/DDao_python/python_flask/dojo_survey_val/templates/index.html @@ -0,0 +1,43 @@ + + + + +{{message}}
+ {% endfor %} + {% endif %} + {% endwith %} + +Name: {{ name }}
+Dojo Location: {{ location }}
+Favorite Language: {{ language }}
+Comment: {{ comment }}
+ + + \ No newline at end of file diff --git a/DDao_python/python_flask/hello/test_1.py b/DDao_python/python_flask/hello/test_1.py new file mode 100644 index 0000000..1bea412 --- /dev/null +++ b/DDao_python/python_flask/hello/test_1.py @@ -0,0 +1,9 @@ +from flask import Flask +app = Flask(__name__) + +@app.route('/') +def hello_world(): + return 'My name is Anna
' + + +app.run(debug=True) \ No newline at end of file diff --git a/DDao_python/python_flask/landing_page/server.py b/DDao_python/python_flask/landing_page/server.py new file mode 100644 index 0000000..88b5074 --- /dev/null +++ b/DDao_python/python_flask/landing_page/server.py @@ -0,0 +1,20 @@ +from flask import Flask, render_template, request, redirect +app = Flask(__name__) + +@app.route('/') +def index(): + return render_template('index.html') + + +@app.route('/ninjas') +def ninjas_info(): + return render_template('ninjas.html') + +@app.route('/dojos/new', methods=['GET']) +def dojo_new(): + + return render_template('dojo.html') + return redirect('/') + + +app.run(debug=True) \ No newline at end of file diff --git a/DDao_python/python_flask/landing_page/static/css/style.css b/DDao_python/python_flask/landing_page/static/css/style.css new file mode 100644 index 0000000..e69de29 diff --git a/DDao_python/python_flask/landing_page/static/images/ninja.png b/DDao_python/python_flask/landing_page/static/images/ninja.png new file mode 100644 index 0000000..98a33ea Binary files /dev/null and b/DDao_python/python_flask/landing_page/static/images/ninja.png differ diff --git a/DDao_python/python_flask/landing_page/templates/dojo.html b/DDao_python/python_flask/landing_page/templates/dojo.html new file mode 100644 index 0000000..e6156f6 --- /dev/null +++ b/DDao_python/python_flask/landing_page/templates/dojo.html @@ -0,0 +1,16 @@ + + + + +
+ A ninja (忍者) or shinobi (忍び, "to sneak") was a covert agent or mercenary in feudal Japan. The functions of the ninja included espionage, sabotage, infiltration, assassination and guerrilla warfare. Their covert methods of waging irregular warfare were deemed dishonorable and beneath the samurai-caste, who observed strict rules about honor and combat. The shinobi proper, a specially trained group of spies and mercenaries, appeared in the 15th century during the Sengoku period, but antecedents may have existed in the 14th century,[4] and possibly in the 12th century (Heian or early Kamakura era).
+ + + \ No newline at end of file diff --git a/DDao_python/python_flask/my_name/server.py b/DDao_python/python_flask/my_name/server.py new file mode 100644 index 0000000..70f3c8d --- /dev/null +++ b/DDao_python/python_flask/my_name/server.py @@ -0,0 +1,16 @@ +from flask import Flask, render_template, request, redirect +app = Flask(__name__) + +@app.route('/') +def index(): + return render_template('index.html') + + +@app.route('/process', methods=['POST']) +def process(): + + return request.form['name'] + return redirect('/') + + +app.run(debug=True) \ No newline at end of file diff --git a/DDao_python/python_flask/my_name/templates/index.html b/DDao_python/python_flask/my_name/templates/index.html new file mode 100644 index 0000000..674db72 --- /dev/null +++ b/DDao_python/python_flask/my_name/templates/index.html @@ -0,0 +1,13 @@ + + + + +I am thinking of a number between 1 - 100
+Take a guess!
+ {% if session['guess'] %} + {% if session['guess'] == "too_low" %} +Too Low dude..
+You is too high!
+The number was {{ session['num'] }}
+ +Welcome to my portfolio! My name is Anna!
' + + +@app.route('/projects') +def projects(): + return render_template('portfolio.html') + + +@app.route('/about') +def about(): + return render_template('about.html') + +app.run(debug=True) \ No newline at end of file diff --git a/DDao_python/python_flask/portfolio/static/style.css b/DDao_python/python_flask/portfolio/static/style.css new file mode 100644 index 0000000..ce12b86 --- /dev/null +++ b/DDao_python/python_flask/portfolio/static/style.css @@ -0,0 +1,5 @@ +p{ + margin: 0px auto; + width: 960px; + font-style: italic; +} \ No newline at end of file diff --git a/DDao_python/python_flask/portfolio/templates/about.html b/DDao_python/python_flask/portfolio/templates/about.html new file mode 100644 index 0000000..87d36ad --- /dev/null +++ b/DDao_python/python_flask/portfolio/templates/about.html @@ -0,0 +1,11 @@ + + + +I am a Python web developer and love going to hackathons in my spare time. I love making things and meeting new people! People might be surprised to learn that I own a horse and used to be a horse trainer! Sorry...that was a lie...lol.
+ + \ No newline at end of file diff --git a/DDao_python/python_flask/portfolio/templates/portfolio.html b/DDao_python/python_flask/portfolio/templates/portfolio.html new file mode 100644 index 0000000..f67377f --- /dev/null +++ b/DDao_python/python_flask/portfolio/templates/portfolio.html @@ -0,0 +1,17 @@ + + + +{{message}}
+ {% endfor %} + {% endif %} + {% endwith %} + +Name: {{fname}} {{lname}}
+Email: {{email}}
+ + \ No newline at end of file diff --git a/DDao_python/python_mysql/Blogs/Blogs.mwb b/DDao_python/python_mysql/Blogs/Blogs.mwb new file mode 100644 index 0000000..097b719 Binary files /dev/null and b/DDao_python/python_mysql/Blogs/Blogs.mwb differ diff --git a/DDao_python/python_mysql/books/books.mwb b/DDao_python/python_mysql/books/books.mwb new file mode 100644 index 0000000..48099ad Binary files /dev/null and b/DDao_python/python_mysql/books/books.mwb differ diff --git a/DDao_python/python_mysql/countries/countries.mwb b/DDao_python/python_mysql/countries/countries.mwb new file mode 100644 index 0000000..469797a Binary files /dev/null and b/DDao_python/python_mysql/countries/countries.mwb differ diff --git a/DDao_python/python_mysql/user_dashboard/user_dashboard.mwb b/DDao_python/python_mysql/user_dashboard/user_dashboard.mwb new file mode 100644 index 0000000..a4feacd Binary files /dev/null and b/DDao_python/python_mysql/user_dashboard/user_dashboard.mwb differ diff --git a/DDao_python/python_mysql/workbench_setup/workbench_setup.txt b/DDao_python/python_mysql/workbench_setup/workbench_setup.txt new file mode 100644 index 0000000..b2dc983 --- /dev/null +++ b/DDao_python/python_mysql/workbench_setup/workbench_setup.txt @@ -0,0 +1,6 @@ +To do queries directly in the database, you go into your +connections; in the query box, type in your query statements. + +To connect to a specific database, type in "USE [database_name]" +in the query box. ex. " USE twitter " <-- that will connect me +to my Twitter database. \ No newline at end of file diff --git a/DDao_python/python_oop/Animal/animal.py b/DDao_python/python_oop/Animal/animal.py new file mode 100644 index 0000000..cd770ec --- /dev/null +++ b/DDao_python/python_oop/Animal/animal.py @@ -0,0 +1,48 @@ +class Animal(object): + def __init__(self, name, health): + self.name = name + self.health = health + self.display_health() + + def walk(self): + self.health -= 1 + return self + + def run(self): + self.health -= 5 + return self + + def display_health(self): + print "Name: " + str(self.name) + print "Health: " + str(self.health) + +animal1 = Animal("Thor", 100) +animal1.walk().walk().walk().run().run().display_health() + +class Dog(Animal): + def __init__(self, name, health): + super(Dog, self).__init__(name, health) + self.health = 150 + + def pet(self): + self.health += 5 + return self + +dog1 = Dog("Shaggy", 150) +dog1.walk().walk().walk().run().run().pet().display_health() + + +class Dragon(Animal): + def __init__(self, name, health): + super(Dragon, self).__init__(name, health) + self.health = 170 + + def fly(self): + self.health -= 10 + return self + + def display_health(self): + print "This is a Dragon!"+ str(self.health) + +dragon1 = Dragon("Oden", 170) +dragon1.walk().walk().walk().run().run().display_health() diff --git a/DDao_python/python_oop/Bike/bike.py b/DDao_python/python_oop/Bike/bike.py new file mode 100644 index 0000000..c0dddb7 --- /dev/null +++ b/DDao_python/python_oop/Bike/bike.py @@ -0,0 +1,39 @@ +class Bike(object): + def __init__(self, price, max_speed): + self.price = price + self.max_speed = max_speed + self.miles = 0 + + def displayinfo(self): + print "Price of the bike is: $" + str(self.price) + print "The max speed is:" + str(self.max_speed) + print "Total miles:" + str(self.miles) + + def ride(self): + print "Riding" + self.miles += 10 + + def reverse(self): + if self.miles > 0: + self.miles -=5 + print "Reversing" + +bike1 = Bike(500, 20) +bike1.ride() +bike1.ride() +bike1.ride() +bike1.reverse() +bike1.displayinfo() + +bike2 = Bike(129.99, 13) +bike2.ride() +bike2.ride() +bike2.reverse() +bike2.reverse() +bike2.displayinfo() + +bike3 = Bike(1000, 30) +bike3.reverse() +bike3.reverse() +bike3.reverse() +bike3.displayinfo() \ No newline at end of file diff --git a/DDao_python/python_oop/Car/car.py b/DDao_python/python_oop/Car/car.py new file mode 100644 index 0000000..d09d5c4 --- /dev/null +++ b/DDao_python/python_oop/Car/car.py @@ -0,0 +1,28 @@ +class Car(object): + def __init__(self, price, speed, fuel, mileage): + self.price = price + self.speed = speed + self.fuel = fuel + self.mileage = mileage + + if self.price > 10000: + self.tax = 0.15 + else: + self.tax = 0.12 + self.display_all() + + + def display_all(self): + print "Car price is $" + str(self.price) + print "Car speed is " + str(self.speed) + "mph" + print "Car fuel is " + str(self.fuel) + print "Car mileage is " + str(self.mileage) + "mpg" + print "Car Tax is " + str(self.tax) + + +car1 = Car(2000, 35, "Full", 15) +car2 = Car(2000, 5, "Not Full", 105) +car3 = Car(2000, 15, "King of Full", 95) +car4 = Car(2000, 25, "Full", 25) +car5 = Car(2000, 45, "Empty", 25) +car6 = Car(20000000, 35, "Empty", 15) \ No newline at end of file diff --git a/DDao_python/python_oop/Product/product.py b/DDao_python/python_oop/Product/product.py new file mode 100644 index 0000000..2a5bae9 --- /dev/null +++ b/DDao_python/python_oop/Product/product.py @@ -0,0 +1,47 @@ +class Product(object): + def __init__(self, price, item_name, weight, brand): + self.price = price + self.item_name = item_name + self.weight = weight + self.brand = brand + self.status = "For Sale" + self.sell() + self.add_tax() + self.reason_for_return() + self.display_info() + + def sell(self): + if self.status == "For sale": + self.status = "sold" + + def add_tax(self): + sales_tax = 0.12 + return self.price + sales_tax + + def reason_for_return(self): + returns = "defective" + box = "new" + discount = "20%" + if returns == "defective": + self.status = returns + self.price = 0 + elif box == "new": + self.status = "For Sale" + else: box != "New" + self.status = "Used " + discount + " discount" + + def display_info(self): + print "Price $" + str(self.price) + print "Item Name: " + str(self.item_name) + print "Weight: " + str(self.weight) + "lbs" + print "Brand: " + str(self.brand) + print "Status: " + str(self.status) + +product1 = Product(.32, "Tomatos", .25, "Valley", ) +product1.sell() +product1.add_tax() +product1.reason_for_return() +prodcut2 = Product(5.85, "Cheese", 2.4, "Velveeta") +product1.sell() +product1.add_tax() +product1.reason_for_return() \ No newline at end of file diff --git a/DDao_python/python_oop/call_center/ccenter.py b/DDao_python/python_oop/call_center/ccenter.py new file mode 100644 index 0000000..8564160 --- /dev/null +++ b/DDao_python/python_oop/call_center/ccenter.py @@ -0,0 +1,33 @@ +class Call(object): + def __init__(self, id, name, number): + self.unique_id = unique_id + self.caller_name = caller_name + self.caller_phone_num = caller_phone_num + self.time_of_call = time_of_call + self.reason_for_call = reason_for_call + + def display(self): + print self.unique_id + print self.caller_name + print self.caller_phone_num + print self.time_of_call + print self.reason_for_call + + +class CallCenter(object): + def __init__(self, tuple, size) + self.calls = [] + self.queue_size = len(self.calls) + + def add(self): + self.calls.append(new_call) + + def remove(self): + self.call.remove(self.calls[0]) + + def info(self): + for call in self.calls: + print self.caller_name + print self.caller_phone_num + print self.queue_size + diff --git a/DDao_python/python_oop/mathDojo/math.py b/DDao_python/python_oop/mathDojo/math.py new file mode 100644 index 0000000..3f65c4c --- /dev/null +++ b/DDao_python/python_oop/mathDojo/math.py @@ -0,0 +1,12 @@ +class Math_Dojo(object): + def __init__(self): + self.result = 0 + + def add(self): + + + def subtract(self): + + +md = Math_Dojo() +md.add(2).add(2,5).subtract(3,2).result \ No newline at end of file