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
af4bee1200ba30ae3e3b340eaf7e1c593d8d8092
tdominic1186/Python_Crash_Course
/Ch_7_User_Inputs_and_While_Loops/rental_car_7-1.py
215
3.671875
4
# -*- coding: utf-8 -*- """ Created on Wed Apr 25 21:47:59 2018 @author: ACANTAMA """ car = input("What kind of car would you like to rent? ") print("Let me see if we have " + car.title() + "s available to rent.")
7365837c6f9d799e7bd3c0be28ab02220b783271
tdominic1186/Python_Crash_Course
/Ch_5_if_Statements/ordinal_numbers_5-11.py
394
4.09375
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Fri Apr 13 18:31:20 2018 Ordinal numbers @author: Tony_MBP """ numbers = [1,2,3,4,5,6,7,8,9] for number in numbers: if number == 1: print(str(number) + 'st') elif number == 2: print(str(number) + 'nd') elif number == 3: ...
4d4a625594f83aa208935ed1d2b19995285e7cbc
tdominic1186/Python_Crash_Course
/Ch_8_Functions/t-shirt_8-3.py
461
3.546875
4
# -*- coding: utf-8 -*- """ Created on Mon May 14 16:45:43 2018 @author: ACANTAMA """ def make_shirt(size, message): """Prints size of shirt requested and message to be printed on shirt.""" print("The size shirt you requested is " + size.title() + ".") print("The message to be printed on the shirt is '" +...
65dd3baa758f67a3a983f786bc139dfae2ebf94e
tdominic1186/Python_Crash_Course
/Ch_6_Dictionaries/cities_6-11.py
1,045
3.859375
4
# -*- coding: utf-8 -*- """ Created on Wed Apr 25 19:33:42 2018 @author: ACANTAMA """ cities = { 'philadelphia': { 'country': 'united states', 'population': 1568000, 'fact': 'It is the home of the Super Bowl 52 Champion Philadelphia Eagles.', }, ...
d2e439558bdb9161e227cf58aed727d54e04b38e
tdominic1186/Python_Crash_Course
/ch_4_Working_with_Lists/summing_a_million_4-5.py
370
3.59375
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Sun Feb 11 16:34:52 2018 @author: Tony_MBP """ """ creates a list from one to one million, prints min, max, and sum. commented out processs to test one to two at a time. """ numbers = [] for value in range(1,100000001): numbers.append(value) #print(min(...
c51cdf1d0f6c21ad2a42e09233f03ad213329db1
suribes/AIND-Sudoku
/solution.py
7,525
3.765625
4
import logging from utils import * def eliminate_twins(values, unit, twin_boxes, twin_value): """ Eliminate twin values from boxes in the same unit. Args: values(dict): a dictionary of the form {'box_name': '123456789', ...} unit: Unit that has twin boxes twin_boxes: Boxes with twin...
620fe42e47a7290e72954bdf531df987b62441d8
Shiv751/tensorflow-learning
/Demo.py
1,314
3.875
4
import tensorflow as tf weight = tf.Variable([3.0], dtype='float64') bias = tf.Variable([6.7], dtype='float64') input_x = tf.placeholder(tf.float64) expected_y = tf.placeholder(tf.float64) linear_regression = weight*input_x + bias squared_error = tf.square(linear_regression - expected_y) loss_function = tf.reduce_mea...
697cef36ff8affc95804df93b918cbdcaf0cc143
poornapragnarao/ds_alg
/linkedlist.py
1,977
4.03125
4
class Element(object): def __init__(self, val=None): self.value = val self.next = None class LinkedList(object): def __init__(self, elem=None): self.head = elem def append(self, new_element): current = self.head if current: while current.next: ...
b7af4c39f58665c49404b3100b400bc14bd44e92
vidhikhathuria/MayLeetcodeChallenge
/leetcode0401.py
461
3.5625
4
# Problem Link: https://leetcode.com/problems/sort-characters-by-frequency/ class Solution: def frequencySort(self, s: str) -> str: d = defaultdict(list) for i in set(list(s)): st = '' n = s.count(i) for j in range(n): st += i d[n].app...
80370254271a0d1521a2b0cadc26beae2169c108
tmdemr/Portfolio
/Algorithm/Level2/전화번호 목록/solution.py
291
3.609375
4
def solution(phone_book) answer = True phone_book.sort() for i in range(1, len(phone_book)) len_text = len(phone_book[i-1]) print(phone_book[i][0:len_text]) if phone_book[i-1] == phone_book[i][0:len_text] return False return answer
c0d1fc3ec6b2423290c2d6d08ab35a49866cceb8
rdaldian/technical-assessment
/web-scrapping/Kompas-web-scraping-using-bs4.py
1,108
3.578125
4
# Web Scraping or Crowling Using Beautiful Soup # Importing the Libraries from bs4 import BeautifulSoup as soup from urllib.request import urlopen as uReq # Specifying the web address that we want to scrap url_source = 'http://kompas.com/' # Grabbing the page uClient = uReq(url_source) page_html = uClient...
cbc38a58be400e83c18324be9acba86971729545
vladn90/Data_Structures
/heaps/heap_sort_naive.py
797
4.15625
4
""" Naive implementation of heap sort algorithm using Min Heap data structure. """ import random from min_heap_class import MinHeap def heap_sort_naive(array): """ Sorts an array in non-descending order using heap. Doesn't return anything. Time complexity: O(n * lg(n)). Space complexity: O(n), n is len(array)...
a05f9a22236c6be513dc70b383fed528a066ffde
vladn90/Data_Structures
/trees/binary_search_trees/bst_class_test.py
2,334
4.09375
4
""" Testing binary_search_tree_class.py. """ import string import random from binary_search_tree_class import TreeNode, BinarySearchTree def inorder_traversal(bst): """ Returns a string of inorder key traversal of a binary search tree. """ result = [] for k in bst: result.append(k) return ...
e3c592db88be40b47bb98df79e43e8abb359b473
Bianca-Ana-Maria/Python-Project
/python-2.py
158
4.03125
4
while True: number = float(input('Enter a number: ')) if number < 0: break print('You entered: ', number) print("bia")
7c1249777a1cdf09f1da6fb492cc70e85d092ac0
AnjanaPradeepcs/guessmyno-game
/guessmyno.py
541
4.28125
4
import random number=random.randrange(1,10) guess=int(input("guess a number between 1 and 10)) while guess!= number: if guess>number: print("guess a lesser number.Try again") guess=int(input("guess a number between 1 and 10)) else: ...
1aa359451d1e739fc6956bcdba1edf71f71787a0
compsciencelab/pytorchrl
/pytorchrl/agent/env/env_wrappers.py
1,360
3.5
4
import gym from gym.spaces.box import Box class TransposeImage(gym.ObservationWrapper): """ When environment observations are images, this wrapper allows to transpose the axis. It is useful when the images have shape (W,H,C), as they can be transposed "on the fly" to (C,W,H) for PyTorch convolutions t...
ebd53257ff3a0c569c43ef1d335a10ef983371d1
Faraday1221/dividend
/read_file.py
887
3.515625
4
# -*- coding: utf-8 -*- """ Created on Mon Nov 23 23:54:56 2015 @author: jonbruno """ import os import csv # change to the directory where the csv is stored (assuming it is not part of # the path) file_dir = '/Users/jonbruno/Documents/Python/dividend' os.chdir(file_dir) # note this is just a test filename = 'BBEP Di...
d9c267eb0be84552434d656ad159db59f6a9c32d
Dhanyas12/630_PyWays_Dec_Jan
/Strings_In_Python.py
768
3.890625
4
#012345678910111213141516171819202122 -- Left to Right #-22............-2,-1 -- Right to Left str1='Welcome to Python Worl' print("String Special operators i.e. Concatination + :",str1) print(len(str1)) print("Left to Right Indexing",str1[0]) #slicing i.e. Slice- ginves the character from given inde...
3b977042f26e6c91f1ec2d5c2159d0ccb0e4f97b
NiallS4/CA117
/lab_2.2/beststudent_v3_022.py
630
3.59375
4
import sys def main(): try: highest = 0 file = sys.argv[1] with open(file, 'r') as f: students = f.readlines() for line in students: try: tokens = line.strip().split() tokens[1:] = [' '.join(tokens[1:])] mark = int(tokens[0]) if mark > highest: highest = mark name = tok...
f79e1e007fed67f324cad1da547da51bb8dc85ca
NiallS4/CA117
/lab_9.1/bankaccount_091.py
2,433
3.734375
4
class BankAccount(object): next_account_number = 16555232 account_type = 'General' def __init__(self, forename, surname, balance=0, account_number=0): self.forename = forename self.surname = surname self.balance = balance self.account_number = BankAccount.next_account_number BankAccount.next_account_numb...
1b16a049b0001cab1be568042afbb2af92d7737a
NiallS4/CA117
/lab_7.2/geometry_072.py
1,190
4.03125
4
from math import sqrt class Point(object): def __init__(self, x=0, y=0): self.x = x self.y = y def distance(self, other): return sqrt((other.x - self.x)**2 + (other.y - self.y)**2) def __str__(self): return '({:.1f}, {:.1f})'.format(self.x, self.y) class Segment(object): def __init__(self, p1=0, p2=0)...
2eadb5d5722e5b3fad0ac02194366c51583e9f4d
NiallS4/CA117
/lab_2.1/unique_count_021.py
313
3.609375
4
import sys def main(): unique = [] for line in sys.stdin: s = line.strip().lower() for letter in s: if not letter.isalnum(): s = s.replace(letter, ' ') words = s.split() for word in words: if word not in unique: unique.append(word) print(len(unique)) if __name__ == '__main__': main()
c7da52d263cd5e6433ebb2c4e0bdc4344b54a8e9
NiallS4/CA117
/lab_2.1/palindrome_021.py
262
3.734375
4
import sys def palindrome(s): s = s.strip().lower() for letter in s: if not letter.isalnum(): s = s.replace(letter, '') rev_s = s[::-1] return s == rev_s def main(): for line in sys.stdin: print(palindrome(line)) if __name__ == '__main__': main()
560a18ef01f976e336bf241aa6ae2073575a0adb
Superilosa/python-gr.19
/homework4.py
2,731
3.953125
4
import sqlite3 connection = sqlite3.connect('census.db') cursor = connection.cursor() def fill_in_density(province, population, area): cursor.execute(f"INSERT INTO density VALUES ('{province}', {population}, {area})") def print_rows(cursor, multiple): if multiple: for row in cursor.fetc...
08a1db0a5868e6408b10efa039083f401eac83df
lucascerdeira/Simple-Game-Python
/escolha-jogo.py
500
3.75
4
def lin(): print('-=' *27) lin() c = '' print(f'{c:^15}ESCOLHA UM JOGO E DIVIRTA-3SE') lin() print(f'{c:^15}[ 1 ] JOKENPô [ 2 ] ADVINHÇÃO [ 3 ] Par ou Impar') lin() choose = int(input('FAÇA SUA ESCOLHA: ')) while choose != 1 and choose != 2 and choose != 3: escolha = int(input('FAÇA SUA ESCOLHA: ')) if choose...
ac2656f69230d535c7c8fdb9bcd84bd55db10f5f
daigo0927/ctci-6th
/chap8/Q5_alt2.py
691
3.96875
4
def min_product(a, b): bigger = b if a < b else a smaller = a if a < b else b return min_product_helper(smaller, bigger) def min_product_helper(smaller, bigger): global counter if smaller == 0: return 0 elif smaller == 1: return bigger s = smaller>>1 half_prod = min_product_helper(...
798600e1fce50e9ae82b1ed602a72fb06d561dce
daigo0927/ctci-6th
/chap10/Q10.py
1,431
3.890625
4
class RankNode: def __init__(self, d): self.data = d self.left_size = 0 self.left = None self.right = None def insert(self, d): if d <= self.data: if self.left is not None: self.left.insert(d) else: self.left = Rank...
bde69bc931c8dc6c818f98a7888625fd4f807ce5
daigo0927/ctci-6th
/chap2/Q6.py
942
3.703125
4
import os, sys sys.path.append(os.pardir) from utils.linkedlist import LinkedList def is_palindrome(llist): # runner technique, method2 fast = llist.head slow = llist.head stack = [] while fast is not None and fast.next is not None: stack.append(slow.value) fast = fast.next.next ...
1d17f36dfe0cfccdbc375fec31bb8d6e940fc0d7
daigo0927/ctci-6th
/chap8/Q14.py
1,081
3.640625
4
COUNT = 0 def count_eval(s, result): global COUNT COUNT += 1 if len(s) == 0: return 0 if len(s) == 1: return 1 if bool(s) == result else 0 ways = 0 for i in range(1, len(s), 2): c = s[i] left = s[0:i] right = s[i+1:len(s)] left_true = count_eval(left, True) ...
e05420c216663c588db77b89800fc7d26b6d9ba1
simuusang/LeetCodeAnswers
/第2题 两数相加/Solution-1.py
1,182
3.5625
4
class Solution: def addTwoNumbers(self, l1, l2): """ :type l1: ListNode :type l2: ListNode :rtype: ListNode """ # 初始化进位默认为 0 carry = 0 # 初始化一个链表 res = cur = ListNode(0) # 当 l1 和 l2 两个链表中最后一个节点中 val 相加的值大于 10 时, carry == 1 需要再次进入循环 ...
26cdca7eb5c5406f57688de10a330500ea931826
JYlsc/leetcode
/code/easy/13.py
739
3.890625
4
#!/usr/bin/env python # -*- coding: utf-8 -*- # @Time : 2018/7/30 10:28 # @Author : Leishichi # @File : 13.py # @Software: PyCharm # @Tag: class Solution: def romanToInt(self, s): """ :type s: str :rtype: int """ dic = { "I": 1, "V": 5, ...
bc11a64fab70e83df8c6a0db8d0531643167473e
JYlsc/leetcode
/code/easy/20.py
518
3.5625
4
#!/usr/bin/env python # -*- coding: utf-8 -*- # @Time : 2018/7/30 11:39 # @Author : Leishichi # @File : 20.py # @Software: PyCharm # @Tag: class Solution: def isValid(self, s): """ :type s: str :rtype: bool """ dict = {'{': '}', '(': ')', '[': ']'} stack = [] ...
43c6a735d92f1bcee3381064c887b47f5fe79ff9
s4git21/PreCourse-2
/Exercise_2.py
1,434
4.0625
4
# Python program for implementation of Quicksort Sort # give you explanation for the approach ''' Approach: 1) Choose a pivot and swap elements of the array such that the elements to the left of the pivot are always lesser and the elements to the right of pivot are always greater than pivot. 2) At this point, the p...
ea31355d631151a6086ec2cdfff38b6134ec17f9
sainipradeep/coding-practice
/geeks for geeks/euler-circuit-and-path.py
1,014
3.53125
4
# User function Template for python3 def isEulerian(g, nv, ne): ''' g: dict of adjancey list, defaultdict(<class 'list'>) eg-: {0: [1, 2, 3], 1: [0, 2], 2: [0, 1], 3: [0, 4], 4: [3]} nv: num of vertices ne: num of edges return: 0/1/2 ''' # { # Driver Code Starts # Initial Template for P...
0457bf3d978193700a82429753ee79d6540efa25
sainipradeep/coding-practice
/leet code/132-pattern.py
394
3.515625
4
class Solution: def find132pattern(self, nums): st = float("-inf") stack = [] for i in range(len(nums)-1, -1, -1): if nums[i] < st: return 1 else: while len(stack) and nums[i] > stack[-1]: st = stack.pop() stack.append(nums[i]) return 0 if __name__ == ...
ea0942575cbfabca549f85be01eefef50d3f42c0
sainipradeep/coding-practice
/geeks for geeks/solve-the-sudoku.py
1,763
3.65625
4
def solveSudoku(sudoku): positions = [0, 0] if not getEmptyIndex(sudoku, positions): return 1 row = positions[0] col = positions[1] for i in range(1, 10): if try_to_place_a_number_at_position(sudoku, i, row, col): sudoku[row][col] = i if solveSudoku(sudoku): return 1 sudo...
44b91208fc62a8588e74de6b68c5fc450970c425
sainipradeep/coding-practice
/hackerRank/equal.py
385
3.5
4
#!/bin/python3 import math import os import random import re import sys # Complete the equal function below. def equal(arr): max = float('-inf') for i in arr: return arr if __name__ == '__main__': t = int(input()) for t_itr in range(t): n = int(input()) arr = list(map(int, input().rstr...
01a68dd9d0138a18e3246d51cd690db5d78c6154
qiaoyu-jzh/hello-world
/python/test6.py
409
4
4
#返回函数 def createCounter(): def f1(): n=1 while True: yield n n=n+1 it=f1() def f2(): return next(it) return f2 createA=createCounter() print(createA(),createA(),createA()) '''#当下一次调用时,变量值改变,可以使用 1.容器s[] 2.生成器 如上 3.nonlocal 关键词,可以改变 变量值 4.声明global。 '...
8aee1e37b8d65fb372d200a9fd173abc719d6443
gloriasalas/GWC-Summer-Immersion-Program
/TextAdventure.py
1,549
4.1875
4
start = '''You wake up one morning and find yourself in a big crisis. Trouble has arised and your worst fears have come true. Zoom is out to destroy the world for good. However, a castrophe has happened and now the love of your life is in danger. Which do you decide to save today?''' print(start) done = False ...
fdf7ed73792ba61111b58870b2f001991779d56b
allenling/my_leetcode
/easy_level/excel_sheet_column.py
443
3.671875
4
# coding=utf-8 ''' 26进制 n为长度 x1*26**(n-1) + x2*26**(n-2) + x3*26**(n-3) A=1 B=2 Z=26 AA=27 AB=28 AZ=42 BA=43 ''' def excel_columns(s): list_s = list(s) len_s = len(s) - 1 columns = 0 for ele in list_s: columns += (ord(ele) % 64) * 26 ** len_s len_s -= 1 return columns def main...
c10247219f445498dc8ad23bdecc8d5fa2e9b53e
alpernuage/Algorithme-Programmation-in-JS-TS-PHP-Python-exercices
/Boucles/TP4_6.py
208
3.859375
4
def sumArray(array) : i = 0; sum = 0; while (i < len(array)) : currentElement = array[i]; sum = sum + currentElement i+=1; print(sum); return sum; test = [12, 13, 14]; sumArray(test)
d1f27213261b635c1c42d20eeeeec2638e7a9683
NiekAukes/Informati.ca
/rondjesuiteinden.py
577
3.78125
4
word = input("Vul uw woord(en) in HOOFDLETTERS in a.u.b. \n\n\n(alvast bedankt)") rondjes = 0 uiteinden = 0 check = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" circle = [1, 2, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0] ends = [2, 0, 2, 0, 3, 3, 2, 4, 2, 2, 4, 2, 2, 2, 0, 1, 2, 2, 2, 3, 3, 2, 2,...
1916bd5cd1d12a2d844e8b7113b04d235af016fe
NiekAukes/Informati.ca
/slak en penis.py
297
3.65625
4
def telStrings(kString, gString): count = 0 for i in range(len(gString) - len(kString) + 1): if kString in gString[i:i+len(kString)]: count += 1 print("Item found") return "There were",count," times where the program found ",kString," in ",gString
400169da6a4eb8c6ae89295f5286a86ad25453f5
DavidFelipeCaicedo/Algoritmos-
/LavitaesREdura/main.py
896
3.78125
4
for i in range(int(input(""))): B, B2 = input("").split() if B == B2: gana = "¡Otra vez!" elif B == "piedra": if B2 == "tijera" or B2 == "lagarto": gana = B else: gana = B2 elif B == "papel": if B2 == "piedra" or B2 == "Holk": gana = B...
da750e3705b0fd59dea257da356662ddf4428074
qploma/12e
/6.py
1,594
3.515625
4
s = '*' + '123321' * 100 + '+' #задаем произвольную строку(работает действительно на любой) #фактически алгоритм работает так, что он как бы сортирует знаки, чтобы получилась #строка вида 1111...111*3333...333+22222.2222 while '21' in s or '31' in s or '23' in s : if '21' in s: s = s.replace('21', '12...
2840d3fd4ba1278b1fa31abf818b2dab02e1cb30
Raghual/Hackerank_Wipro_Talentnext_2020
/Day_2_solution_2(python).py
162
3.703125
4
str1=input() str1=str1.lower() str2=input() str2=str2.lower() a=str1+str2 p=sorted(a) r= [] [r.append(x) for x in p if x not in r] print(*r,sep="")
67049d96d0ae5cde08e52f2a8924fb818a81d695
lward27/Python_Programs
/wardlPS1.py
4,295
3.9375
4
################################################################# # # Author: Lucas Ward # Date: January 11th, 2008 # Program: Problem Set 1 # Program Name: wardlPS1.py # ################################################################# #precondition: x is is an integer #postcondition: returns Tru...
184375b7f74db4f34534b6a8c40eacb275dca647
lward27/Python_Programs
/shoe.py
652
3.703125
4
#class to represent a shoe of playing cards and manage deals from it. #this class depends on the class Card import random from Card import * class Shoe: def __init__(self, n = 1): random.seed self.cards = [Card(k%52) for k in range(0,52*n)] #put cards in and shuffle random.shuffle(self.cards) def deal(self, n...
de8b9c93aa7d88d00e0cc26fb9fa8dfb2e12b989
lward27/Python_Programs
/fracPart.py
342
3.8125
4
#prec: x is a number #postc: returns the fractional part of the number #example: fracPart(4.5) = .5, fracPart(-3.1) = .9 def fracPart(x): return 1 - (x%1) print "fracPart(5.5) = ", fracPart(5.5), "expected: .5" print "fracPart(56.78) = ", fracPart(56.78), "expected: .22" print "fracPart(-12.2) = ", fracPart(-12....
7d4cd8102b60ed63573d986578e58ccd445314ce
lward27/Python_Programs
/annaGrahm.py
581
3.734375
4
#prec: roast is a string #prec: bacon is a single character. #examples: #lard("moose", "z") -> ["zmoose", "mzoose, "mozose", # "moozse", "moosze", "moosez"] import sys def lard(roast, bacon): tally = [] k = 0 for k in range(len(roast)+1): tally.append(str(roast[0:k] + bacon + roast[k:])) return tally def jumble(w...
6335e8b9471041d03e975b1b20f098a964ed8f7b
lward27/Python_Programs
/findAllAs.py
536
3.765625
4
x = range(1,11) for k in x: print k, for k in []: print "foo" # find 1 + 4 + 9 + 16 + ... + 10000 total = 0 for k in range(1,101): total += k**2 print total ##find factorail(100) product = 1 for k in range(0,100): product *= k + 1 print product print x = ["aardvark", "platypus", "asp", "baboon"] ## find a li...
58578e34604e68fc5b8fd9315959316a62a94c21
lward27/Python_Programs
/echo.py
240
4.125
4
#prec: someString is a string #times is a integer #postc: #prints someString times times to the screen #if times <=0, nothing prints. def repeat(someString, times): if times <= 0: return print someString repeat(someString, times - 1)
791c1cdcf7d7c328a624dfa062b1b12f0ce38627
herry28/spiders
/testcase/add.py
309
3.59375
4
class Calc(): #加法函数 def add(self,a,b): c=a+b return c def jian(self,a,b): c=a-b return c if __name__ == '__main__': #创建对象 ca=Calc() res1=ca.add(3,4) res2=ca.jian(5,2) print(res1) print(res2) name="1" print(type(name))
70f397f6c15ad6fdba1206d26e21510376ca7cbd
herry28/spiders
/project/名片管理.py
2,039
3.890625
4
# #使用字典进行保存 # # all_dict={"小海":{"name":"小海","age":22},"小红":{"name":"小红","age":20}} # #准备一个空字典 # mydic={} # #添加名片 # mydic["小海"]={"name":"小海","age":22} # print(mydic) # #删除名片 # # del mydic["小海"] # # print(mydic) # #修改名片 # mydic["小海"]["age"]=25 # print(mydic) # #查询名片 # myname=mydic["小海"]["name"] # print(myname) #定义一个字典保存...
b6597e6adeda1b0490b1928dfa2dca94283e1ea5
Kratika1510/PythonAssignment
/python workshop/module3/validation_negative.py
366
3.859375
4
n=int(input("Enter no. of items:")) whole=0 for i in range(0,n): while(True): print("Enter price:",i+1) a=int(input()) if a > 0: whole=whole + a break else: pass retai...
c2378a22abd0c22397ea11efc201f88327d027b0
Kratika1510/PythonAssignment
/python workshop/module4/flatter.py
567
3.5
4
matrix=[[1,2,3],[4,5,6],[7,8,9]] flatten_matrix=[] for sublist in matrix: for val in sublist: flatten_matrix.append(val) print('flatter matrix:',flatten_matrix) #optimization fm=[val for sublist in matrix for val in sublist] print(fm) planets=[['Mercury','Venus','Earth'],['Mars','Jupite...
74af756eadb38c75d51e9e40788ceb75e9342296
bradlsum/AdvProgHW2
/Problem2_Python/Main.py
729
3.796875
4
class SalesPerson: def __init__(self): self.items = [] self.rate = .09 self.salary = 200 def add_item(self, item): self.items.append(1) self.items[len(self.items) - 1] = item def print(self): print("Item Code\tValue") for i in range(1, len(self.items...
dfc70a09089453790f8626e9a0cd4c575c3c3e26
aswin191993/ProbleSolving_with_Algorithms_and_Data_Structures
/listing/4.py
790
3.640625
4
class fraction: def __init__(self,num): self.n = num def __str__(self): return str(self.n) def __gt__(self,othr): if self.n > othr.n: return True else: return False def __ge__(self,othr): if self.n >= othr.n: return True ...
0bb5d1841cca056710535c34c3a56f28b32c0906
aswin191993/ProbleSolving_with_Algorithms_and_Data_Structures
/chapter6/4.py
512
3.640625
4
def tree(r): return [r,[],[]] def in_left(root,lval): if root[1] == []: root.pop(1) return root.insert(1,[lval,[],[]]) else: ne=root[1] return in_left(ne,lval) def in_right(root,rval): if root[2] == []: root.pop(2) return root.insert(2,[rval,[],[]]) else: new=root[2] return in_right(new,...
750cfcfb7c5184b1dfab705e8611787056d3c51e
toneypal/py_21
/les_1_4.py
511
3.75
4
# 4. Пользователь вводит целое положительное число. # Найдите самую большую цифру в числе. # Для решения используйте цикл while и арифметические операции. user_number = input("ВВедите целое положительное число - ") max = user_number[0] i = 0 while i < len(user_number): if user_number[i] > max: max = user...
4db80eecaf07ca7b1a570f626cb671fcde0bd1c9
erikson879/mattern
/mattern.py
1,141
3.75
4
#!/usr/bin/env python nroProcesos = raw_input("Ingresar la cantidad de procesos >> "); nroMensajes = raw_input("Ingresar la cantidad de mensajes >> "); p = {}; for j in range(0,int(nroProcesos),+1): v= []; for i in range(0,int(nroProcesos),+1): v.append(0); p['p' + str(j+1)]= v mensaje = 1; while in...
381ff8a8de799f78f6b872d36ab47c4f95ce820c
stupachek/discreteMath
/funk2.py
681
3.515625
4
import copy def product1(X, Y): Z = copy.deepcopy(X) for j in X: for i in Y: if j != i: Z.append(i) return Z def product2(X, Y): Z = list() for j in X: for i in Y: if j == i: Z.append(j) return Z def product3(X, Y): ...
c6399fabc80fb40e3b245b484e67d1f1c2455947
Amartinez93/prueba1
/gitprueba/calendar.py
734
3.5625
4
# coding=utf-8 import datetime ano_actual = str(datetime.date.today().year) mes_actual = str(datetime.date.today().month) dia_actual = str(datetime.date.today().day) ano_recor = str(datetime.date.today().year) mes_recor = str(datetime.date.today().month) dia_recor = str(datetime.date.today().day) def recordar()...
c031b23c4cf09bfff7309821f7a19dce8fd4d3c4
RomarioVice/Cross_Programming_first_lab
/11.py
506
3.703125
4
# -*- coding: utf-8 -*- arr = [] while True: try: N = int(input('\nEnter the Number: ')) if N > 0: break else: print ("\nSike! That's the Wrong Number!") except ValueError: print ("Wrong Number") for x in range(1,99): for y in range(1,99): ...
40fdcea45d17690719c706b1d2e26c572916dae9
RomarioVice/Cross_Programming_first_lab
/3.py
648
3.703125
4
dot = '.' mon = raw_input('\nEnter the Amount of Money! \n(format: xxx.xx)\n') #searching for the character '.' on the cut mstr md = mon.find(dot) print md if float(mon) > 0 and md == -1: print mon + ' rubles ' + ' 00 kopeks' quit() #searching for the value of rubles rub = mon[:md] print rub #searching for the ...
e7b8e12500e38486be6f85d02e0774c0c308d7b4
hichem-belhocine/Social-Media-Analytics
/Solution3/Task2.py
1,593
3.53125
4
import networkx as nx from collections import defaultdict #2-1 Complete the function def percolated_cliques(G, k): percGraph = nx.Graph() cliques_set = [frozenset(c) for c in nx.find_cliques(G) if len(c) >= k] #store all information of cliques in a clique set percGraph.add_nodes_fro...
95c56cb8a30db611dca15805817e78853f482db7
aharri71/hello-world
/Weather.py
616
3.546875
4
import re import urllib.request #http://www.weather-forecast.com/locations/Dublin/forecasts/latest try: city=input("Enter your city: ") url="http://www.weather-forecast.com/locations/" + city + "/forecasts/latest" data=urllib.request.urlopen(url).read() data1=data.decode("utf-8") ...
829d712718dd11c6d90100334ba81603cd5a96c7
kirberich/gerber_to_scad
/gerber_to_scad/vector.py
3,640
3.75
4
# Basic vector maths class import math class V(object): def __init__(self, x: float = 0, y: float = 0): self.x = float(x) self.y = float(y) def __unicode__(self): return "(%s, %s)" % (self.x, self.y) __repr__ = __unicode__ @classmethod def from_tuple(cls, coordinates): ...
f6c9d0c94a80bbaa9db1e9bedc041baf70c2f6fd
jjulch/cti110
/P4HW3_NestedLoops_JeremyJulch.py
356
4.3125
4
# Making Nested Loops # 10-17-2019 # CTI-110 PH4HW3-Nested Loops # Jeremy Julch # # Making the first loop for row in range(6): print('#', end='', sep='') # Making the nested loop to create the spaces between the # for spaces in range(row): print( ' ', end='', sep='') # Mak...
5b2f72364c25639b4c926c3f93a12616702aa825
Pallavi-Prakash-01/pythonBasic
/PracticeProblems/CompoundInterest.py
374
3.90625
4
#Python Program for compound interest (Amount = P(1 + R/100)^t CI = amount-principle amount) def ci(p,t,r): amount=p*(pow((1+r/100),t)) #amount = p*((1+r/100)**t) both statements are same return amount-p p=float(input("Enter principle amount : ")) t=float(input("Enter time : ")) r=float(input("Enter Raote of inter...
5278de96513b746d47360fdca0dd04d144916835
borekon/sgipeconverter
/main.py
4,406
3.640625
4
# -*- coding: utf-8 -*- # Source: https://www.datacamp.com/community/tutorials/python-excel-tutorial (no vale para excel viejos) # https://stackoverflow.com/questions/13437727/python-write-to-excel-spreadsheet (excel viejos) # https://blogs.harvard.edu/rprasad/2014/06/16/reading-excel-with-python-xlrd/ import os ...
9e07366c2b425fa3457978e7e1eca5d571ce2672
nonlining/Algorithms
/Heap and Priority Queues/job_queue.py
2,442
3.5625
4
# python2 from Queue import PriorityQueue class JobQueue: def read_data(self): self.num_workers, m = map(int, raw_input().split(' ')) self.jobs = [int(s) for s in raw_input().split(' ')] assert m == len(self.jobs) def write_response(self): for i in range(len(self.jobs)): ...
661abe7b0839a7b9531188ba9db975d2dc1e2103
nonlining/Algorithms
/Implementaions/Fibonacci Numbers/fibonacci_huge.py
1,126
3.703125
4
# Uses python2 import sys def get_fibonacci_huge2(n, m): v1, v2, v3 = 1, 1, 0 for rec in bin(n)[3:]: calc = (v2*v2) % m v1, v2, v3 = (v1*v1+calc) % m, ((v1+v3)*v2) % m, (calc+v3*v3) % m if rec == '1': v1, v2, v3 = (v1+v2) % m, v1, v2 return v2 def get_fibonacci_huge(n, m): i...
c0f4c7223a76b87ffcaafc899adbf436a8c5dd3a
nonlining/Algorithms
/Implementaions/Fibonacci Numbers/fibonacci_sum_last_digit.py
1,176
3.890625
4
# Uses python2 import math def fibonacci_naive(n): if n <= 1: return n previous = 0 current = 1 sum = 1 for _ in range(n - 1): previous, current = current, (previous + current)%10 return current def get_fibonacci_huge(n, m): if n <= 1: return n previo...
871754b9658755163c62cd6f2e86d113f65a9663
nonlining/Algorithms
/Graph/toposort.py
664
3.78125
4
#Uses python3 import sys def dfs(adj, used, order, x): if used[x] == 1: return used[x] = 1 for e in adj[x]: if used[e] == 0: dfs(adj, used, order, e) order.append(x) def toposort(adj): used = [0] * len(adj) order = [] for v in range(len(adj)): dfs(adj,...
5f72d361fa43bfd12190a82979f697f6c0c0a5be
Haruka0522/Small-Programs
/analyze_otoshidama/main.py
1,339
3.59375
4
import pandas as pd import matplotlib.pyplot as plt from sklearn import linear_model class OtoshidamaAnalyzer(): def __init__(self, data_path): self.df = pd.read_csv(data_path, encoding="UTF8") def linear_regression(self): clf = linear_model.LinearRegression() x = self.df.loc[:, ["age...
4d5d2b731f38b324cc3c4c1722f298881af8bcf9
giserh/taxisim
/routing/BiDirectionalSearch.py
21,884
3.5
4
from Node import * #from Map import Map from Queue import PriorityQueue from random import randint from datetime import datetime HEURISTIC_DISCOUNT = .8 # Uses bidirectional search to find the shortest path between start_node and end_node # Params: # start_node - the node at the beginning of the path # end_node - th...
3265e0a3f7f5debc2aa77744ca65b141692b292d
shykes/dotcloud-sandbox
/sandbox/utils.py
348
3.546875
4
# -*- coding: utf-8 -*- def bytes_to_human(value): bytes_to_human = ( (1024**4, "T"), (1024**3, "G"), (1024**2, "M"), (1024, "K"), (1, "B") ) for factor, suffix in bytes_to_human: if abs(value) >= factor: value /= factor break retu...
cca4946713e0ce29cfe31fc99378f04f4166fbc8
LBFing/Server
/study/python/list.py
667
4.03125
4
#!/usr/bin/python # -*- coding: UTF-8 -*- #三种遍历列表里面序号和值的方法 list = ['html', 'js', 'css', 'python'] # 方法1 print '遍历列表方法1:' for i in list: print ("序号:%s 值:%s" % (list.index(i), i)) print '\n遍历列表方法2:' # 方法2 for i in range(len(list)): print ("序号:%s 值:%s" % (i, list[i])) # 方法3 print '\n遍历列表方法3:' for i, val in enume...
c58b4c9833b3343b96ec00ba44b48669598cd851
LBFing/Server
/study/python/23.py
209
3.6875
4
#!/usr/bin/python # -*- coding: UTF-8 -*- line = 20 for i in range(1,line + 1): print(' ' * (line - i),"*" *(2*i-1)) for i in range(line - 1,0, -1): print(' ' * (line - i), "*" * (2 * i - 1))
a7170021ce22292a241dfe1a3ec691bedc8ca7af
LBFing/Server
/study/python/1.py
384
3.609375
4
#!/usr/bin/python # -*- coding: UTF-8 -*- #有四个数字:1、2、3、4,能组成多少个互不相同且无重复数字的三位数?各是多少? d = [] for i in range (1,5): for j in range(1,5): for k in range(1,5): if i != j and i != k and j != k: print i,j,k d.append([i,j,k]) print "总数量:", len(d) print d
e9dad0a5ad0e9960d28f1b1f7e7149ba6f2fe4cc
GrindelfP/preparing_to_exam
/task_17/17_03_10_1.py
1,516
3.578125
4
count = 0 max_fitting = 0 def first_check(number) -> bool: first_digit = int(str(number)[0]) second_digit = int(str(number)[1]) third_digit = int(str(number)[2]) forth_digit = int(str(number)[3]) if first_digit > second_digit and first_digit > third_digit and first_digit > forth_digit: fir...
f4193bd174fbf3616027123502b9d3f15d988021
GrindelfP/preparing_to_exam
/task_16/16_03_28.py
384
3.796875
4
# F(n) = 1, при n £ 1, # # F(n) = 3 + F(n / 2 – 1), когда n > 1 и чётное, # # F(n) = n + F(n + 2) , когда n > 1 и нечётное. def F(n): if n <= 1: return 1 elif n > 1 and n % 2 == 0: return 3 + F(n / 2 - 1) elif n > 1 and n % 2 == 1: return n + F(n + 2) for n in range(1, 1000): ...
6c6938906f3a885acf92a5cf1471385e47df6e1a
GrindelfP/preparing_to_exam
/task_16/16_06_09.py
680
3.671875
4
def f(n): if n == 0: return 0 elif n % 2 == 0 and n > 0: return f(n / 2) elif n % 2 != 0: return 1 + f(n - 1) counter = 0 for n in range(1, 1001): if f(n) == 3: counter = counter + 1 print(counter) """Алгоритм вычисления значения функции F(n), где n – целое неотрицат...
4252294e1c18b09ec087e2c02099f1c46e0f2b8d
GrindelfP/preparing_to_exam
/task_12/12_05_11.py
790
3.96875
4
string = "1"*81 while "1111" in string or "88888" in string: if "1111" in string: string = string.replace("1111", "888", 1) else: string = string.replace("88888", "888", 1) print(string) # Какая строка получится в результате применения приведённой ниже # программы к строке, состоящей из 81 ид...
eb1262b84d9c5cddf42cf6c9c09636ee996685d4
iRodrigoAF/edutech-pr
/salario.py
1,065
3.953125
4
100 salario = int(input('Qual é o seu salário')) if(salario<280 or salario == 280): valorSalarioAnterior = salario resultado = salario + (salario * 0.20) print("Salario pos reajuste", resultado) print("Salario antes do reajuste", valorSalarioAnterior) print("Aumento de 20%") elif(sa...
1350645b34762317555b3d23f3030e4f08849bcb
EroshenkoD/Project_Eilera
/task_5.py
477
3.625
4
""" 2520 - это наименьшее число, которое можно разделить на каждое из чисел от 1 до 10 без остатка. Какое наименьшее положительное число равномерно делится на все числа от 1 до 20? """ a = 24504480 while a != 0: a += 10 print(a) for i in range(1, 20): if a % i: break else: ...
f4bdabccbeff0e740d8abe41caf9169434e6780f
alicecoal/Python_Lab1
/ForDockerWork/app/main.py
126
3.609375
4
# This is a sample Python script. s = "AbCdEfGhE" t = s.swapcase() print(s, " ", t) #s = input() #t = s.swapcase() #print(t)
94f5cc047100a398005f3de7644f30885d170c32
cliffjsgit/chapter-10
/exercise104.py
529
3.75
4
#!/usr/bin/env python3 __author__ = "Your Name" ############################################################################### # # Exercise 10.4 # # # Grading Guidelines: # - No answer variable is needed. Grading script will call function. # - Function "chop" should remove first and last element in-place. # # 1. Wr...
e37676e882c196756d7af562c25b8fcb53643f0b
cliffjsgit/chapter-10
/exercise108.py
795
4.15625
4
#!/usr/bin/env python3 __author__ = "Your Name" ############################################################################### # # Exercise 10.8 # # # Grading Guidelines: # - Variable "answer" should be the answer to question 1: If there are 23 # students in your class, what are the chances that two of you have the...
7307922e06308c47ed202e52c9aa779a2a491160
kazhirota7/Graph-based-wSTLNN
/wGSTLNN/wGSTLNN/DistanceCalc.py
455
3.53125
4
from math import sin, cos, sqrt, atan2, radians def latLongDist(lat1, long1, lat2, long2): # approximate radius of earth in km R = 6373.0 lat1 = radians(lat1) long1 = radians(long1) lat2 = radians(lat2) long2 = radians(long2) dlong = long2 - long1 dlat = lat2 - lat1 a = sin(dlat...
5d7b4287bf5a429420c7c0dab501c68107fad982
kairos9000/csv-File-Importer
/src/reader.py
28,863
3.703125
4
# -*- coding: utf-8 -*-# import pandas as pd import csv import re from pathlib import Path from chardet import detect from math import log, ceil, floor import reader_support_file as rsf import lxml.etree from lxml import etree import xml.etree.ElementTree as ET class reader(): """The class reader converts csv a...
e1e067a65945456b5dbde8d38554af7eea4c1121
amick/pyMaze
/pyMaze.py
439
3.765625
4
from __future__ import print_function print('Welcome to PyMaze') # Setup an x by y 2D array full of walls (+) col = 5 row = 4 mz = [["#"] * col for i in range(row)] print("mz = %r" % mz) # set the open path mz[0][1] = " " mz[1][1] = " " mz[1][2] = " " mz[2][2] = " " mz[2][3] = " " mz[3][3] = " " # print the maze fo...
81d6f7aa6ea0d7e0e4b1f53b986e68fc961d0903
babuhacker/python_toturial
/practice_test/square_root.py
153
3.953125
4
def square(i): return i * i while True: input_variable = int(input("please enter a number to find square=")) print(square(input_variable))
5dbe2a4b8ff9eb3db18c2031b4205362b7164b18
babuhacker/python_toturial
/Variables/Variables.py
769
4.15625
4
# Global Variables PI = 3.4 # print(PI) # one = 1 # two = 2 # three = 3 one, two, three = 1, 2, 3 # print(one) # print(two) # print(three) two = 4 # print(two) # print(one) Decimal = 1.1 # print(Decimal) StringVar = "Hello" + "1" # print(StringVar) def FunctionName(): newVar = "World" # print(newVar) ...
536dfea7f6f6de219f64ce5876dec29a607496d9
babuhacker/python_toturial
/hacker_rank/The-Minion-Game.py
443
3.640625
4
def minion_game(string): # your code goes here s = len(string) con, vow = 0, 0 for i in range(s): if string[i] in 'AIEOU': vow = vow + (s - i) else: con = con + (s - i) if con > vow: print("Stuart {}".format(con)) elif con == vow: print...
198c4494fd4d84366a1196486eae3a124af52100
babuhacker/python_toturial
/Functions/functions.py
680
3.875
4
'''A function is a block of organized, reusable code that is used to perform a single, related action. As you already know, Python gives you many built-in functions like print(), etc. but you can also create your own functions.''' # def FunctionName(Input): # Action # return Output def addone(Number): ...
8405e87129c3c391177e8dfdfe07b775a60358ec
babuhacker/python_toturial
/hacker_rank/loops.py
764
3.625
4
# # for i in range(5): # # print(i * i) # # # # for i in range(1,4): # # print(i) # # num = int(input("Please enter number: ")) # for i in range(1, num+1): # print(i,end='') # # # n = int(input()) # d = int(input()) # c = int(input()) # b = int(input()) # a = int(input()) # # scores = [n, d, c, b, a] # pri...
d31acc894aea469de64fb4b712c70cd5ad999c18
babuhacker/python_toturial
/hacker_rank/Piling Up!.py
829
3.6875
4
from collections import deque t = int(input()) while t > 0: n = int(input()) # q value A = list(map(int, input().split())) # list of q value lst = deque(A) # pass this list to the deque rm = lst.pop() # The right most element lm = lst.popleft() # The left most element csv = lm if lm > rm e...
f554e0ecc6f6ba3714b349e8a026f061b014e0fe
babuhacker/python_toturial
/hack/hack.py
131
4
4
n = int(input()) if n % 3 == 0: print("-1") if n % 3 == 0: if n % 2 == 0: print("1") else: print("0")