This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from time import sleep, ctime | |
print(ctime()) | |
sleep(2) | |
print(ctime()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import math as ma | |
pi=ma.pi | |
print(pi) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
a=5 | |
b=2 | |
print("{0:2d} divided by {1:2f} is {2:2.3f}".format(a,b,a/b)) | |
print("{1:2f} divided by {0:2d} is {2:2.3f}".format(a,b,b/a)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
try: | |
print("-------------------------------------------------------------------------------------------------------") | |
x=float(input("Float Input 1: ")) | |
y=float(input("Float Input 2: ")) | |
z=x*y | |
print("-------------------------------------------------------------------------------------------------------") | |
print("Input 1:" ,x, " | Input 2: " ,y , "" ) | |
print(x,"*",y , "=",z ) | |
print("") | |
except ValueError: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
with open("00_data\\02_textfile_write.txt",'a') as fout: | |
fout.write("append this text to the line") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fout=open("00_data\\02_textfile_write.txt",'w') | |
fout.write("Hello im the first row.\n") | |
fout.write("and i am the second row.\n") | |
fout.write('\n') | |
fout.writelines(['writelines1\n','witelines2\n']) | |
fout.close() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
with open("00_data\\02_textfile_read.txt","r") as fin: | |
linelist=fin.readlines() | |
print(linelist) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
with open("00_data\\02_textfile_read.txt","r") as fin: | |
for line in fin: | |
print(line) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fin = open("00_data\\02_textfile_read.txt","r") | |
print(fin.readline()) | |
print(fin.readline()) | |
fin.close() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
with open("00_data\\02_textfile_read.txt","r") as f: | |
read_data = f.read() | |
print(read_data) |
OlderNewer