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
bd98dd6e684213e86da1292132c6f2d893140aaf
Dirac26/ProjectEuler
/problem003/main.py
404
4.09375
4
def largest_prime(input_num): """returns the largest prime factor of a num""" largest = None num = input_num n = 2 while n ** 2 <= input_num: while num % n == 0: num = num / n largest = n n += 1 if largest is None: return input_num return largest def m...
e0dbeb7cbd47525ba55470b51c4d192bd5850c66
Manith2000/Algorithms-Data-Structures
/Selection_sort.py
266
4.03125
4
# Selection Sort Algorithm def selectsort(arr): sorted = [] for i in range(len(arr)): #iterate through unsorted part sorted += [min(arr)] arr.remove(min(arr)) return sorted arr = [4,5,1,6,2,2,5,5,3,3,6] print(selectsort(arr))
9eef6495cc38787fc0a33bdad390beead0225b0b
Manith2000/Algorithms-Data-Structures
/Validparantheses.py
479
4.09375
4
def valid(s): valid = True if len(s)%2 != 0: #since pairs of brackets required to be valid. if odd its definitely invalid valid = False return valid for i in range(1,len(s),2): #iterate every potential pair if (s[i-1] == '(' and s[i] != ')') or (s[i-1] == '{' and s[i] != '}')...
774edd572b1497b9a8bc9e1c0f6107147626f276
max-moazzam/pythonCoderbyte
/FirstFactorial.py
541
4.1875
4
#Function takes in a number as a parameter and returns the factorial of that number def FirstFactorial(num): #Converts parameter into an integer num = int(num) #Creates a factorial variable that will be returned factorial = 1 #While loop will keep multipying a number to the number 1 less than it until 1 is ...
9cf1d6c76dae5fe761608b5866774e72105f01b8
Botany-Downs-Secondary-College/mathquiz-patchigalla
/5CheckEntries.py
6,032
3.765625
4
#Creates GUI with classes, generates questions from Random #sprint4.py #P.Patchigalla Feb from tkinter import * #imports all modules of tool kit interface (Tkinter), * is called wildcard from random import * class MathQuiz: #OOP will have classes and funtions will be part of classes #Keep your widgets ...
be2a0036b02452fc09c836750e0e21de5d442c8f
KubilayGazioglu/Codility
/TimeComplexity[FrogJump].py
242
3.515625
4
def solution(X, Y, D): #X start point #Y Destination point #D step size totalDistance = Y-X if totalDistance % D == 0: return totalDistance//D else: return totalDistance//D + 1 solution(1,1,3)
c5ce2fe9720ec9d91c58c65dde28af75b1d04e80
calt-laboratory/biological_sequence_analyzer
/biological_seq_analyzer.py
5,535
3.578125
4
##### Class for basic DNA sequence analysis ##### Author: Christoph Alt # Import modules import random from collections import Counter from typing import Dict, Union import matplotlib.pyplot as plt # Import files from biological_seq_dictionaries import * class BioSeqAnalyzer: """ Class for analyzing biologi...
ca70bcf88e4c34a54babd0e94ca8e77e9fe17f0b
laufergall/pythonsql_workshop
/scripts/utils_sqlite.py
1,588
4.09375
4
""" This file contains utilities for sqlite data access. """ import sqlite3 from typing import List, Tuple def create_connection(db_file): """ create a database connection to the SQLite database specified by db_file :param db_file: database file :return: Connection object or None """ conn...
d66acd385a21c664082d543f6ae4c9d5bde0ec5b
Baymax15/2048_game
/main.clean.py
3,923
3.515625
4
import random as r class board: def __init__(self, size, data=False): self.size = size self.data = [] if data: for x in data: self.data.append(x[:]) else: for _ in range(size): self.data.append([0] * size) def copy(self):...
e1b06441f9f3d9175ae5dd4d9d05737916e87a99
jelockro/launchcode-101
/goMike.py
1,599
3.84375
4
from turtle import Turtle from turtle import Screen import sys sys.setExecutionLimit(65000) class Mike(Turtle): firstname = 'Mike' def __init__(self, color, speed): Turtle.__init__(self) self.shellcolor = color self.color(color) self.speed(speed) def drawAndBack(self, len...
5db18fbb18655ab731866be1bb25a2289a419a5b
DrakeAlia/Graphs
/projects/ancestor/ancestor.py
4,231
4.03125
4
# Suppose we have some input data describing a graph of relationships between parents and children over multiple generations. # The data is formatted as a list of (parent, child) pairs, where each individual is assigned a unique integer identifier. # Write a function that, given the dataset and the ID of an individua...
724ff0664010a44373974733c5bb6732162ff64e
vivek7325/rks369.github.io
/Python/jarvis.py
2,353
3.65625
4
import pyttsx3 import datetime import pywhatkit as kitty import speech_recognition as kan import wikipedia import webbrowser jarvis = pyttsx3.init('sapi5') voices = jarvis.getProperty('voices') jarvis.setProperty('voice', voices[1].id) def speak(audio): jarvis.say(audio) jarvis.runAndWait() # ...
3834f47fb00e27ecde0db448201e192c22c2b4f6
indeyo/PythonStudy
/liaoxuefengLessons/FunctionalProgramming/map&reduce.py
2,199
3.765625
4
#-*- coding: utf-8 -*- """ @Project : StudyPython0-100 @File : map&reduce.py @Time : 2019-07-11 08:40:54 @Author : indeyo_lin @Version : @Remark : """ """ 练习题1 利用map()函数,把用户输入的不规范的英文名字,变为首字母大写,其他小写的规范名字。 输入:['adam', 'LISA', 'barT'],输出:['Adam', 'Lisa', 'Bart'] """ # def normalize(name): # index = 1 # ...
0a89bb2394039f7265facd42d4e2d58216b60d7d
indeyo/PythonStudy
/algorithm/most_item_in_list.py
739
4.0625
4
# !/usr/bin/env python3 # -*- coding: utf-8 -*- """ # @Author : indeyo_lin # @Time : 2020/6/5 11:01 下午 # @File : most_item_in_list.py """ def get_most_in_list(arr: list): """ 富途笔试题 找出列表中出现次数最多的元素 """ if not arr: return -1 count = {} result = [] for i in arr: count[i...
dc0f95828705f2f1e42a9726b0e79e6c25e6d8ae
indeyo/PythonStudy
/leetcode/find_coder.py
551
3.765625
4
# !/usr/bin/env python3 # -*- coding: utf-8 -*- """ # @Author : indeyo_lin # @Time : 2020/5/25 10:48 下午 # @File : find_coder.py """ def find_coder(arr): if not arr: return -1 coder = [] for s in arr: if "coder coder" in s: coder.append(s) return coder if coder else -1 ...
4fdd9b3423f94460b3faad5262229e374ca3518c
indeyo/PythonStudy
/algorithm/insertion_sort.py
720
4.125
4
# !/usr/bin/env python3 # -*- coding: utf-8 -*- """ # @Author : indeyo_lin # @Time : 2020/5/28 4:20 下午 # @File : insertion_sort.py """ def insertion_sort(arr): if not arr: return -1 for i in range(1, len(arr)): current = arr[i] # 有序区的索引 pre_index = i - 1 while pre_i...
ce5cad544a2fc27a8d36f44d9a3bfd8cc8962f3b
indeyo/PythonStudy
/leetcode/replace_space.py
3,654
3.625
4
# !/usr/bin/env python3 # -*- coding: utf-8 -*- """ @Project : PythonStudy @File : replace_space.py @Time : 2020-04-26 14:47:16 @Author : indeyo_lin """ class ReplaceSpace: """ 面试题05. 替换空格 请实现一个函数,把字符串 s 中的每个空格替换成"%20"。 示例 1: 输入:s = "We are happy." 输出:"We%20are%20h...
9ea6a64935a14b0c50cbbeae11f077417d0e35f9
lingkuraki/python
/chapter03/com.kuraki/zip.py
148
3.875
4
names = ['kuraki', 'lingbo', 'damon', 'Jordan'] ages = [26, 25, 100, 50] for name, age in zip(names, ages): print(name, 'is', age, 'year old')
e6538e04ca9938179eebeae64c7ce506c9854327
lingkuraki/python
/chapter03/com.kuraki/whileDemo.py
170
4
4
name = '' while not name or name.isspace(): name = input('Please enter your name: ') print('Hello, {}!'.format(name)) for number in range(1, 101): print(number)
5b4bcebc35451efa0b90dbf11074a201a110efa0
lcantillo00/python-exercises
/11-DictionariosDupes/ex1.py
859
3.84375
4
x = input("Enter a sentence") x = x.lower() # convert to all lowercase alphabet = 'abcdefghijklmnopqrstuvwxyz' letter_count = {} # empty dictionary for char in x: if char in alphabet: # ignore any punctuation, numbers, etc if char in letter_count: letter_count[char] ...
018c53dca45443f6ffc16b7086735f644593dc45
lcantillo00/python-exercises
/10-List/ex5.py
265
3.5625
4
import random def max(alist): maxnum=0 for i in alist: if maxnum<i: maxnum=i return maxnum def main(): f=[] for i in range(100): f.append(random.randint(0, 1000)) print(max(f)) if __name__=="__main__": main()
1f29fed056ccc1691b630acc4ffbc33526a29276
lcantillo00/python-exercises
/2-SimplePythonData/ex11.py
227
4.40625
4
deg_f = int(input("What is the temperature in farengeigth? ")) # formula to convert C to F is: (degrees Celcius) times (9/5) plus (32) deg_c = (deg_f -32)*5/9 print(deg_f, " degrees Celsius is", deg_c, " degrees Farenheit.")
5c609d4fbf967bec92af65ec32a8c7b6e7d1d21c
lcantillo00/python-exercises
/Studio/st2.py
543
4.09375
4
print("Welcome to the Loop Hole!") print("Today's Manager's Special is :") print("Donnuts: A traditional jelly donut in which the jelly filling is made entirely of Capn' Crunch Berries Oops All Berries") num_donuts=int(input("How many do you like?")) price=float(input("How much would you like to pay per donut 'suggeste...
88cf45a659416489228d03a71c18e528c2e28770
lcantillo00/python-exercises
/ex15.py
159
4.09375
4
#Write a function that will return the number of digits in an integer. def intergerNum(num): nstring=str(num) return len(nstring) print(intergerNum(34))
667d442d0c38e26e70f9b0cf7a2e219ccced2f97
lcantillo00/python-exercises
/exs12.py
271
3.890625
4
#Write a program to draw some kind of picture. # Be creative and experiment with the turtle methods provided in import turtle tanenbaum = turtle.Turtle() tanenbaum.hideturtle() tanenbaum.speed(20) for i in range(350): tanenbaum.forward(i) tanenbaum.right(98)
681ec03bc494256d93fd8e6482a2aea210cf94d2
lcantillo00/python-exercises
/4-ModuleTurtle/ex5.py
772
4.15625
4
# draw an equilateral triangle import turtle wn = turtle.Screen() norvig = turtle.Turtle() for i in range(3): norvig.forward(100) # the angle of each vertice of a regular polygon # is 360 divided by the number of sides norvig.left(360/3) wn.exitonclick() # draw a square import turtle wn = turtle.Sc...
4ccfffb6a6cea4bd016495075bb967750dfe05d1
lcantillo00/python-exercises
/9-Strings/ex5.py
885
3.6875
4
# from test import testEqual # # def remove_all(substr,theStr): # newstring=theStr.replace(substr,"",) # return newstring # # # testEqual(remove_all('an', 'banana'), 'ba') # testEqual(remove_all('cyc', 'bicycle'), 'bile') # testEqual(remove_all('iss', 'Mississippi'), 'Mippi') # testEqual(remove_all('eggs', 'b...
d9fbdc7310218e85b562a1beca25abe48e72ee8b
lcantillo00/python-exercises
/randy_guessnum.py
305
4.15625
4
from random import randint num = randint(1, 6) print ("Guess a number between 1 and 6") answer = int(raw_input()) if answer==num: print ("you guess the number") elif num<answer: print ("your number is less than the random #") elif num>answer: print("your number is bigger than the random #")
e15b2129dc2bb67a6815679e4f9b3caca092eaa2
JaredLGillespie/DataStructures
/Python/InsertionSort.py
1,778
3.59375
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- # Copyright (c) 2018 Jared Gillespie # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the ri...
9e71f7ca9e7fc34fe6769a952b923c4d7b8f933f
MusaddiqueahmedDange/python_practice
/COHpythonpractice/chapter 2/02_pr_06_remainder.py
68
3.859375
4
a = 50 b = 8 print("the remainder when a is divided by b is :", a%b)
6e45d0c329bc846c10cdc4e425d2d8700b1da89c
llewelld/countdown
/countdown.py
7,550
4
4
#!/usr/bin/python """ Does the Countdown numbers game. Give it a list of numbers. It'll use all but the last number in a formula using the +, -, * and / operators to try to generate the last number. Only integer arithmetic is allowed, and not all of the numbers need to be used. Syntax: countdown n_1 n_2 ... n_m sum ...
dbd5be5f5ba49f3ff8340d835c203be524583be3
michelmora/python3Tutorial
/BegginersVenv/forLoop.py
1,173
3.875
4
# For loops # The last number (11) is not included. This will output the numbers 1 to 10. # for i in range(1, 11): # print(i) # Python itself starts counting from 0, so this code will also work but will output 0 to 9 # for i in range(0, 10): # print(i) # equivalent to for i in range(10): print(i) # using li...
7b692f7ea4d8718261e528d07222061dc3e35de8
michelmora/python3Tutorial
/BegginersVenv/dateAndTime.py
757
4.375
4
# Computers handle time using ticks. All computers keep track of time since 12:00am, January 1, 1970, known as epoch # time. To get the date or time in Python we need to use the standard time module. import time ticks = time.time() print("Ticks since epoch:", ticks) # To get the current time on the machine, you can ...
4dd9a591648531943ccd60b984e1d3f0b72a800c
michelmora/python3Tutorial
/BegginersVenv/switch(HowToSimulate).py
2,519
4.21875
4
# An if ... elif ... elif ... sequence is a substitute for the switch or case statements found in other languages. # OPTION No.1 def dog_sound(): return 'hau hau' def cat_sound(): return 'Me au' def horse_sound(): return 'R R R R' def cow_sound(): return 'M U U U' def no_sound(): return "T...
d9eb301592bb6cea584f5bee079947d852dd30a4
michelmora/python3Tutorial
/BegginersVenv/functions.py
3,923
4.5
4
# Functions import math def pythagoras(a, b): value = math.sqrt(a * a + b * b) return value # print([pythagoras(3, 3)]) # The keyword def introduces a function definition. It must be followed by the function name and the parenthesized list # of formal parameters. The statements that form the body of the fu...
8dee8c987a27474de2b12a4a783dddc7aa142260
darrengidado/portfolio
/Project 3 - Wrangle and Analyze Data/Update_Zipcode.py
1,333
4.21875
4
''' This code will update non 5-digit zipcode. If it is 8/9-digit, only the first 5 digits are kept. If it has the state name in front, only the 5 digits are kept. If it is something else, will not change anything as it might result in error when validating the csv file. ''' def update_zipcode(zipcode): """C...
76873baab78e9765b6339cb3f7e312e7bec2963d
NeniscaMaria/Grades-and-Assignments-Manager-Application
/GUI.py
24,927
3.671875
4
from tkinter import * from UI import * class GUI(UI): def __init__(self,__students,__assignments,__grades,__undoRedo): UI.__init__(self, __students, __assignments, __grades, __undoRedo) self.__window=Tk() #here I write the name of the project self.__window.title('Assignmen...
3177bc787712977e88acaa93324b7b43c25016f9
sudharsan004/fun-python
/FizzBuzz/play-with-python.py
377
4.1875
4
#Enter a number to find if the number is fizz,buzz or normal number n=int(input("Enter a number-I")) def fizzbuzz(n): if (n%3==0 and n%5==0): print(str(n)+"=Fizz Buzz") elif (n%3==0): print(str(n)+"=Fizz") elif (n%5==0): print(str(n)+"=Buzz") else: print(str(n)+...
c933295fd67c0499071ea60566b9961dc4491ca1
krishna-kumar456/Code-Every-Single-Day
/solutions/alarm.py
357
4.03125
4
""" Alarm Clock. """ import datetime def ring(): print('Beep') user_input_hour = int(input('Enter Hour')) user_input_minutes = int(input('Enter minutes')) beep = True while beep: now = datetime.datetime.now() print(now.hour, now.minute, now.second) if user_input_hour == now.hour and user_input_minutes == now.mi...
f0f5449257bb860b1bb294531016869f8883f78f
krishna-kumar456/Code-Every-Single-Day
/solutions/reverse.py
115
4.09375
4
""" Reverse a string. """ if __name__ == '__main__': string = input('Please enter string ') print(string[::-1])
8078d00c4923e26e25e2079bfcbf2110fd8dccda
krishna-kumar456/Code-Every-Single-Day
/solutions/sieveofe.py
657
3.96875
4
""" Sieve of Eratosthenes. 1. Generate numbers to the limit. 2. Start with 2, eliminate multiples of 2. 3. Proceed to next number (3), eliminate multiples of 3 4. Keep looping until p2 > n. """ userInput = int(input('Please enter the upper limit')) def primes_sieve2(limit): a = [False] * 2 + [True] * (limit-2) ...
bf90882a0af31c4272a9fee19aa2716760847bbc
krishna-kumar456/Code-Every-Single-Day
/solutions/piglatin.py
1,060
4.375
4
""" Pig Lating Conversion """ def convert_to_pig_latin(word): """ Returns the converted string based on the rules defined for Pig Latin. """ vowels = ['a', 'e', 'i', 'o', 'u'] char_list = list(word) """ Vowel Rule. """ if char_list[0] in vowels: resultant_word = word + 'way' """ Consonant Rule. """ ...
d61abfa306531eec1db532e82dff32f2472849fa
Polsonby/cd-python-tictac
/play.py
2,863
3.890625
4
import random game_in_progress = True x_char = 'X' o_char = 'O' space_char = ' ' board = [space_char, space_char, space_char, space_char, space_char, space_char, space_char, space_char, space_char] player_character = '' computer_character = '' def drawBoard(data): print(""" 1 |2 |3 %s | %s | %s | ...
54ce7655f0a25a5dcbbbefabd772ebcec4b31759
JackRossProjects/OpenCV2-Notes
/ch4-shapes-and-texts.py
942
3.75
4
import cv2 import numpy as np # Create an image of size 512x512 with color functionality but initialize to 0 (black) img = np.zeros((512,512,3), np.uint8) # (512, 512) = grayscale || (512, 512, 3) = color functionality # If we want to make the entire ([:]) image (img) blue (255, 0, 0) # img[:] = 255, 0, 0 # Adding a...
cfd8e159d8ba84cfbf47ea88fd83826b3c59c7be
ryanmalani/IT-129
/quiz2-1.py
303
3.765625
4
fhand = open("therepublic.txt") count = 0 def find_a_word(fname, key_word): for line in fhand: if line.lower().startswith(key_word): count = count + 1 return count find_a_word("therepublic.txt", "plato") print(key_word + " showed up " + str(count) + " times in " + fname)
73ad6ddc678473757ca369582a5a49439ac750ee
ryanmalani/IT-129
/ex_8_4.py
341
3.703125
4
#Ryan Malani try: fname = input('Enter file name: ') fhand = open(fname) readfile = fhand.read() words = readfile.split() for word in words: if words.count(word) == 1: uniqueWords = [] uniqueWords.append(word) print(uniqueWords) except: print('Invalid ...
0ba68f90c272d4db39968f77cbabf5bf578f6546
tdd-laboratory/tdd-homework-dastardlychimp
/library.py
3,219
3.609375
4
import re from typing import Tuple _whole_word = lambda x: re.compile(r"\b{}\b".format(x)) _date_iso8601_pat = _whole_word(r'(\d{4})-(0\d|1[0-2])-(0[1-9]|[12][0-9]|3[01])') _date_month_word_pat = _whole_word(r'(\d{2}) (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) (\d{4})'); _mixed_ordinal_pat = _whole_word(r'-?\d...
fe448c3f1329e9b50594a396697cc58fd2ab8890
itielshwartz/protocolAnalyzer
/analyze_protocols.py
5,560
3.65625
4
import csv import glob import os from collections import defaultdict from collections import namedtuple base_values = ["first_name", "last_name", "full_name", "position", "committee", "date", "work_place", "role", "raw_line"] Person = namedtuple('Person', base_values) with open("full_names.csv") as f: ...
24830cb704c4704fdbc51698ea2d06f523e4f868
sdelquin/adventofcode
/2017/day4/day4.py
1,418
3.671875
4
""" Advent of Code 2018. Day 4 Usage: day4.py part1 day4.py part2 day4.py test """ from docopt import docopt PART1_SOLUTION = 337 PART2_SOLUTION = 231 def load_input_data(): with open("input") as f: return [line.strip() for line in f] def part1(): passphrases = load_input_data() va...
2da617bf9c2451201e2d79197c40afd491fb4906
michaelkulinich/SS8_assignment
/mycd_python.py
5,593
4.46875
4
""" A program simulating a "cd" Unix command. The simulated command takes two path strings from the command line and prints either a new path or an error. The first path is a current directory. The second path is a new directory. To make it simple let's assume that a directory name can only contain alphanumeric cha...
da04ab784745cdce5c77c0b6159e17d802011129
sclayton1006/devasc-folder
/python/def.py
561
4.40625
4
# Python3.8 # The whole point of this exercise is to demnstrate the capabilities of # a function. The code is simple to make the point of the lesson simpler # to understand. # Simon Clayton - 13th November 2020 def subnet_binary(s): """ Takes a slash notation subnet and calculates the number of host addresse...
cc4ad41898b97ba008dde737186709286f089798
omnidune/ProjectEuler
/Files/problem9.py
465
4.0625
4
# A Pythagorean triplet is a set of three natural numbers, a < b < c, for which, # a2 + b2 = c2 # For example, 3^2 + 4^2 = 9 + 16 = 25 = 5^2. # There exists exactly one Pythagorean triplet for which a + b + c = 1000. # Find the product abc. def triMultiply(num): for i in range(1, int(num/2)): for j in range(i, i...
c3786bba365334b39c1ec13463c773c760e6f439
KALAIYARASICHANDRASEKAR/Python_Guvi
/multiply.py
115
4.0625
4
#multiply num=int(input("enter the number:")) i=1 sum=0 while(i<=5): sum=sum+num print(sum) i=i+1
f4661370ba24875539acc80900070cff792ae01b
fengnianzhuang/atsim-potentials
/atsim/potentials/potentialfunctions.py
26,934
3.84375
4
"""Functions for different potential forms. Most of the potentials in this module are implemented as callable _Potential_Function_Bases. The potential energy is evaluated by calling one of these objects. By convention the first argument of each is the atomic separation `r`, with other potential parameters following af...
46f4e127eca6bdcd2309406a4f7f5a8259b3a896
zaur557/python.zzz
/taack 1/стоймость покупки.py
112
3.546875
4
a = int(input()) b = int(input()) n = int(input()) cost = n * (100 * a + b) print(cost // 100, cost % 100)
dc1dd25992e4ab98200fe1a4ba28e1211529c6d5
elston-jja/Personal-Projects
/python/Grade12/unit3/Personal Versions/Zodiac/zodiaccomp.py
5,201
4.03125
4
''' Elston Almeida Checks Compatibility of users based on their zodiac sign 2016/30/05 ICS 3U1 ''' '''Get Date''' def birthday_day(identifier): verified_input = False while verified_input is False: try: birth_date_input = input("Please enter "+identifier+ " date of birth: ") if ...
368139b4978ccea8fc599e278be28b0dc3a4d0fd
henaege/python-basics-day-3
/triangle.py
322
3.671875
4
def print_star(): print((" " * (space_count / 2)) + "*" * star_count + (" " * (space_count / 2))) total_width = 10 star_count = 1 space_count = total_width - star_count loop_count = 1 while loop_count <= 10: if star_count % 2 == 1: print_star() star_count += 1 space_count -= 1 loop_count +=...
c9412d1862d73c9bffc8d47b7a1b860f8bd8f62e
henaege/python-basics-day-3
/long_vowels.py
856
3.6875
4
# string = raw_input("Word: ") # word = list(string) # for i in range(0,len(word)-1): # home_slice = word[i:i+2] # if home_slice == ['a', 'a']: # word.remove("a") # word.insert(i, "aaaa") # if home_slice == ['e', 'e']: # word.remove("e") # word.insert(i, "eeee") # if home_slice == ['i', 'i']: # word.rem...
a13a1b0a859f1fa0755e056cfb64552036cf180d
henaege/python-basics-day-3
/banner.py
334
3.609375
4
def print_top(num): print("*" * num) def print_bottom(num): print("*" * num) def print_middle(message): print("*" + " " + message + " " + "*") text = raw_input("What will the banner say? ") width = len(text) + 4 # height = int(raw_input("How high is the box? ")) print_top(width) print_middle(text) print...
bb8993ca645aa4bf204163dfdbae3ce2dbd87499
noltron000/exercisms
/high-scores/high_scores.py
378
3.8125
4
def latest(scores): return scores[-1] def personal_best(scores): return max(scores) def personal_top_three(scores): top_scores = [0]*min(len(scores),3) for score in scores: for top_score in top_scores: if score > top_score: idx = top_scores.index(top_score) top_scores.insert(idx, score) top_sco...
312f11f76a042b25bec17dd1f8a19089b44993fd
hello-lx/CodingTest
/3/625.py
1,250
3.515625
4
class Solution: """ @param nums: an integer array @param low: An integer @param high: An integer @return: nothing """ def partition2(self, nums, low, high): if not nums: return start, end = 0, len(nums) - 1 while start <= end: while s...
75e95c28db08788ac12df8bca709497d68910b38
adamstockton/Python-Class
/Activities/color groups.py
2,589
3.75
4
# Define Grid grid = [ ["G", "G", "B", "R"], ["G", "B", "R", "B"], ["R", "B", "B", "B"] ] # Capture Results highest = { "color": "", "count": 0 } # Compute Result iterated = {} def main(): for row in range(len(grid) - 1): for col in range(len(grid[row]) - 1): # Check if ...
5620f2df6da84ab3425626bc24d5cd9d2597e218
carlemil/ProjectEuler
/completed/euler0026.py
1,299
3.71875
4
##A unit fraction contains 1 in the numerator. The decimal representation of the unit fractions with denominators 2 to 10 are given: ## ## 1/2 = 0.5 ## 1/3 = 0.(3) ## 1/4 = 0.25 ## 1/5 = 0.2 ## 1/6 = 0.1(6) ## 1/7 = 0.(142857) ## 1/8 = 0.125 ## 1/9 = 0.(1) ## 1/10 = 0.1 #Where 0.1(6)...
7ce1b872be63182adfc3485073ce25e4d0a037f0
carlemil/ProjectEuler
/completed/euler0036.py
725
3.703125
4
##The decimal number, 585 = 1001001001 (binary), is palindromic in both bases. ## ##Find the sum of all numbers, less than one million, which are palindromic ##in base 10 and base 2. ## ##(Please note that the palindromic number, in either base, may not include ## leading zeros.) from tools import is_palindrom...
799b052a493c4fabd53c156db5ae90bcb6960cea
carlemil/ProjectEuler
/completed/euler0107.py
2,542
3.578125
4
from tools import read_file class Node: def __init__(self, nr, edges): self.nr = nr self.edges = edges self.mst_edges = [] self.connected_to = [] self.in_mst = False def handle_node(nr, inl): utl = [] for i in range(len(inl)): t = in...
87509b879f03bf974906d723e79df69c1c17cc55
JorgeVidal29/MyMLLearning
/Single Variable Regression/Resturant Population vs Profit/resturantPrediction.py
1,589
3.671875
4
""" Created on Mon May 18 21:56:49 2020 @author: Jorge """ #These are all the libs we are using import pandas as pd import matplotlib.pyplot as plt from sklearn.model_selection import train_test_split from sklearn.linear_model import LinearRegression from sklearn import metrics #reading the dataset and sepera...
bbfa62e0a73aa476ff8c7a2abd98c021c956d20e
Zeonho/LeetCode_Python
/archives/535_Encode_and_Decode_TinyURL.py
1,708
4.125
4
""" TinyURL is a URL shortening service where you enter a URL such as https://leetcode.com/problems/design-tinyurl and it returns a short URL such as http://tinyurl.com/4e9iAk. Design the encode and decode methods for the TinyURL service. There is no restriction on how your encode/decode algorithm should work. You j...
3015e58495f0687c0d5270dc3dcd5b0dd8b3592f
Zeonho/LeetCode_Python
/archives/24_Swap_Nodes_in_Pairs.py
1,422
3.859375
4
""" 24. Swap Nodes in Pairs Medium 1720 152 Add to List Share Given a linked list, swap every two adjacent nodes and return its head. You may not modify the values in the list's nodes, only nodes itself may be changed. Example: Given 1->2->3->4, you should return the list as 2->1->4->3. """ # Definition for ...
2e2a2100b44d151a090c6f7835d6c32ccb8750d1
Zeonho/LeetCode_Python
/archives/997_Find_the_Town_Judge.py
1,460
3.796875
4
""" In a town, there are N people labelled from 1 to N. There is a rumor that one of these people is secretly the town judge. If the town judge exists, then: The town judge trusts nobody. Everybody (except for the town judge) trusts the town judge. There is exactly one person that satisfies properties 1 and 2. You...
346e4c2c35f31b80f0858d9109366bfd64d94d19
Zeonho/LeetCode_Python
/archives/867_Transpose_Matrix.py
462
3.921875
4
""" Given a matrix A, return the transpose of A. The transpose of a matrix is the matrix flipped over it's main diagonal, switching the row and column indices of the matrix. """ class Solution: def transpose(self, A: List[List[int]]) -> List[List[int]]: res = [] for i in range(len(A[0])): ...
ce55003853dc015c58c8d158a37d2a684c5e0b9e
Zeonho/LeetCode_Python
/archives/1_Two_Sum.py
514
3.78125
4
""" Given an array of integers, return indices of the two numbers such that they add up to a specific target. You may assume that each input would have exactly one solution, and you may not use the same element twice. """ class Solution: def twoSum(self, nums: List[int], target: int) -> List[int]: # So...
4f2dff3ef7e3d45d5c94798458a4c543e5c23a26
shreyaydi/Python-Assignment-II
/10.py
636
4.09375
4
# Write a function that takes camel-cased strings (i.e. # ThisIsCamelCased), and converts them to snake case (i.e. # this_is_camel_cased). Modify the function by adding an argument, # separator, so it will also convert to the kebab case # (i.e.this-is-camel-case) as well. def conv(my_string, seperator): var = [my_...
31f60c8ce2e2aa2c827d520e10e174a3c191ff64
nathanpainchaud/advent-of-code
/src/utils/parsing.py
773
3.5
4
import argparse class StoreDictKeyPair(argparse.Action): """Action that can parse a python from comma-separated key-value pairs passed to the parser.""" def __call__(self, parser, namespace, values, option_string=None): """Parses comma-separated key-value pairs passed to the parser into a dict, addin...
b36f1a653b763f89a09c37100791061577d878ee
nathanpainchaud/advent-of-code
/src/2020/day15/rambunctious_recitation.py
1,270
3.984375
4
from pathlib import Path def rambunctious_recitation(starting_numbers_path: Path, num_turns: int) -> None: with open(starting_numbers_path) as file: starting_numbers = [int(number) for number in file.read().split(",")] numbers = {number: turn for turn, number in enumerate(starting_numbers[:-1], 1)} ...
1913d89c6503e5c7cb77a29f2c1064d05e3897c4
Xander999/GeeksForGeeks-Implementation
/Python2.py
428
3.921875
4
''' https://practice.geeksforgeeks.org/problems/is-binary-number-multiple-of-3/0 ''' while(n>0): s=input() k=0 g=len(s) odd=0 even=0 for i in range(g-1,-1,-1): j=g-1-i if(s[i]=='1'): if(j%2==0): odd=odd+1 else: even=even+1 ...
c21c5d23e83c85ecd72ce94447852ee00f3e56c8
HsiaSharpie/My_Python_Note
/TwoSum.py
406
3.6875
4
class Solution: def TwoSum(self, nums, target): value_2_index = {} for index, num in enumerate(nums): if target - num in value_2_index: return [value_2_index[target - num], index] else: value_2_index[num] = index given_nums = [2, 7, 11, 15] t...
f1437255d61fd79d83adc51da504cd2f85f9f534
gbernich/marchmadness
/src/objects.py
1,592
3.734375
4
# Object holds winning and losing team names and seeds class Matchup: def __init__(self, winner_name, winner_seed, loser_name, loser_seed): self.winner_name = winner_name self.winner_seed = winner_seed self.loser_name = loser_name self.loser_seed = loser_seed # Object holds all of the matchups within its T...
3fa38a20a3710de479b5978c953e4633d336b972
hsamvel/Python_homeworks
/homework8_1(Narek).py
329
3.546875
4
def about_books(author_name,**var): list_1 = [var] print(list_1) for el in list_1: for elem in el: if el[elem][0] == author_name: print(elem,el[elem][1]) about_books('dyuma',askanio = ('dyuma',1965),sherlock = ('conan doyle',1887),thrones=('martin ge...
20e5826d68fc6be636cf329fbd0a12ae7b9b6202
hsamvel/Python_homeworks
/homework12_1(Ruben).py
378
3.5625
4
a = [[10,9,6,3,7], [6,10,2,9,7], [7,6,3,8,2], [8,9,7,9,9], [6,8,6,8,2]] i = -1 j = 0 new_a = [] def rotateImage(a): global i,j,new_a if j >= len(a): return new_a row = [] while abs(i) <= len(a): row.append(a[i][j]) i -= 1 new_a.append(row) j += 1 ...
1c86bfd87bff1739ea37ae9f6b2461a99741d61f
hsamvel/Python_homeworks
/homework8_2(Narek).py
359
3.875
4
list_1 = [9,5,8,5,20,1,2,-3,-2,-1,0] list_1.sort() list_1.reverse() list_2 = list_1[0:3] list_3 = list_1[len(list_1)-2:len(list_1)] list_3_count=1 for el in list_3: list_3_count *= el list_3_count *=list_1[0] list_2_count = 1 for elem in list_2: list_2_count*=elem if list_3_count > list_2_count: print(list_...
08a393d5f3c7ca9e7453a5d78aef9836fbd384fa
rajeevranjan1/Python
/Harry/inheritance.py
631
3.984375
4
class Employee: company='Collins' def __init__(self,name,dept): self.name=name self.dept=dept def showDetails(self): print(f"Employee Name: {self.name}") print(f"Departmet: {self.dept}") def showComputerType(self): print("PC/Laptop") class Developer(Emp...
0912899fa71c5c4c52cce4a5353a8f1d484f7a4e
rajeevranjan1/Python
/Harry/chap5.py
211
3.875
4
num=[23,56,72,7] if num[0]>num[1]: c1=num[0] else: c1=num[1] if num[2]>num[3]: c2=num[2] else: c2=num[3] if c1>c2: greatest = c1 else: greatest=c2 print("Greatest Number is",greatest)
d663b67480d685326887340f0ea774066078e5d5
rajeevranjan1/Python
/designerMat.py
448
3.8125
4
y=int(input("Enter number of Row (Odd number between 7 and 101: ")) x=y*3 count=3 fill='.|.' for i in range(y): if i<y//2: print('-'*((x-count)//2)+fill*(2*i+1)+'-'*((x-count)//2)) count +=6 filltemp=2*i+1 elif i==y//2: print('-'*((x-7)//2) + 'WELCOME' + '-'*((x-7)//2)) else:...
6d010e64a36a24e618ff88e49890bade99583435
davidth4ever2/ai
/modules/offtopic/python/shifttest1.bk.py
482
3.546875
4
count = 1 currentSeries = 0 shiftword = "skull" alphabet = "abcdefghijklmnopqrstuvwxyz" g = 0 for i in range(26): print "{0:5} | {1:5} | {2:5} | {3:5} | {4:5} ".format(i, currentSeries,count, shiftword[g], alphabet.index(shiftword[g]) + 1) g = g + 1 if(count%len(shiftword) == 0): g ...
fafab6946720e7e9c5f6756519566d1542f67e16
littlewindcc/Image-Processing
/Sharping&Smoothing/smooth/smoothing.py
791
3.5625
4
import cv #function for Smoothing def MedianFilter(image): w = image.width h = image.height size = (w,h) iMFilter = cv.CreateImage(size,8,1) for i in range(h): for j in range(w): if i in [0,h-1] or j in [0,w-1]: iMFilter[i,j] = image[i,j] else: ...
88916b3af1c561a590ba0eeca996894a843e1456
Skparab1/math-codes
/PolynomialFactorizer.py
16,630
3.578125
4
import time import math #superscripts! ² ³ ⁴ ⁵ ⁶ ⁷ ⁸ isquadratic = False def var_args(args): num = 0 try: while True: hello = (args[num]) num += 1 except: print(' ') return num - 1 def factorfinder(number): number = int(number) if number < 0: numbe...
e37dc65138bacbf973b20936a5a0cc61c79acc9c
harshOS/python_learning
/ABSWP/isPhoneNumberIN.py
659
3.90625
4
def isPhonenumberIN(num): if len(num) != 13 : return False if num[0:3] != "+91": return False if not num[3:13].isdecimal(): return False return True message = "On my wall i found some writen number +918108855425 and 913215854512" for i in range(len(message)): part = message[...
cca57e92493f2ad94e154191204902799cb12191
harshOS/python_learning
/ABSWP/phoneNumINRegex.py
175
3.84375
4
import re isPhoneIn = re.compile(r'(?:(?:\+|0{0,2})91(\s*[\-]\s*)?|[0]?)?[789]\d{9}') mo = isPhoneIn.search("wall det +917894561230") print("Phone number found: "+mo.group())
8a4bf0aac904f4c84465b15f47cc358a18215f36
jeff-a-holland/python_class_2021_B2
/exercise_4/solution.py
2,090
3.96875
4
#!/Users/jeff/.pyenv/shims/python import string def create_password_checker(min_uppercase, min_lowercase, \ min_punctuation, min_digits): """Function to return that checks pw for complexity rules""" def checker(pw): ### Vars rules_dict = {} digit_cntr = uppe...
5055cf7e2742d3c0374f828534b73bd8cda1043a
Mayurg6832/HackerRank-DataStructures-solutions
/tree-huffman-decoding.py
332
3.6875
4
def decodeHuff(root, s): #Enter Your Code Here result="" current=root for i in s: if int(i)==0: current=current.left else: current=current.right if current.left==None and current.right==None: result+=current.data current=root pr...
bc7208dae8989597af27878f3de2aa535aa141b0
CGA21/XO_cmd
/game.py
2,911
4.0625
4
board = ["1","2","3", "4","5","6", "7","8","9"] def play_game(): winner="continue" current_player=choice() display_board() while(winner=="continue"): ask_input(current_player) display_board() winner=check_winner(current_player) if(winner!="continue"): break current_player=flip_play...
31bb0177c0f21a2264e07113f05a8f06a5030b85
aparecidapires/Python
/Python para Zumbis/1 - Comecando com o basico/Comentarios e Resolucao de Exercicios/Lista de Exercicios 1/2.py
222
3.984375
4
''' Escreva um programa que leia um valor em metros e o exiba convertido em milímetros ''' metros = float(input('Digite a quantidade de metros: ')) print ('%.1f metros equivale a %d milímetros' %(metros, metros*1000))
808bdd5149fc9ecc2540f24b32f22c9e505062cd
aparecidapires/Python
/Python para Zumbis/2 - Mastigando estruturas de controle/Repeticoes/2.1 - TWP250 Fatorial e Break.py
145
3.609375
4
#Cálcule o fatorial de dez i = 10 fatorial = 1 while i > 1: fatorial = fatorial * (i-1) i = i -1 print ('Fatorial(10): %d' %fatorial)
4022dd869dd119b97a5ca5ca128076f968aa3d96
aparecidapires/Python
/Python para Zumbis/1 - Comecando com o basico/Comentarios e Resolucao de Exercicios/Lista de Exercicios 1/4.py
471
3.765625
4
''' Faça um programa que calcule o aumento de um salário. Ele deve solicitar o valor do salário e a porcentagem do aumento. Exiba o valor do aumento e do novo salário. ''' salario = float(input('Digite o salario: ')) porcentagem = float(input('Digite a porcentagem de aumento: ')) novoSalario = salario + (salario * po...
4af8683399a7344690ba6e7a3ba749d10852c993
aparecidapires/Python
/Python para Zumbis/3 - Atacando os tipos basicos/Comentarios e Resolucao de Exercicios/Lista III/1.py
398
4.375
4
''' Faça um programa que peça uma nota, entre zero e dez. Mostre uma mensagem caso o valor seja inválido e continue pedindo até que o usuário informe um valor válido. ''' nota = float(input("Digite uma nota entre '0' e '10': ")) while nota < 0 or nota > 10: print ('Digite uma nota válida!') nota = float(inp...
6a284e461c5325c9f072614a21a69e667b4210cd
aparecidapires/Python
/Python para Zumbis/2 - Mastigando estruturas de controle/Repeticoes/2.1 - TWP250 Fatorial e Break - c.py
217
4.0625
4
# Calcule o fatorial de um número inteiro n i = 1 fatorial = 1 numero = int(input('Digite um número: ')) while i <= numero: fatorial = fatorial * i i = i + 1 print ('Fatorial(%d) = %d' %(numero, fatorial))
b20c934c81250c39f5788138338038ece040949f
Grifo89/Algorithms
/where_do_I_belong/getIndexToIns.py
539
3.78125
4
from typing import List def getIndexToIns(arr: List, num: int) -> int: # 1. Sortin list # list.sort() for i in range(len(arr) - 1): for j in range(len(arr) - i -1): if arr[j + 1] < arr[j]: tmp = arr[j] arr[j] = arr[j + 1] arr[j + 1] = tmp ...
b9811d02517fe7e3ab26665d29ff8ffcca068693
lc-huertas/CodingDojo_Python_Stack
/_python/BankAcc.py
1,726
4.0625
4
class BankAccount: def __init__(self, int_rate, balance): # don't forget to add some default values for these parameters! # your code here! (remember, this is where we specify the attributes for our class) # don't worry about user info here; we'll involve the User class soon. self.interest ...
35461c4770c624d1a7843dc88884113255d74344
luciangutu/job_test
/salary.py
963
3.890625
4
""" script to calculate how many years it will take to reach a better salary s1 - current (lower) salary s2 - future/wanted/promissed salary i1 - yearly salary increase for the current salary (%) i2 - yearly salary increase at the other company that you are thinking of going (%) """ s1 = 500 s2 = 800 i1 = 5 i2 = 2 #...
351f49543c5a9d942474a2a34a02543c98b0c92b
luciangutu/job_test
/yield_generator.py
181
3.59375
4
def gen(n): for i in range(n): if i % 2 == 0: yield i x = 5 g = gen(x) while True: try: print(next(g)) except StopIteration: break