blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
7439c05ac2d921b0c5a7f9addbdc195892e63001
logan0czy/Cell-Free
/figures.py
3,105
3.546875
4
""" Show the antenna array response shape in 2D/3D beamforming mode. """ import math import os.path as osp import numpy as np import seaborn as sns import matplotlib.pyplot as plt from matplotlib import cm from mpl_toolkits import mplot3d import mpl_toolkits.mplot3d.axes3d as axes3d from comms import CodeBook def plo...
5775159c2b4d569d608a35b1e741f9123082d347
BassamSaadElsafy/pythonCourse
/lab1/prob6.py
502
4.125
4
word = input("enter your string: ") char = input("enter your char you want to search on the entered string: ") res = [] for i in range(0, len(word)): if word[i] == char: res.append(i) if not res: print ("charater '{}' not found in word '{}'".format(char, word)) else: print ("Ch...
a1122679a3107797a992a55a8668bc19d7da811a
deepkarman/ee456_Autumn17-18
/Assignment 1/problem4.py
969
3.6875
4
#y^2=x^3+9x+5 over field mod 13 import os for t in range(0,13): x = ((t**3)+(9*t)+5)%13 if x == 1: print '({},1)'.format(t) print '({},12)'.format(t) elif x == 4: print '({},2)'.format(t) print '({},11)'.format(t) elif x == 9: print '({},3)'.format(t) print '({},10)'.format(t) elif x...
879ecf598ba2a2a142e36b3feea343f6a6cbce45
effyhuihui/leetcode
/interviews/Google.py
20,609
3.65625
4
__author__ = 'effy' # -*- coding: utf-8 -*- ''' Product of word length which words that share no letters(all lower case) E.g {feed , see, stuck }: max product: 5×4=20 Complexity? Follow up:optimal way to exit earlier in loop. ''' def encode(s): encoded = 0 for char in s: encoded |= 1<<(ord(char)-ord('a'...
c50e60212d9a78c6aad85cdfdc4dc583b00f6051
otverskoj/Coursera_Python
/Week 4/number_minimum_divisor.py
216
3.8125
4
def min_divisor(n): max_div = n ** 0.5 d = 2 while d <= max_div: if n % d == 0: return d else: d += 1 else: return n print(min_divisor(int(input())))
047698f70c04db2ef4196a2156fdb0d6ec3d8c8f
bryanluu/AdventOfCode2020
/Day5/Day5.py
1,212
3.921875
4
#!/bin/python3 UPPER = "BR" ROWS = 127 COLS = 7 # function to convert boarding pass into binary string def parse_seat(bp): bin_str = "".join(map(lambda c: '1' if c in UPPER else '0', bp)) row = int(bin_str[0:-3], 2) col = int(bin_str[-3:], 2) return row, col # function to calculate seat ID def seatID(row, co...
c4923bd97f2ca36dea70b8a41f8eca886f953be1
parski/Advent-of-Code
/5/nice.py
869
3.90625
4
file = open('input.txt') def has_vowels(string): vowel_count = 0 for character in string: if character in 'aeiou': vowel_count += 1 if vowel_count < 3: return False return True def has_twice(string): last_character = None for character in string: if characte...
ad90b15913838f3efa8bbd604c7d0c024fed4af9
orlandolepe/Python-Challenge
/PyPoll/main.py
2,829
3.515625
4
import os import csv # declare variables candidates = [] number_votes = 0 vote_counts = [] election_data = ['1'] # start for loop through file for files in election_data: #find csv file election_dataCSV = csvpath = os.path.join("election_data.csv") with open(election_dataCSV) as csvfile: ...
96c38ef12b2483a3c83f9028f1708c261b230e3e
tommulvey/CSC15_python
/9_12/mulveyt-1-2.py
1,013
3.734375
4
#File: mulvey-1.1.py #Purpose: User inputs how many Bitcoin blocks they have mined, and their electricity usage, and the program # computes how much profit is made per month #Author: Thomas Mulvey #Date: 9/12/2017 #Version: 1.01 def main(): print("Welcome to the Bitcoin Mining Proit Program") print('\n')...
2ded57d8aca3f156526dcaa3bdb0cfeaab76119a
prasadabhishek/coding-practice
/Project/Moderate/17.3.py
250
3.796875
4
#trailing zeros in n factorial def fact(n): if(n<=1): return n else: return n * (fact(n-1)) n=input("enter a number : ") print(str(fact(n))) f=fact(n) count=0 while(f%10 ==0): f=int(f/10) count+=1 print(str(count))
40afe8c429fcb706462e2abc39a12aef2d060b50
MoTo-LaBo/Python-Guideline
/database/select.py
784
4.28125
4
import sqlite3 con = sqlite3.connect("sample.db") cursor = con.cursor() # for row in cursor.execute("SELECT * FROM User"): # print(row) # cursor 自体が iterator になっている。イテレータの働きをする # cursor object を irerator として扱っていく cursor.execute("SELECT * FROM User") # print(next(cursor)) # print(next(cursor)) # .fetchall : 現...
305e2c7b078265717cfb77b54b612635e3fffaaf
jvillega/App-Academy-Practice-Problems-I
/TwoSum.py
638
3.8125
4
#!/usr/bin/env python3 # Write a method that takes an array of numbers. If a pair of numbers # in the array sums to zero, return the positions of those two numbers. # If no pair of numbers sums to zero, return `nil`. # # Difficulty: medium. def twoSum( nums ): for x in range( len( nums ) ): if ( x ) == le...
7c90389bc6a6b598e1df914bcc3fe9c2a8fb268b
1565937966/Bowen
/python file/Moduels test.py
458
3.734375
4
# -*- coding: utf-8 -*- """ Created on Sat Aug 25 21:04:26 2018 @author: 15659 """ class People: def __init__(self,name,color,gender): self.name=name self.color=color self.gender=gender def Name(self): return self.name def Color(self): return self.color def Gender(self): return self.gen...
d771350ed9c2b33d87c8c2650fb6aa4a00e2ce0f
alexbagirov/python_hw
/homestat/homestat.py
7,487
3.8125
4
#!/usr/bin/env python3 def make_stat(filename): """ Функция вычисляет статистику по именам за каждый год с учётом пола. """ with open(filename, encoding='cp1251') as f: s = f.read() years = search_all_occurrences(s, '<h3>', '</h3>') current_year = years[0][0] if len(ye...
acdfc633902f00fc248b8cfcb95088ffb2fa863c
jegadeesh2001/Lab-Main
/Sem4/Python/Basics-1/6.py
102
3.890625
4
n = int(input('Enter the number')) dict = {} for i in range(1,n+1): dict[i] = i * i print(dict)
82ea685e176802402f9c80a29a8c5dd5ba562830
pingrunhuang/CodeChallenge
/leetcode/111.py
1,226
4.15625
4
""" Given a binary tree, find its minimum depth. The minimum depth is the number of nodes along the shortest path from the root node down to the nearest leaf node. Note: A leaf is a node with no children. """ # Definition for a binary tree node. # class TreeNode: # def __init__(self, x): # self.val = x #...
ca4ce9d6c87321b0e4fb8130eedc1be1b312a9f0
DarrenGibson/Python-Complete
/PassingArguments.py
1,103
4.1875
4
#--------------------------------------------------------------------- # Passing Arguments #--------------------------------------------------------------------- ''' Date: 08/13/18 Author: Darren / andrew Reese - stack overflow Subject: function arguments Resources: https://...
a6bd9da714e93181425f8985bc30e0e2e07488ab
DaHuO/Supergraph
/codes/CodeJamCrawler/16_0_1_neat/16_0_1_Leeeon_solution.py
787
3.65625
4
caseCount = int(raw_input()) for caseNum in xrange(1, caseCount + 1): numsLeft = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] number = long(raw_input()) currentNumber = number i = 0 if number == 0: print "Case #{}: INSOMNIA".format(caseNum) else: while len(numsLeft) > 0: #get d...
f4b15f4f62d90cc2e1005552a6f839805f0cdd27
Blizzard440/Prog1-ovn
/Miniräknaren.py
932
3.890625
4
main = 0 while main != 4: print('(1) för +') print('(2) för -') print('(3) för *') print('(4) för att avsluta') main = int(input('Välj räknesätt: ')) if main == 1: print('Räkna med addtition') tal1 = float(input('Tal 1: ')) tal2 = float(input('Tal 2: ')) su...
0b497ae6bf95accc463446c359de8cf8aa1742ea
Abhijeet-AR/Rubik-s-Cube-Solver
/rubik's cube.py
46,971
3.515625
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Wed Feb 20 15:28:51 2019 @author: AR """ class Face: def __init__(self, c, l, r, u , d, n = [0, 0]): self.colors = 3*[[c, c, c]] self.left = l self.right = r self.up = u self.down = d self.n = n ...
4193347a6ba334fb8912e7ed19f8abcbc2782e4e
Machin-Learning/Exercises
/list_concat.py
173
3.703125
4
def concat(*n): output_list = [] for i in n: output_list.extend(i) return (output_list) a = [1,2,3],[4,5,6],[7,8],[9] print(concat(*a)) print()
15c2aca088b4cd058534a8fae7ba1bd1e88b34e5
Zaier9/Curso-Prof-Python
/fibonacci.py
828
3.78125
4
import time class FiboIter(): def __init__(self, max:int): self.max = max def __iter__(self): self.num1 = 0 self.num2 = 1 self.counter = 0 return self def __next__(self): if self.counter == 0: self.counter += 1 return self.num1 ...
eb840ffd37a5409b1f68c7699efee094bd24c5e9
singhr2/Python101
/basics/MapReduceFilter.py
4,743
4.25
4
# MapReduceFilter.py # map and filter are key members of Python’s early functional programming toolset # map() function # => Mapping Functions over Iterables: map # Syntax : r = map(func, seq) # The map function applies a passed-in function to each item in an iterable object # and returns a list containing all th...
a41d409780738215523f41f36400bf73cd939b8b
matheusmelchiades/cursoEmVideo-python-exercicios
/exe30.py
168
4.0625
4
#CODE SCRIPT THAT READ A NUMBER AND PRINT IF # IS PAR OR IMPAR number = int(input('Type a number: ')) print(f'Your number is {"PAR" if number % 2 == 0 else "IMPAR"}')
bb60c95442d8b734feb4159c2158b6cea9e03a1a
Moura93/CursoPython
/desafio3.py
637
4.1875
4
''' AUTOR: Felipe Moura Wanderley 3º desafio: RECEBER PESO, ALTURA E SEXO DE 3 PESSOAS CALCULAR O IMC E APRESENTAR NA TELA OS RESULTADOS IMC CLASSIFICAÇÃO <18,5 Magreza 18,5~24,9 Saudável 25,0~29,9 Sobrepeso 30,0~34,9 Obesidade grau 1 35,0~39,9 Obesidade grau 2 >40 Obesidade grau 3 ''' usuario =[] for x ...
97f3954f72990579c844ab0927bfb63a445d10fa
tyralek/python_basics
/lab/07/test_modules_pass.py
2,325
3.5625
4
''' Created on May 15, 2017 @author: pgaj ''' import unittest from collections import Counter, defaultdict, OrderedDict, namedtuple Person = namedtuple('PersonTuppleNameSpeciallyForRafal', 'name, age') class Test(unittest.TestCase): def test_counter_sequence(self): ''' 1st type of initialization...
ad8589222fa770a270075a29299d82f294f73813
zurda/python-exercises-shecodes
/week09/HW09_02_usefull_methods.py
395
3.515625
4
#07 sum = lambda x,y: x+y print(sum(1,5)) #08 joules = [5000, 8000, 10000, 6000, 12000] print(list(map(lambda x: (x, x/4184.0), joules))) #09 my_range = list(range(1,7)) print([(a, b) for a in my_range for b in my_range]) #print(len([(a, b) for a in my_range for b in my_range])) #10 languages = ["HTML", "JavaScript"...
c6eadecf1a7e1042a8de5899721441cd3492d807
Shubham-Gugale-AutomatonAI/pythonbasic
/minmaxline.py
406
4.1875
4
#To accept file name from user and print all its line using readline #Print max length and min length line #!/usr/bin/python import io x=input("Enter File name") fd=io.FileIO(x) line=fd.readline() max=min=line while line != b'': line=fd.readline() if line == b'': break if len(line)<len(min): min=line if len...
54efa7c5da5ddd9cf72d97ccadf337786697cc7f
pmaczuga/kompilatory
/src/zad3_ast.py
3,302
3.59375
4
class Node(object): def __init__(self): self.line = 0 self.column = 0 def accept(self, visitor): return visitor.visit(self) class Program(Node): def __init__(self, instructions): self.instructions = instructions class Instructions(Node): def __init__(self, instructions...
7f7eeee1b3b05c5ee71703cc69a78f3ae012ab12
phww/Andrew.Ng-ML-Study
/code-homework/ML/ex1_Linear Regression/ex1_batch.py
1,957
3.71875
4
import numpy as np import pandas as pd import matplotlib.pyplot as plt data = pd.read_csv("ex1data1.txt",names = ['population','profit']) x = data.population y = data.profit "初始化,所有变量都是matrix" df = data.copy()#因为insert会改变原数组,所以先复制一份,坑1. df.insert(0,"one",1) X = df.iloc[:,0:df.shape[1]-1] y = df.iloc[:,df.shape[1]-1:df....
e87265fd7a6c11aea9cde76cc090e33c422f25aa
ivantoz/Office-Space-Allocation
/app.py
5,174
3.5
4
""" Amity Allocator This system makes it easy to manage rooms and people at Amity. Usage: create_room <room_type> <room_name> ... add_person <employee_number> <first_name> <last_name> <job_type> [(Y|N)] reallocate_person <person_identifier> <new_room> load_people <filename> print_room <room_name> ...
ad922e83d504a80874a50cb078f32f9b83606f62
anindyaspaul/code-kata
/02-karate-chop/main.py
3,363
3.9375
4
from typing import List, Callable def binary_search_v1(query: int, data: List[int]) -> int: """Iterative solution Returns the first occurrence if there are multiple instances of query. """ pos = -1 start = 0 end = len(data)-1 while start <= end: mid = (start+end)//2 ...
a7a4dc63e5ab2c6b0b2af55cb5b6a9d9c7fef503
alfredo-svh/DailyCodingProblem
/270.py
1,460
4
4
# -*- coding: utf-8 -*- """ Created on Sun Jul 26 18:07:43 2020 @author: Alfredo """ # Daily Coding Problem #270 # Problem: # A network consists of nodes labeled 0 to N. You are given a list of # edges (a, b, t), describing the time t it takes for a message # to be sent from node a to node b. Whenever a node receive...
a1bd47e9ef769f35aff2fab101e95ce07b6c04d9
yiming1012/MyLeetCode
/LeetCode/灯泡开关/1375. 灯泡开关 III.py
1,894
4
4
""" 房间中有 n 枚灯泡,编号从 1 到 n,自左向右排成一排。最初,所有的灯都是关着的。 在 k  时刻( k 的取值范围是 0 到 n - 1),我们打开 light[k] 这个灯。 灯的颜色要想 变成蓝色 就必须同时满足下面两个条件: 灯处于打开状态。 排在它之前(左侧)的所有灯也都处于打开状态。 请返回能够让 所有开着的 灯都 变成蓝色 的时刻 数目 。   示例 1: 输入:light = [2,1,3,5,4] 输出:3 解释:所有开着的灯都变蓝的时刻分别是 1,2 和 4 。 示例 2: 输入:light = [3,2,4,1,5] 输出:2 解释:所有开着的灯都变蓝的时刻分别是 3 和 4(in...
dbb3fb4a1da5d05289ec8c6d4dd24b8945856de5
radhaprashanthi/Illumio
/firewall_test.py
2,843
3.59375
4
import unittest from pkg.firewall_class import Firewall class FirewallTesting(unittest.TestCase): def test_valid_ip_address(self): firewall_instance = Firewall('testing.csv') expected_output = True observed_output = firewall_instance.valid_ip_address('192.168.1.1') self.assertEqu...
ed27706ce705389b7c3be1be9686dd167f01ec92
AlexHutchison-Dev/CS50
/Pset6/readability/readability.py
1,263
3.8125
4
from cs50 import get_string # Get text from user s = get_string("Text: ") words = 0 inword = False letters = 0 words = 0 sentences = 0 # Itterate over characters in user inputted string for c in s: # stop sample if we hit 100 words if (words > 100): break # check for alpha and deal as apropri...
63acea72e78bd82660bdd418473b595b6fae15f2
watson665/python_online_course
/Python/flow-control/Demos/loops.py
1,069
4.03125
4
# while loop num = 0 while num < 6: print(num) num += 1 # for loops with ranges for num in range(6): print(num) for num in range(0, 6): print(num) for num in range(1, 11, 2): print(num) for num in range(10, 0, -1): print(num) # Looping through a list nums = [0, 1, 2, 3, ...
0aa767644603d56f3f0bb3d8e40f3997a85940a5
VenkateshSatagopan/Data-Structures
/Sorting/merge_sort.py
1,282
4.28125
4
def merge(arr,p,q): ''' Function to perform merge- sort ''' if p<q: # Base condition for recursion m = (p + q )//2 merge(arr,p,m) # Divide left part of array merge(arr,m+1,q) # Divide right part of array return merge_array(arr,p,m,q) # Merge left and right part of the ar...
6f8403c3578bdc59ff62cc86219cfacf7bb8bedd
hugodecastro/curso-regex
/grupos/gruposEspeciais1.py
348
3.703125
4
import re texto = 'Joao eh calmo, mas no transito fica nervoso.' print(re.findall(r'[\w]+', texto, re.IGNORECASE)) print(re.findall(r'[\w]+(?=,)', texto, re.IGNORECASE)) print(re.findall(r'[\w]+(?=\.)', texto, re.IGNORECASE)) print(re.findall(r'[\w]+\b(?!,)', texto, re.IGNORECASE)) print(re.findall(r'[\w]+[\s|\.](?...
48a84a0b0d127bf1dc400396ea8457ddd63d142d
EdickssonM/PYTHON_CLASS
/ejercicio5.py
150
3.75
4
tabi =int(input("ingrese el numero inicial del rango:.")) tabmax=int(input("ingrese el numero final del rango")) print(list(range(tabi, tabmax + 1)))
00cd9a38b1ea2985a4eef69b78bf04ad8ebe7c4c
cwx727/Python-Advanced-Programming-and-Asynchronous-IO-Concurrent-Programmin
/chapter02-everything_is_object/all_is_object.py
324
3.625
4
def ask(name='bobby'): print(name) class Person(): def __init__(self): print('bobby2') list_objs = [ask, Person] for list_obj in list_objs: list_obj() def decorate_func(): print('bobby3') return ask my_ask = decorate_func() my_ask('Tom') my_func = ask my_func('bobby') my_class = Person my_cla...
04f551476cbd12c311691e9e3600a9d69da3fb7b
shanghungshih/search4text
/search4text.py
821
3.5625
4
import glob import os def search4text(path, text): def read(file, text): try: with open(file) as f: next_line = f.readline() while next_line: if text in next_line: print(file) break ...
f179093ef129a8f9aac11bdd70eff90a7105d9b8
vmara2/Cookbook
/JES Jython/vmara2lab3.py
552
3.9375
4
#Valo Mara #vmara2 #Monday at 3:00 #Drawing a spirograph on a picture filename = pickAFile() pict = makePicture(filename) t = makeTurtle(pict) t.setPenColor(yellow) t.setPenWidth(3) turn(t, 18) def drawStar(): sideCount = 1 while (sideCount <= 5): forward(t) forward(t) turn(t, (720/5)) sideCou...
aff705cb4e74c6069eff9e29de090848923fe4a0
nancyzyhu/algorithm_described_by_python
/search_algorithm/bfs.py
1,201
3.65625
4
# -*- coding: utf8 -*- # 实现广度优先搜索算法 import collections # 定义一个图 graph = dict() graph['me'] = ['hello', 'world', 'sking'] graph['hello'] = ['sk', 's4'] graph['s4'] = ['sk'] graph['sk'] = [] graph['world'] = ['s2'] graph['s2'] = [] graph['sking'] = ['s3'] graph['s3'] = [] def is_finish_search(vertex): # 判断当前搜索顶点是...
93c598799460809c3f1cbe1a927091894a2053d9
Tuchev/Python-Fundamentals---january---2021
/07.Dictionaries/02.Dictionaries_-_Exercise/05. SoftUni Parking.py
814
3.859375
4
n = int(input()) registered_users = {} for _ in range(n): data = input().split() command = data[0] user = data[1] if len(data) > 2: license_plate = data[2] if command == "register": if user not in registered_users: registered_users[user] = license_plate ...
59b7ed7b8f15f443bb3ebe001c43b9605b931f77
Artem89234/Class_DZ
/main(4).py
1,808
3.875
4
import datetime class Territory: def __init__(self, date=None, surface=True, title=None, population=1000, dragon=None): self.date = date self.surface = surface self.title = title self.population = population self.dragon = dragon def show(self): if self.surface: ...
6660fb23965422175aca9db8c52d6bebbf688041
DavTho1983/Regex
/regex2.py
127
3.59375
4
import re split_term = '@' email = 'user@gmail.com' email2 = 'david@gmail.com'.split('@') print(re.split(split_term, email)) print(email2)
1f563bdfdb85e89647b8868602239cd1fc1deeb9
brotaku13/PUBG_Sqlite_database
/table_creation.py
7,004
3.546875
4
import sqlite3 as sql import csv from pathlib import Path import utility_functions FOLDER = Path(Path.cwd()) / Path("Files") PLAYER_DATA = FOLDER / Path("player_data.csv") PUBG_DB = FOLDER / Path("pubg_game_db.sqlite3") TEAM_NAMES = FOLDER / Path("team_names.csv") def drop_table(table_name, conn, curr): """ Dr...
18f00fd9de155f977cdf10216023850c4f6fe774
jungwonkkim/swexpert
/boj1920.py
501
3.859375
4
#수 찾기 def binarysearch(arr, key): start = 0 end = len(arr)-1 while end >= start: half = (start + end) // 2 if arr[half] == key: return 1 elif arr[half] > key: end = half-1 else: start = half+1 return 0 n = int(input()) num_list = li...
39cd91c1e0d4e2c8d1bf3970f7ece09dc1e2a725
colorfulgrayscale/bandviz
/bandviz/bandmanager.py
12,493
3.78125
4
#!/usr/bin/env python """ bandViz Coded by Tejeshwar Sangameswaran tejeshwar.s@gmail.com http://www.colorfulgrayscale.com """ class Artist: """Artist class to store artist entity information""" def __init__(self, name="",instrument=""): """Constructor""" #name of artist ...
550cfd9baa2f54636a2d44ad1f080af8c62cb2b7
shreyassk18/MyPyCharmProject
/Basic Programs/Fibonacci.py
271
4.21875
4
#A series of numbers in which each number is the sum of the two preceding numbers f1=0 f2=1 f = int(input("Enter a range\n")) print("The fibonacci series for %d is:"%(f)) print(f1) print(f2) for i in range(1, f+1): fib = f1+f2 print(fib) f1=f2 f2=fib
15b06d97603346bac8457994acd3ad7fbb9769ef
yatengLG/leetcode-python
/question_bank/unique-number-of-occurrences/unique-number-of-occurrences.py
582
3.5625
4
# -*- coding: utf-8 -*- # @Author : LG """ 执行用时:44 ms, 在所有 Python3 提交中击败了95.14% 的用户 内存消耗:13.7 MB, 在所有 Python3 提交中击败了5.42% 的用户 解题思路: 先统计每个数出现的次数 然后查看次数是否存在重复 """ class Solution: def uniqueOccurrences(self, arr: List[int]) -> bool: record = {} for a in arr: if a in record: ...
25fe4a97312dd76d9af47aba448f8216a7676815
SamuelVera/Algorithims-Misc
/binarySearch/Python/binarySearchRecursive.py
2,141
4.28125
4
import sys def binarySearch(sortedArr: list, l: int, r: int, x: int) -> int: """Do a binary search recursively ------------------- Complexity: Time: O(log(n)) Space: O(log(n) + n) Array in memory + stack calls Parameters: ----------- sortedArr : list Sorted array o...
1c963e2ec453c786f1b96f238be6d1cf5f9a2c2e
sunrisejade/DataCamp
/Importing Data in Python (Part 1)/Importing Data in Python (Part 1).py
4,925
4.71875
5
1.Introduction and flat files --- Importing entire text files In this exercise, you'll be working with the file moby_dick.txt. It is a text file that contains the opening sentences of Moby Dick, one of the great American novels! Here you'll get experience opening a text file, printing its contents to the shell and,...
cc43b3ff7bd3ca8fdd3aca4d465665e0c6227d40
UncleBob2/MyPythonCookBook
/Intro to Python book/chaos/blackjack sln.py
2,385
3.890625
4
from random import randrange def main(): #n = getinputs() #busts = simNGames(n) #printSummary(busts, n) print(simOneGame()) def getinputs(): n = eval(input("How many games do you want to simulate ?")) return n def simNGames(n): bustsDealer = 0 for i in range(n): # Call the ...
745ce644c54e2b09a6cc7d538a9e461b2017a072
himanshuguptagit/cracking-the-coding-interview
/Exercises/2. Linked Lists/2.8 Loop Detection/hasLoop.py
1,181
3.640625
4
import sys import os sys.path.append(os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))) from Util.Node import Node from Util.LinkedList import LinkedList def hasLoop(linkedList): isLoopPresent = False slow = linkedList.head fast = linkedList.head while(fast!= None or ...
93d00cd8cc291bcaf62e9430a5d955f9bcd04848
akashgurava/git-test
/gittest/osops.py
601
3.78125
4
""" A simple module for common OS Operations """ from pathlib import Path def get_filename(path: str) -> str: """ Get the filename from `path` """ return Path(path).name def get_foldername(path: str) -> str: """ Get the last foldername from `path` """ return Path(path).parent.name ...
baf95446cae39fa384d69f2aae48aa85dbdf45c5
rafaelperazzo/programacao-web
/moodledata/vpl_data/380/usersdata/321/78702/submittedfiles/testes.py
975
3.984375
4
a= int(input('Digite um número: ')) b= int(input('Digite um número: ')) c= int(input('Digite um número: ')) if a > b and b > c : print('MAIOR:'a', INTER:'b', MENOR:'c) elif a > c and c > b : print('MAIOR:'a', INTER:'c', MENOR:'b) elif b > a and a > c : print('MAIOR:'b', INTER:'a', MENOR:'c) elif b > c and ...
7066382852dde8b0129fd7b47a19e0ed55a5ff36
catalinc/programmingpraxis-solutions
/python/src/wc.py
2,023
3.90625
4
#!/usr/bin/env python """ wc.py -- word count wc.py [-lcw] [-f file] Wc counts lines, words and characters in the named file, or in the standard input if no file is specified. A word is a maximal string of characters delimited by spaces, tabs or newlines. If the optional argument is present, just the specified coun...
a40e575d275a2e7283c7cf1a05b9d5ae5b9ded1f
btwmendes/Data-Structures-Algorithms
/section_3_recursion/fibonacci.py
265
4.09375
4
def fibonacci(n): """n is the index in the fibonacci sequence.""" assert n >= 0 and int(n) == n, 'The number must be a positive integer only' if n in [0, 1]: return n else: return fibonacci(n-1) + fibonacci(n-2) print(fibonacci(11))
ffaebeaf13accb8bb24ce96382e5a320f3e13409
Raghavendra-Gali/CompetitiveProgramming
/Week3/Day1/Programs/roll_7_dice.py
282
3.734375
4
import random def rand7(): def rand5(): return random.randint(1,5) while True: throw_one = rand5() throw_two = rand5() total_Events = (throw_one-1)*5+(throw_two-1)+1 if total_Events > 21: continue return total_Events%7+1 print('Rolling 7-sided dice') print(rand7())
17b315fb5315874210bab74a7e579af15b7d02bc
Notepad96/Python
/Basic_Syntax/Example.py
1,013
4.0625
4
print("Hello World") print("\n=============1==============") print(1 == 1) # True print(not(1 == 1)) # False print(2 or True) # 2 print(True or 2) # True print(3 and True) # True print("\n=============2==============") print(14 // 3) # 4 (몫 print(14 % 3) # 2 (나머지 print(5 ** 3) # 125 print("\n======...
62d72ce493d833b98b07929079ec8ac061031bd2
iiinjoy/algorithms_python_lessons
/level1/test_lesson1.py
4,961
3.65625
4
#!/usr/bin/env python3 import unittest from lesson1 import * class TestLinkedListMethods(unittest.TestCase): def test_delete_1(self): L1 = LinkedList() L1.add_in_tail(Node(42)) self.assertEqual(L1.head, L1.tail) self.assertEqual(L1.head.value, 42) L1.delete(42) se...
da95d15ee0d61675fbc024891e410afe08ca86f5
stldavids/01-Introduction
/main.py
1,490
3.734375
4
#!/usr/bin/env python3 import utils utils.check_version((3,7)) utils.clear() bee = "According to all known laws of aviation, there is no way that a bee should be able to fly. Its wings are too small to get its fat little body off the ground. The bee, of course, flies anyways. Because bees don't care what humans thin...
3a3d0be27e884e0aac48989d6409c8835660540c
arovit/Coding-practise
/misc/diving_board.py
710
3.765625
4
#!/usr/bin/python ## Total number of boards K ## Shorter Board len short ## Longer Board len long def getAllLengths(total, count, short, long, visited): key = "%s#%s"%(total, count) if key in visited: return if count == 0: print total else: getAllLengths(total+short, count - ...
897faeb0e4f1ee3a393be9185004352cf66ab3c7
Gabrielkaliboy/demo
/markdown/python_liaoxuefeng_3.5_2/7.4.py
2,396
4.25
4
#Python内建的filter()函数用于过滤序列。 #和map()类似,filter()也接收一个函数和一个序列。和map()不同的是,filter()把传入的函数依次作用于每个元素,然后根据返回值是True还是False决定保留还是丢弃该元素。 #例如,在一个list中,删掉偶数,只保留奇数,可以这么写: def is_odd(n): return n % 2==1 print("过滤奇数",list(filter(is_odd,[1,2,3,4,5,6]))) def not_empty(s): return s and s.strip() print(list(filter(not_emp...
7f1ceeb615ef63ff9d6f43e1418b7b2c4b47358e
lalitkapoor112000/Python
/Word Counter using Dictionary.py
163
4.0625
4
def wordCount(s): count={} for c in s: count[c]=s.count(c) return count n=input("Enter any word to count words:") print(wordCount(n))
efa98f3b754861a1a3f8ca5e1cba9d2b5b04aff3
EdwaRen/Competitve-Programming
/Leetcode/191.number-of-1-bits.py
373
3.53125
4
class Solution(object): def hammingWeight(self, n): # Use bit manipulation algorithm from Hamming Distance # n & (n-1) will remove the last (smallest) 1 bit while keeping the rest intact res = 0 while n: res += 1 n = n & (n-1) return res ...
d1f2cdd6f7fd4d612c9a689108d4057a68f5a70a
vikcui/find_the_duplicate_num
/find_the_duplicate_number_floyds_tortoise_and_hare.py
1,028
3.984375
4
# author: YANG CUI """ Given an array nums containing n + 1 integers where each integer is between 1 and n (inclusive), prove that at least one duplicate number must exist. Assume that there is only one duplicate number, find the duplicate one. """ def findDuplicate(nums): """ :param nums: input list where the...
558df7e4b74fe1c6b22a844708fca39850df2ead
Magicxiangye/pythonDeepNNLearnCode
/pltCodeFunctionDict.py
2,856
3.609375
4
#可视化数据库matplotlib的代码实验 from collections import Counter from matplotlib import pyplot as plt # simpleImage def SimpleImage(): #两个坐标轴的数据(个数要相同) years = [1950, 1960, 1970, 1980, 1990, 2000, 2010] gdp = [100, 200, 345, 674, 343, 349, 567] # 线图(颜色、标记点的形状、line的样式) plt.plot(years, gdp, color='blue', m...
0f8b93e1bad61202138282fedebaad0476e7a6a6
amtesire/Password-Locker
/password.py
375
3.625
4
import pyperclip class User: ''' Class to create user accounts and save their details ''' def __init__(self,first_name,last_name,password): self.first_name = first_name self.last_name = last_name self.password = password users_list = [] def save_user(self): ''' Method to save a newly created user ...
97f4d4bf6bbeea91ac82ddf267e8c6fc3e00e32a
LiuXPeng/leetcode
/109.py
966
3.875
4
# Definition for a binary tree node. # class TreeNode(object): # def __init__(self, x): # self.val = x # self.left = None # self.right = None class Solution(object): def sortedListToBST(self, head): """ :type head: ListNode :rtype: TreeNode """ if...
10a332b2f9e49248ed0d2d9aaa94870286f99a25
jeffbass/imagezmq
/tests/timing_send_jpg_buf.py
2,483
3.578125
4
"""timing_send_jpg_buf.py -- send PiCamera image stream, compressing images. A Raspberry Pi test program that uses imagezmq to send image frames from the PiCamera continuously to a receiving program on a Mac that will display the images as a video stream. Images are jpg compressed before sending. This program require...
849aa729bea470b206847680bb591e62842d6e37
Zhangkaiwen2001/Myprojects
/python/email/SMTPClient.py
762
3.5625
4
import smtplib import email def prompt(pmt): return input(pmt).strip() fromaddr = prompt("From:") toaddr = prompt("To:") subject = prompt("Subject:") print("Enter message, end with continuously enter:") text = "" while True: try: line = input() except EOFError: break if len(line) == ...
2054df0f1cbe4507e196943a33a8ac0478310643
rlagur9286/algo
/remove_node.py
1,244
3.84375
4
# --------------------------------------------------------- # 링크드리스트에서 중간 노드 삭제하기 # 시간 복잡도: O(N) # 공간 복잡도: O(N) # 참조: https://www.youtube.com/watch?v=_RUGwY_tCFE&index=8&list=PLVNY1HnUlO24RlncfRjfoZHnD0YWVsvhq from duplicated_linked_list import LinkedList class NewLinkedList(LinkedList): def remove(self, item): ...
105aedc0485cd5265aa365e46b4f05fa0619bff4
kbh1860/Studying_OpenCV
/Show_Image_Gray.py
651
3.53125
4
import cv2 Img_Color = cv2.imread("Image_Sample.jpg", cv2.IMREAD_COLOR) if Img_Color is None: print("Failed To Load Image") exit(1) cv2.namedWindow("Color") cv2.imshow('Color', Img_Color) cv2.waitKey(0) Img_Gray = cv2.cvtColor(Img_Color, cv2.COLOR_BGR2GRAY) #Change The Color To Gray #First...
49c47ae8ee71a0d9e62a822baf0bde82138755b8
vishnu5898/DS_with_Python
/Module_1/Sorting/insertion_sort.py
271
4.0625
4
def insertion_sort(arr): n = len(arr) for i in range(1,n): x = arr[i] j = i - 1 while(j >= 0 and x < arr[j]): arr[j+1] = arr[j] j -= 1 arr[j+1] = x array = [4,10,3,7,12,7] insertion_sort(array) print(array)
3843740bae87e567e7598756a5fc7313563f35f8
Coders222/Shared
/CCC/CCC 08 J3 GPS Text Entry.py
890
3.78125
4
keypad = [ list("ABCDEF"), list("GHIJKL"), list("MNOPQR"), list("STUVWX"), ['Y', 'Z', "SPACE", "-", ".", "ENTER"] ] ramadan = input() ramadan = list(ramadan.upper()) for i in range(len(ramadan)): if ramadan[i] == " ": ramadan[i] = "SPACE" ramadan.append("ENTER") matr...
6db2c7714ef720ff262faad6b5e6a1de520935c5
devyogilogic/PythonWprks
/Quadratic Equation.py
276
3.796875
4
import cmath a = int(int("Enter the value of A")) b = int(int("Enter the value of B")) c = int(int("Enter the value of C")) # Discriminent d = (b**2) - (4*a*c) root1 = (-b - cmath.sqrt(d)) / (2 * a) root2 = (-b + cmath.sqrt(d)) / (2 * a) print(root1) print(root2)
0006cd3dd40d93f95dae084fbd6d80806551a946
tahir24434/py-ds-algo
/CodingInterviewProblems/DynamicProgramming/stair_climb.py
385
3.875
4
""" Count ways to reach the n’th stair: There are n stairs, a person standing at the bottom wants to reach the top. The person can climb either 1 stair or 2 stairs at a time. Count the number of ways, the person can reach the top. """ def num_ways(n): nw = [0] * (n + 1) nw[0] = 1 nw[1] = 1 for i in ra...
737d56d4100ecda5a69a36bad436770a0db909c3
Velyana/Python-University
/hom2.py
1,180
3.78125
4
from functools import cmp_to_key def is_pangram(sentence): letters = 'абвгдежзийклмнопрстуфхцчшщъьюя' for letter in letters: if not letter in sentence.lower(): return False return True def char_histogram(text): result = {} for symbol in text: result[str(symbol)] = tex...
745254fb65ccbd7eb8ff6c40b69bc54d875b6e88
Ibukun-Badmus/Datascience_Exercises_With_Python
/Group.py
281
3.5625
4
ds_group_collection = {} def group_names(): for i in range(1): x = input("Enter the key: ") y = input("Enter the values: ") ds_group_collection[x] = [y] return ds_group_collection if __name__ == '__main__': print(group_names())
742cf27795ccef7306bb9b9a47709727c675d017
DL-py/pandas-notebook
/002Dataframe.py
1,205
3.640625
4
""" Dataframe:表格型的数据结构 """ """ Dataframe的创建: *. 一般是通过字典来进行创建 """ import pandas as pd data = {'state': ['Ohio', 'Ohio', 'Ohio', 'Nevada', 'Nevada', 'Nevada'], 'year': [2000, 2001, 2002, 2001, 2002, 2003], 'pop': [1.5, 1.7, 3.6, 2.4, 2.9, 3.2]} frame = pd.DataFrame(data) # 指定列的顺序: frame = pd.DataFrame(da...
82336a860e540ac652c2797805c85aa324d30c6c
limahseng/euler
/euler3.py
258
3.625
4
number = 600851475143 #endpoint is square root of number endpoint = int(number**0.5) #count the largest factor largest=0 for i in range(2, endpoint): if number%i==0: number=number/i largest=i print("The highest prime factor is", largest)
b7e8493f3d18569adf031ee7bdb8a9dc64347fa1
kimurakousuke/MeiKaiPython
/chap03/list0328.py
267
4.125
4
# 计算并输出较小的数字和较大的数字(其五:min函数和max函数) a = int(input('整数a:')) b = int(input('整数b:')) min2 = min(a, b) max2 = max(a, b) print('较小的数字是', min2, '。') print('较大的数字是', max2, '。')
88fa321fa55d58ad43b8f58b560c120d0b63c9e2
moontasirabtahee/OOP_Python_BRACU
/CSE111 Lab Assignment 1/String/Task2.py
134
3.9375
4
#Task2 String = input() if String.isalpha(): print("WORD") elif String.isnumeric(): print("NUMBER") else: print("MIXED")
f7c3b9a82d71a2358343884852f0081a98795ef1
flsantos0101/python_scripts
/src/tuples/db_users.py
556
3.65625
4
number_of_inputs = int(input()) db = {} for i in range(number_of_inputs): age = int(input()) char_name = input() sex = input() marital_status = input() friends = int(input()) photos = int(input()) info = tuple((age,sex,marital_status,friends,photos)) db[char_name] = info for i in db: ...
f9f54b5eb64bda74b08f46bf5d70e5a51e544b23
daqin517/test_pandas
/venv/test_1/tc5.py
461
3.5
4
import pandas as pd pd.set_option('display.unicode.east_asian_width', True) df = pd.read_csv('test.csv') df['物理'] = [88,79,60] df = df.set_index(['学号'],drop=True) print(df) print('===============') print(df['数学'][110]) print('===============') print(df.at[110,'数学']) print('===============') print(df['语文']<110) pr...
32b7d06c4deb2283420e30c819ec53cdceffbd3b
kaito4213/AI-2048-Game-Player
/algorithms/Qlearning.py
5,101
3.546875
4
import copy import numpy as np from core.evaluate_function import * from core.logic import * from core.utils import * def initialization(): """ decrease_pairs represents the number of pairs in which the second number is less than the first number, empty number is taken as 0 in 2048 game, the board is s...
c0713faabf8695f11514bc8336d601a9dc66daf5
rahul0070/Poker
/Poker.py
4,230
3.5
4
import unittest class PokerGame: # [A, K, Q, 10, 9, 8, 6, 5, 4, 3, 2] valueOfRank = {'2':1, '3':2, '4':3, '5':4, '6':5, '7':6, '8':7, '9':8, '10':9, 'J':10, 'Q':11, 'K':12, 'A':13} allScores = {'1':'Straight Flush', '4':'Flush', '2':'Four of a Kind', '3':'Full House', '5':'Straight', '6':'Three of a Kind', '7':'Two...
e3087b4f55f5ced23f8714e691611b9a5a5850b7
chayan0424/ML-projects-under-Summer-internship
/ANN-deeplearning/Artificial Neural Networks.py
3,899
3.75
4
# ANN # Part 1-Data Preprocessing # Importing the libraries import numpy as np import matplotlib.pyplot as plt import pandas as pd # Importing Dataset dataset=pd.read_csv("Churn_Modelling.csv") X= dataset.iloc[:,3:13].values y=dataset.iloc[:,13].values # Encoding Categorical Data from sklearn.preproc...
8ea7dd0d8680a14bf23cf383683fee99c712f47f
compjour/compjour-class-site
/source/files/code/opener-project/stanford-news-download.py
525
3.59375
4
import requests dirname = "data-hold/stuff" print("Downloading the news.stanford.edu homepage") # fetch the page from the URL response = requests.get("http://news.stanford.edu/") # get the "text" attribute of the response rawhtml = response.text print("news.stanford.edu has", len(rawhtml), "characters") # fancy string ...
e31f6d88f3be9cc337dfbb0d2f2364fe4190c836
c-okelly/advent_of_code_2017
/python/day08.py
1,802
3.765625
4
def main(): puzzleInput = open("python/day08.txt", "r").read() # Part 1 assert(part1("""b inc 5 if a > 1 a inc 1 if b < 5 c dec -10 if a >= 1 c inc -20 if c == 10""") == 1) print(part1(puzzleInput)) # # Part 2 # assert(part2("") == 0) # print(part2(puzzleInput)) def part1(puzzleInput...
6ff257b9945c5a8f8bd428ae58240967adce1052
mcgettin/githubLabNMG
/cloudComp/euler/eu9.py
784
4.3125
4
""" A Pythagorean triplet is a set of three natural numbers, a < b < c, for which a2 + b2 = c2 For example, 32 + 42 = 9 + 16 = 25 = 52. There exists exactly one Pythagorean triplet for which a + b + c = 1000. Find the product abc. """ A=B=C=0 #the triplet variables to be found for a in range (1,333): #logically wo...
3a390d78a70a4d39fc420af3c18ad5d3d80178c3
rexhzhang/LeetCodeProbelms
/Sweeping Line/LeetCode252_MeetingRooms.py
735
3.734375
4
""" Given an array of meeting time intervals consisting of start and end times [[s1,e1],[s2,e2],...] (si < ei), determine if a person could attend all meetings. Example 1: Input: [[0,30],[5,10],[15,20]] Output: false Example 2: Input: [[7,10],[2,4]] Output: true """ class Solution: def canAttendMe...
72c8955f5d20368ac0c677cc5ad4fb60efb282ca
supriyo1598/Python_Tutorial_Code
/armstrong.py
185
3.9375
4
a=int(input("Enter the number:")) n=a sum=0 while a!=0: r=a%10 x=r**3 sum=sum+x a=a//10 if sum==n: print("Armstrong Number") else: print("Not Armstrong Number")
1ef3b44d3a9363fb5a3c9a64dfe2fddb21670a92
seanchen513/leetcode
/math/1271_hexspeak.py
1,823
3.953125
4
""" 1271. Hexspeak Easy A decimal number can be converted to its Hexspeak representation by first converting it to an uppercase hexadecimal string, then replacing all occurrences of the digit 0 with the letter O, and the digit 1 with the letter I. Such a representation is valid if and only if it consists only of the ...
1fafafcceea922681dcac4858b64ce18d0117455
IskanderR22/Python
/Algos.py
2,143
4.34375
4
# Variables #Containers / stores data #Vary / assign data hello = "hello there!" # What is a valid variable name to the computer is_this_a_valid_variable_name = "Hello!" # Yes it is faksjbfasjkdfbasdfbajhsdfbhas = "Hello!" # Also valid but not a good one # - Naming conventions # Python naming convention ...
d058571f2789531c78b98b6601ea141181b7a736
Yuri0314/LintCode
/ProblemSet/464 · 整数排序 II/python/464 · 整数排序 II 归并排序 非递归实现.py
1,248
3.5625
4
class Solution: """ @param A: an integer array @return: nothing """ def sortIntegers2(self, A): self.n = len(A) self.mergeSort(A) def mergeSort(self, nums): tmp = [None] * (self.n) subLen = 1 while subLen < self.n: self.mergePass(nums, tmp, su...
d66007f47e7fe199802a94aadc84fd6319e6b8b6
jasonbrackman/tic_tac_toe
/tic_tac_toe.py
4,687
3.578125
4
import random class TicTacToe: def __init__(self): self.user = 'X' self.ai = 'O' self.cells = [ [' ', ' ', ' '], [' ', ' ', ' '], [' ', ' ', ' '], ] self.turn = 0 # __ Validators def is_position_valid(self, pos): # mus...