Skip to content

Instantly share code, notes, and snippets.

View codewithpom's full-sized avatar
🎯
Building txtutils

Padmashree Jha codewithpom

🎯
Building txtutils
View GitHub Profile
number = 9.5
# or you can do this
number = float(9)
# the above line converts nine from int to float and then save it in the number variable
# or even this can be used
number = 9.0
# in the above line we have added a decimal point so it is converted into a float
name = "Chuck Norris"
# or use this
name = 'Chuck Norris'
# so the difference is of the type of qoutes
# have fun
@codewithpom
codewithpom / bool_.py
Created July 13, 2021 11:44
Declare bool in python
i_am_programmer = True
# The above example creates a variable and assigns it as True
i_am_not_a_programmer = False
# The above example creates a variable and assigns it as False
# or you can do this
i_am_programmer = bool(1) # 1 or any number except 0
i_am_not_a_programmer = bool(0) # 0 is the only number which can assign False
# create a string variable
name = "Padmashree"
# print string variable
print(name)
# create a float variable
float_number = 4.5
# print float variable
name = input("What is your name")
# take input from the user and save it in the name variable as string
# print the name
print(name)
# declare a string variable
name = "Padmashree"
# print variable name in upper case
print(name.upper())
# print the vriable in lower case
print(name.lower())
# directly print a word in lower case
# create a string variable
name = "Padmashree"
# print the first charachter of the word
print(name[0])
# prints P
# print the last charachter of the word
print(name[-1])
# prints e
# create a string variable
name = "Padmashree"
# print every word after the fifth charachter
print(name[5:])
# prints shree
# print every word before the fifth charachter
print(name[:5])
# prints Padma
import cv2
# for in-built camera
cam = cv2.VideoCapture(0)
# for external camera
cam = cv2.VideoCapture(0, cv2.CAP_DSHOW)
import cv2
# I used this line because I have external camera.
# You do not need to use cv2.CAP_DSHOW if you do not use external camera
cam = cv2.VideoCapture(0, cv2.CAP_DSHOW)
while True:
ret, frame = cam.read()
cv2.imshow("My Webcam", frame)
key = cv2.waitKey(25)
if key == ord('q'):
break