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
30 changes: 30 additions & 0 deletions hw_2w_answer1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
def rt (l, d, n):
if d > 0:
k = l.index(d)
nl = []
nl = l[k+d:]+l[0:k+d]
return nl
else:
d = d *-1
k = l.index(d)
nl = []
nl = l[k+1:]+l[0:k+1]
return nl

ltn=[]
print()
vl=int(input("Please put the number (0 to finish) :"))

while vl!=00:
ltn.append(vl)
vl=int(input("Please put the number (0 to finish) :"))

sz = len(ltn)

print('\n', ltn, '\n')

print("The list size is: ", sz)

d = int(input(f"\nPlease put shift number smaller than {sz} : "))

print('\n',rt(ltn, d, sz), '\n')
13 changes: 13 additions & 0 deletions hw_2w_answer2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
dicc = {}
def prt_lttr (txt):
for lttr in txt:
if lttr == " ":
vc = lttr
elif lttr =="," or lttr =="'" or lttr == '"' or lttr =="." or lttr ==";" or lttr =='@' :
vc = lttr
elif lttr in dicc:
dicc[lttr]= dicc [lttr]+1
else:
dicc[lttr]=1
print(f"({dicc})")
prt_lttr(input("Please, put the phrase : ").lower())
49 changes: 49 additions & 0 deletions hw_2w_answer3.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
st1 = list(input("\nPlease put the first word: "))
st2 = list(input("\nPlease put the second word: "))

if " " in st1:
st1.remove(" ")
elif " " in st2:
st2.remove(" ")


st1 = set(st1)
st2 = set(st2)

my_set ={}

def mtw (st):
my_set = sorted(st1.intersection(st2)) # asp

nl= [' '] * 3

print()

for i in ((my_set)):

nl[0] = nl[0] + i

if nl[0] == " ":
nl[0] = "No match"

my_set = sorted(st1.difference(st2)) # hr

for i in ((my_set)):

nl[1] = nl[1] + i

if nl[1] == " ":
nl[1] = "No match"

my_set = sorted(st2.difference(st1))

for i in ((my_set)):

nl[2] = nl[2] + i

if nl[2] == " ":
nl[2] = "No match"

print(nl, '\n')

mtw(my_set)
13 changes: 13 additions & 0 deletions hw_2w_answer4.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
fn = int(input('Please, put the first number: '))
sn = int(input('Please, put the second number: '))
tn = int(input('Please, put the third number: '))

n = (fn * sn * tn)

def palin_ant (n):
for i in range(n-1, 0, -1):
if str(i) == str(i)[::-1]:
print(i)
return(i)

palin_ant(n)