Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue 1 #159

Closed
wants to merge 3 commits into from
Closed
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
67 changes: 67 additions & 0 deletions python/beginner/profile_lookup_vinimlo.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
import json

contacts = [
{
"firstName": "Akira",
"lastName": "Laine",
"number": "0543236543",
"likes": ["Pizza", "Coding", "Brownie Points"]
},
{
"firstName": "Harry",
"lastName": "Potter",
"number": "0994372684",
"likes": ["Hogwarts", "Magic", "Hagrid"]
},
{
"firstName": "Sherlock",
"lastName": "Holmes",
"number": "0487345643",
"likes": ["Intriguing Cases", "Violin"]
},
{
"firstName": "Kristian",
"lastName": "Vos",
"number": "unknown",
"likes": ["JavaScript", "Gaming", "Foxes"]
}
];

data = json.loads(json.dumps(contacts))

def look_up_profile(name, field):

boolName = False
boolField = False

for item in data:
for title, value in item.items():
if title == "firstName":
firstName = value
if name == firstName:
boolName = True
boolField, fieldValue = getsField(item, field)

if boolName:
if boolField:
return print(fieldValue)
else:
return print("No such property")
else:
return print("No such contact")

pass

def getsField(item, field):

boolField = False
fieldValue = None

for title, value in item.items():
if title == field:
boolField = True
fieldValue = value

return boolField, fieldValue

look_up_profile("Akira", "like")
13 changes: 13 additions & 0 deletions python/beginner/sum_of_all_numbers_vinimlo.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
def sum_all(list):
sum = 0
if(list[0] < list[1]):
for i in range(list[0], list[1]+1):
sum += i
else:
for i in range(list[1], list[0]+1):
sum += i
return sum

# sum_all([1, 4])

print(sum_all([1, 4]))