Python Programming Test
Topics: Input, Output, For Loops, If Conditions
Duration: 60 Minutes
Total Questions: 4
Total Marks: 40
Question 1: User Greeting and Age Check (10 Marks)
Task:
Write a Python program that:
1. Asks the user to input their name and age.
2. Prints a greeting using the name.
3. If the user is 18 or older, print: "You are eligible to vote."
4. If the user is younger than 18, print: "You are not eligible to vote."
Sample Output:
Enter your name: Sara
Enter your age: 20
Hello, Sara!
You are eligible to vote.
Question 2: Sum of Even Numbers (10 Marks)
Task:
Write a Python program that:
1. Asks the user to input a positive integer n.
2. Uses a for loop to calculate the sum of all even numbers from 1 to n.
3. Prints the result.
Page 1
Python Programming Test
Topics: Input, Output, For Loops, If Conditions
Sample Output:
Enter a positive integer: 10
The sum of even numbers from 1 to 10 is 30.
Question 3: Star Pattern Generator (10 Marks)
Task:
Write a Python program that:
1. Asks the user to input a number n.
2. Uses a for loop to print a right-angled triangle pattern with n rows made of stars (*).
3. Each row should contain that many stars as the row number.
Sample Output (if n = 5):
**
***
****
*****
Question 4: Student Marks Report (10 Marks)
Task:
You are asked to write a Python program for a school to generate a simple student report. The
program should:
1. Ask the user how many students' data they want to enter.
2. For each student:
- Ask for the student's name.
- Ask for the student's marks out of 100.
Page 2
Python Programming Test
Topics: Input, Output, For Loops, If Conditions
- Print whether the student has Passed (marks >= 50) or Failed (marks < 50).
3. After all entries, print the total number of students who passed and failed.
Sample Output:
How many students? 3
Enter name of student 1: Ali
Enter marks of Ali: 78
Ali has Passed.
Enter name of student 2: Zara
Enter marks of Zara: 45
Zara has Failed.
Enter name of student 3: Imran
Enter marks of Imran: 66
Imran has Passed.
Total Passed: 2
Total Failed: 1
Page 3