Skip to content

Instantly share code, notes, and snippets.

@Shiv1801
Shiv1801 / palindrome.py
Created May 3, 2022 12:16
Palindrom triangle in python
a=0
b=0
#Palindrome pattern : 1
for i in range(1,5):
a=(int(pow(10,i)/9))**2
print(a)
#Palindrome pattern : 2
@Shiv1801
Shiv1801 / STS.py
Created May 3, 2022 11:52
Game: Stone,Paper, Scissor with Random function
import random
complist = ["Stone","Paper","Scissor"]
userlist = ["Stone","Paper","Scissor"]
print("Welcome to the game Stone, paper, Scissor")
print("Please enter a value as shown")
print()
user = int(input("For stone : 0 \nFor paper : 1 \nFor Scissor : 2 \nEnter the value : "))
@Shiv1801
Shiv1801 / BMI.py
Created May 3, 2022 11:15
BMI Calculator
height = int(input("Enter height in cm :"))
weight = int(input("Enter weight in kg :"))
BMI = weight/pow((height/100),2)
if BMI>=30:
print(f"Your BMI is {round(BMI,2)} and you are Obese")
elif 25<=BMI<30:
print(f"Your BMI is {round(BMI, 2)} and you are Over Weighted")
elif 18.50<=BMI<25:
@Shiv1801
Shiv1801 / weather.py
Last active May 3, 2022 10:55
Pandas to read csv data
import pandas
data = pandas.read_csv("weather_data.csv")
print(type(data)) #Type checking- To check the data-type
data_dict = data.to_dict() #to convert into a dictionary
print(data_dict)
temp_list = data["temp"].to_list() #to convert into list
print(temp_list)
@Shiv1801
Shiv1801 / screenlisten.py
Created May 3, 2022 10:45
Moving object using turtle graphics screen.listen()
from turtle import Turtle, Screen
tim = Turtle()
screen = Screen()
def move_forwards():
tim.forward(10)
def move_backwards():
tim.backward(10)
def turn_left():
@Shiv1801
Shiv1801 / Spirograph.py
Last active May 3, 2022 10:43
Spirograph using turtle graphics in python
import turtle
from turtle import Turtle, Screen
import random
timmy = Turtle()
timmy.shape("turtle") #change the shape of the cursor
turtle.colormode(255)
#colour=["red","yellow","green","blue","violet","indigo","brown"]
@Shiv1801
Shiv1801 / Fizzbuzz.py
Created May 3, 2022 10:40
FizzBuzz Project
a=input('Enter values: ')
#print(type(a))
x=a.split(" ")
#print(type(a))
for i in range(len(x)):
x[i] = int(x[i])
#print(i)
#print(x[i])
#print(type(x[i]))