import datetime
def trunc_datetime(someDate):
return someDate.replace(day=1, hour=0, minute=0, second=0, microsecond=0)
a = trunc_datetime(datetime.datetime(2018,2,15))
b = trunc_datetime(datetime.datetime(2018,3,20))
print(a <= b)
import random
import string
slova = ['asd', 'dsa','qwe', 'weq', 'zxc', 'cxz', 'rty', 'ytr']
print(slova)
print(random.sample(slova, 3))
Syntax: cv2.rectangle(image, start_point, end_point, color, thickness)
start_point: It is the starting coordinates of rectangle. The coordinates are represented as tuples of two values i.e. (X coordinate value, Y coordinate value).
end_point: It is the ending coordinates of rectangle. The coordinates are represented as tuples of two values i.e. (X coordinate value, Y coordinate value).
cv.rectangle(img,(384,0),(510,128),(0,255,0),3)
try: # used try so that if user pressed other than the given key error will not be shown
if keyboard.is_pressed('q'): # if key 'q' is pressed
print('You Pressed A Key!')
import random
from tkinter import Tk, Button, Canvas, PhotoImage
def putpixel(x, y):
x = int(x * 100 + 100)
y = int(y * 100 + 100)
image.put("white", to=[x, y])
def draw_serp():
x = random.random()
y = random.random()
for step in range(1500):
choice = random.choice(["top", "left", "right"])
if choice == "top":
x1 = x * 0.5
y1 = y * 0.5 + 0.5
elif choice == "left":
x1 = x * 0.5 - 0.5
y1 = y * 0.5
elif choice == "right":
x1 = x * 0.5 + 0.5
y1 = y * 0.5
x = x1
y = y1
if step > 50:
putpixel(x, y)
root = Tk()
canvas = Canvas(root, width=199, height=199, background="black")
image = PhotoImage(width=200, height=200)
canvas.create_image(0, 0, image=image, anchor="nw")
canvas.pack()
button = Button(root, text="Draw", command=draw_serp)
button.pack()
root.mainloop()