0% found this document useful (0 votes)
23 views2 pages

Week 1

Uploaded by

abhirampat7
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)
23 views2 pages

Week 1

Uploaded by

abhirampat7
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
You are on page 1/ 2

Week 1:

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

import datetime

now = datetime.datetime.now()

print (f"Current date and time : {now}")

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

import sys

print("Python version")

print (sys.version)

print("Version info.")

print (sys. version_info)

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

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=",n1)
print("n2=",n2)
print("n3=",n3)
print("n1+n2+n3=",n1+n2+n3)

Note: concatenating strings but %s not equal to string variables

4. Write a Python program to read and print various types of variables.


a=10
b=10.5
c=10+5j
d="hai python"
print(type(a))
print(type(b))
print(type(c))
print(type(d))

5. Write a Python program to print the calendar of a given month and year.

import calendar
y = int(input("Input the year : "))
m = int(input("Input the month between(1-12) : "))
print(calendar.month(y, m))

You might also like