blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string |
|---|---|---|---|---|---|---|
b52f7a3e522b22af97a7dd5162362d58df6fd4ce | JontePonte/SudokuSolver2 | /find_single_possibilities.py | 896 | 4.09375 | 4 |
def find_single_possibilities(field, list):
""" Check if a possibility in the field only appears ones in a list of fields. Sets the fields possibility to that value if so """
if len(list) != 9:
raise ValueError("The list input to find_single_possibilities must be == 9")
# Only check the u... |
9af0f6ff99fc55bd7576acf4a2b8311ab77d75af | adgopi/python-practice-stuff | /leetcode/leetcode explore/arrays/4 search/check_if_double_exists.py | 513 | 3.8125 | 4 | from typing import List
class Solution:
def checkIfExist(self, arr: List[int]) -> bool:
'''
Return if there exist 2 elements in arr such
that one element is twice the other
'''
if arr.count(0)==1:
arr.remove(0)
elif arr.count(0)>=2:
return Tr... |
add31cdf10913dc313ea4cf126dac536b1b5cb85 | supriyo-pal/Machine-Learning-with-python | /logistic regrassion(Binary classification).py | 629 | 3.75 | 4 | # -*- coding: utf-8 -*-
"""
Created on Sat Nov 21 23:49:45 2020
@author: Supriyo
"""
import pandas as pd
from matplotlib import pyplot as plt
from sklearn.model_selection import train_test_split
from sklearn.linear_model import LogisticRegression
df=pd.read_csv("insurance_data.csv")
plt.scatter(df.age,d... |
91790f42d6f3b19e7c56bc82f65760f962035f70 | Fgsj10/Python_Trainning | /Strings/Code_Four.py | 511 | 3.984375 | 4 | """
Author = Francisco Gomes
"""
#User data input and variables
print("Validating number cellphone")
number = str(input("Enter with a number: "))
phoneFormated = number.replace("-", "")
#Checking of number cellphone is validate
if(len(phoneFormated) == 7):
print("Cellphone with 7 digits, adding number 3 in fr... |
8628b5ea1e1674bfe3345fb3752e417dddd36bbe | jacocloeteHU/TICT-V1PROG-15 | /les 02/perkoviz exercises.py | 1,247 | 3.546875 | 4 |
def p(val):
print(val)
return;
# avarage
p((23+19+31)/3)
# 2.1
p(7 + 7+ 7+7 +7)
p(403 // 73)
p(403 % 73)
p(2**10)
p(57-54)
p(min(34.99,29.95,31.50))
# 2.2
p((2+2) < 4)
p((7 // 3) == (1 + 1))
p(((3**3) + (4**4) == 25))
p((2+4+6) > 12)
p((1387 / 19) and True)
p(31 % 2 == 2)
p(min(29.95,34.99) < 30.00)
#... |
2c2da63a48bfe7ea6afd986851fa6f6c00eff5cb | BaoCaiH/Daily_Coding_Problem | /Python/2019_02_15_Problem_31_Edit_Distance.py | 1,189 | 4.1875 | 4 | #!/usr/bin/env python
# coding: utf-8
# ## 2019 February 15th
#
# Problem: The edit distance between two strings refers to the minimum number of character insertions, deletions, and substitutions required to change one string to the other. For example, the edit distance between โkittenโ and โsittingโ is three: substi... |
e7359ad91ccf1bf116022bc3a7609014deb4b971 | sco357/Python-HangMan | /Code.py | 12,834 | 3.71875 | 4 | play = True
while play:
# The below section is used to import the python modules into our code
import time
import os
import random
import sys
# The vairables are defined as 0 or nothing so that they can be operated with straight aaway
player_1_life = 0
player_2_life = 0
l... |
b2f298d715a3309d66207226f72a4e16879d9371 | gorkhali125/image-processing-algorithms | /negative_grayscale/negative_grayscale.py | 1,732 | 3.84375 | 4 | import math
from PIL import Image, ImageDraw
def negative_grayscale(img):
for i in range(0,width):
for j in range(0,height):
thisPixel = img.getpixel((i,j))
#If the current pixel has pixel value, increment the pixel value by 1 and set the pixel value. For Original Image
OrgImagevalues[thisPixel] += 1
im... |
07072a54659aed77b3c72b9a1cdead8033709d3e | FrekiMuninnsson/UdacityFSNDpycode2nd | /rename_files.py | 731 | 3.828125 | 4 | import os
def rename_files():
# Get all the filenames from the folder in which the files reside.
file_list = os.listdir(r"C:\Users\User\Desktop\Udacity FullStack Developer Nanodegree\Secret Message\to_be_renamed")
print(file_list)
saved_path = os.getcwd()
print ("Current Working Directory is "+saved_path)
... |
c60d90dcdf74712ad444fb477b14b20e34018423 | ClariNerd617/personalProjects | /learnPython/abc.py | 450 | 4.125 | 4 | from abc import ABCMeta, abstractmethod
class Shape(metaclass = ABCMeta):
@abstractmethod
def area(self):
return 0
class Square(Shape):
side = 4
def area(self):
print(f'Area of square: {self.side ** 2}')
class Rectangle(Shape):
width = 5
length = 10
def area(self):
... |
53d711bc38f788303101a22b3c897cd51679eaa3 | stjordanis/HackerRank-2 | /marcscupcakes.py | 583 | 3.640625 | 4 | import more_itertools as mit
from pprint import pprint
c = [1, 3, 2]
n = len(c)
possible_miles = []
def random_permute_generator(iterable, n):
for _ in range(n):
yield mit.random_permutation(iterable)
possible_combos = (list(set(list(random_permute_generator(c, 20)))))
for combo in possible_combos:
... |
2ce870fe0cf30c605c09125dc2c9586d9af9fe7e | lordpews/python-practice | /for w else.py | 867 | 4.34375 | 4 | koko = ["bharta", "bengan", "parantha"]
for items in koko:
print(items)
# break
"""
When we use else with for loop the compiler will only go into the else block of code
when two conditions are satisfied:
1. The loop normally executed without any error. using break statements or jump statement w... |
ecbe84ddcbd59968e6b63d231b59e8247c59d252 | Kusanagy/ifpi-ads-algoritmos2020 | /Exercรญcio 3.1.py | 278 | 3.859375 | 4 | def main():
palavra = input('Palavra: ')
right_justify(palavra)
def right_justify(s):
tamanho_palavra = len(s)
quantidade_de_espaรงos = 70 - tamanho_palavra
espaรงos = quantidade_de_espaรงos * ' '
linha = espaรงos + s
print(linha)
main() |
543332482c078ae08a686f3fd12d4496cd4ab0f3 | kajal-0101/python-basics | /check_divisor_second_no.py | 687 | 4.15625 | 4 | '''
Asks the user for two integers, and then displays whether the second integer
is a divisor of the ๏ฌrst integer
'''
print("Two integers are to be taken as input")
a=input("Enter the first integer: ")
a=int(a)
b=input("Enter the second integer: ")
b=int(b)
if(a>b):
large=a
small=b
print("The larger value is {} an... |
ac64cfa2819b4c3b51d0f464ebfbef639eac7103 | Aishaharrash/holbertonschool-machine_learning | /supervised_learning/0x03-optimization/12-learning_rate_decay.py.bak | 1,110 | 3.6875 | 4 | #!/usr/bin/env python3
"""
12-learning_rate_decay.py
Module that defines a function called learning_rate_decay
"""
import tensorflow as tf
def learning_rate_decay(alpha, decay_rate, global_step, decay_step):
"""
Function that updates the learning rate using inverse time decay in numpy
Args:
alpha... |
5acdd481025b763b186bd58c749f37f7f4fe78bd | towshif/towshif.github.io | /projects/helloworlds-intro/helloworld.py | 289 | 3.96875 | 4 | # Function to add 2 numbers
def addme(a, b):
return a+b
def multme(a, b):
return a*b
def divideme(a, b):
return a/b
print("Hello World")
print("Add 5 + 2 = ", addme(5, 2))
print("Multiply 5 * 2 = ", multme(5, 2))
print("Divide 5 / 2 = ", divideme(5, 2))
|
7914cef158de1776bf26b78b0ac4052f537fbbfb | ddtBeppu/introPython3_beppu | /e06/e06_01.py | 767 | 3.859375 | 4 | # ๅพฉ็ฟ่ชฒ้ก 6-1
# ไธญ่บซใฎใชใThingใฏใฉในใไฝใใ่กจ็คบใใใใๆฌกใซใใใฎใฏใฉในใใexampleใจใใใชใใธใงใฏใใไฝใใใใใ่กจ็คบใใใใ
# ่กจ็คบใใใๅคใฏๅใใใใใใจใ็ฐใชใใใ
# Thingใฏใฉในใฎไฝๆ
class Thing():
# ไธญ่บซใๆใใชใใฏใฉในใจใใ
pass
# Thing()ใฏใฉในใ่กจ็คบ
print("class Thing() = ", Thing())
# exampleใชใใธใงใฏใใไฝๆ
example = Thing()
# exampleใชใใธใงใฏใใ่กจ็คบ
print("example = ", example)
# ๅฎ่ก็ตๆ
# ่กจ็คบใใใๅคใฏ็ญใใใใจใ... |
7ea9e89a89c58291844571f06eb2f1b09147f187 | Hayk258/lesson | /kalkulyator.py | 554 | 4 | 4 | print (5 * 5)
print (5 % 5)
print(25 + 10 * 5 * 5)
print(150 / 140)
print(10*(6+19))
print(5**5) #aysinqn 5i 5 astichan
print(8**(1/3))
print(20%6)
print(10//4)
print(20%6) #cuyca talis vor 20 bajanes 6 taki ostatken inchqana mnalu
while True:
x = input("num1 ")
y = input('num2 ')
if x.isdigit() and y.isdi... |
d485457c2776b4be63e235ed34f2c3e743303772 | kgrozis/netconf | /bin/2.12 Sanitizing and Cleaning Up Text.py | 1,750 | 4.09375 | 4 | '''
Title - 2.12. Want to clean up unicode text
Problem - Want to strip unwanted chars, from beginning, end or middle of a text string
Solution - Use basic string functions: str.upper(), str.lower() or simple replacements
str.replace(), or re.sub(), or normalize text with unicodedata.normalize(),
... |
33449d28e999a6522e6631256f756ec4aeae425c | Brittany1908/DCAScraper | /printAllText.py | 673 | 3.578125 | 4 | '''
Program Name: DCA Scraper
Created: March 12, 2017
Modified: March 16, 2017
Purpose: Obtain information from websites, then parse the
information.
'''
#-----------------------------------------------------------
''' Import urllib and BeautifulSoup 4 for obtaining
website info and then parsing'''
import urllib.requ... |
3c17450bf526323321f2b9a401c2be7953a27651 | lucasgr7/PythonChallenge | /source/tests/test_models.py | 7,160 | 3.6875 | 4 | '''
Module for tests in the algorithm in the Python Challenge
'''
import os.path
import sys
sys.path.append(os.path.join(os.path.dirname(os.path.realpath(__file__)), os.pardir))
import unittest
from models import Board, Piece, Position
class TestModels(unittest.TestCase):
'''Unit test classes'''
def test_push... |
866a0d6cfa973ca864ae83fcba1c0f5b2145304c | SoyabulIslamLincoln/Home-Practice | /if else.py | 962 | 3.828125 | 4 | Python 3.7.0 (v3.7.0:1bf9cc5093, Jun 27 2018, 04:59:51) [MSC v.1914 64 bit (AMD64)] on win32
Type "copyright", "credits" or "license()" for more information.
>>> amount=int(input("enter amount: "))
enter amount: 56
>>> if amount<1000:
discount=amount*0.05
print("discount=",discount)
discount= 2.8000000000... |
9645097ade88229932a07db219ea7d129a521e6e | fras2560/InducedSubgraph | /inducer/dcolor.py | 7,744 | 3.75 | 4 | """
-------------------------------------------------------
dcolor
a module to determine the chromatic number of a graph
-------------------------------------------------------
Author: Dallas Fraser
ID: 110242560
Email: fras2560@mylaurier.ca
Version: 2014-09-17
--------------------------------------------------... |
11c4acc8297cbfa0ca420d67c51fe2924d1914bf | patrick-replogle/cs-module-project-hash-tables | /applications/sumdiff/sumdiff.py | 647 | 3.5 | 4 | """
find all a, b, c, d in q such that
f(a) + f(b) = f(c) - f(d)
"""
# q = set(range(1, 10))
# q = set(range(1, 200))
q = (1, 3, 4, 7, 12)
def f(x):
return x * 4 + 6
def sum_diff(nums):
add_table = {}
minus_table = {}
for i in q:
for j in q:
add_table[(i, j)] = f(i) + f(j)
... |
b6bacdcad706d98c1af15c621afa4cff8184ca33 | vinija/LeetCode | /348-design-tic-tac-toe/348-design-tic-tac-toe.py | 875 | 3.8125 | 4 | class TicTacToe:
def __init__(self, n: int):
self.n = n
self.rows = [0] * n
self.cols = [0] * n
self.diagonal = 0
self.anti_diagonal = 0
def move(self, row: int, col: int, player: int) -> int:
p = 1 if player == 1 else -1
#make the move
... |
54b939dc2d6ebd01df6c3f4fb1f35250dba4a0cd | jonovate/sizesorter | /sizesorter/sizechart.py | 17,196 | 3.6875 | 4 | """
Structure of size charts and values
"""
from collections import namedtuple
from copy import deepcopy
from numbers import Number
from .size import Size
"""
Represents the defined Dynamic Values.
base_suffix: The suffix of the dynamic size, which must exist in the accompanying size chart
so... |
709de418761787427ea8938045bac12ea997b41e | IsaDuong/Lab-7 | /Python Lab 7.py | 558 | 3.734375 | 4 | x = 1
while (x<300):
print x
x = x + 2
myList = [8,45,60,15,30,75,85,50,20,5]
index = 0
while (index < len(myList)):
print myList[index]
index = index + 1
import random
rand = random.randint(0,50)
userInput = raw_input()
print "Guess a number between 0-50"
while (userInput != rand):
userIn... |
1ac53e6fc8ebe35a7e6275aeac27b41a20201517 | rloulizi42/Labyrinthe | /labyrinthe.py | 3,966 | 3.671875 | 4 | #!/usr/bin/python3.4
import os
import curses
import sys
from tkinter import *
level = [
"+------------------+",
"| | |",
"| + | + |",
"| | +----+ | |",
"| | | | |",
"| | +--+ |",
"| +---+ ------+ |",
... |
b1429474bbc0b8714a8b208a9afd280e1fd0281a | franciscoquinones/Python | /clase4/clase/ope.py | 455 | 3.703125 | 4 | # -*- coding: utf-8 -*-
"""
Created on Sat Dec 17 18:28:13 2016
@author: Josue
"""
import texto
class Ope(object):#Heredamos la clase primaria de python
def __init__(self,num1,num2):
self.num1=num1
self.num2=num2
print "Operacion"
def suma(self):
print self.num1+sel... |
38ff2cbdca2f03b7b35806b222649ac9e49ff0df | UCLeuvenLimburg/vpw | /cat2/solitaire/python/fvogels.py3 | 1,659 | 3.703125 | 4 | from array import array
def solve(ns):
leftmost = float('Inf')
length = len(ns)
indices = list(range(length))
visited = set()
def jump_left(n, i):
if i > 1 and ns[i] and ns[i-1] and not ns[i-2]:
ns[i] = False
ns[i-1] = False
ns[i-2] = True
... |
4ceea84a5b3d635fb260113a53ef8193d88f2f25 | DaniilStepanov2000/SpellChecker | /check_sentence.py | 2,845 | 4.0625 | 4 | def get_dictionary() -> list:
"""Write words from dictionary to list
Args:
None.
Returns:
List of words that contains dictionary.txt.
"""
dictionary = []
with open('data/dictionary.txt', 'r', encoding='utf-8') as file:
for line in file:
dictionary.append(lin... |
62e70f294b29fdecdeb1727a7a63cc122a3e71d9 | d-dodd/hangman | /hangman.py | 10,158 | 3.625 | 4 | import random
import re
import sys
import fileinput
words_file = open("spelling_words.txt", encoding="utf-8")
words = words_file.read()
words_list = re.findall(r'\w+', words)
with open("player_scores.txt") as f:
lines = f.readlines()
lines = [x.strip() for x in lines]
print("Welcome to hangman!")
print("Y... |
ce75870cddce5c7058168fd0cf608b59dcb7587d | Archishman-Ghosh/OOP-Problem-Aganitha | /Q2.py | 3,120 | 3.796875 | 4 | class X:
def __init__(self, name):
self.name = name
def execute(self, dic):
for key, value in dic.items():
print(key,value)
def shutdown():
pass
class A:
def __init__(self, name):
self.obj = X(name)
print("Class A object created.")... |
04d534cfbd2f7e16594eeb0e75580370c394b80d | sictiru/NewsBlur | /apps/analyzer/tokenizer.py | 775 | 4.09375 | 4 | import re
class Tokenizer:
"""A simple regex-based whitespace tokenizer.
It expects a string and can return all tokens lower-cased
or in their existing case.
"""
WORD_RE = re.compile('[^a-zA-Z-]+')
def __init__(self, phrases, lower=False):
self.phrases = phrases
self.lower... |
3c425f5a60daf4156df31550f1bda378dd2ecc04 | PrimeNumber012357/Fun-with-games-and-shapes | /fibonacci_userinput.py | 1,233 | 4.40625 | 4 | def fibonacci():
#Create i to keep looping through until the input is valid
i = 0
while i < 1:
try:
#Get user input
n = input("Enter the nth term in the Fibonacci sequence that you want to know: ")
user_input = int(n)
seed1 = 0
seed2 = 1
... |
c2c4976ca61e8583e0b9a7eb2bdb6813e37860e1 | ferryleaf/GitPythonPrgms | /arrays/reverse_array_groups.py | 2,495 | 4.3125 | 4 | '''
Given an array arr[] of positive integers of size N. Reverse every sub-array
group of size K.
Example 1:
Input:
N = 5, K = 3
arr[] = {1,2,3,4,5}
Output: 3 2 1 5 4
Explanation: First group consists of elements
1, 2, 3. Second group consists of 4,5.
Example 2:
Input:
N = 4, K = 3
arr[] = {5,6,8,9}
Output: 8 6 5 9... |
0d75c002bae0036d5b5925e66cf80edab959645e | tarampararam/python | /sber/basic/stairway.py | 191 | 4 | 4 | while (True):
n = int(input("Enter a number: "))
if (n > 9):
print("enter a lower number")
else:
break
for x in range(1, n + 1):
for y in range(1, x + 1):
print(y, end='')
print()
|
823594b67ff7e809c4aae07dbd68f98261ef0b35 | tylerneylon/knuth-taocp | /alg_b.py | 2,993 | 4.15625 | 4 | from collections import defaultdict
def pass_(*args):
pass
def algorithm_b(x, D, is_good, update=pass_, downdate=pass_, ell=0):
""" This is the basic backtrack algorithm from section 7.2.2.
x is a list whose values will be changed as this iterates; x will be the
list yielded when valid soluti... |
13e5e39e650128beacc15aadd23027d7600c3c03 | mcdyl1/Projects | /441/part2.py | 950 | 3.875 | 4 | import random
import math
import sympy
import time
def pollard_Rho(n):
i = 1
xi = random.randint(0, n-1)
y = xi
k = 2
d = 1
while d == 1:
i = i + 1
xi = (pow(xi, 2) - 1) % n #(xi**2 - 1) % n
d = math.gcd(y - xi, n)
if d != 1 and d != n:
return d
... |
7d9eba4675b0d77cd2c6dfd858cac3ea71bd4fb0 | ulink-college/code-dump | /challenge_booklet_1/solutions/challenge-1.13.py | 159 | 3.578125 | 4 | ###################################
#
# 1.13
#
#
import time, random
for i in range(10):
print(i, random.randint(0,100))
time.sleep(3)
i =+1
|
62fc488566c5813818a1b2d720e454a14b4128c8 | EderVs/IS-laboratorio-2020-2 | /Alumnos/MartinezMonroyEmily/decorator_example.py | 393 | 3.53125 | 4 | """
Practica 2: Decorador
Ingenieria de Software
Emily Martinez Monroy
"""
"""
Funcion Decorador
"""
def my_decorador(f):
def new_function(*args, **kwargs):
print("Before Function")
f(*args, **kwargs)
print("After Function")
return new_function
"""
Funcion para ejemplificar el decorado... |
7be6246e5edf3c81fb27edc9900302ca5e594568 | 141sksk/practice | /yukicoder/138.py | 325 | 3.625 | 4 | def main():
a = list(map(int, input().split('.')))
b = list(map(int, input().split('.')))
for i in range(3):
if a[i] > b[i]:
print("YES")
break
elif a[i] < b[i]:
print("NO")
break
else:
print("YES")
if __name__ == "__main__":
m... |
e4474b98f8a376b7fae2e33e614f0ef37b5fa1e5 | astral-sh/ruff | /crates/ruff/resources/test/fixtures/pycodestyle/E731.py | 1,919 | 3.75 | 4 | def scope():
# E731
f = lambda x: 2 * x
def scope():
# E731
f = lambda x: 2 * x
def scope():
# E731
while False:
this = lambda y, z: 2 * x
def scope():
# E731
f = lambda: (yield 1)
def scope():
# E731
f = lambda: (yield from g())
def scope():
# OK
f = ob... |
c4de231f2fef58d2687dae8f4bdcebc9538f999f | Seanmusse/todolistclipy | /todolistoldworking.py | 1,141 | 3.625 | 4 | import pickle
import os
os.system("clear")
print("-------------------------------Todo-list CLI application-------------------------------")
def space():
print(" ")
print(" ")
print(" ")
print(" ")
space()
userlist = []
filename = "userdata.p"
def maininput():
loaded_uinput = []
while True:
... |
d55c0d4405652ac1f2ed70633b6be06fce3aa223 | skuxy/Advent-Of-Code-codes | /2019/day2.py | 2,261 | 3.84375 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Second day of 2019 AoC
"""
OPCODE_MAP = {
1: lambda a, b: a + b,
2: lambda a, b: a * b
}
class ShipComputer:
"""
Representing our ships computer
For I'm lazy
"""
def __init__(self, intcode):
self.intcode = intcode
self.posi... |
cd21310eac2cd0fe76aeb4b9d80cc80266e3c3c3 | gaoyan0629/IVY | /devl/closure.py | 878 | 4.0625 | 4 | # When to use closures?
# So what are closures good for?
# Closures can avoid the use of global values and provides some form of data hiding. It can also provide an object oriented solution to the problem.
# When there are few methods (one method in most cases) to be implemented in a class, closures can provide an alt... |
8208c8da0a016ed8f8e9c28db74fcb058968fedd | sunilnandihalli/leetcode | /editor/en/[801]Minimum Swaps To Make Sequences Increasing.py | 1,503 | 3.984375 | 4 | # We have two integer sequences A and B of the same non-zero length.
#
# We are allowed to swap elements A[i] and B[i]. Note that both elements are in
# the same index position in their respective sequences.
#
# At the end of some number of swaps, A and B are both strictly increasing. (A
# sequence is strictly ... |
bf84f2bd0d0479721a294192a92ecbf61e7cf318 | SL-PROGRAM/Mooc | /UPYLAB3-12.py | 428 | 3.75 | 4 | """Auteur: Simon LEYRAL
Date : Octobre 2017
Enoncรฉ
Cet exercice propose une variante de lโexercice prรฉcรฉdent sur le carrรฉ de X.
รcrire un programme qui lit sur input une valeur naturelle n et qui affiche ร lโรฉcran un triangle supรฉrieur
droit formรฉ de X (voir exemples plus bas).
"""
n = int(input())
for i ... |
af1f283ad1ae37cd5b2185578268fbb5ab35f79f | agiang96/CS550 | /CS550Assignment2/problemsearch.py | 4,295 | 3.71875 | 4 | '''
Created on Feb 10, 2018
file: problemsearch.py
@author: mroch
'''
from basicsearch_lib02.searchrep import (Node, print_nodes)
from basicsearch_lib02.queues import PriorityQueue
from explored import Explored
from searchstrategies import (BreadthFirst, DepthFirst, Manhattan)
import time
def graph_search(... |
a594ae1b90a738615ba823a49ab87236fb912a96 | JakeMartin99/LearningML | /kerasCNN.py | 1,774 | 3.53125 | 4 | # Sourced from the blog at https://victorzhou.com/blog/keras-cnn-tutorial/
import os
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3' # Don't print verbose info msgs
import numpy as np
import mnist
import keras
from keras.models import Sequential
from keras.layers import Conv2D, MaxPooling2D, Dense, Flatten, Dropout
from kera... |
0bdd36991ac1f08d378eedc0445fb2e391c2f1a1 | siyaoc2/Final-Project | /siyaoc2_final_project_PE02(from Chapter 9).py | 1,825 | 4.125 | 4 | from random import random
def main():
printIntro()
probA, probB, n = getInputs()
winsA, winsB = simNGames(n, probA, probB)
printSummary(winsA, winsB)
def printIntro():
print("This program simulates a game of volleyball between two")
print('players called "A" and "B". The ability of each player... |
f33d94f70dfad6cf4daffbfef26020065b1251c7 | Jacrabel/Coding-in-Python | /day-3-2-exercise/main.py | 545 | 4.28125 | 4 | # ๐จ Don't change the code below ๐
height = float(input("enter your height in m: "))
weight = float(input("enter your weight in kg: "))
# ๐จ Don't change the code above ๐
#Write your code below this line ๐
BMI = round(weight / (height ** 2))
print (BMI)
if BMI <18.5:
print(f"Your bmi is {BMI},they are underweigh... |
93677132a5291c9674130d6c279051c181452f36 | suwhisper/Solutions-for-Think-Python-2e | /chapter_5/is_triangle.py | 309 | 4.25 | 4 | def is_triangle():
"""shows whether you can or cannot form a triangle from sticks with the given lengths.
"""
a = int(input("Please input a: "))
b = int(input("Please input b: "))
c = int(input("Please input c: "))
if a < b + c and b < a+c and c<a+b:
print("Yes")
else:
print("No")
is_triangle()
|
d8cd1c7df7a689263edc43331814d17fe5c993e3 | GordonDoo/scikit-learn_MLPClassifier_with_dropout_py37 | /examples/neighbors/plot_approximate_nearest_neighbors_hyperparameters.py | 5,141 | 3.734375 | 4 | """
=================================================
Hyper-parameters of Approximate Nearest Neighbors
=================================================
This example demonstrates the behaviour of the
accuracy of the nearest neighbor queries of Locality Sensitive Hashing
Forest as the number of candidates and the numb... |
107ce214b3a0649e27a0e5503038fb3dc5aa71c7 | Tim6FTN/wash-lang-prototype | /wash_lang_prototype/core/common.py | 1,547 | 3.84375 | 4 | from __future__ import annotations
from abc import ABC, abstractmethod
from typing import Any
class Handler(ABC):
"""
Represents an interface that declares a method for building a chain of handlers,
otherwise known as the chain of responsibility pattern.
It also declares a method for executing a requ... |
ae1daca0280747434de635fa84443bc3d2bbd977 | hoanbka/Algorithm-Python | /DFS/generateParenthesis.py | 532 | 3.65625 | 4 | class Solution(object):
def generateParenthesis(self,n):
list = []
self.backtrack(list, "", 0, 0, n)
return list
def backtrack(self,list, str, open, close, max):
if (len(str) == max * 2):
list.append(str)
return
if (open < max):
self... |
11b40b955122878caf0f2714f996da07b66b7962 | Kawser-nerd/CLCDSA | /Source Codes/AtCoder/abc032/A/4825210.py | 134 | 3.5 | 4 | a = int(input())
b = int(input())
n = int(input())
while True:
if n%a==0 and n%b==0:
break
n = n+1
print(n) |
147092e83c3827a8e2defb41994f482e130d45c4 | GISmd/snaddersim | /runsim.py | 1,370 | 3.90625 | 4 | # -*- coding: utf-8 -*-
"""
Created on Sat Jan 27 11:38:47 2018
@author: smmcdeid
Our snakes and ladders simulator
"""
import random
import pandas
board = [[4,35],[8,47],[20,55],[23,5],[31,85],[33,9],[40,62],[44,15],[60,21],
[63,82],[68,36],[72,90],[89,56],[91,70],[94,11],[96,81],[83,43]]
def rolldice()... |
910aa7ced9fff06be32a52c0200f80d17c29a55a | gmyrak/py_tests | /help.py | 292 | 3.703125 | 4 | from turtle import *
def tree ( levels, length ):
if levels > 0:
forward ( length )
left ( 45 )
tree ( levels-1, length*0.6)
right ( 90 )
tree ( levels-1, length*0.6)
left ( 45 )
backward ( length )
setheading ( 90 )
tree ( 5, 100 ) |
ea0add6258be2fca7912c4476c039aae71f76c5d | supratikn/Dijkstra | /Dijkstra.py | 1,417 | 3.84375 | 4 | '''
Created on Jan 30, 2018
@author: sneupane
'''
from builtins import str
graph = {'a':{'b':10,'c':3},'b':{'c':1,'d':2},'c':{'b':4,'d':8,'e':2},'d':{'e':7},'e':{'d':9}}
def dijkstra(graph, start, goal):
shortestDistance ={}
predecessor={}
unseenNodes=graph
infinity = 9999
path=[]
for n... |
24cc3693beba06ed5a2ebc600da998e51b9b3934 | daisuke1230/weekday-search | /weekday-search.py | 329 | 3.90625 | 4 | import datetime
print('start year')
y_i=input()
print('end year')
y_f=input()
print('day')
d=input()
print('weekday')
wd=input()
for y in range(int(y_i),int(y_f)):
for m in range(1,13):
D = datetime.date(y,m,int(d))
if D.weekday() == int(wd)-1:
print(D.strftime("%Y%m%d"))
... |
be190048ea3571d180b99e152d4a496309c9b21f | vivianLL/LeetCode | /172_FactorialTrailingZeroes.py | 1,634 | 3.890625 | 4 | '''
172. Factorial Trailing Zeroes
Easy
https://leetcode.com/problems/factorial-trailing-zeroes/
Given an integer n, return the number of trailing zeroes in n!.
'''
import math
class Solution:
def trailingZeroes(self, n: int) -> int:
# # ๆดๅๆฑ้ถไนๆณ ่ถ
ๆถ
# num = 1
# for i in range(2,n+... |
6dfb18fb594642ceb8f3fb2f548abb86ea64f8a2 | SirAeroWN/ComputerScience | /101/November/Checkerboard.py | 539 | 3.59375 | 4 | from tkinter import *
class Board:
def __init__(self):
self.window = Tk()
self.window.geometry("195x195")
self.size = 160
for i in range(0,8):
for j in range(0,8):
if(i + j) % 2 == 0:
self.canvas = Canvas(self.window, bg = "white", width = self.size/8, height = self.size/8)
self.... |
aa53ebfb8240f6ac9c988e0aa216311bf8e1bb85 | dragos-vacariu/Python-Exercises | /Advanced Practice/program1 sorting list and functors.py | 2,429 | 4.25 | 4 | #Creating a Functor class
class Functor:
#Dunder functions are pre-defined functions which have __ (underscore) as prefix and surfix. Example: __init__()
def __init__(self, word):
self.word = word
#A class became a functor if this function __call___ gets overwritten/defined.
def __call__(self)... |
8fd276d4f9fcd5dbdd38cdcb4504b1c2c1e3317f | benjamesian/holbertonschool-higher_level_programming | /0x06-python-classes/1-square.py | 199 | 3.59375 | 4 | #!/usr/bin/python3
"""Square with size
"""
class Square:
"""Square class
"""
def __init__(self, size):
"""Initialize a Square with a size
"""
self.__size = size
|
f132b6a130e62343f68cacdab008fe67320142c4 | Ben-Donaldson/Python | /input.py | 127 | 4.21875 | 4 | name = input("Hi! What is your name?")
age = input("How old are you?")
print("Hi " + name + "! You are " + age + " years old.") |
2ab635854ee9ed9b1f1d93cafb5c61846f2a5d20 | gabriellaec/desoft-analise-exercicios | /backup/user_195/ch49_2019_03_19_19_32_05_441019.py | 208 | 3.8125 | 4 | numero=int(input("Diga um nรบmero inteiro"))
i=1
L=[numero]
while numero>0:
L[i-1]=numero
numero=int(input("Diga outro nรบmero inteiro"))
i+=1
L.append(0)
L.remove(0)
L.reverse()
print(L) |
7d33305ce35d05ef6c35fbe462dee9de5b367bdf | kotsky/programming-exercises | /Dynamic Programming/Square Of Zeroes.py | 10,573 | 4.125 | 4 | '''
Return True or False if there is a Zero Square (which is created only from "0" as bounder and more or equal than 2x2 size)
in the given matrix.
matrix = [
[1, 1, 1, 0, 1, 0],
[0, 0, 0, 0, 0, 0],
[0, 1, 1, 1, 0, 1],
[0, 0, 0, 1, 0, 1],
[0, 1, 1, 1, 0, 1],... |
6f8236f21701d26a8b7195d2c32fa0f32536a638 | soham2109/python-programming-basics | /InsertionSort.py | 180 | 3.625 | 4 | def InsertionSort(seq):
for sliceEnd in range(len(seq)):
pos = sliceEnd
while pos>0 and seq[pos]<seq[pos-1]:
(seq[pos-1],seq[pos])=(seq[pos],seq[pos-1])
pos = pos-1 |
ee2a1b3aef2b2eb228dba3e21f4cfb7794a51161 | XPerezX/Atv_teste1 | /Manuel e Fernando Calza Correรงรฃo de Erros.py | 10,784 | 4.1875 | 4 | class funcionario():
__instance = None
def __init__(self, nome, salario, cargo, mestrab):
self.nome = nome
self.salario = salario
self.cargo = cargo
self.mestrab = mestrab
def print_nome(self):
print(self.nome)
def print_cargo(self):
print(self.cargo)... |
1b0a61a773ccca07e8b7bf9311f8d908255dd947 | caiquemarinho/python-course | /exploring_ranges.py | 552 | 4.5625 | 5 | """
Ranges
- We need to know loops to use the range.
- We need to understand range to better work with for loops.
Ranges are used to generate numeric sequences, not in a random way, but in a specific way.
range(stop_value)
PS: The stop value is not included, default starting at 0, and incrementing 1.
"""
# Fir... |
7675a14662a3288f3cb59bf103c392757e53b4ec | dr-dos-ok/Code_Jam_Webscraper | /solutions_python/Problem_2/310.py | 4,770 | 3.734375 | 4 | #!/usr/bin/env python
# using datetime module to make the arithmetic of arrival/departure times
# and turnaround times easy.
import datetime
class CTrain:
def __init__(self, tm):
self.time = tm # Time of arrival or departure
self.scheduled = False # if the train has already been schedu... |
33b4579b9b90053037ff840cfb87d25c1dbbbd57 | optionalg/challenges-leetcode-interesting | /hamming-distance/test.py | 1,046 | 3.859375 | 4 | #!/usr/bin/env python
##-------------------------------------------------------------------
## @copyright 2017 brain.dennyzhang.com
## Licensed under MIT
## https://www.dennyzhang.com/wp-content/mit_license.txt
##
## File: test.py
## Author : Denny <http://brain.dennyzhang.com/contact>
## Tags:
## Description:
## ... |
e6baccd13c53bf8405c05d9a5791f67d793e83e4 | tanu312000/pyChapter | /org/netsetos/python/queue/levelorder.py | 1,952 | 3.9375 | 4 | class Node:
def __init__(self, data):
self.data = data
self.next = None
class Queue:
def __init__(self):
self.front = None
self.rear = None
def enqueue(self, data):
if (self.rear == None):
self.rear = Node(data)
self.front = self.rear
... |
cad531621fbd56587fa5ea88023a84bcf74529e3 | nailanawshaba/workshopPythonTDD | /fizzbuzzwoof/fizzbuzz.py | 485 | 3.5625 | 4 | class FizzBuzz(object):
def __init__(self):
self.rules = {3: 'fizz',
5: 'buzz',
7: 'woof',
}
def generate(self, number):
output = ''
for key, value in self.rules.iteritems():
if number % key == 0:
... |
72ff7f80e2c2bca1eb7f6b1ea1e5f9268ab9c1da | rivcah/line_by_line | /strings.py | 2,093 | 4.6875 | 5 | ## This is a function that takes the user's input and counts how many lower or
##upper case letters, integer numbers and other type of characters there are
##in your input. It's a good way for working with conditional statements and
##for loops.
def string_counter(urinput):
count_lower = 0
count_upper = 0
count_n... |
c15bee55369f7b58d4fe13b6f822880800176b9e | mustafasisik/mstfssk | /indexationOfWords.py | 748 | 3.90625 | 4 | from sys import argv
fileName = argv[1]
word = argv[2]
fileText = open(fileName, "r").read()
def indexation(text, word):
d = {}
sentenceList = text.split(".")
index = 0
for sentence in sentenceList:
wordBefore1 = ""
wordBefore2 = ""
for w in sentence.split():
if not... |
e7fab90055edab4ca5c5b46cce0630b5b2876fba | vineetmidha/Online-Challenges | /Displacement.py | 484 | 3.671875 | 4 | https://www.hackerrank.com/contests/all-india-contest-by-mission-helix-a-11th-july/challenges/easy-2-cc/problem
def get_answer(t, x):
return t * 60 * x // 2
tests = int(input())
for _ in range(tests):
t, x = map(int, input().split())
print(get_answer(t, x))
'''
Explanation:
Tot... |
37aaa5cf410aef35cc02b8d6467207c907611a5d | sachinjangid/myAlgos | /myAlgos/search-a-number.py | 576 | 3.84375 | 4 | #User function Template for python3
def searchNumber(arr,n, number):
index = -1
for i in range(n):
if (arr[i] == number):
index =i
break
if (index > -1):
print(index+1)
else:
print(index)
if __name__ == '__main__':
t=int(input())
for _ in range(t):
... |
90f87930b39acd99ea8cf283cf97526e973bfbe4 | ian-garrett/CIS_211 | /211_projects/Week_7/fp.py | 888 | 3.53125 | 4 | """
fp.py: CIS 211 assignment 7, Spring 2014
author: Ian Garrett, igarrett@uoregon.edu
a collection of five functions that utilize functional programming
"""
#1
def codes(x):
return list(map(ord, x))
#2
def vowels(x):
vowels = ['a','e','i','o','u','A','E','I','O','U']
go_do = lambda t: t if t in vowels else ""
... |
68f9c11e2e3e5e5f664753cb26b22f275057411f | billgoo/LeetCode_Solution | /Related Topics/Hash Table/202. Happy Number.py | 471 | 3.53125 | 4 | class Solution:
def isHappy(self, n: int) -> bool:
def sum_happy(x):
ans = 0
while x > 0:
ans += (x % 10) ** 2
x //= 10
return ans
s = {n}
while n != 1:
n = sum_happy(n)
... |
940c6b16b6fc87626052ad1200d53044e8172611 | GallantRage/Web-Scraping | /scraping_project.py | 2,069 | 3.546875 | 4 | # http://quotes.toscrape.com
import requests
from bs4 import BeautifulSoup
from random import choice
response = requests.get("http://quotes.toscrape.com")
soup = BeautifulSoup(response.text, "html.parser")
quotes = soup.find_all(class_="quote")
data = []
for quote in quotes:
q = quote.find(class_="text").get_text()
... |
bcaf059665eb81d0e0992a01ec3f1cb51704a9a4 | LeytonYu/python_algorithm | /sword art online/ๅพ/ๆทฑๅบฆไผๅ
้ๅ.py | 375 | 3.515625 | 4 | def dfs(G,s,S=None,res=None):
if S is None:
S=set()
if res is None:
res=[]
S.add(s)
res.append(s)
for i in G[s]:
if i in S:
continue
S.add(i)
dfs(G,i,S,res)
return res
G = {'0': ['1', '2'],
'1': ['2', '3'],
'2': ['3', '5'],
'3':... |
853c6f2b6b1f0022da9b19de44768c601de69e30 | jayhebe/w3resource_exercises | /List/ex35.py | 363 | 3.65625 | 4 | from itertools import product
def concatenate(lst1, n):
# return [x[0] + str(x[1]) for x in sorted(list(product(lst1, list(range(1, n + 1)))), key=lambda t: t[1])]
result = []
for i in range(1, n + 1):
for j in lst1:
result.append(j + str(i))
return result
if __name__ == '__main... |
14c20cd25a2e81e0b5d24c5011f6a55649dd242c | ernestojfcosta/IPRP_LIVRO_2013_06 | /objectos_2/programas/listas_comp.py | 782 | 3.65625 | 4 | def aplana(lista):
"""Transforma uma lista de lista numa lista simples."""
res = []
for lst in lista:
for elem in lst:
res.append(elem)
return res
def aplana_lc(lista):
"""Transforma uma lista de lista numa lista simples."""
res = [val for elem in lista for val in elem]
... |
09ca6115d0647c012fde3340627c425f2114b4e5 | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/python/bob/fd6add469f2c4cc8b82eaeb41fdf715a.py | 638 | 3.640625 | 4 | class Bob:
def hey(self, msg):
"""Bob's response to a given message."""
response = "Whatever."
if shouting(msg):
response = "Woah, chill out!"
elif question(msg):
response = "Sure."
elif saying_nothing(msg):
response = "Fine. Be that way!"... |
e90b53584351024364517b5cbf9cfd678f80f021 | RamachandiranVijayalakshmi/Condition-Check | /condition.py | 281 | 3.8125 | 4 | def cond(a,b,c):
if a>b and a>c:
print('a greater number')
elif b>a and b>c:
print('b greater number')
elif c>a and c>a:
print('c greater number')
else:
print('ture condion not in the code')
d,e,f=45,23,22
cond(d,e,f)
|
f53b4c73523367b38a41336c69721ff86e131a0b | shovalsolo/PythonWebDriver | /PythonWebDriver/MicrosoftBasic/022_create_json_with_nested_dictionary.py | 1,622 | 4 | 4 | # This is an example of how to convert a dictionary to a json format
import requests
import json
import pprint
person_dictionary = {'first':'Chris' , 'last':'Zo'} #creating a dictionary
person_dictionary ['city'] = 'Orlando' #adding a new key and value to the di... |
c008b4fa487eb11c74e9cf114dea2404a8c598f1 | The-Marauder/Tic-tac-tao | /Tictactoe.py | 2,938 | 3.671875 | 4 | from tkinter import *
import tkinter
import tkinter.messagebox as msg
root = Tk()
root.title("Tic Tac Toe")
Label(root , text="Player 1 : X", font='Comic 22').grid(row=0,column=1)
Label(root , text="Player 2 : O", font='Comic 22').grid(row=0,column=3)
digits =[1,2,3,4,5,6,7,8,9]
count = 0
panels = ["panel"]*10
sign... |
eb267484a2fc18fc34c8070fcb959bd351b42743 | hzhu3142/CardGame | /User_interface.py | 2,381 | 3.828125 | 4 | from blackJack import *
# setup the player's chips
player_chips = Chips()
while True:
# Print an opening statement
print('\nWelcome to Balck Jack! Get as close to 21 as you can without going over! \n',
'Dealer hits until she reaches 17. Aces count as 1 or 11.')
# Create & shuffle the deck, deal ... |
ad32af83277d64c6a29673054d3bc73c953989f2 | habiba2012/python-tutorial | /pythontut5.py | 6,190 | 3.96875 | 4 | # functions
"""
def add_numbers(num1, num2):
return num1 + num2
print("5 + 4 = ", add_numbers(5,4))
def assign_name():
name = "Doug"
print("Name is : ", assign_name())
def change_name():
#name = "Mark"
#return "Mark"
global gbl_name
gbl_name = "Sammy"
#name = "Tom"
#name = change_name(na... |
4d08b51035721202cdd0d7fb362d8ea644ca4a66 | almas06/SecondYear-ComputerEngineering-LabAssignments-SPPU | /DSA Programs/GroupA_Assignment-4.py | 5,249 | 4.03125 | 4 | #Creating 2 sets using inbuilt set method
myset1 = set()
myset2 = set()
#*****************************************************************************************************************8
def AddElement():
set_no = int(input("\nEnter set no. in which you want to insert(1/2): "))
num = int(input("\nEnter number... |
623292f97ed4525b3c6cc8e870215710232ec681 | darwinini/practice | /python/loops.py | 436 | 4.0625 | 4 | """
for i in [0, 1, 2, 3, 4, 5]:
print(i)
#range(n) get me a range of n numbers
for i in range(6):
print(i)
number = 0;
while number > 8:
print(f"Thank you Lord for day {number}")
num = 0
while num < 8:
print(f"The number is: {num}")
num += 1
"""
name = "Darwin"
for char in name:
print(ch... |
2211f35872fb8046468686404f3bf8bd4096d3d5 | Jyotiswaruptripathy/jyoti123 | /prob2.py | 192 | 4.09375 | 4 | n=int(input('enter the no. of integer u want to add:'))
sum=0
for k in range (0,n):
k=int(input('enter the no.: '))
sum=sum+k
print('the sum of digit is = ',sum)
|
87f908d8e18b56beb22dca7da315046e86c6d0b9 | jiyoung-dev/python-algorithm-interview | /ch7_list/L15_์ธ์์ํฉ.py | 1,900 | 3.546875 | 4 | '''
๋ฐฐ์ด์ ์
๋ ฅ๋ฐ์ ํฉ์ผ๋ก 0์ ๋ง๋ค ์ ์๋ 3๊ฐ์ ์๋ฆฌ๋จผํธ๋ฅผ ์ถ๋ ฅํ๋ผ.
nums = [-1, 0, 1, 2, -1, -4]
[
[-1, 0, 1].
[-1, -1, 2]
]
'''
# ํฌํฌ์ธํฐ๋ก ํ์ด
from typing import List
class Solution:
def threeSum(self, nums: List[int]) -> List[List[int]]:
results = []
nums.sort() # ์
๋ ฅ๋ ๋ฐฐ์ด์ ์ ๋ ฌ (ํฌํฌ์ธํฐ ๋ฌธ์ ํ์ด๋ฅผ ์ํ)
for i in range(... |
dc43a072d932e0cb503bb983fe74f8f0f7df3208 | rrwt/daily-coding-challenge | /ctci/ch2/intersection.py | 3,122 | 4.15625 | 4 | """
Given two (singly) linked lists, determine if the two lists intersect.
Return the intersecting node. Note that the intersection is defined based
on reference, not value. That is, if the kth node of the first linked list
is the exact same node (by reference) as the jth node of the second linked
list, then they are i... |
efee73d5b254780e7536a4dc67b87c189aecfca5 | JeeZeh/kattis.py | /Solutions/pet.py | 232 | 3.59375 | 4 | scores = []
biggest = 0
index = 0
for i in range(0, 5):
points = eval(input().replace(" ", "+"))
scores.append(points)
if points > biggest:
biggest = points
index = i
print("%d %d" % (index+1, biggest)) |
2f5e988b7a85b111b1dbfaa2c319deba422dbfdb | janeon/automatedLabHelper | /testFiles/match/match26.py | 1,561 | 3.828125 | 4 |
def main():
print()
print("Welcome to my protein matching program!")
goodInput = False
while not goodInput:
try:
print()
n=input("Which text file would me to use? ")
inputFile = open(n, "r")
p=inputFile.readlin... |
c4665be9a02620da1f0fc874fd129fe26f82008a | drboroojeni/Day-Counter-Drboroojeni | /dayCounter.py | 1,865 | 3.75 | 4 | #calculate the number of days between two dates
#checking whether year n is a leap year
def isLeap(n):
m = n % 400
if n%4 == 0 and m != 100 and m != 200 and m != 300:
return True
#counting the number of days from date m1/d1/y1 to date m2/d2/y2. Returns zero if dates are equal, negative if second d... |
ce75aaa2d0bf75e6c972d14c52430bcb1bceff54 | LucasHenriqueAbreu/introducaoprogramaca | /exercicio_dicionario4.py | 714 | 3.9375 | 4 | # 4. Crie um programa que gerencie o aproveitamento de um jogador de futebol.
# O programa vai ler o nome do jogador e quantas partidas ele jogou.
# Depois vai ler a quantidade de gols feitos em cada partida.
# No final, tudo isso serรก guardado em um dicionรกrio,
# incluindo o total de gols feitos durante o campeo... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.