Assignment-Python
Assignment-Python
Submit a .py file: Write and test your Python code for each question. Submit your solutions as
a .py file (Python script). Ensure your code is well-commented, clear, and follows Pythonic
standards.
Submit a Report: Along with the .py file, you must also submit a written report. The report
should explain:
The logic behind your code.
Step-by-step working of the code for each question.
How the code solves the problem.
Any assumptions or observations you made while solving the question.
If you encountered any challenges, how you overcame them.
The report can be submitted as a PDF File
Code Structure:
Ensure your code is clean and follows proper indentation.
Avoid hardcoding values unless required. Make your code dynamic and reusable.
Use appropriate variable names that are meaningful and self-descriptive.
Naming Conventions:
Name your Python files according to the question they correspond to (e.g.,
question_1.py, question_2.py, etc.).
The report file should be named like roll_number_report.docx (e.g., 123_report.docx).
Strict Warnings
Late Submission: Any assignment submitted after the deadline will receive a penalty of 10% per
day. Submissions later than 3 days past the due date will not be accepted under any
circumstances.
Plagiarism: Any form of plagiarism or copying from another student, the internet, or any other
sources will result in an automatic zero for the assignment. We have plagiarism detection
systems in place. If you are unsure about the guidelines, please ask for clarification before
submitting.
Code Accuracy: The code must run without errors. Submitting code that does not execute or
throws errors will result in zero marks for that question. Ensure you test your code thoroughly
before submission.
Adherence to Instructions: Ensure you follow all instructions carefully. Failure to follow the
instructions, including not submitting both the Python file and the report, will lead to a reduced
grade.
Version Control: Before submitting, make sure your code is in its final version. Submitting a
draft or incomplete code will result in a loss of marks. Review your code and report carefully.
External Libraries: If you use external libraries (like numpy, matplotlib, pandas, etc.), make sure
to mention them in your report and install them using pip in the Python environment. Do not
include unnecessary or unused libraries.
How to Submit
Step 1: Write your Python code for each question in separate .py files.
Step 2: Write a report as described above.
Step 3: Compress your .py files and report into a single ZIP file for submission.
Step 4: Submit the ZIP file via the assigned submission portal.
Please note that any deviation from the above instructions will impact your grade. Pay close
attention to detail and follow the rules strictly.
Question 3: Loops
Write a Python program that prints all prime numbers from 1 to your roll number. If your roll number is
odd, use a while loop. If it’s even, use a for loop.
Question 4: Functions
Define a function factorial(n) to calculate the factorial of a number. Use this function to calculate the
factorial of the last digit of your roll number.
Question 5: Lists
Create a list of the first 10 multiples of your roll number. Write a program to:
Question 6: Dictionaries
Create a dictionary where keys are digits from 1 to 5, and values are their cubes. Write a program to:
Add a key-value pair where the key is the last digit of your roll number, and the value is its square.
Question 7: Strings
Write a Python program to generate a string by repeating your roll number’s digits (as characters) 5
times. Then:
Count the occurrence of each digit in the string if your roll number is odd.
Reverse the string if your roll number is even.
Accepts two numbers as input: the first two digits of your roll number and the last digit.
Divides the first number by the second.
Handles any exceptions if the second digit is 0.
If your roll number ends in an odd digit, display all details for an employee with the name John, age 30,
and employee ID as the first digit of your roll number. If the roll number ends in an even digit, use the
last two digits as employee ID.