blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
ca208c8bc7a37c214ddb26959219ab3413fe327d
TarekSw/SMTP-GMAIL
/smtp_network.py
5,301
3.609375
4
#First thing to do: # - Got to the google account settings and turn On Less Secure Apps feature. # in order to be able to send email from an outside application using the Gmail SMTP server. from email.mime.multipart import MIMEMultipart from email.mime.text import MIMEText from email.mime.base import MIMEBase from tk...
75f6d0e33ef63f984f464c15e50ac5cff6cf3204
green-fox-academy/wenjing-liu
/week-03/day-01/bank-account/usa_dollar.py
354
3.765625
4
from currency import Currency class USADollar(Currency): def __init__(self, value): super(USADollar, self).__init__(value, 'USD', 'Federal Reserve System') ''' ### USADollar **`USADollar` is a `Currency`** - It must accept a value. - The code must be "USD" by default. - The central bank name must be "Feder...
dae698c381c1d6a3a024f1b92c2fc79aad990b96
holmes1313/Leetcode
/702_Search_in_a_Sorted_Array_of_Unknown_Size.py
2,302
3.84375
4
# -*- coding: utf-8 -*- """ Created on Tue Nov 12 12:46:12 2019 @author: z.chen7 """ # 702. Search in a Sorted Array of Unknown Size """ Given an integer array sorted in ascending order, write a function to search target in nums. If target exists, then return its index, otherwise return -1. However, the array size ...
2b8835db02a4d12bf2f1634cee1b314e8ff862e9
MaxwellClemens/AdventOfCode2017
/12/day12.py
2,928
3.5
4
import math def calculateChangeToVelocities(currentPositions, allPositions, currentIndex): changeToVelocities = [0,0,0] for index, position in enumerate(allPositions): if index == currentIndex: continue for k in range(3): if currentPositions[k] < position[k]: ...
d9442feba85d179b29b482bd6e804ac30afb4c6d
manasbundele/computer-vision-projects
/modified-mnist/resnet_mnist.py
5,003
4
4
''' By: Manas Bundele Project Constraints: The goal is to train a CNN to recognize images of digits from the MNIST dataset. This dataset consists of gray level images of size 28x28. There is a standard partitioning of the dataset into training and testing. The training has 60,000 examples and the testing has 10,000 ...
c40573d0eaaed88658b7e7c0ebe72df1a361448b
garret1evg/cousera_DB
/week3/problem4.py
876
3.703125
4
import MapReduce import sys """ Word Count Example in the Simple Python MapReduce Framework """ mr = MapReduce.MapReduce() # ============================= # Do not modify above this line def mapper(record): # key: document identifier # value: document contents key = record[0] friend = record[1] ...
14e348d7ea30d522b9646e29dc194b9cea8da561
BIOSBrothers/IS-105_2016_Gruppe1
/ICA05/Search5 copy.py
497
3.609375
4
from timeit import Timer def fillList(l, n): l.append(range(1, n + 1)) l = [] fillList(l, 100) def search_fast(l): for item in l: if item == 10: return True return False def search_slow(l): return_value = False for item in l: if item == 10: return_value =...
6db846e0b92683c11ad70b82d6ec926f37844fb0
Bhawna4tech/Smart-Audio-Book-Reader
/rpi_shutdown.py
415
3.765625
4
#!/usr/bin/python # Import the modules to send commands to the system and access GPIO pins import RPi.GPIO as gpio import os #Set pin numbering to board numbering gpio.setmode(gpio.BOARD) #Set up pin 15 as an input gpio.setup(13, gpio.IN) ###GPIO PIN FOR SHUT DOWN # Set up an interrupt to look for pressed button g...
dc573ba68e7849479839dc2d255f827500bc09bc
kodyamani/ChatBox
/ChatBox.py
954
3.9375
4
def intro(): print("Hey! I'm Penelope") def process_input(solution): greeting = ["hi", "hello", "what's up", "hello", "wessup", "wassup", "hey"] goodbye = ["bye", "see ya", "kick rocks", "goodbye"] if is_valid_input(solution, greeting): say_greeting() elif is_valid_input(so...
026f40e779d1da1faabc471f22cc52cb33b3d84b
mduanaa/IoT
/Linux/echo_server.py
1,067
3.53125
4
import socket import sys # local_host = '127.0.0.1' port = 49999 # create TCP/IP sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) # bind the socket to the port server_address = ('localhost', port) print('starting up on {} port {}'.format(*server_address)) sock.bind(server_address) # call listen() to push in...
2a82df7420aada6ffbc3e3979026470ebd989c3b
StaticNoiseLog/python
/calculus_basic/derivative_and_integral.py
622
3.84375
4
def f(x): return x**2 def derivative(x): h = 1./1000. rise = f(x+h) - f(x) run = h slope = rise / run return slope def integral(startingx, endingx, numberOfRectangles): width = (float(endingx) - float(startingx)) / numberOfRectangles runningSum = 0 for i in range(n...
38c96eb9aa0327766b82b18b0a9cee213a4e5554
rfabio8770/tkintersimple
/main.py
920
3.859375
4
from tkinter import Tk, Label, Entry, Button ventana = Tk() ventana.title("Ejemplo de Place") ventana.geometry("400x200") def fnsuma(): num1 = txt1.get() num2 = txt2.get() num3 = float(num1) + float(num2) txt3.delete(0,'end') txt3.insert(0, num3) lbl1 = Label(ventana, text="Primer número:",bg="ye...
cabc1f11a7d69bdd776e1a1d6c5b4db78bff24ed
mahimasunny/home_security
/project/motion_detector.py
1,564
3.5
4
# This file implements the motion detector functionality import RPi.GPIO as gpio import io import picamera import cv2 import time import numpy import face_recognition_impl from IPython.display import display from PIL import Image, ImageDraw import datetime led=17 # pin 18 is connected to the PIR sensor OUT pin pir=18...
cef6065e9ae5e7e0d5cd0014d0bf947ad6cbe7ab
Mon8Cats/Python100Days
/Study/object_oriented/class_test.py
2,603
4.0625
4
class BookShelf: def __init__(self, *books): self.books = books def __str__(self): return f"Bookself with {len(self.books)} books." class Book: def __init__(self, name): self.name = name def __str__(self): return f"Book {self.name}" book = Book("Harry Potter") book...
c7901abc836b8bdf8a257df906a6d1b47096fe23
jessie-JNing/Algorithms_Python
/Recursion_DP/Fibonacci_robotXY.py
1,293
4.46875
4
#!/usr/bin/env python # encoding: utf-8 """ Imagine a robot sitting on the upper left corner of a X by Y grid. The robot can only move in two directions: right and down. How many possible path are thre for the robot to go from (0,0) to (X, Y)? FOLLOW UP: Imagine certain spots are "off limits", such that the robot can...
c63b6402e84f5761cdf7654e7f8d0bf641e3dc8d
MuideenAM/MyPythonWorks
/tryme4.py
359
3.78125
4
def new_line(): print('.') def three_lines(): new_line() new_line() new_line() def nine_lines(): three_lines() three_lines() three_lines() def clear_screen(): print('Calling clear_screen()') i = 1 while(i <= 2): nine_lines() three_lines() i += 1 new_line() print('Printing nine lin...
51a5bce89e79e41ed0ffde5c6af8e2e05602e83b
daniel-reich/ubiquitous-fiesta
/KQe5w8AdSLbweW8ck_20.py
387
3.578125
4
def char_at_pos(r, s): if type(r)==list: if s=='even': return [r[i] for i,j in enumerate(r) if i%2!=0] else: return [r[i] for i in range(len(r)) if i%2==0] else: if s=='even': return ''.join([r[i] for i,j in enumerate(r) if i%2!=0]) else: ...
89c15deca8a59ab75b308974f3fc63b96e8b96cf
betuppumo/sxpt
/python/5-1/2.py
516
4.15625
4
class People: # 请在下面填入声明两个变量名分别为name和country的字符串变量的代码 #********** Begin *********# #********** End **********# def introduce(self,name,country): self.name = name self.country = country print("%s来自%s" %(name,country)) name = input() country = input() # 请在下面填入对类People进行实例化的代码,对象为p...
61393f769fbc92271fc4d0a56ec55d86c388cf2d
pythonthings/lettersmith_py
/lettersmith/lens.py
3,377
3.765625
4
""" A minimal implementation of Haskel-style lenses Inspired by Elm's Focus library and Racket's Lenses library. Lenses let you create getters and setters for complex data structures. The combination of a getter and setter is called a lens. Lenses can be composed to provide a way to do deep reads and deep writes to ...
be1e531d83c260837aefd67c3e7bc848dded41bb
ShourjaMukherjee/Dummy
/11thcodes/Remedials/10) Aaquib Pattern (1).py
730
4.0625
4
def pattern(n): #Defining a function to #display the required pattern for i in range(1,2*n,2): for j in range(2*(n-1),i,-2): #range for spaces print " ", for k in range(1,i+1): ...
3d59a6b2ca83bff422c742c023e691acce9fc3fb
manuelamercado/structures-algorithms-nanodegree-projects
/P1/task2.py
2,565
3.5625
4
""" Finding Files For this problem, the goal is to write code for finding all files under a directory (and all directories beneath it) that end with ".c" Here is an example of a test directory listing, which can be downloaded here: ./testdir ./testdir/subdir1 ./testdir/subdir1/a.c ./testdir/subdir1/a.h ./testdir/subd...
5efbfe09cbc9b17e9b92a8ca4af6b216d063794f
jessicahuang513/data_structures
/binarytree.py
908
3.921875
4
class Node: def __init__(self, val): self.val = val self.left = None self.right = None class BinaryTree: def __init__(self): self.root = None def add(self, val): newNode = Node(val) if(self.root == None): self.root = newNode else: self._add(self.root, newNode) def _add(self, root, node): if...
d51c6790c2bc701d0e0fd207099f2eacb8beb3a2
coolsnake/JupyterNotebook
/new_algs/Sequence+algorithms/Selection+algorithm/A-FnReliefF.py
605
4.3125
4
#https://medium.com/@yashdagli98/feature-selection-using-relief-algorithms-with-python-example-3c2006e18f83 from ReliefF import ReliefF import numpy as np from sklearn import datasets import pandas as pd #example of multi class problem iris = datasets.load_iris() X = iris.data Y = iris.target fs = ReliefF(n_neighb...
b244234b58d9af3cfb511d93d799cdaa54a3a4ce
PO6OTAHK/Pixel-Warships
/projectile/projectile.py
577
3.65625
4
import pygame class Projectile(pygame.sprite.Sprite): """Класс описывающий снаряд, принимает скорость, урон, тип, координаты, размер, картинка, группы(групп неограниченное кол-во)""" def __init__(self, speed, damage, typke, position, size, img, *groups): super().__init__(*groups) self.speed = sp...
3111767aa96403246f4a01e739684fefcde8b4cd
star428/python_learn_X2
/function/define.py
237
3.546875
4
import math def drop(): print("i am drop") def my_sin(number): if not isinstance(number, (int, float)): raise ValueError("it's not number") else: return math.sin(number) print(my_sin(45)) print(math.pi)
1a263ffb40e61b54e800069a9a41fd055be8adca
nilizadeh/twitter-glass-ceiling
/code/gender_by_name.py
3,730
4.0625
4
import os import io import sys class gender(): def __init__(self, indir, outdir): self.dir = indir self.outdir = outdir self.names_female = {} self.names_male = {} def get_names_counts(self): ''' The names for each year are listed in a file. Read all the files and combine the info from all the yea...
6e959809bfe55899f1e93cfa63fbd8e405fce7f0
dhackner/Fun-Puzzles
/AllPossiblePaths.py
1,972
3.578125
4
#!/usr/bin/env python """Number of nonintersecting paths in an n X n grid from (0, 0) to (n, n) 1x1 = 1 2x2 = 2 3x3 = 12 4x4 = 184 5x5 = 8512 This pattern is OEIS A007764 - number of nonintersecting (or self-avoiding) rook paths joining opposite corners of an n X n grid (according to OEIS): 6x6 = 1262816 7x7 = 57578...
e7b05d6b3399d423d199cb20fdc74880d291e1ed
Totoro2205/python-rush-tasks
/level-1/task-1/task-1-44-1.py
459
4.0625
4
#!/usr/bin/env python3 #coding: utf-8 """ Решение без проверок на ошибки ввода """ print('Расчет площади и периметра прямоугольника') a = float(input('Введите первое число:')) b = float(input('Введите второе число:')) print("Площадь прямоугольника: ", a * b) print("Периметр прямоугольника: ", 2 * a + 2 * b)
ae4751999f65ec7fc7341d428c016c6595b78ef1
hestad/advent-of-code
/2018/day8/day8_tree.py
1,754
3.5625
4
from dataclasses import dataclass from typing import List @dataclass class Node: children: List[any] metadata: List[int] def metadata_sum(self) -> int: return sum(self.metadata) def has_no_children(self) -> bool: return len(self.children) == 0 def children_count(self): r...
87fc10616dbec83ebee2fba200cdde45118b98e8
ffionRichards/university_DataMining
/Question2.py
878
3.59375
4
from random import choice from numpy import array, dot, random from pylab import plot, ylim #Creating a step function stepfunction = lambda x: 0 if x < 0 else 1 #inputting training data training_data = [ (array([-0.1,0.0]), 0), (array([0.0,9.0]), 0), (array([10.0,0.0]), 1), (array([10.0,8.0]),...
2c552fcc2b2dfbd12efbacc0d159cf20dc0ee52a
sinadadashi21/Wave-1
/making-change.py
575
4.03125
4
cost = int(input("Enter the number of cents: ")) toonies = cost // 200 after_toonies = cost % 200 loonies = after_toonies // 100 after_loonies = after_toonies % 100 quarters = after_loonies // 25 after_quarters = after_loonies % 25 dimes = after_quarters // 10 after_dimes = after_quarters % 10 nickels = after_dim...
f044e58403cb79e4d7a13e597f2bffa81ec1e7a1
flfelipelopes/Python-Curso-em-Video
/ex025.py
164
3.96875
4
#Crie um programa que leia o nome de uma pessoa e diga se ela tem "SILVA" no nome. nome = str(input('Digite o seu nome: ')).strip() print('SILVA' in nome.upper())
eeee7b3c9aea694aadfffbacc942968bc2de5ded
pkenway/pearls
/3/datastructures.py
1,328
3.609375
4
letter_definitions = { 'A' : [ '1*4- ,2-A,4- ', '1*3- ,4-A,3- ', '1*2- ,2-A,2- ,2-A,2- ', '1*1- ,8-A-1- ', '2*2-A,6- ,2-A'], 'I' : [ '3*6-I', '3*2- ,2-I,2- ', '3*6-I'], } def banner(letter): if letter not in letter_definitions: ...
1c579296c85e672599ebf8b8407fb2f7aaa10dd5
jsh/fluent_python
/ch1/vector.py
1,119
4.28125
4
#!/usr/bin/env python """Demo infix operators, bool, abs, repr.""" from math import hypot class Vector: """Vectors.""" def __init__(self, x=0, y=0): self.x = x self.y = y def __repr__(self): return "Vector(%r, %r)" % (self.x, self.y) def __bool__(self): return bool(...
c9770a1675f2c9fda09114327870bd122897c88f
mcnallyd/HackerRank
/solutions/array_left_rotation.py
1,010
3.984375
4
#https://www.hackerrank.com/challenges/ctci-array-left-rotation def array_left_rotation(a, n, k): """ Rotate elements in an array of integers n = number of i tegers in a k = number of left rotations to perform a = array of integers """ if (not a) or (k == 0) or (k%n == 0): return a...
ab75761833615b9fb934bb041abaa8bd5a3225d0
chanyoonzhu/leetcode-python
/290-Word_Pattern.py
666
3.53125
4
""" - hashmap - hashmap + hashset - O(n), O(1) """ class Solution: def wordPattern(self, pattern: str, s: str) -> bool: words = s.split() if len(words) != len(pattern): return False mapping = {} # mapping: word -> char assigned = set() # assigned char ...
12369ededa7c946d6e9d85402ec1a05dfaf10707
MingYanWoo/Leetcode
/146. LRU缓存机制.py
2,847
3.796875
4
# 146. LRU缓存机制 # 运用你所掌握的数据结构,设计和实现一个 LRU (最近最少使用) 缓存机制。它应该支持以下操作: 获取数据 get 和 写入数据 put 。 # 获取数据 get(key) - 如果密钥 (key) 存在于缓存中,则获取密钥的值(总是正数),否则返回 -1。 # 写入数据 put(key, value) - 如果密钥已经存在,则变更其数据值;如果密钥不存在,则插入该组「密钥/数据值」。当缓存容量达到上限时,它应该在写入新数据之前删除最久未使用的数据值,从而为新的数据值留出空间。 # 进阶: # 你是否可以在 O(1) 时间复杂度内完成这两种操作? # 示例: # LRUCache ca...
d7f17ae6d03a2b5f5fa31c77c9cf44ee3f7ff953
Oleksiy-Yurchenko/Habit-Tracker
/analytics.py
1,059
3.703125
4
"""Module analytics contains functions tracked(), same_period(), longest_streak().""" def tracked(habits_list, tracked_status=True): """Function takes a list with habits as an argument and returned the list of habits with the tracked status set to True by default. If the flag tracked_status is set to false fu...
e1abefe002d912289e320df2c53fdd887e57b211
akash-ranjan8/PYTHON_CODES
/assert.py
81
3.65625
4
x=int(input("enter a number greater than 5")) assert x>5,"invalid!!!!" print(x)
2f0d73be05e146da50a82edb69958efcb1421ca6
md3sIam/vk_test
/Cluster.py
977
3.765625
4
class Cluster: def __init__(self, x=None, clusters=None, diff=None): if x is not None: # creation a cluster by one point self.height = 0 self.center = x self.subclusters = [] self.left_point = x # to easily compute distances self.righ...
bd9ea0976448b57b8f2cfe016435e8d065e77554
chicory-gyj/JustDoDo
/pre_test/if.py
133
3.84375
4
#!/usr/bin/python name=raw_input('enter your name:') if name.endswith('chicory'): print 'hello,chicory' else: print 'hello,strager'
d755f615039b736ac5b9098d1ee7f232891cd04a
cweiyu/a
/1.py
526
3.703125
4
# coding: utf-8 # In[16]: def reverse(word): answer = '' for i in word: answer = i + answer return(answer) a= reverse("junyiacademy") print(a) # In[19]: def reverse_2(word): word = word + " " alist = list() answer_2 = '' for i in word: if i != ' ': ans...
c22b3209660298f22a28b4af6a9d96a207a0de50
Wangbojia/CarPricePrediction
/temp01.py
157
3.5
4
class C: def f1(self,a,b): return a+b class D: def f1(self): cc = C() b=cc.f1(1,2) return b dd = D() print(dd.f1())
2f87f80e9d2dc7a45d60b6d5b143fb0e53d409a2
ishita-kumar/Applied-Algorithms-Code
/weighted scheduling.py
2,587
3.8125
4
import sys from operator import itemgetter # AIM : You are given a set of jobs. Each job i has a start time si and a finish time fi. It also has a weight wi. # Two jobs are compatible if their start-finish intervals don't overlap. The goal is to find the maximum weight # subset of mutually compatible jobs (a subset wi...
12ca7e83286e59ee6eaced776cb2c6d154b2d4c3
jhyang12345/algorithm-problems
/google_prep/dfs_stack.py
475
3.90625
4
def dfs(graph, cur): visited = {} stack = [] stack.append(cur) while stack: s = stack.pop() if s not in visited: print(s) visited[s] = True for node in graph[s]: if node not in visited: stack.append(node) # https://www.geeksfor...
559dad97bc638486b651b431b391176568a23071
zhanghua7099/LeetCode
/88.py
941
4.375
4
''' 题目:合并两个有序数组 给定两个有序整数数组 nums1 和 nums2,将 nums2 合并到 nums1 中,使得 num1 成为一个有序数组。 说明: 初始化 nums1 和 nums2 的元素数量分别为 m 和 n。 你可以假设 nums1 有足够的空间(空间大小大于或等于 m + n)来保存 nums2 中的元素。 ''' ''' 示例: 输入: nums1 = [1,2,3,0,0,0], m = 3 nums2 = [2,5,6], n = 3 输出: [1,2,2,3,5,6] ''' def merge(nums1, m, nums2, n)...
4ce6fd37558c24355ce9257ad917614c25e7dfd4
sasadangelo/pythonbyexamples
/examples/for/for.py
1,545
4.625
5
letters=['a','b','c','d'] # For loops through the list, element by element, and print it. # end =" " --> print without new line for s in letters: print(s, end =" ") # Print a new line print() # The enumerate function return two value: # - the index of the element # - the element for i, s in enumerate(letters): ...
5bcbe6fb19d30be80e07b8357ab1a3246766fcea
jamilemerlin/exercicios_python
/CursoemVideo/e078.py
626
3.953125
4
valorlista = [] for contador in range(0, 5): valorlista.append(int(input(f'Digite um número para a posição {contador}: '))) print(f'Os números digitados são: {valorlista}') ordenada = valorlista[:] ordenada.sort() menor = ordenada[0] maior = ordenada[-1] print(f'O menor número foi {menor} e está na posição ', end='...
3a27480d99a0596fad958332ad990efd60377024
youthcodeman/self-learning-python
/org.hzg.pyLearn/运算符/comparisonOperator.py
193
3.84375
4
#_*_ coding:utf-8 _*_ #比较运算符 num_a = 8 num_b = 56 print(num_a == num_b) print(num_a != num_b) print(num_a > num_b) print(num_a >= num_b) print(num_a < num_b) print(num_a <= num_b)
2d9f892c82d30052ca7a2d3e5c9a982047afb937
syn7hgg/ejercicios-python
/15_6/4.py
1,645
3.703125
4
class Student: def __init__(self, name, rut, marks): self.name = name self.rut = rut self.marks = marks def get_name(self): return self.name def get_rut(self): return self.rut def get_marks(self): return self.marks def get_avg(self): marks ...
bc2650f4d9de243d59170e315f3fd644e8df9537
Doublespe11/MiniProjects
/Basic MiniProjects/calculator.py
288
3.640625
4
# -*- coding: utf-8 -*- """ Created on Wed Jun 12 23:50:27 2019 @author: Michał """ while True: evaluation = input() if evaluation.startswith("q"): break if "^" in evaluation: evaluation=evaluation.replace("^","**") print(eval(evaluation))
45507e47d9145dc653194fa746234a9277857819
Rory-git-hub/New_Repos
/DSSK2 - Assignment A..py
1,670
3.515625
4
def bs_func(data,func,size): n = len(data) bs_reps = np.empty(size) for i in range(size): bs_reps[i] = func(np.random.choice(data, size=n)) return bs_reps #-- This is the bootstrap resampling function, which takes three arguments. #-- By iterating over an empty numpy array we can st...
727ed203e2c04978bf2adc046086c20074fb3703
kevinmandich/Bengal
/skyscrapers.py
641
3.53125
4
## skyscrapers.py ## Challenge # 120 import os import sys with open(os.getcwd()+'\\skyscrapers_example.txt', 'r') as lines: #with open(sys.argv[1], 'r') as lines: testCases = lines.read().splitlines() for bld in testCases: sky = {} sky[0] = 0 for nums in bld.split(';'): nums = nums.strip('(...
c177d09e782edabec8c2e3b1e082542d13038c95
daveinnyc/various
/python-practice/debugger.py
305
3.59375
4
# Some code to use with pdb # Use with: python3 -m pdb debugger.py def adder(number): plus_one = number + 1 return plus_one def loops(number): var_sum = 0 for i in range(number): var_sum += adder(i) return var_sum if __name__ == "__main__": print(f"Result: {loops(4)}")
6935e2dc8972447435618e95aa2c27aeb4478f50
ShinjiKatoA16/azuma-python2
/for4-06-var1.py
382
3.75
4
# python2 P37 for4-06 variation, change outer loop to while, it is easier to understand to use 2-d for loop number = int(input('input number => ')) # row = (number+4)//5 while number > 0: out_s = '' for col in range(1,6): if number > 0: # need to process more? out_s += str(col) ...
6d4386e94a65dedd65ba711e6a716bddcdadbd49
mk777/haar_trees
/coint_stat.py
1,365
3.5
4
from __future__ import with_statement from math import sqrt import sys def read_data(filename): """reads the file of results printed by haar_coint""" result={} with open(filename,'r') as file: for l in file: (n,s,vec)=l.partition('['); if s: result.setdefau...
ba1fb9c86a1298ac19a065a7f3981bd91b268d74
simonchuth/mutation_frequency
/src/plot_gene.py
5,174
3.75
4
import numpy as np import matplotlib.pyplot as plt import seaborn as sns def plot_mutation_frequency(site_list, gene_size, density=True, gene_name='', mutation_type=''): """To plot the mutation frequency of a gene Args: site_list (list of int): list containing sites of mutation gene_size (int)...
baca28082ccd70b164f0875f09026c9ef783928c
wileyj/public-python
/z-list_unique.py
652
3.5
4
class Solution(object): def uniq(self, nums): newlist = [] print "newlist: %s" % (newlist) print "list_len: %i" % (len(nums)) for i in xrange(0,len(nums)): print "i: %i" % (nums[i]) numcount = 0 for j in xrange(0,len(nums)): ...
ea4b3acae47e2d9efc754c60c6e2ed182b64f81c
rafasapiens/learning
/sqlite_3.py
252
3.578125
4
import sqlite3 connection = sqlite3.connect("Database.db") c = connection.cursor() #SQL def create_table(): c.execute("CREATE TABLE IF NOT EXISTS dados (id INTEGER, unix REAL, keyrd TEXT, datestamp TEXT, value REAL)") create_table()
e84628c2f44e65ddde433bd12b1e9c974f3586bb
gistable/gistable
/all-gists/72a0da8d9b42bed28e61/snippet.py
1,477
3.546875
4
# Tweetに含まれる単語のポジネガによる感情度の付与 # 形態要素化できた単語のうち、ポジに分類されるものを1、ネガに分類されるものを-1 # 形態要素化できた単語数で割ることで平均値を取り指標化 pn_data = [data for data in posi_nega_dict.find({},{'word':1,'value':1})] def get_emotion_value(word): ret_val = None for d in pn_data: if d['word'] == word: ret_val = d['value'] ...
478f4869577d6943b350334689c9ce81f921d57c
lodado/PS
/BOJ/10815BOJ치킨배달.py
485
3.890625
4
def scan(): return map(int, input().split()) def binary_search(arr, val): left = 0 right = len(arr)-1 while(left<=right): mid = (right + left)//2 # print(left, mid, right) now = arr[mid] if(now<val): left = mid + 1 elif(now==val): return 1 else: right = mid - 1 #print() return 0 ...
e932ad1fde72263373aaef038a9d64299bbe00c1
GabrielG-prog/EduPython
/exoPy.py
185
3.78125
4
 somme=0 nbarticle= int(input("saisir un nombre")) for n in range(nbarticle): nb=int (input("saisir nb article")) somme=somme+nb print("somme totale",somme)
0fed791153c3a399ee55d19b2c3f50804feddcc2
sadiashormin/python_problems
/Designer DoorMat.py
178
3.515625
4
n, m = raw_input().split() pattern = [('.|.'*(2*i + 1)).center(int(m), '-') for i in range(int(n)//2)] print('\n'.join(pattern + ['WELCOME'.center(int(m), '-')] + pattern[::-1]))
ab1bc02e972ccab35388c23e7615da5198030392
erzelenki/PythonLearning
/except key.py
228
3.90625
4
# how to abuse the dictionary # and how to deal with it dict = { 'a' : 'b', 'b' : 'c', 'c' : 'd' } ch = 'a' try: while True: ch = dict[ch] print(ch) except KeyError: print('No such key:', ch)
2cba051c06a405d45f6d84d4fe1ac6ced7da47bd
edarigo/python-project
/test_AverageRange.py
2,088
3.78125
4
import unittest from AverageRange import AverageRange class TestAverageRange(unittest.TestCase): '''Unit test to test the AverageRange Class''' def setUp(self): '''Set up data to be used in test''' # First matrix to test self.test_matrix = [[0,6.3,141,51,62,58.03],[0,6.6,130,54,15....
3fb50d89c90310a16cb8c5c8c1836b39152f2813
murali-kotakonda/PythonProgs
/PythonBasics1/10decotor/closures/Ex6.py
534
4.03125
4
#Functions are objects: #Python functions are first class objects. #In the example below, we are assigning function to a variable. #This assignment doesnt call the function. #It takes the function object referenced by shout and creates a second name pointing to it, yell. #Python program to illustrate functions can be t...
b502b9ceeb45c3c3be36762c9e1043ebed48072f
seonukim/Study
/keras/keras29_lstm.py
1,308
3.625
4
from numpy import array from keras.models import Sequential from keras.layers import Dense, LSTM # 1. 데이터 구성 x = array([[1, 2, 3], [2, 3, 4], [3, 4, 5], [4, 5, 6]]) y = array([4, 5, 6, 7]) y2 = array([[4, 5, 6, 7]]) # res : (1, 4) y3 = array([[4], [5], [6], [7]]) # res : (4, 1) print("x.shape : ", x.s...
0cfbcfa4108259dbf0d6e6b3054e426e81d673a4
abhishek98as/30-Day-Python-DSA-Challenge
/Tkinter/sleep method.py
479
3.75
4
#sleep() method is used to stop execution of a program temporarliy for a given amount of time . # when this function is called PVM stops program execution for given amount of time module import time for i in range (20): print(i) if(i==10): time.sleep(6) ...
9c0abe700693251b6b2ed59cfb769191bb535baf
Steinunntry/M
/25agust/27.08.Assign3.whileloops/2.First n even numbers.py
174
3.90625
4
n = int(input("Input an int: ")) # Do not change this line # Fill in the missing code below min = 1 while min <= n : if min % 2 == 0: print(min) min = n-1
810c3c24525ff1eec35f277c027e7afb6f0d46a9
ssinghaldev/interview_bit
/arrays/merge_intervals.py
4,139
3.90625
4
#https://www.interviewbit.com/problems/merge-intervals/ import bisect # Definition for an interval. # class Interval: # def __init__(self, s=0, e=0): # self.start = s # self.end = e class Solution: # @param intervals, a list of Intervals # @param new_interval, a Interval # @return a l...
c6c4655ab3f04f0dd2e604c4a9b1d30bb2af4a31
astral-sh/ruff
/crates/ruff/resources/test/fixtures/flake8_bugbear/B020.py
820
3.640625
4
""" Should emit: B020 - on lines 8, 21, and 36 """ items = [1, 2, 3] for items in items: print(items) items = [1, 2, 3] for item in items: print(item) values = {"secret": 123} for key, value in values.items(): print(f"{key}, {value}") for key, values in values.items(): print(f"{key}, {values}") ...
d3bef9b4c589605c442f92e71f7ccbed22df2b0a
hb162/Algo
/Algorithm/Ex_130420/Ex_Second_Largest_BST.py
1,147
4.03125
4
""" Given the root to a binary search tree, find the second largest node in the tree. """ class Node: def __init__(self, data): self.data = data self.left = None self.right = None def insert(root, data): if not root: return Node(data) if data < root.data: root.lef...
62c20c30feba55e9e0c28599227b9ffcaaea649a
rafaelperazzo/programacao-web
/moodledata/vpl_data/21/usersdata/120/8023/submittedfiles/exercicio24.py
359
3.9375
4
# -*- coding: utf-8 -*- from __future__ import division import math #ENTRADA n=int(input('digite o valor do primeiro numero :')) m=int(input('digite o valor do segundo numero :')) #PROCESSAMENTO mdc=1 divisor=2 while (divisor <=n): if n% divisor==0 and m%divisor==0: mdc=divisor divisor= divisor + 1 ...
3c8680cfc8a8ab86b858226b122dc663bb627eef
JosephTagirov/LW_2
/7.4.py
193
4.09375
4
from random import * x=int(input('The computer has guessed a number from 1 to 10. Try to guess it: ')) if x==randint(1, 10): print('You are right') else: print('You are wrong')
e1990259e2c3b08aac68d19f8ea009b98db3cae6
paulbright/ml_training
/Multiple Linear Regression/load_model.py
984
3.53125
4
# -*- coding: utf-8 -*- """ Created on Tue Mar 5 10:09:02 2019 @author: a142400 """ import pandas as pd import pickle as pickle # Importing the dataset dataset = pd.read_csv('50_Startups.csv') X = dataset.iloc[:, :-1].values y = dataset.iloc[:, 4].values # Encoding categorical data from sklearn.preprocessing imp...
635c55da11807353977a93fe8906d9d10d23db46
karthik-ballullaya/Kannada_OCR_TTS
/Code/KannadaTextToSpeech.py
636
3.625
4
from gtts import gTTS import os import sys # The text that you want to convert to audio _, input_file, output_file = sys.argv print(f'Reading from text {input_file}') with open(sys.argv[1], 'r', encoding='utf-8') as f: mytext = f.read() # Language in which you want to convert language = 'kn' # Passing the tex...
e8d3e93f2ff9563a830c30823830655ce70e26b5
glimperg/Lectures-Lesroosters
/classes.py
2,551
4.28125
4
class Course: """ Creates a course object containing course data and a list of students following the course. The course data is in the following format: [name, lectures, seminars, seminar capacity, practicals, practical capacity] """ def __init__(self, data, students): self.name...
b0e6712be398d1f62c99eccdfc21012bdd98c956
WilbertHo/hackerrank
/challenges/algorithms/graph_theory/even_tree/py/eventree.py
758
3.53125
4
#!/usr/bin/env python from collections import defaultdict import fileinput def build_graph(input): graph = defaultdict(list) for adj, node in input: graph[node].append(adj) return graph def subtree_count(graph, v): count = 1 queue = graph.setdefault(v, []) for v in queue: co...
d645cd08f03764e81430bae0d0254fd6aafb3ac8
Huxhh/LeetCodePy
/1-50/014LongestCommonPrefixEasy.py
1,235
3.671875
4
# coding=utf-8 """ 思路 首先找到所有字符串中长度最短的一个,将它用enumerate表示,即字符下标与字符一一对应 遍历其他字符串,每个字符与enumera中的字符比较,出现不同时返回下标得到结果 时间复杂度 O(m*n) 空间复杂度O(n) """ def longestCommonPrefix(strs): res = "" if len(strs) == 0: return res flag = 1 i = 0 for s in strs: if len(s) == 0: return res w...
cf70ec11705a585f5bedb522a074576bafcd5668
meganesu/twitter-scraper
/tweet-parser.py
190
3.71875
4
import json # Load the data from the JSON file into a dictionary named tweets tweets = json.load(open('tweets.json')) for t in tweets: # Do things with the data here! print(t["text"])
7c0b792fd02d1cd156f7c58b8b8b2cc286b802e9
Z-Clark/algorithm007-class02
/Week_01/G20200343040212/LeetCode_189_0212.py
1,349
3.5625
4
# -*- coding: utf-8 -*- # @Time : 2020-03-12 22:53 # @Author : peniridis # @Version : V0.1 # @File : leetcode_189.py # @Desc : # 给定一个数组,将数组中的元素向右移动 k 个位置,其中 k 是非负数。 # # 示例 1: # # 输入: [1,2,3,4,5,6,7] 和 k = 3 # 输出: [5,6,7,1,2,3,4] # 解释: # 向右旋转 1 步: [7,1,2,3,4,5,6] # 向右旋转 2 步: [6,7,1,2,3,4,5] # 向右旋转 3 步: [5,6...
2b41e85b88993729de188045582c0cc9ffd5e58f
djefford/hacking
/Python/theboringstuff/tablePrinter.py
682
3.765625
4
#! python3 tableData = [['apples', 'oranges', 'cherries', 'banana'], ['Alice', 'Bob', 'Carol', 'David'], ['dogs', 'cats', 'moose', 'goose']] ## Start functions def maxLength(myList): length = 0 for item in myList: if len(item) > length: length = len(...
b28d9b3621aa76fc478302cd6bad6206183559da
kiu1202/hello-world
/helloworld2
792
4.40625
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- age=20 if age>=18: print('your age is',age) print('adult') age=3 if age>=18: print('your age is',age) print('adult') else: print('your age is',age) print('teenager') age=3 if age>=18: print('adult') elif age>=6: print('teenager') else: ...
bed8b0b7d685d422f65f2d0da96302e57235d08d
Cohiba3310/BMI-Calculator
/bmi.py
403
4
4
h = input('請輸入身高(m): ') w = input('請輸入體重(kg): ') h = float(h) w = float(w) bmi = w / (h ** 2) print('您的BMI為: ', bmi) if bmi < 18.5: print('體重過輕!') elif 18.5 <= bmi < 24: print('正常範圍') elif 24 <= bmi < 27: print('過重!') elif 27 <= bmi < 30: print('輕度肥胖!!') elif 30 <= bmi < 35: print('中度肥胖!!!') elif bmi >= 35: prin...
f4eec1bd08483d69848b66631fbf3f893677b527
CS7591/Python-Classes
/1. Python Basics/2. Basic Rules/3. Data Types and Conversions.py
3,785
4.03125
4
''' Built-in Data Types In programming, data type is an important concept. Variables can store data of different types, and different types can do different things. Python has the following data types built-in by default, in these categories: Text Type: str Numeric Types: int, float, complex S...
c33571fe6158790d4e7f7006ea33132f05273f43
hendricktyler5/Simple-Encryption-Decryption
/Encryption.py
1,916
3.921875
4
""" Encryption.py Simple Encryption/Decryption Program Written by Tyler Hendrick """ def main(): while True: enOrDe = input("Enter 1 for Encrypting a message or 2 for Decrypting a message\n") if (enOrDe == 1): print "Welcome to the Encryption program" str = raw_input("Enter your string to be ...
aff697eb15c1bc18f5b73da64c646d0839e5913c
thiago02/python-fundamentals
/HandsOn/Aula05/exec1.py
852
3.6875
4
# ----- CONEXAO COM O BANCO import psycopg2 con = psycopg2.connect( "host=%s dbname=%s user=%s password=%s" % ( 'localhost' , 'projeto' , 'postgres' , '123456' ) ) cur =con.cursor() print con # INSERIR UM POST conteudo = raw_input("digite o conteudo: ") titulo = raw_input ("digite o titulo: ") cur = con.cursor(...
67299319d1a963f1bf988a8b75a1d724885ccc4d
rheena/Python-basics
/Sequences and Collections.py
3,779
4.5625
5
#Sequence is a collection of elements. One object that contains multiples values but can be treated as one thing. #List -Defined using square brackets [] mylist = [10, 20, 30, 'string', True, 8.97] print(mylist) #Most sequences are indexed. Index is a number that gives us information about the position of an elem...
a3743e2ec4c51f61a10250808c684d70a9b81187
jennyChing/leetCode
/399_calcEquation.py
2,261
3.9375
4
''' 399. Evaluate Division Equations are given in the format A / B = k, where A and B are variables represented as strings, and k is a real number (floating point number). Given some queries, return the answers. If the answer does not exist, return -1.0. Example: Given a / b = 2.0, b / c = 3.0. queries are: a / c = ?...
b2dc38eec8889fab9c836ea77b804c9267c5b336
max180643/Pre-Programming-61
/Onsite/Week-2/Friday/Vending Machine.py
718
3.84375
4
"""Vending Machine""" def main(): """Main Function""" money = 0 item = 0 total = 0 while True: input_ = input() if input_ != "END": if int(input_) >= 0: money += int(input_) elif int(input_) < 0: item += 1 ...
f4f84ad70047863feadde8c43759f6cbac537388
wuyaqiang/Algorithm_Learn
/剑指Offer/MyCode/No_12.py
2,643
3.953125
4
''' 剑指 Offer 第12题 leetcode 79. Word Search leetcode 212. Word Search II ''' def has_path(board, word): ''' 剑指Offer 12 leetcode 79. Word Search ''' # 解法一 剑指Offer解法,使用 visited 矩阵: # if not board or len(board) == 0 or not board[0] or len(board[0]) == 0: # return False # # def judge...
17fdb4c697f033ea8880b4577e8d64b28feb8d6c
Keerti-Gautam/PythonLearning
/Functions/FirstClass-Anonymous-HigherOrderFunc.py
880
3.890625
4
# Python has first class functions def create_adder(x): def adder(y): # return x + y return adder # create_adder returns x+y add_10 = create_adder(10) # 10+y is put in add_10 add_10(3) # => 10+3 =13 # There are also anonymous functions (lambda x: x > 2)(3) # => True (lambda x, y: x ** 2 + y ** 2)(2...
7ff8d7cd66cc1c28e9613e8ad74f80fc537e182d
abhaykoduru/sql
/cars_insert_update.py
761
4.0625
4
import sqlite3 with sqlite3.connect("cars.db") as connection: c = connection.cursor() data = (('Ford', 2013, 1000), ('Ford', 2014, 2000), ('Ford', 2015, 3000), ('Honda', 2014, 10000), ('Honda', 2015, 15000)) c.executemany("insert into inventory values(?,?,?)", data) c.execute("select * from inventor...
be9267b86feeef3c68232a5119a8306944d7e183
Omkarj21/Data-Structures_Collections_Collectors
/Dict_Comprehension.py
255
3.671875
4
keys = ['a', 'b', 'c', 'd', 'e'] values = [1, 2, 3, 4, 5] # 1st Way : abc = {p:q**2 for p,q in zip(keys,values)} print(abc) # 2nd Way : abc = {p:p**2 for p in values} print(abc) # 3rd Way : abc = {x: x**3 for x in range(10) if x**3 % 4 == 0} print(abc)
fd8b1570b0333b8449145bec4de5ecaf6ade9a22
pzengseu/leetcode
/SwapNodesinPairs.py
825
3.75
4
# Definition for singly-linked list. class ListNode(object): def __init__(self, x): self.val = x self.next = None class Solution(object): def swapPairs2(self, head): """ :type head: ListNode :rtype: ListNode """ h = ListNode(-1) h.next = head ...
a39bed5482a0c9fc73f5b58eab44ce5f42811b37
jrmak/FNNR-ABM
/FNNR_ABM/excel_import_2014.py
8,237
3.546875
4
# !/usr/bin/python """ This document imports household, individual, and land parcel data from the excel file. It also converts the imported data into workable values. """ from openpyxl import * import inspect from excel_import import * # Directory in which source file is located, exact name of source file...
739ac022c29814d67a2803f938f47c723116e98b
fghjgfdfgh/statistics
/function.py
3,234
3.75
4
import numpy as np import matplotlib.pyplot as plt import pandas as pd from sklearn import metrics from sklearn.metrics import r2_score def number_of_occurence(numpy_array:np.array): """function that checks the number of times each value occurs in an array Arguments: numpy_array: One dimensional numpy...
6b391388364666dd0bbaa2cf5ee1841dd62475a0
PhilLint/Master
/Knowledge Representation/Satisfiability Solver/process_sudokus.py
2,460
3.5
4
import math as m import os # reads.txt sudoku collection to a list def read_txt(path, name): input_file = open(path + name) sudoku_lines = input_file.readlines() sudokus = list() for sd in sudoku_lines: sudokus.append(list((sd.strip('\n')))) return sudokus # processes one sudoku_list to ...
b032d63ae3f1084ad83f30a138b98772c4c9dd4b
OnlyHyun/Python
/ones.py
841
3.578125
4
""" 2나 5로 나눌 수 없는 0 이상 10,000 이하의 정수 n이 주어졌는데, n의 배수 중에는 10진수로 표기했을 때 모든 자리 숫자가 1인 것이 있다. 그러한 n의 배수 중에서 가장 작은 것은 몇 자리 수일까? 바보냐?? 1 11 111 1111 11111 ... 이 나눠지는지 봐 병신같이 풀려면 일일이 배수 곱해서 하면 된다 """ s = [] while True: n = input("0~1000이하의 정수를 입력하시오: ") if(n == ' '): print("끝 수고!!") break el...
2958d6dfca1fe10c6630870b979084d1c2e2459e
Hallyson34/uPython
/ultrapassandoz.py
128
3.65625
4
x = int(input()) y = int(input()) i=1 soma=x while x>=y: y=int(input()) while soma<=y: soma=soma+(x+i) i+=1 print(i)