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
35 changes: 35 additions & 0 deletions nine/david/Tasks/artificial.py
Original file line number Diff line number Diff line change
@@ -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()

44 changes: 44 additions & 0 deletions nine/david/Tasks/chat_bot.py
Original file line number Diff line number Diff line change
@@ -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()
102 changes: 102 additions & 0 deletions nine/david/Tasks/check.py
Original file line number Diff line number Diff line change
@@ -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)
54 changes: 54 additions & 0 deletions nine/david/Tasks/classes.py
Original file line number Diff line number Diff line change
@@ -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():










28 changes: 28 additions & 0 deletions nine/david/Tasks/concatinate.py
Original file line number Diff line number Diff line change
@@ -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()


Loading