Day 6: Let's Review :
# Enter your code here. Read input from STDIN. Print output to STDOUT
t=input()
for i in range(0,t):
string =raw_input()
print ''.join([string[i] for i in range(0,len(string),2)])+" "+''.join([string[i] for i in range(1,len(string),2)])
Day 7: Arrays :
#!/bin/python
import sys
n = int(raw_input().strip())
arr = map(int,raw_input().strip().split(' '))
arr.reverse()
print " ".join(str(i) for i in arr)
Day 8: Dictionaries and Maps :
# Enter your code here. Read input from STDIN. Print output to STDOUT
t=input()
data=dict()
index=[]
for i in range(0,t):
array=raw_input().split(" ")
data[array[0]]=array[1]
for k in range(0,t):
inp= raw_input()
if data.has_key(inp):
print inp+"="+data[inp]
else:
print "Not found"
Day 9: Recursion :
n= input()
def factorial(n):
if n ==0 or n==1 :
return 1
else:
return n*factorial(n-1)
print factorial(n)
# Enter your code here. Read input from STDIN. Print output to STDOUT
t=input()
for i in range(0,t):
string =raw_input()
print ''.join([string[i] for i in range(0,len(string),2)])+" "+''.join([string[i] for i in range(1,len(string),2)])
Day 7: Arrays :
#!/bin/python
import sys
n = int(raw_input().strip())
arr = map(int,raw_input().strip().split(' '))
arr.reverse()
print " ".join(str(i) for i in arr)
Day 8: Dictionaries and Maps :
# Enter your code here. Read input from STDIN. Print output to STDOUT
t=input()
data=dict()
index=[]
for i in range(0,t):
array=raw_input().split(" ")
data[array[0]]=array[1]
for k in range(0,t):
inp= raw_input()
if data.has_key(inp):
print inp+"="+data[inp]
else:
print "Not found"
Day 9: Recursion :
n= input()
def factorial(n):
if n ==0 or n==1 :
return 1
else:
return n*factorial(n-1)
print factorial(n)
No comments:
Post a Comment