diff --git a/nine/david/Tasks/artificial.py b/nine/david/Tasks/artificial.py new file mode 100644 index 0000000..e6fe8ce --- /dev/null +++ b/nine/david/Tasks/artificial.py @@ -0,0 +1,35 @@ +# create a value that holds 2 lists, those two lists should have dictionaries of several keys and values of different types + + + +family = [ + { + "Principal" : "Mr Dele", + "Occupation" : ["Principal", "Real Estate", "Pure Water Factory"], + "Age" : 58, + "Gender": "Male", + "Height": 5.7, + "Complextion": "Dark", + "Marital Status": "Married", + "Children": 2, + "Vehicles" : ["Toyota Venza", "Benz"] + }, + { + "Principals_wife" : "Mrs Angela", + "Occupation": ["Vice Principal", "Trader", "Project manager", "House wife"], + "Children": 2, + "Age": "50", + "Height": 5.7, + "Complextion": "Fair", + "Hobbies" : ["Singing", "Baking", "Cycing", "Gymnasium", "Beach"], + "BestFriends" : ["Mrs Benson", "Mrs Olivia"], + "vehicle" : ["Camry", "Honda Rx350"] + } +] + +def find(): + for lists in family: + # lists = ["principal"] + print(lists["Principal"]) +find() + diff --git a/nine/david/Tasks/chat_bot.py b/nine/david/Tasks/chat_bot.py new file mode 100644 index 0000000..db0e207 --- /dev/null +++ b/nine/david/Tasks/chat_bot.py @@ -0,0 +1,44 @@ +import datetime +import random +import time +import json + + +def chatbot(): + response = "yes" + while response == "yes": + + question = input("What's that your question sef?\n").split() + + dictionary = open("C:/Users/US CHIPS/python_with_cohorts/nine/david/Tasks/david.json") + + dictionary = json.load(dictionary) + + reply = [] + + # question = [x.lower() for x in question] + + question = question + + + if ["exit"] == question: + print("Existing...") + break + + for key in question: + if key in dictionary.keys(): + reply.append(random.choice(dictionary[key])) + + if reply: + print(random.choice(reply)) + else: + print("Ogbeni, don't stress me.... Ask better question biko!") + + time.sleep(1) + print() + + response = input("Do you want to chat more? (yes or no)\n").lower() + if response == 'no': + print("Bye!") + +chatbot() diff --git a/nine/david/Tasks/check.py b/nine/david/Tasks/check.py new file mode 100644 index 0000000..ecbe1b9 --- /dev/null +++ b/nine/david/Tasks/check.py @@ -0,0 +1,102 @@ +name = "dAvId" +name_capitalize = name.capitalize() +name_lower = name.lower() +name_with_white_space = " David " +name_lstripped = name_with_white_space.strip() +name_rstripped = name_with_white_space.strip() +swapped = name.swapcase() + + +# print(name_lstripped) +# print(name_rstripped) +# print(swapped) +# print(name) +# print(name_lower) +# print(name_capitalize) + +list_of_names = ["Hellen", "David", "Joe", "Rogen", "Motunrayo", "Johnson", "Adeola Esther", "Mofobi", "jim Doe"] + +# longest = max(list_of_names, key=len) +# shortest = min(list_of_names, key=len) +# print(longest) +# print(shortest) + +# counter = 1 +# for each in list_of_names: +# if len(each) > counter: +# counter = len(each) +# result = each + +# print(result) + +# maximum = 0 +# for i in range(len(list_of_names)): +# length = len(list_of_names[i]) +# if maximum < length: +# maximum = length +# value = list_of_names[i] + +# print("Longest Name = ", value) +# print("Number = ", maximum) + +# minimum = 1000 +# for i in range(len(list_of_names)): +# length = len(list_of_names[i]) +# if minimum > length: +# minimum = length +# value = list_of_names[i] + +# print("Shortest Name = ", value) +# print("Number = ", minimum) + +# printing smallest names +# smallest = 5 +# for i in list_of_names: +# if len(i) == smallest: +# smallest = len(i) +# result = i +# print(result) + + +# # search if list contains some strings +# for i in list_of_names: +# if i.__contains__("gen"): +# print(i) + + +class_a = ["Hellen", "David", "Joe", "Rogen", "Motunrayo"] +class_b = ["Johnson", "Adeola Esther", "Mofobi", "jim Doe"] + + + +longest = 0 +shortest = 0 +for i in range(len(class_a)): + lenght = len(class_a[i]) + if longest < lenght: + longest = lenght + value = class_a[i] + else: + if i in range(len(class_b)): + lenght = len(class_b[i]) + if shortest < lenght: + shortest = lenght + value1 = class_b[i] + +print("Class A longest name = ", value) +print("Class B longest name = ", value1) + +if value < value1: + print("Class A has longer name than Class B") +else: + print("Class B has longer name than Class A") + +# classes = [class_a, class_b] + +# for i in range(len(classes)): +# for j in range(len(classes[i])): +# # print(classes[i][j]) +# if i > j: +# print(i) +# if i < j: +# print(j) \ No newline at end of file diff --git a/nine/david/Tasks/classes.py b/nine/david/Tasks/classes.py new file mode 100644 index 0000000..5f50ff2 --- /dev/null +++ b/nine/david/Tasks/classes.py @@ -0,0 +1,54 @@ +# 9. Write a python class named student with two attributes student_name, marks. +# Modify the attribute values of the said class and print the ooriginal and modified values of the said attributes. +class Student: + def __init__(self, student_name, mark): + self.student_name = student_name + self.mark = mark + +def original_values(): + original = Student("David", 50) + + print(original.student_name) + print(original.mark) +# original_values() + + +def modified_values(): + original = Student("Angel", 100) + + print() + + print(original.student_name) + print(original.mark) +# modified_values() + + +#10. +class SecondQeustion: + def __init__(self, student_id, student_name): + self.student_id = student_id + self.student_name = student_name + +def new(): + original = SecondQeustion(100, "Michael") + # print(original.__dict__) to get the result as a dictionary + original.__dict__.update(student_class = "Jss3", sex = "Male") #to update or add an attribute to a class + + print(original.student_name) + print(original.student_id) + print(original.student_class) + print(original.sex) + +new() + +# def student_name_removed(): + + + + + + + + + + diff --git a/nine/david/Tasks/concatinate.py b/nine/david/Tasks/concatinate.py new file mode 100644 index 0000000..c494641 --- /dev/null +++ b/nine/david/Tasks/concatinate.py @@ -0,0 +1,28 @@ +# Write a program that prints +first_name = "Johnnie" +last_name = "Doe" +age = 47 +s_o_o = "Lagos" + +for i in range(0, len(first_name), 2): + print(first_name[i].upper(), age // 10, sep=" ", end=" ") +print() + +for i in range(0, len(s_o_o), 2): + print(s_o_o[i].upper(), last_name.upper(), sep=" ", end=" ") +print() + +concat = first_name + last_name +# print(concat.upper().replace(" ", "-")) + +# for i in range(0, len(concat)): +# print(concat[i].upper(), sep="-", end="-") + +for i in range(len(concat)): + if i == len(concat) - 1: + print(concat[i].upper()) + else: + print(concat[i].upper(), end="-") +print() + + diff --git a/nine/david/Tasks/data.py b/nine/david/Tasks/data.py new file mode 100644 index 0000000..4bfb015 --- /dev/null +++ b/nine/david/Tasks/data.py @@ -0,0 +1,553 @@ +data = [ + { + "login": "gentlesolo", + "id": 5492998, + "node_id": "MDQ6VXNlcjU0OTI5OTg=", + "avatar_url": "https://avatars.githubusercontent.com/u/5492998?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/gentlesolo", + "html_url": "https://github.com/gentlesolo", + "followers_url": "https://api.github.com/users/gentlesolo/followers", + "following_url": "https://api.github.com/users/gentlesolo/following{/other_user}", + "gists_url": "https://api.github.com/users/gentlesolo/gists{/gist_id}", + "starred_url": "https://api.github.com/users/gentlesolo/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/gentlesolo/subscriptions", + "organizations_url": "https://api.github.com/users/gentlesolo/orgs", + "repos_url": "https://api.github.com/users/gentlesolo/repos", + "events_url": "https://api.github.com/users/gentlesolo/events{/privacy}", + "received_events_url": "https://api.github.com/users/gentlesolo/received_events", + "type": "User", + "site_admin": False + }, + { + "login": "daunikman", + "id": 8968140, + "node_id": "MDQ6VXNlcjg5NjgxNDA=", + "avatar_url": "https://avatars.githubusercontent.com/u/8968140?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/daunikman", + "html_url": "https://github.com/daunikman", + "followers_url": "https://api.github.com/users/daunikman/followers", + "following_url": "https://api.github.com/users/daunikman/following{/other_user}", + "gists_url": "https://api.github.com/users/daunikman/gists{/gist_id}", + "starred_url": "https://api.github.com/users/daunikman/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/daunikman/subscriptions", + "organizations_url": "https://api.github.com/users/daunikman/orgs", + "repos_url": "https://api.github.com/users/daunikman/repos", + "events_url": "https://api.github.com/users/daunikman/events{/privacy}", + "received_events_url": "https://api.github.com/users/daunikman/received_events", + "type": "User", + "site_admin": False + }, + { + "login": "ehizman", + "id": 23247186, + "node_id": "MDQ6VXNlcjIzMjQ3MTg2", + "avatar_url": "https://avatars.githubusercontent.com/u/23247186?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/ehizman", + "html_url": "https://github.com/ehizman", + "followers_url": "https://api.github.com/users/ehizman/followers", + "following_url": "https://api.github.com/users/ehizman/following{/other_user}", + "gists_url": "https://api.github.com/users/ehizman/gists{/gist_id}", + "starred_url": "https://api.github.com/users/ehizman/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/ehizman/subscriptions", + "organizations_url": "https://api.github.com/users/ehizman/orgs", + "repos_url": "https://api.github.com/users/ehizman/repos", + "events_url": "https://api.github.com/users/ehizman/events{/privacy}", + "received_events_url": "https://api.github.com/users/ehizman/received_events", + "type": "User", + "site_admin": False + }, + { + "login": "Olaoluolowe", + "id": 24969588, + "node_id": "MDQ6VXNlcjI0OTY5NTg4", + "avatar_url": "https://avatars.githubusercontent.com/u/24969588?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/Olaoluolowe", + "html_url": "https://github.com/Olaoluolowe", + "followers_url": "https://api.github.com/users/Olaoluolowe/followers", + "following_url": "https://api.github.com/users/Olaoluolowe/following{/other_user}", + "gists_url": "https://api.github.com/users/Olaoluolowe/gists{/gist_id}", + "starred_url": "https://api.github.com/users/Olaoluolowe/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/Olaoluolowe/subscriptions", + "organizations_url": "https://api.github.com/users/Olaoluolowe/orgs", + "repos_url": "https://api.github.com/users/Olaoluolowe/repos", + "events_url": "https://api.github.com/users/Olaoluolowe/events{/privacy}", + "received_events_url": "https://api.github.com/users/Olaoluolowe/received_events", + "type": "User", + "site_admin": False + }, + { + "login": "hedreez09", + "id": 29062895, + "node_id": "MDQ6VXNlcjI5MDYyODk1", + "avatar_url": "https://avatars.githubusercontent.com/u/29062895?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/hedreez09", + "html_url": "https://github.com/hedreez09", + "followers_url": "https://api.github.com/users/hedreez09/followers", + "following_url": "https://api.github.com/users/hedreez09/following{/other_user}", + "gists_url": "https://api.github.com/users/hedreez09/gists{/gist_id}", + "starred_url": "https://api.github.com/users/hedreez09/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/hedreez09/subscriptions", + "organizations_url": "https://api.github.com/users/hedreez09/orgs", + "repos_url": "https://api.github.com/users/hedreez09/repos", + "events_url": "https://api.github.com/users/hedreez09/events{/privacy}", + "received_events_url": "https://api.github.com/users/hedreez09/received_events", + "type": "User", + "site_admin": False + }, + { + "login": "solutionCraftsman", + "id": 29656757, + "node_id": "MDQ6VXNlcjI5NjU2NzU3", + "avatar_url": "https://avatars.githubusercontent.com/u/29656757?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/solutionCraftsman", + "html_url": "https://github.com/solutionCraftsman", + "followers_url": "https://api.github.com/users/solutionCraftsman/followers", + "following_url": "https://api.github.com/users/solutionCraftsman/following{/other_user}", + "gists_url": "https://api.github.com/users/solutionCraftsman/gists{/gist_id}", + "starred_url": "https://api.github.com/users/solutionCraftsman/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/solutionCraftsman/subscriptions", + "organizations_url": "https://api.github.com/users/solutionCraftsman/orgs", + "repos_url": "https://api.github.com/users/solutionCraftsman/repos", + "events_url": "https://api.github.com/users/solutionCraftsman/events{/privacy}", + "received_events_url": "https://api.github.com/users/solutionCraftsman/received_events", + "type": "User", + "site_admin": False + }, + { + "login": "CaptainBKola", + "id": 31166533, + "node_id": "MDQ6VXNlcjMxMTY2NTMz", + "avatar_url": "https://avatars.githubusercontent.com/u/31166533?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/CaptainBKola", + "html_url": "https://github.com/CaptainBKola", + "followers_url": "https://api.github.com/users/CaptainBKola/followers", + "following_url": "https://api.github.com/users/CaptainBKola/following{/other_user}", + "gists_url": "https://api.github.com/users/CaptainBKola/gists{/gist_id}", + "starred_url": "https://api.github.com/users/CaptainBKola/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/CaptainBKola/subscriptions", + "organizations_url": "https://api.github.com/users/CaptainBKola/orgs", + "repos_url": "https://api.github.com/users/CaptainBKola/repos", + "events_url": "https://api.github.com/users/CaptainBKola/events{/privacy}", + "received_events_url": "https://api.github.com/users/CaptainBKola/received_events", + "type": "User", + "site_admin": False + }, + { + "login": "momah95", + "id": 37146344, + "node_id": "MDQ6VXNlcjM3MTQ2MzQ0", + "avatar_url": "https://avatars.githubusercontent.com/u/37146344?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/momah95", + "html_url": "https://github.com/momah95", + "followers_url": "https://api.github.com/users/momah95/followers", + "following_url": "https://api.github.com/users/momah95/following{/other_user}", + "gists_url": "https://api.github.com/users/momah95/gists{/gist_id}", + "starred_url": "https://api.github.com/users/momah95/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/momah95/subscriptions", + "organizations_url": "https://api.github.com/users/momah95/orgs", + "repos_url": "https://api.github.com/users/momah95/repos", + "events_url": "https://api.github.com/users/momah95/events{/privacy}", + "received_events_url": "https://api.github.com/users/momah95/received_events", + "type": "User", + "site_admin": False + }, + { + "login": "isholajanet", + "id": 39619383, + "node_id": "MDQ6VXNlcjM5NjE5Mzgz", + "avatar_url": "https://avatars.githubusercontent.com/u/39619383?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/isholajanet", + "html_url": "https://github.com/isholajanet", + "followers_url": "https://api.github.com/users/isholajanet/followers", + "following_url": "https://api.github.com/users/isholajanet/following{/other_user}", + "gists_url": "https://api.github.com/users/isholajanet/gists{/gist_id}", + "starred_url": "https://api.github.com/users/isholajanet/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/isholajanet/subscriptions", + "organizations_url": "https://api.github.com/users/isholajanet/orgs", + "repos_url": "https://api.github.com/users/isholajanet/repos", + "events_url": "https://api.github.com/users/isholajanet/events{/privacy}", + "received_events_url": "https://api.github.com/users/isholajanet/received_events", + "type": "User", + "site_admin": False + }, + { + "login": "Debagboola", + "id": 40859055, + "node_id": "MDQ6VXNlcjQwODU5MDU1", + "avatar_url": "https://avatars.githubusercontent.com/u/40859055?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/Debagboola", + "html_url": "https://github.com/Debagboola", + "followers_url": "https://api.github.com/users/Debagboola/followers", + "following_url": "https://api.github.com/users/Debagboola/following{/other_user}", + "gists_url": "https://api.github.com/users/Debagboola/gists{/gist_id}", + "starred_url": "https://api.github.com/users/Debagboola/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/Debagboola/subscriptions", + "organizations_url": "https://api.github.com/users/Debagboola/orgs", + "repos_url": "https://api.github.com/users/Debagboola/repos", + "events_url": "https://api.github.com/users/Debagboola/events{/privacy}", + "received_events_url": "https://api.github.com/users/Debagboola/received_events", + "type": "User", + "site_admin": False + }, + { + "login": "IbidapoOlalekan", + "id": 41305811, + "node_id": "MDQ6VXNlcjQxMzA1ODEx", + "avatar_url": "https://avatars.githubusercontent.com/u/41305811?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/IbidapoOlalekan", + "html_url": "https://github.com/IbidapoOlalekan", + "followers_url": "https://api.github.com/users/IbidapoOlalekan/followers", + "following_url": "https://api.github.com/users/IbidapoOlalekan/following{/other_user}", + "gists_url": "https://api.github.com/users/IbidapoOlalekan/gists{/gist_id}", + "starred_url": "https://api.github.com/users/IbidapoOlalekan/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/IbidapoOlalekan/subscriptions", + "organizations_url": "https://api.github.com/users/IbidapoOlalekan/orgs", + "repos_url": "https://api.github.com/users/IbidapoOlalekan/repos", + "events_url": "https://api.github.com/users/IbidapoOlalekan/events{/privacy}", + "received_events_url": "https://api.github.com/users/IbidapoOlalekan/received_events", + "type": "User", + "site_admin": False + }, + { + "login": "tboydv1", + "id": 45124633, + "node_id": "MDQ6VXNlcjQ1MTI0NjMz", + "avatar_url": "https://avatars.githubusercontent.com/u/45124633?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/tboydv1", + "html_url": "https://github.com/tboydv1", + "followers_url": "https://api.github.com/users/tboydv1/followers", + "following_url": "https://api.github.com/users/tboydv1/following{/other_user}", + "gists_url": "https://api.github.com/users/tboydv1/gists{/gist_id}", + "starred_url": "https://api.github.com/users/tboydv1/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/tboydv1/subscriptions", + "organizations_url": "https://api.github.com/users/tboydv1/orgs", + "repos_url": "https://api.github.com/users/tboydv1/repos", + "events_url": "https://api.github.com/users/tboydv1/events{/privacy}", + "received_events_url": "https://api.github.com/users/tboydv1/received_events", + "type": "User", + "site_admin": False + }, + { + "login": "Patrick5455", + "id": 46347439, + "node_id": "MDQ6VXNlcjQ2MzQ3NDM5", + "avatar_url": "https://avatars.githubusercontent.com/u/46347439?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/Patrick5455", + "html_url": "https://github.com/Patrick5455", + "followers_url": "https://api.github.com/users/Patrick5455/followers", + "following_url": "https://api.github.com/users/Patrick5455/following{/other_user}", + "gists_url": "https://api.github.com/users/Patrick5455/gists{/gist_id}", + "starred_url": "https://api.github.com/users/Patrick5455/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/Patrick5455/subscriptions", + "organizations_url": "https://api.github.com/users/Patrick5455/orgs", + "repos_url": "https://api.github.com/users/Patrick5455/repos", + "events_url": "https://api.github.com/users/Patrick5455/events{/privacy}", + "received_events_url": "https://api.github.com/users/Patrick5455/received_events", + "type": "User", + "site_admin": False + }, + { + "login": "itunuelijah", + "id": 46831122, + "node_id": "MDQ6VXNlcjQ2ODMxMTIy", + "avatar_url": "https://avatars.githubusercontent.com/u/46831122?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/itunuelijah", + "html_url": "https://github.com/itunuelijah", + "followers_url": "https://api.github.com/users/itunuelijah/followers", + "following_url": "https://api.github.com/users/itunuelijah/following{/other_user}", + "gists_url": "https://api.github.com/users/itunuelijah/gists{/gist_id}", + "starred_url": "https://api.github.com/users/itunuelijah/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/itunuelijah/subscriptions", + "organizations_url": "https://api.github.com/users/itunuelijah/orgs", + "repos_url": "https://api.github.com/users/itunuelijah/repos", + "events_url": "https://api.github.com/users/itunuelijah/events{/privacy}", + "received_events_url": "https://api.github.com/users/itunuelijah/received_events", + "type": "User", + "site_admin": False + }, + { + "login": "akinleries", + "id": 47524901, + "node_id": "MDQ6VXNlcjQ3NTI0OTAx", + "avatar_url": "https://avatars.githubusercontent.com/u/47524901?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/akinleries", + "html_url": "https://github.com/akinleries", + "followers_url": "https://api.github.com/users/akinleries/followers", + "following_url": "https://api.github.com/users/akinleries/following{/other_user}", + "gists_url": "https://api.github.com/users/akinleries/gists{/gist_id}", + "starred_url": "https://api.github.com/users/akinleries/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/akinleries/subscriptions", + "organizations_url": "https://api.github.com/users/akinleries/orgs", + "repos_url": "https://api.github.com/users/akinleries/repos", + "events_url": "https://api.github.com/users/akinleries/events{/privacy}", + "received_events_url": "https://api.github.com/users/akinleries/received_events", + "type": "User", + "site_admin": False + }, + { + "login": "kareemmonsur", + "id": 47614910, + "node_id": "MDQ6VXNlcjQ3NjE0OTEw", + "avatar_url": "https://avatars.githubusercontent.com/u/47614910?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/kareemmonsur", + "html_url": "https://github.com/kareemmonsur", + "followers_url": "https://api.github.com/users/kareemmonsur/followers", + "following_url": "https://api.github.com/users/kareemmonsur/following{/other_user}", + "gists_url": "https://api.github.com/users/kareemmonsur/gists{/gist_id}", + "starred_url": "https://api.github.com/users/kareemmonsur/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/kareemmonsur/subscriptions", + "organizations_url": "https://api.github.com/users/kareemmonsur/orgs", + "repos_url": "https://api.github.com/users/kareemmonsur/repos", + "events_url": "https://api.github.com/users/kareemmonsur/events{/privacy}", + "received_events_url": "https://api.github.com/users/kareemmonsur/received_events", + "type": "User", + "site_admin": False + }, + { + "login": "Akinolae", + "id": 48059516, + "node_id": "MDQ6VXNlcjQ4MDU5NTE2", + "avatar_url": "https://avatars.githubusercontent.com/u/48059516?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/Akinolae", + "html_url": "https://github.com/Akinolae", + "followers_url": "https://api.github.com/users/Akinolae/followers", + "following_url": "https://api.github.com/users/Akinolae/following{/other_user}", + "gists_url": "https://api.github.com/users/Akinolae/gists{/gist_id}", + "starred_url": "https://api.github.com/users/Akinolae/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/Akinolae/subscriptions", + "organizations_url": "https://api.github.com/users/Akinolae/orgs", + "repos_url": "https://api.github.com/users/Akinolae/repos", + "events_url": "https://api.github.com/users/Akinolae/events{/privacy}", + "received_events_url": "https://api.github.com/users/Akinolae/received_events", + "type": "User", + "site_admin": False + }, + { + "login": "dabreeze", + "id": 48369515, + "node_id": "MDQ6VXNlcjQ4MzY5NTE1", + "avatar_url": "https://avatars.githubusercontent.com/u/48369515?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/dabreeze", + "html_url": "https://github.com/dabreeze", + "followers_url": "https://api.github.com/users/dabreeze/followers", + "following_url": "https://api.github.com/users/dabreeze/following{/other_user}", + "gists_url": "https://api.github.com/users/dabreeze/gists{/gist_id}", + "starred_url": "https://api.github.com/users/dabreeze/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/dabreeze/subscriptions", + "organizations_url": "https://api.github.com/users/dabreeze/orgs", + "repos_url": "https://api.github.com/users/dabreeze/repos", + "events_url": "https://api.github.com/users/dabreeze/events{/privacy}", + "received_events_url": "https://api.github.com/users/dabreeze/received_events", + "type": "User", + "site_admin": False + }, + { + "login": "oolabisi", + "id": 50625324, + "node_id": "MDQ6VXNlcjUwNjI1MzI0", + "avatar_url": "https://avatars.githubusercontent.com/u/50625324?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/oolabisi", + "html_url": "https://github.com/oolabisi", + "followers_url": "https://api.github.com/users/oolabisi/followers", + "following_url": "https://api.github.com/users/oolabisi/following{/other_user}", + "gists_url": "https://api.github.com/users/oolabisi/gists{/gist_id}", + "starred_url": "https://api.github.com/users/oolabisi/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/oolabisi/subscriptions", + "organizations_url": "https://api.github.com/users/oolabisi/orgs", + "repos_url": "https://api.github.com/users/oolabisi/repos", + "events_url": "https://api.github.com/users/oolabisi/events{/privacy}", + "received_events_url": "https://api.github.com/users/oolabisi/received_events", + "type": "User", + "site_admin": False + }, + { + "login": "SimNinwo", + "id": 50625397, + "node_id": "MDQ6VXNlcjUwNjI1Mzk3", + "avatar_url": "https://avatars.githubusercontent.com/u/50625397?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/SimNinwo", + "html_url": "https://github.com/SimNinwo", + "followers_url": "https://api.github.com/users/SimNinwo/followers", + "following_url": "https://api.github.com/users/SimNinwo/following{/other_user}", + "gists_url": "https://api.github.com/users/SimNinwo/gists{/gist_id}", + "starred_url": "https://api.github.com/users/SimNinwo/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/SimNinwo/subscriptions", + "organizations_url": "https://api.github.com/users/SimNinwo/orgs", + "repos_url": "https://api.github.com/users/SimNinwo/repos", + "events_url": "https://api.github.com/users/SimNinwo/events{/privacy}", + "received_events_url": "https://api.github.com/users/SimNinwo/received_events", + "type": "User", + "site_admin": False + }, + { + "login": "gbemme", + "id": 50625401, + "node_id": "MDQ6VXNlcjUwNjI1NDAx", + "avatar_url": "https://avatars.githubusercontent.com/u/50625401?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/gbemme", + "html_url": "https://github.com/gbemme", + "followers_url": "https://api.github.com/users/gbemme/followers", + "following_url": "https://api.github.com/users/gbemme/following{/other_user}", + "gists_url": "https://api.github.com/users/gbemme/gists{/gist_id}", + "starred_url": "https://api.github.com/users/gbemme/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/gbemme/subscriptions", + "organizations_url": "https://api.github.com/users/gbemme/orgs", + "repos_url": "https://api.github.com/users/gbemme/repos", + "events_url": "https://api.github.com/users/gbemme/events{/privacy}", + "received_events_url": "https://api.github.com/users/gbemme/received_events", + "type": "User", + "site_admin": False + }, + { + "login": "PastorCoder", + "id": 50626194, + "node_id": "MDQ6VXNlcjUwNjI2MTk0", + "avatar_url": "https://avatars.githubusercontent.com/u/50626194?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/PastorCoder", + "html_url": "https://github.com/PastorCoder", + "followers_url": "https://api.github.com/users/PastorCoder/followers", + "following_url": "https://api.github.com/users/PastorCoder/following{/other_user}", + "gists_url": "https://api.github.com/users/PastorCoder/gists{/gist_id}", + "starred_url": "https://api.github.com/users/PastorCoder/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/PastorCoder/subscriptions", + "organizations_url": "https://api.github.com/users/PastorCoder/orgs", + "repos_url": "https://api.github.com/users/PastorCoder/repos", + "events_url": "https://api.github.com/users/PastorCoder/events{/privacy}", + "received_events_url": "https://api.github.com/users/PastorCoder/received_events", + "type": "User", + "site_admin": False + }, + { + "login": "emperorsegxy", + "id": 51512956, + "node_id": "MDQ6VXNlcjUxNTEyOTU2", + "avatar_url": "https://avatars.githubusercontent.com/u/51512956?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/emperorsegxy", + "html_url": "https://github.com/emperorsegxy", + "followers_url": "https://api.github.com/users/emperorsegxy/followers", + "following_url": "https://api.github.com/users/emperorsegxy/following{/other_user}", + "gists_url": "https://api.github.com/users/emperorsegxy/gists{/gist_id}", + "starred_url": "https://api.github.com/users/emperorsegxy/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/emperorsegxy/subscriptions", + "organizations_url": "https://api.github.com/users/emperorsegxy/orgs", + "repos_url": "https://api.github.com/users/emperorsegxy/repos", + "events_url": "https://api.github.com/users/emperorsegxy/events{/privacy}", + "received_events_url": "https://api.github.com/users/emperorsegxy/received_events", + "type": "User", + "site_admin": False + }, + { + "login": "Oviep", + "id": 53795498, + "node_id": "MDQ6VXNlcjUzNzk1NDk4", + "avatar_url": "https://avatars.githubusercontent.com/u/53795498?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/Oviep", + "html_url": "https://github.com/Oviep", + "followers_url": "https://api.github.com/users/Oviep/followers", + "following_url": "https://api.github.com/users/Oviep/following{/other_user}", + "gists_url": "https://api.github.com/users/Oviep/gists{/gist_id}", + "starred_url": "https://api.github.com/users/Oviep/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/Oviep/subscriptions", + "organizations_url": "https://api.github.com/users/Oviep/orgs", + "repos_url": "https://api.github.com/users/Oviep/repos", + "events_url": "https://api.github.com/users/Oviep/events{/privacy}", + "received_events_url": "https://api.github.com/users/Oviep/received_events", + "type": "User", + "site_admin": False + }, + { + "login": "jerrywise97", + "id": 54330961, + "node_id": "MDQ6VXNlcjU0MzMwOTYx", + "avatar_url": "https://avatars.githubusercontent.com/u/54330961?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/jerrywise97", + "html_url": "https://github.com/jerrywise97", + "followers_url": "https://api.github.com/users/jerrywise97/followers", + "following_url": "https://api.github.com/users/jerrywise97/following{/other_user}", + "gists_url": "https://api.github.com/users/jerrywise97/gists{/gist_id}", + "starred_url": "https://api.github.com/users/jerrywise97/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/jerrywise97/subscriptions", + "organizations_url": "https://api.github.com/users/jerrywise97/orgs", + "repos_url": "https://api.github.com/users/jerrywise97/repos", + "events_url": "https://api.github.com/users/jerrywise97/events{/privacy}", + "received_events_url": "https://api.github.com/users/jerrywise97/received_events", + "type": "User", + "site_admin": False + }, + { + "login": "dayoolacodes", + "id": 54889931, + "node_id": "MDQ6VXNlcjU0ODg5OTMx", + "avatar_url": "https://avatars.githubusercontent.com/u/54889931?v=4", + "gravatar_id": "", + "url": "https://api.github.com/users/dayoolacodes", + "html_url": "https://github.com/dayoolacodes", + "followers_url": "https://api.github.com/users/dayoolacodes/followers", + "following_url": "https://api.github.com/users/dayoolacodes/following{/other_user}", + "gists_url": "https://api.github.com/users/dayoolacodes/gists{/gist_id}", + "starred_url": "https://api.github.com/users/dayoolacodes/starred{/owner}{/repo}", + "subscriptions_url": "https://api.github.com/users/dayoolacodes/subscriptions", + "organizations_url": "https://api.github.com/users/dayoolacodes/orgs", + "repos_url": "https://api.github.com/users/dayoolacodes/repos", + "events_url": "https://api.github.com/users/dayoolacodes/events{/privacy}", + "received_events_url": "https://api.github.com/users/dayoolacodes/received_events", + "type": "User", + "site_admin": False + } +] + +# for every user that their id is odd, print them +# for every user that their id contains 8, print them + +def odd_id(): + user_login = [] + for dictionary in data: + if dictionary["id"] % 2 >= 0: + user_login.append(dictionary["login"]) + + for logins in user_login: + print("Users with odd = ", logins) + +odd_id() +print() + + +def id_with_eight(): + user_login = [] + for dictionaries in data: + if str(dictionaries["id"]).__contains__("8"): + user_login.append(dictionaries["login"]) + + for logins in user_login: + print("User with '8' in ids = ", logins) + +id_with_eight() + + + + diff --git a/nine/david/Tasks/data1.json b/nine/david/Tasks/data1.json new file mode 100644 index 0000000..8b1a337 --- /dev/null +++ b/nine/david/Tasks/data1.json @@ -0,0 +1,182 @@ +{"colors": [ + { + "color": "red", + "value": "#f00" + }, + { + "color": "green", + "value": "#0f0" + }, + { + "color": "blue", + "value": "#00f" + }, + { + "color": "cyan", + "value": "#0ff" + }, + { + "color": "magenta", + "value": "#f0f" + }, + { + "color": "yellow", + "value": "#ff0" + }, + { + "color": "black", + "value": "#000" + } +], + +"example_one": { + "id": "0001", + "type": "donut", + "name": "Cake", + "ppu": 0.55, + "batters": + { + "batter": + [ + { "id": "1001", "type": "Regular" }, + { "id": "1002", "type": "Chocolate" }, + { "id": "1003", "type": "Blueberry" }, + { "id": "1004", "type": "Devil's Food" } + ] + }, + "topping": + [ + { "id": "5001", "type": "None" }, + { "id": "5002", "type": "Glazed" }, + { "id": "5005", "type": "Sugar" }, + { "id": "5007", "type": "Powdered Sugar" }, + { "id": "5006", "type": "Chocolate with Sprinkles" }, + { "id": "5003", "type": "Chocolate" }, + { "id": "5004", "type": "Maple" } + ] +}, +"example_two": [ + { + "id": "0001", + "type": "donut", + "name": "Cake", + "ppu": 0.55, + "batters": + { + "batter": + [ + { "id": "1001", "type": "Regular" }, + { "id": "1002", "type": "Chocolate" }, + { "id": "1003", "type": "Blueberry" }, + { "id": "1004", "type": "Devil's Food" } + ] + }, + "topping": + [ + { "id": "5001", "type": "None" }, + { "id": "5002", "type": "Glazed" }, + { "id": "5005", "type": "Sugar" }, + { "id": "5007", "type": "Powdered Sugar" }, + { "id": "5006", "type": "Chocolate with Sprinkles" }, + { "id": "5003", "type": "Chocolate" }, + { "id": "5004", "type": "Maple" } + ] + }, + { + "id": "0002", + "type": "donut", + "name": "Raised", + "ppu": 0.55, + "batters": + { + "batter": + [ + { "id": "1001", "type": "Regular" } + ] + }, + "topping": + [ + { "id": "5001", "type": "None" }, + { "id": "5002", "type": "Glazed" }, + { "id": "5005", "type": "Sugar" }, + { "id": "5003", "type": "Chocolate" }, + { "id": "5004", "type": "Maple" } + ] + }, + { + "id": "0003", + "type": "donut", + "name": "Old Fashioned", + "ppu": 0.55, + "batters": + { + "batter": + [ + { "id": "1001", "type": "Regular" }, + { "id": "1002", "type": "Chocolate" } + ] + }, + "topping": + [ + { "id": "5001", "type": "None" }, + { "id": "5002", "type": "Glazed" }, + { "id": "5003", "type": "Chocolate" }, + { "id": "5004", "type": "Maple" } + ] + } +], + +"example_three": { + "id": "0001", + "type": "donut", + "name": "Cake", + "image": + { + "url": "images/0001.jpg", + "width": 200, + "height": 200 + }, + "thumbnail": + { + "url": "images/thumbnails/0001.jpg", + "width": 32, + "height": 32 + } +}, + +"example_four": { + "items": + { + "item": + [ + { + "id": "0001", + "type": "donut", + "name": "Cake", + "ppu": 0.55, + "batters": + { + "batter": + [ + { "id": "1001", "type": "Regular" }, + { "id": "1002", "type": "Chocolate" }, + { "id": "1003", "type": "Blueberry" }, + { "id": "1004", "type": "Devil's Food" } + ] + }, + "topping": + [ + { "id": "5001", "type": "None" }, + { "id": "5002", "type": "Glazed" }, + { "id": "5005", "type": "Sugar" }, + { "id": "5007", "type": "Powdered Sugar" }, + { "id": "5006", "type": "Chocolate with Sprinkles" }, + { "id": "5003", "type": "Chocolate" }, + { "id": "5004", "type": "Maple" } + ] + } + + ] + } +} +} diff --git a/nine/david/Tasks/david.json b/nine/david/Tasks/david.json new file mode 100644 index 0000000..3e79637 --- /dev/null +++ b/nine/david/Tasks/david.json @@ -0,0 +1,25 @@ + + +{ + + "time": ["The time is ", "Go buy wristwatch"], + "name": ["Siri", "Sam", "Alexa", "Ask me something else biko"], + "love": ["Ja, ich liebe dich!", "Nein, ich liebe dich nicht", "Scheiße", "Love is wicked"], + "eat": ["Yeah, baby!", "Nah 😢"], + "single": ["I'm single as feck", "It's like I'm in one relationship like that joor"], + "programs": ["I write python sometimes", "I'm learning java", "I can't kill myself on golang", + "C# is unnecessarily hard"], + "country": ["I've been to Canada", "Maybe the UK", "Lovely Kenya", "Extremely beautiful Latvia"], + "age": ["I am old"], + "play": ["It depends tho", "Biko leave me alone joor", "Make I daze you?!"], + "sleep": ["I rarely sleep mehn", "I can't shutdown, I can only have a 10sec power nap daily"], + "football" : ["I was once a local champion in my secondary school because i was fast", "Omoh eh, i love football die", + "Since i break my leg, i nor try am again"], + "parents" : ["I love my mother", "I love my father", "I dey gbadun my Parle paarol pass marle own joor!", + "i dey gbadun my Mile parol pass Parle joor!"], + "siblings" : ["i have '3' siblings", "I have '6' siblings", "Mtchwwwww, na only me my papa born"], + "goals" : ["Watch matches at Old Trafford", "Waking up every day knowing i have the financial backing to do anything"], + "school" : ["me i nor finish ss3 oo!", "I am a degree holder", "I be illiteracy oga"] + + +} \ No newline at end of file diff --git a/nine/david/Tasks/factorial.py b/nine/david/Tasks/factorial.py new file mode 100644 index 0000000..7cc1093 --- /dev/null +++ b/nine/david/Tasks/factorial.py @@ -0,0 +1,11 @@ +number = int(input("Enter a number to check factorial: ")) +factorial = 1 + +for num in range(1, number + 1): + factorial = factorial * num +print(factorial) + +if (number == 0): + print("Factorial of 0 is ", factorial) +elif(number == 1): + print("Factorial of 1 is ", factorial) diff --git a/nine/david/Tasks/fruitBox.py b/nine/david/Tasks/fruitBox.py new file mode 100644 index 0000000..116dc09 --- /dev/null +++ b/nine/david/Tasks/fruitBox.py @@ -0,0 +1,31 @@ +a = ["Bananas", "Oranges", "Mangoes"] +b = ["bread", "eggs", "tomatoes"] +c = ["rice", "beans", "yam"] + +variable = [a, b, c] +print("s/n", "\t fruits", "\t positions") +print() +counter = 0 + +# for column in range(3): +# for row in range(3): +# counter += 1 +# + +# for row in range(3): +# for column in range(3): +# counter += 1 +# print(f'{counter} \t {variable[row][column]} \t {[row]} {[column]}') +# # print() + + +row = 2 +while row >= 0: + col = 2 + while col >= 0: + counter += 1 + print(f'{counter} \t {variable[col][row]} \t {[col]} {[row]}') + # print(variable[col][row], col, row) + col -= 1 + row -=1 + diff --git a/nine/david/Tasks/iterate_dictionary.py b/nine/david/Tasks/iterate_dictionary.py new file mode 100644 index 0000000..824decb --- /dev/null +++ b/nine/david/Tasks/iterate_dictionary.py @@ -0,0 +1,20 @@ +# guy.keys() #to get all the keys in a dictionary +# guy.values() # to get all the values in a dictionary + +# for key, values in guy.items(): + # print(key, value) to iterate and get both the keys and values in a dictionary + +# guy = { +# "first_name": "John", +# "last_name": "Doe", +# "siblings": ["Bola", "mobile", "Kennedy", "Jameson", "Postman"], +# "coohort": 1, +# "friend_list": "" +# } + +name = "Nobody expects the spanish inquisition! and you?!" + +name = name.lower() +name = name.strip("?", "!") +name = name.strip("!", "") +print(name) \ No newline at end of file diff --git a/nine/david/Tasks/new_data.py b/nine/david/Tasks/new_data.py new file mode 100644 index 0000000..b529119 --- /dev/null +++ b/nine/david/Tasks/new_data.py @@ -0,0 +1,255 @@ + +data = {"colors": [ + { + "color": "red", + "value": "#f00" + }, + { + "color": "green", + "value": "#0f0" + }, + { + "color": "blue", + "value": "#00f" + }, + { + "color": "cyan", + "value": "#0ff" + }, + { + "color": "magenta", + "value": "#f0f" + }, + { + "color": "yellow", + "value": "#ff0" + }, + { + "color": "black", + "value": "#000" + } +], + +"example_one": { + "id": "0001", + "type": "donut", + "name": "Cake", + "ppu": 0.55, + "batters": + { + "batter": + [ + { "id": "1001", "type": "Regular" }, + { "id": "1002", "type": "Chocolate" }, + { "id": "1003", "type": "Blueberry" }, + { "id": "1004", "type": "Devil's Food" } + ] + }, + "topping": + [ + { "id": "5001", "type": "None" }, + { "id": "5002", "type": "Glazed" }, + { "id": "5005", "type": "Sugar" }, + { "id": "5007", "type": "Powdered Sugar" }, + { "id": "5006", "type": "Chocolate with Sprinkles" }, + { "id": "5003", "type": "Chocolate" }, + { "id": "5004", "type": "Maple" } + ] +}, +"example_two": [ + { + "id": "0001", + "type": "donut", + "name": "Cake", + "ppu": 0.55, + "batters": + { + "batter": + [ + { "id": "1001", "type": "Regular" }, + { "id": "1002", "type": "Chocolate" }, + { "id": "1003", "type": "Blueberry" }, + { "id": "1004", "type": "Devil's Food" } + ] + }, + "topping": + [ + { "id": "5001", "type": "None" }, + { "id": "5002", "type": "Glazed" }, + { "id": "5005", "type": "Sugar" }, + { "id": "5007", "type": "Powdered Sugar" }, + { "id": "5006", "type": "Chocolate with Sprinkles" }, + { "id": "5003", "type": "Chocolate" }, + { "id": "5004", "type": "Maple" } + ] + }, + { + "id": "0002", + "type": "donut", + "name": "Raised", + "ppu": 0.55, + "batters": + { + "batter": + [ + { "id": "1001", "type": "Regular" } + ] + }, + "topping": + [ + { "id": "5001", "type": "None" }, + { "id": "5002", "type": "Glazed" }, + { "id": "5005", "type": "Sugar" }, + { "id": "5003", "type": "Chocolate" }, + { "id": "5004", "type": "Maple" } + ] + }, + { + "id": "0003", + "type": "donut", + "name": "Old Fashioned", + "ppu": 0.55, + "batters": + { + "batter": + [ + { "id": "1001", "type": "Regular" }, + { "id": "1002", "type": "Chocolate" } + ] + }, + "topping": + [ + { "id": "5001", "type": "None" }, + { "id": "5002", "type": "Glazed" }, + { "id": "5003", "type": "Chocolate" }, + { "id": "5004", "type": "Maple" } + ] + } +], + +"example_three": { + "id": "0001", + "type": "donut", + "name": "Cake", + "image": + { + "url": "images/0001.jpg", + "width": 200, + "height": 200 + }, + "thumbnail": + { + "url": "images/thumbnails/0001.jpg", + "width": 32, + "height": 32 + } +}, + +"example_four": { + "items": + { + "item": + [ + { + "id": "0001", + "type": "donut", + "name": "Cake", + "ppu": 0.55, + "batters": + { + "batter": + [ + { "id": "1001", "type": "Regular" }, + { "id": "1002", "type": "Chocolate" }, + { "id": "1003", "type": "Blueberry" }, + { "id": "1004", "type": "Devil's Food" } + ] + }, + "topping": + [ + { "id": "5001", "type": "None" }, + { "id": "5002", "type": "Glazed" }, + { "id": "5005", "type": "Sugar" }, + { "id": "5007", "type": "Powdered Sugar" }, + { "id": "5006", "type": "Chocolate with Sprinkles" }, + { "id": "5003", "type": "Chocolate" }, + { "id": "5004", "type": "Maple" } + ] + } + + ] + } +} +} + +def find_glazed(): + var = data["example_two"] + + for i in var: + new = i["topping"] + for j in new: + if j["id"] == "5002": + print(j["type"]) + +find_glazed() + + + + + + + + + + + + + + +# def find_toppings(): +# var=data["example_one"]["topping"] + +# for i in var: +# if i["id"]=="5007": +# print(i["type"]) + # print(i["type"]) + +# find_toppings() + +# def find_barter(): +# var=data["example_four"]["items"]["item"] + +# for i in var: +# pick = i["batters"]["batter"] +# for keys in pick: +# if keys["id"] == "1003": +# print(keys["type"]) + +# # find_barter() + +# def find_doughnut(): +# var = data["example_four"]["items"]["item"] + +# for i in var: +# pick = i["type"] +# print(pick) +# # find_doughnut() + +# def find_regular(): +# var = data["example_two"] + +# for first in var: +# i = first["batters"]["batter"] +# for second in i: +# if second["id"] == "1001": +# print(second["type"]) + +# find_regular() + +# def get_regular_value(): +# dew=data["example_two"] +# for i in dew: +# deq= i["batters"] +# print(deq) + +# get_regular_value() \ No newline at end of file diff --git a/nine/david/Tasks/new_task.py b/nine/david/Tasks/new_task.py deleted file mode 100644 index e69de29..0000000 diff --git a/nine/david/Tasks/numbersTriangle.py b/nine/david/Tasks/numbersTriangle.py new file mode 100644 index 0000000..69d1b73 --- /dev/null +++ b/nine/david/Tasks/numbersTriangle.py @@ -0,0 +1,12 @@ +# for row in range(1, 6 + 1): +# for column in range(1, row + 1): +# print(column, end=" ") +# print(" ") + + + +for row in range(0, 5 + 1): + for column in range(row - 1, 0, -1): + print(column, end=" ") + print(" ") + diff --git a/nine/david/Tasks/plusMinusPrinter.py b/nine/david/Tasks/plusMinusPrinter.py new file mode 100644 index 0000000..bd5418e --- /dev/null +++ b/nine/david/Tasks/plusMinusPrinter.py @@ -0,0 +1,51 @@ +#!/bin/python3 + +import math +import os +import random +import re +import sys + +# +# Complete the 'plusMinus' function below. +# +# The function accepts INTEGER_ARRAY arr as parameter. +# + +def plusMinus(userNum): + # Write your code here + total_positive = 0.0 + total_negative = 0.0 + total_zeros = 0.0 + + positive_counter = 0 + negative_counter = 0 + zero_counter = 0 + + for num in userNum: + if num > 0: + positive_counter += 1 + elif num < 0: + negative_counter += 1 + elif num == 0: + zero_counter += 1 + + total_positive = positive_counter/len(userNum) + print(round(total_positive, 6)) + print() + + total_negative = negative_counter/len(userNum) + print(round(total_negative, 6)) + print() + + total_zeros = zero_counter/len(userNum) + print(round(total_zeros, 6)) + + + +if __name__ == '__main__': + n = int(input().strip()) + + arr = list(map(int, input().rstrip().split())) + + plusMinus(arr) diff --git a/nine/david/Tasks/practice.py b/nine/david/Tasks/practice.py new file mode 100644 index 0000000..e762032 --- /dev/null +++ b/nine/david/Tasks/practice.py @@ -0,0 +1,19 @@ +# import json + +# data1 = open("C:/Users/US CHIPS/python_with_cohorts/nine/david/Tasks/data1.json") + +# data = json.load(data1) + +# print(data["colors"]) + +# hello_str = "Hello World" +# print(hello_str[0: 11: 2]) + + +# for i in range(5): +# print(i) + + +a_str = "hello" +a_str[1] = "r" +print(a_str) \ No newline at end of file diff --git a/nine/david/Tasks/ten_ten_game.py b/nine/david/Tasks/ten_ten_game.py index c77217f..093b5d1 100644 --- a/nine/david/Tasks/ten_ten_game.py +++ b/nine/david/Tasks/ten_ten_game.py @@ -1,13 +1,19 @@ -left_leg = 1 -right_leg = 2 +def tenten(): + left_leg = 1 + right_leg = 2 -print("instructions: Enter 1 for left leg, Enter 2 for right leg") + print("instructions: Enter 1 for left leg, Enter 2 for right leg") -player1 = int(input("Player1: Enter a number: ")) -player2 = int(input("Player2: Enter a number: ")) + player1 = int(input("Player1: Enter a number: ")) + player2 = int(input("Player2: Enter a number: ")) -if player1 == left_leg and player2 == right_leg: print("Player 1 wins") -elif player1 == left_leg and player2 == left_leg: print("Player 2 wins") -elif player1 == right_leg and player2 == left_leg: print("Player 1 wins") -elif player1 == right_leg and player2 == right_leg: print("player 2 wins") -elif player1 != left_leg or right_leg and player2 != left_leg or right_leg: print("Please read game instructions") + if player1 == left_leg and player2 == right_leg: print("Player 1 wins") + elif player1 == left_leg and player2 == left_leg: print("Player 2 wins") + elif player1 == right_leg and player2 == left_leg: print("Player 1 wins") + elif player1 == right_leg and player2 == right_leg: print("player 2 wins") + elif player1 != left_leg or right_leg and player2 != left_leg or right_leg: print("Please read game instructions") + + +def tired_class(): + print("We are tired") + print("Let us go on break") \ No newline at end of file diff --git a/nine/david/chapterThree/validatingUserInputs.py b/nine/david/chapterThree/validatingUserInputs.py new file mode 100644 index 0000000..f022ae1 --- /dev/null +++ b/nine/david/chapterThree/validatingUserInputs.py @@ -0,0 +1,18 @@ +passes = 0 +failures = 0 +number_of_failures = 0 + +for students in range(10): + result = int(input("Enter results (1 = pass. 2 = fail: )")) + + + if result == 1: + passes += 1 + elif result != 1 and result != 2: + print("Invalid input") + else: + failures += 1 + + +print("Passes = ", passes) +print("Failures = ", failures) \ No newline at end of file diff --git a/nine/david/chapterTwo/alphabeticalOrder.py b/nine/david/chapterTwo/alphabeticalOrder.py new file mode 100644 index 0000000..4275c4f --- /dev/null +++ b/nine/david/chapterTwo/alphabeticalOrder.py @@ -0,0 +1,10 @@ +letters = "pbil" +letters.__reversed__ +print(letters) + + +#iterator - is an object used to iterate over iterable objects like lists, tuples, dicts and sets. +# Examples - __iter_() and __next__() + +# for i in range(10): +# print(i) \ No newline at end of file diff --git a/nine/david/chapterTwo/arithmetic.py b/nine/david/chapterTwo/arithmetic.py new file mode 100644 index 0000000..29a45dc --- /dev/null +++ b/nine/david/chapterTwo/arithmetic.py @@ -0,0 +1,12 @@ +a = 27.5 + 2 +b = 27.5 - 2 +c = 27.5 * 2 +d = 27.5 / 2 +e = 27.5 // 2 +f = 27.5 ** 2 +print(a) +print(b) +print(c) +print(d) +print(e) +print(f) \ No newline at end of file diff --git a/nine/david/chapterTwo/arithmeticSmallestAndLargest.py b/nine/david/chapterTwo/arithmeticSmallestAndLargest.py new file mode 100644 index 0000000..f317043 --- /dev/null +++ b/nine/david/chapterTwo/arithmeticSmallestAndLargest.py @@ -0,0 +1,30 @@ +print("This program prints the sum, product, average, smallest and largest of your inputs") +input1 = int(input("Enter first number: ")) +input2 = int(input("Enter second number: ")) +input3 = int(input("Enter tnird number: ")) +print() + +sum = input1 + input2 + input3 +average = sum / 3 +product = input1 * input2 * input3 + +if input1 < input2 and input1 < input3: + smallest = input1 +elif input2 < input3: + smallest = input2 +else: + smallest = input3 + +if input1 > input2 and input1 > input2: + highest = input1 +elif input2 > input3: + highest = input2 +else: + highest = input3 + + +print("The sum of your inputs = ", sum) +print("The average of your inputs = ", average) +print("The product of your inputs = ", product) +print("Smallest of your inputs = ", smallest) +print("Highest of your inputs = ", highest) diff --git a/nine/david/chapterTwo/circleAreaDiameterCircumference.py b/nine/david/chapterTwo/circleAreaDiameterCircumference.py new file mode 100644 index 0000000..9603936 --- /dev/null +++ b/nine/david/chapterTwo/circleAreaDiameterCircumference.py @@ -0,0 +1,10 @@ +radius = 2 +pi = 3.14159 + +diameter = radius * pi +circumference = 2 * pi * radius +area = pi * radius ** 2 + +print("Diameter: ", diameter) +print("Circumeference: ", circumference) +print("Area: ", area) \ No newline at end of file diff --git a/nine/david/chapterTwo/consecutiveIntegers.py b/nine/david/chapterTwo/consecutiveIntegers.py new file mode 100644 index 0000000..a40c010 --- /dev/null +++ b/nine/david/chapterTwo/consecutiveIntegers.py @@ -0,0 +1,6 @@ +numbers = int(input("Enter a number")) +sum = 0 + +for num in range(1, numbers+1): + sum += num +print(sum) diff --git a/nine/david/chapterTwo/control.py b/nine/david/chapterTwo/control.py new file mode 100644 index 0000000..b07b987 --- /dev/null +++ b/nine/david/chapterTwo/control.py @@ -0,0 +1,9 @@ +my_var = 0 +if my_var % 2: + if my_var**3 != 27: + my_var = my_var + 4 + else: + my_var /= 1.5 +else: + my_var -= 2 +print(my_var) \ No newline at end of file diff --git a/nine/david/chapterTwo/divisibleBySeventeen.py b/nine/david/chapterTwo/divisibleBySeventeen.py new file mode 100644 index 0000000..8ad7bfd --- /dev/null +++ b/nine/david/chapterTwo/divisibleBySeventeen.py @@ -0,0 +1,16 @@ +print("How many three digit numbers are divisible by 17") +input("Press enter to find out....") +list_0f_num = [] + +for number in range(1000): + if number % 17 == 0: + list_0f_num.append(number) + +print(list_0f_num) +print(len(list_0f_num)) + +# continue is used to end the current iteration in a for loop or a while loop and continues the next iteration +# The break keyword is used to break out of a for/while loop + +# "is" operator is used to check if two variables are located in the same part of the memory +# "==" operator is used to check of a value equals the other. Returns true or false. diff --git a/nine/david/chapterTwo/gradePrint.py b/nine/david/chapterTwo/gradePrint.py new file mode 100644 index 0000000..c2086b4 --- /dev/null +++ b/nine/david/chapterTwo/gradePrint.py @@ -0,0 +1,4 @@ +grade = int(input("Enter grade: ")) + +if grade >= 90: + print("COngradulations, your grade of ", grade, "earns you an 'A' in this course!") diff --git a/nine/david/chapterTwo/heartRateCalculator.py b/nine/david/chapterTwo/heartRateCalculator.py new file mode 100644 index 0000000..bc65675 --- /dev/null +++ b/nine/david/chapterTwo/heartRateCalculator.py @@ -0,0 +1,13 @@ +age = int(input("Enter your age: ")) + +maximum_heart_rate = 220 - age +target_heart_rate = 85|100 * maximum_heart_rate +target_heart_rate_range = 0 + +for i in range(0, target_heart_rate): + target_heart_rate_range += target_heart_rate + +print("Maximum heart Rate = ", maximum_heart_rate) +print("Your targe heart rate = ", target_heart_rate) +print("Your target heart range = ", target_heart_rate_range, end=" ") + diff --git a/nine/david/chapterTwo/integerValueOfCharacter.py b/nine/david/chapterTwo/integerValueOfCharacter.py new file mode 100644 index 0000000..3810914 --- /dev/null +++ b/nine/david/chapterTwo/integerValueOfCharacter.py @@ -0,0 +1,13 @@ +print("Integer equivalent for 'A': ", ord('A')) +print("Integer equivalent for 'B': ", ord('B')) +print("Integer equivalent for 'C': ", ord('C')) +print("Integer equivalent for 'b': ", ord('b')) +print("Integer equivalent for 'c': ", ord('c')) +print("Integer equivalent for 'd': ", ord('d')) +print("Integer equivalent for '0': ", ord('0')) +print("Integer equivalent for '1': ", ord('1')) +print("Integer equivalent for '2': ", ord('2')) +print("Integer equivalent for '$': ", ord('$')) +print("Integer equivalent for '*': ", ord('*')) +print("Integer equivalent for '+': ", ord('+')) +print("Integer equivalent for ' ': ", ord(' ')) diff --git a/nine/david/chapterTwo/investmentReturn.py b/nine/david/chapterTwo/investmentReturn.py new file mode 100644 index 0000000..a76c3cf --- /dev/null +++ b/nine/david/chapterTwo/investmentReturn.py @@ -0,0 +1,12 @@ +p = 1000 +r = 7/100 +ten_years = 10 +twenty_years = 20 +thirty_years = 30 +ten_years_deposit = 1000 * ten_years +twenty_years_deposit = 1000 * twenty_years +thirty_years_deposit = 1000 * thirty_years + +a = p(1 + r)**10 + +print(int(a)) \ No newline at end of file diff --git a/nine/david/chapterTwo/largeAndVeryLarge.py b/nine/david/chapterTwo/largeAndVeryLarge.py new file mode 100644 index 0000000..6d03d4a --- /dev/null +++ b/nine/david/chapterTwo/largeAndVeryLarge.py @@ -0,0 +1,8 @@ +number = 5000 +number2 = 1000000 + +large = number ** 2835 +very_large = number2 ** 90875970 + +print(large) +print(very_large) \ No newline at end of file diff --git a/nine/david/chapterTwo/multiples.py b/nine/david/chapterTwo/multiples.py new file mode 100644 index 0000000..3381d55 --- /dev/null +++ b/nine/david/chapterTwo/multiples.py @@ -0,0 +1,7 @@ +num = 1024 +num2 = 2 + +if num % 4 == 0 and num2 % 10 == 0: + print("Yes") +else: + print("No") \ No newline at end of file diff --git a/nine/david/chapterTwo/oddEven.py b/nine/david/chapterTwo/oddEven.py new file mode 100644 index 0000000..71c5ff2 --- /dev/null +++ b/nine/david/chapterTwo/oddEven.py @@ -0,0 +1,7 @@ +print() +input = int(input("Enter a number: ")) + +if input % 2 == 0: + print(input, "is an even number") +else: + print(input, "is an odd number") \ No newline at end of file diff --git a/nine/david/chapterTwo/perfectSquare.py b/nine/david/chapterTwo/perfectSquare.py new file mode 100644 index 0000000..8d94cee --- /dev/null +++ b/nine/david/chapterTwo/perfectSquare.py @@ -0,0 +1,9 @@ +import math +user_number = int(input("Enter a number: ")) + +square_root = math.sqrt(user_number) + +if int(square_root + 0.5) ** 2 == user_number: + print(user_number, "is a perfect square") +else: + print(user_number, "is not a perfect square") diff --git a/nine/david/chapterTwo/printOutNumberOne.py b/nine/david/chapterTwo/printOutNumberOne.py new file mode 100644 index 0000000..bd8a7b1 --- /dev/null +++ b/nine/david/chapterTwo/printOutNumberOne.py @@ -0,0 +1,12 @@ +# 2.1 +x = 2 +y = 3 + +print("x =", x) +print("Print value of", x, "+", x, "is", x + x) +print("x =") +print((x + y), "=", (y + x)) + +# 2.2 +rating = input("Enter an integer rating between 1 - 10: ") #nothing + diff --git a/nine/david/chapterTwo/seperatingDigitsInAnInteger.py b/nine/david/chapterTwo/seperatingDigitsInAnInteger.py new file mode 100644 index 0000000..dd5f52e --- /dev/null +++ b/nine/david/chapterTwo/seperatingDigitsInAnInteger.py @@ -0,0 +1,7 @@ +input1 = int(input("Enter first number: ")) +input2 = int(input("Enter second number: ")) +input3 = int(input("Enter third number: ")) +input4 = int(input("Enter fourth number: ")) +input5 = int(input("Enter fifth number: ")) + +print(input1, " ", input2, " ", input3, " ", input4, " ", input5) \ No newline at end of file diff --git a/nine/david/chapterTwo/squaresAndCubes.py b/nine/david/chapterTwo/squaresAndCubes.py new file mode 100644 index 0000000..db7f650 --- /dev/null +++ b/nine/david/chapterTwo/squaresAndCubes.py @@ -0,0 +1,10 @@ +number = 0 +square = 0 +cube = 0 + +print("number square cube") + +for number in range(0, 6): + square = number * number + cube = number * number * number + print(f"{number}\t{square}\t{cube}")