Skip to content

Instantly share code, notes, and snippets.

View DevloperHS's full-sized avatar

Purnendu Shukla(Harsh) DevloperHS

View GitHub Profile
@DevloperHS
DevloperHS / flag.py
Created July 27, 2023 17:30
Python TURTLE challenge | draw national flag pattern
import turtle
colors = ["#FF9933", "white", "green"]
t = turtle.Pen()
turtle.bgcolor("black")
for i in range(200):
t.speed("fastest")
t.pencolor(colors[i%3])
@DevloperHS
DevloperHS / flag_pattern.py
Created July 24, 2023 18:11
National Flag Pattern
import turtle
colors = ["green", "white", "red"]
t = turtle.Pen()
turtle.bgcolor("black") # Set the background color to black
for i in range(200):
t.speed('fastest')
t.pencolor(colors[i % 3])
@DevloperHS
DevloperHS / format.py
Created July 23, 2023 15:38
F string programs
text = "PYTHON"
print(f"{text}")
print(f"{text:#<20}")
print(f"{text:_>20}")
print(f"{text:.^20}")
@DevloperHS
DevloperHS / star.py
Created July 22, 2023 16:41
Create an extraordinary star pattern using python turtle
from turtle import *
import random
speed(speed ='fastest')
def draw(n, x, angle):
# loop for number of stars
for i in range(n):
@DevloperHS
DevloperHS / batman.py
Created July 21, 2023 15:28
batman logo using python
import turtle
#initialize method
bat = turtle.Turtle()
#size of pointer and pen
bat.turtlesize(1, 1, 1)
bat.pensize(3)
#screen info
@DevloperHS
DevloperHS / capitalize.py
Created July 20, 2023 14:57
Code to convert to title case
word = "welcome To minute coder"
l = word.split()
m = []
for i in l:
a = i.capitalize()
m.append(a)
print(' '.join(m))
# print(word.title())
@DevloperHS
DevloperHS / sep.py
Last active July 18, 2023 15:33
Add a thousand separator in python
num1 = 3_000_000_00
num2 = 3_0
result = num1*num2
print(result)
@DevloperHS
DevloperHS / discard.py
Created July 14, 2023 16:05
Python code to remove an element form a set
# discard function
s = {1,2,3}
# s_rem = s.remove(4) - throws error
s_rem = s.discard(4) # works fine
print(s)
@DevloperHS
DevloperHS / zip.py
Created July 13, 2023 15:03
How to use zip() in python
# zip in python
# zip function takes in multiple iterables and combines them to form a single iterable object. Let's understand its use case
# 2 iterables
a = [1,2,3]
b = ["one", "two", "three"]
# use normal - error
'''
@DevloperHS
DevloperHS / palindrome.py
Created July 11, 2023 15:44
Python Program To Check If Given String Is A Palindrome Or Not.
# write a palindrome program in python
# string jise left-> right , right-> left read kro , dono same honge : dad , mom
# user input()
s = input()
# string reverse
rev_s = s[::-1]