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
7d1f106223c7d1ab1e4620d9d36b29a15adbbb9c
cyberLaVoy/algorithms-notebook
/python/bfs.py
571
3.71875
4
from queue import Queue # graph: a list of lists (adjacency list) [ [ w0, w1, ...], ...] # start: starting vertex as index to adjacency list # Output: the step-wise distance to all vertices from start vertex def bfs(graph, start): distance = [None]*len(graph) distance[start] = 0 queue = Queue() # F...
2c08e7bcd8497a7b7ae25e6ade314cc5fee1dd6a
cyberLaVoy/algorithms-notebook
/python/multiplesAndDivisors.py
531
3.90625
4
def gcd(a, b): if b == 0: return a return gcd(b, a%b) # nums: a list of integers # Output: the gcd of all values in nums def gcdList(nums): result = nums[0] for i in range(1, len(nums)): result = gcd(result, nums[i]) return result def lcm(a, b): return a*b//gcd(a,...
5cbdec2008fac142d0804a32ae3930d9b2f72738
AlexisBallo2/rockpaperscissors
/rockpaperscissors.py
1,961
3.96875
4
import random import sys import time x = 0 y = 0 print("Rock") #1 print("Paper") #2 print("Scissors") #3 while True: choice = True while choice: player = input(("What is your choice?: ")) if player == "rock" or player == "Rock": player = 1 choice = Fal...
437e39bcf34f461b61338bc5b4946746387b37ef
MurtAlsa/mpyc
/mpyc/seclists.py
9,169
4.03125
4
"""This module provides a secure (oblivious) alternative to Python lists. A secure list contains secret-shared values. Apart from hiding the contents of the list, however, it is also possible to hide which items are accessed and which items are updated. In principle, only the length of a secure list remains public. A...
eb8f13ba8ef2c9a7adad8dcc94081a8aa24cb93e
hsinhuibiga/Python
/insertion sort.py
1,419
4.34375
4
# sorts the list in an ascending order using insertion sort def insertion_sort(the_list): # obtain the length of the list n = len(the_list) # begin with the first item of the list # treat it as the only item in the sorted sublist for i in range(1, n): # indicate the current item to be p...
8e19a6ae2b7f16d1c5a0f163a0edf36e73213d0a
BryanBumgardner/dsp
/python/advanced_python_dict.py
1,900
3.921875
4
import pandas as pd from pandas import DataFrame, read_csv from collections import OrderedDict #where is your file? here! path = '/Users/bryanbumgardner/anaconda/faculty.csv' #convert into pandas dataframe, and be picky about your column names. df = pd.read_csv(path, header=0) df.columns = ['Name', 'Degree', 'Title', '...
d7171247945955b541e35dd6520bf709e7ea64ab
AliSeren/Java
/ali_seren (1).py
2,238
3.5
4
from tkinter import * class Ali_0: def __init__(self): self.ali_1 = Tk() self.ali_1.title('TÜRKİYE - ŞEHİRLER') self.ali_2=open("sehirler.txt",'r') self.ali_4={ali_3.split(',')[1].rstrip() for ali_3 in self.ali_2} self.ali_2.close() self.ali_5=list(...
e0bf91a6c7bbfa10f8928ac58ce052dbe27f6aff
tommyle128/leminhtu-labs-c4e20
/Lab03/homework/inside.py
216
3.71875
4
def is_inside(point, rect): end_x = rect[0] + rect[2] end_y = rect[1] + rect[3] if rect [0] <= point [0] <= end_x and rect[1] <= point [1] <= end_y: return True else: return False
313cc05b63fb54c0d5b2bc2f5b6956db2dfb754c
yonghee555/Python-Study
/2_내장_시퀀스_타입/6_reversing_words.py
242
3.828125
4
def reversing_words_slice(word): new_word = [] words = word.split(" ") new_word = words[::-1] return " ".join(new_word) if __name__ == "__main__": print(reversing_words_slice("파이썬 알고리즘 정말 재미있다"))
1f0572c27e4187c8d5c335476f8e59b5288019e2
yonghee555/Python-Study
/7_추상_데이터_타입/13_reverse_string_with_stack.py
314
4.1875
4
from stack import Stack def reverse_string_with_stack(str1): s = Stack() revStr = '' for c in str1: s.push(c) for _ in range(s.size()): revStr += s.pop() return revStr if __name__ == "__main__": str1 = "Hello!" print(str1) print(reverse_string_with_stack(str1))
211f71814c385eef3cb93cd22800c6dabe7b91da
TamTran72111/aoc-2020
/python/day15.py
2,370
3.765625
4
import unittest from typing import List def memory_game(starting_numbers: List[int], last_turn: int) -> int: memory = [None] * 30_000_001 last_num = starting_numbers[-1] for index, num in enumerate(starting_numbers[:-1]): memory[num] = index for turn in range(len(starting_numbers)-1, last_turn...
ebb84e086cc4c1f70803a7ae481a6ca041d85d76
csse120-201930/18-Exam2-201930
/src/problem2.py
20,308
3.546875
4
""" Exam 2, problem 2. Authors: David Mutchler, Vibha Alangar, Matt Boutell, Dave Fisher, Mark Hays, Amanda Stouder, Aaron Wilkin, their colleagues, and PUT_YOUR_NAME_HERE. """ # TODO: 1. PUT YOUR NAME IN THE ABOVE LINE. import time import testing_helper ###########################################...
280fce0abb519105a75112549424979e312104f8
Stablemadness/python_assignments
/pi3.py
486
4.0625
4
import copy list1 = [1, 1, 1, 2, 3, 4] list2 = [4,3,2,1,6] if list1 == list2: print('equals') if list1 < list2: print('list1 less than list2') print(list1, list2) list2.sort() print(list2) if list1 == list2: print('equals') if list1 > list2: print('list1 greater than 2') if list2 > list1: ...
c5e200c7892025ea75774dcbfccbc3bb0bb51dee
grimmi/learnpython
/maxlength.py
330
4
4
''' Find the number with the most digits. If two numbers in the argument array have the same number of digits, return the first one in the array. https://www.codewars.com/kata/58daa7617332e59593000006/train/python ''' def find_longest(arr): return max(arr, key=lambda x: len(str(x))) print(find_longest([123, 345,...
d70613eaa55ed3f52e384a4f97e3a751d0723e87
grimmi/learnpython
/linkedlist1.py
1,132
4.125
4
''' Linked Lists - Push & BuildOneTwoThree Write push() and buildOneTwoThree() functions to easily update and initialize linked lists. Try to use the push() function within your buildOneTwoThree() function. Here's an example of push() usage: var chained = null chained = push(chained, 3) chained = push(chained, 2) ch...
d3e25805b601aff974c730abd85b4368724d09d4
grimmi/learnpython
/reversebytes.py
810
4.125
4
''' A stream of data is received and needs to be reversed. Each segment is 8 bits meaning the order of these segments need to be reversed: 11111111 00000000 00001111 10101010 (byte1) (byte2) (byte3) (byte4) 10101010 00001111 00000000 11111111 (byte4) (byte3) (byte2) (byte1) Total number of bits will always be a mu...
61afa0c643dc0555b1ccab6f907cc2cc68154468
StafDehat/python2
/personal/lab03d-birthdays.py
790
3.71875
4
# Author: Andrew Howard import random classSize = 23 # Return whether or not list contains a duplicate value def has_duplicates(inList): for x in inList: if ( inList.count(x) > 1 ): return True return False # Generate a birthday def birth(): return random.randint(1,365) # Generate a list of birthda...
f9d7b69561c33480b84db5582d1545a632b01f84
StafDehat/python2
/personal/review-lab.py
1,573
3.765625
4
# Solution: # https://dl.dropboxusercontent.com/u/68071780/labdone.py # Author: Andrew Howard import random import math import sys # Initialize wallet = 100 print "Beginning balance: $",wallet # Roll 1 die, return value def dieRoll(): #return int(math.ceil(random.random() * 6)) return random.randint(1,6) # Roll...
45e1843009a07de686d8d2be4fb9f29b0c823d60
Alish26/PP2
/TSIS 3/H.py
329
3.828125
4
def gcd(a, b): if(not b): return a return gcd(b, a % b) def lcm(a, b): lcm.x += b if(lcm.x % a == 0 and lcm.x % b == 0): return lcm.x return lcm(a, b) lcm.x = 0 a, b = input().split() a = int(a) b = int(b) if(a > b): print(gcd(a, b) + lcm(b, a) ) else: print(gcd(a, b) + l...
c8d196a77bf174e023019f052b7f1eecdc96bfd7
Alish26/PP2
/TSIS 5/7.py
247
3.703125
4
import re def Sol(s): p = '^[a-z]+_[a-z]+$' if re.search(p, s): return 'Found a match!' else: return('Not matched!') print(Sol("aab_cbbbc")) print(Sol("aab_Abbbc")) print(Sol("Aaab_abbbc"))
3d5bd1903fbd123b16d4900a91b9ecdb8d1990d0
morins/modupython
/practice4-2_String.py
1,827
4.03125
4
# 모두의 연구소, 토요일 스터디 Jump to Python - Study 1st, Sangwoo Ji # 4.2 문자열(String) # 문자열 만드는 방법 4가지 # 위의 예에서는 문자열을 만들 때 이중인용부호(")만을 사용했지만 이 외에도 문자열을 만드는 방법은 세 가지가 더 있다. 파이썬에서 문자열을 만드는 방법은 다음과 같이 네 가지로 구분된다. # "Hello World" # 'Python is fun' # """Life is too short, You need python""" # '''Life is too shor, You need pyth...
886ebc6d1dc174ba743958143cd80d1c7d595df4
IvoryLu/data-processing
/practice/simple_1.py
749
3.9375
4
# -*- coding: utf-8 -*- """ Created on Mon Nov 4 13:24:03 2019 @author: Ivory.Lu """ # Complete the jumpingOnClouds function below. def jumpingOnClouds(c): count = 0 one = 1 i = 0 while i + 1 < len(c): print(i) if one not in c: count = int(len(c)/2) break ...
cf6bca31d3318cd223d62466b9fe012edcf00655
MukeshThamilvanan/MTPythonPractices
/loopstry.py
573
3.515625
4
# print("Solution A") # for x in range(200, 301): # print(x) # print("Solution B") # for y in range(200, 300, 4): # print(y) # print("Prime numbers from 1 to 100") # for def solution(): a = 10 b = 11 c = 12 return a+b, a+c, b+c def sum(a, b): return a+b def main(a): print("main", a) def onlyprim...
7d854312aa354e2bb3243ae95de55e1bd4f12a57
ddzz/algorithms
/mergeSort.py
715
3.90625
4
# Recursive merge sort algorithm # O(nlogn) running time def mergeSort(array): if len(array) <= 1: pass else: mid = len(array)//2 left = array[:mid] right = array[mid:] mergeSort(left) mergeSort(right) i = 0 j = 0 k = 0 for k in range(len(array)): if len(left) > i and len(right) > j...
b813a38631d35d6ccc84b871fade7dc9ccbde14c
ll0816/My-Python-Code
/decorator/decorator_maker_with_arguments.py
1,084
4.1875
4
# !/usr/bin/python # -*- coding: utf-8 -*- # decorator maker with arguments # Liu L. # 12-05-15 def decorator_maker_with_args(d_arg1, d_arg2): print "I make decorators! And I accept arguments:{} {}".format(d_arg1, d_arg2) def decorator(func): print "I am the decorator. Somehow you passed me arguments:...
e6c961a8bd80a519024fe2f0636c982fb6566ec4
ll0816/My-Python-Code
/webScraper/best-sandwiches-2012.py
3,402
3.5625
4
#!/usr/bin/python # -*- coding: utf-8 -*- # Scraper for best sandwiches of 2012 in Chicago. Generate flat-formated tsv file. # Liu Li # 12-03-2015 # Code Source: http//www.gregreda.com/2013/04/29/more-web-scraping-with-python/ # Source: http://www.chicagomag.com/Chicago-Magazine/November-2012/Best-Sandwiches-Chicago/ ...
295ace8f90f7303eba831493003cdd7289a4c3c9
ll0816/My-Python-Code
/decorator/dive_in_decorator.py
1,094
4.21875
4
# !/usr/bin/python # -*- coding: utf-8 -*- # dive in decorator # Liu L. # 12-05-15 def decorator_maker(): print "I make decorators! I am executed only once:"+\ "when you make me create a decorator" def my_decorator(func): print "I am a decorator! I am executed"+\ "only when you decorate a...
21079958d6258d156092e881a67e882c981d837d
Vasiliy1982/repo24122020
/python/DZ_Python_№8 задача 1.py
1,630
3.9375
4
# DZ_Python_№8 задача 1 # Пользователь вводит с клавиатуры два числа. # Нужно посчитать отдельно сумму четных, нечетных и чисел, кратных 9 в указанном диапазоне, # а также среднеарифметическое каждой группы. number_first = int(input("Введите первое число: ")) number_last = int(input("Введите второе число: ")) ...
61770d0011bff3c587916ead9a331e820d8a1fec
Vasiliy1982/repo24122020
/python/DZ_Python_№7 задача 1 ver2.py
559
3.96875
4
# DZ_Python_№7 задача 1 # Пользователь вводит с клавиатуры два числа. # Требуется проанализировать все числа в этом диапазоне по следующему правилу: если число кратно 7, его надо выводить на экран. number1 = int(input("Введите первое число: ")) number2 = int(input("Введите второе число: ")) for i in range(numb...
0699f762600979d79430486583d4beeb87924825
Vasiliy1982/repo24122020
/praktika_urok6_1.py
704
3.59375
4
#praktika_urok6_1 size_file_gig = int(input("Введите размер файла в гигабайтах")) speed_inet = int(input("Введите скорость интернет соединения")) size_file = size_file_gig*1024*1024*1024 upload_time = size_file/speed_inet choice = input("Если хотите узнать время скачивания в часах введите: 1, если в минутах 2,...
00b636907d8c06e2381454cc5ac78cd4d215940f
Vasiliy1982/repo24122020
/python/DZ_Python_№6 задача 1.py
1,140
4.0625
4
#Урок 6: Задача 1 #Пользователь вводит с клавиатуры число в диапазоне от 1 до 100. Если число кратно 3 (делится на 3 без остатка)нужно вывести слово Fizz. # Если число кратно 5 нужно вывести слово Buzz. Если число кратно 3 и 5 нужно вывести Fizz Buzz. # Если число не кратно не 3 и 5 нужно вывести само число. # Если...
c30e94c2f8cda010ff6f145c4208837c41dc5299
ZJXuan128/practice
/py100/30.建立数组查重函数.py
255
3.671875
4
def search(s_list): for i in range (0,len(s_list)): for j in range (i+1,len(s_list)): if(s_list[i]==s_list[j]): return True return False s_list=list(input("输入一组数据")) a=search(s_list) print(a)
41a60423e3f28a43588427f8ba101bbea8a78d4f
ZJXuan128/practice
/py100/87.列表转字典.py
211
3.625
4
key=input("输入各个键:") list_k=key.split() value=input("输入对应值:") list_v=value.split() for i in range (0,len(list_v)): list_v[i]=int(list_v[i]) s=dict(zip(list_k,list_v)) print(s)
808893981afe0f62bf638b1c445a6ef2df6396f8
ZJXuan128/practice
/py100/36.星期判断.py
601
3.9375
4
str=input("输入星期英文字母:") while(1): if(str=='M'): print("星期一") break elif(str=='W'): print("星期三") break elif(str=='T'): str1=input("下一个字母") if(str1=='u'): print("星期二") break elif(str1=='h'): print("星期四") ...
5dd8f6e5bdeade0c94913a939bbafbf0b9d74294
ZJXuan128/practice
/py100/75.给定字符串_查重.py
247
3.53125
4
st=input("输入要查重的字符串:") for i in range (0,len(st)): for j in range (i,len(st)): if(st[i]!=st[j]): print(j+1) t=1 break if(t!=0): break if(t==0): print(-1)
ee565cd76ebd5e7a45a685c1489a0978dd4c7ebd
ZJXuan128/practice
/py100/71.循环输出列表_.py
122
3.5625
4
st=input("输入列表元素,空格分割") s_list=st.split() for i in range (0,len(s_list)): print(s_list[i])
1262b469c03a0527eee51413cb93dd02f3eda68a
ZJXuan128/practice
/py100/39.100以内素数.py
195
3.796875
4
import math print("2\n3") for i in range (2,100): for j in range (2,int(math.sqrt(i)+1)): if(i%j==0): break if(j==int(math.sqrt(i))): print(i)
027e1de58d7988f37e4ef458f0c489dee835a825
ZJXuan128/practice
/py100/35.判断回文.py
154
3.5625
4
n_list=list(input("输入一个五位数")) if(n_list[0]==n_list[4]and n_list[1]==n_list[3]): print("是回文") else: print("不是回文")
1e9ff432200546f5abe8b29d1ca5696d160c3248
ZJXuan128/practice
/py100/77.1~7组成奇数.py
210
3.546875
4
s =0;total = 0 for i in range (0,9): if(i == 1 ): total = 4 elif(i ==2): total = total*7 else:total *= 8; print("0~7组成%d位数,有:%d个"%(i,total)) s+=total print("总计为:%d" % s)
bb2e9c9e0d342d7a3690e3b5900e461d18cc580a
Njeri-anne5/Computer-Graphics-Algorithms-in-Python
/Output Primitives/Line Drawing Algorithms/bresenhams_line.py
1,361
4.0625
4
# This algorithm is used for scan converting a line. It was developed by Bresenham. # It is an efficient method because it involves only integer addition, subtractions, # and multiplication operations. These operations can be performed very rapidly so # lines can be generated quickly. # Learn about it here : http...
bd36877176cb6139059c5c24dd4dfe016829e99d
menard-codes/quadratic_solver
/quadratic_equation.py
5,756
3.65625
4
from math import sqrt import tkinter as tk from tkinter import messagebox as mb root = tk.Tk() root.title("Quadratic Equation Solver") def title_hover(event): label_a = event.widget label_a.config(bg="#f3fcb1", font=("Bookman Old Style", 21)) def title_leave(event): label_a = event.widget label_a.config(bg="#...
bb0fffddc9e3da188e75123ff4e9362fa0eddccd
harshagr18/DjangoPractice
/FirstCode.py
147
3.921875
4
def Thanos(x): if x == 6: return True else: return False x = int(input("Please Enter the number of stones Thanos got")) print(Thanos(x))
5201d00c50e71feca476ffa1c815740b82b4f1b0
veerapalla/cracking_the_coding_interview
/Interview/rpn2infix/rpn2infix.py
1,758
3.546875
4
import doctest import sys args = sys.argv[1:] # print args def rpn2infix(args): """ test rpn2infix >>> rpn2infix("1 _".split()) '_1' >>> rpn2infix("3 4 _ + 5 * 6 -".split()) '(3 + _4) * 5 - 6' >>> rpn2infix("3 _ 4 + 5 6 - *".split()) '(_3 + 4) * (5 - 6)' >>> rpn2infix("2 3 + *".split()...
23e09857f3a65f1f51220f67e5ad65b872c13736
veerapalla/cracking_the_coding_interview
/GlassDoor/amazon/commonchar.py
221
3.671875
4
def commonchar(a, b): s1 = set([]) s2 = set([]) for i in range(len(a)): s1.add(a[i]) for i in range(len(b)): s2.add(b[i]) return s1.intersection(s2) print commonchar("hello", "elbow")
f3bf281a60b0e3b27e55daafeac9f88d38504109
tomoswootton/project-euler
/p36.palindrome-2-bases.py
941
3.953125
4
def binary_convert(number): n=0 #find number of columns needed while pow(2,n) <= number: n = n + 1 n = n-1 binary = [0] * (n+1) while n>=0: if number >= pow(2,n): number = number - pow(2,n) binary[n] = 1 n = n-1 binary.reverse() return ''.j...
4c4dd9aff9a22fc64aa69bdc0111550cd755c36a
JoerdanNewue/Money_Parter
/Fellow_Paymaster.py
920
3.96875
4
print("Кассир оптимально выдаст вам сдачу") change = int(input(print("укажите величину остатка в копейках"))) if change < 0: print("такого быть не может") while change < 0: change = int(input(print("укажите величину остатка в копейках"))) a = 50 av = 0 b = 10 bv = 0 c = 5 cv = 0 d = 1 dv = 0 lowchange = change ...
5905a4f8fb9d09f4d4c479cd8f1fd1bc2de1b7d6
sihuamanu/shiyanlou
/python-basic-calculator-dev/calculator2.py
945
3.640625
4
#!/usr/bin/env python3 import sys def cal(a, b): try: income = int(b) except ValueError: print("Parameter Error") exit() insurance = income * (0.08 + 0.02 + 0.005 + 0.06) tax_income = income - insurance - 3500 if tax_income <= 0: tax_pay = 0 elif tax_income <= 1...
75f6664728839cce2ba012dec18ee4ef3922ab1f
OSU-CS-325/Project_One_MSS
/better-enumeration/alg2.py
1,126
3.609375
4
#------------------------------------------------------------------------------- # Function: betterEnumeration # Description: Computes the maximum sub-array and and associated sum using # the "better enumeration" algorithm. # Receives: values - list of integers # Returns: maximum sub-array s...
0a05b4f0f9c82eb9756c49e6828d02f27d1b1257
devlinmorrow/hang_human
/game.py
1,127
3.765625
4
class Game(): def __init__(self, word_to_guess): self.word_to_guess = word_to_guess self.chosen_characters = [""] self.guesses_left = 10 def convert_word(self): converted_word = [] for char_in_word_to_guess in self.word_to_guess: if char_in_word_to_guess in ...
6ec63ad053443aa4b6f9e993a3877e02d9d1372b
suryabakaraju/LeetCode
/Judgecircle_leetcode.py
391
3.5
4
# -*- coding: utf-8 -*- """ Created on Tue Sep 19 01:13:38 2017 @author: surya """ class Solution(object): def judgeCircle(self, moves): """ :type moves: str :rtype: bool """ if moves.count('U')-moves.count('D')==0 and moves.count('L')-moves.count('R')==0: ...
e372e09609e43f129d3b3e1f57b9964154524210
tranvantam09032000/Thuattoan_python
/QuickSort.py
692
3.921875
4
def partition(arr, start, end): pivot = arr[start] left = start + 1 right = end while True: while left <= right and arr[right] >= pivot: right = right - 1 while left <= right and arr[left] <= pivot: left = left + 1 if left <= right: arr[left]...
731b8308465cdeb1e8e033f5a61870a7146a4e46
irtaylor/rick_and_morty_text_game
/rm_room.py
3,490
4.375
4
#!/usr/bin/env python class Room(object): """ A Room in the Rick and Morty text adventure game is an area that exists in a World object. Rooms may have characters, features, items, and other secrets a player can find and interact with. """ def __init__(self, name): """ Initia...
efd82b583ffd65d8dda404992ede9e38dfd4da9b
acynonix/Support-Genie
/supportGenie/main_functions.py
2,305
3.6875
4
import random """ 'agent_av' is a boolean 'since' is a list containing [hr, m, sec] 'role' is a list containing strings that defines the agent's role """ data = {'agent_1': {'agent_av': True, 'since': [11, 59, 00], 'role': ['Spanish Speaker', 'Support']}, 'agent_2': {'agent_av': True, 'since': [12, 0...
c7c3c4674fde09c24e9969f085765a8b3fe6f1dc
ftonolini45/VICI
/neural_networks/layers.py
9,673
3.59375
4
''' Functions to implement layers ''' import tensorflow as tf from neural_networks import NN_utils import numpy as np def reshape_1D(x,sig_sz=None): ''' Reshape data array from [number_of_samples,dimensions] to [number_of_samples,signal_length,channels] INPUTS: x - input data array in the format [...
1deab1f73b6df98c1ef2d3dc6bf5c9485b4d8478
koogordo/py-games
/TicTacToe/tic_tac_toe.py
2,406
3.59375
4
def check_winner(current_board, player): if( (current_board[0] == player and current_board[1] == player and current_board[2] == player) or (current_board[3] == player and current_board[4] == player and current_board[5] == player) or (current_board[6] == player and current_board[7] == player ...
08b0ce788e8a282304303d4e1f5548fd91108283
804463592/python3
/open_file.py
298
3.6875
4
try: file_name=input('请输入需要打开的文件名(加上后缀名):') f=open(file_name) print('文件内容是:') for each_line in f: print(each_line) except OSError as reason: print('出错了'+str(reason)) else: print("一切正常") #print(f.read(-1))
d66940e46dc5ceef9a1b858256d3f539b86ca170
RodionLe/Dawson-Python
/5/распределенные ссылки.py
550
3.515625
4
mike = ["белая рубашка", "комбинезон цвета хаки", "пиджак"] mr_dawson = mike honey = mike print("mike(original): ", mike) print("mr_dawson(copy mike): ", mr_dawson) print("honey(copy mike): ", honey) honey[2] = "красный свитер" print("change honey") print("honey(copy mike): ", honey) print("honey(copy mike): ", mike) p...
3f9963f130edfeb952f10d9197645cf7ffce7ddb
RodionLe/Dawson-Python
/7/обработаем.py
1,609
4.3125
4
# Демонстрирует обработку исключительных ситуаций try: num = float(input("Введите число ")) except: print("Похоже, это не число") try: num = float(input("\nВведите число ")) except ValueError: print("Это не число") # Обработка исключений нескоьких разных типов print() for value in (None, "Привет!"): ...
e56b714573b97c59c17b2d090dfc1824cb4c5233
RodionLe/Dawson-Python
/4/срезы пиццы.py
652
4.0625
4
word = "пицца" print("Ведите начальный и конечный индекс для того среза 'пиццы',который хотите получить.") print("Для входа нажмите enter, не вводя начальную позицию. ") start = None while start!="": start = (input("\nНачалььная позиция: ")) if start: start = int(start) finish = int(input("Конеч...
1367ca8a2ec3af38a9b7fd2de535d0f1881660eb
RodionLe/Dawson-Python
/4/1/1/_1.py
247
3.96875
4
start = int(input("Введите начало осчета: ")) finish = int(input("Введите конец отсчета: ")) a = int(input("Введите интервал отсчета: ")) for i in range(start, finish+1, a): print(i)
b48d9ff135b24aae510a297eeadad9e00c71838b
kakkilaya/JSON-indentor
/indentor.py
1,301
3.8125
4
#!/usr/bin/python2 #take the input file and open it into "text" with open("raw.txt") as input_file: text = input_file.read() #declare empty structires to hold data istack = [] str_length = 0 indent = 0 current_string = "" #remove all existing indentation, so that a common indentation rule #can be ...
3428ffa16d743a4c282336205e944e5d4973ade1
AnanthaVamshi/PySpark_Tutorials
/code/chap01/dataframe_creation_from_csv.py
3,529
4.3125
4
#!/usr/bin/python #----------------------------------------------------- # 1. Create a DataFrame from a CSV File # from Input as a CSV File of the # following format: # # <name><,><city><,><age> # # 2. Find average of age per city. #------------------------------------------------------ # Input Parameters: #...
eea014769cae2076ed03df55421127ff889a802a
AnanthaVamshi/PySpark_Tutorials
/code/chap07/dataframe_drop_column.py
2,078
3.53125
4
#!/usr/bin/python #----------------------------------------------------- # Create a DataFrame and DROP a COLUMN # Input: NONE #------------------------------------------------------ # Input Parameters: # NONE #------------------------------------------------------- # @author Mahmoud Parsian #------------------------...
b8fdbfa602d0928217d6fa18a3dee3bdfaf6890d
AnanthaVamshi/PySpark_Tutorials
/code/chap02/word_count_driver_with_filter.py
2,672
4.21875
4
#!/usr/bin/python #----------------------------------------------------- # This is a word count in PySpark. # The goal is to show how "word count" works. # Here we write transformations in a shorthand! # # RULES: # # RULE-1: # Here I introduce the RDD.filter() transformation # to ignore the words if the...
a7ca48340cb0bfeb7113d7716c88e3c0425487c3
AnanthaVamshi/PySpark_Tutorials
/code/chap06/average_by_key_use_combinebykey.py
1,610
3.5
4
#!/usr/bin/python #----------------------------------------------------- # This program find average per key using # the combineByKey() transformation. #------------------------------------------------------ # Input Parameters: # none #------------------------------------------------------- # @author Mahmoud Parsia...
30bbe8835a444e3a1e4bec8185bf989672e6b639
AnanthaVamshi/PySpark_Tutorials
/code/chap07/dataframe_multi_dim_agg_rollup.py
7,811
4.25
4
#!/usr/bin/python #----------------------------------------------------- # Create a DataFrame and perform groupBy() and rollup() # Input: NONE #------------------------------------------------------ # Input Parameters: # NONE #------------------------------------------------------- # @author Mahmoud Parsian #-------...
56dca0edc3cac52b7af95a3be46a9ab638d594fe
AnanthaVamshi/PySpark_Tutorials
/code/chap07/dataframe_creation_add_columns.py
4,977
3.9375
4
#!/usr/bin/python #----------------------------------------------------- # Create a DataFrame and ADD NEW COLUMNS # Input: NONE #------------------------------------------------------ # Input Parameters: # NONE #------------------------------------------------------- # @author Mahmoud Parsian #---------------------...
e62e5b6568270ccb7ff4b961f09fdcde58eeb9bd
AnanthaVamshi/PySpark_Tutorials
/code/chap11/breadth_first_search_example.py
3,195
3.765625
4
#!/usr/bin/python #----------------------------------------------------- # This program # # 1. Builds a graph using GraphFrames package. # # 2. Applies Breadth First Search (BFS) algorithm. # Breadth-First Search (BFS) finds the shortest # path(s) from one vertex (or a set of vertices) # to another vertex (...
1ba18acd32a0b7b95fe64ef48beea7178a86b1f9
yeonjooyou/learn-python
/python-lab/lab08/compreLab4.py
460
3.5625
4
# 실습 9 import random random_list = [] while True : random_list.append(random.randint(0, 100)) if len(random_list) == 10 : break print(random_list) # 딕셔너리 생성 dict = {str(i) : 'pass' if random_list[i-1] >= 60 else 'nopass' for i in range(1, 11)} print(dict) # case 2 nums = [random.randint(1, 100) for ...
41a18dcff3a563e7b598a9f33239c5d7364f3b6a
yeonjooyou/learn-python
/python-lab/lab06/funcLab9.py
738
3.71875
4
# 함수명: sumEven1, 매개변수: 가변형, 리턴값: 1개 # 기능: 아규먼트가 몇 개가 전달되든 처리해야 한다. # 아규먼트는 1 이상의 숫자만 온다고 정한다. # 전달된 아규먼트들에서 짝수에 해당하는 숫자들만 합을 계산해서 리턴한다. # 전달된 아규먼트들 중에서 짝수가 없으면 0을 리턴한다. # 아규먼트가 전달되지 않으면 -1을 리턴한다. def sumEven1(*ints) : sum = 0 if not ints : return -1 else : for num in ...
d50a7b5147323dda969b783a0f898c29ed07f538
yeonjooyou/learn-python
/python-lab/lab07/dicLab2.py
535
3.609375
4
weather_dict = { '월' : (32, 24), '화': (33, 24), '수': (33, 25), '목': (33, 23), '금': (31, 23), '토': (31, 24), '일': (29, 24), } # 사용자에게 요일명 한 개를 입력받는다. day = input("> 요일명을 한글로 입력하세요 :") if day in weather_dict : print(day, '요일의 최저온도는', min(weather_dict[day]), '이고' '최고온도는'...
e40c75efa3a8bf5793f36f7dbdec2ba46dfdd29d
yeonjooyou/learn-python
/python-lab/lab06/listLab1.py
461
3.828125
4
# 10, 5, 7, 21, 4, 8, 18 로 구성되는 리스트를 생성하여 listnum에 저장한다. listnum = [10, 5, 7, 21, 4, 8, 18] # listnum에 저장된 값들 중에서 최댓값을 추출하여 출력한다. # 최대값을 구하는 기능은 함수를 사용하지 않고 제어문으로 직접 구현한다. max_value = listnum[0] for i in range(1, len(listnum)) : if max_value < listnum[i] : max_value = listnum[i] print('최댓값 :', max_value)
3e68f19aeda10ea6ee627505a92961a50e2f5074
yeonjooyou/learn-python
/python-lab/lab03/forLab2.py
98
3.5625
4
for i in range(0,5,1) : print(i) # 개행처리 ''' while i < 5 : print(i) i += 1 '''
d0c60faf89e252b65b21fc50345524c05569f75e
yeonjooyou/learn-python
/python-lab/lab07/listLab7.py
1,049
3.921875
4
list = [[10, 20, 30, 40, 50], [5, 10, 15], [11, 22, 33, 44], [9, 8, 7, 6, 5, 4, 3, 2, 13]] # 행단위 합을 구하여 출력한다. def sumRow(order) : sum = 0 for i in range(0, len(list[order])) : sum += list[order][i] print(order+1, '행의 합은', sum, '입니다.') for order in range(0...
2dda353a34103a358fb45c1aa0bc35a338d89b30
yeonjooyou/learn-python
/python-lab/lab05/funcLab3.py
1,142
3.609375
4
# 함수명: expr, 매개변수: 숫자 2개와 연산자 1개, 리턴값: 연산 결과 또는 None # 기능: 전달된 두 개의 숫자에 대해서 전달된 연산을 처리하고 그 결과를 리턴한다. # 연산자는 +,-,*,/ 만 처리하며 그 외의 연산자는 연산을 하지 않고 None 값을 리턴한다. def expr(a, b, operator) : if operator == '+' : return a + b elif operator == '-' : return a - b elif operator == '*' : r...
19e153a65bddd8a138c46c0fa395e2b3c131851a
yeonjooyou/learn-python
/python-lab/lab02/conditionLab3.py
433
3.765625
4
# 1. grade 라는 변수에 1부터 6사이의 숫자를 랜덤으로 추출하고 저장한다. import random # 모듈 grade = random.randint(1, 6) print(grade) #랜덤값을 확인하기 위한 출력문 # 조건 평가 시 and 연산자를 사용해서 해결한다. if grade>=1 and grade <= 3: print(grade, "학년은 저학년입니다.") else: # elif grade>=4 and grade<=6: print(grade, "학년은 고학년입니다.")
c989985dadc4267234e4b7d32c92a9817920c575
Ape12b/Intro-to-Algo-CLRS
/qiuck_sort.py
524
3.578125
4
def swap(i,j): return(j,i); def partition(A,p,r): x = A[r]; i = p-1; for j in range(p,r): if A[j] <= x: i = i+1; (A[i],A[j]) = swap(A[i],A[j]); (A[i+1],A[r]) = swap(A[i+1],A[r]); print A; return i+1; def quick_sort(A,p,r): if p < r : ...
fb56e28d7a0304b3e02873b2c3298857e7a48b34
thattazhi/Coding_Problems
/Python/Odd Numbers!.py
473
3.609375
4
import itertools def findMaxGoalsProbability(teamGoals): # Write your code here sums = [] for i, j in itertools.combinations(teamGoals, 2): sums.append(i+j) result = sums.count(max(sums)) / len(sums) print (result) print (sums) if len(str(result)) == 3: print (str(result) + "...
8d5e720c341af66a27d9c866cb5cf5515a5d538d
leachtucker/cs-unit-1-sprint-1-module-1-modules
/main.py
498
3.96875
4
""" Import the "math" module. Then, print an alphabetically sorted list of all the functions available in the "math" module that start with the letters "is". """ # YOUR CODE HERE import math def startsWithIs(string): try: if (string.index('is') == 0): return True else: return False except Value...
e208ac0c88a0deb679fe009b5dcc59b2b2e7413a
philip6560/Hacker-Rank-Challenges
/Fradulent Activity Notification.py
3,057
3.890625
4
days_count = int(input('Enter the number of days you want to monitor client"s transaction:')) transaction_data_set = [] data = 0 trailing_counter = int(input('Enter the days interval for trailing client"s expenditure:')) for x in range(days_count): data = input('Enter amount for day ' + str(x+1) + ':') transact...
0b36faadd749aae154b17521aea1482aca85f9ce
caiooliveirac/estudosemprograma-o
/brasileirao.py
424
4.03125
4
brasil = ('Fortaleza', 'Athletico-PR', 'Atlético-GO', 'Bahia', 'Red Bull Bragantino', 'Fluminense', 'Palmeiras', 'Flamengo', 'Atlético-MG','Corinthians','Ceará','Santos','Cuiabá','Sport','São Paulo','Juventude','Internacional','Grêmio','América-MG','Chapecoense') print(brasil[:5]) print(brasil[-4:]) a = sorted(brasil) ...
db1c477c3b77dd009fae66b653a20ecaddc6c663
jcalise/pwp-capstones
/TomeRater/TomeRater.py
6,581
4.1875
4
class User(): """ User class for TomeRater application, defines characteristics of the User and adds useful methods for working with Users """ def __init__(self, name, email): self.name = name self.email = email self.books = {} def get_email(self): """ Returns the User ...
05ffa5a522597169bb61d8c745538fd859e73c5c
yutachaan/img_processing
/neural_network_2/plot.py
378
3.734375
4
# 第一引数にエラー変移のファイルを指定 import sys import csv import matplotlib.pyplot as plt with open(sys.argv[1]) as f: reader = csv.reader(f) l = [row for row in reader] x = [float(row[0]) for row in l] y = [float(row[1]) for row in l] plt.plot(x, y, c='red', marker='x', markersize=3) plt.xlabel('Number of training') plt.ylabe...
ce3c436ac1f00021693d92b6ba314ee56f0449af
basu0001/first-pr-Hacktoberfest--2019
/codes/algorithms/matrix_chain_multiplication/python/MCM.py
1,105
4.09375
4
def matrix_chain_multiplication(dimensions): """ Implementation of matrix chain multiplication """ matrix = [[0 for _ in dimensions] for _ in dimensions] for j in range(2, len(dimensions)): for i in range(j - 1, 0, -1): if j == i + 1: matrix[i][j] = dimensions[i...
cd66256d452b443a687faab49484472176a55b3d
basu0001/first-pr-Hacktoberfest--2019
/codes/algorithms/bucket_sort/bucket_sort.py
1,106
3.9375
4
def bucketsort( A ): # get hash codes code = hashing( A ) buckets = [list() for _ in range( code[1] )] # distribute data into buckets: O(n) for i in A: x = re_hashing( i, code ) buck = buckets[x] buck.append( i ) # Sort each bucket: O(n). # I mentioned above that the worst case for bucket so...
b2a1519297c64e1f43931c17b7ddf7c9fd625d3c
N3CROM4NC3R/python_crash_course_exercises
/If_conditionals/alien-colors3.py
248
3.828125
4
alienColor = "red" if alienColor == "green": print("You did earn 5 points") elif alienColor == "yellow": print("You did earn 10 points") elif alienColor == "red": print("You earned 15 points") else: print("That alien no exists,lol")
0ceacfc9a01043c67e1b717c205fbaf9460d87c7
N3CROM4NC3R/python_crash_course_exercises
/dictionarys/cities.py
215
4.28125
4
cities = { "Valle de la Pascua" : "Venezuela", "New york" : "Unite States", "Atenas" : "Greek", "Tokyo" : "Japan" } for city,country in cities.items(): print("The city "+city+" is in "+country)
e8056918e1f3314049077ba85c6eb974ea3ed348
N3CROM4NC3R/python_crash_course_exercises
/dictionarys/pets.py
408
3.765625
4
pets = { "puddy" : { "kind" : "dog", "name" : "puddy" }, "pete" : { "kind" : "koala", "name" : "pete" }, "platon" : { "kind" : "monkey", "name" : "platon" } } for name,information in pets.items(): print("The information of the pet:",name,"is:")...
40c4b6404a407baccd99a1b2d8381efbe43525f2
N3CROM4NC3R/python_crash_course_exercises
/functions/t-shirt.py
188
4.1875
4
def makeShirt(name): size = input("Write your favorite size shirt:") print("Hello "+name+", the size of the shirt will be "+size) makeShirt("santiago") makeShirt(name = "santiago")
2ce3f475370790cd8abb306c705fb3966b4942fe
N3CROM4NC3R/python_crash_course_exercises
/my-ideas/math function/math-function.py
1,813
3.703125
4
file = open("math-function.txt","r") mathFunction = file.read() mathFunctionList = [] print(mathFunction) x = input("Insert x:") mathFunctionList = list(mathFunction) for n,i in enumerate(mathFunctionList): if i == 'x': mathFunctionList[n] = str(x) print(mathFunctionList) index = 0 # Potencias while ind...
96c5ab29276d6b5c1ed600ba4b76934d4b57afdd
N3CROM4NC3R/python_crash_course_exercises
/functions/magicians.py
162
3.953125
4
def show_magicians(names): for name in names: print("The magician name is: "+name) magicians = ["carlos","pedro","ignacio"] show_magicians(magicians)
aa60328ddf11240a19c9aa1360b49ae37777aee9
shreya-trivedi/PythonLearn
/q03lenght.py
515
4.21875
4
#!/usr/bin/python3.5 ''' Problem Statement Define a function that computes the length of a given list or string. (It is true that Python has the len() function built in, but writing it yourself is nevertheless a good exercise.) ''' import sys def get_lenght(word): ''' Function to get lenght of a string Args...
8508ac0c197dc0f2f596205b7bc256218d7f438d
ariesunique/python-shorts
/test_validator.py
1,710
3.53125
4
from validator import is_valid def test_null_or_empty_input(): assert is_valid("") == False assert is_valid(None) == False assert is_valid(" ") == False def test_no_tags(): assert is_valid("not valid") == False assert is_valid("This <is> not </is> valid") == False def test_tag_is_invalid(): assert...
0ba18330e73fe32e425038ee035ba2526eaddaf9
dislocated-averstra/baseRepo
/Python/Mazes/GameObject/player_zame.py
1,563
3.515625
4
import pygame class PlayerZame(pygame.sprite.Sprite): RED = (255, 0, 0) PLAYER_SIZE = 8 def __init__(self, x_position, y_position, size): pygame.sprite.Sprite.__init__(self, self.containers) self.image = pygame.Surface((self.PLAYER_SIZE, self.PLAYER_SIZE)) pygame.draw.circle(sel...
7d4e2bab2a3a29152086a7d6f5f8dcb408359166
Vuntsova/guess-the-word
/guess.py
347
4.03125
4
secret_word = "python" guess = "" num_guesses = 0 max_guesses = 3 out_of_limit = False while out_of_limit is False and secret_word != guess: guess = input('Guess the secret word: ') num_guesses += 1 if num_guesses == max_guesses: out_of_limit = True if out_of_limit is True: print('You Lost') ...
6e9b490d5d254f569c3ace7e5b166a97547e16c2
sbeechani/Competetive-Programming
/Competetive_Programming/Week1/Day3/isBalanced.py
628
3.71875
4
def is_balanced(root): if(root == None): return True nodes = [] depths = [] nodes.append((root,0)) while(len(nodes)>0): current,cdepth = nodes.pop() if(current.left == None and current.right == None): if(cdepth not in depths): depths.appe...
47ccda1f294db15f318fba98069eb0e3c39208f1
sbeechani/Competetive-Programming
/Competetive_Programming/Week2/Day2/bracketvalidator.py
1,266
3.859375
4
import unittest def is_valid(code): # Determine if the input code is valid validate = [] for i in code: if(i=='(' or i=='[' or i=='{'): validate.append(i) else: if(len(validate)>0): check = validate.pop() if(ord(i)-ord(c...
025019c5c30f8baab7aadde04c12883a38f23c37
llfwer/python
/other/类操作.py
354
3.953125
4
''' program: 类操作 version: python 3.5.3 time: 2017/11/14 author: rowe ''' class Test: def __init__(self, name, age): self.name = name self.age = age def show_name(self): print(self.name) def get_age(self): return self.age obj = Test('rowe', 31) obj.show_name() print('Age...
8460c7c47dae8b12a820a8b33ec9bc8f64fd4a88
shoyab/network
/substitution.py
234
3.78125
4
import string msg = raw_input("any string goes here") cypher = "" #creates a alphabet of lowercase ascii characters alphabet = string.ascii_lowercase for a in msg: cypher = cypher + chr(((ord(a) - 95) % 26) + 97) print cypher
1983bc1f4e45a5e89dc6fbc538a0a3b9ddc198de
JiWKim/Study
/170517_areAnagrams.py
1,029
4.0625
4
#p.194 ##q51 Anagrams def areAnagrams(string1, string2): string1=string1.upper() string2=string2.upper() string1_letters=list() for strings in string1: string1_letters.append(strings) string2_letters=list() for strings in string2: string2_let...