Skip to content

Instantly share code, notes, and snippets.

View pratik-choudhari's full-sized avatar
๐Ÿ’ป
Studying

Pratik Choudhari pratik-choudhari

๐Ÿ’ป
Studying
View GitHub Profile
from redis import Redis
from rq.job import Job
redis = Redis()
job = Job.fetch('my_job_id', connection=redis)
print(f'Result: {job.result}')
def nth_prime_number(n):
primes = 1
num = 2
while primes <= n:
mod = 1
ptrue = True
while mod < (num - 1):
if num%(num-mod) == 0:
ptrue = False
break
from redis import Redis
from rq import Queue
cnx = Redis()
task_queue = Queue("long_task_queue", connection=cnx)
@pratik-choudhari
pratik-choudhari / square.py
Last active November 15, 2021 14:54
pythonji turtle code to create a square
import turtle as ๐Ÿข
for _ in range(4):
๐Ÿข.forward(100)
๐Ÿข.left(90)
@pratik-choudhari
pratik-choudhari / show_img.py
Last active November 15, 2021 14:54
pythonji PIL code to open a image file
from PIL import Image as ๐Ÿ–ผ๏ธ
๐Ÿ“ฆ = ๐Ÿ–ผ๏ธ.open("mountains.jpg")
๐Ÿ“ฆ.show()
@pratik-choudhari
pratik-choudhari / ๐Ÿผ_translated.py
Last active November 15, 2021 14:54
pythonji's translated version of ๐Ÿผ.๐Ÿ
import pandas as __pythonji_panda__
# Define a dataframe and print it to the console
__pythonji_snake__ = __pythonji_panda__.DataFrame(
{
"animal": ["Panda", "Python", "Lion"],
"__pythonji_grinning_face__": ["__pythonji_panda__", "__pythonji_snake__", "__pythonji_lion__"],
"number": [1, 2, 3],
},
).set_index("__pythonji_grinning_face__")
@pratik-choudhari
pratik-choudhari / ๐Ÿผ.py
Last active November 15, 2021 14:54
pythonji code to create a pandas dataframe
import pandas as ๐Ÿผ
# Define a dataframe and print it to the console
๐Ÿ = ๐Ÿผ.DataFrame(
{
"animal": ["Panda", "Python", "Lion"],
"๐Ÿ˜€": ["๐Ÿผ", "๐Ÿ", "๐Ÿฆ"],
"number": [1, 2, 3],
},
).set_index("๐Ÿ˜€")
@pratik-choudhari
pratik-choudhari / convert.py
Last active November 15, 2021 14:55
pythonji code to convert images in jpg
import os as ๐Ÿ–ฅ๏ธ
import sys as ๐Ÿ› ๏ธ
from PIL import Image as ๐Ÿ–ผ๏ธ
for ๐Ÿ“ฅ in ๐Ÿ› ๏ธ.argv[2:]:
f, e = ๐Ÿ–ฅ๏ธ.path.splitext(๐Ÿ“ฅ)
๐Ÿ“ค = f + ".jpg"
if ๐Ÿ“ฅ != ๐Ÿ“ค:
try:
with ๐Ÿ–ผ๏ธ.open(๐Ÿ“ฅ) as ๐Ÿ“ฆ:
def add(x: int, y: int) -> int:
return x + y
number: str = "1"
number = 2
number += 1
print(number) # prints 3
sequence: list = ["foo", "bar"]
sequence = set()
print(type(sequence)) # prints <class 'set'>