Skip to content

Instantly share code, notes, and snippets.

View UcheAnyiam's full-sized avatar
🤓

Uche Anyiam UcheAnyiam

🤓
View GitHub Profile
@UcheAnyiam
UcheAnyiam / How to iterate through a dictionary in Python
Last active March 28, 2021 11:23
Homework Assignment #7: Dictionaries and Sets Details: Return to your first homework assignments, when you described your favourite song. Refactor that code so all the variables are held as dictionary keys and value. Then refactor your print statements so that it's a single loop that passes through each item in the dictionary and prints out it's…
"""
pirple.com/python
Python Homework Assignment #7: Dictionaries and Sets
Details:
Return to your first homework assignments, when you described your favorite song.
Refactor that code so all the variables are held as dictionary keys and value.
Then refactor your print statements so that it's a single loop that passes through each item in the dictionary
and prints out it's key and then it's value.
Extra Credit:
Create a function that allows someone to guess the value of any key in the dictionary,
@UcheAnyiam
UcheAnyiam / Adding items to a list
Last active March 28, 2021 11:15
Homework Assignment #4: Lists Details: Create a global variable called myUniqueList. It should be an empty list to start. Next, create a function that allows you to add things to that list. Anything that's passed to this function should get added to myUniqueList, unless its value already exists in myUniqueList. If the value doesn't exist already…
"""
pirple.com/python
Homework Assignment #4: Lists
Create a global variable called myUniqueList. It should be an empty list to start.
Next, create a function that allows you to add things to that list.
Anything that's passed to this function should get added to myUniqueList,
unless its value already exists in myUniqueList.
If the value doesn't exist already it should be added and the function should return True.
If the value does exist, it should not be added, and the function should return False;
Finally, add some code below your function that tests it out.
@UcheAnyiam
UcheAnyiam / Fizz,Buzz,Prime - Python
Last active February 25, 2021 20:07
This is the source code that lists the prime number and the 'fizz' and 'buzz' numbers depending on the range choses.
for number in range(2,101):
if number % 3 == 0 and number % 5 == 0:
print(number,"fizzbuzz")
continue
if number % 3 == 0:
print (number, "fizz")
continue
if number % 5 == 0:
print (number, "buzz")
continue