0% found this document useful (0 votes)
21 views4 pages

Weekly Test

Uploaded by

nanaalhaki
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
21 views4 pages

Weekly Test

Uploaded by

nanaalhaki
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

WEEKLY TEST 3– PFS11

1. Reverse First and Last Name [1M]


Question: Write a Python program that:
 Takes two inputs from the user: first name and last name.
 Stores them in variables and prints them in reverse order, formatted as: "Last Name,
First Name".
Sample Input:
Enter your first name: John
Enter your last name: Doe
Sample Output:
Doe, John

2. Formatted Greeting [1M]


Question: Write a Python program that:
 Takes the user's full name as input.
 Outputs a greeting like: "Hello, <Full Name>!".
 Ensure the output is properly formatted, with the first letter of each word capitalized.
Sample Input:
Enter your full name: john doe
Sample Output:
Hello, John Doe!

3. Formatted Float [1M]


Question: Write a Python program that:
 Asks the user to input a floating-point number.
 Stores the number and prints it formatted with exactly 2 decimal places.
Sample Input:
Enter a floating-point number: 12.34567
Sample Output:
12.35

4. Multiple Inputs in One Line [1M]


Question: Write a Python program that:
 Prompts the user to enter three different inputs: an integer, a float, and a string.
 Prints all three inputs in a single line, with each value separated by a comma.
Sample Input:
Enter an integer: 10
Enter a float: 3.14
Enter a string: Hello
Sample Output:
10, 3.14, Hello

5. Calculate Age [1M]


Question: Write a Python program that:
 Takes the user's birth year as input.
 Prints the current age of the user by calculating it using the current year (e.g., 2024).
Sample Input:
Enter your birth year: 1990
Sample Output:
You are 34 years old.

6. Formatted Number Sentence [1M]


Question: Write a Python program that:
 Prompts the user to enter two numbers.
 Prints these numbers formatted as a sentence: “The numbers you entered are X and
Y”.
Sample Input:
Enter the first number: 15
Enter the second number: 25
Sample Output:
The numbers you entered are 15 and 25.

7. Product and Price Receipt [2M]


Question: Write a Python program that:
 Asks the user to input a product name and its price.
 Outputs a receipt-like message formatted with the price aligned to the right, ensuring
that the price is displayed with two decimal places.
Sample Input:
Enter the product name: Apple
Enter the price: 1.5
Sample Output:
Product: Apple
Price: 1.50

8. Character Count in a Sentence [2M]


Question: Write a Python program that:
 Prompts the user for a sentence.
 Prints the number of characters in the sentence (excluding spaces) along with the
sentence itself.
Sample Input:
Enter a sentence: Python is awesome
Sample Output:
Your sentence: Python is awesome
Character count (excluding spaces): 15

You might also like