-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.py
More file actions
160 lines (128 loc) · 2.81 KB
/
test.py
File metadata and controls
160 lines (128 loc) · 2.81 KB
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
email="abc@abc.com"
n=(email.split('@'))
print("Hi {0}, Welcome to {1}".format((n[0].capitalize()),(((n[1].split('.'))[0]).capitalize())))
s= [x if (x<=5) else 'not matched' for x in [2,3,4,5,6]]
print(s)
#mark_apple if apple_is_ripe else leave_it_unmarked for apple in apple_box
class Solution(object):
def intToRoman(self, num):
dict = ["M","CM","D","CD","C","XC","L","XL","X","IX","V","IV","I"]
nums = [1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1]
result = ""
for letter, n in zip(dict, nums):
result += letter * int(num / n)
num %= n
return result
d=Solution()
i=d.intToRoman(593)
print(i)
n=2
if 0<=n<=25:
kth=n
else:
kth=n%26
y=[chr(x) for x in range(65,91)]
print(y)
s='A'
res=''
for i in s:
res+= y[((y.index(i))+kth)%26]
print(res)
def ciphertext(s,n):
if 0<=n<=25:
kth=n
else:
kth=n%26
y=[chr(x) for x in range(65,91)]
res=''
for i in s:
res+= y[((y.index(i))-kth)]
return res
print(ciphertext('KALYAN',2))
#!/bin/python3
import math
import os
import random
import re
import sys
#
# Complete the 'caesarCipher' function below.
#
# The function is expected to return a STRING.
# The function accepts following parameters:
# 1. STRING s
# 2. INTEGER k
#
def caesarCipher(s, k):
if 0<=k<=25:
kth=k
else:
kth=k%26
y=[chr(x) for x in range(65,91)]
res=''
for i in s:
if i not in y:
if i.upper() in y:
i=i.upper()
res+= y[((y.index(i))+kth)%26].lower()
else:
res+=i
else:
res+= y[((y.index(i))+kth)%26]
return res
if __name__ == '__main__':
fptr = open(os.environ['OUTPUT_PATH'], 'w')
n = int(input().strip())
s = input()
k = int(input().strip())
result = caesarCipher(s, k)
fptr.write(result + '\n')
fptr.close()
s='SOSSOSSPSSXPS*S'
result=0
if len(s)%3==0:
k=[s[i:i+3] for i in range(0,len(s),3)]
for j in k:
if j!='SOS':
result+=1
else:
result ="Invalid Signal"
def marsExploration(s):
result=0
o="SOS"*int(len(s)/3)
for i,j in zip(s,o):
if i!=j:
result+=1
return result
class A:pass
class B:pass
class C:pass
class D(B,C,A):pass
class E(D):pass
class F(D):pass
class G(E,F):pass
l=G.mro()
for i in l:
print(i,end='\n')
import urllib.request
f=urllib.request.urlopen('https://www.codingem.com/python-print-without-parenthesis/')
f2=open("i.html","w")
for line in f:
b=line.decode().strip()
f2.write(b)
out=""
c=1
s="Kalyannn"
for i in range(len(s)-1):
if s[i]==s[i+1]:
c+=1
else:
out=out+s[i]+str(c)
c=1
out=out+s[i+1]+str(c)
print(out)
ot=""
for i in range(len(out)):
if out[i].isalpha() and out[i+1].isdigit():
ot=ot+str(out[i])*int(out[i+1])
print(ot)