Registry Synced

Jan 2026 - Python - Week 3 - GrPA 2 - For Loop - GRADED

340 words
2 min read

Graded Assignment

Course: Jan 2026 - Python

Overview Question Test Cases Solution
GrPA 2 - For Loop - GRADED
Submission deadline has passed for this assignment
Due Mar 04, 2026 at 11:59 PM IST
Instructions
Use "Test Run" to verify your code with public test cases.
Press "Submit" to have your assignment evaluated.
You can submit your assignment multiple times up until the deadline.
Make sure to submit your final code by the deadline to receive your score.
Summary
100 out of100
Score
Public Tests
View details
14/14 Passed
Submitted on Mar 04, 2026 at 9:46 PM IST
Private Tests
View details
14/14 Passed
Submitted on Mar 06, 2026 at 10:50 PM IST
⏱️ 00:07 ✕
🔓 Unlock 📖 Ref 🔄 Reset
Python3
+ -
python
# Note this prefix code is to verify that you are not using any for loops in this exercise. This won't affect any other functionality of the program.
with open(__file__) as f:
    content = f.read().split("# <eoi>")[2]
if "while " in content:
    print("You should not use while loop or the word while anywhere in this exercise")

# your code should not use more than 7 for loops
# assuming one for loop per problem
if content.count("for ")>7:
    print("You should not use more than 7 for loops")

# This is the first line of the exercise
task = input()
# <eoi>

if task == 'factorial':
    n = int(input())
    result = 1
    i = 1
    for i in range(1,n+1):
    result*=i
    print(result)

elif task == 'even_numbers':
    n = int(input())
    for i in range(0,n+1,2):
    print(i)

elif task == 'power_sequence':
    n = int(input())
    value = 1
    for i in range(n):
    print(value)
    value *= 2

elif task == 'sum_not_divisible':
    n = int(input())
    total = 0
    for i in range(1,n):
    if i % 4 !=0 and i % 5 !=0:
    total += i
    print(total)

elif task == 'from_k':
    n = int(input())
    k = int(input())
    count = 0

    for num in range(k,0,-1):
    if num % 2 == 1 and '5' not in str(num) and '9' not in str(num):
Document Outline
Table of Contents
System Normal // Awaiting Context

Intelligence Hub

Navigate the knowledge graph to generate context. The Hub adapts dynamically to surface backlinks, related notes, and metadata insights.