0% found this document useful (0 votes)
5 views

283443assignment 1 - Python Programming-1720516922702

Uploaded by

test.root421
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

283443assignment 1 - Python Programming-1720516922702

Uploaded by

test.root421
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

UNIT 1

Assignment 1
Assignment 1

Note: Attempt any two questions from the following [5 Marks Each]

Q1. Explain the significance of indentation in Python with an example.

Q2. Explain what string slicing is and provide an example where you extract a substring from a
given string.

Q3. Explain the range function in Python and write a program to print all even numbers from 2 to
20 using it.

Note: Attempt any two questions from the following [10 Marks Each]

Q4. Write a Python program that takes three numbers as input and prints the largest of the three
using if-elif-else statements.

Q5. Explain the in-operator in Python and how it can be used to check for the presence of a
substring within a string. Provide a practical example.

Q6. Explain the concept of an infinite loop and provide a scenario where it might occur. Write a
Python program demonstrating how to handle and prevent infinite loops.

Note: Attempt any two questions from the following [ 20 Marks Each]

Q7. Write a Python program that simulates a grading system. The program should take a
student's score as input and output their grade (A, B, C, D, F) based on predefined score
ranges. Include conditions for input validation and error handling.

Q8. Discuss the various types of loops available in Python, their use cases, and their differences.
Write a Python program to generate the Fibonacci sequence up to a specified number of
terms using a for loop.

Q9. Write a Python program to count the number of words, characters, and sentences in a given
paragraph. Explain how string slicing and methods are used to achieve this.

Q10. Write a Python program that calculates the sum of a series of positive numbers entered by
the user until the user inputs a negative number. Use a while loop and handle invalid input
gracefully.

You might also like