diff --git a/hw_2w_answer1.py b/hw_2w_answer1.py new file mode 100644 index 0000000..313d473 --- /dev/null +++ b/hw_2w_answer1.py @@ -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') diff --git a/hw_2w_answer2.py b/hw_2w_answer2.py new file mode 100644 index 0000000..3f4991d --- /dev/null +++ b/hw_2w_answer2.py @@ -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()) \ No newline at end of file diff --git a/hw_2w_answer3.py b/hw_2w_answer3.py new file mode 100644 index 0000000..73df62d --- /dev/null +++ b/hw_2w_answer3.py @@ -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) \ No newline at end of file diff --git a/hw_2w_answer4.py b/hw_2w_answer4.py new file mode 100644 index 0000000..34f828e --- /dev/null +++ b/hw_2w_answer4.py @@ -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) \ No newline at end of file