0% found this document useful (0 votes)
7 views5 pages

TPEC-3 - Partial Code - Set 1

Uploaded by

rakshuu397
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views5 pages

TPEC-3 - Partial Code - Set 1

Uploaded by

rakshuu397
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

SET - 1

Regular Programs

1. List Comprehensions
if __name__ == '__main__':

x = int(input())

y = int(input())

z = int(input())

n = int(input())

//insert your code here…

2. Lists

if __name__ == '__main__':
N = int(input())
command=[]
for i in range(N):
command.append(input().split())

//insert your code here…

3. Nested Lists

if __name__ == '__main__':
lis=[]
for _ in range(int(input())):
name = input()
score = float(input())
lis.append([name,score])

lis.sort(key=lambda lis:lis[1])

//insert your code here…


4. sWAP cASE

def swap_case(s):
//insert your code here…

if __name__ == '__main__':
s = input()
result = swap_case(s)
print(result)

5. Find a string

def count_substring(string, sub_string):


//insert your code here…

if __name__ == '__main__':
string = input().strip()
sub_string = input().strip()

count = count_substring(string, sub_string)


print(count)

6. Designer Door Mat

n,m=input().split()
c='|'
v='.'

n=int(n)
m=int(m)
//insert your code here…

7. Alphabet Rangoli
n=int(input())
for i in range(n-1,-1,-1):
for j in range(i):
//insert your code here…
for j in range(n-1,i,-1):
//insert your code here…
for j in range(i,n):
//insert your code here…
for j in range(2*i):
//insert your code here…
print()
for i in range(1,n):
//insert your code here…

8. String Validators

def pr(t):
if t==1:
print(True)
else:
print(False)

if __name__ == '__main__':
s = input()
//insert your code here…
Additional Programs
1. No Idea!
n,m=list(map(int, input().split()))
//insert your code here…
2. Word Order

from collections import OrderedDict

d=OrderedDict()
n=int(input())
for i in range(n):
//insert your code here…
3. Find the runner-up score
if __name__ == '__main__':

n = int(input())

arr = map(int, input().split())

//insert your code here…

4. The Minion Game

def minion_game(string):
k=0
s=0
vowels="AaEeIiOoUu"
for i in range(len(string)):
//insert your code here…
if __name__ == '__main__':
s = input()
minion_game(s)
5. Compress the string

S=input()
i=1
a=[]
count=1
while i<len(S):
//insert your code here…
for i in a:
print(i,end=' ')

You might also like