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
14 changes: 14 additions & 0 deletions DictionaryWithList.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# 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] }
list_a = [5,3,9,0,2,3,1]
list_b = [4,7,5,1,2]
list_c = [8,1,3,2,4]
list_a.sort()
list_b.sort()
list_c.sort()
data['a'] = list_a
data['b'] = list_b
data['c'] = list_c
print(data)
22 changes: 22 additions & 0 deletions ListChange.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# 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 = [2,3,5,7,11,13,17,19]

while True:
i = 0
try:
number_exe = int(input('Please Enter The Number of Execution : '))
except ValueError:
print("Please Input Integer Only - TRY Again...")
continue
while i<number_exe:
first = numbers[0]
numbers.pop(0)
numbers.append(first)
print(numbers)
i +=1
31 changes: 31 additions & 0 deletions NumberOfOccurences.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# 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)
occ_10 = occ_ = occ_20 = occ_50 = occ_60 = occ_70 = occ_80 = 0
Num_Occurences ={}
for item in tuple1:
if item == 10:
occ_10 = occ_10+1
Num_Occurences['10'] = occ_10
for item in tuple1:
if item == 20:
occ_20 = occ_20+1
Num_Occurences['20'] = occ_20
for item in tuple1:
if item == 50:
occ_50 = occ_50+1
Num_Occurences['50'] = occ_50
for item in tuple1:
if item == 60:
occ_60 = occ_60+1
Num_Occurences['60'] = occ_60
for item in tuple1:
if item == 70:
occ_70 = occ_70+1
Num_Occurences['70'] = occ_70
for item in tuple1:
if item == 80:
occ_80 = occ_80+1
Num_Occurences['80'] = occ_80
print(Num_Occurences)