-
Notifications
You must be signed in to change notification settings - Fork 0
/
PythonStudy-edit
54 lines (47 loc) · 1.13 KB
/
PythonStudy-edit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import time
import webbrowser
breaks=3
break_count=0
print("This program started on "+time.ctime())
while(break_count < breaks):
time.sleep(10)#time delay
webbrowser.open("website address")
break_count += 1
##change file name##
import os
def rename_files():
file_lists = os.listdir(r"D:\prog\py")
saved_path = os.getcwd()
os.chdir(r"D:\prog\py")
for file_name in file_lists:
print("old name:" +file_name)
print("new name:" +file_name.translate(none,"1234567890") #delete numbers from file name
os.rename(file_name,file_name.translate(none,"1234567890"))
os.chdir(saved_path)
rename_files()
#turtle draws square
import turtle
def draw_square():
window = turtle.Screen()
window.bgcolor("green")
pet=turtle.Turtle()
pet.speed(3)
pet.color("red")
pet.forward(100)
pet.right(90)
pet.forward(100)
pet.right(90)
pet.forward(100)
pet.right(90)
pet.forward(100)
----function----
def sum_multi(choice, *args):
if choice == "sum":
result = 0
for i in args:
result = result + i
elif choice == "mul":
result = 1
for i in args:
result = result * i
return result