Neural Sync Active
May 2026 - Python - Week 3 - GrPA 3 - Nested loops - GRADED
Registry Synced
May 2026 - Python - Week 3 - GrPA 3 - Nested loops - GRADED
891 words
4 min read
Reading compass
Now · Problem Statement
GrPA 3 - Nested loops - GRADED
Course: May 2026 - Python
Week 3
Problem Statement
Change in eligibility criteria to write oppe1 exam:
A1>=40/100 AND A2>=40/100 AND A3>=40/100 AND A4>=40/100
Create a multi-functional program that performs different tasks based on the user input. The program should support the following tasks:
Permutation (
permutation): Given a string s, print all the possible two-letter permutations(without repitition) of the letters in the string.Sorted Permutation (
sorted_permutation): Given a string s, print all the possible two-letter permutations(without repetition) of the letters in the string where the first character comes before the second one in alphabetical order. The order in which the permutations are printed is same as the previous one (Type: Filtering).Repeat the Repeat (
repeat_the_repeat): Given a number n, print the numbers from 1 to n in the same line and repeat this n times.Repeat Incrementally (
repeat_incrementally): Given a number n, print a pattern where the k-th line contains the first k numbers and there are n lines in total. For example, if n is 4, the output should be:Increment and Decrement (
increment_and_decrement): Given a number n, print a pattern where the k-th line should have the numbers from 1 to k and then back down to 1. For example, if n is 4, the output should be:Test Cases
Public Test Cases
Case 1
Input:
textpermutation abc
Expected Output:
textab ac ba bc ca cb
Actual Output:
textab ac ba bc ca cb
Case 2
Input:
textpermutation dog
Expected Output:
textdo dg od og gd go
Actual Output:
textdo dg od og gd go
Case 3
Input:
textsorted_permutation bca
Expected Output:
textbc ab ac
Actual Output:
textbc ab ac
Case 4
Input:
textsorted_permutation bad
Expected Output:
textbd ab ad
Actual Output:
textbd ab ad
Case 5
Input:
textrepeat_the_repeat 3
Expected Output:
text123 123 123
Actual Output:
text123 123 123
Case 6
Input:
textrepeat_the_repeat 4
Expected Output:
text1234 1234 1234 1234
Actual Output:
text1234 1234 1234 1234
Case 7
Input:
textrepeat_incrementally 4
Expected Output:
text1 12 123 1234
Actual Output:
text1 12 123 1234
Case 8
Input:
textrepeat_incrementally 5
Expected Output:
text1 12 123 1234 12345
Actual Output:
text1 12 123 1234 12345
Case 9
Input:
textincrement_and_decrement 3
Expected Output:
text1 121 12321
Actual Output:
text1 121 12321
Case 10
Input:
textincrement_and_decrement 4
Expected Output:
text1 121 12321 1234321
Actual Output:
text1 121 12321 1234321
Private Test Cases
Case 1
Input:
textpermutation xyz
Expected Output:
textxy xz yx yz zx zy
Actual Output:
textxy xz yx yz zx zy
Case 2
Input:
textpermutation hi
Expected Output:
texthi ih
Actual Output:
texthi ih
Case 3
Input:
textsorted_permutation cba
Expected Output:
textbc ac ab
Actual Output:
textbc ac ab
Case 4
Input:
textsorted_permutation adc
Expected Output:
textad ac cd
Actual Output:
textad ac cd
Case 5
Input:
textrepeat_the_repeat 2
Expected Output:
text12 12
Actual Output:
text12 12
Case 6
Input:
textrepeat_the_repeat 5
Expected Output:
text12345 12345 12345 12345 12345
Actual Output:
text12345 12345 12345 12345 12345
Case 7
Input:
textrepeat_incrementally 2
Expected Output:
text1 12
Actual Output:
text1 12
Case 8
Input:
textrepeat_incrementally 6
Expected Output:
text1 12 123 1234 12345 123456
Actual Output:
text1 12 123 1234 12345 123456
Case 9
Input:
textincrement_and_decrement 2
Expected Output:
text1 121
Actual Output:
text1 121
Case 10
Input:
textincrement_and_decrement 5
Expected Output:
text1 121 12321 1234321 123454321
Actual Output:
text1 121 12321 1234321 123454321
Official Solution
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
task = input()
if task == 'permutation':
s = input()
for i in range(len(s)):
for j in range(len(s)):
if i != j:
print(s[i] + s[j])
elif task == 'sorted_permutation':
s = input()
for i in range(len(s)):
for j in range(len(s)):
if i != j and s[i] < s[j]:
print(s[i] + s[j])
elif task == 'repeat_the_repeat':
n = int(input())
for _ in range(n):
for i in range(1, n+1):
print(i, end='')
print()
elif task == 'repeat_incrementally':
n = int(input())
for i in range(1, n+1):
for j in range(1, i+1):
print(j, end='')
print()
elif task == 'increment_and_decrement':
n = int(input())
for i in range(1, n+1):
for j in range(1, i+1):
print(j, end='')
for j in range(i-1, 0, -1):
print(j, end='')
print()
else:
print("Invalid")
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX