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

Python Assignment: Circle Area & String Manipulation

The document contains a Python assignment with four programming tasks. The tasks include calculating the area of a circle, reversing a user's full name, computing a specific integer expression, and printing a multi-line string. Each task is accompanied by a sample solution in Python code.

Uploaded by

minatoax.gaming
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)
2 views4 pages

Python Assignment: Circle Area & String Manipulation

The document contains a Python assignment with four programming tasks. The tasks include calculating the area of a circle, reversing a user's full name, computing a specific integer expression, and printing a multi-line string. Each task is accompanied by a sample solution in Python code.

Uploaded by

minatoax.gaming
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

1. Write a Python program that accepts the radius of a circle from the user and
computes the area.
Sol:

r=int(input("enter the radius:"))


area=3.14*(r**2)
print(area)

2. Write a Python program that accepts the user's first and last name and prints them
in reverse order with a space between them.

Sol:
first=input("enter the first name:")
last=input("enter the second name:")
name=first+last
ans=name[::-1]
print(''.join(ans))

3. Write a Python program that accepts an integer (n) and computes the value of
n+nn+nnn.
Sol:
n=int(input("enter the value of n: "))
ans=n+(n*n)+(n*n*n)
print(ans)
4. Write a Python program to print the following 'Sample string':

Sample string:
a string that you "don't" have to escape
This
is a ....... multi-line
heredoc string --------> example

Sol:
string='''
A string that you "don't" have to escape
This
is a ....... multi-line
heredoc string --------> example'''
print(string)
&&&&&

You might also like