Solution of the problems .

The journey of a thousand miles begins with one step.

Problems on Python πŸ™‚

Q1)Β Write a Python program which accepts the radius of a circle from the user and compute the area.Β 

Q2)Write a Python program to display the current date and time.

Q3)Write a Python program to get the Python version you are using.

Q4)Write a Python program that accepts an integer (n) and computes the value of n+nn+nnn.

eg. 3+33+333=369

Q5)Write a Python program which accepts a sequence of comma-separated numbers from user and generate a list and a tuple with those numbers

eg Input some comma seprated numbers : 5,8,2,4,1,9
List : [β€˜5’, β€˜8’, β€˜2’, β€˜4’, β€˜1’, β€˜9’]
Tuple : (β€˜5’, β€˜8’, β€˜2’, β€˜4’, β€˜1’, β€˜9’)

Solution 1 :

from math import pi

r = float(input (“Input the radius of the circle : “))

print (“The area of the circle with radius ” + str(r) + ” is: ” + str(pi * r**2))

Solution 2 :

import datetime

now = datetime.datetime.now()

print (“Current date and time : “)

print (now.strftime(“%Y-%m-%d %H:%M:%S”))

Solution 3 :

import sys

print(“Python version”)

print (sys.version)

print(“Version info.”)

print (sys.version_info)

Solution 4 :

a = int(input(“Input an integer : “))

n1 = int( “%s” % a )

n2 = int( “%s%s” % (a,a) )

n3 = int( “%s%s%s” % (a,a,a) )

print (n1+n2+n3)

Solution 5 :

values = input(“Input some comma seprated numbers : “)

list = values.split(“,”)

tuple = tuple(list)

print(‘List : ‘,list)

print(‘Tuple : ‘,tuple)

Thankyou friends #Stayhealthy #Staysafe #happycoding #havefun πŸ™‚

You may also like...

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Discover more from Microsoft 365

Subscribe now to keep reading and get access to the full archive.

Continue reading