blob_id stringlengths 40 40 | repo_name stringlengths 5 127 | path stringlengths 2 523 | length_bytes int64 22 545k | score float64 3.5 5.34 | int_score int64 4 5 | text stringlengths 22 545k |
|---|---|---|---|---|---|---|
8aafa2e4c9f130cae9ae687ee40bc38032220274 | tusvhar01/practice-set | /practice set 3 (add two no.).py | 151 | 3.859375 | 4 | l1=int(input("Enter 1st no.: "))
l2=int(input("Enter 2nd no.: "))
l3=(l1+l2)
print(f"sum of {l1} and {l2} is {l3}")
print("sum of",l1,"and",l2,"is",l3) |
4851bf916952b52b1b52eb1d010878e33bba3855 | tusvhar01/practice-set | /Practice set 42.py | 489 | 4.25 | 4 | my_tuple = tuple((1, 2, "string"))
print(my_tuple)
my_list = [2, 4, 6]
print(my_list) # outputs: [2, 4, 6]
print(type(my_list)) # outputs: <class 'list'>
tup = tuple(my_list)
print(tup) # outputs: (2, 4, 6)
print(type(tup)) # outputs: <class 'tuple'>
#You can also create a tuple u... |
aac8a16f53644388787dc5ba3046f9931c70a97a | tusvhar01/practice-set | /practice set 34.py | 540 | 3.8125 | 4 | beatles=[]
print("Step 1:", beatles)
beatles.append('John Lennon')
beatles.append("Paul McCartney")
beatles.append("George Harrison")
print("Step 2:", beatles)
list_length=len(beatles)
for i in range(list_length):
beatles.append("Stu Sutcliffe")
beatles.append("Pete Best")
print("Step 3:", beatles)
bre... |
c5b96392f26ec171300a322ad81a8fdd70ceac81 | tusvhar01/practice-set | /practice set 1.py | 98 | 3.90625 | 4 | l1=int(input("Enter a no."))
if(l1%2==0):
print("no.is prime")
else:
print("no. is odd")
|
44646f831f341a2527a6887d9b4ac62c05b9500d | tusvhar01/practice-set | /practice st 30.py | 251 | 3.9375 | 4 | secret_number=777
n=int(input("Enter a no.: "))
while(n!=777):
if(n!=secret_number):
print("Ha ha! You're stuck in my loop!")
n=int(input("Enter a no.: "))
print("Well done, muggle! You are free now.")
# Game , To choose a secret no. |
37c28ad515026a3db91878d907f7d31e14f7e9a7 | tusvhar01/practice-set | /Practice set 73.py | 472 | 4.125 | 4 | a=input("Enter first text: ")
b=input("Enter second text: ")
a=a.upper()
b=b.upper()
a=a.replace(' ','')
b=b.replace(' ','')
if sorted(a)==sorted(b):
print("It is Anagram") # anagram
else:
print("Not Anagram")
#An anagram is a new word formed by rearranging the letters of a word, usin... |
26862791d09543430b4bbbed9310e944dac3d31f | tusvhar01/practice-set | /Practice set 75.py | 85 | 3.53125 | 4 | x='\''
print(len(x)) # length of x will mot be 2 it will be one |
3724dba190b96cab8b3a6423c6e49f847b0ca511 | dviar2718/code | /python3/fraction.py | 201 | 3.921875 | 4 | """
Python3 Notes on Fraction type
"""
>>> from fractions import Fraction # Fractions: numerator + denominator
>>> f = Fraction(2,3)
>>> f + 1
Fraction(5, 3)
>>> f + Fraction(1,2)
Fraction(7, 6)
|
bd50429e48eae21d7a37647c65ae61866c1e97cb | dviar2718/code | /python3/types.py | 1,259 | 4.1875 | 4 | """
Python3 Object Types
Everything in Python is an Object.
Python Programs can be decomposed into modules, statements, expressions, and
objects.
1. Programs are composed of modules.
2. Modules contain statements.
3. Statements contain expressions.
4. Expressions create and process objects
Object Type Example
-... |
52dbce360b83eaae68a9ba285acfed1e019dd68c | Pensutti/Prison-Escape-RPG | /Minigame - Kitchen.py | 5,378 | 3.890625 | 4 | import time
import os
def minigame_kitchen():
minigame = 0
minigame_kitchen = 0
scr_mk = 0
score_minigame_kitchen = 0
#RESPOSTAS: 42135 5213674 24351
#Explicação do Minigame
print('''\n
Você conseguiu se passar por cozinheiro. Agora deve acertar a preparação de 3 p... |
1a7b97bce6b4c638d505e1089594f54914485ec0 | shaner13/OOP | /Week 2/decimal_to_binary.py | 598 | 4.15625 | 4 | #intiialising variables
decimal_num = 0
correct = 0
i = 0
binary = ''
while(correct==0):
decimal_num = int(input("Enter a number to be converted to binary.\n"))
if(decimal_num>=0):
correct = correct + 1
#end if
else:
print("Enter a positive integer please.")
#end else
#end... |
7e0f5caffff7b2613d4c34033ad9761d89688aed | shaner13/OOP | /TESTS/LabTest2.py | 3,946 | 4.53125 | 5 | '''
Program to implement a 3D vector class in python.
The Vector class will also encapsulate a lot of
basic math operators, such as
Adding
Subtracting,
Multiplying (by an integer (returns scalar product) and another vector.)
There is also a constructor and __str__ function available in the class.
The class also has ... |
5033425f184746bf78e93ed58185dc9caf61571e | patwmcnamara/GA_NFL | /NFL_methods.py | 3,207 | 3.578125 | 4 | def home(data):
"Look at game ID suffix to identify home team"
Add categorical variable indicating home team
def week(data):
"Look at game ID prefix to calculate days between games and identify week number"
Add variable indicating week number
def play(data):
"Look at offensive team and count... |
f1c8c9a63f4a00228ab611c55698431320583391 | holyrocklee/programming_exercise | /04_dp_dark_string.py | 930 | 3.515625 | 4 | # -*- coding: utf-8 -*-
# Author :Rocklee
# Time :2019/8/26 9:59
#方法1:此解法内存超出限制
import itertools
n = int(input())
s = 'ABC'
no_repeat = [] #表示含有连续完整的'ABC'、'ACB'等三个字符的
if n<3:
print(len(list(itertools.product(s,repeat=n))))
else:
# list(itertools.product(s,repeat=n))可以把三种元素的排列组合,包括有重复元素和没有重复元素的情况
tmp = []... |
2e95085b97b55f10c8004ecb3941e09107e6d949 | FrauBoes/iot | /basic_read/read_sensor.py | 2,200 | 3.59375 | 4 | # Script to read temp and humidity from DHT11 sensor
import Adafruit_DHT
import datetime
import time
# Read temperature and humidity from DHT sensor
def read_sensor(sensor, pin):
try:
humidity, temp = Adafruit_DHT.read(sensor, pin)
except: # Return None if reading was unsuccessful
print(... |
4a85b012f1a5b8a137665992d365c3958f29c46c | FrauBoes/iot | /python_basics/even-or-odd.py | 188 | 4.1875 | 4 | num = int(input("Please type a number: "))
if num == 0 or num % 2 == 0:
print(str(num) + " is an even number.")
else:
print(str(num) + " is an odd number.")
print("Finished!")
|
b51ba0b42641bb959b1cdb16f55fed6d9e841b5a | bruhge/HunttheWumpus | /Wumpus.py | 3,525 | 3.546875 | 4 | import random
class WumpusGame(object):
def __init__(self):
cave = {1: (2, 5, 8),
2: (1, 3, 10),
3: (2, 4, 12),
4: (3, 5, 14),
5: (1, 4, 6),
6: (5, 7, 15),
7: (6, 8, 17),
8: (1, 7, 11),
... |
74134e47b36a4efefc62e73f41f05345bc8645f9 | nazhanHarzula/test-case-problem | /test_case1.py | 1,376 | 3.578125 | 4 | import json
# Split data based on ascending part
def split_data_into_part(list_order):
list_new = []
my_list = []
for i in range(len(list_order)):
if i+1 < len(list_order):
if list_order[i] < list_order[i+1]:
my_list.append(list_order[i])
else:
... |
bd98b44224a655b3b6fcbb68f6d69e3390a629e7 | idycodes/SCAMP-Assesment | /fibonacci_series.py | 439 | 4.03125 | 4 | # Idiongoabasi Udoh
# Fibonacci Series solution
a=int(input("Enter the number of terms: "))
first=0
second=1
if a<=0:
print("The requested series is", first)
else:
print(first,second,end=" ")
for x in range(2,a):
... |
0cda415271ae3a8cef1bf338e8b47c52f2fb3157 | jibarra/advent-of-code | /2017/day3/day3.py | 9,851 | 4.25 | 4 | import math
# day3_input = 23
day3_input = 347991
"""
Each new 'square' is an odd number squared. So the first
is 1^2, the next is 3^2, then 5^2, etc.
In these scenarios, the max distance is at the diagonals. The
diagonals are a distance of 1 less than the number squared
for that particular square. The min distance ... |
d5085e97c7194faaa535664dc6584e52c8c36fee | chetnashah/pythonwork | /basics/inheritance.py | 750 | 4.09375 | 4 | # the basic way to declare dervied class is
# class DerivedClassName(BaseClassName):
# pass
# This is a classical class, not a new style class
class Person:
def __init__(self, first="John", last="Doe"):
self.firstname = first
self.lastname = last
def Name(self):
return self.firstname + " " + s... |
3911461c7d15d9461fd97c7cff0e52199b32f85b | rakeshbairi/Python | /Operators_Strings_Collections.py | 737 | 3.78125 | 4 | #Operators
print('Addition: '+str(1+1))
print('Division: '+str(13/2)) #Floor Division
print('Modulo Division: '+str(13//2)) # Integer Division
print('Exponental: '+str(2**6))
print('Absolute Value: '+str(abs(-5)))
#Try Catch
try:
a=5/0
print("Good to go")
except:
print("Don't do that")
#St... |
fa1ed3ad8bf17d11fef21382c80e01eb152672d6 | abaatiyah/Artificial-Intelligence | /Face Detection/FaceDetection.py | 974 | 3.671875 | 4 | import cv2 as cv
# Load the cascade
face_cascade = cv.CascadeClassifier('haarcascade_frontalface_default.xml')
# Read the input image
img = cv.imread('pic1.jpg',cv.IMREAD_UNCHANGED)
# Convert into grayscale
imgGray = cv.cvtColor(img, cv.COLOR_BGR2GRAY)
# Detect faces
faces = face_cascade.detectMultiScale(imgG... |
f89160a78b3c2951062d00b4f84a8430696bcff0 | FurmanSK/adventofcode2020 | /day3/app.py | 1,133 | 3.8125 | 4 | from collections import deque
import math
# Create queue (deck) global
d = deque()
def calcTreesInSlope(x, y):
# calculates based on x and y slope passed in
# x, y coord for current position
currentPos = [0, 0]
# tree count found
treeCount = 0
xoff = 0
while currentPos[1] < len(d):
... |
294115d83f56263f56ff23790c35646fa69f8342 | techreign/PythonScripts | /batch_rename.py | 905 | 4.15625 | 4 | # This will batch rename a group of files in a given directory to the name you want to rename it to (numbers will be added)
import os
import argparse
def rename(work_dir, name):
os.chdir(work_dir)
num = 1
for file_name in os.listdir(work_dir):
file_parts = (os.path.splitext(file_name))
os.rename(file_na... |
f08a7e8583fe03de82c43fc4a032837f5ac43b06 | bartoszmaleta/python-microsoft-devs-yt-course | /25th video Collections.py | 1,278 | 4.125 | 4 | from array import array # used later
names = ['Bartosz', 'Magda']
print(names)
scores = []
scores.append(98) # Add new item to the end
scores.append(85)
print(scores)
print(scores[1]) # collections are zero-indexed
points = array('d') # d stands for digits
points.append(44)
points.append(12... |
9eb9c7ecf681c8ccc2e9d89a0c8324f94560a1f3 | bartoszmaleta/python-microsoft-devs-yt-course | /31st - 32nd video Parameterized functions.py | 878 | 4.28125 | 4 | # same as before:
def get_initial2(name):
initial = name[0:1].upper()
return initial
first_name3 = input("Enter your firist name: ")
last_name3 = input("Enter your last name: ")
print('Your initials are: ' + get_initial2(first_name3) + get_initial2(last_name3))
# ___________________
def get_iniial(name... |
b3026c45a91238f22f7b9a4c7d458ac3f7b92fb1 | jonasrk/PiscoSourHashcode2020 | /read_and_write_functions.py | 764 | 3.859375 | 4 | "read and write functions"
import sys
def read_input_file(file_name):
"""
Reads the input file and returns m, n and sizes
"""
with open(file_name, "r") as fin:
line = fin.readline()
m, n = [int(num) for num in line.split()]
line = fin.readline().split()
sizes = np.emp... |
8018ab0fda4ba461eaea27bc29d629ea348f7f65 | sudhasr/BFS-2 | /rottenOranges.py | 1,564 | 3.5625 | 4 | """BFS approach"""
#Accepted on Leetcode
#Time complexity - O(N) as we are visiting every node
#Space complexity - O(N) for the queue
from collections import deque
class Solution(object):
def orangesRotting(self, grid):
"""
:type grid: List[List[int]]
:rtype: int
"""... |
770d4d6fa022b3488060f4566a28842b932c5e31 | vinvarad/Python_Projects | /.ipynb_checkpoints/Pybank_01-checkpoint.py | 447 | 3.546875 | 4 | import csv
total_net = 0
with open ('graded_homework_02-Python_Instructions_PyBank_Resources_budget_data.csv','r') as financial_data:
record_reader = csv.DictReader(financial_data)
for row in record_reader:
print(row)
for 'Date','Profit/Losses' in record_reader.items():
total_net += int(Profit... |
51baf239cdf6a624b49efa3fee8f9010e13e0f74 | nilavann/HackerRank | /Python/Strings/Alphabet Rangoli.py | 348 | 3.75 | 4 | def print_rangoli(size):
# your code goes here
import string
lowerCaseAlphabet = string.ascii_lowercase
output = []
for i in range(size):
letters = "-".join(lowerCaseAlphabet[i:size])
output.append(((letters[::-1]+letters[1:]).center((size + ((size - 1) * 3)),"-")))
print("\n".jo... |
3491bbdd091f4121378ab4ce2b03bd6e8cd5d120 | nilavann/HackerRank | /Regex/Applications Challenges/Find a Word.py | 223 | 3.609375 | 4 | #!/bin/python3
import re
sentences = " ".join( [ input() for _ in range( int( input()))])
for _ in range( int( input())):
testWord = input()
print( len( re.findall( "(?<![\w\d])"+testWord+"(?![\w\d])", sentences))) |
50d9005f38d116c0f32495657c86571f77212e8a | nilavann/HackerRank | /Regex/Applications Challenges/Find A Sub-Word.py | 209 | 3.703125 | 4 | #!/bin/python3
import re
words = ""
substring = []
for _ in range(int ( input())):
words = words + input() + " "
for _ in range(int ( input())):
print( len( re.findall( "\B" + input() + "\B", words))) |
3298f44912437cb53f8e2681a03fbdaede3236a8 | nilavann/HackerRank | /Python/Strings/sWAP cASE.py | 106 | 3.921875 | 4 | def swap_case(s):
return "".join( [ word.upper() if( word.islower()) else word.lower() for word in s]) |
3c0deb3daf0f333024f96cab134be6c5e257e255 | nilavann/HackerRank | /Python/Classes Challenges/Classes: Dealing with Complex Numbers.py | 1,622 | 4 | 4 | #!/bin/python3
import math
class Complex(object):
def __init__(self, real, imaginary):
self.real = real
self.imaginary = imaginary
def __add__(self, other):
return Complex( self.real + other.real, self.imaginary + other. imaginary)
def __sub__(self, other):
return Complex( ... |
277a858a44aa1304f3b26646b67fef8bceb63241 | nilavann/HackerRank | /Python/Regex and Parsing Challenges/Re.start() & Re.end().py | 442 | 3.765625 | 4 | #!/bin/python3
import re
s, k = input(), input()
#method 1
"""
if k in s:
print( *[ (el.start(), el.start()+len(k)-1) for el in re.finditer( r"(?={})".format( k), s)], sep="\n")
else:
print( "(-1, -1)")
"""
#method2
pattern = re.compile(k)
res = pattern.search( s)
if res:
while res:
print( "({0},... |
c609e6dfb1bf675c3ae6b93df6a1ca6d528851eb | nilavann/HackerRank | /Python/XML Challenges/XML2 - Find the Maximum Depth.py | 235 | 3.796875 | 4 | maxdepth = 0
def depth(elem, level):
global maxdepth
# your code goes here
if( level >= 0 and maxdepth == level):
maxdepth = level + 1
# print( elem, level)
for child in elem:
depth(child, level+1)
|
80c5dd0ccd96ccf0bc824542ab36240ab97d054a | nilavann/HackerRank | /30 Days of Code Challenges/Day 28: RegEx, Patterns, and Intro to Databases.py | 311 | 3.59375 | 4 | #!/bin/python3
import sys
import re
N = int(input().strip())
l = []
for a0 in range(N):
firstName,emailID = input().strip().split(' ')
firstName,emailID = [str(firstName),str(emailID)]
if( bool(re.match( r"^[a-z.]+@gmail\.com$", emailID))):
l.append(firstName)
print( *sorted(l),sep="\n") |
81f0a7c6561a2fbe04954dd13a94a36a2267fb20 | nilavann/HackerRank | /Python/Sets/Set .symmetric_difference().py | 242 | 3.609375 | 4 | #!/bin/python3
setA, setB = [ set(input().split()) for _ in range(4)][1::2]
#symmetric differnce return the items both its that not present in both
# method 1
# print( len(setA.symmetric_difference(setB)))
# method 2
print( len(setA^setB)) |
7a12fe2a57cd889377285725991ecafc904fb556 | laurenolivia/python-review | /oop/employee_class.py | 1,889 | 3.828125 | 4 | class Employee:
"""A simple employee class"""
num_of_employees = 0
raise_amt = 1.04
def __init__(self, first, last, pay):
self.first = first
self.last = last
self.pay = pay
self.email = f'{self.first}.{self.last}@company.com'
Employee.num_of_employees += 1
... |
421df64d87484e18e9b226a0d148501073fef055 | Raamy/td-algo-python | /Episode 2/Exercice12.py | 318 | 3.9375 | 4 | # Affichage de chaque caractères d'une chaîne avec la boucle for
mot = "Développement"
for char in mot:
print(char)
# Affichage de chaque élemeent d'une liste avec la boucle for
liste = ["Element N°1", "Element N°2", "Element N°3", "Element N°4", "Element N°5"]
for element in liste:
print(element) |
d640a0b50e39005267b166ee061c12dfc9e80347 | Raamy/td-algo-python | /Episode 2/Exercice7.py | 133 | 3.71875 | 4 | number = 1
def print_message(x):
for i in range(10):
print("Message n°" + str(x))
x += 1
print_message(number) |
88b7f567d19d7364a86094862b1b0b1a7a4281f4 | gzmason/Risk-Constrained-RL-env | /rl_env/envs/rl_env.py | 4,813 | 3.578125 | 4 |
# coding: utf-8
# In[1]:
import gym
from gym import spaces
import pandas as pd
import numpy as np
# In[ ]:
class CustomEnv(gym.Env):
"""Custom Environment that follows gym interface"""
metadata = {'render.modes': ['human']}
def __init__(self, df):
super(CustomEnv, self).__init__()
#df come... |
98782db88b252780eba31b1e89d50660cba4662e | ToolsforBigData/exercise6 | /ex10_2.py | 2,947 | 3.65625 | 4 | from PIL import Image
import numpy as np
# Function that takes with the image resized to (8,9) and greyscaled
# and returns the hash string of that image
# Input: The greyscaled resized image and the size of the image.
# Output: The hash string
def hashingFun(img,size):
# Get the pixel values of the image into a n... |
23057a94e61247556a73e34d58d98329b0738e13 | MMVonnSeek/Hacktoberfest-2021 | /Python-Programs/placeholder_images/placeholder.py | 1,862 | 3.515625 | 4 | #! /usr/local/bin/python
import argparse
import re
from os import getcwd, path
import requests
# script to get placeholder image from via.placeholder.com api
# by taking input from user via argparse
# https://via.placeholder.com/600x400
def main():
parser = argparse.ArgumentParser(
description="Get pla... |
b32b7084de9ece1df058877b51c035586dc477f9 | MMVonnSeek/Hacktoberfest-2021 | /Python-Programs/who_pay_bill.py | 379 | 4.0625 | 4 | import random
# Split string method
names_string = input("Give me everybody's names, separated by a comma. ")
names = names_string.split(", ")
# Don't change the code above
# Write your code below this line
name_length = len(names)
random_name = random.randint(0, name_length - 1)
person_who_will_pay = names[random_... |
3c934b9b229a14f92862e6e6be6da9e41a1974f9 | MMVonnSeek/Hacktoberfest-2021 | /Python-Programs/py-port-scanner-main/portscanner.py | 2,040 | 3.609375 | 4 | #!/bin/python3
import argparse
import re
import socket
import time
import header
# Arguement Parsing for CLI
parser = argparse.ArgumentParser(description="A Simple Network port scanner.")
parser.add_argument("host", help="Ip address of host to scan.")
parser.add_argument(
"-p",
dest="port_range",
default... |
2fb0f374d4b6e0b4e08b9dd6cdd324c903537832 | MMVonnSeek/Hacktoberfest-2021 | /Python-Programs/Reverse_Doubly_Linked_List_Using_Stack.py | 1,291 | 4.21875 | 4 | class Node:
def __init__(self, data):
self.prev = None
self.data = data
self.next = None
class Doubly_Linked_List:
def __init__(self):
self.head = None
def Add_at_front(self, new_data):
new_node = Node(new_data)
new_node.next = self.head
... |
cb822123aafc88728aac3eec9868df208cd062d8 | MMVonnSeek/Hacktoberfest-2021 | /Python-Programs/horoscope/daily_horoscope.py | 1,201 | 3.828125 | 4 | """
Program to get horoscope for
Yesterday, Today and Tomorrow
of any zodiac sign
"""
import inquirer
import requests
from bs4 import BeautifulSoup
zodiac_sign = {
"Aquarius": 1,
"Aries": 2,
"Cancer": 3,
"Capricorn": 4,
"Gemini": 5,
"Leo": 6,
"Libra": 7,
"Pisces": 8,
"S... |
6544630135a7287c24d1ee167285dc00202cb9aa | MMVonnSeek/Hacktoberfest-2021 | /Python-Programs/avg-parse.py | 1,168 | 4.15625 | 4 | # Total, Average and Count Computation from numbers in a text file with a mix of words and numbers
fname = input("Enter file name: ")
# Ensure your file is in the same folder as this script
# Test file used here is mbox.txt
fhandle = open(fname)
# Seeking number after this word x
x = "X-DSPAM-Confidence:"
y = len(x)
... |
04b6de16e4bb5e3ceb7d0c459335f81930f044ac | MMVonnSeek/Hacktoberfest-2021 | /Python-Programs/ReverseString.py | 111 | 4.28125 | 4 | print("enter a text you want to reverse")
txt = str(input())
a = txt[::-1]
print("Reversed text is:")
print(a)
|
6934e148c95348cd43a07ddb86fadc5723a0e003 | MMVonnSeek/Hacktoberfest-2021 | /Python-Programs/number_decorator.py | 543 | 4.34375 | 4 | # to decorate country code according to user defined countrycode
# the best practical way to learn python decorator
country_code = {"nepal": 977, "india": 91, "us": 1}
def formatted_mob(original_func):
def wrapper(country, num):
country = country.lower()
if country in country_code:
ret... |
2b1543014f39e9ff3f16c4e83da2902370360629 | MMVonnSeek/Hacktoberfest-2021 | /Python-Programs/dict.py | 200 | 4.0625 | 4 | # Python program demonstrating the use of dictionary
person = {"name": "Smriti", "github": "smritineupane"}
for k, v in person.items():
print("Name:", k)
print("Github Username:", v)
|
baa660a94516473a53677e9f3b6082d3ee37b999 | Liuhui0816/HogwartsTesting | /pytest_practice/calc/test_calc.py | 2,365 | 3.5625 | 4 | """
补全计算器(加减乘除)的测试用例
使用数据的数据驱动,完成加减乘除用例的自动生成
创建 fixture 方法实现执行测试用例前打印【开始计算】,执行测试用例之后打印【计算结束】
控制测试用例顺序按照【加-减-乘-除】这个顺序执行
结合allure 生成测试结果报告
"""
import allure
import pytest
@allure.feature('测试计算器')
class Test_calc:
@pytest.mark.run(order=1) # 按照顺序执行测试用例
@allure.story("测试加法")
def test_ad... |
fc81a1bc381cbfa8aa4a9e561e36b0cdf87b1b07 | GursharanKaur08/Python-Projects | /Dice Rolling Simulator/dice.py | 1,426 | 3.96875 | 4 | # We want random number in b/w 1 and 6, condition provided is that 1 and 6 should be included.
import random
print('|---Welcome to dice stimulator---|')
while True:
dice_number = random.randint(1,6)
if dice_number == 1:
print('-----------')
print('| |')
print('| o |')
... |
1018ca8997e73c43c9067bfbc8f1414d5012fd6a | infinite-Joy/kernels | /fake_news.py | 2,903 | 3.53125 | 4 |
# coding: utf-8
# The main aim of this notebook is to classify fake news and real news and see the confusion matrix.
# In[*]
import pandas as pd
print("Import `fake_or_real_news.csv`")
df = pd.read_csv('fake_or_real_news.csv')
# In[*]
y = df[['label']]
print(y.head())
# In[*]
df.drop('label', axis=1, inplace=... |
132cf9277e7df37443d3ee65c3545cde80115479 | belushkin/bloomon | /bloomon/utils/bouqet_manager.py | 9,525 | 3.5 | 4 | import re
from bloomon.entities.bouqet_design import BouqetDesign
from collections import defaultdict
class BouqetManager(object):
"""
A class used to operate input data from the input stream.
It takes input data and decide whether it is flower or design, then it stores it in internal storage
... |
ac8b0ece36ae1c01186f042af449774185fa89bc | ericwang2004/Eric- | /Code/Graphs/sudoku_solve.py | 1,973 | 3.921875 | 4 | #
#
#
#
from collections import deque
import time
'''
nodes = possible configurations
edges = links two configurations that can be obtained through changing one character
'''
def display(string):
# displays the string of length 81 representing the puzzle into the sudoku format
for i in range(len(string)):
if i %... |
d7f5a7d5b8448eff946fd6cd3e7a8f5fbbe5d14c | ericwang2004/Eric- | /Code/Graphs/dijkstra.py | 1,817 | 4.03125 | 4 | # Dijkstra
#
#
#
#
class infinity(float):
def __gt__(self, other):
return True
def __lt__(self, other):
return False
def create_adjacency_list(lines):
adjl = {}
for line in lines:
line = line.strip()
if ' ' not in line: # it's a vertex
adjl[line] = []
else: # it's an edge
v1, v2, w = line.split(' ... |
ba3152b703525a43c61e3c129c4b533edb101658 | ericwang2004/Eric- | /Code/Heaps/heaps.py | 2,422 | 3.953125 | 4 | # comment this
# runtime of insert, delete, minimum, heapsort
# table in google docs
#
'''
9
5 3
1
l = [0, 23, 11, 9, 1, 5, 3]
'''
class Heap:
# min heap - parent is smaller than children
def __init__(self):
self.elems = [0]
'''
root = second item in self.elems
for every node at inde... |
aa1617d47dfbe2c58b24542c22fd0a3ded433093 | vikaskumar99/sorting_visualizer | /mergeSort.py | 1,630 | 3.71875 | 4 | import time
def mergeSort(data, draw, speed):
mergeSortAlgo(data, 0 , len(data)-1, draw, speed)
def mergeSortAlgo(data, left, right, draw, speed):
if left<right:
middle = (left + right) // 2
mergeSortAlgo(data, left, middle, draw, speed)
mergeSortAlgo(data, middle+1, right, dr... |
46578ba7b0d8bb79cc53daad6a0987109c85d9cc | CodeBytes-PDX/text_adventure_challenge | /bradley_elenbaas/character.py | 1,903 | 3.5625 | 4 | '''
Project: Life Adventure
Character file.
.. codeauthor:: Bradley Elenbaas <mr.elenbaas@gmail.com>
'''
# Import Python first-party libraries.
import copy
class Character(object):
'''
Character class.
'''
def __init__(self):
'''
Pseudo-Constuctor.
'''
#... |
6e10d09bf4a4a4abb756f1391831c3001397eefd | zonkisa/leezyer | /TheAlgorithms/data_structures/python/linked_list/linked_list.py | 7,729 | 4.09375 | 4 | """
链表:
一种递归的数据结构
或为空,或指向一个结点的引用,该结点含有一个泛型元素和一个指向另一条链表的引用
其中结点是一个可能含有任意类型数据的抽象实体
"""
from __future__ import print_function
# 嵌套类的形式定义抽象实体,结点值data为泛型类型,初始化结点的引用指向为空
class Node:
def __init__(self, data):
self.data = data
self.next = None
"""
链表API
在表尾插入结点、在表头插入结点、链表遍历(大小)、删除表头结点、删除表尾结点、空链表检查、链表反转
... |
e686ac193d1134d790a60836d1a3fed699de5c74 | zonkisa/leezyer | /TheAlgorithms/data_structures/python/find/Elementary_Symbol_Tables/binary_search_tree.py | 10,005 | 3.96875 | 4 | # coding: utf-8
from __future__ import print_function
from queue import Queue
class Node:
left = None
right = None
def __init__(self, key, val, N):
self.key = key
self.val = val
self.N = N # 以该结点为根的子树中的结点总数
# self.left = None
# self.right = None
class BinarySear... |
4c250c69b79b013e6118edb2128b996e812bef0e | trentbitterman/Hangman | /print_hangman.py | 3,510 | 4.28125 | 4 | """Functions to print out the state of the hanged man"""
def print_hangman(hangman_state):
"""Prints correct hangman depending on state"""
if hangman_state == 1:
print_state_one()
elif hangman_state == 2:
print_state_two()
elif hangman_state == 3:
print_state_three()
elif ... |
000a9e0df1acb5804b401a0c87f06f11162c9c88 | eclecticexistential/PracticePythonDaily | /practice_daily.py | 43,701 | 4.125 | 4 | # # #for importing dictionary to string
# # #import json
# # import random
# #
# # # def even_odd(num):
# # # return not num % 2
# # #
# # # start = 5
# # #
# # # while start > 0:
# # # number = random.randint(1,99)
# # # if even_odd(number):
# # # print("{} is even".format(number))
# # # else:
... |
dc882ac280f0b5c40cbc1d69ee9db9529e1ad001 | Raviteja02/CorePython | /venv/Parameters.py | 2,308 | 4.28125 | 4 |
#NonDefault Parameters: we will pass values to the non default parameters at the time of calling the function.
def add(a,b):
c = a+b
print(c)
add(100,200)
add(200,300)
print(add) #function address storing in a variable with the name of the function.
sum=add #we can assign the function variable to any user ... |
1fbbfcd3d4379b370e0ccc9ee98434a023f30302 | risusanto/shortest-path | /prim.py | 1,344 | 3.515625 | 4 | #prim algorithm
def prim(graph, root):
assert type(graph)==dict
nodes = list(graph)
nodes.remove(root)
visited = [root]
path = []
next = None
while nodes:
distance = float('inf')
for s in visited:
for d in graph[s]:
if d in visited or s == ... |
16c9496e938b3d37774beaf6f14691e2c75a53dd | burakdogan94/ownprojects | /ebobekok_def.py | 635 | 3.59375 | 4 | def ekok(a, b):
toplam = a*b
i=1
while i<toplam:
i+=1
if a % i == 0 and b % i == 0:
print(f"Ekok: {i}")
break
else:
print("ekok: 1")
break
def ebob(a, b):
if a>b:
c=b+1
while c>=0:
c-=1
if ... |
7202f2f286c55dd325fac8a773ff72f4879648f2 | snivaskumar/wifi-py-rpi-car-controller | /RTSim/RTRobot.py | 1,982 | 3.5 | 4 | from RTSim import RTSim
class RTRobot(RTSim):
"""
RTRobot Controller for RTSim real-time robot simulation.
https://github.com/FJFranklin/wifi-py-rpi-car-controller/tree/master/RTSim
"""
def __init__(self, seconds):
# usage: RTRobot (seconds)
RTSim.__init__(self, seconds)
... |
cd8d1f478d220308fe950e8fb5c858e35a46d269 | daniel-hampton/computer_vision_scratch | /canny02.py | 670 | 3.78125 | 4 | """
Canny Edge Detection
Goal
In this chapter, we will learn about
Concept of Canny edge detection
OpenCV functions for that : cv2.Canny()
"""
import cv2
import numpy as np
from matplotlib import pyplot as plt
cap = cv2.VideoCapture(1)
while cap.isOpened():
ret, frame = cap.read()
if ret:
edges = ... |
4697219871610812fe26e32cae77e5ead7afae01 | daniel-hampton/computer_vision_scratch | /smoothing03.py | 1,091 | 3.5 | 4 | """
Smoothing Images
Goals
Learn to:
Blur imagess with various low pass filters
Apply custom-made filters to images (2D convolution)
"""
import cv2
import numpy as np
from matplotlib import pyplot as plt
img = cv2.imread('small_person.jpg')
img = img[:, :, ::-1] # convert colors from BGR to RGB using numpy indexing (... |
c3da15761fa9841a968312a736d64c960cbcea6c | daniel-hampton/computer_vision_scratch | /vid_basics03.py | 1,167 | 4.0625 | 4 | """
Getting Started with Videos
Goal
Learn to read video, display video and save video.
Learn to capture from Camera and display it.
You will learn these functions : cv2.VideoCapture(), cv2.VideoWriter()
"""
import numpy as np
import cv2
cap = cv2.VideoCapture('device_video.mp4')
# Define the codec and create Video... |
0f32a56ec557f7a68cbcf591e5d43b4ba8bd84a8 | abiramikawaii/Python | /sum-of-multiples.py | 265 | 4.21875 | 4 | def sum_of_multiples(a,b, n):
ans=0
for i in range (1,n):
if(i%a==0 or i%b==0):
ans=ans+i
print("Sum of multiples of ", a,"and",b,
"for all the natural numbers below ", n, " is ", int(ans))
# Driver Code
sum_of_multiples(3,5, 20)
|
c6df114aef716ec5e1753fcf4ee39928de54d7f1 | niclasgeiger/udacity | /final-project/code/feature_relevance.py | 1,645 | 3.609375 | 4 | from sklearn.model_selection import train_test_split
from sklearn.tree import DecisionTreeRegressor
from matplotlib import pyplot as plt
def check_feature_relevance(data):
redundant = []
significant = []
for feature in data.keys():
print 'Checking Feature "', feature, '"'
# Make a copy of t... |
787e8abec85a1fc4cb30d63c56e3848b89a4b342 | niclasgeiger/udacity | /final-project/code/outlier_detection.py | 1,946 | 3.71875 | 4 | import numpy as np # linear algebra
import matplotlib.pyplot as plt
def detect_outliers(data):
# For each feature find the data points with extreme high or low values
_out = []
duplicate = []
check_data = data.drop(labels=["id","date"], axis=1)
extreme_count = dict.fromkeys(data.index.values,0)
... |
92ad1e82cfe82181cb558d414ed7d527071caf02 | Mohammed-AhmedAF/python | /if.py | 88 | 3.9375 | 4 | x = 5
if (x > 1):
print("X is bigger than 1.")
else :
print("X is not bigger than 1")
|
56195319ed67e464bf7f0720480c5cc074a47f35 | sahascal/demo-py | /hello.py | 198 | 4.125 | 4 | # first python code
def say_hi(name='Sam'):
if name =='':
print("You didn't enter a name")
else:
print("Hi! there")
for letter in name:
print(letter)
|
e74cdb39b235e0e237327bd706aef39daffd833d | Igglyboo/Project-Euler | /200-299/200-209/Problem203.py | 1,300 | 3.796875 | 4 | from time import clock
from math import sqrt
def timer(function):
def wrapper(*args, **kwargs):
start = clock()
print(function(*args, **kwargs))
print("Solution took: %f seconds." % (clock() - start))
return wrapper
@timer
def find_answer():
distinct = set()
previous = [1, 1... |
673535106f98405bb620266583d2eaa4460dd1f3 | Igglyboo/Project-Euler | /1-99/50-59/Problem50.py | 1,630 | 3.59375 | 4 | from time import clock
def timer(function):
def wrapper(*args, **kwargs):
start = clock()
print(function(*args, **kwargs))
print("Solution took: %f seconds." % (clock() - start))
return wrapper
@timer
def find_answer():
primes = sieve(1000000)
primes_cache = [[0, 0, 0]] * le... |
78446cf1687966e3ddb3fd0a9febc88e17d1a48b | Igglyboo/Project-Euler | /1-99/30-39/Problem34.py | 508 | 3.546875 | 4 | from time import clock
from math import factorial
def timer(function):
def wrapper(*args, **kwargs):
start = clock()
print(function(*args, **kwargs))
print("Solution took: %f seconds." % (clock() - start))
return wrapper
@timer
def find_answer():
total = 0
for i in range(10,... |
57e73f040ef8e5d85f99593ac4a2dcf4560ee2ac | Igglyboo/Project-Euler | /1-99/30-39/Problem32.py | 697 | 3.515625 | 4 | from time import clock
def timer(function):
def wrapper(*args, **kwargs):
start = clock()
print(function(*args, **kwargs))
print("Solution took: %f seconds." % (clock() - start))
return wrapper
@timer
def find_answer():
target = ['1', '2', '3', '4', '5', '6', '7', '8', '9']
... |
864ec03c9ef270240538d7fbf774f9450b010374 | Igglyboo/Project-Euler | /1-99/50-59/Problem57.py | 1,045 | 3.640625 | 4 | from time import clock
from itertools import count
from math import sqrt
def timer(function):
def wrapper(*args, **kwargs):
start = clock()
print(function(*args, **kwargs))
print("Solution took: %f seconds." % (clock() - start))
return wrapper
@timer
def find_answer():
previous_... |
3b9cd47661ca6cdacd5ecccd052d3c46bd7570a6 | BananaAndBread/FCS | /Homework 1/frequency_analisys.py | 6,038 | 4 | 4 | def exchange_values_in_dict(some_dict, key, new_value):
"""
Assigns value "new_value" to the key "key" from dict "some_dict", finds key which was associated with value
"new_value" in dict "some_dict" and replaces its value with the previous value of key "key"
:param some_dict:
:param key:
:param... |
dc81fb4d55f94c235f2bc6c24fbc9dd450ed9fd8 | vrundpat/Mazegen | /main.py | 1,886 | 3.546875 | 4 | from generate import *
pygame.init()
width, height, diff = 800, 800, 40
linecol, AiColor, winColor = (0, 0, 0), (152, 254, 255), (255, 255, 255)
count, tiles, visited, rows, cols, condition = 0, [], [], width//diff, height//diff, False
win = pygame.display.set_mode((width, height))
pygame.display.set_caption("Maze Ge... |
0df8dbb8b73d0d16ae2c01eb319a95125006a94b | bastiwang26/python_study | /for_number.py | 215 | 3.71875 | 4 | for i in range(1,5):
for j in range(1,5):
if i == j:
continue
for k in range(1,5):
if k == j or k == i:
continue
print str(i) + str(j) + str(k) |
aedb7c26c818fb91b847f833762d6eae56fc2c2c | bastiwang26/python_study | /if.py | 200 | 3.96875 | 4 | ans = input("pls input a number: ")
num = 10
if ans > num:
print "%s is bigger than %s" % (ans,num)
elif ans < num:
print "%s is smaller than %s" % (ans,num)
else:
print "they are same" |
f969e3f238c8086b1df8e4ec60aa7200f46eac65 | Folkert94/Algoritmen-Datastructuren | /cs_airport/airport.py | 2,823 | 3.59375 | 4 | """
Folkert Stijnman
10475206
Datastructuren & Algoritmen
Airport implementation using BST and Airport.
"""
import argparse
from bst import BST
class Airport(BST):
def __init__(self, wait_time=300000, simple=False):
BST.__init__(self)
self.wait_time = wait_time
self.simple = simple
... |
00c2e3008842660ae189daba7673f8d19a9b8b4a | markdannel/leetcode | /dp/maxProfit.py | 245 | 3.6875 | 4 | def maxProfit(prices):
maxp = 0
minp = prices[0]
for i in prices:
minp = min(minp, i)
maxp = max(maxp, i- minp)
return maxp
prices = list(range(999, 0, -1))#[7,1,5,3,6,4]
prices.append(5)
print(maxProfit(prices)) |
bf0e681b7608dd9198aa35f09f2e115df9aebfb6 | markdannel/leetcode | /tree/no113.py | 1,248 | 3.78125 | 4 | # 给定一个二叉树和一个目标和,找到所有从根节点到叶子节点路径总和等于给定目标和的路径。
# 说明: 叶子节点是指没有子节点的节点。
# 示例:
# 给定如下二叉树,以及目标和 sum = 22,
# 5
# / \
# 4 8
# / / \
# 11 13 4
# / \ / \
# 7 2 5 1
# 返回:
# [
# [5,4,11,2],
# [5,8,4,5]
# ]
# Definition for a binary t... |
772e7aef360b595c1778235181e703e6c35ad553 | markdannel/leetcode | /reveseLineList.py | 290 | 3.921875 | 4 | class LinkedList(object):
def __init__(self, x):
self.val = x
self.next= None
def reverse(node):
p = node
cur = node.next
p.next = None
while cur:
temp = cur.next
cur.next = p
p = cur
cur = temp
return p |
0b0231c84a4a50a75ed1d27387aba6f4a4fe29ec | markdannel/leetcode | /tree/no889.py | 761 | 3.984375 | 4 | # 返回与给定的前序和后序遍历匹配的任何二叉树。
# pre 和 post 遍历中的值是不同的正整数。
# 示例:
# 输入:pre = [1,2,4,5,3,6,7], post = [4,5,2,6,7,3,1]
# 输出:[1,2,3,4,5,6,7]
# 提示:
# 1 <= pre.length == post.length <= 30
# pre[] 和 post[] 都是 1, 2, ..., pre.length 的排列
# 每个输入保证至少有一个答案。如果有多个答案,可以返回其中一个。
# Definition for a binary tree node.
class TreeNode:
def __... |
cd2236d3b1b0490064483e2e9275c24c698cc0a9 | coolzoa/INTRO_IfExercises | /homework1.py | 21,661 | 4.125 | 4 | """
Author: Jose Pablo Murillo
File: homework1
Description: Use of if clause
Last update: 01/12/2018
Python version 3.6.4
"""
#Exercise 1
def miniCalculator(number1: int, number2: int, operation: str) -> int:
"""
Inputs: first number, second number, operation code
Output: arithmetic operation result or err... |
3b1bbf74275f81501c8aa183e1ea7d941f075f56 | Tadiuz/PythonBasics | /Functions.py | 2,366 | 4.125 | 4 | # Add 1 to a and store it in B
def add1(a):
"""
This function takes as parameter a number and add one
"""
B = a+1
print(a," if you add one will be: ",B)
add1(5)
print(help(add1))
print("*"*100)
# Lets declare a function that multiplies two numbers
def mult(a,b):
C = a*b
return C
... |
6e5f3346fce64a36206f8c8007c40746eabadb83 | nishiwakki/aoj | /alds1/stable_sort.py | 1,707 | 3.90625 | 4 | # -*- coding: UTF-8 -*-
from copy import deepcopy
# 隣同士のみの交換のため、大移動がない
# 順序がまばらになることがないためstable
def bubble_sort(A, N):
flag = True
while flag:
flag = False
for j in range(N-1, 0, -1):
if int(A[j][1]) < int(A[j-1][1]):
tmp = A[j]
A[j] = A[j-1]
... |
27584ece608dd8773a7f9b1a65b66aee40efb26f | nishiwakki/aoj | /alds1/koch_curve.py | 1,223 | 3.71875 | 4 | # -*- coding: UTF-8 -*-
import math
# 小数8桁まで表示する関数
def pprint(x, y):
print('{:.8f}'.format(x), '{:.8f}'.format(y))
# 2点p1,p2のs,u,tを計算する関数
def koch(p1x, p1y, p2x, p2y):
sx = p1x + (p2x - p1x) / 3
sy = p1y + (p2y - p1y) / 3
tx = p2x - (p2x - p1x) / 3
ty = p2y - (p2y - p1y) / 3
ux = sx + \
... |
9924eea082edc59a093418622e6647b8948a05c2 | kip-codes/python-sandbox | /PythonCrashCourse-EricMatthes/8. Functions/cars.py | 547 | 3.609375 | 4 | # File: cars
# Project: PythonCrashCourse
# Local author: kevinip
# Created on 11/11/2017 at 4:13 PM
#
# For inquiries about the file please contact the author.
def makeCar(manufacturer, model, **kwarg):
car = {}
car['manufacturer'] = manufacturer
car['model'] = model
for key, value in kwarg.items():
... |
289ae926da39b6f63b296fa58dbe7408314602c9 | kip-codes/python-sandbox | /PythonCrashCourse-EricMatthes/2. Variables and Simple Data Types/stripping_names.py | 530 | 4.03125 | 4 | # File: stripping_names
# Project: PythonCrashCourse
# Local author: kevinip
# Created on 09/23/2017 at 6:16 PM
#
# For inquiries about the file please contact the author.
# Assignment prompt
print("2-7. Store a person's name, and include whitespace characters at the beginning and end of the name."
"Make sure yo... |
e05531d35037fd3d9f694bdb9eab6e90a468aae4 | kip-codes/python-sandbox | /PythonCrashCourse-EricMatthes/2. Variables and Simple Data Types/famous_quote.py | 558 | 3.796875 | 4 | # File: famous_quote
# Project: PythonCrashCourse
# Local author: kevinip
# Created on 09/23/2017 at 6:07 PM
#
# For inquiries about the file please contact the author.
# Assignment prompt
print("2-5. Famous Quote:")
print("Find a quote from a famous person you admire. Print the quote and the name of the author. (p. 2... |
c32f56b39ba7c6ceb66c043bda1fe09f2ee9b8df | kip-codes/python-sandbox | /PythonCrashCourse-EricMatthes/3. List Introduction/modifying_lists.py | 5,570 | 4.375 | 4 | # File: modifying_lists
# Project: PythonCrashCourse
# Local author: kevinip
# Created on 09/23/2017 at 8:56 PM
#
# For inquiries about the file please contact the author.
import random
# Assignment prompt
print('* ' * 20)
tiy3_4 = "If you could invite anyone, living or deceased, to dinner, who would you invite?" \
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.