-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtugas for loop.py
52 lines (43 loc) · 1.26 KB
/
tugas for loop.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
inputKalimat =input('maskkan kalimatmu disini :')
def getReverse(kalimat):
outputan=''
listkata=inputKalimat.split(' ')
for kata in listkata:
outputan += kata[::-1] + ' '
return outputan
print(f'hasil balikan :{outputan}')
print(getReverse(inputKalimat))
'''
Abjad = {'A' : '.-',
'B':'-...',
'C' : '-.-.','D': '-..','E':'.','F':'..-.',
'G':'--.','H':'....','I':'..','J':'.---','K':'-.-',
'L':'.-..','M':'--','N':'-.','O':'---','P':'.--.','Q':'--.-',
'R':'.-.','S':'...','T':'-','U':'..-','V':'...-',
'W':'.--','X':'-..-','Y':'-.--','Z':'--..',' ':'|','1':'.----','2':'..---',
'3':'...--','4':'....-','5':'.....','6':'-....','7':'--...','8':'---..',
'9':'----.','0':'-----' }
x= input('masukkan kata/kalimat:')
y= list(x)
def kodeMorse(x):
morseCode=''
for i in x:
morseCode += Abjad[i.upper()]
# morseCode +='/'
return morseCode
print(kodeMorse(x))
'''
'''
# caesar cipher
alpabet = 'abcdefghijklmnopqrstuvwxyz'
inputan= input('masukkan pesanmu :')
loncatan = int(input('masukkan jumlah loncatan :'))
outputan =''
for i in range(len(inputan)):
karakter = inputan[i]
# print(karakter)
location = alpabet.find(karakter)
newLocation= (location+loncatan)%26
outputan += alpabet[newLocation]
print(outputan)
'''