blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
67c822dd04505cea39cabfa36ce582ad8bae34b3
weitaishan/PythonPractice
/Base/Finished/Test71.py
1,429
3.984375
4
# *_*coding:utf-8 *_* ''' 题目:编写input()和output()函数输入,输出5个学生的数据记录。 ''' # # 方法一 # student1 = input("请输入你的性别、姓名、年龄,中间用空格间隔: ") # student2 = input("请输入你的性别、姓名、年龄,中间用空格间隔: ") # student3 = input("请输入你的性别、姓名、年龄,中间用空格间隔: ") # student4 = input("请输入你的性别、姓名、年龄,中间用空格间隔: ") # student5 = input("请输入你的性别、姓名、年龄,中间用空格间隔: ") # # def o...
3339b88f610eb16bb835b3421436da9f7583c3a7
janaki-rk/silver_train
/Coding Challenge_12.py
1,631
4
4
# DAILY CODING CHALLENGE 12 # Question asked by: AMAZON # There exists a staircase with N steps, and you can climb up either 1 or 2 steps at a time. Given N, # write a function that returns the number of unique ways you can climb the staircase. The order of the steps matters. # For example, if N is 4, then there are 5 ...
1047387c8e942dfeecb427b8300fe4c4684a9a42
mrlancelot/CodingPractice
/Handbook/String/Valid_Parentheses.py
261
3.8125
4
s = "()[]{}" stack = [] op = {')':'(',']':'[','}':'{'} for i in s: if i in op: if stack and stack[-1] == op[i]: stack.pop() else: print(False) else: stack.append(i) print (True if not stack else False)
e38bd5619fbe6bcf5e779d02b6c5b33d308fadfc
behrouzmadahian/python
/GANS/01-DCGAN.py
10,994
3.734375
4
import numpy as np import tensorflow as tf import os, time, itertools, imageio, pickle from matplotlib import pyplot as plt from tensorflow.examples.tutorials.mnist import input_data ''' we resize the images into (1,64,64,1). Think about convolution, getting a p*p image (1, 64, 64, 1) and after several convolu...
f1f5dcd6744ce0128af624ee55f480f53bc90f0d
asheahan/invigorate
/data/idea-generator.py
5,282
3.5625
4
"""Module that scrapes concept data to be used by the idea generator Runs through a number of "Scrapers" that take concept data, such as magic types, locations, and animals, and saves these in JSON files to be loaded into the database as fixtures. """ import json import os import requests from bs4 import BeautifulS...
1c1632cd55b4ea9f73c77240bd6cbe867bf3e7e7
PolynomialTime/WISE2017
/selection_probability.py
549
3.53125
4
# select num items according to probabilities import random def select(node_list, probability, num): selected = [] i = 0 while i < num: x = random.uniform(0,1) cumulative_probability = 0.0 for item, item_probability in zip(node_list,probability): cumulative_probability ...
681fec99cca186fc13aaef8e3e6b486bd690356b
jhz940303/Code_Similarity_Detection
/main.py
1,834
3.890625
4
import math from nltk import ngrams if __name__ == '__main__': s1 = """ Natural-language processing (NLP) is an area of computer science and artificial intelligence concerned with the interactions between computers and human (natural) languages. """ s2 = """ ...
b801e76b5221f8fffe2ba2b9c70257187d58d4e1
Robin59/code
/tools.py
4,245
4.15625
4
#tools use for the cryptographie from random import * #Create a key for the enigma cypher def enigmaKey (nbRings) : """ Create a key for the enigma cypher, nbRings is the number of rings contain in the key """ key=[] for a in range(nbRings) : list = range(256) subKey = [] ...
783c0def3640a0c28d8eda8357a9c646bb5c9480
reyduar/Python
/0/Agenda_telefonica_v3.py
739
3.546875
4
""" Autor Ariel Duarte Fecha : 28/06/2015 Programa de Contactos telefonicos version 3 """ import sys import modulos_2 def principal(): modulos_2.bienvenida() opcion = input("> ") print("Has seleccinado la opción", opcion) if opcion=="1": modulos_2.escribir() principal() elif opcion=="2": ...
7fdc0f22c9216f2a571a8bba2d814887d25a586a
Koszarsky/Audiobook
/audiobook.py
960
3.921875
4
def timeRemaining (hours,minutes,speed): hoursToMin = hours * 60 hoursPlusMin = hoursToMin + minutes speedAlteredTotal = hoursPlusMin / speed speedAlteredTotal = int(round(speedAlteredTotal)) speedAlteredMin = speedAlteredTotal % 60 speedAlteredHours = (speedAlteredTotal - speedAlteredMin)...
e40d8417d2ecc06865912cd8f332ab1e786eb24b
dollarstir/king
/loops.py
281
3.859375
4
wl=1 while wl< 6 : print (wl) if wl==5: print("5 is enough \n") break wl +=1 #for loops for i in range(1,11): print (i) print("\n") names= ["kofi","Ama","Afua"] for dollar in names : print (dollar + " is a good student")
5744adafe3cf691aecc4a65f1fc0f0b2385c9ab1
DtxdF/reverse-shell-sdc
/core/security.py
865
3.578125
4
# -*- coding: UTF-8 from crypter import encrypt, decrypt class passwordLimit(Exception): pass class repeatLimit(Exception): pass class Secure: def __init__(self, password, repeat=1): if (int(len(password)) <> 32): raise passwordLimit("La contrasena debe tener una logitud de 32 caracteres....
3e9526912ccb8a7343c158df780c2eb0c15c4250
krishnanunni-pr/Pyrhon-Django
/asessment/assesment2/palindrome.py
392
4.3125
4
# def check_palindrome(str): # reverse = str[::-1] # check=1 # if(str!=reverse): # check=0 # return check # def check_palindrome(str): reverse=str[::-1] check=1 if(str!=reverse): check=0 return check str = input("Enter the string: ") check= check_palindrome(str) if(chec...
8bd64a1576360313c91c87292ef3420243fd5339
green-fox-academy/hoanjinan
/week-01/day-2/exercises-w1d2/loops/i_wont_cheat_on_the_exams.py
158
3.609375
4
# Create a program that writes this line 100 times: # "I won't cheat on the exam!" a = 1 while a <= 100: print("I won't cheat on the exam!", a) a += 1
41d506d34fd77c8b6fd0b97970b6d90e2112880f
Chenlu-Wu/CarND-LaneLines
/lane_line_tracking.py
10,851
3.703125
4
#importing some useful packages import matplotlib.pyplot as plt import matplotlib.image as mpimg import numpy as np import cv2 import os import math get_ipython().run_line_magic('matplotlib', 'inline') def grayscale(img): """Applies the Grayscale transform This will return an image with only one color channel...
e61d7e7b22e73aab56dd421ce230c604aa83d91c
tiewangw/Python
/MachingLearning/chapter10/10.4 SelectKBest.py
1,386
3.578125
4
# 删除与分类任务不相关的特征 from sklearn.datasets import load_iris from sklearn.feature_selection import SelectKBest from sklearn.feature_selection import chi2, f_classif from sklearn.feature_selection import SelectPercentile # 加载数据 iris = load_iris() features = iris.data target = iris.target # 将分类数据转换成整数型数据 features = features....
c16ae19bc18c042bd972333a50d654f1d23d21ab
sandeepmaxpayne/Udacity_Computer_Vision_Nanodegree
/Computer Vision Intro/Project1_Facial_Key_Point/models.py
2,245
3.796875
4
## TODO: define the convolutional neural network architecture import torch import torch.nn as nn import torch.nn.functional as F # can use the below import should you choose to initialize the weights of your Net import torch.nn.init as I class Net(nn.Module): def __init__(self): super(Net, self).__init_...
da1cd8bfa31747a5c5b2802c531f05344d974d57
Munklar/Partridge-Puzzle
/Analysis/postproc.py
5,905
3.734375
4
matrix = list() m_dim = 36 trans_list = list() def init_matrix(): global matrix line = list() for i in range(m_dim): line.append(0.0) for i in range(m_dim): matrix.append(line) def show_minmax(count): global matrix maxval = 0.0 minval = float(count+1) ...
2eb13d4fe67579362f02b11462287e9f3cafd396
teenage-coder/Data-Analysis-with-Python
/While Loop in Python/Rock Paper Scissors Final.py
1,423
3.9375
4
import random times = int(input("How many chancess you want to play: ")) print("****************") print("* Rock - 0 *") print("* Paper - 1 *") print("* Scissors - 2 *") print("****************") print("") playerScore = 0 opponentScore = 0 chancess = 0 while (chancess != times): opponent = random.randi...
38d9265bf27edcc15d85308b3d8847d8e052686e
AAAleg/learning
/algorithms_2/simple_graph/simple_graph.py
4,243
3.515625
4
class Queue: def __init__(self): self.items = [] self._size = 0 def isEmpty(self): return self._size == 0 def enqueue(self, item): self.items.insert(0, item) self._size += 1 def dequeue(self): if not self.isEmpty(): self._size -= 1 ...
01f6bf79efc9e126dcfa33cb4b3e89fd698f2716
bobby8704/Unit-4-Project
/day25.py
306
4.1875
4
# Find the sum of all the multiples of 3 or 5 below 1000. total_sum = 0 for i in range (0, 1000): # for every number from 0 to 999 if i % 3 == 0 or i % 5 == 0: # if that number is a multiple of 3 or five total_sum = total_sum + i # total sum would add that number print(total_sum)
72c3f22453e256b7ee92081d7d485657f680da70
chinsaku/leetcode
/104. Maximum Depth of Binary Tree.py
918
3.8125
4
# Definition for a binary tree node. # class TreeNode: # def __init__(self, x): # self.val = x # self.left = None # self.right = None """ class Solution: n = 1 def help(self, p, q): if p == None and q == None: return n if p or q : n += 1 return...
93dbd7e69a42fa502ffbc7507e9163d59139a848
LogicPenguins/BeginnerPython
/exercisesATBSWP/practiceprojects/fantasyinv.py
736
3.78125
4
inventory = { 'rope': 1, 'torch': 6, 'gold coin': 42, 'dagger': 1, 'arrow': 12 } dragon_loot = ['gold coin', 'dagger', 'gold coin', 'gold coin', 'ruby', 'ruby', 'rope', 'rope', 'rope'] def display_inventory(player_inventory): print("Inventory:") for item, amount in inventory.items(): ...
036f73cdaf9b526193538a45c3e0254f2f4e9898
cuyu/leetcode
/543.二叉树的直径.py
1,223
3.625
4
# # @lc app=leetcode.cn id=543 lang=python3 # # [543] 二叉树的直径 # # Definition for a binary tree node. class TreeNode: def __init__(self, x): self.val = x self.left = None self.right = None # @lc code=start class Solution: def diameterOfBinaryTree(self, root: TreeNode) -> int: def...
5c63162fbabcf9df912d4e95eeaba391a875786c
AlvisonHunterArnuero/EinstiegPythonProgrammierung-
/basic_advanced_ternary_operator.py
551
4.46875
4
#---------------------------------------------------------------------------- # Basic and advanced conditional using ternary operators to print strings # Made with ❤️ in Python 3 by Alvison Hunter Arnuero - February 1st, 2022 # JavaScript, Python and Web Development tips at: https://bit.ly/3p9hpqj #--------------------...
e1abdcf58a76cbb090ce3902d6ba654880de7d3c
Utkichaps/opencv-tutorial-practice
/v.hough_line_transform.py
2,235
4.03125
4
''' Hough transform is a technique used to detect any shape, if you can represent it in a mathematical form. It can even detect the shape if it is broken or distorted a bit. The algorithm is as follows: 1. Edge detection 2. Mapping of edge points to the Hough space and storage in the accumulator 3. Interpre...
9a7abde14af22114731c515f792ba74b5e83df41
CristobalME96/Universidad
/Programacion 1/Tarea 1/supermercado.py
448
3.78125
4
print ("ingrese el valor del producto 1") product1 = int(input()) print ("ingrese el valor del producto 2") product2 = int(input()) print ("ingrese el valor del producto 3") product3 = int(input()) print ("ingrese el valor del producto 4") product4 = int(input()) print ("ingrese el valor del producto 5") product5 = int...
e11196ff003aa513de2bc01ca0d1a24338917175
leandrominer85/Data-Analysis-Bitcoin-price-Klines
/python_code/data_visualizator.py
1,872
3.671875
4
#!/usr/bin/env python # coding: utf-8 # In[1]: import plotly.graph_objects as go import pandas as pd import glob import os # In[12]: def data_vis(path = '..\data\cleaned'): ''' This function receives a path for the data. First it asks the user wich file(complete path) he wants. Uses this to...
d07245c209416c52276de80605b2e82f9de49f70
Jp9910/Projeto-e-Analise-de-Algoritmos
/Listas/Lista7Questao2.py
4,277
3.546875
4
#Lista semanal de PAA - Lista 7 Questão 2 #Aluno: João Paulo Feitosa Secundo class Node(): def __init__(self,freq,simb,left=None,right=None) -> None: self.freq = freq self.left = left self.right = right self.simb = simb self.huff = '' def arvoreHuffman(T,n): frequencia ...
ff522575c14c41e4e82b71bc155e58ea4352c32a
9Harkonnen6/Yet_Another_FizzBuzz
/fizzBuzz.py
395
3.859375
4
# fizzbuzz try: x = int(input('Up to which number shall I count fizzbuzz? ')) except ValueError: print('That aint number!') for i in range(1,x,1): if i % 3 == 0 and i % 5 == 0: print(f'{i} FizzBuzz') elif i % 3 == 0: print(f'{i} Fizz') elif i % 5 == 0: print(...
a66c6006aa0ec0ddd57f5419066cfa876bb9c12b
duxun93/LeetCodeProject
/Leetcode_easy/169. Majority Element/169_Majority Element.py
434
3.609375
4
#https://leetcode.com/problems/majority-element/ def majorityElement(nums): L = sorted(nums) P = {} for i in L : if i in P :#等同于 if P.__contains__(i): P[i] = P[i] + 1 else : P[i] = 1 j = max(P.values()) for x in P : if P[x] == j : return x...
28918cff46213fd216a45aed1fe36d5209d25ddc
adam1996/Codewars-Katas-Python
/8kyu/Is_he_gonna_survive.py
791
3.859375
4
''' Is he gonna survive? https://www.codewars.com/kata/59ca8246d751df55cc00014c/train/python A hero is on his way to the castle to complete his mission. However, he's been told that the castle is surrounded with a couple of powerful dragons! each dragon takes 2 bullets to be defeated, our hero has no idea how many b...
384f23a5dbf8287289a2ad2e8a50ef7e6520216f
cjk6632/Python-Study
/P-Week1/Q/Q6.py
162
3.640625
4
# [1, 3, 5, 4, 2] 리스트를 [5, 4, 3, 2, 1]로 만들기 # 리스트 내장 함수 사용하기 a = [1,3,5,4,2] print(a) a.sort() print(a) a.reverse() print(a)
01c72865c4a7bbde2c187a2bb294750b393c6163
Team-Tomato/Learn
/Juniors - 1st Year/Barani/DAY 5/Decimal_2_Binary.py
452
4.375
4
print("***CONVERTING DECIMAL TO BINARY***") def Decimal_2_binary(dec): if dec > 1: Decimal_2_binary(dec//2) print(dec%2, end = '') if __name__ == '__main__': ch = 'r' while ch == 'r': dec = int(input("Enter positive Decimal number needs to be conerted to binary: ")) print("Binar...
712d725d09419d946de98a97bf911a17a21579dc
imaks3112/letsUpgrade_Python
/Day9/Question 1.py
637
3.515625
4
//primeOrNot.py file. %%writefile primeOrNot.py def prime(number): return number // import primeOrNot primeOrNot.prime("9") //testPrimeOrNot.py file %%writefile testPrimeOrNot.py import unittest import primeOrNot class testPrime(unittest.TestCase): def isPrime(se...
493f7c2b31eeef1ce52216da6b2ee3f75e5fb90c
bonnieyan/Python
/3-homework-yanjun/qwe.py
370
3.578125
4
# for i in range(5): # print(i) # # for j in range(0, 5): # print(j) import re s = "phone number : 010-8877665 0431-98989498 0832-3821251" reg = "0\d{2}-d{7}|0\d{3}-\d{7}|0\d{3}-\d{8}" print(re.findall(reg,s)) #捕捉与不捕捉7665 ip = "1234.543.123.12 255.255.133.255 0.0.144.0 192.168.11.1" reg1 = "(?:\d{1,3}\.){3...
5079f57ec9c43f3323bf2919eb26ff67ac8e491c
guilhermemaas/python-use-a-cabeca
/python_files/mystery.py
197
3.71875
4
def double(arg): print(f'Before: {arg}') arg = arg * 2 print(f'After: {arg}') def change(arg): print(f'Before: {arg}') arg.append('More Data') print(f'After: {arg}')
cd645e5a9539e669093b26ca4681a8943ea5b15d
wangdongfrank/LeetCode-python
/ValidPalindrome.py
378
3.578125
4
class Solution: # @param s, a string # @return a boolean def isPalindrome(self, s): New = [] for ch in s: if (ch>='0' and ch<='9') or (ch>='a' and ch<='z'): New.append(ch) elif ch>='A' and ch<='Z': New.append(chr(ord(ch) - ord('A') + or...
536d750d68e2555972787bc624da860701b5daa6
bpatel0711/Rover
/world/abstract/orientation/directions.py
1,178
3.625
4
from enum import IntEnum class Direction(IntEnum): NORTH=0 SOUTH=1 EAST=2 WEST=3 _oppo=[Direction.SOUTH,Direction.NORTH,Direction.WEST,Direction.EAST] _left=[Direction.WEST,Direction.EAST,Direction.NORTH,Direction.SOUTH] _right=[Direction.EAST,Direction.WEST,Direction.SOUTH,Direction.NORTH] def op...
80e084b8c7671d86b82d0514e64cad192cfd74a0
akhil-code/machine-learning
/genetic-algorithm/sum-of-numbers/evolve.py
3,301
3.5
4
import numpy as np import matplotlib.pyplot as plt from numpy import random class Individual: def __init__(self, numbers=None, mutate_prob=0.01,minv=0,maxv=100): if numbers is None: self.numbers = random.randint(minv,high=maxv+1,size=10) else: self.numbers = numbers ...
7c0c2bcd2822af2a3e920b908266b9ed45ed7d70
Stewie4848/cp1404_class_activities
/Week_03/Warm_up.py
681
4.125
4
# def main(): # age = input("Please enter your age: ") # age = age_check(age) # if age < 0 or age > 150: # age = age_check() # # # def age_check(age): # while age is not age.isalpha(): # print("Invalid age!") # age = input("Enter age:") # return age is_valid_input = Fals...
e5312e7b20e2f737d77d3b14b6663139d88d4557
wcompton019/HW2
/stack.py
3,596
3.921875
4
# HW2: Stack # Budget 10+ hours by Oct. 8 to complete this assignment if you received an autograder score of less than 50 on HW1. # You may use code from class or prior assignments, but may not use internal Python data structures such as lists or arrays. # You are strongly encouraged to use a Linked List. You ca...
0e8f7eabba2617472297d4576506da563d85c2de
hazle09/algorithm
/hj_algorithm/1_1 중복이 없는가.py
1,054
4.0625
4
''' 중복이 없는가 : 문자열이 주어졌을 때, 이 문자열에 같은 문자가 중복되어 등장하는지 확인하는 알고리즘을 작성하여라. 자료구조를 추가로 사용하지 않고 풀 수 있는 알고리즘 또한 고민하여라. ''' import collections # Hash 를 이용 # 딕셔너리.get(key,[default값]) : 딕셔너리에 key가 있으면 해당 key 에 대한 값을 반환하고, 없으면 default에 지정한 값을 반환한다. def hash(string): d = {} for w in string: d[w] = 0 # pri...
8ea35703d5f7ce8c6f4fec0875abdb6c05a8e71b
habsid/machine-learning
/track.py
7,983
3.5625
4
import numpy as np # linear algebra import pytz #for timestamp import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv) import folium #to map the jogging route import shapely #to create a polygon area on the map from shapely.geometry import Point, Polygon #reading the csv file in a pandas datafra...
83c9312af8920fd9618383aee6d3d9b66f3e7d99
CaiqueCaah/Estudo-de-Python
/Estudo/fundamentos.py
150
3.71875
4
#import math from math import sqrt import random num = random.randint(1, 10) raiz = sqrt(num) print('A raiz de {} é igual {:.2f}'.format(num, raiz))
db21f1cb0398f4db46b8112633184fdfcbda6330
imjamesku/CS-6316-Machine-Learning
/HW/HW2/RidgeRegression.py
5,793
3.75
4
# Machine Learning HW2 Ridge Regression import matplotlib.pyplot as plt import numpy as np # Parse the file and return 2 numpy arrays def load_data_set(filename): arr = np.loadtxt(filename) x, y = np.split(arr, [-1], axis=1) return x, y # Split the data into train and test examples by the train_proport...
06280f319d8989dc3eaa41403eeca9a9d4650f0d
everaldobass/curso-devaria
/Curso_04-Python3/aula01/desafio01.py
989
4.28125
4
# Devaria aula 23 Python Aula 1 de linguagem de programação parte 4 # Inpute do usuário n1 = int(input("Digite o primeiro numero: ")) n2 = int(input("Digite o Segundo número: ")) operador = input("\nDigite o Operador do Calculo: ") res = None # Declarando as funções def soma(n1, n2): print(f"Somando {n1} + {n2}"...
94e239a6f688f4df5990c2be9ee60aa7b5fe3ce9
z-o-e/LeetCode_OJ_Python
/combinations.py
573
3.515625
4
class Solution: # @return a list of lists of integers def combine(self, n, k): return self.findCombinations([i for i in range(1, n+1)], k) def findCombinations(self, nums, k): sol = [] if k==0: return sol for i in range(len(nums)): ...
9e9e0e6c5544e4d58613d2cbf808a2925c78aa40
psykidellic/python-lfu
/lfu_cache/dllist.py
6,958
3.796875
4
from typing import Any, Optional, Union, Iterable from .exceptions import OtherListElement class Element(object): def __init__(self, value: Any, dllist: 'DLList'): """Element object is an element of the linked list. value keep track of the actual value that is set by the application. :p...
818812333b5fb1224072fb0904e242c69321840b
achyutParimi/pythonPractise
/src/pythonSamples/dictionaries_samples.py
1,746
3.96875
4
# -*- coding: utf-8 -*- """ Created on Thu Nov 23 14:11:20 2017 @author: aparimi """ # Definition of countries and capital print("How to relate 2 lists") countries = ['spain', 'france', 'germany', 'norway'] capitals = ['madrid', 'paris', 'berlin', 'oslo'] # Get index of 'germany': ind_ger ind_ger=countries.index('ge...
73ce46804c2b26dd917d733073cb1bcc0269304f
gui2one/python_playground
/game_of_life/modules/myWheel.py
2,280
3.734375
4
import pygame import math class myWheel(): def __init__(self,_screen, parent=None): self.screen = _screen self.position = [50,200] self.radius = 30.0 self.segs = 10 self.rotation = 0.0 self.reverse = False self.parent = parent self.radialOffset = 0.0 ...
28380368fd78673a29f8d0eec8806494b6bed0f6
green-fox-academy/criollo01
/week-03/day-03/09_centerbox.py
467
4.1875
4
# create a square drawing function that takes 1 parameter: # the square size # and draws a square of that size to the center of the canvas. # draw 3 squares with that function. from tkinter import * root = Tk() canvas = Canvas(root, width='300', height='300') canvas.pack() def center_box(size): square = canvas....
087377ef1cf9450a91e5c0006717986359d10dc1
ire-and-curses/python_examples
/type_check_args.py
871
4.1875
4
#!/usr/bin/env python ''' type_check_args.py - Test a string for possible interpretation as an int or float Author: Eric Saunders October 2011 ''' import sys def cast_string(incoming): try: cast_value = int(incoming) print "Type determined: '%s' is an int" % incoming return cast_value ...
d74070b6781ac9f83529d6ef78e1a722fb84c7c2
flandalanda/t3-IDO
/solver.py
3,751
3.78125
4
#!/usr/bin/python # -*- coding: utf-8 -*- from collections import namedtuple Clinic = namedtuple("Clinic", 'index cost regions') def trivial_cover(regions_count, clinics_count, clinics): """ picks and sets one-by-one until all the regions are covered """ clinics_built = [0]*clinics_count coverted = set()...
9a415f1a0bb7bdfecbdbd1a0359436790dc58dd2
jriall/algoexpert
/medium/invert_binary_tree.py
1,244
4.40625
4
# Invert Binary Tree # Write a function that takes in a Binary Tree and inverts it. In other words, # the function should swap every left node in the tree for its corresponding # right node. # Each BinaryTree node has an integer value, a left child node, and a right # child node. Children nodes can either be BinaryTre...
0bf8e1985cfc7cb893a5ce96a1b1630e78135a41
asharkova/python_practice
/SpecialTask/cycleDetect.py
4,064
3.90625
4
from operator import mul def base10ToOther(number, base): """ Converts number from base 10 to another base number {int} -- number as the string that needs to be converted base {int} -- original base of the integer return {str} -- integer as a string """ e = number//base q = number % b...
5f6c7402623470b5aa8f4207af91bac2f2134024
jpalisoul/CS301-Algorithms
/Assignment 1 - Searching Algorithms/PalisoulJosephSearchTester.py
2,481
3.84375
4
######################################################################### # Assignment 1 - Searching Algorithms (Tester) # # # # PROGRAMMED BY Joe Palisoul (January 10, 2015) # # CLASS CS30...
881b15f18ef2b503dbf4139904f26d9467e132ac
Serjio2888/BakaevDecor
/test_whenthen.py
1,615
3.5625
4
from unittest import TestCase from whenthen import WhenThen class WhenThenTest(TestCase): def whenthen(func): return WhenThen(func) @whenthen def funny(x): x = x+2 return x def test_base(self): self.assertEqual(5, self.funny(3)) def test_main_functional(se...
32bf48b56dccf8b223deba03ad4260ad45c90803
ChrisMarriner/cp1404practicals
/prac_03/broken_score.py
731
3.921875
4
""" Christopher Marriner CP1404/CP5632 - Practical Broken program to determine score status PSEUDOCODE: get score if score is between 0 and 50 display "bad" else if score is between 50 and 90 display "pass" else if score is between 90 and 100 display "Excellent" else display "Invalid score" """ im...
e4fa93d0b873b7279e46777b6d92743a84c31224
AdamZhouSE/pythonHomework
/Code/CodeRecords/2592/60686/315543.py
263
3.6875
4
nums = int(input()) list_all = [] for i in range(nums): list_all.append(int(input())) if nums == 1 and list_all[0] == 2: print(8) elif nums == 1 and list_all[0] == 3: print(22) elif list_all[0] == 4: print(41) elif list_all[0] == 5: print(69)
dd88c329d7f72d9e4fa37e0630bf11e49cea066b
liujb/hello-py
/syntax/raiseException.py
548
3.671875
4
# FileName:raiseException.py class DefinedException(Exception): def __init__(self, length, least): Exception.__init__(self) self.length = length self.least = least try: s = raw_input('Enter something-->') if(len(s) < 3): raise DefinedException(len(s), 3) #raise EOFError else: pass ex...
c6dce5e883c42d78240882b8cc9c5861ae627862
NBakalov19/SoftUni_Python_Fundamentals
/01.Python_Intro_Functions_And_Debugging/numbers_with_step.py
124
3.703125
4
start = int(input()) end = int(input()) step = int(input()) for number in range(start, end, step): print(number)
19f8ad33fd3a26fe44d4046285ca5a35afa5bf95
HarrisLawYF/Python_Regression_Models
/Multiple Linear Regression/multipe_linear_regression.py
3,790
3.734375
4
# -*- coding: utf-8 -*- """ Created on Mon Feb 4 00:20:56 2019 @author: lawha """ import numpy as np import matplotlib.pyplot as plt import pandas as pd # Import dataset dataset = pd.read_csv('50_Startups.csv') # first is Y, second is X X = dataset.iloc[:,:-1].values y = dataset.iloc[:,-1].values # Encoding catego...
4ce861e2cfc7420791de9bd9f44e1931f849db33
AndreiTsukov/PythonFiles
/Classwork/pygame/lesson5/classificatsion1.py
911
3.984375
4
''' class cat(): name = "" color = "" weight = 0 def meow(self): print('meow,',self.name) animal = cat() animal2 = cat() animal.name = "Клубок" animal.color = "Красный" animal.weight = 3 animal2.name = "Зеленка" animal2.color = "Красный" animal2.weight = 4 animal2.meow() animal...
cdd9103b9c67006b07d7f645652bf7ac51a2611e
joyDDT/python_code
/py/Python_Crash_Course/favorite_numbers.py
237
3.671875
4
favorite_numbers = { 'adam':[1,5,78], 'cooper':[2,5,45], 'anna':[4,5,666], } for K,V in favorite_numbers.items(): print(K.title() + " 's favorite numbers are: ") for num in V: print(num) print('\n')
7acf60832262de454a333594ee5a1e6a360870c6
tranquilshore/Daily-Coding-Problems
/DCP_169_merge_sort_linked_list.py
1,174
4.125
4
class Node: def __init__(self,val): self.val = val self.next = None head = Node(3) head.next = Node(6) head.next.next = Node(2) head.next.next.next = Node(1) head.next.next.next.next = Node(9) def merge_sort(head): if head is None or head.next is None: return head #get head...
079f3a9169e996032db2a6c1bf93746b3f3cdd16
DalengaMRX/Python
/Exercicios/exe35.py
565
4.28125
4
"""Desenvolva um programa que leia o comprimento de três retas e diga ao usuário se elas podem ou não formar um triângulo. """ print("") line_a = int(input("Enter the size line A: ")) line_b = int(input("Enter the size line B: ")) line_c = int(input("Enter the size line C: ")) print("") if (line_b - line_c) < line_a...
93b054f4c12af5344b93ead842549aac93a3e0c1
prof2mathangellier/SNT
/Python/allumettes.py
5,229
3.71875
4
#!/usr/bin/env python3 import turtle import sys #Les constantes NOMBRE_ALLUMETTE = 19 HAUTEUR_BOIS_ALLUMETTE = 50 HAUTEUR_ROUGE_ALLUMETTE = 10 COULEUR_BOIS_ALLUMETTE = "#CDA88C" COULEUR_ROUGE_ALLUMETTE = "#DC5844" COULEUR_FOND = "#8CCDC4" TITRE = "Jeu des allumettes" TAILLE_ECRITURE = 26 TAILLE_ECRITURE_2 = 16 #Les ...
cfadec0797efe3ba5e383f200446cd208104b877
Uttam1982/PythonTutorial
/08-Python-DataTypes/Dictionary/08-dictionary-comprehension.py
3,458
3.796875
4
#********************************************************************************************** # Dictionary comprehension #********************************************************************************************** # Dictionary comprehension is an elegant and concise way to create a new dictionary # from an itera...
1d5e7550caf11f6c1165aba2bf670f1de395a1dc
KMFtcy/100examples
/test_3.py
271
3.734375
4
# -*- coding: UTF-8 -*- import math import cmath n = 0; while True: temp_a = n+100; temp_b = n+268; sqrt_a = math.sqrt(temp_a); if sqrt_a.is_integer(): sqrt_b = math.sqrt(temp_b); if sqrt_b.is_integer(): print n; n = n+1;
f4ceb5e1bff1a17757f1f3b256dd656978a811fa
BingSuYam/Python_work
/practice.py
692
3.515625
4
name = "해피" animal = "고양이" age = 4 hobby = "낮잠" is_adult = age >= 3 print ("########################################") print ("우리집 " + animal + "의 이름은 "+ name +"이예요") hobby = "츄릅" #print ( name + "는 "+ str(age) +"살이며, "+ hobby+"을 아주 좋아해요") print ( name ,"는 " , age ,"살이며, ", hobby,"을 아주 좋아해요") print ( name+"는 어른일까요? "...
35e6bc14a4be05639fe7e19b147dd615f873189f
jonfisik/ScriptsPython
/Scripts10/Script85.py
663
4.15625
4
'''Exercício Python 085: Crie um programa onde o usuário possa digitar sete valores numéricos e cadastre-os em uma lista única que mantenha separados os valores pares e ímpares. No final, mostre os valores pares e ímpares em ordem crescente.''' numero = [[],[]] print('-+-'*15) valorProv = 0 for c in range(1,8): val...
4ab03c34af6877a72f8b3993850632983d8e7020
sarari0318/basic-data-structures
/DataStructures/array.py
1,896
3.53125
4
class MyArray: def __init__(self): self.data = {} self.length = 0 def __str__(self): return str(self.__dict__) # 引数に指定されたindexに該当する要素を取得するメソッド def get(self, index): return self.data[index] # Arrayの一番最後に要素を追加するメソッド def push(self, item): # self.length-1が現...
80a805a412485f6d6f1ff88d95c67be9dcfe77d0
RaviAnthony/Python-practice-
/module.py
392
3.703125
4
""" import tuple.py def linecount(filename): count = 0 for line in open(filename): count += 1 return count print linecount('tuple.py')""" hello = [5,6,9,10] challo = [5,6,9,10] print hello print challo def compare(x,y): if set(hello) & set(challo): print " number are found" ...
144ddfb08f047afa62d0604e28e75c9b06cb0453
nandhinipandurangan11/CIS40_Chapter3_Assignment
/CIS40_Nandhini_Pandurangan_P3_5.py
1,452
4.6875
5
# CIS40: Chapter 3 Assignment: P3.5 Nandhini Pandurangan # This program uses a function to solve problem 3.5 # P3.5: Write a program that reads three numbers and prints "increasing" # if they are in increasing order, "decreasing" if they are in decreasing order # and neither otherwise. Here, "increasing" means strictl...
43cc2ec6481af37e2d57c4c71cb1defbb90603c4
Shinnnyshinshin/LeetCode
/2_AddTwoNumbers_LeetCodeDriver.py
3,770
3.703125
4
#------------------------------------------------------------------------------- # #------------------------------------------------------------------------------- # By Will Shin # #------------------------------------------------------------------------------- # LeetCode prompt #----------------------------...
c1673b0c1ed33aefe871ea4f222db19427bf8cc3
chr1shr/am205_examples
/4_optimization/iter_2d.py
490
3.875
4
#!/usr/bin/python3 from math import sqrt # Function to perform root-finding on def f(x1,x2): return (x1*x1+x2*x2-1,5*x1*x1+21*x2*x2-9) # Function to print out solution def print_sol(k,x1,x2): (f1,f2)=f(x1,x2) print("%4d %18.12g %18.12g %19.12g %19.12g" \ %(k,x1,x2,f1,f2)) # Define starting posi...
2022cc30acbf51c358268982b9280ca2859ef041
chnbin/CodeSnippet
/unittest/wordExtension.py
785
3.546875
4
class Solution(object): def findWordExtension(self, word): if not word: return [] word = word.lower() res = [] prev = None start = end = 0 for i in range(0, len(word)): if not prev: start = i prev = word[i] elif prev == word[i]: end = i elif pr...
d4ba8ff5aac313dfdce73e210eaeed76a9d3eabb
nightelf/hackerrank
/algorithms/number-theory/restaurant/restaurant.py
717
3.640625
4
__author__ = 'jared' from fractions import gcd from sys import stdin, stdout """ Problem: Martha is interviewing at Subway. One of the rounds of the interview requires her to cut a bread of size l x b into smaller identical pieces such that each piece is a square having maximum possible side length with no left over ...
3facea8f3adaf2779354c5c98b7fe646bfe402fa
jarrisonfor/DAW-Python
/Tema 1/1.6.py
416
3.9375
4
""" A-1.6 - Operaciones aritméticas (V). Aplicar descuentos Escribir un programa que solicite al usuario un número y le reste el 15%, almacenando todo en una única variable. A continuación, mostrar el resultado final en pantalla. Ejemplo de ejecución: Ingresá un número: 260 Descontando el 15% queda: 221.0 """ numer...
fa6a6f4fce1bd70a22631cda3ae1efff88086a40
AnatolyDomrachev/karantin
/is28/garaev28/lab8/Zad6_2.py
397
3.640625
4
def array_inp(a): b=[] f=open(a,'r') x=f.readline() while x!="": c=x.split(":") z={'1':c[0],'2':int(c[1])} b.append(z) x=f.readline() f.close return b def search(a,s): for i in range(len(a)): if (str(b[i]['1']) == s)or(str(b[i]['2']) == s): print (b[i]) a=input('Введите имя файла: ') s=input('В...
b16a9bb88c1a58ec8442d57246e2608d847f0496
Aasthaengg/IBMdataset
/Python_codes/p03456/s518012721.py
77
3.515625
4
a,b=input().split() c=int(a+b) d=c**(1/2) print("Yes" if int(d)==d else "No")
254f04dc58fc7c33304eae24d890bdb07fe06afc
iskenderunlu/Algorithms-Data-Structures
/Algorithms/bitwiseimplementation/reverse_bits.py
243
4.09375
4
#!/usr/bin/python def reverse_bits(x): reverse = 0 while x: reverse = (reverse << 1) + (x & 1) x = x >> 1 return "{0:b}".format(reverse) if __name__ == "__main__": calculated = int(raw_input(),2) print(reverse_bits(x = calculated))
5b17743bc737d638168f474ccf3a0445450572c4
srushd/Author-identification
/SVM(slicing,C).py
1,175
3.5
4
#!/usr/bin/python """ This is the code to accompany the Lesson 2 (SVM) mini-project. Use a SVM to identify emails from the Enron corpus by their authors: Sara has label 0 Chris has label 1 """ import sys from time import time sys.path.append("C:/Users/Srushti/Desktop/ML/ML udacity/ud120-proj...
fd4d725e5b2f5fd607b843926277d92419646aed
HSSBoston/sir-covid
/newly-infected-decay.py
700
3.5
4
import matplotlib.pyplot as plt plt.figure(figsize=(6,9)) days = 3 yValues1 = [] yValues2 = [] yValues3 = [] yValues4 = [] yValues5 = [] yValues6 = [] for x in range(days + 1): y1 = 10 * 1 ** x y2 = 10 * 0.75 ** x y3 = 10 * 0.5 ** x y4 = 10 * 0.25 ** x y5 = 10 * 0.125 ** x y6 = 10 * 0 ** x ...
32a6bff16b5f6bdc3acebd55343daf6429fdc2c5
petersont/landscape
/landscape.py
5,340
3.703125
4
from graph import * import random def rand(A, B, V): return Vector((B-A) * random.random() + A, (B-A) * random.random() + A, V * random.random()) def rand_with_height_function(A, B, height_function): x, y = random.random(), random.random() z = height_function(x, y) return Vector((B-A) * x + A, (B-A) ...
c9e8e2156a37388606e090b599a17011aefdedd6
ShubhamKulkarni1495/DSA
/DSA/Sorting/bubble.py
331
3.703125
4
def buuble_sort(list1): i=0 temp=0 while(i<len(list1)-1): j=0 while(j<len(list1)-1): if(list1[j]>list1[j+1]): temp=list1[j] list1[j]=list1[j+1] list1[j+1]=temp j+=1 i+=1 print(list1) a=[5,3,8,1,7,9,4] buu...
77a5392c299662f5d9094ad235b210d225d30bf3
Will-is-Coding/exercism-python
/acronym/acronym.py
618
3.78125
4
import re def abbreviate(unabbreviated): prefaceAcronym = re.match('^([A-Z]+)', unabbreviated).group(1) if len(prefaceAcronym) > 1: return prefaceAcronym else: unabbreviated = ' '.join([ word[0].upper() + word[1:] for word in re.sub('\W', ' '...
2c260f6b3b50a1433f0554e2fc31a966c31d5fda
kristen-foong/spja
/labs/10/solutions.py
2,259
3.78125
4
import queue def parse_graph(path): with open(path, "r") as f: graph = [[] for _ in range(int(f.readline().strip()))] for line in f: x, y = line.split("-") graph[int(x)].append(int(y.strip())) return graph def shortest_path(graph, source, destination): visite...
262dfa884a95829580c117e44e41ab63960af9d8
GargNishant/AL-DS
/sorting/recuresive_bubble_sort.py
455
3.859375
4
import random def sort(arr, last_index=None): if last_index is None: last_index = len(arr) if last_index == 1: return for i in range(last_index-1): if arr[i] > arr[i+1]: arr[i], arr[i+1] = arr[i+1], arr[i] return sort(arr, last_index=last_index-1) if __name__ == ...
3100390a37460577d4ed6c9b09d592c558020e22
Peter-J-Brown/Common-Problems
/Arrays Questions/Missing Number.py
247
4.0625
4
sorted_list10 = [1,2,3,4,5,7,8,9,10,11,13,15,16,17,18,19,20] print(sorted_list10[-1]) def find_missing(array): return [x for x in range(array[0], array[-1]+1) if x not in array] print("This missing number is:", find_missing(sorted_list10))
b37f39b9e6f2064c7ad15b480581ad428406dcf0
chanvolodya/CodeChalange
/Day3/Theory/ClassDatabase.py
912
4.21875
4
import sqlite3 from sqlite3 import Error class Database: '''Class DATABASE store data of students and their departament''' def __init__(self,name_database): self.name_database = name_database def create_database(self): """Create data base""" conn = None try: con...
e9d62f20b7539c731e8392797178a9ac2ddb4fee
akhandsingh17/assignments
/topics/Arrays/SubArrayKSum.py
796
3.859375
4
""" Given an array of integers nums and an integer k, return the total number of continuous subarrays whose sum equals to k. Example 1: Input: nums = [1,1,1], k = 2 Output: 2 Example 2: Input: nums = [1,2,3], k = 3 Output: 2 """ def AllSubArraySum(nums, k): result = [] dict = {} dict.setdefault(0, []...
0c334f6a6d37217fda79cefacee2c3acb2c22bb8
akarshan96/Coding-Problems
/Longest_Bitonic_Subsequence.py
878
3.671875
4
''' https://www.interviewbit.com/problems/length-of-longest-subsequence/ Microsoft ''' class Solution: # @param A : tuple of integers # @return an integer def longestSubsequenceLength(self, arr): n = len(arr) dp = [1] * n dp2 = [1] * n sum_arr = [] for i in ...
b180c1df990f6f59959e70a571699f39d1f324f8
ebby-s/ALevelCS
/Python Challenges/ebbyTU05.py
126
3.875
4
rain = input("is it raining") if rain == "yes": print("GET TO THE ARK!!!") else: print ("Im bored, Im going to sleep")
a836eb320df1873a71c864a586a5e218693c5c3d
AdamZhouSE/pythonHomework
/Code/CodeRecords/2158/60749/252930.py
2,436
3.53125
4
def myAtoi( s: str) -> int: #判断输入的字符串是否为空,或者仅包含空白字符 if s=='' or s==' ': return 0 #生成两个列表,integer1_list用于判断首个非空字符是否为有效字符 #integer2_list用于判断当首个非空字符是为有效字符时,下一个字符是否为数字 integer1_list=['0','1','2','3','4','5','6','7','8','9','-','+'] integer2_list=['0','1','2','3','4','5','6',...
812ad9e4e6c2e9e2f6ab809c918de51684412122
Renugadevi-S/python3
/5_reverse_name.py
318
4.59375
5
#This program is used to find reverse the the name first_name=(input("")) sec_name=(input("")) #This print is print the sec_name #in reverse manner and first_name as like sec_name print(sec_name[-1::-1] ,first_name[-1::-1]) #This print is uded to print the sec_name and first_name print(sec_name,first_name)
a65613f6624a3e70f9a0ad2effb2bec1a9a93dc0
trtufts/CS683
/Homework 1/Prob_5_3.py
5,728
3.78125
4
# -*- coding: utf-8 -*- """ Created on Sun Sep 21 19:56:33 2014 Python 2.7 @author: Tim Tufts CS 683 HW 1 Problem 5.3 Solves the Knight's Shortest Path problem with the heuristic function designed in problem 5.2 (For Github: this problem finds the shortest path a knight on a chessboard can take to go from (0,0) to (x...
f6fa3acc88a87edd5161f97a85b591c5bfee79c1
rashidulhaq-coding/Machine-Learning-by-sentdex
/revision.py
320
3.75
4
import pandas as pd df = pd.DataFrame( { "a" : [1,3,5], "b" : [7,4,5] }, index = [1,2,3] ) # print(df) df02 = pd.DataFrame( [[0,4,5], [2,5,6], [4,5,6]], index = [0,1,3], columns= ['a','b','c'] ) # df02.rename(columns = {"a":"z"},inplace = True) print(df.head())
dca403049c1b1adbdfceaf6ee767241bc9a33094
wanglei949758173/study
/ProgrammingLanguage/python/code/20.异常.py
707
3.84375
4
# 异常 print('hello') try: print(10 / 0) # ZeroDivisionError: division by zero except: print('出错了') else: print('未出错') # 异常类型 try: print(c) print(10 / 0) except NameError: print('出现 NameError') except ZeroDivisionError: print('出现 ZeroDivisionError 异常') # 可以在异常类后边跟着一个 as xx 此时xx就是异常对象 except E...