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

Python Programming Assignment Solutions

Uploaded by

hassancsk5
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)
6 views3 pages

Python Programming Assignment Solutions

Uploaded by

hassancsk5
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