blob_id
stringlengths
40
40
repo_name
stringlengths
5
127
path
stringlengths
2
523
length_bytes
int64
22
545k
score
float64
3.5
5.34
int_score
int64
4
5
text
stringlengths
22
545k
80589f7cf1a696d7ebb8846fbf78524177ef3550
carevealed/PBCore
/test.py
202
3.59375
4
from xml.etree. ElementTree import ElementTree, Element, tostring root = Element("person") tree = ElementTree(root) root.text = "s" # root.append(PB_Element("name")) # print tree print tostring(root)
37298e5ff447e461038e1bd284fe3aff4d0d4d7d
gozelalmazovna/txt_file_reading_data.py
/txt_file_reading_data.py
575
3.765625
4
#Initialize variables count = 0 pos = 0 num = 0 #Ask for a file name fname = input("Enter the name:") #Check the file name try: fhand = open(fname,"r") #if true open it except: print("Invalid file name") #if false quit quit() #Search for a lines 'X-DSPAM-Confidence: 0.8475' #Count them and find averag...
aaf18cddc67bb846b6d1fd42ed33f91a54d42b46
larsyencken/shelly
/shelly_cmd/space.py
819
3.828125
4
#!/usr/bin/env python # -*- coding: utf-8 -*- # # space.py # shelly # """ Insert spaces between lines. """ import sys import optparse def space(istream=sys.stdin, ostream=sys.stdout): for i, l in enumerate(istream): if i > 1: ostream.write('\n') ostream.write(l) def _create_optio...
aa43cebff9fc004821a5b857dd7babe4e35fe6a4
larsyencken/shelly
/shelly_cmd/drop.py
1,554
3.5
4
#!/usr/bin/env python # -*- coding: utf-8 -*- # # drop.py # shelly # """ Drop a prefix of lines from stdin which match a pattern. """ import sys import optparse import re def drop(regex, istream=sys.stdin, ostream=sys.stdout, until=False): search = re.compile(regex).search write = ostream.write if unt...
a9cf859429a310242c31b3edcac61225feac869d
dzieber/python-crash-course
/ch3/every.py
535
4.21875
4
''' exercise 3.8 ''' things = ['one', 'fish', 'two', 'fish'] print(things) print(things[0]) print(things[-1]) things[0] = 'moose' print(things) things.append('squid') print(things) things.insert(2,'fish') print(things) print(things.pop(2)) print(things) del things[1] print(things) bad = 'fish' things.remove(bad) print...
0e99419b90d9bdaafa76ebbda14479182632f074
dzieber/python-crash-course
/ch4/dimensions.py
492
3.828125
4
''' chapter 4, Tuples ''' dimensions = (200,50) print(dimensions[0]) print(dimensions[1]) # to copy a tuple into a list you have to cast it temp_dimensions = list(dimensions[:]) print(temp_dimensions) temp_dimensions[0] = 250 print(temp_dimensions) # and it works the other way as well. Note that you don't need to make...
08dbd5e07f9b0f31a1c7ed9c826a742db92f158b
dzieber/python-crash-course
/ch4/threes.py
171
4.40625
4
''' exercise 4-7. Threes: Make a list of the multiples of three from 3 to 30, print with a for loop ''' threes = list(range(3,33,3)) for three in threes: print three
d705924d0fde34ce6ebb4d3cf94c85e1a8c05343
dzieber/python-crash-course
/ch3/places.py
311
3.8125
4
''' Problem 3.8 ''' places = ['home', 'here', 'there', 'everywhere', 'bolivia'] print(places) print(sorted(places)) print(places) print(sorted(places, reverse=True)) print(places) places.reverse() print(places) places.reverse() print(places) places.sort() print(places) places.sort(reverse=True) print(places)
920fbd54560fc0619d6b43771e04dda0baa8b66f
dzieber/python-crash-course
/ch4/magicians.py
267
3.59375
4
magicians = ['billy', 'bob', 'alice'] for magician in magicians: print(magician.title() + ", you are nifty!") print("I like your socks, " + magician.title() + "!\n") print("All done!") magicians.append('muffy') for magician in magicians: print(magician)
f683490dfe741e423d91f656f2a02eb265b079d8
taorea/pythonic
/42.math.py
363
3.671875
4
import math print(math.sin(math.pi/2)) print(math.sqrt(4)) print(math.floor(-2.5)) print(math.sin(math.pi * 2)) print(round(3.5)) print(round(-2.5)) print(math.degrees(1)) print(math.degrees(math.pi)) #弧度转换为角度 print(math.radians(180)) #角度转换为弧度 print(chr(40)) x = input("Enter a character:") ch = chr(ord(x) +...
40eb8e65cb5f4be45e28b6e8adb891dec961c38f
taorea/pythonic
/35.金融问题.py
272
3.71875
4
finalAcount = eval(input("输入最终的金额值")) yearRate = eval(input("输入年利率")) year = eval(input("输入存款年限")) monthRate = yearRate / 1200 initialAcount = finalAcount / (1 + monthRate) ** (year * 12) print("initialAcount is",initialAcount)
ca7b0f5910dec18ca17511bb2e68e6deccaebf31
taorea/pythonic
/28.运算符.py
516
3.828125
4
#今天是星期二,100天后是星期几 print("一百天后:",(2 + 100) % 7) print(25 / 4) print(int(25 / 4)) print(25 // 4) print(round(25 / 4)) #根据表达式用python编写 #print(4/(3 * (r + 34)) - 9 * (a + b*c) + (3 + d*(2 + a))/(a + b * d)) m = 10 r = 3 print(m * r ** 2) i = 3 i += 1 print(i) # 4 i *= 2 print(i) # 8 i **= 2 print(...
28d372b05efd39e0d1e98ee971018bf31e5a42b1
taorea/pythonic
/9.time.py
270
3.890625
4
import time datatime = time.time() print(datatime) int_time = int(datatime) print(int_time) hour = int_time / 3600 print(hour) second = int_time % 3600 day = hour / 24 year = day / 365 print("year:{0} day:{1} hour:{2} seocond:{3}".format(year,day,hour,second))
9abd1adc6afcb73d314465456321785f2ad83878
rucyang/learnpy
/lazy_sum.py
698
3.625
4
#! /usr/bin/env python #! -*- coding:utf-8 -*- def calc_num(*args): ax = 0 for i in args: ax = ax + i return ax def lazy_sum(*args): def sum(): ax = 0 for i in args: ax = ax + i return ax return sum f1 = lazy_sum(1,2,3,4,6) f2 = lazy_sum(1,2,3,4,6) print f1 == f2 print '###########################...
14102572e37f13aff29c86a1e36fa6c0e8286979
nishantchaudhary12/Leet_Code
/Python/509_fibonacciNumbers.py
568
4.03125
4
#fibonacci numbers ''' The Fibonacci numbers, commonly denoted F(n) form a sequence, called the Fibonacci sequence, such that each number is the sum of the two preceding ones, starting from 0 and 1. ''' class Solution(object): def fib(self, N): """ :type N: int :rtype: int """ ...
73690468a60b4fbe8d5f346e3e56c0afd0524a34
nishantchaudhary12/Leet_Code
/Python/45_jumpGameII.py
587
3.71875
4
'''Given an array of non-negative integers, you are initially positioned at the first index of the array. Each element in the array represents your maximum jump length at that position. Your goal is to reach the last index in the minimum number of jumps.''' class Solution: def jump(self, nums: List[int]) -> int...
002a782c713df8db3b1c24dd99255df650ac5aac
nishantchaudhary12/Leet_Code
/Python/1272_removeInterval.py
932
3.90625
4
'''Given a sorted list of disjoint intervals, each interval intervals[i] = [a, b] represents the set of real numbers x such that a <= x < b. We remove the intersections between any interval in intervals and the interval toBeRemoved. Return a sorted list of intervals after all such removals.''' class Solution: d...
041af4f8f344d815c8994b69869322b427b0e55f
nishantchaudhary12/Leet_Code
/Python/415_addStrings.py
767
3.703125
4
'''Given two non-negative integers num1 and num2 represented as string, return the sum of num1 and num2''' class Solution: def addStrings(self, num1: str, num2: str) -> str: i = len(num1) - 1 j = len(num2) - 1 carry = 0 num = 0 res = list() while i >= 0 or j >= 0: ...
462d97b11712b62fb701b242d4b2676318406954
nishantchaudhary12/Leet_Code
/Python/59_spiralMatrixII.py
920
3.71875
4
'''Given a positive integer n, generate a square matrix filled with elements from 1 to n2 in spiral order.''' class Solution: def generateMatrix(self, n: int) -> List[List[int]]: result = [[0] * n for i in range(n)] arr = [i for i in range(1,n*n+1)] i,j,k = 0,0,0 x, y = n, n ...
a8bf15c8d3cfc2896e924d587740b7345b2fc178
nishantchaudhary12/Leet_Code
/Python/9_palindromeNumber.py
435
4.09375
4
'''Determine whether an integer is a palindrome. An integer is a palindrome when it reads the same backward as forward.''' class Solution(object): def isPalindrome(self, x): flag = False original = x result = 0 if x >= 0: while x > 0: result = (result * 1...
8897ca366247488f0da80c081fb085b508c5b5dc
nishantchaudhary12/Leet_Code
/Python/243_shortestWordDistance.py
539
3.90625
4
'''Given a list of words and two words word1 and word2, return the shortest distance between these two words in the list.''' class Solution: def shortestDistance(self, words: List[str], word1: str, word2: str) -> int: d = 2 ** 31 - 1 indx1, indx2 = -1, -1 for i, each in enumerate(words): ...
378c96dc6fa21e3d78c0fd3e7abc08ad8925ee5e
nishantchaudhary12/Leet_Code
/Python/226_invertBinaryTree.py
469
4.0625
4
#Invert a binary tree. # Definition for a binary tree node. # class TreeNode: # def __init__(self, x): # self.val = x # self.left = None # self.right = None class Solution: def invertTree(self, root: TreeNode) -> TreeNode: def _helper(node): if not node: ...
a80808ddf69a094eea72d606dd0c04ed2745c51a
nishantchaudhary12/Leet_Code
/Python/461_hammingDistance.py
470
4.0625
4
'''The Hamming distance between two integers is the number of positions at which the corresponding bits are different. Given two integers x and y, calculate the Hamming distance.''' class Solution: def hammingDistance(self, x: int, y: int) -> int: x = '{0:032b}'.format(x) y = '{0:032b}'.format(y)...
6d2a177a993e6d105c8dc81fb9df52afa581b808
nishantchaudhary12/Leet_Code
/Python/349_intersectionOfTwoArrays.py
450
3.65625
4
'''Given two arrays, write a function to compute their intersection.''' from collections import Counter class Solution: def intersection(self, nums1: List[int], nums2: List[int]) -> List[int]: num1 = set(nums1) num2 = Counter(nums2) result = list() for each in num1: if...
0bad1de84c27a3c5da22e767f6dbe32c94a57e52
nishantchaudhary12/Leet_Code
/Python/938_rangeSumOfBST.py
878
3.671875
4
'''Given the root node of a binary search tree, return the sum of values of all nodes with value between L and R (inclusive). The binary search tree is guaranteed to have unique values.''' # Definition for a binary tree node. # class TreeNode: # def __init__(self, x): # self.val = x # self.left =...
80259bab52476f0961c356bc16f3de4fafd4c51f
moizlokhandwala/Python-prac-2
/CompundInterest.py
605
3.71875
4
# -*- coding: utf-8 -*- """ Created on Mon Jan 1 12:18:44 2018 @author: Twox3 """ def future_value(present_value, annual_rate, periods_per_year, years): """ Input: the numbers present_value, annual_rate, periods_per_year, years Output: future value based on formula given in question """ rate_per_...
7db8c6ea4dc2c54f3f93ab32668a6e5edee6f03a
moizlokhandwala/Python-prac-2
/PracticeQuiz.py
160
3.625
4
# -*- coding: utf-8 -*- """ Created on Mon Jan 1 12:28:01 2018 @author: Twox3 """ def addtwo(a, b): added = a + b return a x = addtwo(2, 7) print(x)
072e7671906f84747d78bbfba47228e0d8bdf355
moizlokhandwala/Python-prac-2
/Michigan/Dictionary Excercise 1.py
558
3.703125
4
# -*- coding: utf-8 -*- """ Created on Wed Jan 31 10:25:35 2018 @author: Twox3 """ FileName = input('Enter the file name : ') counts=dict() MaxWord='' MaxCount=0 try: fhandler = open(FileName) except: print('Invalid File !') for line in fhandler: line = line.rstrip() if line.startswith('From:') :...
86300827ebb05e9a1959b7c9ec24fb32438b0a52
tsong/project-euler
/p30.py
120
3.5
4
def fifth(n): return n == sum( [int(d)**5 for d in str(n)] ) print sum( [n for n in xrange(10,1000000) if fifth(n)] )
4f64a2c2969534f697f0a5287c2f1eacfc4781bd
Proyecto2-icc/P1
/Menus.py
2,321
3.875
4
def PrimerMenu(): print("MENU PRINCIPAL") print("[1] Ingresar Matrices") print("[2] Operar Matrices") print("[3] Mostrar Matrices") print("[4] Salir") opcion = input("Seleccione opción: ") if opcion in ["1","2","3","4"]: return opcion else: print("Opción incorrecta, intente nuevamente"...
0344dfc23937277d106ac4e6121942d3142c42e4
gordonhirsch/bin
/getartist.py
745
3.703125
4
#!/usr/bin/python import os import sh import re import argparse tags_of_interest = ["TPE2", "TPE1"] def parse_args(): parser = argparse.ArgumentParser(description="Get MP3 artist, giving priority to album artist") parser.add_argument("file", help="the MP3 file") return parser.parse_args() def get_mp3_ta...
7eabcd39a3376aeb8d4e809df279a9cdde8fbd83
ck3207/daily_scripts
/get_interval_date.py
2,261
3.6875
4
import datetime import time import random class IntervalDate: """获取两个随机的日期, begin_date,end_date 提供给账户分析自定义区间接口使用""" def __init__(self): self.current_date = time.strftime("%Y%m%d", time.localtime()) def get_random_num(self, small_num, big_num): """返回一个基于small_num与big_num的整数""" if is...
f6763fa17d031bca737cbec5e2bfb5dc2da5b76d
dm-drogeriemarkt/pyspark-expectations
/pyspark_expectations/arguments_format_checker.py
1,854
3.609375
4
import numbers def check_var_type(var, var_name, types_list): if isinstance(types_list, type): types_list = [types_list] if not isinstance(var, tuple(types_list)): raise ValueError("<{0}> only accepts {1}".format(var_name, types_list)) def check_min_max(min_value, max_value): check_var_ty...
34139103c543a3ed988681411963770f0067b39c
L200170054/Prak_ASD_B
/UAS_L200170050_L200170054_L200170060_B/data_buku.py
10,707
3.671875
4
class data_buku(object): """class data untuk Buku""" def __init__(self, judul_buku, nama_penulis, tanggal_terbit): self.judul = judul_buku self.penulis = nama_penulis self.tanggal = tanggal_terbit def __repr__(self): info = self.judul + ', ' + self.penuli...
1c38124ab5af396e9ab19816947af30f5d7b5dbf
YYJecter/Pathfinder-Generation-NPC
/Pathfinder-Generation-NPC/class_selection.py
3,339
3.65625
4
import random def Die(n): import random return(random.randint(1,n)) def StatRoll(): return (Die(4)+Die(4)+Die(4)+Die(4)+Die(4)) Strength=StatRoll() Dexterity=StatRoll() Constitution=StatRoll() Intelligence=StatRoll() Wisdom=StatRoll() Charisma=StatRoll() def StatMod(n): return((n-10)//2) StrMod=StatMod(Str...
6fe40fec45477da49060eb84fc699ce68e6075c7
ant0nm/reinforcement_exercise_d23
/exercise.py
818
4.375
4
def select_cards(possible_cards, hand): for current_card in possible_cards: print("Do you want to pick up {}?".format(current_card)) answer = input() if answer.lower() == 'y': if len(hand) >= 3: print("Sorry, you can only pick up 3 cards.") else: ...
98e5c88bc5306e7123fb54f3b57e661b6b10bd60
Shubham2713/Tic_Tac_ToeGame
/Tic_TAc_Toe.py
4,116
4.0625
4
import random from IPython.display import clear_output #display the board everytime def print_board(board): clear_output() print(board[7]+"|"+board[8]+"|"+board[9]) print("_____") print(board[4]+"|"+board[5]+"|"+board[6]) print("_____") print(board[1]+"...
b09a3c88ab758a52e3dfd67fd8081f3070d55e94
Preburnism/PAT
/Python/1_1_demo.py
705
3.65625
4
import matplotlib.pyplot as plt import numpy as np # from matplotlib.image import imread """ img = imread("E:/Pictures/壁纸/wallhaven-73vge9_1920x1080.png") # 当前目录下可../xxx/xxx.jpg plt.imshow(img) plt.show() """ # initiate data x = np.arange(-5, 5, 0.1) # 0.1为单位生成-5-5之间数据 y1 = np.sin(x) y2 = np.cos(x) # plot plt.plo...
8fa3f71c473ea6683f0d2f346e1a16dddfb2413c
pfeuh/atasmPrecompiler
/oneShot/dummy.py
505
3.65625
4
#!/usr/bin/python # -*- coding: utf-8 -*- import sys import os def write(text): sys.stdout.write(str(text)) def writeln(text): write(text) write("\n") result = (0x1234, 0x2345, 0x3456) tmp_lst = [] for value in result: tmp_lst.append(value & 255) tmp_lst.append(value /256) print tmp_lst fo...
7380aa16ecb4c0251e6143517e086dd87d562080
DariaKharitonova/python-project-lvl1
/brain_games/games/brain_even.py
422
3.71875
4
import random DESCRIPTION = 'Answer "yes" if number even otherwise answer "no".' MAX_NUMBER = 100 MIN_NUMBER = 1 def get_question_and_answer(): number = generate_number() question = str(number) correct_answer = 'yes' if is_even(number) else 'no' return question, correct_answer def is_even(number): ...
c0152eb175a12cc2be653e446d6cbca591780dfc
DariaKharitonova/python-project-lvl1
/brain_games/engine.py
882
3.90625
4
import prompt NUMBER_OF_ROUNDS = 3 TASK_PREFIX = 'Question:' def run_game(game): print('Welcome to the Brain Games!') print(game.DESCRIPTION) print() user_name = prompt.string('May I have your name? ') print() print(f'Hello, {user_name}!') run_game_loop(user_name, game.get_question_and_an...
a174dde156d2d4123bfcc840a22febf413c3d48b
peonyau/SPE10117-Information-System-lab3
/lab6q1rectangle.py
278
3.625
4
from tkinter import Tk, Canvas frame=Tk() canvas=Canvas(bg='white',height=250,width=300) canvas.create_rectangle(10,10,200,150,fill='blue',outline='black') canvas.create_text(100,100,text='Au Tsz Yui') canvas.create_line(70,110,150,110) canvas.pack() frame.mainloop()
2de7b5af4590ea3685da9ffaffc8302c42d837d8
ntuong196/AI-for-Puzzle-Solving
/Week7-Formula-puzzle/script_graph_revision.py
6,156
4.15625
4
""" An example using Graph as a weighted network. https://networkx.github.io/documentation/networkx-1.10/reference/generated/networkx.drawing.nx_pylab.draw_networkx_edge_labels.html """ import matplotlib.pyplot as plt import networkx as nx import numpy as np import search class MyDiGraphProblem(search.Pr...
28789e85fe5a651088aed96262a4ba1c9bb97bed
ntuong196/AI-for-Puzzle-Solving
/Week7-Formula-puzzle/formula_puzzle.py
1,095
4.34375
4
# # Instructions: # # Complete the fill_in(formula) function # # Hints: # itertools.permutations # and str.maketrans are handy functions # Using the 're' module leads to more concise code. import re import itertools def solve(formula): """Given a formula like 'ODD + ODD == EVEN', fill in digits to...
0c2f0b9c3f54b7d76ef01ccf1db3107873d218e1
luizg-motta/infosatc-lp-avaliativo-01
/exercicio04.py
310
3.765625
4
premio = float(input("Digite o valor do prêmio: ")) imposto = (premio*0.93) print("O valor do prêmio é de {} reais com o imposto de {} reais.\n O primeiro recebeu {} reais.\n O segundo {} reais.\n E o terceiro {} reais".format(imposto, (premio - imposto), (imposto*0.46), (imposto*0.32), (imposto*0.22)))
afc983fa1e4e03e0a8076752758f7aa42c3421e2
luizg-motta/infosatc-lp-avaliativo-01
/exercicio18.py
154
3.96875
4
volume = float(input("Digite um valor de volume em m³:")) print("O valor de volume {:.1f} convertido para litros: {:.1f}".format(volume, (volume*1000)))
32edac452bca0b5b977a91084f71d6699fdcd44e
arathym/sentimentprediction
/merge_test_files.py
885
3.609375
4
#----- combining all the text files into the csv and also removing the punctuations------ # This program should be run inside the test folder since we are taking all the global .text files from that folder import glob import string fw = open('test_set.csv','wb') # file to which we are writing all the text file...
f257568f3bef133317a2f9df85f3dd594929922e
dreamnid/advent2020
/02/2a.py
565
3.953125
4
#!/usr/bin/env python3 INPUT_FILE = '2-input.txt' valid = 0 with open(INPUT_FILE) as fh: for line in fh: # E.g. 2-3 a: bbacda # Format of each line # char_limits inclusive required_character: password line_parts = line.split(' ') char_limits = list(map(int, line_parts[0].s...
72593fe34d5504065a91c21223a9f9db2f3bd454
dreamnid/advent2020
/06/6.py
1,393
3.59375
4
#!/usr/bin/env python3 import math from functools import reduce from typing import List, Set INPUT_FILE='6-input.txt' INPUT_FILE='6-example.txt' def get_any_yes() -> Set[str]: # Note that this depends on the file having an extra blank line at the end with open(INPUT_FILE) as fh: tmp = set() ...
c7f08b63ad5def930eb690cbbe51c8bdb90019be
lkhurana/gitcourse
/coloursDice.py
1,320
3.515625
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- # # team: Stefani Diaz, Lakshay Khurana, Panda # expert of exercise block 1: Stefani Diaz import random import time import sys import matplotlib.pyplot as plt def get_random_number(start, end): num = random.randint(start, end) return num def write_log_file(outp...
bd8bf4bfeffb290882ae8b2be524447d7f8a1e7c
codaf/ctci
/chapter-1/rowColumZero.py
766
3.953125
4
def makeZero(matrix): row = len(matrix) col = len(matrix[0]) list = [] for i in range(0, row): for j in range(0, col): if matrix[i][j] == 0: list.append((i,j)) if list: for elem in list: row1, col1 = elem for i in r...
552ac07459fc41a3ded8d737ee03b19c5d7ab76e
Yologuy101/string-encryption
/string_encryption.py
1,584
4.03125
4
s = input("Enter a string to encrypt: ") x = int(input("Shift value: ")) def encipher(s, x): """ encipher the string """ new_s = '' for i in s: if i != " ": new_char = warp(i) new_s = new_s+new_char else: new_s = new_s + " " return new_s def warp ...
b3974837bdaf507d7cbc6ca86cd760249fc5fa88
siradam/Algorithms
/Sub_arr_of_max_sum_naive.py
385
3.609375
4
def sub_arr_max_sum(arr): max = arr[0] for i in range(0,len(arr)): for j in range(i, len(arr)): sum = 0 for k in range(i, j): sum += arr[k] if sum > max: max = sum return max a = [1, -4 , 3, 5, 7, -9, -7, 7, 7, -15, 2, 4, 3...
eedf7b307c173ad34065a8f99cd8f21a3ea2bd99
Tajnicka/moj-prvy-blog
/test.py
321
3.5625
4
print('Hello, Django girls!') #def hi(meno): # if meno == "Tana": # print("Ahoj Tana") # elif meno == "Matej": # print("Ahoj Matej") # else: # print("Ahoj neznama") #hi("Mima") def hi(meno): print("Ahoj " + meno + "!") dievcata = ["Tana","Mima","Zuzka","Alex","Ty"] for meno in dievcata: hi(meno) print("Dal...
fe459061898837d12711ff7c51f68564b837be47
Scille/umongo
/umongo/i18n.py
725
3.546875
4
_gettext = None def gettext(message): """ Return the localized translation of message. .. note:: If :func:`set_gettext` is not called prior, this function retuns the message unchanged """ return message if not _gettext else _gettext(message) def set_gettext(gettext): """ D...
dbe29e10984d4744903cc5c2be9a6a9760952019
vindurriel/nest
/summarize.py
3,295
3.515625
4
#encoding=utf-8 from collections import defaultdict frequencies=defaultdict(int) stop_words=set() DISPLAY_FULLTEXT=True SUMMARY_RATIO= 0.1 def init_stopwords(): global stop_words stop_words= set(u"where the of is and to in that we for an are by be as on with can if from which you it this then at have all not one has ...
f948a6879d75e97b03630ffa7022454210ba4198
pushpindersingh1811/Calculator-Python
/interface.py
646
3.609375
4
from basic_calculator import calculator from length_converter import l_c from area_converter import a_c from weight_converter import w_c from temperature_converter import t_c print(""" For 'BASIC CALCULATOR' = Press "b" For 'LENGTH CONVERTER' = Press "l" For 'AREA CONVERTER' = Press "a" For 'WEIGHT CONVERTER...
650634e8c5712e66379c92c690dc03c528fb43b7
RobertBoylan-zz/Pig-Latin-Translator
/Pig Latin Translator.py
1,706
3.8125
4
import string def Translate(englishString): vowels = "aeiou" consonants = "bcdfghjklmnpqrstvwxyz" vowelSounds = ["xr", "yt"] translation = [] for word in englishString.split(): if len(word) == 2 and word[1] == "y": # Rule 4 translation.append(word[1:]+ word[0] +...
972d12732dcc31fa39896edae175f8fa558055bb
khalidprogrammer/python_tuts
/Lamda func.py
272
3.59375
4
# # def add(a,b): # return a+b # # print(add(1,4)) # Lamdaa function is anoymus function # add = lambda x,y:x+y # # print(add(3,4)) a = [[1,2],[5,4],[6,1]] # # def showlist(a): # return a[1] # a.sort(key=showlist) # print(a) a.sort(key=lambda x:x[1]) print(a)
1a56fd20304d82bc921077adbfa424ab28f0ddfd
khalidprogrammer/python_tuts
/reducefunc.py
250
3.96875
4
from functools import reduce list1 = [1,2,3,4,2] # # sum_list= reduce(lambda x,y:x+y,list1) # print(sum_list) # num =0 # for item in list1: # num=num+item # # print(num) def add(a,b): return a+b total_sum = reduce(add,list1) print(total_sum)
aa40e2107e95c6e7ca4e89d978cd1df662c9686b
khalidprogrammer/python_tuts
/read_file.py
189
3.546875
4
f = open("khalid.txt","r") print("lines was print below \n") # content = f.read() # for line in f: # print(line,end="") print(f.readline()) print(f.readline()) print(f.readline())
b3237eeeca1953be927dcccde547ea9859cf09f8
khalidprogrammer/python_tuts
/multipleinheritance_ex.py
839
3.609375
4
class Electronic: name = "Computer" model = "HP" camera ="Dell 4.5px" charger = "Yes" display ="Tube LCD" def PrintDevice(self): return f"Name is {self.name} \n Model is {self.model} \n Charger is {self.charger} \n Display is {self.display} " class PhoneGadget(Electronic): hdmi = "...
80cb9850a1ebed8a1569f0c6f46b9b23e54363bd
khalidprogrammer/python_tuts
/fault_calculator.py
1,422
4.34375
4
print("============================ Welcome To Faulty Calculator=========================") print("================Please enter this operator +,*,/,_,%** =================================") def calculator(): operator = input("Enter operator\n") number1 = int(input("Enter num1 \n")) number2 = int(input("E...
c77dbcde2d4bda000a4d813c0a7acc92fb4c6c77
jprorama/minemail
/bin/fullpath_itemset
663
3.609375
4
#!/usr/bin/python # extract the function args from url query parameters to create function args itemset from urlparse import urlparse import sys def pathsplit(x): return x.split('/') def argsplit(x): return x.split('=') def argname(x): return len(x) == 2 and x[0] + "= " + x[1] + "&" or x[0] + "=" def pathname(x): re...
783ff939d29fb7a5161e3ffff92689150d2d1e68
HexColors60/crianza
/examples/genetic/double-number.py
2,503
3.765625
4
""" A genetic programming simulation that produces programs that double their input values. """ import crianza import crianza.genetic as gp import random class DoubleInput(gp.GeneticMachine): """A GP machine that produces programs that double their input values. E.g., "* 2" or "dup +". """ def __init...
aa5bfc0a89a37962ee6178bf33ef5b21aa7a53da
MaxBranvall/practicepython.org-Exercises
/ex2.py
482
4.28125
4
# Ask user for number # print appropriate message if it's odd or even num = int(input("Please enter a number: ")) if num % 2 == 0 and num % 4 == 0: print("Even and divisble by 4!") elif num % 2 == 0: print("Just even!") elif num % 4 == 0: print("Just divisible by 4") else: print("Odd!") num = int(inp...
b0df43cf432bcddaf572dd8709ac11c07104c915
qq2681121906/1803
/06-day/20章作业11.py
178
3.71875
4
price = input("请输入商品价格") name = input("请输入商品名称") weight = input("请输入商品重量") print("价格%s\n名称%s\n重量%s\n"%(price,name,weight))
a64deda2fe47c30160cbc2e8e97cbff0469e42b4
qq2681121906/1803
/07-day/23章7题.py
269
4.03125
4
s_acc = "123456" s_pwd = "abc" acc = input("请输入账号") pwd = input("请输入密码") if s_acc == acc and s_pwd == pwd: print("登陆成功") elif s_acc != acc and s_pwd == pwd: print("账号错误") elif s_acc == acc and s_pwd != pwd: print("密码错误")
0122779b733d1d116e05b36e66154a43dc039533
qq2681121906/1803
/17-day/1-不定常函数.py
331
3.671875
4
def sum(a,b): c = a+b print(c) def sum1(a,b,*args,**kwargs): all_sum = 0 c = a+b print(args) print(kwargs) all_sum+=c for i in args: all_sum+=i for i in kwargs.values(): all_sum+=i print(all_sum) sum(1,2) #sum1(1,2,3,4,5,date6) t = (3,4,5) d = {"date":6} sum1(1...
cfcc4033dac8e236293eb01664ca0d32b9c01099
qq2681121906/1803
/07-day/23章9题.py
132
3.53125
4
figure = int(input("请输入一个数字")) if figure%2 == 0: print("%d是偶数"%(figure)) else: print("%d是奇数"%(figure))
6805cae6014dd2fe0f0fc44f8819ff7bd70638fa
singh-sumit/DS-Algo
/datastructure/python/Linked List/insertion.py
3,357
4.4375
4
''' Insertion on list can be done in : 1. At head of list 2. In between Node 3. At end of list ''' # Node class class Node: # function to initialize node object def __init__(self, data): self.data = data # Assigning provided data self.next = None # Initialize next poi...
1b772160a7a674d1ffe6153db0121856032b8e33
singh-sumit/DS-Algo
/datastructure/python/circular-list/count_nodes.py
1,890
4.09375
4
# count nodes in a circular list class Node: def __init__(self, data): self.data = data self.next = None # circular list class CircularLinkedList: def __init__(self): self.head = None # push node to head of list --O(1) def push(self, value): new_node = Node(...
0c5b6bdd96e6b85e5ad231b1740aefd20af82a8a
singh-sumit/DS-Algo
/datastructure/python/circular-list/sorted-insert.py
3,463
4.46875
4
# Sorted insert for circular Linked list """ - Allocate a node for new value say (new_node) Algorithm: Case 1: Linked List is empty : 1. Create a self loop new_node.next = new_node 2. Update head to new_node self.head = new_node Case 2: New Node is to be inserted before the head node: 1. Ch...
c96650a47a063e35156c72d155465b4ecefafe47
ppizarror/FI3104-Template
/lib/utils.py
3,475
3.96875
4
#!/usr/bin/env python # -*- coding: utf-8 -*- """ UTILS Este archivo provee de funciones básicas que son globalmente usadas. Autor: PABLO PIZARRO @ github.com/ppizarror Fecha: SEPTIEMBRE-OCTUBRE 2015 - 2016 Licencia: GPLv2 """ def append_list_to_list(origin, l): """ Añade los elementos de la lista l a la lis...
95db70fc0b3eb8f79eb2bed5926bb7d55268a42c
ojaAmazom/python
/List4-4.py
225
3.703125
4
print('1からnまでの和を求めます。') while True: n = int(input('nの値:')) if n > 0: break sum = 0 i = 1 while i <= n: sum += i i += 1 print('1から',n,'までの和は',sum,'です。')
8ba0897a51b2bae1a42ed6d09ca7512a0b8de728
chrisphamdev/halloween-bot
/helper/JsonHelper.py
501
3.5
4
""" This class removes the repetition for access and writing JSON files. """ from typing import Union, List, Dict import json class JsonHelper: @staticmethod def json_write(filepath: str, obj): with open(filepath, 'w') as file_input: json.dump(obj, file_input, indent=4) @static...
919c658e700bb9a53c8f11304b6884cac335374f
rbcvsz/python-treinamentos
/Coursera/Semana 4/soma dos digitos de um numero.py
154
3.96875
4
num = int(input("Digite um número inteiro: ")) soma = 0 while num > 0: ultimo = num%10 soma = soma + ultimo num = num//10 print(soma)
c8e06d07c169c6766b99e8ae096eecab0dd902a0
rbcvsz/python-treinamentos
/Data Science Academy/for para buscas.py
177
3.78125
4
street_fair = ["japanese pumpkin","potato","carrot","lettuce","broccoli","organic coffee","bread"] for item in street_fair: if item == "watermelon": print("Nice!")
0739814d04ad9cde3e45c0c4fe3e429395676f73
rbcvsz/python-treinamentos
/Coursera/Semana 5/funcao fatorial.py
205
3.953125
4
#Função para calculo de Fatorial def fatorial(numero): fatorial = 1 for i in range(1, numero+1): if i <= numero: fatorial *= i return fatorial print(fatorial(5))
da07deeea1190ddc92331c17f11bad8abca0172b
rbcvsz/python-treinamentos
/csv_pequeno.py
339
3.640625
4
import csv #Abrir o arquivo referencia = open(r"C:\python\pequeno3.csv","r") #Ler a tabela arquivo = referencia.read() #Separar o arquivo em linhas: linhas = arquivo.split('\n') todasLinhas = [] #Separar cada linha em coluna: for i in linhas: colunas = i.split(',') print() todasLinhas.append(colunas) ...
1c44fed92ef5e6e7c986f79a0f2473de31325184
hansweni/UBC_PHYS_Python-crash-course
/2. Arduino for Data Collection/RGB_LED.py
1,311
4.28125
4
''' Program to demonstrate how to flash the three colors of a RGB diode sequentially using the Arduino-Python serial library. ''' # import libraries from Arduino import Arduino import time board = Arduino() # find and connect microcontroller print('Connected') # confirms the microcontroller has been found # give pi...
b2f0a374a3739e069299da3a27a3b476db7efab3
regulusreddy/Machine-Learning
/neural_network_gradient_linear_reg.py
9,997
4.03125
4
# -*- coding: utf-8 -*- """ Created on Sun Dec 10 19:54:05 2017 @author: lalit """ #neural network from scratch #Network with input layer, one hidden layer, and output layer #Input layer has two units and one bias unit #Hidden layer has two units and one bias unit #Output layer has two units import numpy as np impor...
ade53a6a0ed848fb9f85b2f2efc2fce45f7b4240
ProfoundNetworks/pygeons
/pygeons/api.py
29,256
3.6875
4
"""A more Pythonic interface for geonames. Offers the following abstraction over the geonames data: - The world is divided into countries (see the Country class) - Each country is divided into states (see the State class) - A state includes multiple cities (see the City class) Countries are at the very top level. Yo...
d37459954159f00eda568e09f0c84c63d620a964
yooni1903/DDIT
/workspace_python/HELLOPYTHON/day01/mytest04.py
298
3.671875
4
# a = input("시작수를 넣으세요") 단 작은 수 # b = input("끝 수를 넣으세요") # a에서 b까지의 합을 구하세요 a = input("시작수를 넣으세요") b = input("끝 수를 넣으세요") sum = 0 for i in range(int(a), int(b)+1): sum += i print("합계 : ", sum)
ad666ccb276e5121a6a72a7a53a8da242293d9fe
yooni1903/DDIT
/workspace_python/HELLOPYTHON/day01/mytest02.py
304
3.703125
4
sum = 0 for i in range(11): sum += i print(sum) # 2~10까지의 2의 배수의 합을 구하시오 a = range(2,11) sum = 0 for i in a: if i % 2 == 0: sum += i print(sum) # 선생님이 하신 코드 sum2 = 0 for i in range(2, 11): if i % 2 == 0: sum2 += i print(sum2)
6c0497d06e0ec61dd629c904a4ad59bfaa1a2853
yooni1903/DDIT
/workspace_python/HELLOPYTHON/day06/myselect_sem.py
366
3.640625
4
import pymysql # MySQL Connection 연결 conn = pymysql.connect(host='localhost', user='root', password='python', db='python', charset='utf8') curs = conn.cursor() # 자바에서 statement와 같은 역할이다 sql = "select col01, col02, col03 from sample" curs.execute(sql) rows = curs.fetchall() print(rows) ...
65418f750afea14168ea6f8095b9bf1234b722a8
KiranGowda10/Add-2-Linked-Lists---LeetCode
/add_2_num.py
832
4.125
4
class Node: def __init__(self, data = None): self.data = data self.next = None class LinkedList: def __init__(self): self.head = Node() def append(self, data): new_node = Node(data) current_node = self.head while current_node.next is not None...
ece476c469370e6aaeb61f1b5255f83735f312a5
zhengjieliuyan/project---python
/py基础/testzuoye.py
796
3.9375
4
#作业1 # a = input('请输入自己的英文名字') # dict = {} # dict['name'] = a # real_name = dict['name'] # dict['new_name'] = dict['name'][::-1] # liar_name = dict['new_name'] # print('正常的英语姓名:%s\n您的英语翻转姓名:%s' %(real_name, liar_name)) #作业2 # corse = input('请输入各科的成绩,中间以分号隔开') # corse_list = corse.split(',') # print(corse_list) # for n ...
bb451bf1f60d1406b5117dca92fda370b2ba7dcd
Ashokkommi0001/Python-Patterns-Symbols
/reverse_triangle.py
244
3.890625
4
def reverse_triangle(): for row in range(6): for col in range(11): if (row==0) or (row-col==0 or row+col==10): print("*",end=" ") else: print(end=" ") print()
852fc3cba12c11c5825db50cc171386da989806f
Ashokkommi0001/Python-Patterns-Symbols
/right_triangle.py
234
3.859375
4
def right_triangle(): for row in range(6): for col in range(6): if (col==5 or row==5) or row+col==5: print("*",end=" ") else: print(end=" ") print()
cc7051de3b373e45282d1f5e6af3393084de9c75
labuzzetta/conformal
/conformal/measures.py
1,278
3.65625
4
class Measure: """Abstract Measure base class.""" def __init__(self): pass class Ratio(Measure): def __init__(self): pass @staticmethod def measure(output, label): """ The ratio of best best scoring label for not equal to ground truth label and the score ...
856ade8436be149108576ebb4bfbfc99af574e13
carmonantonio/python_coursera
/dictionaries.py
319
3.578125
4
# Este programa busca una direccion de correo y guarda la frecuencia en un diccionario mail = dict() fh = open('mbox.txt') for lines in fh: if not lines.startswith('From: ') : continue lines = lines.rstrip() words = lines.split() for word in words: mail[word] = mail.get(word,0)+1 print (mail)
fb2327282c9e747258eeb78c888e3c353020a4c8
carmonantonio/python_coursera
/numlist.py
335
3.96875
4
count = 0 total = 0 while True: inp = input("Hello, please enter a number:") if inp == "done": break if len(inp) < 1 : break try: num = float(inp) except: print("Invalid input") continue count = count + 1 total = total + num print(num,"Total acumulado",total,"total numbers",count) print("Average is ",tot...
5f555dca5a4ac40285dd11bca38912a28cf11f2f
betsybookwyrm/tropofy-anagram
/tests/test_anagram.py
740
3.84375
4
""" Tests for basic functions to avoid having to run the whole thing just for this Written for py.test """ from anagram.anagram import hash_word, validate_word def test_word_hash(): assert hash_word('Alphabetise') == 'aabeehilpst' assert hash_word('live') == hash_word('Evil') assert hash_word('TomMarvol...
e055162150e1a8da76779bd3443bc61d211658cf
Skylore/studypy
/hw1/utils.py
933
3.671875
4
import random class Car: def __str__(self): return "don't use print!!!" def __eq__(self, other): print("don't use == ") return False class Bmw(Car): count = 0 def __init__(self): Bmw.count += 1 class Audi(Car): count = 0 def __init__(self): Audi.c...
5ba29042fdbe4dc55e7b1360679c6a1b24aae6e3
1411kondas/cs257
/olympics/olympics.py
1,952
3.65625
4
''' Sriya Konda olmympics.py Jeff Ondich Adapted by code from ''' import psycopg2 from config import password from config import database from config import user # Connect to the database try: connection = psycopg2.connect(database=database, user=user, password=password) except Exception as e: ...
b541459c491e56d666fd84fecbaa972589e0dedb
mo-mosverkstad/my_net_socket
/original_python_socket/PythonTcpServer/PythonTcpServer.py
1,759
3.953125
4
# first of all import the socket library import socket import sys # reserve a port on your computer in our # case it is 1337 but it can be anything # Define socket host and port SERVER_HOST = '127.0.0.1' SERVER_PORT = 1337 MAX_BUFFER = 1024 # create socket try: server_socket = socket.socket(socket.AF_INET, socket...
134599c044350454a2c68f96fbfac05e3e1758d3
MITZHANG/BIDS
/src/common_lib/link_list.py
3,766
4
4
#!/usr/bin/env python # encoding: utf-8 """ @author: HuRuiFeng @file: link_list.py @time: 2019/4/9 20:48 @desc: 链表的实现 """ class Node(object): def __init__(self, val=None, p = None): self.data = val self.next = p def __str__(self): return "Node[" + str(self.data) + "]" class LinkList(o...
b080019ab7806d956070579a31915f5da7dbe4ad
MITZHANG/BIDS
/src/array/binary_search_array.py
765
4
4
#!/usr/bin/env python # encoding: utf-8 """ @author: HuRuiFeng @file: binary_search_array.py @time: 2019/2/9 16:01 @desc: 第7讲:数组二分查找 """ # key: 要查找的关键字,data: 数组,N: 数组长度 def binary_search_array(key, data, N): if N < 0: return -1 low = 0 high = N - 1 while low <= high: mid = int(low + (h...
39114dc528e2ffb0c82961beecabfbef18bc32d4
Luke-zhang-04/Leetcode-solutions
/hard/problem4/__main__.py
1,394
3.75
4
""" Runtime: 92 ms, faster than 84.09% of Python3 online submissions for Median of Two Sorted Arrays. Memory Usage: 12.7 MB, less than 100.00% of Python3 online submissions for Median of Two Sorted Arrays. 02/14/2020 MM/DD/YY """ class Solution: # From merge sort @staticmethod def merge(array1, array2): ...