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
20 changes: 20 additions & 0 deletions assignment-1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@


def get_pascal(n):

for x in range(n+1):
print ("")

z = 1
for y in range(1, x+1):
#print(C, ' ', sep='', end='')
print (z , end=" ")
z = z * (x - y)
z = z // y
#print()


result = get_pascal(5)
print (result)


15 changes: 15 additions & 0 deletions assignment-2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@

def hyphen_sort (words) :


list = words.split ("-") # split by the hyphen
list =sorted(list)

final = '-'.join(list) #making sorted string
return (final)


words = input('enter the words: ')
words = hyphen_sort (words)

print (words)
20 changes: 20 additions & 0 deletions assignment-3.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@

def is_perfect(n):

total = 0

for x in range (1,n):
if n % x == 0 :
total += x

if total == n :
return("Yes")
else:
return("No")


number = input("enter number: ")
number = int (number)

print ("is the number perfect: ", end="")
print(is_perfect(number))
69 changes: 69 additions & 0 deletions assignment-4.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
import random
import secrets
import string

#password_length = 10
#number_lowercase = 4
#number_uppercase = 4
#number_digits = 5
#number_special_characters = 3


print ("Welcome to password generator!")
print ("How would you like your new password...")
password_length = int (input("enter password length: "))
number_lowercase = int (input("how many lowercase characters: "))
number_uppercase = int (input("how many uppercase characters: "))
number_digits = int (input("how many digits: "))
number_special_characters = int (input("how many special characters: "))



def generate_password (password_length, number_lowercase,number_uppercase, number_digits, number_special_characters) :

letter_lower = string.ascii_lowercase
letters_upper = string.ascii_uppercase
digits = string.digits
special_chars = string.punctuation

#rand_lower = ""
#rand_upper = ""
#rand_digit = ""
#rand_special = ""
password_char_list = ""

for x in range(1, number_lowercase) :
password_char_list += random.choice(letter_lower)


for x in range(1, number_uppercase) :
password_char_list += random.choice(letters_upper)

for x in range(1, number_digits) :
password_char_list += random.choice(digits)


for x in range(1, number_special_characters) :
password_char_list += random.choice(special_chars)




#print (password_char_list)


final_password = []
for x in range(password_length):

random_char = random.choice(password_char_list)
final_password.append(random_char)



final_password = "".join(final_password)

print(final_password)


print ("your new password is: ", end="")
generate_password (password_length, number_lowercase,number_uppercase, number_digits, number_special_characters)
9 changes: 9 additions & 0 deletions bonus-1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
dictionaries = [{'make': 'Nokia', 'model': 216, 'color': 'Black'},
{'make': 'Mi Max', 'model': '2', 'color': 'Gold'},
{'make': 'Samsung', 'model': 7, 'color': 'Blue'}]

# the output shown in the readme file suggests it's sorting by "color" key?
sorted = sorted(dictionaries, key = lambda x:x["color"])


print (sorted)
13 changes: 13 additions & 0 deletions bonus-2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
list_numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]


#even_list = sorted( lambda x: x %2 != 0)

even_list = list( filter(lambda x: x%2 == 0, list_numbers) )
print("even numbers are: ", even_list)


odd_list = list( filter(lambda x:x %2 != 0, list_numbers) )
print("odd numbers are: ", odd_list)