-
Notifications
You must be signed in to change notification settings - Fork 0
/
array.py
181 lines (105 loc) · 2.69 KB
/
array.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
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
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
#python day 2, 3, 4 ,5 6,7 ,8&9 # Declare second integer, double, and String variables.
j = 0
e = 0.0
t = “”
# Read and save an integer, double, and String to your variables.
j = int(raw_input())
e = float(raw_input())
t = str(raw_input())
# Print the sum of both integer variables on a new line.
print i + j
# Print the sum of the double variables on a new line.
print d + e
print s + t
# Concatenate and print the String variables on a new line
# The ‘s’ variable above should be printed first.
import math
import sys
mealcost=float(raw_input())
tipp=float(raw_input())
taxp=float(raw_input())
tip=float(mealcost*tipp/100)
tax=float(mealcost*taxp/100)
total=int(math.floor(float(mealcost+tax+tip)))
print “The total meal cost is “ + str(total) + “ dollars.”
class Person:
def __init__(self,initialAge):
if initialAge < 0:
self.initialAge = 0
print “Age is not valid, setting age to 0.”
else:
self.initialAge = initialAge
# Add some more code to run some checks on initialAge
def amIOld(self):
if self.initialAge < 13:
print “You are young.”
elif self.initialAge < 18:
print “You are a teenager.”
else:
print “You are old.”
# Do some computations in here and print out the correct statement to the console
def yearPasses(self):
self.initialAge = self.initialAge + 1
# Increment the age of the person in here
#!/bin/python
import sys
N = int(raw_input().strip())
for i in range(1,11):
print str(N) +” x “ +str(i) +” = “+str(N*i)
# Enter your code here. Read input from STDIN. Print output to STDOUT
import sys
n = int(raw_input().strip())
S = “”
odd = “”
even = “”
for i in range(0,n):
S = raw_input()
for j in xrange(0,len(S),2):
even = even + S[j]
#print S[j]
#j = j + 2
for k in xrange(1,len(S),2):
odd = odd + S[k]
#print S[k]
#k = k + 1
print even +” “+ odd
odd = “”
even = “”
#!/bin/python
import sys
n = int(raw_input().strip())
arr = map(int,raw_input().strip().split(‘ ‘))
arr.reverse()
final =””
for i in range(0, n):
final = final + str(arr[i]) +” “
print final
# Enter your code here. Read input from STDIN. Print output to STDOUT
n = int(raw_input().strip())
i = 0
#print n
e = “”
arr = []
d = dict(raw_input().split() for _ in range(n))
#for keys,values in d.items():
# print keys +” “ +values
#print d
e = str(raw_input())
#while e:
# arr.append(e)
#print e
# e = str(raw_input())
#print e
#strs = [“” raw_input() while not _]
while e:
if e in d:
print e +”=”+d[e]
else:
print “Not found”
e = str(raw_input())
if not e:
break
import math
n = int(raw_input())
m = math.factorial(n)
print str(m)