0% found this document useful (0 votes)
13 views2 pages

Python Programming Assignment Tasks

The document outlines a Python assignment with four questions. Q1 requires creating a number pyramid based on user input, Q2 involves counting vowels and consonants in a string, Q3 focuses on processing a list of integers to find the sum of squares of even numbers, and Q4 entails reading student data to assign grades based on marks. Each question includes input/output formats and examples.

Uploaded by

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

Python Programming Assignment Tasks

The document outlines a Python assignment with four questions. Q1 requires creating a number pyramid based on user input, Q2 involves counting vowels and consonants in a string, Q3 focuses on processing a list of integers to find the sum of squares of even numbers, and Q4 entails reading student data to assign grades based on marks. Each question includes input/output formats and examples.

Uploaded by

sahilkha0224
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Python Assignment 1

Q1. Number Pattern Pyramid


Write a program that takes an integer `n` from the user and prints a pyramid pattern of numbers
like this:
Enter number of rows: 4
1
23
456
7 8 9 10

Use nested loops and ensure proper spacing.

Q2. Vowel & Consonant Counter


Read a string `s` from the user. Write a program that counts and prints the number of vowels (a,
e, i, o, u – case insensitive) and consonants in the string.
Handle spaces and punctuation marks by ignoring them.

Example:
Enter a string: Hello World!
Vowels: 3
Consonants: 7

[Link] a list of integers `nums`, perform the following operations:


1. Create a new list `even_nums` containing only the even numbers from `nums`.
2. Square each number in `even_nums`.
3. Print the sum of the squared numbers.

Input format:
Enter numbers separated by space: 1 2 3 4 5 6

Output:
Sum of squares of even numbers: 56 (i.e., 2² + 4² + 6² = 4 + 16 + 36 = 56)

Q4. Write a program that reads student data in the following format:
- Input: Number of students `n`
- For each student, read `name`, `marks` (out of 100) in a line separated by comma (e.g.,
`Alice,85`).

Compute the grade using the following criteria:


- 90 ≤ marks ≤ 100 → A
- 80 ≤ marks < 90 → B
- 70 ≤ marks < 80 → C
- 60 ≤ marks < 70 → D
- marks < 60 → F

Store the result in a dictionary where the key is the student name and the value is the grade.
Finally, print the dictionary.

Example:
Enter number of students: 3
Enter details (name,marks): Alice,92
Enter details (name,marks): Bob,78
Enter details (name,marks): Carol,65

Output: {'Alice': 'A', 'Bob': 'C', 'Carol': 'D'}

You might also like