0% found this document useful (0 votes)
5 views3 pages

Python Assignment 1: Programming Tasks

The document outlines a Python assignment consisting of various programming tasks and questions to be completed on ruled A4 sheets, with a submission deadline of September 9, 2025. It includes tasks such as writing programs for patterns, palindrome checks, string manipulations, file operations, and mathematical calculations. Additionally, it requires short notes on Python concepts and explanations of specific Python features and methods.

Uploaded by

Gaurav Prajapati
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)
5 views3 pages

Python Assignment 1: Programming Tasks

The document outlines a Python assignment consisting of various programming tasks and questions to be completed on ruled A4 sheets, with a submission deadline of September 9, 2025. It includes tasks such as writing programs for patterns, palindrome checks, string manipulations, file operations, and mathematical calculations. Additionally, it requires short notes on Python concepts and explanations of specific Python features and methods.

Uploaded by

Gaurav Prajapati
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 Assignment-1

Do the assignment on ruled A4 sheets and keep scanned copy


of assignment for your reference.
Last date to submit Assignment is 09/09/25 . After that I will
not accept any submissions.
Please write the content according to the marks given also give
example where ever possible.

UNIT-1

Q1 (a)Write a python program to print the following pattern:


(8)
*
**
***
****
*****
****
***
**
*
(b)Write a python program to check whether string is
palindrome ? (7)

Q2 (a)Assume that the variable data refers to the string Python


rocks !". (8)
Use a string method to perform the following tasks:
(i) Obtain a list of the words in the string
(ii) Convert the string to uppercase
(iii) Locate the position of the string "rocks".
(iv) Replace the exclamation point with a question mark.

(b)Write a Python program that reads a text file and changes


the file by capitalizing each character of the file. (7)
Q3 Write short note on following (2.5 x 2 = 5)
(i) Python
(ii) String

Q4 (i)How do you run a shell script in Python. (7.5)


(ii)Describe the different data types in Python. (7.5)

Q5 Describe the following:


(i) Subscript operator (7.5)
(ii) Types of text files in Python (7.5)

Q6 (2.5 x 2 = 5)
(a)What are the key features of the python?
(b)Explain join() and split() string methods.

Q7 (a)Write a program that accepts the lengths of three sides


of a triangle as inputs. The program output should indicate
whether or not the triangle is a right triangle. (7)

(b)Write a program that takes the radius of a sphere (a floating-


point number) as input and then outputs the sphere's
diameter, circumference, surface area, and volume. (8)

Q8 (b)Write a Python program to count the frequency of words


in a file. (7)

Q9 Describe the following: (15)


(b) The variables x and y refer to numbers. Write a code
segment that prompts the user for an arithmetic operator and
prints the value obtained by applying that operator to x and y.
(d) Describe the purpose of the break statement and the type
of problem for which it is well suited.
(e) What happens when the programmer forgets to update the
loop control variable in a while loop?
(f) Assume that the variable x has the value 55. Use an
assignment statement to increment the value of x by 1

Q10 (a) The math module includes a pow function that raises a
number to a given power. The first argument is the number,
and the second argument is the exponent. Write a code
segment that imports this function and calls it to print the
values 82 and 54. (8)
(b) Write a program that accepts the lengths of three sides of a
triangle as inputs. The program output should indicate whether
or not the triangle is an equilateral triangle. (7)

Q11. (a) Assume that the variable myString refers to a string.


Write a code segment that uses a loop to print the characters
of the string in reverse order. (8)
(b) Write a code segment that prompts the user for a filename.
If the file exists, the program should print its contents on the
terminal. Otherwise, it should print an error message. (7)

You might also like