blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
9a13823522c78e77945ed48d414fe458ede19f50
mcxu/code-sandbox
/PythonSandbox/src/misc/fizzbuzz.py
915
4.125
4
""" Write a program that prints the numbers from 1 to 100. But for multiples of three print "Fizz" instead of the number and for the multiples of five print "Buzz". For numbers which are multiples of both three and five print "FizzBuzz". """ class FB: @staticmethod def fizzBuzz1(): for i in range(1,1...
a585ac9848bd1026f4b138c675264d538aba7290
mcxu/code-sandbox
/PythonSandbox/src/leetcode/lc142_linked_list_cycle_ii.py
1,665
3.703125
4
''' 142. Linked List Cycle II [Medium] Given a linked list, return the node where the cycle begins. If there is no cycle, return null. To represent a cycle in the given linked list, we use an integer pos which represents the position (0-indexed) in the linked list where tail connects to. If pos is -1, then there is n...
c18ffdf60d338cce4b9cf9bbe09a640e623b478d
mcxu/code-sandbox
/PythonSandbox/src/leetcode/lc6_zigzag_string_conversion.py
1,580
3.71875
4
''' The string "PAYPALISHIRING" is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed font for better legibility) P A H N A P L S I I G Y I R And then read line by line: "PAHNAPLSIIGYIR" ''' class Solution: def convert(self, s: str, numRows...
fb4ba106741526837aeaac210235d651013a6f92
mcxu/code-sandbox
/PythonSandbox/src/misc/sorted_tuples.py
1,361
3.90625
4
''' L1: [(1,2), (3,9)] L2: [(4,6), (8,10), (11,12)] output: [(1,2), (3,10), (11,12)] ''' def mergeTuples(L1, L2): mergedTups = [] # merge tuples as is by their first values p1, p2 = 0, 0 while p1 < len(L1) and p2 < len(L2): tup1, tup2 = L1[p1], L2[p2] if tup1[0] <= tup2[0]: ...
382cf2492658e73d1b62527ae8389b86643b965c
mcxu/code-sandbox
/PythonSandbox/src/misc/smallest_diff_2_arrays.py
1,108
3.828125
4
""" Function that takes 2 arrays. Find a pair of numbers from the arrays (1 number from each array), whose absolute difference is closest to 0. Assume only there only exists 1 pair of smallest difference. Sample input: [-1, 5, 10, 20, 28, 3], [26, 134, 135, 15, 17] Sample output: [28, 26] """ class SD: @staticmet...
840c0802e94326689d51ec3ab395ccd4cdc7a194
mcxu/code-sandbox
/PythonSandbox/src/leetcode/lc1453_max_points_inside_dartboard.py
1,270
3.6875
4
''' https://leetcode.com/contest/weekly-contest-189/problems/maximum-number-of-darts-inside-of-a-circular-dartboard/ You have a very large square wall and a circular dartboard placed on the wall. You have been challenged to throw darts into the board blindfolded. Darts thrown at the wall are represented as an array o...
b01a7fa7890561688220b97075888df1245fbe20
mcxu/code-sandbox
/PythonSandbox/src/misc/coin_change_num_ways.py
5,829
3.90625
4
""" Given array of pos ints representing denominations, and a single non-negative int representing a target amount of money. Write function to return number of ways to make change for that target amount. Sample input: 6,[1,5] Sample output: 2 (1x1 + 1x5 and 6x1) """ class Prob: ''' Recursive, brute force. ...
c68a46f7a33ddad8ea9f29b8a8b6e9387e349a18
mcxu/code-sandbox
/PythonSandbox/src/leetcode/lc437_path_sum_3.py
4,430
3.859375
4
''' 437. You are given a binary tree in which each node contains an integer value. Find the number of paths that sum to a given value. The path does not need to start or end at the root or a leaf, but it must go downwards (traveling only from parent nodes to child nodes). The tree has no more than 1,000 nodes and the v...
74d45e4e2153b8a495b86587382b79a47de40657
mcxu/code-sandbox
/PythonSandbox/src/misc/floyd_cycle_detection_linked_list.py
3,442
3.90625
4
''' Floyd's Cycle Detection Algorithm (Tortoise and Hare Algorithm) Version 1: Given linked list, return true if cycle exists, false otherwise. Version 2: Given linked list, if cycle exists, break the cycle, then return the node value where the cycle begins. If the LL doesn't have a cycle, then return None ...
ae2cc80c779164b9831c7cef79a55e950c6c68a9
mcxu/code-sandbox
/PythonSandbox/src/misc/closest_value_in_bst.py
2,162
4
4
""" Find the closest value to a target in a Binary Search Tree """ import math from unittest import TestCase class BST: def __init__(self, value): self.value = value self.left = None self.right = None def insert(self, value): if value < self.value: if self.left is ...
9a1081007e37a9c455c4ade69415a8ee5d536490
mcxu/code-sandbox
/PythonSandbox/src/leetcode/lc70_climbing_stairs.py
1,557
4.03125
4
""" count down with memo Time complexity: O(n), n = number of stairs Space complexity: O(n) """ class Solution: def climbStairs(self, n: int) -> int: def helper(n, memo): if n < 0: return 0 if n == 0: return 1 if n in ...
3f55ded7fa4a270613ac669e530af2b4c8a81a2d
mcxu/code-sandbox
/PythonSandbox/src/misc/bt_left_side_view.py
2,192
4.34375
4
''' Print left side view of binary tree from root node. Ref: https://aonecode.com/amazon-interview-questions-software-engineer ''' class Node: def __init__(self, value): self.value = value self.left = None self.right= None class Prob: ''' Let d = tree depth, n = num of nodes in tree...
6f60dfca7eef2ca7a1e06ae9d73cb67271844615
mcxu/code-sandbox
/PythonSandbox/src/courses/ml_andrewng/ex1/exercise1.py
1,388
3.921875
4
""" Machine Learning Andrew Ng - Programming Exercise 1 """ import pandas as pd import os.path as path import matplotlib.pyplot as plt class Ex1: @staticmethod def readCSVData(filePath, pickleFile, colNames=[]): df = pd.read_csv(filePath, names=colNames) print(df.info()) print(df.head(...
e8a02d6ecc66fab3e2a723241e6337e0389a8ad3
mcxu/code-sandbox
/PythonSandbox/src/leetcode/lc2348_num_zero_filled_subarrays.py
480
3.53125
4
""" Number of Zero-Filled Subarrays https://leetcode.com/problems/number-of-zero-filled-subarrays/description/ """ class Solution: def zeroFilledSubarray(self, nums: List[int]) -> int: zeroSubarrays = [0] * len(nums) numSubarraysSoFar = 0 for i,n in enumerate(nums): if nums[i] ...
9d9545044966e3692b6d73cedf68611a63ba1967
mcxu/code-sandbox
/PythonSandbox/src/leetcode/lc443_string_compression.py
2,771
3.515625
4
# https://leetcode.com/problems/string-compression/ class Solution: def compress(self, chars) -> int: charsOrigLen = len(chars) count = 1 lo = 0 hi = 0 i = 0 while i < len(chars)-1: #print("--- i=",i) char = chars[i] nextchar = cha...
cfc64119c99fc1293b76ca2c546a6c3d2e7732f8
mcxu/code-sandbox
/PythonSandbox/src/misc/pairs_that_add_up_to_target.py
1,905
4.03125
4
""" Given an array of numbers, find all pairs of numbers that add up to a target number. https://www.geeksforgeeks.org/count-pairs-with-given-sum/# """ def findPairs(arr, target): numMap = {} for i,n in enumerate(arr): if n in numMap.keys(): numMap[n].add(i) else: numMap...
a838faa5ccdd959dc4ba53984028f86c7b22b163
cysembrano/python101
/1/classes.py
503
3.859375
4
class Point: def __init__(self, x, y): self.x = x self.y = y @staticmethod def move(): print("move") def draw(self): print("draw") class Person: def __init__(self, name): self.name = name def talk(self): print(f"Hi, I am {self.name}") point...
f8701fc0662ce15aee33a2efafe0af36ee556587
dhanalakshmi012/sum-of-num
/sum.py
176
4.09375
4
# sum-of-num num=raw_input("enter the num:") if num<0: print("enter positive num") else: sum=0 while(num>0): sum+=num num-=1 print("the sum is",sum)
b196c3c797f33ed56444de90328cd731cf8967a0
vkk1710/CS384_1801CE31
/Assignments/Assignment2/tutorial02.py
5,213
4.125
4
# All decimal 3 places import tutorial01 as A1 import math # Function to compute mean def mean(first_list): # mean Logic mean_value = summation(first_list)/len(first_list) mean_value = round(mean_value,6) return mean_value # Function to compute median. You cant use Python functions def median(first_li...
e140c3586757e82a20d4dd85fd22013778aaed6a
juruen/numerical-equation-solving
/bisect.py
733
3.5625
4
import math PRECISION = 1E-10 def is_zero(a): return math.fabs(a) < PRECISION and math.fabs(a) > 0 def different_sign(a, b): return (a * b) < 0 def bisect(fn, a, b): """ Find a zero in the given function (fn) and two intervals a, b where fn(a) * fn(b) < 0, i.e: have distinct sign """ if ...
2b4c19de70520199753dffd4f7cd0f97a9f936bb
aditi0330/Codecademy-Python-for-Data-Science
/Pandas/Multiple_tables_in_Pandas.py
2,184
4.28125
4
#Dealing with multiple tables in Pandas #Creating a DataFrame made by matching the common columns of two DataFrames is called a merge #We can specify which columns should be matches by using the keyword arguments left_on and right_on #We can combine DataFrames whose rows don’t all match using left, right, and outer ...
a546a062b37940cf79e3e4aade523605cfca327b
aditi0330/Codecademy-Python-for-Data-Science
/Statistics/Median.py
429
3.6875
4
# Import packages import numpy as np import pandas as pd # Read in author data greatest_books = pd.read_csv("top-hundred-books.csv") # Save author ages to author_ages author_ages = greatest_books['Ages'] # Use numpy to calculate the median age of the top 100 authors median_age = np.median(author_ages) ...
65fe2b98d5d9fd0cf943c4a058073359f9e03071
Pseudomoridin/Chess
/rook.py
2,799
3.78125
4
from string import ascii_lowercase class rook(): def __init__(self, colour, position): self.colour = colour self.position = position def set_position(self, position): self.position = position def get_type(self): return "r" def get_position(self): return self.position def get_colour(sel...
a79261f82150dc1dcb149aa7cc679ab7c8ff0f88
onepcc/fundamentos-python
/CicloForBasico_2.py
4,635
4.125
4
#1.- Tamaño grande: dada una lista, escriba una función que cambie todos los números positivos de la lista a "big". # Ejemplo: biggie_size ([- 1, 3, 5, -5]) devuelve la misma lista, pero cuyos valores son ahora [-1, "big", "big", -5] def big(valores): original = valores arr =[] for x in original: i...
3ac85ded00d29807a8e7aafb0ffd72c0999a98d5
eschloff/flg-test
/extend_the_power_rule_to_functions_with_rational_exponents.py
11,778
3.546875
4
import random import sympy as sym import tools from tools import unique, Printer, Template, Problem import validations import os import sys class Template1(Template): """Template for generating problems of the form ax^{n} where n is rational and a is a non-zero integer""" @unique def variables(self): ...
69f17596909776b7a576ecf1ee4271bcbdcb6d19
robertnunn/Bioinformatics-practice
/FindRES.py
3,171
3.8125
4
''' Find proto-restriction sites in an arbitrary DNA sequence, given a list of sites arguments: Master RE list, RE search list, DNA file written for Python 3.5.2 ''' import os, sys # creats a dictionary of RE sites from the file passed def load_sites(file, sites, cut_site=0): site_dict = {} wit...
8c47c7e5acdbf8d34603b3ff4ea84cc2169040c5
priyanshi5/Calculator
/Calculator.py
3,704
3.578125
4
from tkinter import * #import tkinter.messagebox #import parser def btn_Click(numbers): global operator operator = operator + str(numbers) text_Input.set(operator) # Clear Function def btn_ClearD(a): global operator operator = "" text_Input.set("") def btn_Equ(): global operator s...
052562c69cb731eda49fa362c8c498057b7f20b3
alvaro3023/t07_rojas_oliva
/rojas/interaciones/interacion_04.py
302
3.625
4
#C = Cristo esta #P = presente en #T = tu #c = Corazon msg = "CPTc" for letra in msg: if letra == "C": print("Cristo esta") if letra == "P": print("presente en ") if letra == "T": print("tu") if letra == "c": print("corazon.") #fin_iterador print("Fin de Bucle")
1917c45fef4b1b1b04d31c1381aa39f8119e8d45
aww/coursera_datasci
/assignment3/4_asymmetric_friendships.py
886
3.65625
4
#!/usr/bin/env python import MapReduce import sys """ List asymmetric friendships """ mr = MapReduce.MapReduce() def mapper(record): person = record[0] friend = record[1] if person < friend: # pair in a canonical (lexigraphic) way. mr.emit_intermediate((person,friend), '>') else: mr....
81fd4d27ee4897618e32d9c944adc7adbd871304
kzagorulko/blog
/backend/blog/resources/utils.py
557
3.65625
4
def no_spacing_string(max_length=None, min_length=None): def validate(value): if ' ' in value: raise ValueError('There must be no spaces in this field') if max_length and len(value) > max_length: raise ValueError( f'This field must be shorter than {max_length}...
1fd0f0ed8e93a0f65078f0973dc532bfb74162f2
jayant-bhagat/python
/py_chalannage1.py
467
4.28125
4
#Write a function named capital_indexes. The function takes a single parameter, which is a string. #Your function should return a list of all the indexes in the string that have capital letters. #For example, calling capital_indexes("HeLlO") should return the list [0, 2, 4]. def capital_indexes(st): ans = [] ...
9dffdf569e5a326187a662757fc13766d9d528c6
IshaSarangi/Tic-Tac-Toe
/TicTacToe_game.py
6,466
3.546875
4
import pygame pygame.init() # colors grey = (50, 50, 50) red = (255, 64, 25) neon = (179, 255, 25) # board win = pygame.display.set_mode((400, 400)) pygame.display.set_caption("Tic-Tac-Toe") first = pygame.draw.rect(win, grey, (25, 25, 100, 100)) # RGB -> starting positions (x, y) -> rectangle dimensi...
1d8897c962e960e7cde8c21ece7e24d669c97c84
Harneett/First_project
/DateTime_Demo.py
308
4.03125
4
import datetime deadline = input("Enter deadline for your project...(mm/dd/yyyy)") currentDate = datetime.date.today() dueDays = datetime.datetime.strptime(deadline,'%m/%d/%Y').date() difference = dueDays - currentDate print("You have " + str(difference.days) + " days left to complete your project.")
8094bdd860b994eca14473d057d1826bb1ccc29f
viniciusbortolotti/logicaprogramacao
/atividade1.py.py
648
3.90625
4
def calcula_soma( lista ): numeros = input() soma_dos_numeros = sum(numeros) return soma_dos_numeros def converte_entrada( texto ): numeros = '3 8 9 2 0' entrada = input(numeros) texto = str(entrada) lista_dos_numeros = texto.split() print(lista_dos_numeros) def processa_nu...
9c5ee67c056d3352bcf32cff5a21ef63311d6632
mirror6677/TextAnalysis_CSCI204
/basicStats.py
7,244
3.578125
4
import sllink, sStack import random class BasicStats: """ This class performs basic statistical analysis to the input list/dictionary. """ def __init__(self): pass def createFreqMap(self, freqList): """ This method takes in a list of words and returns a dictionary, whose ...
46e74a633d411f52f986dace3bd2de96abdf3ce2
mirror6677/TextAnalysis_CSCI204
/sStack.py
391
3.59375
4
class Node: data = None next = None class SStack: def __init__(self): self.head = None def push(self, newNode): newNode.next = self.head self.head = newNode def pop(self): if self.head == None: return self.head else: popNode = self....
0eb8a98fa62f779d8711335052ed9b347eb1fb4c
santia-bot/python
/trabajos de la clase/numero = 1.py
170
4.03125
4
numero = 1 num = int(input("ingrese el numero por el cual multiplicar:")) while numero <= 10: multi = numero * num print(num,"x",numero,"=",multi) numero += 1
20e8f7b6f28745f73e377dfc7b6b334059b5a9d2
santia-bot/python
/trabajos de la clase/ciclos.py
470
4.03125
4
#"ciclos infinitos" """ numero = int(input("ingrese un numero:")) for x in range(10): multi = numero * (x * 1) print(numero, "x", x + 1, "=", multi) """ #wwhile """ x = 0 numero = int(input("ingrese un numero:")) while x != 10: multi = numero * (x + 1) print(numero, "x", x, "=", multi) x += 1 """ #while infin...
f40e2bf2525015a81998b41cef70a63b7ef847f9
santia-bot/python
/trabajos de la clase/ejercicio while.py
250
4.15625
4
print("*actividad while*") numero = int(input("ingrese los numero que quiera sumar: \n ")) #variable = numero total = 0 while numero >= 1: valor = int(input("ingrese un valor: \n ")) total += valor numero = numero - 1 print("el total es:", total)
d3abd790dbcfda85dd2f9fac77f4afdfc69c4170
lucasmllr/text_recogition_project
/detect_iban.py
1,388
3.578125
4
import sys sys.path.insert(0, './python-stdnum') from stdnum import iban def iban_check(iban_string): ''' checks whether a string is an IBAN ''' try: iban.validate(iban_string) return True except: # this is bad style. change to invalid checksum exception later return False...
1d74cdb6d485afed7262cb68b00060275aee9ad3
sevln/PyProjects
/FibonacciSequence/FibonacciSequence.py
1,038
4.375
4
# FIBONACCI SEQUENCE # Asks user to input desired term of Fibonacci sequence for program to return # returns nth term of Fibonacci sequence # n is input by user def fib(num): # returns nth term of Fibonacci sequence # Term 0 = 0, Term 1 = 1, Term 2 = 0 + 1 = 1, etc # starting with n1 = 0, n2 = 1, term = 1 ...
5dce1c47404a513a35608851156a6c632628ad09
sevln/PyProjects
/CountdownClock/CountdownClock.py
1,333
4.34375
4
# COUNTDOWN CLOCK # User to inputs time and date # Program will print out a message at given intervals, telling user how much longer there is until the selected time # SUBGOALS # If the selected time has already passed, have the program tell the user to start over. # Asks for the year, month, day, hour separately, all...
4727711ee6a1bc789dd601da22586f46bad7758d
DeepFreek/NewTry
/INTERN_TEST_SOLVE.py
331
3.65625
4
def regulator(error): if(error>=0): return 0 else: return abs((0.4*error+0.006*(error**3))/25.6125) Temperature_Sensor=0 Normal_Temperature=75 Power=0 while True: Temperature_Sensor=int(input()) print(Temperature_Sensor-Normal_Temperature) print(regulator(Temperature_Sensor-Normal_Te...
dfcaab7d466bc7e96b9413f37548516f41126c07
ethan626/sentiment
/sentiment_challenge.py
3,553
3.609375
4
#!/bin/python import tflearn from tflearn.data_utils import to_categorical, pad_sequences import pandas as pd import numpy as np from collections import Counter """ Week three challenge of Intro to Deep Learning with Siraj. The challenge is to write a reccurernt network utilizing LSTM to classify video game reviews b...
5997b89a55e5741adfc6b747f82c817179451ca3
projet2019/MemoryGame
/game.py
5,737
3.546875
4
from board import Board from player import Player from error import InvalidInputError, InvalidCardError from datetime import datetime from typing import List, Tuple, TextIO class Game: """Gère le déroulement du jeu""" def __init__(self): self.board: Board = Board() self.players: List[Player] ...
150f728047bce5b8dedcaa7313d5f7dd3608cf23
Rainboylvx/pcs
/luogu/1080/data.py
139
3.78125
4
import random rnd = random.randint n = rnd(3,10) print(n) print(rnd(3,10),rnd(3,10)) for i in range(0,n): print(rnd(3,10),rnd(3,10))
c8f1c8081141a4f6872e60c07819ace3dd10305e
Rainboylvx/pcs
/poj/2889/data_generator.py
566
3.875
4
#!/usr/bin/env python from cyaron import * n = randint(5,10); m = randint(n,n*(n-1)/2); print(n,m) graph = Graph.graph(n, m) # 生成一个n点,m边的无向图,边权均为1 for edge in graph.iterate_edges(): # 遍历所有边,其中edge内保存的也是Edge对象 print(edge.start,edge.end) n = randint(5,10); m = randint(n,n*(n-1)/2); print(n,m) graph = Graph.graph(n, ...
e3f5cb934831c2401d890d47eb9814741091be62
momeyer/cs50Introduction
/pset6/mario/more/mario.py
397
4.28125
4
def print_piramid(height): brick = "#" space = " " for i in range(1, height + 1): print(f"{space * (height - i)}{brick * i} {brick * i}") def get_correct_input(): height = int(input("Height: ")) if height >= 1 or height <= 8: return height else: get_correct_input() de...
87b4bd700a774f4cc63ca951cb42f48770d49e95
christwt/BlackJack
/main.py
2,384
4.03125
4
''' Black Jack Application main.py Author: William Christie copyright 2017 William Christie Last modified date: 2/2/17 ''' # import modules from blackJackClass import BlackJackDeck def rules(): ''' display black jack rules and odds ''' print("\nBlack Jack Rules!\n") print("Minimum bet ...
cebf31391fbbf23aa3b625e473c2ec76951393be
ScottJianTin/Stock-Price
/main.py
3,593
3.671875
4
import yfinance as yf import streamlit as st import pandas as pd from datetime import date st.write(""" # Financial Dashboard """) ## define the ticker symbol (e.g. AAPL - Apple, AMZN - Amazon, MSFT - Microsoft) tickerSymbol = st.selectbox("Select Stock", ("Facebook (FB)", "Apple (AAPL)", "Amazon (AMZN)", "...
cdd83376d4ef4014177b3200faedff74ab108d15
TomaszMazurekWSB/WSB-Python
/.github/workflows/bridge_design_pattern.py
2,496
4.53125
5
# Bridge Design pattern is used to join specific and independent # abstractions, it is used when we have to implement platform # independent features or when different abstractions are required # to be implemented for the same abstraction. # In this example have a Cuboid class having three attributes # named as length...
34e9d16f29ea48f99ef65dee09495e3c7c440e95
bri-cottrill/Old-Python-HW
/sinewave.py
427
3.640625
4
# 01/24/19 - Week 3 HW # displays the curvature of a sinusoid on the terminal in a single statement # Note: I know this is not *technically* a single statement, but I couldn't figure out how to do without importing math. Any solutions posted in review would be appreciated. import math print(*[(x+50)*' '+' *' for x in...
dfcbbcc4a269467e1fa0a66e92bc7782577f19ed
maziyardowlat/TechnicalQuiz
/Test.py
1,183
3.546875
4
import unittest from AngleCalc import AngleCalc class TestCalc(unittest.TestCase): def test_angle(self): angle_calc = AngleCalc() result = angle_calc.boundTo180(10) result2 = angle_calc.boundTo180(-280) result3 = angle_calc.boundTo180(390) result4 = angle_calc.boundTo180(0)...
cc97bda4d460330527698e5af537f7ad70e2358d
HadesXD/projectEulerProblems-py
/euler004.py
501
4.0625
4
# # A palindromic number reads the same both ways. The largest palindrome # made from the product of two 2-digit numbers is 9009 = 91 × 99. # # Find the largest palindrome made from the product of two 3-digit numbers. a = 10 b = 10 c = 1 big = 1 def Reverse(n): r = 0 while n > 0: r *= 10 r ...
b9b8adeb726e15760396b50462035c88e06df348
mithunpm/newProjectPhython
/app.py
222
3.796875
4
print("mithun") print('&' * 10) p_name="ginu" p_age='20' p_isexist=False print("name :" + p_name + "age :" + p_age ) p_name=input("enter the name ") p_color=input("enter favourate color ") print(p_name +" like "+p_color)
5e15c6025089d8a0f4b57183017e118ea8261184
mithunpm/newProjectPhython
/example.py
112
3.875
4
weight=input('input the weight? ') weight=int(weight) pound=weight/2.2046 print("weight in kg ===" + str(pound))
89ebcc12e41125577b5c9967e7f8599c2392ea00
s10th24b/DNN_study
/practice/4_MinimizingCostUpdate.py
1,454
3.75
4
import tensorflow as tf import matplotlib.pyplot as plt x_data = [1,2,3] y_data = [1,2,3] W = tf.Variable(tf.random_normal([1]),name='weight') X = tf.placeholder(tf.float32) Y = tf.placeholder(tf.float32) # Our hypothesis for linear model X * W hypothesis = X * W # cost/loss function cost = tf.reduce_mean(tf.squar...
b463892e35af1a2829aed7c13f4898d86ddd7766
s10th24b/DNN_study
/practice/12_NNTipsLab.py
11,682
3.609375
4
from tensorflow.examples.tutorials.mnist import input_data import tensorflow as tf import numpy as np import matplotlib.pyplot as plt import random mnist = input_data.read_data_sets("MNIST_data/", one_hot=True) #Use softmax, NN, Xavier, Deep NN select = input("select option(All:0, softmax_cross_entropy_with_logits=1,...
d4c43fe92fd2052f3f7869d016d144ab28796ed9
HarshithaKP/Python-practice-questions-
/17.py
458
3.953125
4
# Implement a program to get three values from CLA and print the sum of them. import sys def cla_sum(): summ=0 a=int(sys.argv[1]) b=int(sys.argv[2]) c=int(sys.argv[3]) summ=summ+a+b+c print("Sum of 3 numbers is :",summ) def main(): print("program to get three values from CLA and print the sum of them") try: ...
e12ee3517bc6b62cbe6bcfc0c2ddd1c5015d0e3b
HarshithaKP/Python-practice-questions-
/16.py
327
4.25
4
# Implement a program to print the elements of a list. def prin(mylist): print(mylist) def main(): mylist=[] n=int(input("Enter the total number of elements you wish to add to list :")) for i in range(0,n): element=input("Enter the element :") mylist.append(element) prin(mylist) if __name__ == '__main__': ...
75d8ec9144dca7307fe0eaf5c13646f49d06f219
HarshithaKP/Python-practice-questions-
/27.py
367
4.4375
4
# Implement a progam to convert the input string to lower case ( without using standard library) def lowercase(string): result = '' for char in string: if ord(char) <=90: result += chr(ord(char) + 32) print(result) def main(): string=input("Enter any string in uppercase :") lowercas...
7a184a37e50365d497b985ccc986a2914966516b
HarshithaKP/Python-practice-questions-
/23.py
201
4.125
4
# Implement a program to write a line from the console to a file. def main(): f=open("file1.txt","w") line=input("Enter a line to add in file :") f.write(line) if __name__ == '__main__': main()
d48e5352d382213bd34c2977db937dbbe351b60c
angelinaossimetha/climate-change-simulator
/simulator.py
3,894
3.796875
4
class Simulator: """Simulates the climate of Branlex""" def __init__(self): self.year = 0 self.max_temperature = 100 self.current_bad = 150 self.worst_threshold = 80 self.bad_threshold = 150 self.current_worst = 0 self.country_names = [] self.polic...
d45cb9c82e50f6ac6521af13169e3da44bc2f672
orcas59/Test
/input.py
113
4
4
print("Calculating Program") a=int(input("Enter 1st number")) b=int(input("Enter 2nd number")) c = a+b print(a+b)
4c9d61e95e027391d69a66a68caafc85cb55832c
orcas59/Test
/Ex5.2.py
108
3.828125
4
s = int(input("Distance (km.) : ")) t = int(input("Time (hr.) : ")) v = s/t print("Result") print(v,"km/hr")
bdcbe5a19729915decbb901f7194f0870f1fb0c1
philcleveland/exercism_python
/armstrong-numbers/armstrong_numbers.py
209
3.71875
4
def is_armstrong_number(number): number_as_string = str(number) num_digits = len(number_as_string) sum = 0 for i in number_as_string: sum += int(i)**num_digits return sum == number
5d2ac11a6d2c8201f200ea183669f93fae197160
philcleveland/exercism_python
/yacht/yacht.py
2,382
4
4
""" This exercise stub and the test suite contain several enumerated constants. Since Python 2 does not have the enum module, the idiomatic way to write enumerated constants has traditionally been a NAME assigned to an arbitrary, but unique value. An integer is traditionally used because it’s memory efficient. It is a...
81173f5a4cd6d87cfa4881c65152d433e8a52305
milamao/coding-exercise
/leetcode_863.py
1,992
3.578125
4
# Definition for a binary tree node. # class TreeNode: # def __init__(self, x): # self.val = x # self.left = None # self.right = None class Solution: def distanceK(self, root: TreeNode, target: TreeNode, k: int) -> List[int]: # thoughts: # first build an edge map ...
44abf21ed56ddc6512b7fabfa4b1182cc2c100fd
milamao/coding-exercise
/leetcode_889.py
955
3.734375
4
# Definition for a binary tree node. # class TreeNode: # def __init__(self, val=0, left=None, right=None): # self.val = val # self.left = left # self.right = right class Solution: def constructFromPrePost(self, preorder: List[int], postorder: List[int]) -> Optional[TreeNode]: pos...
69a901b9c7dd29ee19df621a2de6a21026b8ffcf
milamao/coding-exercise
/leetcode_16.py
1,197
3.625
4
class Solution(object): def threeSumClosest(self, nums, target): """ :type nums: List[int] :type target: int :rtype: int """ nums.sort() # O(nlogn) closest_sum = float('INF') min_diff = float('INF') for i in range(len(nums)): sum...
195c74fd865c1ae71fa3d28ce90d273bf848859f
pedrohbtp/twitch-youtube-plays-fall-guys
/key.py
3,831
3.546875
4
# For Windows # http://stackoverflow.com/questions/1823762/sendkeys-for-python-3-1-on-windows # https://stackoverflow.com/a/38888131 import win32api import win32con import win32gui import time, sys keyDelay =0.1 # https://docs.microsoft.com/en-us/windows/win32/inputdev/virtual-key-codes keymap = { "w": 0x57, #w ...
4a3457bfb7a48c770b7ca76a50a129f92ef4c675
WilliamHdz/Tareas_Proyectos
/PYTHON/P13.py
1,388
3.78125
4
flag = True while flag == True: archivo = open("Salida_P13.txt","a") print("") print("####################################################") print("# 1. COMPROBAR SI NACÍ EN UN AÑO BISIESTO ---- (a) #") print("# 2. HISTORIAL ------------------------------- (h) #") print("# 3. SALIR -----------------------------...
4294a91f40a887c08a33641c900ff601df543c2a
WilliamHdz/Tareas_Proyectos
/PYTHON/P06.py
2,055
3.59375
4
flag = True while flag == True: try: archivo = open("Salida_P06.txt","a") print("") print("#########################################################################") print("# 1. DETERMINAR EL TIPO DE TRIANGULO CON RESPERCTO A SUS LADOS ---- (t) #") print("# 2. SALIR --------------------------------------...
ba0e0c13a36a8f24e17458087c47100bcf7c5f31
WisdomLLong/NN_Workspace
/Regression/SVM_Regression.py
2,069
3.5625
4
# -*- coding: utf-8 -*- # 美国波士顿地区房价数据描述 # 读取数据 from sklearn.datasets import load_boston boston = load_boston() print(boston.DESCR) # 数据分隔 from sklearn.cross_validation import train_test_split import numpy as np X = boston.data y = boston.target X_train, X_test, y_train, y_test = train_test_split(X, y, random_state=...
7091a79de0cacdd27f25e8b7e541b642b50cc649
brahimmade/music-inbox
/apps/library/utils/tea.py
1,189
4.25
4
def encrypt(value, key): ''' Encrypts value with key using the Tiny Encryption Algorithm. * value has to be an integer or a long * key has to be an integer array of length 4 ''' v0 = value >> 32; v1 = value & 0xFFFFFFFFL; sum=0 delta=0x9e3779b9 k0=key[0]; k1=key[1]; k2=key[2]; k3=ke...
519b53d9fc66eef35a52cb85ea46c6fdc315170c
blitzher/puzzle_making
/puzzle_tools.py
2,408
3.6875
4
""" loads a text file <'input.txt'> and encrupts it using custom methods and outputs into <'output.txt'> """ import os from PIL import Image all_puzzles = [] def _printif(stat, cond): if cond: print(stat); def _req_file(filename): if not os.path.isfile(filename): with open(filename, 'w') a...
a74f5df1d7db377f7941f86abac9db95354de0bc
yulianghui/chigua-test
/chigua-test/Demo/test.py
463
3.65625
4
#coding=utf-8 shopping = {"Mac":9000,"kindle":800,"tesla":900000,"python_book":105,"bike":2000} amount = input("请输入您的金额:") product = input("请选择您的商品:") amount = int(amount) product_prace = int(shopping[product]) balance =amount-product_prace if amount <product_prace: print("商品价格为%d元,您的余额不足!"%product_prace) els...
d73b653ca7018bd551caa1e9647e6bcb025a2cee
suzumiya123/study-thinkpython
/do_for.py
171
3.859375
4
#!/usr/bin/env python3 # -*- conding: utf-8 -*- sum = 0 for x in range(101): sum = sum + x print(sum) aum = 0 a = 100 while a >=0: aum = aum + a a= a -1 print(aum)
9b82b07df644b3395d25cc7e404e374b93c10754
juliusbc/hackerrank
/angrychildren.py
1,208
3.515625
4
# let's avoid sorting the entire list of packets, in hopes of keeping the algorithm less than n*log(n). # in fact let's even avoid holding all the packets in memory at the same time by using a stream-based algorithm # the first K packets are necessarily the best packets. # the values of the packets must all be stored,...
c721aa3078f3f8fd4c2c64192c4b44215493c73c
zaidhassanch/PointerNetworks
/NLPspecialization/4_AttentionModels/Week1/T001_stack_semantics/stack.py
12,126
3.71875
4
# coding: utf-8 # # Stack Semantics in Trax: Ungraded Lab # In this ungraded lab, we will explain the stack semantics in Trax. This will help in understanding how to use layers like `Select` and `Residual` which operates on elements in the stack. If you've taken a computer science class before, you will recall that ...
f8bf2515c4236e7ce239711ac3b8cda560b0cddb
zaidhassanch/PointerNetworks
/T002_sort_alphabet/readWords.py
444
3.515625
4
def readInWords(): f = open("/usr/share/dict/words", "r") char_list = ['\'', 'é', 'ö'] f = [ele for ele in f if all(ch not in ele for ch in char_list)] f = [ele for ele in f if len(ele) < 14] f = [ele.rstrip() for ele in f] f = [ele.lower() for ele in f] maxlength = 0 for i, x in enumerate(f): pri...
9bfe8a4d8677744d69255f1a13028a0cd4e5e830
baiyang0223/python
/testnet/testtcp/testcs1/server.py
1,300
3.515625
4
import socket def main(): # 创建tcp套接字-买手机 tcp_sock = socket.socket(socket.AF_INET,socket.SOCK_STREAM) # 绑定tcp地址-办手机卡 tcp_sock.bind(("",7890)) # 创建socket套接字的默认属性是主动的,使用listen变为被动,这样就可以接收别人的链接了-手机设置为正常状态 tcp_sock.listen(128) while True: # accept准备接收,等待客户端链接,返回元组:等号右边是个元组,等号左边是多个变量...
e634d90f91735bb2dd1b2fffda104040da09e26e
baiyang0223/python
/testIterater/fibonacci.py
1,147
3.859375
4
from collections import Iterable, Iterator import os,sys,random,time class Fibonacci(): def __init__(self,collect_allnum=0): self.arr = list() self.cursor = 0 self.collect_allnum = collect_allnum self.num1 = 0 self.num2 = 1 def __iter__(self): return self d...
41a2d772c0eb15d6330328d4bac7e4710080d238
50sven/carla_rllib
/carla_rllib/utils/trajectory_planning.py
9,046
3.671875
4
"""Polynomial Trajectory Planning This script allows the user to calculate polynomial trajectories based on jerk minimization. The trajectories are planned in frenet coordinates. Classes: * Trajectory - basic trajectory class * PolynomialGenerator - trajectory calculation based on jerk minimization """ import...
c53a7dab04b0c9d806267e05dfdf06871c2ee336
iliandy/codewars
/palindrome_chain_length.py
258
3.75
4
# https://www.codewars.com/kata/525f039017c7cd0e1a000a26/train/python def palindrome_chain_length(n): count = 0 while(str(n) != str(n)[::-1]): n = n + int(str(n)[::-1]) count += 1 return count print palindrome_chain_length(87)
05113ca1f55f3579b3cb5227dadcbaba685a21d0
iliandy/codewars
/find_missing.py
331
3.9375
4
# https://www.codewars.com/kata/find-the-missing-term-in-an-arithmetic-progression/train/python def find_missing(seq): step = (seq[-1] - seq[0])/len(seq) comp_seq = range(seq[0], seq[-1], step) if (set(comp_seq) - set(seq)): return (set(comp_seq) - set(seq)).pop() print find_missing([1, 2, 3, 4, 6,...
54d4c91b63d15e98b113b6e6f414fbd3892ab18d
hp04301986/leetcode
/347TopKFre.py
648
3.953125
4
""" Given a non-empty array of integers, return the k most frequent elements. For example, Given [1,1,1,2,2,3] and k = 2, return [1,2]. Note: You may assume k is always valid, 1 ≤ k ≤ number of unique elements. Your algorithm's time complexity must be better than O(n log n), where n is the array's size. """ import coll...
f66a18b33c33fbed332c609314f188b44f979597
hp04301986/leetcode
/020ValidParenthes.py
471
3.6875
4
class Solution: def isValid(self, s): """ :type s: str :rtype: bool """ dic = {'(': ')', '[':']','{':'}'} temp = [] for ss in s: if ss in dic.keys(): temp.append(ss) elif temp and (ss in dic.values() and ss == dic[temp[-...
9df3ca810e91ae0f2cf493d3bbda7f38fd2ecb75
hp04301986/leetcode
/026removedup.py
898
3.96875
4
""" Given a sorted array, remove the duplicates in-place such that each element appear only once and return the new length. Do not allocate extra space for another array, you must do this by modifying the input array in-place with O(1) extra memory. Example: Given nums = [1,1,2], Your function should return length = 2,...
33f9f1454537bae1cd3cd6917f5d904a26fb2a20
Marcinar1010/CS50
/pset6/mario/mario.py
939
4.03125
4
import cs50 def main(): # prompt the user for positive integer not greater than 8 while True: height = cs50.get_int("Height: ") if height > 0 and height <= 8: break # print pyramid print_pyramid(height, -1) def print_pyramid(height, row): # base case if height ==...
5527a237bd7d5ba5b4a3b21bc16a7ea520ace539
Foo2018/Assignment-2
/mammals.py
924
3.609375
4
from extractor import Extractor """ Test Python file for file extractor. Also provides test if an attribute declared outside of an __init__""" class Mammal(object): @staticmethod def feeds(): print("milk") def proliferates(self): pass class Marsupial(Mammal): def proliferates(sel...
e81f6ceab7577f2338b172ce7a477b3902274f53
gadeleon/chromatic_circle
/test/test_music_theory.py
904
3.796875
4
''' Unit tests for music_theory.py ''' import unittest import music_theory class RunKeyTestCase(unittest.TestCase): '''Tests for music_theory module''' def setUp(self): ''' Called before testing ''' pass def test_lowercase_valid(self): ''' Assert 3rd of...
a7c561fe5b3e649a6b21875c72dd047c4fa8e6f3
thiiagolourenco/Perceptron
/perceptron.py
3,270
3.65625
4
# Thiago Lourenço C. Bezerra # Rede Neurais - Professor Meuser Valença # Para teste foi usado os dados da PRIMEIRA ativiade da cadeira (1º PRÁTICA) !! import random, copy class Perceptron: def __init__(self, entradas, saidas, taxa_aprendizado, ciclos, limiar): self.entradas = entradas self.sai...
c700d6579361c9353f4e938717c4308b57f856a8
SeanJia/MachineLearningImpl
/MLP.py
7,033
3.625
4
__author__ = 'Zhiwei Jia' import numpy as np from numpy import * class NeuralNet: def __init__(self, sizes, act=0): """the initialization function to create a new neural network with specified size""" self.num_layers = len(sizes) self.sizes = sizes self.biases = [np.random.randn(...
463e43ffccd0947870f62f5f7d5e315d93dfc33f
ahmedabzk/itertools
/permutations.py
245
4.03125
4
import itertools letters = ['a','b','c','d'] numbers = [0,1,2,3,4] names = ['Corey', 'Nicole'] # permutations are used to iterate over items where order does matter result = itertools.permutations(letters,2) for item in result: print(item)
3dd73e60e817f26a851196186276c0c6f7952955
fxl2015/python_study
/test02/hello.py
222
3.71875
4
#hello.py # print "hello python!" # print "hello python!" # print "hello python!" # print "hello python!" # print "hello python!" name=int(raw_input("input:")) print"name=",name if name>10: print name else: print -name
d16e48b99203158057c5d71e9f21401e8ebd60b4
fxl2015/python_study
/test01/com/Test.py
6,171
3.609375
4
# print "121212" # print("sasas") # a=10 # if a>100: # print a # else: # print -a # print 'i\'m ok' # print 'amamm\n\n\n\n\n' # print '''wqwq # rere # gfgfgf # kjkjkjk # ''' # print True and False # print None # PI=3.1415926 # print 10/3.0 # print ord('a') # print chr(102) # # a='hhhhh' # print "hello,%s"...
aa04d81cfa8900f9deef2f7efba352c54815e052
melihburma/GlobalAIHubPythonCourse
/Homework/hw2.py
232
3.9375
4
users={"melih":"123456","mehmet":"password","fatma":"deneme"} name=input("input username: ") pw=input("input password: ") if users[name]==pw: print("login succesfully") else: print("wrong password or username")
e56a0512b3ecdc97f46e2038a380076d2cfb8976
Judyoooooooooo/Python-Programming
/Practice/lesson5_inventory.py
334
3.71875
4
Q = int(input("Order quantity Q: ")) R = int(input("Reorder point R: ")) I = int(input("Initial inventory I: ")) print("Inventory: " + str(I)) while True: #因為每天都要跑,所以讓他無窮迴圈 sales = int(input("Sales in a day: ")) I=I-sales if I-sales>=0 else 0 if I<R: I=I+Q print("Inventory: " + str(I))
503f1f0c92f895845b7e7a891a1d547cae52ccde
Judyoooooooooo/Python-Programming
/Practice/lesson5_practice.py
202
3.71875
4
gradeStr=input() #12345 grades = gradeStr.split() grades.append([9, 7, 5]) print(grades) print(grades[3][0],grades[3][1]) #list中的list值 print(grades[3], grades[2] * 2) print(len(grades)) #長度