a = float(input('enter any number: '))
print('%f * %f = %f\n' % (a, a, a*a))
a,b = input('enter any two numbers: ').split() # split(): two numbers with space in between; split(','): two numbers with , in between
print('%f * %f = %f\n' % (float(a), float(b), float(a)*float(b)))
now = time.localtime()
filename = "log_%02d%02d%02d_%02d:%02d:%02d.txt" % (now.tm_year, now.tm_mon, now.tm_mday, now.tm_hour, now.tm_min, now.tm_sec)
f = open(filename, 'w') # r: read-only, r+: read and write, w: write, a: append
f.write('abcdefgh')
f.close()
g = open('t.txt', 'r')
line = g.readline()
while line:
print (line, end='\n')
line = g.readline()
g.close()
h = open('t.txt', 'r')
lines = h.readlines()
for line in lines:
print(line*2, end=' ')
h.close()
Result------------------------------------------
enter any number: 1.000000 * 1.000000 = 1.000000
enter any two numbers: 1.000000 * 2.000000 = 2.000000
abcdefgh
abcdefghabcdefgh
Informative post.Thanks for sharing the post
ReplyDeleteFull Stack Training in Chennai | Certification | Online Training Course| Full Stack Training in Bangalore | Certification | Online Training Course | Full Stack Training in Hyderabad | Certification | Online Training Course | Full Stack Developer Training in Chennai | Mean Stack Developer Training in Chennai | Full Stack Training | Certification | Full Stack Online Training Course
Great Article.Thanks for the post.
ReplyDeletePython course in Pune