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

Python Programming Assignment

This document outlines a Python programming assignment consisting of eight questions. Each question has a specific problem statement, input format, and output format that must be followed. The tasks range from basic printing and arithmetic operations to more complex list manipulations and pattern printing.

Uploaded by

Priyanka Khabiya
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)
4 views4 pages

Python Programming Assignment

This document outlines a Python programming assignment consisting of eight questions. Each question has a specific problem statement, input format, and output format that must be followed. The tasks range from basic printing and arithmetic operations to more complex list manipulations and pattern printing.

Uploaded by

Priyanka Khabiya
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

Python Programming Assignment

Course: Programming in Python

Language: Python 3

Instructions:

• Write programs using Python 3.

• Follow the input and output format strictly.

• Use proper indentation.

• Do not print extra spaces or extra lines.


Question 1: Hello World
Problem Statement:

Write a Python program to print:

Hello, World!

Input Format: No input required.

Output Format: Print Hello, World! to stdout.

Question 2: Arithmetic Operators


Problem Statement:

Read two integers and print:

1. Sum

2. Difference (first - second)

3. Product

Input Format:

First line: Integer A

Second line: Integer B

Output Format:

Print three lines containing sum, difference, and product.

Question 3: Print Squares


Problem Statement:

Read an integer n. Print the square of all non-negative integers less than n.

Input Format: Single integer n.


Output Format: Print n lines showing squares from 0 to n-1.

Question 4: Conditional Statements


Problem Statement:

Given integer n:

• If n is odd → Print Weird

• If n is even and in range 2 to 5 → Print Not Weird

• If n is even and in range 6 to 20 → Print Weird

• If n is even and greater than 20 → Print Not Weird

Input Format: Single positive integer n.

Output Format: Print Weird or Not Weird.

Question 5: Student Marks Dictionary


Problem Statement:

Given student names and their marks, print the average marks of the queried student
correct to 2 decimal places.

Input Format:

First line: Number of students

Next n lines: Name followed by marks

Last line: Query student name

Output Format: Print average to 2 decimal places.

Question 6: Swap Case


Problem Statement:
Convert lowercase letters to uppercase and uppercase letters to lowercase.

Input Format: A single string.

Output Format: Modified string with swapped cases.

Question 7: List Operations


Problem Statement:

Initialize an empty list and perform operations based on commands:

insert i e, print, remove e, append e, sort, pop, reverse

Input Format:

First line: Integer N (number of commands)

Next N lines: Commands

Output Format: Print the list for each print command.

Question 8: Alphabet Rangoli


Problem Statement:

Print an alphabet rangoli of given size.

The center contains letter 'a' and boundary contains nth alphabet letter.

Input Format: Single integer size.

Output Format: Print the rangoli pattern.

You might also like