blob_id
stringlengths
40
40
repo_name
stringlengths
5
127
path
stringlengths
2
523
length_bytes
int64
22
3.06M
score
float64
3.5
5.34
int_score
int64
4
5
text
stringlengths
22
3.06M
110b21ff016ce740c38dadb6abed39073512636a
AAM77/100-days-of-code
/round 1 code/r1d17_files/sum_of_positive.py
733
3.859375
4
# Name: Sum of Positive # Difficulty: 8 kyu # --- sources --- # Website: CodeWars # URL: https://www.codewars.com/kata/sum-of-positive/train/ruby # # # ################## # # # Instructions # # # ################## # # # You get an array of numbers, return the sum of all of the positives...
8f8c22e7e83830b6435005278f83588a8940268b
SACHSTech/ics2o-cpt-2021-KevinWang11
/main.py
6,368
4.21875
4
""" ------------------------------------------------------------------------------- Name: main.py Purpose: A program that acts as a "computer kiosk" and allows the user to click on buttons to learn new things about computers. (CPT) Author: Wang.K Created: 03/22/2021 ----------------------------------------------...
a269a3b6e63f32563e5d9bad6a03b50137b1c949
reid24hrs/numbertheory
/numbertheory/congruences.py
255
3.703125
4
# program to explore congruence m = input("Enter number m: ") table = [[0 for x in range(m+1)] for y in range(m)] for i in range(m+1): print i+1, print for a in range(m): for k in range (m+1): # table[a][k]= a**k print a**(k+1)%m, print
c952e3c2fe8b03b0694059054204e3f5e275dbf4
Nazar4ick/Tic-Tac-Toe
/Trees/game.py
1,285
4.09375
4
from board import Board def main(): """ Controls the flow of the game """ game_board = Board() while True: try: row = int(input('In which row would you like to place ' 'x (write a number starting from 1): ')) col = int(input...
7e3abcb2610760112853644dc903bd3efb0adabb
laloluna14/bedu-data-01-20210206
/hm_02_tabla.py
179
4.03125
4
''' given a number show its Tabla de Multiplicar ''' number = int(input('Give me a number: ')) for i in range(1, 11): mult = number * i print(f'{number} X {i} = {mult}')
aeee165dc83d4576eb80089f658fe92f8da66ca0
ZeroRoyX/Object-Oriented-Programming---Platzi
/abstraccion.py
817
3.515625
4
class Washing_machine: def __init__(self): pass def wash(self, temperature = 'cold'): """Método público que se llama 'wash' y recibe una temperatura e internamente el método llamará a varios métodos privados, cosas que el usuario no le interesaría cómo funciona. """ ...
0c2e95d7e5e7e8dfacf7af70d03ad1b954af63af
Kaiarognaldsen/innlevering
/Oppgave-1.py
371
3.65625
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Mon Sep 24 14:38:56 2018 @author: kaiarognaldsen """ import math ioner = float(input("Hvor mange ioner per mol er det i løsningen din?")) pH = -math.log(ioner) if 0 <= pH < 7: print("Løsningen er sur.") elif pH == 7: print("Løsningen er nøytral...
fc3752a916579080049fedc033d90233eba0b98c
rr-y/Python-Learning
/linked_list.py
936
3.796875
4
'''Linked List Implementation in Python''' '''Node of the linked list''' class Node: def __init__(self, val): self.val = val self.next = None class LinkedList: def __init__(self): self.root = None def add_node(self, val): new_node = Node(val) if self.root ...
cd1f058045cc9414ca8d8f2d5ed0e7f0d4ef231d
suiody/Algorithms-and-Data-Structures
/Data Structures/Circular Linked List.py
1,248
4.125
4
""" * Author: Mohamed Marzouk * -------------------------------------- * Circular Linked List [Singly Circular] * -------------------------------------- * Time Complixty: * Search: O(N) * Insert at Head/Tail: O(1) * Insert at Pos: O(N) * Deletion Head/Tail: O(1) * Deletion [middle / pos]: O(N) * Spa...
0b3f91fc5e7ab0c4f8acae0284e3685ac643129d
asalpha/Text-Analysis
/summary extraction.py
1,343
3.515625
4
import csv import pandas as pd n = 1 def addindex(): global n n = n + 1 def extract_summary(product_name): w = open("FILEPATH", "w", encoding="utf8", newline = "") writer = csv.writer(w) f = open(file, encoding="utf8") reader = csv.reader(f) writer.writerows([["Index", "Incident Ticket Nu...
fa607bd48642fd47ded26f35790fe4b6d946ebd3
gespyrop/Python-Exercises
/ex7.py
488
3.90625
4
import datetime today = datetime.datetime.now() day = datetime.date(today.year + 1, 1, 1) daysOfTheWeek = ("Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday") s = 0 while day.year <= today.year + 10: day += datetime.timedelta(days = 1) if day.day == today.day and day.weekday() == t...
f25510ade5b395f723aeae70ab1f28b8427bbe24
geekhub-python/in-out-math-mdtehwgp
/apples.py
265
4.09375
4
#!/usr/bin/env python3 schoolboys = int(input('schoolboys count: ')) apples_count = int(input('how many apples: ')) div = apples_count//schoolboys apples_in_box = apples_count % schoolboys print('apples per schoolboy: ', div) print('apples left:', apples_in_box)
7e7e387ae8e27b92ffba9db1991aebe3b83c73a7
alreadytaken01/ICST231proj
/Work/person.py
748
3.84375
4
class Person: def __init__(self,firstname,lastname): self.firstname = firstname self.lastname = lastname def __str__(self): return "{},{}".format (self.firstname, self.lastname) self.lastname def eat(self,food): print("{} will eat {}".format(self.firstname, self.l...
dd644de064f7417ad667537f564b411ca651407a
LeroyChristopherDunn/StringKataPython
/tests/teststringcalculator.py
1,518
3.921875
4
import unittest from stringkata.stringcalculator import StringCalculator, IllegalArgumentError class StringCalculatorTest(unittest.TestCase): def setUp(self): self.calculator = StringCalculator() def test_hello_world(self): self.assertEqual("hello", "hello", "message not equal") def te...
911781009f0295ada6366563e7c9f23d76e39a31
nikhil1991-cloud/Galaxy-SED-Fitting-MCMC
/Generate_alphas.py
2,068
3.515625
4
import numpy as np def generate_alphas(A,y,Initial_a,Sigma_matrix,epochs): """Solves for z to the problem Az=y when uncertainties are present in both A and y. Input parameters: A: Array of shape (m,n) with m number of observations and n independent variables. y: Array of shape (m...
b7da9b32b8e24dbf342fdb31459216f31b9fbd02
Maxim687/Laboratory-work-04.10.21
/Untitled-1.py
478
3.796875
4
from statistics import mean a =int(input("Введите число a:")) b =int(input("Введите число b:")) e = a * b x = int(input("Введите число x:")) z = e ** x + x ** 0,5 print("z = " + str(z)) N = [-5,-3,-1,1,3,5,7,9] V = [1,3,5,7,9] avarage=mean(V) print("Найбільше число N:" + str(max (N))) print("Середнє арифмети...
06fed6e87d23c21a8969f21eaf55440d7ac282cb
AlexanderMattheis/bioinformatics-algorithms-in-python
/algorithms/backtracking/multi_table_backtracking.py
5,836
3.765625
4
from algorithms.backtracking.backtracking import Backtracking from data.alignment_output_data import AlignmentOutputData from maths.vector import Vector import system.string_symbols as strings class MultiTableBacktracking(Backtracking): MATRIX_LBL_MAIN = "S" MATRIX_LBL_HORIZONTAL_GAPS = "-Q" MA...
3f6e43bf6e3013b8d4f064303e020343cc29848f
AlexanderMattheis/bioinformatics-algorithms-in-python
/maths/cost_function.py
4,278
3.84375
4
from maths.matrix_reader import MatrixReader import maths.matrix_types as matrix_types import system.string_symbols as strings import system.words as words class CostFunction: """ Returns the cost for the alignment of two amino acids. """ A = "A" R = "R" N = "N" D = "D" ...
64885c2b72e27c8121516996b0052131c79aae01
WondarLock/python
/dz2.py
776
3.859375
4
# cars = ['mazda', 'citroen', 'bmw'] # cars.append('jigul') # cars.remove('jigul') # cars.sort() # cars.reverse() # print(cars) import random luckyNumber = random.randint(1, 100) print(luckyNumber) difficulty = int(input('Выбери количество попыток: ')) attempts = 1 userNumber = int(input('И ваша цифра: ')) while att...
10d8d5586a366c13449cb87b56563c98054f6deb
nikser86/Home_work_6
/HW_6_2.py
272
3.71875
4
inp_file = open("1.txt") li='' for line in inp_file: li = li + line.rstrip() + "!\n" print(line.rstrip() + "!",li) inp_file.close() with open("1.txt",'w') as out_file: out_file.write(li) with open("1.txt",'a') as out_file: print("Hello",file=out_file)
18877913baf943b05b1d4851731ae5ff614dffa9
code-fury/pyalgo
/pyalgo/serial_sort.py
3,895
3.96875
4
import copy def heap_sort(array, compare=lambda x, y: x > y): """ Best: O(n log n) Worst: O(n log n) Avg: O(n log n) @param array the array to be compare @param compare the comparing function @return the sorted array """ def heapify(a, idx, max_len): left = idx * 2 + 1 ...
7daa4d388c2730dfde80ebb44d344a96a0394cf3
Selina0210/Python-learning
/17 偏函数.py
588
3.703125
4
# 把字符串转化成十进制数字 int("12345") # 求八进制的字符串12345,表示成十进制的数字是多少 int("12345", base=8) # 求十六进制的字符串12345,表示成十进制的数字是多少 def int16(x, base=16): return int(x, base) int16("12345") ''' ### 偏函数 - 参数固定的函数,相当于一个有特定参数的函数体 - functools.partial的作用是,把一个函数某些参数固定,返回一个新函数 ''' import functools #实现上面int16的功能 int16 = fun...
9939f9731b893d874435406a2e80e3c6aad6dc42
ivan-ha/google-codejam
/src/2018/qualification/trouble-sort/app.py
758
3.609375
4
def processOne(): length = int(input()) values = [int(s) for s in input().split()] evenIndexList = [] oddIndexList = [] troubleSorted = [] # split list into 2 for i in range(length): if i % 2 == 0: evenIndexList.append(values[i]) else: oddIndexList.append(values[i]) # sort and merg...
0f2d989f1bef0eda54097e2e41ec5788af35c40a
gus-salazar/pythonTest
/usingPoints.py
271
3.734375
4
from Point import Point from Rectangle import Rectangle pointa=Point(10.0,5.0) pointb=Point(1.0,9.0) print "the distance of the point "+str(pointa)+" and ther point "+str(pointb)+" is:"+str(pointa.distance(pointb)) rectangle=Rectangle(pointa,pointb) print rectangle
69388645a5d516ab58c11c6e86b3da089e844f86
iviekht/Beetroot_HW
/1_5_1.py
196
3.9375
4
def stringManipulation(str): if len(str) < 2: return ' ' return str[0:2] + str[-2:] print(stringManipulation('helloworld')) print(stringManipulation('my')) print(stringManipulation('x'))
6bf1ac672f726b18f39e48037477bb16c0f010bd
preethika2308/code-kata
/strpal.py
67
3.515625
4
d=input() rd=d[::-1] if(d==rd): print("yes") else: print("no")
b6109a6be59d427dfaf8401790f3e3a108f2041b
preethika2308/code-kata
/splch.py
162
3.71875
4
input_string = input() cout = 0 for s in input_string: if s.isdigit() == False and s.isalpha() == False and s.isspace() == False: cout = cout + 1 print(cout)
4127119b93c76dc8044d4c5950164ce419eb06db
preethika2308/code-kata
/set102.py
53
3.515625
4
kj=int(input()) while(kj%2==0): kj=kj//2 print(kj)
fc051fa7a65ab225a072e762daa121c40a061873
preethika2308/code-kata
/ks12.py
142
3.609375
4
nu1=int(input()) nu2=0 array=input().split(" ") array.sort(reverse=True) for a in range(0,nu1): nu2*=10 nu2+=int(array[a]) print(nu2)
912874fb5344a6c3f7e12fa0f7bec146d2bec9ff
preethika2308/code-kata
/resultoddeven.py
101
3.828125
4
si,fi=input().split() si=int(si) fi=int(fi) a=si+fi if(a%2==0): print("even") else: print("odd")
8b2a2814e2c9155907fe4c7b06b330e59ab3611b
hannahduncan/python-challenge
/PyPoll/main.py
2,215
3.84375
4
#Import Dependencies import os import csv #Initialize variables totalVotes = 0 name = "" voteCount = 0 maxVoteCount = 0 votePercent = 0 winner = "" voteList = [] candidatesList = [] header = [] #Path for CSV csvPath = os.path.join("Resources/election_data.csv") #Open and read election data with open(csvPath) as c...
d35e775cc560686610e10cfbeff516917fa942dc
agf231/Blackjack
/blackjack.py
5,820
4.03125
4
# -*- coding: utf-8 -*- """ Created on Thu Jun 27 12:54:16 2019 @author: anfuente """ #Generate deck of cards #Deal cards #show dealt cards #Create starting amount of money, keep track of it #place/accept bets #allow for hit, split, stay, doubledown #play out dealer's hand #determine winner #add double opt...
289b9359f75aaf5d8e05692a0bdc789f89b39c71
zhgmen/Data-Structures-and-Algorithms-use-Python
/array_and_list(1).py
2,363
3.671875
4
class Array(object): def __init__(self,size): self.size = size self._items = [None] * size def __getitem__(self,index): return self._items[index] def __setitem__(self, index, value): self._items[index] = value def __len__(self): return len(self._items) def...
417e4e21e00e6bb15f06df0370e4e5d1e335bac9
nazousagimhou/Datacademy
/jan_ken_po.py
900
3.71875
4
opciones = ('piedra', 'papel','tijeras') jugada_j1 = input('Jugador 1, elige: piedra, papel o tijeras: ') jugada_j1.lower() j1 = 1 if jugada_j1 in str(opciones): j1 = opciones.index(jugada_j1)+1 #print(j1) else: raise NameError('Elige una opcion valida') jugada_j2 = input('Jugador 2, elige: piedra, pap...
16c3c7b2302a7fd892b67a00b09d41e058a3cff5
sula678/python-note
/basic/if-elif-else.py
233
4.125
4
if 3 > 5: print "Oh! 3 is bigger than 5!" elif 4 > 5: print "Oh! 4 is bigger than 5!" elif 5 > 5: print "Oh! 5 is bigger than 5!" elif 6 > 5: print "Of course, 6 is bigger than 5!" else: print "There is no case!"
8cb784b9efefb30c2b9db37e37e5132db8a087e2
bull313/PSSP
/test/pyparse_test25.py
304
3.546875
4
import sys import math import random import threading import time from functools import reduce age = 15 if age < 5: print("Stay Home") elif (age >= 5) and (age <= 6): print("Go to Kindergarten") elif (age > 6) and (age <= 17): print("Grade", (age - 5)) else: print("College")
7a1a0a4015349fe5ac0c0353a17cbcd520f553ab
AzNBagel/CS350HW2
/subarray_nsquare.py
2,437
3.828125
4
import random """ Andrew McCann Homework 2 Algorithms & Complexity CS350 """ NUM_ELEMENTS = 10 LOW_VAL = -10 HIGH_VAL = 10 array = [] for i in range(NUM_ELEMENTS): array.append(random.randint(LOW_VAL, HIGH_VAL)) print(array) def max_subarray(array): max_substring = LOW_VAL for i in range(len(array))...
516c20ae40e13be34ba6a100b10c748f326bd337
rseymour/eetrumpingsbot
/eeify.py
1,386
3.78125
4
import random text = "People don't know how great you are. People don't know how smart you are. These are the smart people. These are the smart people. These are really the smart people. And they never like to say it. But I say it. And I'm a smart person. These are the smart. We have the smartest people. We have the sm...
2d19853498f074493da505f690b5e21d82fed82b
fhavranek/python-course
/9/Matrix.py
2,241
3.609375
4
#! /usr/bin/env python3 import copy import sys class Matrix: def __init__(self, rows, columns): self.row_count = rows self.column_count = columns self.rows = {} self.columns = {} def check_index(self, row, column): if (row <= 0 or row > self.row_count or column <=0 or column > self.column_count): print...
e707b084c1932e484b5023eae4052fc606332c3c
mreboland/pythonListsLooped
/firstNumbers.py
878
4.78125
5
# Python's range() function makes it easy to generate a series of numbers for value in range(1, 5): # The below prints 1 to 4 because python starts at the first value you give it, and stops at the second value and does not include it. print(value) # To count to 5 for value in range(1, 6): print(value) ...
8a9b9a790d09aa9e7710b48b67575553224a497b
EvheniiTkachuk/Lessons
/Lesson24/task1.py
949
4.15625
4
# Write a program that reads in a sequence of characters and prints # them in reverse order, using your implementation of Stack. class MyStack: def __init__(self): self.array = [] def push(self, item): self.array.append(item) def pop(self): return self.array.pop() ...
f12695405b54a25339bbd9b7098502bee4bd0d42
EvheniiTkachuk/Lessons
/Lesson13/task3.py
965
4.46875
4
# Напишите функцию под названием `choose_func`, которая принимает список из числа и 2 # функции обратного вызова. Если все числа внутри списка положительны, выполнить # первую функцию в этом списке и вернуть ее результат. В противном случае вернуть результат второго def square_nums(nums): return [num ** 2 f...
d601ac0ac5939ebeab19c77e60f329742c309371
EvheniiTkachuk/Lessons
/Lesson8/task1.py
398
3.578125
4
def oops(list1): for i in range(0, len(list1) + 1): print(list1[i]) def oops(dict1): print(dict1[0]) list1 = [1, 2, 3, 4] try: oops(list1) except IndexError: print('IndexError') dict1 = {1: 'one', 2: 'two', 3: 'three'} try: oops(dict1) except KeyError: print('Ke...
d69a710becdd434773d15def23dbe71e3c426b75
EvheniiTkachuk/Lessons
/Lesson24/task3_2.py
1,856
4.125
4
# Extend the Queue to include a method called get_from_stack that # searches and returns an element e from a queue. Any other element must # remain in the queue respecting their order. Consider the case in which the element # is not found - raise ValueError with proper info Message class Queue: def __init_...
b587d2df6638affa6d7ad80c74127a8306551eb2
EvheniiTkachuk/Lessons
/Lesson23/task5.py
610
4.03125
4
############################################# # All tasks should be solved using recursion ############################################# def sum_of_digits(digit_string: str) -> int: if not digit_string.isdigit(): raise ValueError("input string must be digit string") elif len(digit_string) <= 1...
02ffe7089ad2b5c05246949bf9731c73130e3ebd
EvheniiTkachuk/Lessons
/Lesson24/task2.py
1,596
4.15625
4
# Write a program that reads in a sequence of characters, # and determines whether it's parentheses, braces, and curly brackets are "balanced." class MyStack: def __init__(self): self.array = [] def push(self, item): self.array.append(item) def pop(self): return sel...
7191a0743560cc83b9522c6fae2f5bdffb721bc0
EvheniiTkachuk/Lessons
/Lesson5/task1.py
460
4.125
4
# #The greatest number # Write a Python program to get the largest number from a list of random numbers with the length of 10 # Constraints: use only while loop and random module to generate numbers from random import randint as rand s = [] i = 1 while i <= 10: s.append(rand((10**9), (10**10) - 1)) ...
6a2360495a92274bc6e732fd890982bafd58381b
kookoowaa/Repository
/SNU/Python/Extrawork/Test.py
358
3.734375
4
import random ans1 = "go for it" ans2 = "no wat Jose" ans3 = 'Im not sure, ask me again' print('welcome to my magic ball') question = input('ask me for advice then press enter to shake me.\n') print('shaking...\n' *4) choice = random.randint(1,8) if choice ==1: answer = ans1 elif choice ==2: answer = ans2 e...
170e024bfc15c446e5627abb381465dd9de05c66
kookoowaa/Repository
/SNU/Python/Extrawork/function_times_table.py
185
4.03125
4
def times_table(n,num): num = int(input('which cal., would you like to have?')) n=1 while n < num: print(num, '*', n, '=', num * n) n += 1 times_table(5,6)
55062a569b72f7a94548b73ed83539de1c57adb0
kookoowaa/Repository
/SNU/Python/BigData_Programming/170619/Programming_1.py
537
4.1875
4
print('\nWelcome to Python Programming') #Greetings print('This is Your First Python Program\n') print('What is your name?') #Ask for your input name = input() print('Hi! ' + name) #compare this with the following line print('Hi!', name) print('The length of your name is:') print(len(name)) age = input (...
0aebd9d0c07ab57ec91e763efb77fa8c577b4f8c
kookoowaa/Repository
/SNU/Python/BigData_Programming/[TA3-1] source code/3-1-1.py
353
3.625
4
n = int(input()) integers = [int(i) for i in input().split()] m = int(input()) divisor_sum = 0 multiple_sum = 0 for i in integers: if m%i == 0: divisor_sum += i # 약수이면서 배수인 경우(i=m)도 있으므로 if문 두개를 활용한다 if i%m == 0: multiple_sum += i print(divisor_sum) print(multiple_sum)
3ff648273ff944d8371829ef9f515c2335e2f0bc
kookoowaa/Repository
/SNU/Python/BigData_Programming/hw3/test.py
1,018
4.0625
4
# Assignment Number..: 3 # Author.............: Park, Chanwoo # File name..........: hw3a.py # Written Date.......: 2017-06-28 # Program Description: input tester, conditional command # Create variable ID and assign name to it ID = 'Park Chanwoo' print('Q1 : ', ID) print() # Separate ID into two variables by an empty...
f377ea961c8752af2348750e12aa4bb82a97a935
kookoowaa/Repository
/SNU/Python/Extrawork/number_guess.py
920
3.65625
4
import random difficulty = input('1-3까지 난이도를 선택 해 주세요') if difficulty == '1': comp_pick = random.randint(1, 10) print('컴퓨터가 1에서 10사이의 수를 선택하였습니다.') elif difficulty == '2': comp_pick = random.randint(1, 50) print('컴퓨터가 1에서 50사이의 수를 선택하였습니다.') else: comp_pick = random.randint(1, 100) print('컴퓨터가...
9a9f02d7d36150749820c11ad1815e1939c21fad
kookoowaa/Repository
/SNU/Python/코딩의 기술/zip 활용 (병렬).py
774
4.34375
4
### 병렬에서 루프문 보다는 zip 활용 names = ['Cecilia', 'Lise', 'Marie'] letters = [len(n) for n in names] longest_name = None max_letters = 0 # 루프문 활용 for i in range(len(names)): count = letters[i] if count > max_letters: longest_name = names[i] max_letters = count print(longest_name) print(max_letters) #...
3542c95c808fdd945bf5b13920e594c5f8a203a2
kookoowaa/Repository
/SNU/Python/BigData_Programming/170623/t5.py
112
3.671875
4
found = False a = ['aa','ab','ac','ad','ae'] for x,y in enumerate(a): if y == 'ab': break print(x,y)
278891053f5e095c460288e2c85a583536b59ef9
kookoowaa/Repository
/SNU/Python/BigData_Programming/170623/t2(while).py
135
3.578125
4
l = "seoul" index = 0 while index < len(l): if l[index] == 'u': break index += 1 else: index = -1 print(index,'\n')
7d525b0746b09d8ffd61a0da77f985f2ee90b9d7
kookoowaa/Repository
/SNU/Python/BigData_Programming/hw5/hw5a.py
922
4.03125
4
# Assignment Number..: 5 # Author.............: Park, Chanwoo # File name..........: hw5a.py # Written Date.......: 2017-07-05 # Program Description: Using package and module # Q1: Printing current time using 'datetime' module import datetime now = datetime.datetime.now() # Retrieve local time from the computer prin...
85db2bc7815d8d9f3e19cfa170d5759fce0b6c74
fathanick/data-scrapper
/youtube-comments-scrapper-2.py
1,354
3.546875
4
#https://stackoverflow.com/questions/49907917/how-to-scrape-youtube-comments-using-beautifulsoup import time import pandas as pd from selenium.webdriver import Chrome from selenium.webdriver.common.by import By from selenium.webdriver.common.keys import Keys from selenium.webdriver.support.ui import WebDriverWait from ...
a240405826b5d53a72d0dcb138adf9efbce6c626
iriav3/csvPythonEdit
/splitGui.py
1,634
3.671875
4
#include these libraries import csv import sys from tkinter import * #function definition def split(): filename = file_name.get()+".csv" splitrow = row_number.get() org = open(filename) csv_org = csv.reader(org) headers = next(csv_org) #headerLabel = Label(mGui,text="Existing headers in file: \n"+str(hea...
5da0bc37a55cfe00cdd54776375611e24b5a71f9
hemu-codes/Class-Assignments---330
/AkkarajuHemantha_AS5.py
1,251
3.609375
4
# Author: Hemantha Akkaraju # Assignment: Image Processing with Vectors # import math from math import sin import sys sys.path.append('./Lib') from image_mat_util import file2image from image_mat_util import image2display from image_mat_util import image2file imgA = file2image("SourceImages/s1-256.png") imgB = file2i...
8c856b2303b58b47a61475df2074ffec932c8e62
reubenraff/Python-Projects-
/fortune_teller.py
873
4.03125
4
from random import randint def fortune_teller(): print("Please choose a color: red, blue, black, purple, orange or green") for turn in range(3): color = input("Enter a color: ") color_list = ["red", 'blue', 'black', 'purple', 'orange', 'green'] if color in color_list: ...
fb57296132ee3c28d5940f746bbc1496e566c946
nidhi988/THE-SPARK-FOUNDATION
/task3.py
2,329
4.34375
4
#!/usr/bin/env python # coding: utf-8 # # Task 3: Predicting optimum number of clusters and representing it visually. # ## Author: Nidhi Lohani # We are using Kmeans clustering algorithm to get clusters. This is unsupervised algorithm. K defines the number of pre defined clusters that need to be created in the proce...
6151bc6abf5df0469e51bfb1e5992d46d49675f7
the-tk-official/python-day-4
/Who's Paying.py
510
3.796875
4
import random test_seed = int(input('Create a seed number: ')) random.seed(test_seed) nameAsCSV = input("Give me everybody's names, seperated by coma. ") names = nameAsCSV.split(', ') # Get the total number of items in list. # num_item = len(names) # Generate random number between 0 and the last index. # random_cho...
8cc53c372c9fb7870284285a50e91f8d86e179d8
FrankRuns/Udacity
/Machine-Learning/DecisionTrees/treeMain.py
846
3.6875
4
#!/usr/bin/python """ lecture and example code for decision tree unit """ import sys from class_tree_vis import prettyPicture, output_image from prep_tree_terrain_data import makeTerrainData import matplotlib.pyplot as plt import numpy as np import pylab as pl from classifyDT import classify features_train, labels_...
65d2ba3d984567002d83f04bbf0fa42ded16a5bb
dineshneela/class-98
/file.py
678
4.125
4
# program to read and open a file. #>>> f= open("test.txt") #>>> f.read() #'test filllles' #>>> f= open("test.txt") #>>> filelines=f.readlines() #>>> for line in filelines: #... print(line) #... #test filllles. somettttthing else # program to split the words in a string. #>>> introstring="my name is Di...
d1927ec28e90fbb459ae6e8c130300851260c3ea
rabbitxyt/leetcode
/231_Power_of_Two.py
542
4.09375
4
# Given an integer, write a function to determine if it is a power of two. class Solution(object): def isPowerOfTwo(self, n): """ :type n: int :rtype: bool """ ans = False if n == 0: ans = False elif n == 1 or n == 2: ans = True ...
51529a20fd896ff2e1234d96654db4287b3d0fee
rabbitxyt/leetcode
/389_Find_the_Difference.py
673
3.546875
4
# Given two strings s and t which consist of only lowercase letters. # # String t is generated by random shuffling string s and then add one more letter at a random position. # # Find the letter that was added in t. class Solution(object): def findTheDifference(self, s, t): """ :type s: str ...
fd32771a179a7270543f7873456e6f090521443a
rabbitxyt/leetcode
/67_Add_Binary.py
391
3.765625
4
# Given two binary strings, return their sum (also a binary string). # # The input strings are both non-empty and contains only characters 1 or 0. class Solution: def addBinary(self, a, b): """ :type a: str :type b: str :rtype: str """ ab = int(a, 2) bb = i...
7d08735f35a767e09a808a5d89bf749d489b39a3
rabbitxyt/leetcode
/14_Longest_Common_Prefix.py
985
3.671875
4
# Write a function to find the longest common prefix string amongst an array of strings. # # If there is no common prefix, return an empty string "". class Solution: def longestCommonPrefix(self, strs): """ :type strs: List[str] :rtype: str """ op = '' if strs == [...
c399ef795ea999a7100eefd266b65ed635c9be39
rabbitxyt/leetcode
/496_Next_Greater_Element_I.py
861
3.625
4
# You are given two arrays (without duplicates) nums1 and nums2 where nums1’s elements # are subset of nums2. Find all the next greater numbers for nums1's elements in the # corresponding places of nums2. # # The Next Greater Number of a number x in nums1 is the first greater number to its # right in nums2. If it does ...
bb90b6ad8eba53c05db1fd1dcc7cafc57877ba36
sathyamahavishnu/sathya
/count.py
97
3.75
4
string="hello" c=0 for i in range(len(string)): if(string[i]!=' '): c=c+1 print (c)
7dc9b2750f11b787a74f0f301bd67bc9ab71be9a
sathyamahavishnu/sathya
/vowel.py
103
4.03125
4
x=('a' or 'e' or 'i' or 'o' or 'u') y='f' if(x!=y): print("Vowel") else: print("Consonant")
d553e9cd026a9d890d64c587b6e0840430ef0c65
sathyamahavishnu/sathya
/arraymax.py
185
4
4
def largest(arr,n): max=arr[0] for i in range(1, n): if arr[i]>max: max=arr[i] return max arr=[1,2,3,4,5] n=len(arr) lar=largest(arr,n) print(lar)
690f268dd3988e75b6900ce301fdbffd009bfbb0
Spagichman/Colab
/Lab 1 13.09.18/Lab SS.py
374
3.5625
4
# y = a*x**2 + b*x + c = 0 import turtle turtle.shape("turtle") turtle.pu() turtle.right(90) turtle.forward(300) turtle.right(90) turtle.forward(300) turtle.right(180) turtle.pd() turtle.forward(200) turtle.left(90) turtle.forward(200) turtle.left(90) turtle.forward(200) turtle.right(90) turtle.forward(200) turtle.rig...
f5d836faeb7a182452c82ab0422eb9ac80cfe2bc
rneher/augur
/augur/date_util.py
1,026
4.03125
4
import datetime def string_to_date(string): (y, m, d) = map(int, string.split('-')) return datetime.date(year=y, month=m, day=d) def year_difference(start_date, end_date): start_ord = start_date.toordinal() end_ord = end_date.toordinal() return (end_ord - start_ord) / 365.25 def year_delta(start_date, years): ...
af96297409b0bba95dc7d7f2aaf28ecca01eac34
AmiGandhi/leetcode
/438_FindAllAnagramsInString.py
1,693
4
4
# Given a string s and a non-empty string p, find all the start indices of p's anagrams in s. # Strings consists of lowercase English letters only and the length of both strings s and p will not be larger than 20,100. # The order of output does not matter. # Example 1: # Input: # s: "cbaebabacd" p: "abc" # Output:...
ba05816922d2efe7ea8869e7552c8325e95c7e19
AmiGandhi/leetcode
/918_MaximumSumCircularSubarray.py
1,850
3.546875
4
# Given a circular array C of integers represented by A, find the maximum possible sum of a non-empty subarray of C. # Here, a circular array means the end of the array connects to the beginning of the array. (Formally, C[i] = A[i] when 0 <= i < A.length, and C[i+A.length] = C[i] when i >= 0.) # Also, a subarray may...
98c95fbc1b33b4dcbf698054354e5ec5b3761265
AmiGandhi/leetcode
/1232_CheckIfItsAStraightLine.py
1,528
3.78125
4
# You are given an array coordinates, coordinates[i] = [x, y], where [x, y] represents the coordinate of a point. # Check if these points make a straight line in the XY plane. # Example 1: # Input: coordinates = [[1,2],[2,3],[3,4],[4,5],[5,6],[6,7]] # Output: true # Example 2: # Input: coordinates = [[1,1],[2,2],[3,...
51c0e203f0763232f661909f795173dd23388c54
alimony/spotify-long-tail
/spotify-long-tail.py
1,615
3.53125
4
#!/usr/bin/env python # encoding: utf-8 """ This script takes a list of artists as input (one artist per line) and searches for them on Spotify, determining how many of the given artists are available. Code by Markus Amalthea Magnuson <markus@polyscopic.works> """ import sys import time import urllib2 import spotime...
5caa2af465a72c24b4a595a00cf3b5f1b01f1761
becerratops/episode-guess
/episodeGuess.py
3,929
4.03125
4
# Rick and Morty episode guessing game # Author: Adam Becerra import random maxNum = 36 minNum = 1 # Rick's episode rickNum = random.randint(minNum, maxNum) def firstGuess(): """ This function handles morty's first guess """ # Take input, convert into an integer try: guess...
4705b6e2d83bd2581a92df4fd18538d4503a1d1d
ynandwan/misc-scripts
/misc-problems/median_of_two_sorted_arrays.py
3,895
4.25
4
""" Given two sorted arrays nums1 and nums2 of size m and n respectively, return the median of the two sorted arrays. The overall run time complexity should be O(log (m+n)). Example 1: Input: nums1 = [1,3], nums2 = [2] Output: 2.00000 Explanation: merged array = [1,2,3] and median is 2. Example 2: Input: nums1 ...
bff149e4e339bb9f5ddc86bc516e6ba6284811f4
devdave/txWeb
/txweb/http_codes.py
7,468
3.6875
4
""" Should be self-explanatory. These are used to bubble up various server conditions: errors, missing, I am a teapot , and 3xx redirect directives for the application to handle. `HTTPCode` is the base class for all over codes refer to https://en.wikipedia.org/wiki/List_of_HTTP_status_codes """ impor...
46d7b102e3f4452ad0b61951850aa4d34a75df5c
LabSis/HardwareCollector
/Cliente/Linux/componentes/procesador.py
1,784
3.578125
4
class Procesador(): def __init__(self): self.nombre = "" self.descripcion = "" self.tamanio_cache = "" #En KB self.arquitectura = "" self.cantidad_nucleos = 0 self.cantidad_procesadores = 0 self.fabricante = "" self.velocidad = "" # En...
80864e4b83f7fe6ab7a0685bcc6fd765e5634799
marcelosantos/python-basico
/modulo1.py
521
3.875
4
'''Arquivo de calculo''' def soma(a,b): '''Calcula a soma de dois numeros''' return a+b def somas(a,b,*numeros): '''Soma varios numeros passados''' n=a+b for i in numeros: n+=i return n def somat(*numeros): '''Soma varios de forma simples''' r = [ for n in numeros ] return r def diferenca(a,b): '''Calc...
3e3ec0072fc654028ac960ed9a426595d09f78cd
RossMedvid/Pythone_core_tasks
/HW_9_task_4.py
346
3.578125
4
class Person: def __init__(self,name,age): self.name=name self.age=age self.info=self.name+"s age is "+str(age) names=["john","matt","alex","cam"] ages=[16,25,57,39] for i in range(4): name,age=names[i],ages[i] person=Person(name,age) print(person.info, na...
dbf060462ed4cfd43cc5d0a3c00db3037327bee3
LucasDiasTavares/Python
/fizz.py
98
4.09375
4
num = int(input("Digite o numero: ")) if num%3==0: print("Fizz") else: print("",num)
04ca8aa522f31c988c0a62adb0fcbea6e96c12af
LucasDiasTavares/Python
/replace.py
163
3.578125
4
import sympy as sp x = sp.Symbol('x') texto = input("Digite: ") function = texto var = input("Digite2: ") texto2 = int((function.replace('x', var))) print(texto2)
bf7334ff2f473f62fe20e001ecb781580d7af70e
RashiniKaweesha/Repo-Excluded-From-HacktoberFest-2021
/codes/queueing-modelsim/Stochastic.py
7,991
3.75
4
from math import factorial EPS = 1e-9 # -------------------- -------------------- -------------------- -------------------- # class MM1: def __init__(self, _lambda, mu): # lambda : mean arrival rate self.__lambda = eval(_lambda) # mu : mean service rate self.__mu = eval(mu) ...
ff06290949e3e116af35fe5954fa557999823780
borjaguanchesicilia/TDA-Python
/ListaSimplementeEnlazada/test/testFinal.py
685
3.609375
4
import ListaEnlazada as l import Nodo as n listaSimple = l.ListaEnlazada() for i in range(5): aux = n.Nodo(i) listaSimple.insertarCabeza(aux) listaSimple.recorrerLista() listaSimple.queHayEnCabeza() listaSimple.extraerCabeza() listaSimple.recorrerLista() print("\nEl valor a buscar es el 20...") listaSimp...
ca5fb5a27eec7f47cc543cef4242f505a344b893
4LuckyMove/Education_Space_Lab
/Design Patterns/Structural/Structural_2_Bridge.py
1,566
3.578125
4
from abc import ABC, abstractmethod class Realization(ABC): @abstractmethod def name_realization(self): pass @abstractmethod def operation_realization(self): pass class PlatformA(Realization): def name_realization(self): return 'Платформа А' def operation_realizatio...
5684af965c04bea5991c42eaddb784a9de02d87a
PatKevorkian/Code-Examples
/LearnDataMine/GradientDesc/gradientDesc.py
1,776
3.546875
4
import matplotlib.pyplot as plt import numpy as np import random import math def gradientDescent(x, y, theta, alpha, m, numIterations): xTrans = x.transpose() prevCost = 0 for i in range(0, numIterations): hypothesis = np.dot(x, theta) loss = hypothesis - y # avg cost...
4164c00031be8c4f842ced5eebe83f3649763c13
apoorvamalemath/Coding-Practice
/0017_TreeTraversals.py
755
3.78125
4
def preOrder(root): if(root): print(root.info,end=" ") preOrder(root.left) preOrder(root.right) def inOrder(root): if(root): inOrder(root.left) print(root.info,end=" ") inOrder(root.right) def postOrder(root): if(root): postOrder(roo...
2679bc1730a8db3c767431e99212d6a040e88c88
apoorvamalemath/Coding-Practice
/0007_ Largest Fibonacci Subsequence.py
1,149
4.03125
4
""" Given an array with positive number the task to find the largest subsequence from array that contain elements which are Fibonacci numbers. Input: The first line of input contains an integer T denoting the no of test cases. Then T test cases follow. Each test case contains an integer N denoting the size of the arr...
99ccb896601bff8101aed883cd1a0166aa684de6
zinh/programming_exercises
/python/tree/same_tree.py
305
3.5
4
def is_same_tree(tree1, tree2): if tree1 is None or tree2 is None: if tree1 == tree2: return True else: return False if tree1.val == tree2.val: return is_same_tree(tree1.left, tree2.left) and is_same_tree(tree1.right, tree2.right) return False
ff391a6c97e96b953ed8511b4d754429111ef108
zinh/programming_exercises
/python/longest_substring.py
1,335
3.59375
4
from typing import Dict def longest_substringv1(s: str) -> int: pos : int = 0 max_len : int = 0 current_substring : list[str] = [] while True: if pos >= len(s): return max_len c = s[pos] try: idx = current_substring.index(c) current_substring ...
1a7c48054418adef604c72fa24c62904e6a41525
Oli-4ction/pythonprojects
/dectobinconv.py
556
4.15625
4
"""************************* Decimal to binary converter *************************""" #function def function(): #intialize variables number = 0 intermediateResult = 0 remainder = [] number = int(input("Enter your decimal number: ")) base = int(input("Choose the number format: ")) ...
916fbf51b9f9608026ceebaea2cbec2c7eabce64
matthewfollegot/advent-of-code-2020
/day1/day1.py
717
3.921875
4
def day1(): nums = set() with open('data.txt', 'r') as f: for line in f: num = int(line) conjugate = 2020 - num if conjugate in nums: print(f"found two nums sum to 2020, product is {num*conjugate}") return nums.add(num) day...
0dd74a0b8f012e364e1efe1d748279a2dc17ddcf
bmjoseph/NineCard
/scripts/strategies.py
18,267
3.515625
4
#---------------------------------------------------------- # Strategy functions and their associated helpers. #---------------------------------------------------------- import numpy as np import pandas as pd from gameLogic import * def sort_hand(hand): ''' This function takes in your hand and sort...
130bcbac66bd8b0479006d934ee36b3285b1af4d
thisis-vishal/carbash
/scoreboard.py
565
3.5
4
from turtle import Turtle FONT = ("Courier", 24, "normal") class Scoreboard(Turtle): def __init__(self): super().__init__() self.level=1 self.hideturtle() self.penup() self.goto(-270,250) self.updatelevel() def updatelevel(self): self.clear() s...
23bc57141a395db259fca23482e043d121bd47d1
marcopoloian/programacion
/medidas.py
408
3.921875
4
#Ian Marco Piñeros# m=input("escoja un numero") m=int(m) if m<1: print("no puede ser menor 0") 1h=3600s print(m) while (True): print("pul a cm") print("pul a km") print("cm a pul") print("cm a km") print("km a milla") print("milla a km") print("m/s a km/h") print("km/h a m/s...