NPTEL » The Joy of Computing using Python
Please scroll down for latest Programs 👇
Week 2 - Programming Assignment 1
Due on 2025-08-07, 23:59 IST
Gautam Gambhir, freshly appointed head coach for India’s 2025 away Test series against England, has asked the new analyst, Aryan, to keep a quirky statistic:
“At the end of each day’s play,” Gambhir says, “tell me the total runs we scored in every odd-numbered over—1st, 3rd, 5th … all the way up to the last over bowled that day. It helps me spot momentum in the sessions where bowlers are freshest.”
Aryan realises the job boils down to simple maths: if n is the last over of the day (always a positive integer), he just needs the sum of all odd integers from 1 through n.
Your task is to step into Aryan’s shoes and automate this little ritual.
Input Format:
A single integer
Output Format:
A single integer: the sum of all odd numbers from 1 to n
Public Test Cases | Input | Expected Output | Actual Output | Status |
---|---|---|---|---|
Test Case 1 | 1 | 1 | 1\n
| Passed after ignoring Presentation Error |
Test Case 2 | 2 | 1 | 1\n
| Passed after ignoring Presentation Error |
Test Case 3 | 10 | 25 | 25\n
| Passed after ignoring Presentation Error |
Week 2 - Programming Assignment 2
Due on 2025-08-07, 23:59 IST
A high-security vault uses a custom PIN authentication mechanism. To reduce the chances of brute-force attacks, the system only allows PINs that are Neon Numbers.
The rule is:
A PIN is valid if the sum of the digits of its square equals the PIN itself.
Your Task: Write a Python program that reads a numeric PIN input by the user and validates whether it is a Neon Number or not.
Public Test Cases | Input | Expected Output | Actual Output | Status |
---|---|---|---|---|
Test Case 1 | 0 | Neon Number | Neon Number\n
| Passed after ignoring Presentation Error |
Test Case 2 | 1 | Neon Number | Neon Number\n
| Passed after ignoring Presentation Error |
Test Case 3 | 2 | Not Neon Number | Not Neon Number\n
| Passed after ignoring Presentation Error |
Week 2 - Programming Assignment 3
Due on 2025-08-07, 23:59 IST
While analysing intercepted communications, TASC officer Srikant Tiwari suspects that some messages might be carrying hidden signals. One of the red flags used by the agency is the density of vowels in a message — unusually high vowel counts may indicate a coded alert.
To assist in screening these messages quickly, a script is needed to count the number of vowels in any given string.
Write a Python program that:
Takes a message as input.
Counts the number of vowels (a, e, i, o, u — both uppercase and lowercase).
Prints the vowel count.
Input Format:
A single line containing a string .
Output Format:
A single integer — the count of vowels (A, E, I, O, U in both uppercase and lowercase).
Public Test Cases | Input | Expected Output | Actual Output | Status |
---|---|---|---|---|
Test Case 1 | hello | 2 | 2\n
| Passed after ignoring Presentation Error |
Test Case 2 | PYTHON | 1 | 1\n
| Passed after ignoring Presentation Error |
Test Case 3 | OpenAI 123 | 4 | 4\n
| Passed after ignoring Presentation Error |
No comments:
Post a Comment
Keep your comments reader friendly. Be civil and respectful. No self-promotion or spam. Stick to the topic. Questions welcome.