Python 3 problems
1.
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
Def alienNumbers (s) :
A=0
For I in s:
If I=="T" :
A=a + 1024
Elif I=="y" :
A=a + 598
Elif I=="!" :
A=a + 121
Elif I=="a" :
A=a + 42
Elif I=="N" :
A=a + 6
Elif I=="U" :
A=a + 1
The else:
A=a + 0
Return a
Print (alienNumbers (" a! Ya!!! U!!! NaU "))
Print (alienNumbers (" aaaUUU "))
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
Rewrite this, without string method and without ist/array, a tuple, the set, a dictionary
Print (alienNumbers (" "))
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
Sample output:
> AlienNumbers (" a! Ya!!! U!!! NaU ")
1095
> AlienNumbers (" aaaUUU ")
129
> AlienNumbers (" ")
0
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
2.
Write a encrypt (s)
Rules: no ist/array, a tuple, the set, a dictionary
You write your information upside down (so, Hello, world became dlrow, olleH), but you don't stop there, because it is too easy to crack - who can think out! Now you have written on the reverse, then you begin by on the opposite side of the string, the characters together, now you have written on the reverse, and then starting on the opposite side of the string, you put these characters together, so, the first and last character becomes dlrow olleH, so the first and the last one character becomes the encrypted string, the first and the second character in the second and the second last character becomes the third and fourth characters of the string, and so on, therefore, the Hello, world eventually became dHlerlolwo,
Sample output:
> Encrypt (" Hello, world ")
'dHlerlolwo,'
>> Encrypt (" 1234 ")
'4132'
> Encrypt (" 12345 ")
'51423'
> Encrypt (" 1 ")
'1'
> Encrypt (" 123 ")
'312'
> Encrypt (" 12 ")
'21'
> Encrypt (" Secret Message ")
'eSgeacsrseetM'
> Encrypt (", '4' r ")
"R," 4 "
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
3.
Rules: no ist/array, a tuple, the set, a dictionary
Continuously repeating characters is least letters, below is the sample
Ana is no characters,
Borborygmus not square, because it is a child of the word bor twice in a row,
Abracadabra is a square,
Repetitive is not square, because it is a child of the word ti repeated twice in a row,
Grammar is not squarefree, because the child word repeated twice in a row,
Gaga not square word, because the child word repeated twice in a row, ga
Rambunctious is no squares,
Abcab is no squares,
There are no square abacaba,
GHT ZRTZGHTGHTGHTGHTQ not squarefree, because the son word repeated twice (is actually three times, but as long as find two is enough) repeat, thus come to the conclusion that the word is not no square),)
Aa word not square, because a child word repeated twice,
Zatabracabrac not square word, because the child word abrac repeated twice in a row,
Write a squarefree (s)
Sample output:
> Squarefree (" ")
True
> Squarefree (" a ")
True
> Squarefree (" ZRTZGHTGHTGHTQ ")
False
> Squarefree (" abcab ")
True
> Squarefree (" 12341341 ")
False
> Squarefree (" 44 ")
False