blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
58293f1f659653a907d4e8bdd2f0f9ab59888f30
law35/Weekly-Expendature-Graph
/Bar charts.py
886
3.796875
4
"""Weekly expenditures:""" import matplotlib.pyplot as plt def draw_bar_graph(data, labels): num_bars = len(data) positions = range(1, num_bars + 1) plt.barh(positions, data, align = 'center') plt.yticks(positions, labels) plt.xlabel('Amount') plt.ylabel('Catagories') plt.title('Weekly Expen...
e4a741b36a99b4754efdcf0ae4173a2056909337
ranjithkumar121/Data_Structure
/linearsearch.py
288
4
4
def search(arr,n,x): for i in range(0,n): if(arr[i] == x): return i return -1 arr = [1,2,6,3,7,8] x = 1 n = len(arr) result = search(arr,n,x) if(result == -1): print("Element not found") else: print("Element found at index ",result)
b98135c387649a9c148ce47a926b84940124df05
cnguyen83/learn-python-hard-way
/ex3.py
778
4.125
4
# Print start statement. PEMDAS print "I will now count my chickens:" # Print hens and roosters. / * % go first print "Hens", 25.0 + 30.0 / 6.0 # 30 print "Roosters", 100 - 25 * 3 % 4 # 97 # Print eggs. % / left to right. print "Now I will count the eggs:" print 3 + 2 + 1 - 5 + 4 % 2 - 1 / 4 + 6 # 7 print "Partial ...
ef125de24f07904f2f39c524b4b39c63d8e88e4b
mikesorsibin/PythonHero
/Functions/function_rangecheck.py
336
3.78125
4
def ran_check(num,low,high): if num in range(low,high): print(f"{num} is in range of {low} and {high}") else: print(f"{num} not in range") ran_check(2,1,9) ran_check(2,3,9) def ran_check_bool(num,low,high): return num in range(low,high) print(ran_check_bool(2,1,9)) print(ran_check_bool(2...
830939a82ec23093671179b718f3ac02f112bdc8
michalisFr/last_will
/last_will/file_encryption.py
3,710
3.609375
4
from pretty_bad_protocol import gnupg from pathlib import Path import shutil def import_pubkey(pubkey): """This function takes as argument the public key filepath, reads the key from file and adds it to the keychain. The key will be used in encrypt_info to encrypt the file. It returns a gpg object that co...
346f3c1dd08de93850527f31a6eda27d0148a680
A-French-PngHash/PonziPyramidalSystem
/Client/mainclient.py
6,059
3.546875
4
from Client.hashing import * import requests import os import sys token = "" invitation_code = "" current_balance = 0 def welcome_message(): print( "Welcome to the \"Hoped Programm\" where you can begin to earn money in juste a few days ! All you need to do" " is recruit other persons.") def be...
8afef4475ea33fb0a914018d4ec80ba434ac66e6
RoanPaulS/Whileloop_Python
/divby_both_2_3.py
134
3.640625
4
first = 1; last = 100; while(first <= last): if(first%2 == 0 and first%3 == 0): print(first); first = first +1;
345fb68e8b72971feccbc4fecaa12f4c4e1cf4e4
Ayoabass/Whitt-Company
/2a.py
851
3.515625
4
from pulp import * prob = LpProblem("Problem 2.", LpMinimize) x1 = LpVariable('x_1', lowBound = 0) x2 = LpVariable('x_2', lowBound = 0) x3 = LpVariable('x_3', lowBound = 0) # Objective function prob += 3*x1 + 3*x2 + 5*x3, "Obj" # Constraints prob += 2*x1 + x3 >= 8 prob += x2 + x3 >= 6 prob += 6*x1 + 8*x2 >= 48 print(...
12afde179467ad9e8262a1d5be5f85776f92dab8
Shubhamsingh7/Python-Exercise-File-
/euler 4.py
673
3.5625
4
import sys def prime(n): flag=0 for i in range(2,n//2): if n%i==0: flag=1 else: pass if flag==0: return True else: return False def palindrome(n): a=n i=0 num=0 while(n!=0): rem=n%10 num=nu...
500fcff3bc8d47ce5b847bbe9e5d6d2e98dc2b99
aminbeirami/dataVisualization
/Bar Charts/basicBarChartMatplot.py
282
3.5625
4
import matplotlib.pyplot as plt plt.bar([1,3,5,7,9],[5,2,3,6,8], label= 'example one', color = 'r') plt.bar([2,4,6,8,10],[3,6,7,2,1], label = 'example two', color = 'g') plt.xlabel = ('bar number') plt.ylabel = ('bar height') plt. title ('just a practice') plt.legend() plt.show()
b0e69fa86238add45dd66244891011549b3124b8
manmohanalla2/aisera
/challenge1.py
697
3.75
4
def three_percentage(string): counter = 0 value_holder = 0 result = False for i in string: if i.isdigit(): digit = int(i) if digit + value_holder == 10: if counter != 3: return False result = True value_hold...
4d3f63f2a12b8008bc4954a88977671dafae0fe3
yezaki/pyCSV-1
/src/test/test_sample_csv_file.py
1,111
3.578125
4
# -*- coding: utf-8 -*- """ Unit test for sample_csv_file.py """ import sys sys.path.append('../') # 親ディレクトリの親ディレクトリを読み込む import unittest from sample_csv_file import csvfl_csvToList from sample_csv_file import csvfl_listToCsv newData = [] dataDir = r"C:\work\GitHub\pyCSV\data" csvFullPath = dataDir + r'\sample_data.C...
44100ba7957a6ce497203d8eabf17d5a7182663a
legendofmiracles/dots
/bin/jonas
176
4.15625
4
#!/usr/bin/env python3 print("HALLO JONAS!") jonas = input("DU BIST DOCH JONAS, ODER? (Y/N)") if jonas == "Y": print("HALLO JONAS!") else: print("HAU AB! NUR JONASE DUERFEN DAS HIER NUTZEN")
ec4e5c686b6a954d6adc2f1bdd1a560c7ef2ba13
alxtt/Algorithms-and-Data-Structures
/books/Algorithms+DataStructures/binary_search.py
1,429
3.828125
4
import random """ Binary Search """ """ binary_search: returns index of key if found, -1 if not found. """ def binary_search(a, start, end, key): mid = start + (end-start)//2 if( key < a[mid] ): return binary_search(a,start,mid-1,key) elif(key > a[mid] ): return binary_search(a,mid+1,end,key) elif(key...
ae26fe4efb28a77c1efa0d2ee42331aee646ab89
deveshrattan/dsabeginning
/day3_quick.py
772
4
4
import random def partition(arr, low ,high): pivot=arr[high] i=low for j in range(i,high): if (arr[j]<=pivot): arr[j],arr[i]=arr[i],arr[j] i+=1 arr[i],arr[high]=arr[high],arr[i] return i def quicksort(arr, low, high): if(low<high): p=partition(arr,low,hi...
94412e759cd91eb5d81d7b66374cba5d033d0088
dylanlee101/leetcode
/code_week32_1130_126/reorganize_string.py
1,172
3.5
4
''' 给定一个字符串S,检查是否能重新排布其中的字母,使得两相邻的字符不同。 若可行,输出任意可行的结果。若不可行,返回空字符串。 示例 1: 输入: S = "aab" 输出: "aba" 示例 2: 输入: S = "aaab" 输出: "" 来源:力扣(LeetCode) 链接:https://leetcode-cn.com/problems/reorganize-string ''' class Solution: def reorganizeString(self, S: str) -> str: if len(S) < 2: return S ...
20298562ef80226ac1886e4df38e1e2b1649666f
FKatenbrink/Advent-of-Code
/2018/day2_1.py
1,213
3.640625
4
import sys from collections import defaultdict def test_day2_1(): assert evaluate_line("abcdef") == (0, 0) assert evaluate_line("bababc") == (1, 1) assert evaluate_line("abbcde") == (1, 0) assert evaluate_line("abcccd") == (0, 1) assert evaluate_line("aabcdd") == (1, 0) assert evaluate_line("a...
0bd06085ab2467bf5788f0ee12a066f7da05f96e
Una-zh/algorithms
/code_repo/topK.py
1,377
3.8125
4
# -- coding: utf-8 -- # author: una # datetime: 2019-09-02 16:09 """ 找第K大的数 """ # 1. 大根堆 def heap_sort(nums, k): """ :param nums: 无序数组 :param k: 第k大的数 :return: 返回第k大的数 """ n = len(nums) nums = [0] + nums # 将下标变成从1开始,方便计算 # 自下而上初始化大根堆 for i in range(n // 2, 0, -1): heap_...
2342388fae90ea279542f73ba4df69b9f8fd6398
kxu68/BMSE
/assignments/AY_2017_2018/semester_1/7/assignment/test_person.py
3,182
3.703125
4
""" Test Person :Author: Arthur Goldberg <Arthur.Goldberg@mssm.edu> :Date: 2017-12-09 :Copyright: 2017, Arthur Goldberg :License: MIT """ import unittest from person import Person, Gender, PersonError class TestGender(unittest.TestCase): def test_gender(self): self.assertEqual(Gender().get_gender('Male...
a3b5f383f030bd206f866aaf7318124a68db1ee6
GriffithsLab/fooof-unit
/fooofunit/scores/score_correlation.py
1,055
3.515625
4
# -*- coding: utf-8 -*- """Correlation Coefficient score class""" import sciunit import numpy as np class CorrelationScore(sciunit.scores.Score): """A Correlation Score. A float in the range [-1.0,1.0] representing the correlation coefficient. """ _description = ('A correlation of -1.0 shows a perfe...
5864ca7b4e8dbae1637da47a60b9a8a6f040f602
erjan/coding_exercises
/the_number_of_the_smallest_unoccupied_chair.py
2,470
3.953125
4
''' There is a party where n friends numbered from 0 to n - 1 are attending. There is an infinite number of chairs in this party that are numbered from 0 to infinity. When a friend arrives at the party, they sit on the unoccupied chair with the smallest number. For example, if chairs 0, 1, and 5 are occupied when a fr...
d87010d0af0b0b174446bf75f4bc4a119539e575
jonathanschen/python_practice
/mitlab4stones.py
1,539
4.09375
4
start_pile = 100 max = 5 total_pile = start_pile p1 = [] p2 = [] while total_pile <= 100: p1_turn = int(raw_input("P1 pick a number between 1 and 5: ")) while p1_turn > max: print "Your response needs to between 1 and 5" p1_turn = int(raw_input("P1 pick a number between 1 and 5: ")) while p1_turn <= 0: p...
24df1675b31327b36e820a94b44a69cb6e0bcf1f
yagays/nlp100
/chp02/18.py
277
3.671875
4
#!/usr/bin/env python # -*- coding: utf-8 -*- col = [] with open("data/hightemp.txt") as f: for line in f: l = line.rstrip().split("\t") col.append(l) sorted_col = sorted(col, key=lambda x: x[2], reverse=True) for c in sorted_col: print("\t".join(c))
c47ca67642b70fd09e5e8802beb51a29f3fe57e0
tangmaoguo/python
/learn_python/advanced_features/iterable.py
320
4.0625
4
#迭代器 from collections import Iterable from collections import Iterator print(isinstance([],Iterator)) print(isinstance({},Iterator)) print(isinstance('abc',Iterator)) print(isinstance((x for x in range(10)),Iterator)) print(isinstance(100,Iterator)) #把Iterable变成Iterator print(isinstance(iter([]),Iterator))
c91232cc8f00fc66a37340be80a2f579dd99d0dc
devbelloni/Exercicios_em_python
/ex010.py
117
3.859375
4
r=float(input('Digite o valor em reais... R$')) d=r/3.27 print('O valor de R${} em dólar é US${:.2f}.'.format(r,d))
4726c22d618edbae13f724e76ad12747e085664c
Rivarrl/leetcode_python
/leetcode/601-900/819.py
1,346
3.640625
4
# -*- coding: utf-8 -*- # ====================================== # @File : 819.py # @Time : 2019/11/27 23:44 # @Author : Rivarrl # ====================================== from algorithm_utils import * class Solution: """ [819. 最常见的单词](https://leetcode-cn.com/problems/most-common-word/) """ @timei...
8992e04198f014d38447d700fa1b77dd962b54af
pushpanjay-kmr/video_transcoding_time_prediction
/Implementation_Python/socket_programming/prac/server.py
776
3.8125
4
#!/usr/bin/python # Import all from module socket from socket import * # Defining server address and port host = '' #'localhost' or '127.0.0.1' or '' are all same port = 52000 #Use port > 1024, below it all are reserved #Creating socket object sock = socket() #Binding socket to a address. bind() takes...
7223e52658a063bc07e26c424aaef2a502a285c0
KlebanA/Python.lessons
/1.4.py
240
4.0625
4
a = int(input("Введите числитель: ")) b = int(input("Введите знаменатель: ")) if a < b: print("правильная дробь") else: print("неправильная дробь") # print Fraction
e7fda4a0d62271d37a255edf84c46401a6bbb110
daniel-reich/ubiquitous-fiesta
/cGaTqHsPfR5H6YBuj_11.py
170
3.75
4
def make_sandwich(i, f): b = [] for a in i: if a == f: b.append("bread") b.append(f) b.append("bread") else: b.append(a) return b
75474e6fce3e801ad8f01498314294fcad082110
mhdella/energy-market-deep-learning
/marketsim/model/energy_market.py
4,848
3.515625
4
class Bid(): """A bid that represents a price-quantity pair in the system.""" def __init__(self, label, price, quantity, band): self.label = label self.price = price self.quantity = quantity self.band = band def copy(self): return Bid(self.label, self.price, s...
304f08fd8acad398c49a9253bb1829cba5a0c3d7
JakeNTech/GCSE-Python-Code
/Arrays/arrays.py
346
3.71875
4
myString1="hello" print("1D ARRAY") for i in range(0,len(myString1)): print(myString1[i]) print("\n"*10) print("2D ARRAY") myString2=["Hello"," I am macintosh"] for a in range(0,len(myString2)): for b in range(0,len(myString2[a])): print(myString2[a][b]) myString3=["Hello"," I am macintosh"," And I have...
51e6d0a9096f97844ef495910eac6266a683494e
anunayarunav/MCMC-Deciphering
/utils.py
3,602
3.8125
4
import numpy as np import random from copy import deepcopy from copy import copy def az_list(): """ Returns a default a-zA-Z characters list """ cx = list('abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ') return cx def generate_random_permutation_map(chars): """ Generate a random per...
6f6a2dd98239b59b5a9cbcb55dfedb19de6d5565
drcpcg/codebase
/Array/array-rotation-type.py
836
4.34375
4
# https://www.geeksforgeeks.org/type-array-maximum-element # descending, clockwise rotated or anti-clockwise rotated. # increasing or Ascending and rotated # decreasing or Descending and rotated def findArrayRot(a,n): i=0 while (i<n-1 and a[i]<a[i+1]): i+=1 if i==n-1: print("Ascending Ar...
b9dc4c1f20d9ac531cad7f9e2d08f52832b60fbb
waiteb15/py3forsci3day
/dicts_and_sets.py
1,475
3.703125
4
#!/usr/bin/env python """ Dict and set examples for KAPL class """ # builtin imports # 3rd-party (CPAN) imports # org imports # project imports def main(): """ Program entry point :return: None """ # get cmd line options dict_examples() set_examples() def dict_examples(...
f4b47d4b167bf351d49e9cbb825919fd19d37334
Yuri-Santiago/curso-udemy-python
/Seção 8/Exercícios/atv10.py
2,358
3.921875
4
""" 10 - Foi realizada uma pesquisa de algumas características físicas de cinco habitantes de certa região. De cada habitante foram coletados os seguintes dados: sexo, cor dos olhos (A - Azuis ou C - Castanhos), cor dos cabelos (L - Louros, P - Pretos ou C - Castanhos) e idade. - Faça uma função que leia esses dados em...
be4aed99f181e5576f7853219b6c0fe7d2a3c8e0
Interloper2448/BCGPortfolio
/Python_Files/murach/exercises/ch14/movies/objects.py
323
3.5
4
class Movie: def __init__(self,name="",year=0): self.name = name self.year = year def getStr(self): return self.name + " ("+str(self.year)+")" def main(): mov = Movie() mov.name = "The Moleman" mov.year = 2050 print(mov.name, mov.year) if __name__ == "__main__": ...
f4ccc3922b61bc49aecd71a9f53e62f62f4d8442
dbutler20/ISAT252Lab1Butler
/lab9.py
761
3.53125
4
""" Lab 9 Classes """ #3.1 #3.2 class my_stat(): def cal_sigma(self,m,n): self.result=0 for i in range(n,m+1): self.result = self.result +i return self.result def cal_pi(self,m,n): self.result=1 for i in range(n,m+1): ...
67c255e54c776a2271e39cbde8be6ec1ef85fbb5
younglua-wv/curso-em-video-python-mundo1
/antecessorESucessor.py
143
4.125
4
numero = int(input("Digite um número: ")) print(f"Analisando o valor {numero}, seu antecessor é {numero - 1} e o sucessor é {numero + 1}.")
8e39aeadc7634c01da963438ecdf907709ea0c30
daksh105/CipherSchool
/Assignment1/AlternateSort.py
280
3.890625
4
def AlternateSort(li): n = len(li) for i in range(n): if i == (n - i - 1): print(li[i]) break print(li[n - i - 1], end =" ") print(li[i], end = " ") li = list(map(int, input().split())) li.sort() AlternateSort(li)
24d62c6ddd9e9d7ddf1e47fa762d49cafdfa3a97
jeykarlokes/complete-reference-to-python3-programs
/python/nptel1.py
1,229
4
4
age = input("enter the age ") if age and (age >= 18 and age <=21): print("you are ok ") elif age and age < 18 : print("you are not eligible") else : print ("nooooooooo") # else: # print("enter the input please ") # rock paper scissors print(".....................") print("welcome to r...
02cb91310ce122b1d985465a31509691cf87645a
Alexh99/NLP-Assignment1-Tweet-Classification
/Submit/twtt.py
1,099
3.75
4
import sys import preprocess def main(argv): if (len(argv) < 2 or len(argv) > 3): print "Wrong number or arguements" sys.exit(2) # Get command line arguements input_file_name = argv[0] output_file_name = argv[len(argv) - 1] #Last arguement input_file = open(input...
983654d48aeea4996af91b6b717214cb4f46c255
LiyangLingIntel/HandsOnAlgorithms
/python/LeetCode/3_LongestSubstringWithoutRepeatingCharacters.py
1,035
4.125
4
""" Given a string, find the length of the longest substring without repeating characters. Example 1: Input: "abcabcbb" Output: 3 Explanation: The answer is "abc", with the length of 3. Example 2: Input: "bbbbb" Output: 1 Explanation: The answer is "b", with the length of 1. Example 3: Input: "pwwkew" Output: 3 Exp...
4afdb81389083b737200cc057149791dd237b7f3
Arman-Amandykuly/python-lessons
/TSIS1/day1/28.py
78
3.765625
4
txt = "Hello World" txt = txt.replace('H','J') #Replacing 'H' character by 'J'
cb3733b67539c459128f8b8495e7936575aafb5e
Aasthaengg/IBMdataset
/Python_codes/p02403/s457006428.py
217
3.59375
4
#coding:utf-8 h = 1 w = 1 while h+w != 0: h, w=input().rstrip().split(" ") h = int(h) w = int(w) if h == 0: if w==0: break for i in range(h): print("#"*w) print("")
36f9c59be09da2169d54cf160b33b525a10b38ed
alexandramilliron/Ratings-v2
/crud.py
1,044
3.515625
4
"""CRUD operations to populate the ratings database.""" from model import db, User, Movie, Rating, connect_to_db def create_user(email, password, name): """Create and return a new user.""" user = User(email=email, password=password, name=name) db.session.add(user) db.session.commit() return us...
172b525a570b43fa09fbf8e6c36fc35edd2ac99a
socodezuhair/aptlist
/aptlist.py
4,930
4
4
import random import string import csv # Define filename to store list of employees EMPFILE = 'employees.txt' OOOFILE = 'ooo.txt' # Function to add employee to list def addEmployee(): # Prompt to get employee name response = raw_input("Please enter employee name (to add): ") # Open file and save new employee's nam...
012d617c4dcffb5659c69105c153175e203e86b6
roozbehsaffarkhorasani/assignment4
/11.py
530
3.8125
4
import math print("a*(x^2) + b*x + c = 0") firstnumber = float(input("adad aval ro vared kon")) number2 = float(input("adad dovom ro vared kon")) number3 = float(input("adad sevom ro vared kon")) a = math.sqrt((number2 ** 2) - (4 * firstnumber* number3)) if a > 0: print("javab aval hast", ((-1 * number...
cd5ae3dab94472ca5e0a32475ad97f6ceddd53fc
farmanAbbasi/farmanAbbasi-pythonAll3
/Stack & Queue Questions/nextLargestElementInArray.py
979
3.8125
4
# class Stack: # def __init__(self): # self.items = [] # def isEmpty(self): # return self.items == [] # def push(self, item): # self.items.append(item) # def pop(self): # return self.items.pop() # def peek(self): # return self.items[len(self.item...
b63901a77610248be5aa1baaeca1625eb2bf4458
mrczl/Python-study
/1-1 Input.py
292
4.15625
4
# 1-1 input # input(prompt=None, /) # Read a string from standard input. print('----------1-1 Input---------') name = input("Please enter your name:->") age = input ("Please enter your age:->") print("Hi!,My name is "+name+",and I'm "+age+",Nice to meet you! \ Welcome to join our club.")
c66157dd6eee64c822cf30af0d7acc94cf103e79
aronnax77/python_uploads
/alg#010_chunky.py
824
4.59375
5
""" chunky.py Author: Richard Myatt Date: 15 January 2018 This is an algorithm which mirrors a question set for JS. Write a function that splits an array (first argument) into groups the length of size (the second argument) and returns them as a two-dimensional array. Please enter an array (list) of numbers followed...
d37b26ac05c1c3bf6f1df3ad0601e20233a5f6a5
AdamZhouSE/pythonHomework
/Code/CodeRecords/2621/60693/237467.py
276
3.859375
4
numbers=input().split(',') sum=int(numbers[0]) maxsum=sum for i in range(1,len(numbers)): if sum>0: sum+=int(numbers[i]) if sum>maxsum: maxsum=sum else: sum=int(numbers[i]) if sum>maxsum: maxsum=sum print(maxsum)
556747cb04ec1fbba2adddbbf401abf58d16d191
yoavh28/Space_Invaders
/Space Invader Game.py
5,931
3.578125
4
#Space Invaders - Part 1 import pip import turtle import os import math import random import time import pygame from pygame import mixer # Load the required library pygame.mixer.pre_init(44100,16,2,4096) pygame.init() #Situation In game -> 1 Lose -> 0 situation=1 #Set up screen wn=turtle.Screen() #change to full ...
ecbef2280175552f047fcb4e477bfdcfe86e194d
czrj-fun/example
/Python/一,基础语法/21.文件操作.py
215
3.859375
4
# 操作文件或者文件夹的相关技术 # 通过file函数打开指定位置文件 file = open("C://Users//zhangjian//Desktop//张健-3月份绩效.txt",mode='r'); # 输出文件中的内容 print(file.read())
e4800acb2eb611b8e3a04d7ad7f97504daf5a017
MarcosVRM/Exercices
/Alura/Games/forca.py
4,786
3.765625
4
from random import randrange import jogos def jogar(): mensagem_de_abertura() gerar_palavra() palavra_secreta = gerar_palavra() letras_acertadas = ocultar_palavra(palavra_secreta) acertou = False enforcou = False erros = 0 print("A palavra secreta tem {} letras".format(letras_acertada...
c992cc45184564282099df45d6edc999b9ecbed8
vv31415926/python_lesson_04_UltraLite
/main.py
442
4.25
4
''' Написать любую функцию без параметров и функцию с параметрами Написать любую функцию с возвращаемым значением и без него Написать любую lambda функцию ''' def hi(): print('Всем привет!') def summa( a,b ): return a+b fLambda = lambda x,y: x+y hi() print( summa(3,2) ) print( fLambda(3,2) )
16bb271f93b5f03e1f4107f3789ec8a53fdd8d35
Nnigmat/Homeworks
/Sort_words_using_radix_sort.py
1,258
3.828125
4
''' Task: Write a program that takes as input N English words written in lower case, and sort them in lexicographic order. For example, if the input is blue red green then the output should be blue green red As another example, if the input is apples apple then the output should be apple apples Implement your ...
9e76a48e7b47f29c88a30e7f12084f9ede8b1ec4
itsolutionscorp/AutoStyle-Clustering
/all_data/exercism_data/python/word-count/a5484b0e3bd240789005a33c83d4e800.py
115
3.765625
4
def word_count(string): string = string.split() return dict((word,string.count(word)) for word in string)
be0ef86355b98b4a2e0e014229603ef2a007c65d
joncrawf/aoc-2018
/day01/1.py
400
3.546875
4
from argparse import ArgumentParser def build_parser(): parser = ArgumentParser() parser.add_argument('--data-path', type=str, required=True) return parser def main(): args = build_parser().parse_args() with open(args.data_path) as file: data = file.read().splitlines() frequency = s...
1c3a3100c7176915ea621635adade2692e1d03f4
atreadw1492/pyply
/pyply/pyply.py
6,022
4.125
4
import pandas import collections import functools def lapply(OBJECT, func, keys = None): """ lapply(OBJECT, func, keys = None) Based off R's lapply function. Takes a list, tuple, or dict as input, along with a function. The function is applied to every element i...
d765c8ee99db6694ff32e9dd974af8420ab8ac37
julius1290/pythonProject
/main.py
1,125
4.03125
4
import math while True: try: userInput = float(input("Please give a circle radius:\n")) break; except ValueError: print("Please give a valid number") radius = float(userInput) area = (radius**2)*math.pi print(area) userInput = input("Give a comma seperatet list of numbers:\n") userInput...
f87db646dc2f0fd7a608f6e1664ee415d407a2a4
rtillmo/Python-coding
/Tidbits2/binary.py
166
3.875
4
def binary(): s="" n=(raw_input("Type a number:")) n=int(n) while n>0: r=n%2 s=str(r)+s n=n/2 print "the binary equivalent is", s binary()
36b6d77933b815c84ddbfa23a18f17e61aae2818
ilsersokolov/Otus
/hw01/data_gathering/gathering.py
11,061
3.703125
4
""" ЗАДАНИЕ Выбрать источник данных и собрать данные по некоторой предметной области. Цель задания - отработать навык написания программ на Python. В процессе выполнения задания затронем области: - организация кода в виде проекта, импортирование модулей внутри проекта - unit тестирование - работа с файлами - работа с...
ba6efde91089fd2659b82cdada59b956b47017bd
danielstabile/python
/exercicio 5.py
527
4.03125
4
#5 Escreva um programa que receba dois números e um sinal, e faça a operação matemática definida pelo sinal. n1 = int(input("Informe o primeiro numero: ")) n2 = int(input("Informe o segundo numero: ")) sinal = input("Informe o segundo numero: ") resultado = 0 sinal_ok = 1 if sinal == "+": resultado = n1 + n2 elif si...
c4be7aa01d56e6701f6f08940efe88e105388e54
rohit-kadam-hub/python-project
/Project_2_hello_YOU.py
448
4.34375
4
#Ask user for name name =input("What is your Name? : ") #Ask user for age age =input("What is your age ? : ") #ask user for city city = input("What city do you live in ? : ") #Ask user what they enjoy love=input("What do you love doing? : ") #Create output text string = "Your name is {} and you ar...
72b34d82d798c92c305e28869dfec6201e606539
ikramulkayes/University_Practice
/practice30.py
221
3.8125
4
lst = [2,53,-2,6,2] for i in range(len(lst)-1): for j in range(len(lst)-i-1): #bubble sorting if lst[j]>lst[j+1]: temp = lst[j] lst[j] = lst[j+1] lst[j+1] = temp print(lst)
c4784d117fb0b18720a5fa6080cb054a4495c664
jaweria332/GUI-with-Python
/Notepad.py
2,035
3.90625
4
#Import Tkinter, a library used for GUI in Python from tkinter import * #Importing filedialog from tkinter import filedialog #Importing messagebox from tkinter import messagebox #Declaring a root object root=Tk() #Define title of your window root.title("Gets Started with Python GUI") #Defining the windows size roo...
e154ffe65ae5fad51df0c58d72c95d2fdda292a0
ErinSmith04/Python-2018
/Magic_8_Ball_ErinSmith.py
685
4.0625
4
import random import time name = input("What is your name?: ") print("What's up %s! I can predict your future" %name) g_1 = "Yes" g_2 = "Outlook seems good" g_3 = "Results seems true" m_1 = "It seems unclear" m_2 = "Maybe..." m_3 = "I'm not saying no, but I'm not saying yea.." b_1 = "No" b_2 = "Fear the Future" b_3 =...
cd000608d0f956da717253e4a7d3589571957c21
Aish32/data-chronicles
/Core Concepts/Data Preprocessing/standardizing_and_scaling.py
732
3.609375
4
from sklearn.datasets import load_wine data = load_wine() X = data.features y = data.target # Split the dataset and labels into training and test sets X_train, X_test, y_train, y_test = train_test_split(X, y) # Fit the k-nearest neighbors model to the training data knn.fit(X_train, y_train) # Score the model on t...
6e4af8dd72ef37ba5abe7ad478d7b25d0789d7b0
kudeh/automate-the-boring-stuff-projects
/character-picture-grid/character-picture-grid.py
1,034
3.65625
4
# character-picture-grid.py # Author: Kene Udeh # Source: Automate the Boring stuff with python Ch. 4 Project def rotate90(grid): """Rotates a grid 90 degrees Args: grid (list): a 2d list representing a grid Returns: grid (list): rotated copy of a 2d grid """ return list(zip(*grid[:...
2c40e43be678e94d36611789dfabc001ae294b44
SuYoungHong/checkIO_solutions
/CheckIO/most_frequent_days.py
1,467
3.734375
4
__author__ = 'Su-Young Hong' __version__ = '0.1' __email__ = 'suyoung.hong@gmail.com' __status__ = 'for fun' import datetime def most_frequent_days(year): """ :param year: integer, year you want to check :return: list, days which were most common days in that year """ reference = [('Monday', 0), (...
14827d4f4382cf7fe44d92baabbad12f0b7022ab
andrewparmar/python-tools
/python-practice/GeekforGeeks/bfs_graph_traversal_simple.py
676
3.875
4
class Graph(object): def __init__(self): self.graph = {} def add_edge(self, u, v): self.graph.setdefault(u, []).append(v) def BFS(graph, root): visited = [False] * len(graph.graph) queue = [] queue.append(root) stringer = [] while queue != []: node = queue.pop...
28fe12fdf851d531e00df243fc0f1e0b422ee422
Mohammed-Shoaib/Coding-Problems
/Gulf Programming Contest/2019/pyramids/pyramids.py
372
3.78125
4
def tetrahedral(n): return n * (n + 1) * (n + 2) // 6 def pyramids(n, m): return tetrahedral(n) - tetrahedral(m) with open("pyramids.in", "r") as fin: with open("output.out", "w") as fout: n, m = map(int, fin.readline().split()) while n or m: fout.write(f'{pyramids(n, m)}\n')...
3319313a5939bd97d4e876bb6b413b36f38f7915
gauravhansda/InterviewQuestions
/QuickSort.py
1,033
4
4
def main(): arr = [54, 26, 93, 17, 77, 31, 44, 55, 20] print "before sorting: ", arr quickSort(arr) print "after Sorting: ", arr def quickSort(arr): qSortHelper(arr, 0, len(arr) - 1) def qSortHelper(alist, start, end): if start < end: split_point = partition(alist, start, end) ...
d26aa92ca71e8b10402f076b1fcd45c6b432f351
paul-khouri/Flask_ReadingData_Searching_Inserting
/dbDeleting.py
1,311
3.90625
4
import sqlite3 # connect def db_Search(s): conn = sqlite3.connect('memberTable.sqlite') cur = conn.cursor() sql = 'select * from memberTable where lastName like "%{0}%" ' \ 'or address like "%{0}%" or suburb like "%{0}%" '.format(s) cur.execute(sql) result = cur.fetchall() conn.close(...
65a388d0983b871be240fe402aeaa1d631017105
uyennguyen16900/leetcode-problems-and-variable-table
/coding.py
1,457
3.96875
4
# Given a sorted linked list, delete all duplicates such that each element appear only once. # head = 1->1->2 = 1->2 # curr = 2 def deleteDuplicates(head): """ :type head: ListNode :rtype: ListNode """ if head is None: return head curr = head while curr.next is not None: ...
f391fafab5bbc55bdeb48f9c975e0fd7e6326ca2
ctrlMarcio/feup-iart-proj1
/delivery/algorithm/genetic/crossover.py
7,003
3.71875
4
"""Holds crossover classes used in genetic algorithms. Classes: Crossover OnePointCrossover OrderCrossover """ from abc import ABC, abstractmethod import delivery.algorithm.operation.restriction as restriction import copy import random class Crossover(ABC): """The general abstract crossover class. ...
6f430b8cc4d4b0cdc6b22e1958c9181ca818bdad
thomashigdon/poker-sim
/player.py
2,594
3.5625
4
import card_set import chip_stack import hand_scorer class Player(object): def __init__(self, name, starting_stack_amount): self.name = name self.stack = chip_stack.ChipStack(starting_stack_amount) self.hole = card_set.Hole() self.game_state = None # Set a player's activity...
7b560c5192a5fbea60da3b0db8e054f70983fc46
solar1um/solarium
/dunders.py
815
3.625
4
# dunder method, magic methods # double underscore methods # isistence print(dir(1), type(1)) class CInt: def __init__(self, n): self.n = n def __add__(self, other): return f'sum is {self.n + other}' def __eq__(self, other): if self.n == other: return f'{self.n}, is ...
617ec6a342cb58ba08c5da2d837f276a7f841513
neethupauly/Luminarmaybatch
/Fundamentals/raise_keyword.py
389
3.859375
4
# raise - keyword for exception printing # same number # no1=int(input("enter num1")) # no2=int(input("enter num2")) # if no1==no2: # raise Exception("two numbers are same") # else: # print(no2+no1) #age condition exception printing age=int(input("enter your age")) if age>18: print("eligible for vaccina...
a6ac0f2d6cd586bed36db89ebce93582224c80b8
kailee-madden/Natural-Language-Processing
/hw2/incase.py
6,776
3.6875
4
for character in string.printable: for character2 in string.printable: sub = (character, character2) s = Transition(1, sub, 0) s2 = Transition(0, sub, 0) fst.add_transition(s) fst.add_transition(s2) ins = ("ε", character) i = Transition(0, ins, 0) fst.add_transiti...
567841fc0a92ed105fee5074af5d843f19878962
harjothkhara/python_sandbox
/python_sandbox_starter/files.py
717
4.09375
4
# Python has functions for creating, reading, updating, and deleting files. # Open a file myFile = open('myfile.txt', 'w') # created a file # Get some info print('Name: ', myFile.name) # Name: myfile.txt # Is Closed : False # means is it closed within our script print('Is Closed : ', myFile.closed) # False print...
0df61cb8171e9fd875f27935ca2d967aec49f0e7
tylors1/Leetcode
/Problems/encodeMessage.py
816
4.21875
4
# Run-length encoding is a fast and simple method of encoding strings. The basic idea is to represent repeated successive characters as a single count and character. For example, the string "AAAABBBCCDAA" would be encoded as "4A3B2C1D2A". # Implement run-length encoding and decoding. You can assume the string to be en...
baf37d76fa5a3cf4f19173bb119fe88a1fcee752
quantumesx/EvolutionofCommunication
/Code/Helper.py
3,999
4.1875
4
"""Compute angles and coordinates.""" import math def find_ang(xy1, xy2, verbose=False): """ Find orientation of the vector linking x1, y1 to x2, y2. Note: this is 180d different from the vector linking x2,y2 to x1,y1. Validated: 03/04/19. """ x1 = xy1[0] y1 = xy1[1] x2 = xy2[0] ...
3bc6e5afaa49596c4c3761eb69046b675f518680
ParulProgrammingHub/assignment-1-gaganlotey
/q1.py
123
3.71875
4
l=int(input("enter the length of a rectangle")) b=int(input("enter the breath of a rectangle")) a=l*b p=2*(l*b) print(a,p)
36c6baa33a62626609d261102b135842528a1e52
Pythonjowo/Fundamental_banget2020
/RIdwan Ilyas/part 12.py
118
3.71875
4
x = input('Masukkan bilangan') x = int(x) if x % 2==0: print('Bilangan Genap') else: print('Bilangan ganjil')
692524ce0c50f163f689012b504756e3a8923593
clintmthompson/Sweepstakes
/sweepstakes.py
1,658
3.8125
4
from contestants import Contestant import random class Sweepstakes: def __init__(self, name): self.name = name self.contestants_list = [ { "first_name": "Bill", "last_name": "Dauterive", "email": "bill4387@gmail.com", "r...
1a50db09a719e429306de92a56df37ab7b774569
qq915522927/python-
/python_study/算法/迪克斯特拉算法.py
2,040
3.875
4
# coding=utf8 ''' 迪克斯特拉算法用于解决加权图的最小路径问题,适用于有向无环图 总体分为4步 1. 找出最便宜的节点 2. 计算该节点的各个邻居的开销 3. 重复第一步找出最便宜的节点 4. 重复第二部更新该节点邻居的开销 ''' ''' 具体实现步骤: 1.首先需要三个散列表 第一个表用来储存图结构 {'start':{'A':6,'B':2},'A':{'end':1},'B':{'A':3,'end':5},'end':{}} 每一个键值对的值表示该节点下邻居节点以及开销。 第二个表用来存放到各个节点的总开销 costs = {'A':6,'B':2,'end':float('inf')} 第三个表用来...
389760781784074d77569fd1f0911a238e02657a
eddiewu6/LeetCode
/326. Power of Three.py
385
3.9375
4
#Idea: find the maximum integer of power of 3, and check the residule of that number % n #O(1) in time, O(1) in space #AC in 250ms class Solution(object): def isPowerOfThree(self, n): """ :type n: int :rtype: bool """ return n > 0 and 1162261467 % n == 0 #1162261367 is the...
efd4543579c42e75a178c7d25c2b41d5e86f53b7
psmzakaria/Practical-1-2
/Practical2Q2.py
873
4
4
# Given weightages are represented as below and are universal MIDSUMMERTEST = 0.20 ASSIGNMENT1 = 0.25 ASSIGNMENT2 = 0.35 GENERALPERFORMANCE = 0.20 # User input of scores gradeMidSummerTest = int(input("Enter your Midsummer test scores")) gradeAssignment1 = int(input("Enter your Assignemt1 test scores")) gradeAssignmen...
84be4d95894f6b594d3ec29e67405d64a2f437bc
shiwuhao/python
/file/somescript.py
135
3.5
4
# /usr/bin/env python3 import sys text = sys.stdin.read() words = text.split() wordcount = len(words) print('WorldCount:', wordcount)
f8945c1ed591541c48aa7fd7eed5c634612645cb
daniel-reich/turbo-robot
/Ddmh9KYg7xA4m9uE7_20.py
474
4
4
""" Write a function that transforms all letters from `[a, m]` to `0` and letters from `[n, z]` to `1` in a string. ### Examples convert_binary("house") ➞ "01110" convert_binary("excLAIM") ➞ "0100000" convert_binary("moon") ➞ "0111" ### Notes Conversion should be case **insensitive** (see e...
f06901a14879b269d2d75334f97152c9ff85c8f0
ecstowe/AFS505_u1
/assignment4/ex36.py
3,729
3.921875
4
from sys import exit def finish_line(): print("Holy shit it worked. The Fascists are obliterated.") print("You won!") finish_line() def gate_start(): print("""You are at the top of your favorite ski run, you look left and see the Jesus themself strapping into their skis. \n You look right and see Stalin t...
b96dd3d9a09cc4f7c19b396ed74c1e2efb945ee9
Bappy200/Python
/learing_python/try_catch.py
198
3.90625
4
try: age=int(input("Enter your age : ")) income=2000 rick=income/age print(rick) except ValueError: print("Invalid Age") except ZeroDivisionError: print("Age not be 0 !")
6e68d627c61dc22d8793c9c312b116272ddc4c2f
rielaben/Final_Project
/calcs_vis.py
7,300
3.625
4
import unittest import sqlite3 import json import os import matplotlib import matplotlib.pyplot as plt import numpy as np from scipy import stats from numpy import percentile import csv def setUpDatabase(db_name): '''This function takes in the name of the database and creates a connection and cursor to it. It ...
184c12923237bf834427058ba20921c7732119f9
mws19901118/Leetcode
/Code/Furthest Building You Can Reach.py
1,108
3.765625
4
class Solution: def furthestBuilding(self, heights: List[int], bricks: int, ladders: int) -> int: heap = [] #Use a min heap to maintain the largest ladders gap. Because we want to use ladder for the heigher gap as many as possible for i in range(len(he...
be98f72e78ce5b67822d7f09bdb249d0fe248a62
sireesha98/15218
/beg-50.py
70
3.609375
4
a=int (input()) if ( a & (a - 1)): print('no') else: print('yes')
d146ca36e0e32ba3edc96191f7ce56a2dc2cd2c2
UWPCE-PythonCert-ClassRepos/py220-online-201904-V2
/students/Shirin_A/lesson09/assignment/src/jpgdiscover.py
713
4.125
4
""" This program will find all the .png files in the file directory system """ import os def list_jpg_files(path): """This is the recursive function for discovering .png files""" path_list = [] for root, directories, files in os.walk(path): file_list = [] for file in files: ...
c506a266a25134dc0c42eb9da45376d8d48aeab8
TalkingFoxMid/hexEditor17
/utils/test_integer_hexer.py
338
3.609375
4
import unittest from utils.integer_hexer import IntegerHexer class TestIntegerHexer(unittest.TestCase): def test_to_hex1(self): hexer = IntegerHexer() assert hexer.get_hex_string(10) == "0000000A" def test_to_hex2(self): hexer = IntegerHexer() assert hexer.get_hex_string(1404...
f71eab5a48e402bd46f793bc951c1f9fbc76fc8e
basantech89/code_monk
/python/MITx/6.00.1x_Introduction_to_ComputerSCience_and_Programming_using_Python/conditional.py
338
4.3125
4
# branching program x = int(raw_input("enter an integer:")) if x%2 == 0: if x%3 == 0: print(" ") print("divisible by 2 and 3") else: print(" ") print("divisible by 2 but not by 3") elif x%3 == 0: print("divisible by 3 but not by 2") else: print("neither divisible by 2 nor by 3") print('done ...
23a3ff947eca4e55235017e2abdf9b7edbb52db5
sgas/luts3-client
/sgasclient/baseconvert.py
438
3.890625
4
""" Module for converting a number to base62. """ BASE62 = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" def base10to62(number): BASE = 62 if number == 0: return BASE62[number] new_number = '' current = number while current !=0 : remainder = current % BASE ...