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
17 changes: 17 additions & 0 deletions answer1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
def rotateArray(a, d):
n = len(a)
if d > 0:
a[:] = a[-d:n] + a[:-d]

if d > n:
d = d % n
print(a)

else:
a[:] = a[-d:n] + a[:-d]

return a
list = list(map(int,input('Enter a list?').strip().split()))
number = int(input('Enter a number?'))

print(rotateArray(list,number))
19 changes: 19 additions & 0 deletions answer2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
sentence = input('Please write a sentence: ')
sentence = sentence.replace(' ', '')

punc = """!()-[]{ };:'"\,<>./?@#$%^&*_~"""
new_form_sentence = ' '
dict = {}
for i in sentence:

if i not in punc:
new_form_sentence += i

for keys in new_form_sentence:
keys = keys.lower()
keys = keys.strip()

dict[keys] = dict.get(keys,0) + 1
new_dict = list(zip(dict.keys(), dict.values()))

print(str(new_dict))
24 changes: 24 additions & 0 deletions answer3.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
def common(str1, str2):
str1 = str1.lower()
str2 = str2.lower()
list1 = []
list2 = []
punc = """!()-[]{ };:'"\,<>./?@#$%^&*_~"""

for i in str1:
if i not in punc:
list1 += i
for i in str2:
if i not in punc:
list2 += i

shared_letters = sorted(set(list1) & set(list2))
unique_to_str1 = sorted(set(list1) - set(list2))
unique_to_str2 = sorted(set(list2) - set(list1))

return ' '.join (str(e) for e in shared_letters), ' '.join(str(e) for e in unique_to_str1), ' '.join(str(e) for e in unique_to_str2)


str1 = input('Please type a word: ')
str2 = input('Please type a second word: ')
print(common(str1, str2))
9 changes: 9 additions & 0 deletions answer4.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
def some_function(a, b, c):
mult = a * b * c
return ('The nearest palindromical prime number less than {}'.format(mult))

a = int(input('Please enter first number: '))
b = int(input('Please enter a second number: '))
c = int(input('Please enter last number: '))

print (some_function(a, b, c))