blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
4242a90a0256a4747dd5512081132d8b7d5b307c
deadiladefiatri/Deadila-Defiatri_I0320023_Aditya-Mahendra_Tugas4
/I0320023_Deadila Defiatri_Soal 4_Tugas4.py
380
3.890625
4
# Syarat Mendaftar Kursus Online print("Berapa Usia Anda?") usia = int(input()) if usia >= 21: print("Apakah anda sudah lulus ujian kualifikasi (Y/T)") kualifikasi = input() if kualifikasi == "Y": print("Anda dapat mendaftar di kursus") else: print("Anda tidak dapat mendaftar di kursus")...
9150a45601fe7e06b95067a501274f1f3e07cb97
PudgyElderGod/CS1.2
/hashtable.py
7,112
4.125
4
from linkedlist import LinkedList, Node class HashTable(object): #initializer function (constructor) for new hashtable (a new list of linked lists) def __init__(self, init_size=8): """Initialize this hash table with the given initial size.""" # Create a new list (used as fixed-size array) of e...
2978bd422f3b8bef87ecef2ed8e1d9c4122467de
hhe0/Leetcode
/Easy/0001-0099/0021/python/Solution.py
955
3.90625
4
# Definition for singly-linked list. class ListNode: def __init__(self, x): self.val = x self.next = None class Solution: def mergeTwoLists(self, l1, l2): """ :type l1: ListNode :type l2: ListNode :rtype: ListNode """ head = ListNode(0) ...
d05482900606ffed6bb13688d5eb3ba0ed45d51e
lucasdan121/NITI
/Dominó.py
44
3.515625
4
x = int(input()) print(int(((x+1)*(x+2))/2))
bb591964c72698ee3eb2998e48f6d64bb4fbe4a5
Fangziqiang/PythonInterfaceTest
/pythonBasic/2列表和元组/2.4元组:不可变序列/yuanzu.py
432
3.640625
4
#coding=utf-8 # 创建元组的语法很简单:如果用逗号分隔了一些值,那么你就自动创建了元组 x=1,2,3 print x # 运行结果:(1, 2, 3) # 空元组可以用没有包含内容的两个圆括号来表示 # 包括一个值的元组的实现方法 y=42, print y # 运行结果:(42,) z=(42,) print z # 运行结果:(42,) print 3*(40+2) # 运行结果:126 print 3*(40+2,) # 运行结果:(42, 42, 42)
275e25b73c1f499c6184afe41bf2bdd6e88a2698
nxl904/ud_SQL_Log_Analysis
/log_ana.py
1,921
3.546875
4
#!/usr/bin/env python3 import psycopg2 """Import the psycopg adapter to allow integration with PostgreSQL database and the below python code""" DBNAME = "news" def popular_articles(): try: db = psycopg2.connect(database=DBNAME) c = db.cursor() c.execute("select authart.title, authart.nam...
031ca253207b074370573b421b1356c89274d245
wufanwillan/leet_code
/Maximum Depth of Binary Tree.py
1,117
4.03125
4
# Given a binary tree, find its maximum depth. # The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node. # Definition for a binary tree node. # class TreeNode(object): # def __init__(self, x): # self.val = x # self.left = None # se...
d1b6cd62e417fe01d760fd84af6129b6ce2f4722
rushi-the-neural-arch/OpenCV-Tutorials
/OpenCV_Objects_Basics.py
5,159
3.65625
4
import argparse import imutils import cv2 ap = argparse.ArgumentParser() # CREATE the ArgumentParser object ap.add_argument("-i", "--image", required=True, help = "Path to your input image") # CALL the add_arg function to pass arguments args = vars(ap.parse_args()) # Finally PARSE the input argu...
8483433b29ab2346075eb447e15613f2415836b5
FWNT/ycsh_python_course
/reverse_sort_5.py
84
3.75
4
x=[] for i in range(5): a=int(input()) x.append(a) x.sort() x.reverse() print(x)
2450c7cccafa7d66157ef16b35ced3b903ee0b60
SuryakantKumar/Data-Structures-Algorithms
/Searching & Sorting/Insertion-Sort.py
1,120
4.25
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Wed Jan 1 08:42:58 2020 @author: suryakantkumar """ ''' Problem : Given a random integer array. Sort this array using insertion sort. Change in the input array itself. You don't need to return or print elements. Input format : Line 1 : Integer N, Array S...
8e2346bbf34b4231f14212473d5b2801d0789785
JosephLevinthal/Research-projects
/5 - Notebooks e Data/1 - Análises numéricas/Arquivos David/Atualizados/logDicas-master/data/2019-1/223/users/3113/codes/1716_2496.py
83
3.828125
4
num=int(input("")) s=0 while(num!=-1): s=s+num num=int(input("")) p=s print(p)
bd32d48143c7f0fd895ee24a60f317c09790d9e7
ebisLab/codingchallenges
/DP/slidingwindows.py
3,657
3.84375
4
import collections import sys INT_MIN = -sys.maxsize - 1 INT_MAX = sys.maxsize print(INT_MIN) print("INT_MAX", INT_MAX) ''' Input: a List of integers as well as an integer `k` representing the size of the sliding window Returns: a List of integers ''' def sliding_window_max(nums, k): # this is fixed windows max...
b7d0d37825ff4c5d6ce3fd96b28c5c8464dbcd88
leeiozh/troyka
/IntegrateMethods.py
6,472
3.65625
4
import numpy as np from abc import abstractmethod class Integrator: """ integrator's base class """ def __init__(self, dt, m, forces): """ init function :param dt: time step :param m: mass :param forces: type of forces """ self.m = m sel...
400ea4d20fdb6f47c421a7913a4797ae1b71fb3e
6306022610113/INE_Problem
/Edabit/แทน-20210505T205914Z-001/แทน/edabit/edabitcup1.py
198
3.9375
4
def cup_swapping(swaps): ball = "B" for move in swaps: if ball in move: ball = move[1] if move[0] == ball else move[0] return ball print(cup_swapping(["AB", "CA"]))
cdb1217335d5be2347c65b5519a321c852b98f68
anaturrillo/intro-python
/clase_01/ejercicios/ej_04.py
641
4.15625
4
# 4) Al ejercicio anterior agregarle la validación de la operacion def operar(): num_1 = input('Ingrese el primer número: ') operacion = input('Ingrese la operación: ') num_2 = input('Ingrese el siguiente número: ') num_1_int = int(num_1) num_2_int = int(num_2) if operacion == "+": ...
6fe186342d68fb2c12f171b55f715c91c6c88018
rajeshpandey2053/python_assignment
/data/D10.py
133
4.03125
4
string = input('Enter the string: ') result = [] for i in range(0,len(string),2): result.append(string[i]) print("".join(result))
93135b996f1239ed75cd3dd440934cc8044ad189
kbj102409/python-study
/ex08.py
2,944
3.734375
4
#b까지수를 짝수 홀수로 표현 b = int(input("入力 : ")) for i in range(1,b+1): if i%2 == 0: print(i,"偶数") else : print(i,"奇数") #b까지수를 짝수 홀수갯수 표현 b = int(input("入力 : ")) su = 0 si = 0 for i in range(1,b+1): if i%2 == 0: su +=i else : si +=i print(su,si) #li.insert()이용 li = [1,2,3,4,5,6...
0744500b85a8229f3fb04a072be2dcaf9b9a3c7a
syam7/PracProject
/Python_Day2/dynamicE.py
565
3.875
4
row = int(input("Give the number of rows:")) col = int(input("Give the number of columns:")) m = [[0 for i in range(col)]for j in range(row)] for i in range(1,row+1): for j in range(1,col+1): if i==1 or i==row: m[i-1][j-1] = 1 elif (i == (row+1)/2) and j in range(1,col): m[...
764fa77749a4e5551761a52430e35642a264997d
drakulic/Capstone
/TreeNode.py
3,864
4
4
from collections import Counter import numpy as np class TreeNode(object): ''' A node class for a decision tree. It is either a leaf node or a parent node of two other nodes. This class has essentially one process, to predict a label for a row of data. There is also a method, as_string(), which is use...
8231ff3e7e9405e6a2e7f1b22478661b2ab8eb90
DritonG/selfdrivingCars_UniTuebingen
/exercise_03_modular_pipeline/template/longitudinal_control.py
2,188
3.5
4
import numpy as np import matplotlib.pyplot as plt from scipy.signal import find_peaks from scipy.interpolate import splprep, splev from scipy.optimize import minimize import time class LongitudinalController: ''' Longitudinal Control using a PID Controller functions: PID_step() control() ...
2dc5d31cb494c7142234b648a2a07ca0afa3ae47
adamandrz/Python-basics
/challenge1.py
156
3.71875
4
a = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89] b = [] value = int(input("Podaj wartosc < 100 :")) for x in a: if x <= value: b.append(x) print(b)
e7cdeef72fb476cffdb16710f4b75e765f815f43
y0ssi10/leetcode
/python/backspace_string_compare/solution.py
612
3.78125
4
# Problem: # Given two strings S and T, # return if they are equal when both are typed into empty text editors. # means a backspace character. # # Note: # After backspacing an empty text, the text will continue empty. # class Solution: def backspaceCompare(self, S: str, T: str) -> bool: def build(s:...
5699d66af1987968c67a28921692e6ccbdf31f77
cmuphyscomp/60-223-f16
/exercises/mobile/Chip-blink/chip_blink.py
284
3.546875
4
import Adafruit_GPIO as GPIO import time led_pin = "CSID6" # gets a gpio object gpio = GPIO.get_platform_gpio() # set up the pinmode gpio.setup(led_pin, GPIO.OUT) #blink the led while True: gpio.set_high(led_pin) time.sleep(1) gpio.set_low(led_pin) time.sleep(1)
35cd9b5d743a51f88c8d4845136493c3f6bc7791
Avdunusinghe/Algorithms
/insert_sort_algorithem.py
708
4.34375
4
# Write a program to read a set of numbers (between 10 to 20) from the keyboard and store them in an array. # Declare Array _array = [] # input Array Size n = int(input("Enter the number of element: ")) # save Array Element for v in range(0, n): _array.append(int(input("Enter a number"))) # print array elements...
9d089607c5716a3c0ee5e69797305c5442548f02
jonastr/street_address_parser
/test_address_line_parser.py
1,829
3.53125
4
from unittest import TestCase from street_address_parser import StreetAddressParser class AddressLineParserTest(TestCase): def _assert_parses_address_correctly(self, test_data): for input_line, expected_output in test_data: self.assertEqual( expected_output, St...
98d2d7044b8630f31ba7642b86381f1df14fd0ef
atlasbc/cs50
/pset6/pset6/vigenere.py
1,428
4.0625
4
import cs50 import sys def main(): # Check whether command-line argument has 2 argument if len(sys.argv) != 2: print("Usage: ./vigenere k") exit(1) keyword = sys.argv[1] # Check whether keyword contains only alphabetical symbols if keyword.isalpha()...
d06c17099648f015af207923178776ace238d283
Ascarik/PythonLabs
/Ch05/Lab55.py
531
3.75
4
import turtle flag = True turtle.left(45) for i in range(0, 8): if i % 2 == 1: flag = False else: flag = True for j in range(0, 8): turtle.pensize(3) turtle.penup() turtle.goto(-200 + 60 * j, 150 - 60 * i) turtle.pendown() # Pull the pen down if f...
1f84924824d3b0daf2f160e1291a9f536ce67ea8
wodograyvk/test_skeemans
/SkeemansCourse/home8/lifecoding_1.py
265
3.96875
4
def some_function(one, two, three=0): if one and two: return one + two elif one: return one ** 2 elif two: return three ** 3 elif three: return -1 else: return return 228 print(some_function(0, 2, 3))
3b374071e4e3217255bc4f2553b2dbf389429d4f
IshteharAhamad/project
/aggregation.py
523
3.828125
4
class Salary: def __init__(self,pay,reward): self.pay = pay self.reward = reward def annual_salary(self): return (self.pay*12) + self.reward class Employee: def __init__(self,name, position,sal): self.name=name self.position = position self.sal = sal # here pa...
0b0bdaac0a6346b992e737cd5ba983f3344b51dc
ilkeryaman/learn_python
/analysis/youtube/youtube.py
4,212
3.65625
4
import pandas as pd import numpy as np from introduction.modules.printer_module import pretty_print pd.set_option('display.max_columns', 20) # Max how many columns will be shown at print output pd.set_option('display.width', 500) # It puts a new line after some spaces. This option sets output width. pd.set_option('d...
0b7569c61acafc6a705e070932b3cf7dd1850495
gabrielsalesls/curso-em-video-python
/ex013.py
174
3.5625
4
n = float(input('Digite o salario do funcionario: ')) a = (n*15)/100 ns = n+a print('O salario é {}, aumentou {} reais e o novo salario é {:.2f}'.format(n, a, ns))
1b2c0db98f91bad777cd0e1d004967866d671037
Ajith-Kumar-V/Online_coding_round_questions
/Codewars.py
205
3.65625
4
def abbrevName(name): #code away! h='' l=name.split() for i in l: i.capitalize() h+=(i[0]+'.') h=h.strip(".") h=h.upper() print(h) name=input() abbrevName(name)
be4c9973874ef0f19f9f45b7600571a09b4d8d88
Uma-Ravi22/Bertelsmann-Technology-Scholarship-Python-Challenges
/Day62_PrintTuple.py
880
4.71875
5
# Day 62: Printing Tuple Records. # A common use for tuples is as records, similar to a STRUCT in some other languages. # For this exercise, write a Python function, format_sort_records, that takes the PEOPLE list: # PEOPLE = [('Joe', 'Biden', 7.85),('Vladimir', 'Putin', 3.626),('Jinping', 'Xi', 10.603)] and # returns...
1c4f554321191b2abbd036878072a4540a824719
thojac/projecteuler
/020/p020.py
269
3.84375
4
# Problem 020 - Factorial digit sum def fac(n): sum = 1 while n > 1: sum *= n n -= 1 return sum def factorial_digit_sum(n): return sum(int(i) for i in list(str(fac(n)))) if __name__ == "__main__": print(factorial_digit_sum(100))
751291a754a38c9c6b4b717ff9b7319dbe753013
piaoger/lightning-fireball
/2019fireball/哥德巴赫3.py
378
3.90625
4
#验证哥德巴赫猜想,函数版 def is_prime(n): if n != int(n) or n <2: return False for i in range(2,n): if n% i ==0: return False return True #——— n=eval (input('n=')) for n1 in range (2,n//2+1): if is_prime(n1) and is_prime(n-n1): print(n1,n-n1) #找出【ab】区间内最大指数和直属数量统计
e360ac837f60bbcb028eea41366f5e377f8bacd9
rishabhad/Python-Basics-
/square_root.py
247
3.5625
4
import math D= input('Enter any temprature by comma seperation').split(",") print(type(D)) c=50 h=30 Q=[] for i in D : print(type(i)) p=round(math.sqrt(2*c* int(i)/h)) Q.append(p) print(str(Q)) #print(",".join(str(Q)))
dabe6b22d6a497a1ae0cda15f95591adf459e683
elvisnava/machine-learning
/linear_regression_nonlinear_test.py
2,163
3.546875
4
from linear_regression import Regression import math import random import numpy as np def random_point(): ''' Returns a random 2-dimensional vector of floats between -1 and +1 ''' return [random.uniform(-1., 1.), random.uniform(-1., 1.)] def target_f(x1, x2): ''' Nonlinear target function f(x1...
835e9c35a7caf49afc948908b04c82406657c33b
lxconfig/UbuntuCode_bak
/algorithm/数据结构和算法/42-迷宫问题1.py
3,229
4
4
""" 输入一个二维矩阵,并给定起始坐标及终点坐标,在矩阵中,1代表是墙,不能通过,0代表是路径,可以通过。 问能否找到一条路径通向终点坐标,能则返回True,否则返回False 0 0 1 0 0 1 0 0 1 0 0 1 1 0 0 1 0 0 1 0 0 0 1 0 1 将0看作是图中的顶点 """ def Maze(matrix, start, end): visited = [[False] * len(matrix) for _ in range(len(matrix))] return Maze...
befb875415e5b87d1cdc3111b77f88f4dd4770da
forestlight1999/algorithm
/sort.py
9,686
4.125
4
#!/usr/bin/env python # coding=utf-8 ''' @Author: forestlight @Date: 2019-08-25 16:29:29 @LastEditTime: 2019-09-05 21:24:27 @Description: implement the classical sort algorithm ''' from utils import get_randint_data from collections.abc import Iterable class Sort(object): def __init__(self, cache_len): pa...
f56788882a89937d8a17e5ed08a4736d7f4b70ce
griase94/simple_dart_engine
/game.py
3,685
3.9375
4
from player import Throw, Player class Game: def __init__(self, players, point_goal, double_out): self.players = players self.current_player = 0 self.point_goal = point_goal self.double_out = double_out self.game_over = False # start first round for first player ...
56dbe865a8149f905f07590229d714bb789948d0
EmmanuelSHS/LeetCode
/lint_max_gap.py
812
3.671875
4
#!/usr/bin/env python # coding=utf-8 class Solution: # @param nums: a list of integers # @return: the maximum difference def maximumGap(self, nums): # write your code here if len(nums) == 1: return 0 n = 5 size = max(nums) / n if size == 0: ...
baf453ced737c74c4141a1df0a2e52776c7c5303
wead-hsu/senti-ranking
/scripts/find_english.py
528
3.65625
4
#!/usr/bin/python import codecs import sys def find_english(ifn, ofn): sf = codecs.open(ifn, 'r', 'utf-8') of = codecs.open(ofn, 'w', 'utf-8') line = sf.readline() while line: word = line.split()[0] if is_alphabet(word[0]): of.write(line.split()[0] + '\n') line = sf.readline() return 0 def is_alphab...
1c6a09db15fc3e474180760161b7618d9fff2038
vpreethamkashyap/plinux
/7-Python/11.py
4,052
3.625
4
#!/usr/bin/python import sys import time import shutil import os import subprocess ############################################################## ##Calling a Function # Function definition is here def printme( str ): "This prints a passed string into this function" print str return; # Now you can call print...
bc8649f3638b2d0376d869c4acb87d96a47d26d7
jameswmccarty/PyImgMosaic
/PyImgMosaic.py
6,139
3.671875
4
#!/usr/bin/python # This utility reproduces an image from many other # smaller image 'tiles.' from PIL import Image import os import sys from subprocess import call from math import sqrt from random import randint """ Create a directory called 'img_src' in the same location as this script. Populate this directory w...
7533ef381b2b647f21c9abb600df68ef8fdc356e
Kornelijus/udacity
/Full Stack Web Developer Nanodegree/Project 3 - Logs Analysis/reportingtool.py
2,561
3.546875
4
#!/usr/bin/env python3 import psycopg2 import sys import datetime def connect(db="news"): # Connects to PostgreSQL database try: global conn, cur conn = psycopg2.connect("dbname={}".format(db)) cur = conn.cursor() except: # Prints error, plays an error sound print("...
a05bf41659923a7aa6a72d6550da03615223b501
Sreerag07/bankproject
/oop/std1.py
415
3.609375
4
class Student: college="Luminar" def setval(self,name,rollno,dep): self.name=name self.rollno=rollno self.dep=dep print("Name:", self.name) print("Rollno:", self.rollno) print("Department", self.dep) print("Colllege", Student.college) def __str__(self)...
1db7f5787577410d0f0582cb418bfe2bcb764f43
mama00/Algorithms
/QuickSort/main.py
2,223
3.671875
4
#Author: Marceus Jethro #Implementation of QuickSort with average time complexity of O(nlogn) and also with space complexity of #O(n) in best cast and O(n^2) in worst case #note that if you use the Partition fonction instead your space complexity will shrink #to a constant but your time complexity will grow #feel free...
070956a26b3162d54b3acb85b8c2890edbab77d3
rafaelperazzo/programacao-web
/moodledata/vpl_data/476/usersdata/339/110421/submittedfiles/Av2_Parte3.py
254
3.9375
4
# -*- coding: utf-8 -*- a=[] b=[] n=int(input('quantidade de elementos a: ')) m=int(input('quantidade de elementos b: ')) for i range(n): a.append(input('Elementos de a: ')) for i range(m): b.append(input('Elementos de b: ')) while a
c17cca68ceb316accae491678334071cce095b83
GreenhillTeacher/Python2021
/myPygame.py
3,019
3.828125
4
#Maria Suarez #C:\Users\suarezm\Documents\python\Python2021 # K_UP up arrow # K_DOWN down arrow # K_RIGHT right arrow # K_LEFT left arrow import time, sys, pygame print(sys.path) pygame.init() #Initialize the game pygame.time.delay(100) #delay in millisecond...
f0f77ebbea4aadb13d51e91ec024ea39b83c85cc
youhusky/Facebook_Prepare
/013. Roman to Integer.py
616
3.578125
4
# Given a roman numeral, convert it to an integer. # Input is guaranteed to be within the range from 1 to 3999. # focus on the rule compare the previous number class Solution(object): def romanToInt(self, s): """ :type s: str :rtype: int """ dic ={'X':10,"V":5, 'I'...
803773f00696501a1be884cadc8c4debd9076f49
yument7/PyLearn
/PyaBaseGrammer/inputprintTest.py
389
4.03125
4
#!/usr/bin/python3 # --coding=UTF-8-- # 使用递归方法,逆序打印出输入的字符串,字符串长度固定为5,例如abcde def inputOutputTest(n): str=input('请输入字符:') if n==1: return str else: return inputOutputTest(n-1)+str if __name__ == "__main__": str = inputOutputTest(5) print('the reverse str is: %s'%str)
c9e8572fb8e5fa5405ee1827d15fef6828fb961e
PacktPublishing/Learn-Computer-Science-and-Python
/Ch1/adder.py
262
4.03125
4
import sys if(len(sys.argv) == 3): print (sys.argv[1], " + ", sys.argv[2], " = ", int(sys.argv[1]) + int(sys.argv[2]) ) else: print ("You need to include the 2 numbers you want me to add. For example:") print ("python.py " + sys.argv[0], " 4 5")
bcb4d179e04ebc957606d2815aefc0bfadcf5137
miguelgcoias/aalg-graphs
/structs/weighted_graph.py
2,323
3.5
4
from array import array from json import load from structs.graph import Graph class WeightedGraph(Graph): def __init__(self, data): '''Static sparse weighted graph class constructor. Allows reading from a JSON file or from a dictionary object mimicking the structure of a loaded JSON fi...
4218794baac564e840453b36e350b9ac5a14c23e
dacugo/Python
/Cisco_IBM/Literales.py
521
3.734375
4
#entiedase como literal los caracteres alfabeticos usados en el almacenamiento de información #inicialmente los datos de tipo numerico que se pueden almacenar00 #uso del número 2 como un String print("2") #uso del número 2 como un Entero print(2) #imprimiendo un número octal print(0o123) #imprimiendo un número hexade...
2d5bb128133b8870397db8ba7e822d1be5f20a03
Mnbee33/self_taught_python
/chapter15/Playground.py
190
3.515625
4
import Card import Deck card1 = Card.Card(10, 2) card2 = Card.Card(11, 3) print(card1 < card2) print(card1 > card2) print(card1) deck = Deck.Deck() for card in deck.cards: print(card)
3b2350d8ba00c9e68dfd5f4f176eacc7dd0aa455
MrgLuK/tceh_python_dev
/course08_generators/homework/generators_hw.py
1,710
4.09375
4
# Написать генератор, который бы каждый раз возвращал новое случайное число import random from collections import Iterable import sys def gen1(): while True: yield random.randint(-sys.maxsize, sys.maxsize) x_random = gen1() print(next(x_random)) print(next(x_random)) # Написать генератор, который бы р...
d8df1be481a79bc3e02d012c4d8ad1497435f247
Sahith-8055/XYZ
/CSPP1/iterate_even_reverse.py
78
3.84375
4
print("print Hello!") for i in range(10,0,-2): print("print",i)
990fd8f670a1ff1e9f2109216132899c06c5167f
yfeng2018/IntroPython2016a
/students/ChiHo/session06/weapon.py
552
3.5
4
# Weapon Lab # Student: Chi Kin Ho # Date: Wednesday, February 17, 2016 def hand_weapon(size): if size == 'small': return 1 elif size == 'medium': return 2 else: return 3 def gun(size): if size == 'small': return 5 elif size == 'medium': return 8 else:...
0075ce372f5e079722d2008fe223e0f6d74333e8
ziyadedher/birdynet
/src/game/world.py
2,012
3.953125
4
"""This module contains and manages a game world.""" import random from typing import List, Tuple from game import config class Wall: """Represents a wall barrier in the game.""" gap_start: int location: float def __init__(self, gap_start: int) -> None: """Initialize a wall with the given ...
471c3f123fb58d388085de420781b1be547165b8
xianglight/rf_unfolding
/applications/cancellation/helpers/signal_processing.py
5,855
3.65625
4
#!/usr/bin/env python # -*- coding: utf-8 -*- """ Functions for signal processing and plotting. """ import numpy as np from scipy.signal import savgol_filter import sys import os import matplotlib.pyplot as plt import seaborn as sns sns.set() def signal_power(x): """Compute the power of a discrete signal. ...
f169d6e4f504a63602d745d17a6913e32ad8d13c
Seedy1999/ProjectEuler
/Problem 1 - Multiples of 3 and 5.py
556
4.09375
4
""" If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23. Find the sum of all the multiples of 3 or 5 below 1000. """ import time end = 10 tic = time.perf_counter() result = sum([x for x in range(end) if (x % 3 == 0 or x % 5 == 0)]) toc = tim...
2a2feca18c6774c9d0366febd488386224e63014
Prabithapallat01/pythondjangoluminar
/workshop/program2.py
188
3.78125
4
num=input("Enter the number:") i=1 data=0 pattern="" while(i<=int(num)): res=num*i pattern=pattern+"+"+res data+= int(res) i+=1 pattern=pattern.lstrip("+") print(pattern)
40cc170c0a15bbd2bc5d21fd532f6bc4000dcd82
ckk/adventofcode
/12/12.py
992
4
4
#!/usr/bin/env python import json # my first solution for counting all numbers was a really quick and dirty method in the shell: # jq . < input | egrep '[[:digit:]]+' | sed -re # 's/^[^[:digit:]-]*([-[:digit:]]+)[^-[:digit:]]*$/\1/' # which gives all of the numbers, then another simple one-liner to sum them. # Bot...
d00124e51aae19c473c55b606b87c8b373ea54cb
Chiva-Zhao/pproject
/cookbook/numdatetime/num_martrix.py
468
3.609375
4
# 矩阵与线性代数运算 import numpy as np import numpy.linalg m = np.matrix([[1, -2, 3], [0, 4, 5], [7, 8, -9]]) # Create a vector and multiply v = np.matrix([[2], [3], [4]]) def base(): # print(m, m.T, m.I, sep='\n') print(v, m * v, sep='\n') def lineagle(): print(numpy.linalg.det(m)) # Eigenvalues print...
e0f8cd4201e38943773e1f6302455aab1807b038
codeacade/py-random
/projecteuler/07.py
1,000
3.53125
4
## https://projecteuler.net/problem=7 ######################################################################################################## ## By listing the first six prime numbers: 2, 3, 5, 7, 11, and 13, we can see that the 6th prime is 13. ## What is the 10001st prime number? #################################...
88efb7fae44957ad1fa60587795ed781aed0c4e1
Vin129/IWTL_Python
/Python/wan2learnPy/List.py
407
3.984375
4
arr = [] # 添加 append arr.append(1) # [1] arr.append(2) # [1,2] # 删除 del arr = [1,2,3,4] del arr[2] # [1,2,4] # 获取长度 len arr = [1,2,3,4] len(arr) # 4 # 组合 + arr = [1,2,3,4] + [5,6] # [1, 2, 3, 4, 5, 6] # 重复 * arr = [1]*4 # [1, 1, 1, 1] # 包含 in arr = [1,2,3,4] print(5 in arr) # False print(4 in arr) # True # 遍历 for...
b6d9df60e64b903b4edcbaf76045c7281c98d316
chriskwon96/Algorithm_codes
/kakao/크레인인형뽑기게임/크레인인형뽑기게임.py
1,459
3.640625
4
# 격자의 상태가 담긴 2차원 배열 board # 크레인을 작동시킨 위치가 담긴 배열 moves # 크레인을 모두 작동시킨 후 터트려져 사라진 인형의 개수를 return def getTopDoll(board, pos): for i in range(N): if board[i][pos] != 0: #i가장 빨리 인형을 찾으면 doll = board[i][pos] # 인형겟 board[i][pos] = 0 # 인형 빼줘 return doll #인형의 종류(숫자)를 리턴 def check...
ef46d760dd1dfdabf6938d4a787428abc1a8ff34
missmorganyoung/gwc-chatbot
/chatbot.py
2,977
3.984375
4
def main(): intro() while True: get_user_input1() get_user_input2() get_user_input3() get_user_input4() get_user_input5() AskRockPaperScissors() answer = input("Guess the color that I am thinking of.") process_input(answer) print("Good job!...
0ea89f2e03e8a2ffe54b4d374e79513de02af136
murbard/multinomial
/tests/tests.py
4,030
3.578125
4
import unittest from collections import Counter from math import sqrt import scipy.stats from multinomial import binomial, int_sqrt, sample_binomial, sample_binomial_p, sample_multinomial_p def get_tuples(length, total): """ Computes all possible multinomial draws, the support of the multinomial distribution ...
0ab385324dcef984ea3d73220fdb5a75fdd8593d
c-ernest/pirple
/If_statement.py
183
3.734375
4
def threeParameters(a, b, c): new_c = int(c) if a == b or a == new_c or b == new_c: print(True) else: print(False) threeParameters(6, 5, "5")
921a327bbd66669b085f37b548186fbfd1a4ae69
cesar-machado/Learn-py
/list.py
114
3.5625
4
# define a list of names names = ["cesar", "gil", "ben"] names.append("elisa") names.sort() print(names)
5b13d715bd13770c9c7d64f35b24be5ecaeacfd7
nebkor/lpthw
/game/map.py
9,749
4.15625
4
from sys import exit import re # define gold_room() def gold_room(): ''' This is the gold room. Player chooses amount of gold, and if the choice is an integer and less than 50, prints "Nice, you're not greedy, you win! Good Job!". If the integer is greater than or equal, prints "You gre...
7889951bd2447088d933c1bac6b4db4522e9c7a6
SubhasmitaPurohit/Foundation-Of-Machine-Learning
/Page_Blocks_Report.py
3,948
3.578125
4
#!/usr/bin/env python # coding: utf-8 # In[2]: import pandas as pd import numpy as np import matplotlib.pyplot as plt import pandas as pd import sklearn # In[3]: get_ipython().run_line_magic('pwd', '') # In[5]: get_ipython().run_line_magic('cd', 'F:\\BA\\Term 5\\ML') # In[8]: df=pd.read_csv("page_block.c...
f398206fcc006916c192f0fd59af4a20daeaed43
chloeeekim/TIL
/Algorithm/Leetcode/Codes/MajorityElement.py
1,244
3.65625
4
""" 169. Majority Element : https://leetcode.com/problems/majority-element/ 숫자들로 이루어진 리스트가 주어졌을 때, 해당 리스트에서 가장 많이 등장하는 숫자를 찾는 문제 - majority element는 리스트의 사이즈가 n일 때, n/2번보다 많이 등장한다 - 리스트는 비어있지 않고, majority element는 항상 존재한다 Example: - Input : [3,2,3] - Output : 3 - Input : [2,2,1,1,1,2,2] - Output : 2 Note: - Soluti...
e1bde565189369cf51aba051905bf1dfdd27d6e4
pankleshwaria/python-code-snippets
/CSV Files/csv_reader.py
608
4.09375
4
# This tutorial deals with reading CSV (Comma Separated Values) files import csv filename = "student_grades.csv" rows = [] fields = [] with open(filename, mode="r", encoding="utf-8") as csvfile: csvreader = csv.reader(csvfile) # extracting field names through first row fields = next(csvreader) for...
8e6f4db3dd759f475f255e310f9b1c7ca7936225
jwoojun/CodingTest
/src/main/python/algo_expert/String/거꾸로해도 이효리.py
157
4.03125
4
# 거꾸로해도 이효리 T = input() check = {True : "Palindrome", False:"Not Palindrome"} if T == T[::-1] : print(check[True]) else : print(check[False])
2b200be6510a9bab00e1a1a52ad6c277918f242a
stewajos/457Project
/Client.py
2,442
3.609375
4
import socket import sys import os import math HOST = 0 # The server's hostname or IP address PORT = 0 # The port used by the server def client(): the_socket = socket.socket() # this method is intended to recieve a list of files in the directory the server is currently in def list_receiver(): ...
fb7839d89cce42bd09adcd928d48ed1d6bf9431d
JennieOhyoung/interview_practice
/reverse_string.py
1,180
4.15625
4
# 1. Write a function "rev_str" that takes string and reverse. # 1b. Takes string of words, reverse order or words string = "christmas" def reverse(string): l = list(string) temp = 0 for i in range(len(l)/2): temp = l[-1-i] l[-1-i] = l[i] l[i] = temp print l "".join(l...
96d9b732d959825b4b5b00ca042306790720c224
nithinveer/leetcode-solutions
/Reconstruct a 2-Row Binary Matrix.py
879
3.5625
4
def reconstructMatrix( upper, lower, colsum): cols = len(colsum) col_sum = sum(colsum) if lower+upper != col_sum or (colsum.count(2)>lower or colsum.count(2) >upper ): return [] arr = [[0 for i in range(cols)],[0 for i in range(cols)]] # print(arr) for i in range(cols): if colsum...
84b5fbaaf4780c9c9b2f1643c677a5ecfadd9092
arawat0756/Data_sturcture_-_Algorithms
/Algorithms/calculate_recursive.py
363
4.3125
4
def calculate_rec(n): '''This function also called tail recursion.''' if n > 0: k = n ** 2 print(k) calculate_rec(n - 1) calculate_rec(4) # def calculate_rec(n): # '''This function is called head recursion''' # if n > 0: # calculate_rec(n - 1) # k = n ** 2 # ...
b1f38bcb557853e35efe3f7b2f36ceb41e86ed3a
MStimpson/Python-Training
/fibonacci.py
628
4.09375
4
def is_number(s): try: int(s) return True except ValueError: return False while True: while True: user_input = input('How many fibonacci numbers would you like to see?\n') if(is_number(user_input)): print('\n') break else: print('\nThat is not an integer.') i = 0 First_Valu...
9a1f92abcaecd3575bb80c848b95dc7974e49924
cliffgla/camera_shop
/camera_store.py
1,170
3.78125
4
# define types of photography photo_styles = [ "street", "portrait", "landscape", "photojournalism", "fine art", "wildlife", "snapshot" ] printed_list = ", ".join(photo_styles) # recommend cameras, lenses, other gear depending on camera type. # take user input to decide what kind of camera to buy def user_pref(): ...
fb08b87e997fe66711b544fbbd9f23c001d1c38a
freebz/Learning-Python
/ch19/ex19-1.py
503
3.828125
4
# 재귀 함수 # 재귀를 이용한 더하기 def mysum(L): if not L: return 0 else: return L[0] + mysum(L[1:]) # 자신을 재귀적으로 호출 mysum([1, 2, 3, 4, 5]) # 15 def mysum(L): print(L) # 재귀 단계 추적 if not L: # 각 단계에서 L은 점점 짧아짐 return 0 else: return L[0] + mysu...
f6ce58b1d2e3377146aed64757a0183303f708bc
uzzielumanzor/sorts
/sorts.py
5,698
3.703125
4
import time import random import math def generador(cantidad): lista = range(cantidad) random.shuffle(lista) return lista def buble_sort(alist): for passnum in range(len(alist)-1,0,-1): for i in range(passnum): if alist[i]>alist[i+1]: tem...
18830a185baa39f1f16b39d8ca5f2e42f5bd3307
samturton2/Python_user_data_task
/main.py
1,594
4.5625
5
# Declare variables as the text the user inputs # Information automatically saved as string type # We are happy with all this information being a string so we don't need to change the data type first_name = input('Enter first name\n=> ').capitalize() middle_name = input('Enter middle name\n=> ').capitalize() last_name ...
005294d96269eb4fdfe8266c214476d4d43fbf4a
GameDevelopeur/Project-CNED
/Fleury-Jean-SG16-Enseignement Scientifique-Projet/main.py
3,488
3.71875
4
# PONG: By Jean Fleury # Touche: Haut = E, Bas = C # C'est un Jeu sans fin import turtle import os # Fenetre wn = turtle.Screen() wn.title("Pong by Jean Fleury") wn.bgcolor("black") wn...
c953ffb9eb98055bed45b1b87d679fb996ccaf0d
millerwatson/cvproj_1
/finalProj_0.py
5,237
4
4
import argparse import cv2 import numpy as np from matplotlib import pyplot as plt """This program takes in a street sign from the user and returns what type of sign it is. It works by getting the amount of sides on the sign's contour and comparing those with a list of sign types. It also provides a col...
707ac0a344865fe5b4c122e0750b682e4fd4d127
Jerry-Wan/CSCI-UA102
/week1Lec1/Week1Lec1/Coding Related/OOP Polynomial.py
1,482
3.875
4
import math class Polynomial: def __init__(self, coeffs): self.coeffs = coeffs def evaluate_at(self, s): result = 0 for a in range(len(self.coeffs)): result += self.coeffs[a]*math.pow(s,(len(self.coeffs)-1-a)) return int(result) def __str__(self): ...
0df958d261d4a4a18bc9afd790e2860cc4f33153
sdo91/programming_puzzles
/project_euler/solved/p049.py
2,982
3.71875
4
#!/usr/bin/env python def addToPath(relPath): from os import path import sys dirOfThisFile = path.dirname(path.realpath(__file__)) dirToAdd = path.normpath(path.join(dirOfThisFile, relPath)) if dirToAdd not in sys.path: print 'adding to path:', dirToAdd sys.path.insert(0, dirToAdd) ...
2f4ae1d82aa9c9b0795e3cc2a8db986dd8ce8b99
vasugarg1710/Python-Programs
/5(Apni Dict).py
213
4.125
4
# Apni Dictionary dict1 = {"mutable":"can change","immutable":"cannot change", "python":"a programming language","notebook":"collection of pages"} print("Enter the word") word = input() print(dict1[word.lower()])
6bd7f82802057188452bdee5299d3b886b946311
KaramAbuMokh/Machine-Learning
/autoencoders/reduce diminsions/reduce diminsions.py
2,657
3.59375
4
import numpy as np import pandas as pd import seaborn as sns import matplotlib.pyplot as plt # new : to make data sets from sklearn.datasets import make_blobs if __name__ == '__main__': # create the data set data=make_blobs(n_samples=300 ,n_features=2 ,centers=2 # how...
aa7bd7157370e7647d6dfaa226b6462df633ef8a
ruizsugliani/Algoritmos-1-Essaya
/entrega_final/ej3.py
1,142
3.671875
4
def matriz_guardar(ruta, matriz): ''' Recibe una matriz de n x m números enteros y la guarda en el archivo indicado. ''' with open(ruta, "w") as f: for fila in matriz: for numero in fila: if numero != fila[-1]: f.write(f"{numero} ") ...
4a3e784d51eb546ac66cd078c40a50ade8486629
xandyctz/URI-Online-Judge
/INICIANTE/Python/1021.py
1,365
3.671875
4
def main(): valor = float(input()) valor +=0.001 troco = valor cem = troco//100 troco = troco - (cem*100) ciquenta = troco//50 troco = troco - (ciquenta*50) vinte = troco//20 troco = troco - (vinte*20) dez = troco//10 troco = troco - (dez*10) cinco = troco//5 troco = troco - (cinco*5) ...
658edec51a180f989243b79572e90bfa0874cf0d
NemoNemo03/N-Stock
/新建文本文档2.py
833
3.984375
4
# Hello, how are you? Fine. 使得该句子按照单词反转并保留所有的空格 def reverse(str_list, start, end): while start < end: str_list[start], str_list[end] = str_list[end], str_list[start] start +=1 end -=1 #预置反转函数 a,b = b,a setence = ' Hello, how are you? Fine. ' str_list = list(s...
e231ba1553e20d9c07ad9197f0f5fc4834224299
LochNeffCodeMonster/Assignments
/Linked_List.py
894
3.96875
4
# Node class class Node: def __init__(self, data): self.data = data self.next = None # Linked list class class LinkedList: def __init__(self): self.head = None # Computes the length of a linked list def getLength(head): length = 0 while head: length = length + 1 head ...
252290cf9187e88409dd254468aa53bc65a22a9a
SlaviSotirov/HackBulgaria
/week_0/day_1/contain_digs.py
207
3.953125
4
def contains_digit(number, digit): string = str(number) char = str(digit) for symbol in string: if symbol == char: return True return False print(contains_digit(143, 2))
7833aafc7c5e55cb58be18ee07d08d9dbb7572ba
misa9999/python
/courses/pythonBrasil/EstruturaDeDecisao/ex009.py
610
4.0625
4
# pede três números e mostra em orde decrescente # pede os números n1 = int(input('n1: ')) n2 = int(input('n2: ')) n3 = int(input('n3: ')) maior = menor = meio = n1 # verfica o maior número if n2 > n1 and n2 > n3: # n2 maior maior = n2 elif n3 > n1 and n3 > n2: # n3 maior maior = n3 # verf...
0d4c891661ab7c14128c6d8caa5b255b0e22f938
sonhaidang1995/dangsonhai-fundamental-c4e20
/Session02/Homework/3.3d 9x9 number 0-1.py
359
3.84375
4
for i in range (1,10): if i%2 == 0: for k in range(1,10): if k%2==0: print(1,end=" ") else: print(0,end=" ") print("") else: for k in range(1,10): if k%2==0: print(0,end=" ") else: ...
7b248bc0039a55ab51e110554607ecacf82238d4
kim-min-ju449/programming-python-
/문제07-01.py
886
3.546875
4
a="neven" a ="seven" if (a[0] ==a[4]) and (a[1] ==a[3]): print('팰린드롬이다') if a[0] != a[4]: print("팰린드롬이 아니다") elif a[1] !=a[3]: print("팰린드롬이 아니다") else: print("팰린드롬이 아니다.") #i값 0,1 for i in range(2): if a[i]!=a[4-i]: print("팰린드롬이 아니다") a="enevene" if a[0] != a[6]: print("팰린드롬이 아니다") e...
0a6ca0925327fdb6f00b76795fac00ee0d07d145
aisteva/pythonas
/2_PROGRAMA/7.py
410
3.65625
4
#7.Sukurkite atsitiktini masyva dydzio 3x5 naudodami #np.random.rand(3, 5) funkcija ir suskaiciuokite: #suma, eiluciu suma, stulpeliu suma. #array1 = np.arange(9).reshape([3,3]) import numpy as np array = np.random.rand(3, 5) sumAll = array.sum() sumColumn = sum(array) sumRow = array.sum(axis=1) print(array) print...