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
26 changes: 26 additions & 0 deletions assignment_1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# HOMEWORK_1
# Write a Python program which executes following rules on this given list => numbers = [2, 3, 5, 7, 11, 13, 17, 19]
# -take an input(number) from the user
# -take out the first element of the list and put it at the end. Do this x times that in the first step the user indicated.
# -print the list
# -(OPTIONAL) make sure there is not an error while taking input

numbers = []
for i in range(2,20):
check = True
for j in range(2,i):
if(i%j == 0):
check = False
break
if(check):
numbers.append(i)

print(numbers)


n = int(input("Enter n: "))

for i in range(n):
numbers.append(numbers.pop(0))

print(numbers)
10 changes: 10 additions & 0 deletions assignment_2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Write a Python program that returns the following dictionary with sorted values.
# NOTE: Dictonaries have keys and values. Here the values are lists.
# So, the returned dictonary should have sorted values(list).

data = { 'a': [5, 3, 9, 0, 2, 3, 1], 'b': [4, 7, 5, 1, 2], 'c': [8, 1, 3, 2, 4] }

for i in data:
data[i] = sorted(data[i])

print(data)
16 changes: 16 additions & 0 deletions assignment_3.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Write a Python program that returns a dictionary
# which consists the unique elements in the following tuple as keys and
# the number of occurrences of elements as values.


tuple1 = (20, 10, 60, 70, 50, 20, 80, 20, 10, 20, 60, 60, 50)

new = {}
s = set(tuple1)

for i in s:
new[i]=tuple1.count(i)

print(new)