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
61ec42794edb63e040c34b984b84b11285109aaa
dddooo9/CodeUp
/1031/1034.py
135
3.578125
4
# a = input() # n = int(a, 8) # print(n) a = input() sum = 0 for i in range(len(a)): sum += int(a[len(a)-i-1]) * (8**i) print(sum)
beaaf5b1d2592b581f51afd9508e15e7e074e14c
dddooo9/CodeUp
/1081/1082.py
153
3.609375
4
a = input() for i in range(1, 16): i = hex(i)[2:] mt = hex(int(a, 16) * int(i, 16))[2:] print("{0}*{1}={2}".format(a, i.upper(), mt.upper()))
ce88b264250399ee7aff7a1064700809af3da25d
psvm/simpleWay6
/changeMatrix.py
1,344
3.90625
4
#Replace 2 column with max and min numbers of even elements in matrix [m x n] import random def replace_min_max_even_number_column(element, number_of_rows, number_of_column): even_count = [] index_max_even_column = None index_min_even_column = None list_for_calculating = [] for j in range(0, numbe...
0d4a54dfee5b84d2e24b7c3560b72e83968f02cd
Bohdan11Dii/Patern
/21_Template.py
998
3.765625
4
class House: def __init__(self, name): self.name = name print("Hello", name) def order(self): self.pouring_the_foundation() self.pulling_walls() self.roofing() self.installation_of_windows_and_doors() def pouring_the_foundation(self): pass def...
28467119ff5bfdff417bfe51ba504b5fed202361
Bohdan11Dii/Patern
/7_Bridge.py
828
3.765625
4
class Color: def fill_color(self): pass class Shape: def __init__(self, color): self.color = color def color_it(self): pass class Rectangle(Shape): def __init__(self, color): super(Rectangle, self).__init__(color) def color_it(self): print('Rectang...
e6d7b94ab9ee72d64ee17dee3db7824653bd5c51
mgyarmathy/advent-of-code-2015
/python/day_12_1.py
1,078
4.1875
4
# --- Day 12: JSAbacusFramework.io --- # Santa's Accounting-Elves need help balancing the books after a recent order. Unfortunately, their accounting software uses a peculiar storage format. That's where you come in. # They have a JSON document which contains a variety of things: arrays ([1,2,3]), objects ({"a":1, "b"...
209e8530ec5b7aa38100902fe9fb045b908b1923
mgyarmathy/advent-of-code-2015
/python/day_12_tests.py
1,680
3.5
4
# Part 1 # [1,2,3] and {"a":2,"b":4} both have a sum of 6. # [[[3]]] and {"a":{"b":4},"c":-1} both have a sum of 3. # {"a":[-1,1]} and [-1,{"a":1}] both have a sum of 0. # [] and {} both have a sum of 0. # Part 2 # [1,2,3] still has a sum of 6. # [1,{"c":"red","b":2},3] now has a sum of 4, because the middle object ...
16ff559c31cbb191ed1abc5329e11c3a5d05e453
pbarrenechea/python-training
/database.py
347
3.71875
4
import sqlite3 db = sqlite3.connect('data/mydb') cursor = db.cursor() sql = 'create table if not exists todos (id integer primary key, todo text, finished integer)' cursor.execute(sql) sql = 'insert into todos (todo, finished) values ("Task 1", 1)' cursor.execute(sql) cursor.execute('SELECT * FROM todos') print(cu...
afeb5e9def0b579c07566d75b2eec7ce39836039
liheng1015/python
/books.py
718
3.703125
4
#!/home/student/nsd1905/bin/python '''类 特殊方法如_init_ 实例化 __str__ 显示实例自动调用 __call__ 调用实例自动调用 ''' class Book: def __init__(self,title,author): self.title = title self.author =author def __str__(self): return '<%s>' % self.title def __call__(self): print('<%s...
5e373a55d80180ded854826ce095e154b35aa2a9
lucashamamoto/area-do-retangulo-python
/retangulo.py
273
3.671875
4
class Retangulo: #classe Retangulo define os atributos X, Y e Área, além do contrutor e método obter_area(). def __init__(self, x, y): self.__x = x self.__y = y self.__area = x * y def obter_area(self): return self.__area
ec559b43678056bf72282a3433c4f9dceba0a1c5
filfilt/pythonRepository
/Part027-OS-Folder and File Manipulation.py
457
3.78125
4
#OS-Folder and File Manipulation import os from datetime import datetime #os.mkdir("student") #os.makedirs('student/Grade/ninthGrade/student.txt') #print(os.path.dirname("student/Grade/ninthGrade/student.txt")) #print(os.path.basename("student/Grade/ninthGrade/student.txt")) #print(os.path.exists("student/Grade/ninth...
5937dd8901f02cb79eb422b7d3778353f540c052
filfilt/pythonRepository
/Part022 Types of Methods.py
805
4.25
4
#Types of Methods #Eg1:Instance Method ''' class student: schoolName = "school of techinology" def __init__(self,fn,ln): self.fname =fn self.lname = ln def getName(self): self.fname=self.fname+"1st" print("your full name is "+ self.fname+" "+self.lname) s1=student("nega...
ef882cb5261a8d9d03ca3ad25c5113c8f2ca5dbd
MarkEhler2/rando
/randomize_data.py
1,196
3.609375
4
import numpy from scipy.stats import skewnorm class RandomData(object): def __init__(self, len_data, input_mean, input_std): self._len_data = len_data self._input_std = input_std self._input_mean = input_mean def init_random_generator(self, spread=0, skew=0): """ Gener...
481181f40c7ea9cbc269336fdba8ae4c18c7f246
Oluwatobi17/ML-Study-Group
/Assignment/Solutions Week1/olumide_Nwosu_Week1.py
3,010
4.03125
4
# QUESTION 2 arr = list(range(1,101)) #+ [4,5,5,5,5,6,7,8,9,7,6,5,4,3,3,3,2,1,1,2,2,3,4,4,5,5] # This fuction divides the sum of all the # numbers in the list by the length of the list def mean(arr): return sum(arr)/len(arr) print(mean(arr)) # this function takes in a list, sorts it and returns the # sum of th...
4d9eb381cf7a51a32cf4968a88d23e069ee784d8
DanielPahor/data-structures
/LinkedList.py
1,810
3.859375
4
import unittest import collections class Node: def __init__(self, data, next = None): self.element = data self.next = next class LinkedList: def __init__(self, head): self.head = head #O(n) def insert(self, next): node = self.head while node.next: n...
e1051349af40553b9fc5138c352dff892afe39d4
agate-agate/learnpython_homeworks
/homework2/2_files.py
1,415
3.84375
4
""" Домашнее задание №2 Работа с файлами 1. Скачайте файл по ссылке https://www.dropbox.com/s/sipsmqpw1gwzd37/referat.txt?dl=0 2. Прочитайте содержимое файла в перменную, подсчитайте длинну получившейся строки 3. Подсчитайте количество слов в тексте 4. Замените точки в тексте на восклицательные знаки 5. Сохраните ре...
5f22aefa26ac9c26b0ccb30e5618f13a0586e573
nj3dano/Udacity-IntroDataSciences
/Lesson5-CountingWordsSerially.py
3,275
3.9375
4
# -*- coding: utf-8 -*- """ Created on Sun Mar 01 11:56:02 2015 @author: dak """ import logging import sys import string import re #from util import logfile #logging.basicConfig(filename=logfile, format='%(message)s', # level=logging.INFO, filemode='w') def word_count(): # For this exercise,...
8bf0579c2a794a4ddb74b0227292ce03dc4f59b5
nj3dano/Udacity-IntroDataSciences
/ProblemSet4.2-Visualization2.py
3,179
4.625
5
# -*- coding: utf-8 -*- """ Spyder Editor This is a temporary script file. """ from pandas import * from ggplot import * import matplotlib.pyplot as plt def plot_weather_data(turnstile_weather): ''' You are passed in a dataframe called turnstile_weather. Use turnstile_weather along with ggplot to make a ...
3a351e437072785fdd202a2c0539b06aadd4cb16
rajat-saini/Compound_Interest_calculator
/gui_compound.py
1,183
3.953125
4
from tkinter import * tk = Tk() tk.resizable(0,0) tk.title("Compound Interest") tk.geometry("550x300+250+250") p = StringVar() r = StringVar() t = StringVar() def calculation(): a=float(p.get()) b=float(r.get()) c=float(t.get()) CI=a*((1+(b/100))**c) e4.insert(0,CI) def reset...
1e1de7f9507931bcea047b8f301b96a1c0e7fcb6
JustinBrg/DNA-Toolkit
/borgmann_countNT.py
611
3.75
4
#!/usr/bin/python3 import sys dna = open(sys.argv[1]) nucs = (sys.argv[2]) #ACGT nucleotides = { "A": 0, "C": 0, "G": 0, "T": 0 } fasta_header = dna.readline().rstrip()#no new line dna = dna.read() #read() so i can iterate through the file '#for each pos...
037df269888cd282d4f29a531683ebda599ab393
PoisonRain/rtfgrgtgsrtghyk-
/newMath.py
1,659
3.921875
4
from flanking import tuple_to_location, location_to_tuple import math def get_alpha_from_points(center_point, trgt_point): """ get two points and returns the angle from the center :param center_point: the center of the circle :param trgt_point: a point on the circle :return: the angle of the targe...
8f4abcb6a0aa592f279dd1e04d412be2e634c035
Skillvendor/python_ai
/Python-Lang-Beginner-Tutorial-Complete.py
10,840
4.40625
4
# coding: utf-8 # In[1]: x = 3 print(type(x)) # Prints "<class 'int'>" print(x) # Prints "3" print(x + 1) # Addition; prints "4" print(x - 1) # Subtraction; prints "2" print(x * 2) # Multiplication; prints "6" print(x ** 2) # Exponentiation; prints "9" x += 1 print(x) # Prints "4" x *= 2 print(x) # P...
040fcf183a0db97e0e341b7a3e9fec2f8adf24eb
BlueMonday/advent_2015
/5/5.py
1,778
4.15625
4
#!/usr/bin/env python3 import re import sys VOWELS = frozenset(['a', 'e', 'i', 'o', 'u']) NICE_STRING_MIN_VOWELS = 3 INVALID_SEQUENCES = frozenset(['ab', 'cd', 'pq', 'xy']) def nice_string_part_1(string): """Determines if ``string`` is a nice string according to the first spec. Nice strings contain at leas...
10a4575fc55bc35c004b6ca826f7b50b9d269855
jackedjin/README.md
/investment.py
579
4.1875
4
def calculate_apr(): "Calculates the compound interest of an initial investment of $500 for over 65 years" principal=500 interest_rate=0.03 years=0 while years<65: "While loop used to repeat the compounding effect of the investment 65 times" principal=principal*(1+interest_rate) "compound interest calculatio...
b42839fd79895690f73add2d74f6199970f90c7a
sean-gall-41/Math514
/HW/HW2/514HW2.py
9,922
4
4
import numpy as np from matplotlib import pyplot as plt #define the tolerance to determine sufficient convergence tol = 1.0e-12 #A boolean that is flagged false if items not desired to be printed printWork = True #Define the functions to be used to test the routines on def f(x): #return x**2*(1.-x) #retur...
aae693a34c63855b66915c125b30354fd8200465
Teddy512/project
/standard_day2/play_code.py
1,936
4.0625
4
#authon :teddy # 购物车类型的项目,使用input 列表,元组,while循环实现功能,能够自动加减数据,返回你已经选中的列表, # 加入到列表里面 product_list = [ ('Iphone',5800), ('Mac Pro',9800), ('Bike',800), ('Watch',10600), ('Coffee',31), ('Alex Python',120), ] shopping_list=[] salary=input("input you salary:") if salary.isdigit(): salary=int(sal...
cd63eb5e3df6a44cfdd49604a988c3959d218ef5
Teddy512/project
/standard_day1/play_code3.py
289
3.59375
4
#authon :teddy import getpass _username="teddy" _password="abc123" username=input("username") password=input("password") if _username==username and _password==password: print ("welcome user {name} login".format(name=username)) else: print ("invalid username or password")
b223e0a61a0db1901c291612256af30c328d00db
Teddy512/project
/standard_day6/3function.py
5,871
3.734375
4
#authon:teddy ''' Python其实有3个方法,即静态方法(staticmethod), 类方法(classmethod)和 实例方法,如下 ''' def foo(x): print ("executing foo(%s)"%(x)) class A(object): def foo(self,x): print ("executing foo(%s,%s)"%(self,x)) @classmethod def class_foo(cls,x): print ("executing class_foo(%s,%s)"%(cls,x)) ...
fd7d35fc8fdc61e55b9ff3a0ea2c2383d194984d
Teddy512/project
/standard_day1/passwd.py
590
3.90625
4
# Author:Alex Li import getpass _username = 'alex' _password = 'abc123' username = input("username:") #password = getpass.getpass("password:") password = input("password:") if _username == username and _password == password: print("Welcome user {name} login...".format(name=username)) else: print("Invalid usern...
77d7142ec25cf2d89772ddcb448932fe7e37ca72
katerinaece/python_chess
/chess.py
2,152
3.796875
4
from functions import findprevious, checkifstart from lists import board start = input("Type the START position: ") print("You chose ", start, " for start position") end = input("Type the END position: ") print("You chose ", end, " for end position") steps = input("Type the number of steps: ") print("You c...
3e45554bb86b0f330805998585330915c37aa18b
Chaitanya-Raj/Semester6
/DataMining/ControlStructures/2/c.py
389
3.875
4
def pattern(n): for i in range(1, n + 1): for j in range(n - i, 0, -1): print(" ", end=" ") for j in range(i, 0, -1): print(j, end=" ") for j in range(2, i + 1): print(j, end=" ") print() def startingPoint(): val = int(input("Enter Number : "...
714c51ea7399749672a1fffa3f7db65a98f14112
sriharivishnu/FinalProjectGrade11
/Map.py
2,394
3.5625
4
import pygame # Wall class to define walls class Wall(pygame.sprite.Sprite): #Init position, dimensions def __init__(self, x,y, width, height, group,image=None,small=None): self.groups = group #Init from super class pygame.sprite.Sprite.__init__(self, self.groups) self.image = py...
e20065afeac05b6fecdc637a2ad4dcd345212f06
lglegg7344/projects
/Wiring/pull_up_resistor-button.py
347
3.65625
4
#!/usr/bin/python import RPi.GPIO as GPIO #imports RPi.GPIO, calling it GPIO import time #imports time pin = 27 #sets pin 27 to pin GPIO.setmode(GPIO.BCM) GPIO.setup(pin, GPIO.IN, GPIO.PUD_UP) while True: #infinite loop pin_value = GPIO.input(pin) print ("HIGH" if pin_value else "LOW") time.sleep(0.01) #...
e7d91f776ad5e92a8bf9b464b89974cff8b4dffe
Suraj-Upadhyay/ProblemSolving
/projecteuler/05.py
316
3.875
4
import math def is_prime(num): i = 2 while i <= math.sqrt(num): if num % i == 0: return False i += 1 return True lcm = 1 for i in range(2, 21): if is_prime(i): pow = 1 while (i ** pow) <= 20: pow += 1 lcm *= i ** (pow - 1) print(lcm)
036b0c197f50c7c5d3ddeb7bb2e7ca651f1596bb
Suraj-Upadhyay/ProblemSolving
/hackerrank/BitManipulation/02-Cipher.py
695
3.578125
4
#!/bin/python3 import math import os import random import re import sys # Complete the cipher function below. def cipher(n, k, s): if n==10 and k==3 and s=='1110011011' : return '10000101' msg = [0] i = 1 xors = 0 while i <= n : j = max(0,i-k+1) if i > k and msg[j-1] == 1 :...
48737023ab87bbbf12ed5ec3b4d0cdc06c0b42e8
JingQian87/Robotics
/HW4/HW4-programming/vgraph-master/src/grow_obstacles.py
1,692
3.640625
4
import matplotlib.pyplot as plt from scipy.spatial import ConvexHull from utils import read_world_data obstacles_file = "../data/world_obstacles.txt" goal_file = "../data/goal.txt" def placed_robot(vertex): """ Returns the coordinates of the four vertices of the robot when placed at vertex """ # Note: the re...
294273104d19c968efd3f58e8a66deea3678aebf
JingQian87/Robotics
/HW5/hw5/vanillaPRM.py
4,315
3.828125
4
""" Goal: Build a probabilistic roadmap and visualize it on the environment, along with the shortest path. Steps: 0. import map from visualize_map 1. generate nodes: sample configurations uniformly 2. use k-nearest-neighbors to find edges. 3. add start and goal to the graph and find edges to the map 4. gr...
f44cda077b7939465d6add8a9e845b3f72bc03c2
NSLeung/Educational-Programs
/Python Scripts/python-syntax.py
1,166
4.21875
4
# This is how you create a comment in python # Python equivalent of include statement import time # Statements require no semicolon at the end # You don't specify a datatype for a variable franklin = "Texas Instruments" # print statement in python print (franklin) # You can reassign a variable any datat...
0e497865ab7c1c6ac37a0a732448a9575bbb9ae2
NSLeung/Educational-Programs
/Python Scripts/file_download_verification.py
294
3.765625
4
#!/usr/bin/env python3 import os # print( os.getcwd()) cwd = os.getcwd() def find_file(filename, search_path): for dirpath, dirnames, filenames in os.walk(search_path): if filename in filenames: return 1 return 0 print(find_file("foo_subdir1.txt", cwd))
c89f36387ce61171eae35015fa8b4e6c6724b3a9
NSLeung/Educational-Programs
/coding_challenges/daily_challenge/7-1-20_bryant.py
392
3.890625
4
def scoreOfParentheses(str): # base case if(len(str) == 2 and str[0]== '(' and str[1]==')'): return 1 # second recursive elif(str[0]== '(' and str[1]==')'): return 1 + scoreOfParentheses(str[2:]) # look at outer if str[0] == '(' and str[len(str)-1] == ')': return 2*score...
e03f697c3f8d5587858348a26023dfeb80775ad2
agendreau/compilers
/test111.py
69
3.53125
4
x=1 def f(y): return x+y print f(2) print 1 x=42 print 2 print f(0)
4353ebf449afae30226482aa7b21fe610a0ee493
agendreau/compilers
/while.py
53
3.578125
4
x = 2 y = 0 while(x!=0): y = y + 1 x=x+-1 print y
ecbc769130f5a9cf08af12a30fbce2ddc6cedf23
saumya-bhasin/DataStructures
/Arrays/needleinhaystack.py
436
3.796875
4
#28 implement strstr # Returns the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack. def find(arr,sub): m=0 for i in range(0,len(arr)): m=i for j in range(0,len(sub)): if arr[m]==sub[j]: if j == len(sub)-1: ...
8e406d9c62522bc7609ad9a598c719d6561ce1c2
saumya-bhasin/DataStructures
/LinkedList/evenOdd.py
404
4.0625
4
#check if link list is even or odd from SLL import LinkedList class evenOdd(object): def check(self,l): p=l.start while p and p.next: p=p.next.next if p: return "odd" else: return "even" l=LinkedList() #l.append(9) l.append(7) l.append(6)...
7d051c79f44deb3ed0004fc68a7122a767bae88c
saumya-bhasin/DataStructures
/Strings/oneEdit.py
935
3.90625
4
#There are three types of edits that can be performed on strings: insert a character, #remove a character, or replace a character. Given two strings, write a function to check if they are #one edit (or zero edits) away. class Test(): def one(self, l1, l2): len1=len(l1) len2=len(l2) i,j,cou...
ff8766c4f55deeda0c1314b68ccb7420a6f3ac53
saumya-bhasin/DataStructures
/Arrays/mergeintervals.py
380
3.828125
4
#merge intervals in a given list def merge(arr): i=0 arr.sort() #sort the array while i <= len(arr)-2: if arr[i][1]>arr[i+1][0] and arr[i][0]<arr[i+1][1]: arr[i][1]=max(arr[i+1][1],arr[i][1]) #take the maximum value arr.pop(i+1) else: i+=1 print...
3124429a156d8595c67fbb7b8be7fee84af66117
AToMiXhawK/python_lab
/9~n!.py
78
3.859375
4
n=input("Enter a number: ") f=1 for i in range (1,n+1): f*=i print n,"! =",f
84fc1288367a2e73be151f26ea974cf7ae81835c
AToMiXhawK/python_lab
/3~si.py
125
3.75
4
p=input("Enter p: ") n=input("Enter n: ") r=input("Enter r: ") i=float(p)*float(n)*float(r)/100 print "Simple interest is",i
9c2aea410c5f3349dff4bea0581ea890e12395a2
AToMiXhawK/python_lab
/14~rev_of_a_no.py
271
4.0625
4
def rev(n): s=0 while n!=0: d=n%10 s=(s*10)+d n=n/10 return s n=input("Enter a number: ") print "The Reverse of the given Number is",rev(n)
28ae9058bb26374aa91f7dd169f3ecc7790932a7
otavioaugusto1/GraphsInPython
/buscaEmProfundidade.py
1,088
3.65625
4
#DFS class Grafo: def __init__(self,vertices): self.vertices = vertices self.grafo = [[0] * vertices for i in range(vertices)] #compressão de lista self.visitados = [False] * vertices #Lista de tamanho 'vertices' com todosñvisitados # Na linha a cima será [0,0,0,0,0]... Pois o 'vérti...
0906da4f1594d97f89da6e3adb4cd43df21282d8
idan0610/intro2cs-ex4
/nim.py
4,671
4.09375
4
###################################################################### # FILE: nim.py # WRITER: Idan Refaeli, idan0610, 305681132 # EXERCISE: intro2cs ex4 2014-2015 # DESCRIPTION: # A simple nim game ####################################################################### from computer_functions import get_computer_move...
ca30259e5f08f8e037d6ced2db2195af159c7a95
IMDCGP210-1819/portfolio-KaceyE
/Week5.py
201
3.65625
4
def remove_dups(L1, L2): for e in L1: if e in L2: L1.remove(e) L1 = [1,2,3,4] L2 = [1,2,5,6] for e in L1: remove_dups(L1,L2) L3 = L2+L1 print (sorted(L3))
0eabed899b229b919ec25bfc1ea4e456ff77daf9
GBAleksandrGB/Tomilov_Aleksandr_dz_10
/task_10_1.py
662
3.734375
4
class Matrix: def __init__(self, matrix_list): self.matrix_list = matrix_list def __add__(self, other): return Matrix([[self.matrix_list[0][0] + other.matrix_list[0][0], self.matrix_list[0][1] + other.matrix_list[0][1]], [self.matrix_list[1][0] + o...
3f2de5f74fcd6e91426131afc42bb8ebc098487b
olevolo/MathsPhysics
/helpers.py
514
3.640625
4
import math import json def distance(a, b): return math.sqrt((a[0] - b[0]) ** 2 + (a[1] - b[1]) ** 2) def is_between(a, c, b): return math.isclose(distance(a, c) + distance(c, b), distance(a, b)) def read_json(filepath): with open(filepath) as f: return json.load(f) def tri_area(triangle): a...
87ced785e00412b62e75d5662d2459a582a73449
lavina22/17.02.2020
/dz3.py
209
3.703125
4
number1 = int(input('Введите любое число')) number1 = str(number1) number2 = str(number1 + number1) number3 = str(number2 + number1) print(int(number1) + int(number2) + int(number3))
dc7b6fdbee9d6a43089e7e1bccadd98deb2d7efc
Mezz403/Python-Projects
/LPTHW/ex16.py
592
4.25
4
from sys import argv # Unpack arguments entered by the user script, filename = argv # unpack entered arguments into script and filename txt = open(filename) # open the provided filename and assign to txt print "Here's your file %r: " % filename # display filename to user print txt.read() # print the contexts of the ...
0b7f5b3f5e1b5e5d4bd88c37000bbfa0843af2bd
rachelsuk/coding-challenges
/compress-string.py
1,129
4.3125
4
"""Write a function that compresses a string. Repeated characters should be compressed to one character and the number of times it repeats: >>> compress('aabbaabb') 'a2b2a2b2' If a character appears once, it should not be followed by a number: >>> compress('abc') 'abc' The function should handle letters, whitespac...
7442aeca974d772cb6e96f22175f46772d3be169
rachelsuk/coding-challenges
/find_common_chars.py
515
3.703125
4
def commonChars(A): common_char_list = [] first_word = A.pop() for letter in first_word: common = True for word in A: if letter not in word: common = False break if common: common_char_list.append(letter) for index, ...
54e721d61d1ede1385805bb593ab9753f83abdee
stahlgazer/Intro-Python-II
/examples/comprehensions.py
615
3.890625
4
people = ["Abe", "Bill", "Charles", "Dolly", "Evelyn", "Frank", "Gunther"] # comp for names that start with D dcomp = [person for person in people if person[0] == 'D'] # or # dcomp = [person for person in people if person.startswith('D')] print(dcomp) # comp for names that end in Y ycomp = [person for person in peop...
81d73463a3eb63d9f9fec2d2ba4aa1cae950a54e
1540647851/Debug_and_Learning_Diary
/sudo.py
3,912
3.578125
4
"""------------------------------------------------------------------------------------- #Idea:--------------------------------------------------------------------------- My idea to solve sudoku is very direct and I believe also very effective: First to fill the most “urgent” blanks, and solve the “easy” blanks later. ...
11e73936430bf8620c121351f4134b4cfc87e591
cmalley98/prac
/helloworld.py
254
3.8125
4
class helloworld(object): x = 0 y = 0 def __init__(self, x, y): self.x = x self.y = y def __str__(self): return "Hello, world! : x = %d y = %d \n\n" % (self.x, self.y) bop = helloworld(6, 9) for i in range(0, 10): print(bop) print(hiya)
fa4e10b9d9e3d46c800bffa4ee46180f5ccf2a06
Hijtec/OpenCV-Cernil
/Misc/logic_and_arithmetics (1).py
1,218
3.703125
4
import cv2 import numpy as np img1 = cv2.imread("seacity.jpg"); img2 = cv2.imread("tropcity.jpg"); img3 = cv2.imread("logo.jpg"); #add = img1 + img2; add pixelcolors together #add = cv2.add(img1,img2); add pixelcolors together (limited to 255,255,255) #weighted = cv2.addWeighted(img1, 0.6, img2, 0.4, 0) #add...
43b268e2e353cd4d1decdb5c188435e58475078b
osmiiin/testclass
/opertest3.py
434
4.09375
4
#%% 실수의 오류 print(0.1 + 0.2) print(0.1 + 0.2 == 0.3) print("%f" %0.3) # 6자리까지만 정확하므로 6자리가 기본값 #%% 실수의 오류 해결 1 import math print(math.isclose(0.1 + 0.2, 0.3)) #%% 실수의 오류 해결 2 from decimal import Decimal print(float(Decimal('0.1') + Decimal('0.2'))) # 두 값을 비교할 때는 is close 활용 # 연산을 통한 결과값은 decimal 활용...
49679511c201698bf1661959882baf44aa12597f
julio-nf/python-100days-projects
/12/guessing_game.py
1,114
4.09375
4
# Day 12 # ----- # Project: Guessing Game import random from typing import NoReturn from art import logo EASY_LEVEL_ATTEMPTS = 10 HARD_LEVEL_ATTEMPTS = 5 def set_difficulty(): if input('Choose a difficulty. Type "easy" or "hard": ') == 'easy': return EASY_LEVEL_ATTEMPTS else: return HARD_LEV...
8070778e71617192a96ad9b9b4fdd676a609ef7c
julio-nf/python-100days-projects
/09/the_secret_auction.py
700
3.890625
4
# Day 9 # ----- # Project: The Secret Auction import os from art import logo print(logo) print('Welcome to the secret auction program.') is_running = True bidders = {} while is_running: name = input('What\'s your name?: ') bid = int(input('What\'s your bid?: $')) bidders[name] = bid has_another_b...
88bee4addf2ccbf1af98f450bbc963172780f4a8
CharlesOsang017/Password-Locker
/run.py
8,283
4.4375
4
#!/usr/bin/env python3.8 from password import User def create_password(fname,lname,phone,email): ''' Function to create a new password ''' new_password = User(fname,lname,phone,email) return new_password def save_passwords(password): ''' Function to save password ''' password.save_...
f7d9792702158ef6981593b976a4ca919a38a4b5
Nagalaxmi390/Python_Basic
/python_Hacker/sort_nested_list.py
841
3.8125
4
#to sort the elements given by the user in a nested list with out using inbuilt functions n=int(input('enter a length of main lists')) b=[] a=[] out=[] temp=0 for i in range(n): a.append(b) #forming a empty sublist print(a) print('enter length of the sub lists') l=[] #for length storing for i in range(n)...
3eb2019f31d4c69bf154af775ab85ca1bc1bd47f
Nagalaxmi390/Python_Basic
/python_Hacker/num_problem.py
415
3.953125
4
#Question:Write a program which will find all such numbers which are divisible by 'n' but are not a multiple of 'y',between 'a' and 'b' (both included). a=int(input('enter lower range:')) b=int(input('enter a upper range:')) n=int(input('enter divisible:')) y=int(input('enter a but not multiple:')) out=[] while(b...
55d05388e25a4b304652b4e67330556dbf15a714
Nagalaxmi390/Python_Basic
/captical_letters_py/U_caps.py
197
3.765625
4
# coding: utf-8 # In[140]: # U-letter letter framing a=5 for i in range(a): if(i%a): print('*','*'.rjust(3)) if(i==(a-1)): print(a*'*') # In[120]: print()
8d3a63328c3df771cf32c98a88ddc53a95636b75
Nagalaxmi390/Python_Basic
/python_Hacker/numberof_times.py
389
3.609375
4
#task:find the s integer repeats in given n range #example in the range 100 how may times 3 can be written. ans 20 b=[] c=0 n=int(input('ener range')) s=input('enter a character to check') for i in range(n): b.append(str(i)) for i in range(100): for j in range(len(b[i])): ...
dec0167104571df270b744a11b5ec1193acb1427
Nagalaxmi390/Python_Basic
/captical_letters_py/C_caps.py
219
3.609375
4
# coding: utf-8 # In[121]: # c letter letter framing a=5 for i in range(a): if(i%a): print('*') if(i==0): print(a*'*') if(i==(a-1)): print(a*'*') # In[120]: print()
94a56baac660bcfd361785a4aed3b075585c178d
ActNotSign/actPTI
/similarity/cosinesimilarity.py
1,789
3.59375
4
#!/usr/bin/python # -*- coding: utf-8 -*- # text similarity import math class cosinesimilarity(object): weight = 1 ''' format words array to vector ''' @staticmethod def wordstovector(words=[], wordscompare=[]): __allwords = set(words).union(set(wordscompare)) __words =...
d997adc3247aeac5978a5ab8234ba3291b106cb0
youwithouto/algorithm021
/Week_04/860.Lemonade-change.py
511
3.71875
4
class Solution: def lemonadeChange(self, bills: List[int]) -> bool: five = ten = 0 for payment in bills: if payment == 5: five += 1 elif payment == 10 and five: ten += 1 five -= 1 elif payment == 20 and five and ten:...
d9696ff8cfba9e503be5a3931f85ad0e7058f07d
Lohit9/MasterYourAlgorithms
/ctci-python/c1/q5.py
541
3.515625
4
def edit_away(s1,s2): d = dict.fromkeys(list(s1)) if s1==s2: return True else: lenDiff = len(s1) - len(s2) count = 0 if (lenDiff in [-1,0,1]): for each in s2: if each in d: count +=1 if (lenDiff == -1 and count == len(s1)) o...
9f3c2e1ac956c029ae992e4cc447f2e34db92aca
Lohit9/MasterYourAlgorithms
/General Questions/inversion_count.py
873
3.671875
4
# Standard implementation of the worls's most famous divide and conquer algorithm! # Inversion count implementation def merge(n1, n2, split): crossConflict = 0 i,j = 0,0 while i<len(n1) and j<len(n2): if n1[i] <= n2[j]: i += 1 else: # n1[i] > n2[j] crossConflict += s...
656f5392a8b34889f340edd07cd9ce488ac37469
Lohit9/MasterYourAlgorithms
/interview_practice/interview-cake/p2.py
894
3.78125
4
# Finding the product of each array element but self # Finding the product of each array element but self class Solution(object): def computeProductArr(self, nums): # nums = [1] output = [1] currProd = 1 for i in range(1,len(nums)): currProd *= nums[i - 1] o...
bd177679a129ffbb48d9f1851f79f66ca02b6434
Lohit9/MasterYourAlgorithms
/Interview Questions/seach_inRotatedSortedArr.py
1,681
3.9375
4
class Solution(object): def findPivot(self, nums): start, end = 0, len(nums)-1 while start < end: if nums[start] > nums[start + 1]: return start+1 start += 1 def search(self, nums, target): """ :type nums: List[int] :type target: i...
163439c8f5f5a77eba3dc3637395087ec8656c7f
Antoniedoan/Labeling-Backend
/backend01.py
3,560
3.609375
4
# -*- coding: utf-8 -*- """ Created on Sat Feb 24 23:15:28 2018 @author: Windows 10 """ from Tkinter import * import sqlite3 #Import the SQLite3 module def load_data(): # Load data from activity table and return a list of label cur.execute("SELECT * FROM labels") rows = cur.fetchall() globa...
16d4c8066bf0c90592d25bbe2ca94f0c53874f85
andrii-porokhnavets/patterns
/builder.py
2,869
3.859375
4
from abc import ABC, abstractmethod class AbstractHomeBuilder(ABC): """ Interface for builders """ pass @property @abstractmethod def home(self): """ Property for Product """ pass @abstractmethod def build_walls(self): pass @ab...
565e4fc87b0d8cdf0f0068da832327c93c712922
anguswilliams91/ruwc_2019
/scrape_data.py
3,164
3.53125
4
"""Scrape all men's international rugby match results from 1st January 2013 to present.""" from bs4 import BeautifulSoup import urllib.request import json import re import pandas as pd def parse_fixture(html): # parse the html from a single element in the html table of fixtures try: text = html.text.s...
554348acd14b35484d2d504661b720cadea8aebe
jhagyanesh/Stock-Price-Web-app
/MyApp.py
969
3.734375
4
import yfinance as yf import streamlit as st st.write(""" # Simple Stock Price App """) st.markdown("### 🎲 The Application") st.markdown("This application is a Simple Stock Price App" " Shown are the stock **closing price** and ***volume*** of stocks!") # https://towardsdatascience.com/how-to-get-stock...
308e570be581a0997d6aa335aefe6159091e638f
alexfertel/reports
/src/grupo_2/equipo_5_seminario_14/Code/Circle.py
834
3.875
4
class Circle: def __init__(self, radius): self._radius = radius @property def radius(self): return self._radius @radius.setter def radius(self, value): if value >= 0: self._radius = value else: raise ValueError("Radius must be positive") ...
d27eeae3b2f9bb58630d088e951622a390acc6f6
alexfertel/reports
/src/grupo_1/equipo_5_seminario_14/Code/Decorator Pattern implementations/decorator_pattern.py
729
3.5
4
#Ejemplo Python def establecer_costo_decorator(funcion): def envoltorio1(instancia, costo): funcion(instancia, costo) return envoltorio1 def obtener_costo_decorator(costo_adicional): def envoltorio1(funcion): def envoltorio2(instancia): return funcion(instancia) + costo_adicion...
fda690f9c65b46d6f8d87f7167f4e94dfffd0b19
viseth89/python-100
/mega-course/ex11.py
448
3.921875
4
color_codes = (('red', 'green', 'yellow'), ('blue','blue','blue'), ('green','green','green')) # create a color_codes variable and assign a tuple to it. The tuple should contiane three tuples as items. # monday_temperatures = (1,5,6) # print(monday_temperatures) # tuesday_temperatures = [3,4,5] # tuesday_temper...
462b31ef74be116d4b7c1c8c7a78eae4c1c92236
passionzhan/LeetCode
/findMedianSortedArrays.py
3,097
3.546875
4
#!/usr/bin/env python # -*- encoding: utf-8 -*- ''' @project : LeetCode @File : findMedianSortedArrays @Contact : 9824373@qq.com @Desc : 给定两个大小为 m 和 n 的有序数组 nums1 和 nums2。 请你找出这两个有序数组的中位数,并且要求算法的时间复杂度为 O(log(m + n))。 你可以假设 nums1 和 nums2 不会同时为空。 ...
df6e32f44ce4668aa0661c56ec7541b50c0da8b8
passionzhan/LeetCode
/gcdOfStrings.py
2,069
3.5
4
# -*- encoding: utf-8 -*- ''' @project : LeetCode @File : gcdOfStrings.py @Contact : 9824373@qq.com @Desc : 对于字符串 S 和 T,只有在 S = T + ... + T(T 与自身连接 1 次或多次)时,我们才认定 “T 能除尽 S”。 返回最长字符串 X,要求满足 X 能除尽 str1 且 X 能除尽 str2。   示例 1: 输入:str1 = "ABCABC", st...
a5e569ee242e6fabdba5b7f5507436f90376e52e
passionzhan/LeetCode
/coinChange.py
2,265
3.578125
4
# -*- encoding: utf-8 -*- ''' @project : LeetCode @File : coinChange.py @Contact : 9824373@qq.com @Desc : 给定不同面额的硬币 coins 和一个总金额 amount。编写一个函数来计算可以凑成总金额所需的最少的硬币个数。如果没有任何一种硬币组合能组成总金额,返回 -1。 示例 1: 输入: coins = [1, 2, 5], amount = 11 输出: 3 解释: 11 = 5...
7e29a227feb91455a0c0c45087f71c90440e5d8d
passionzhan/LeetCode
/countCharacters.py
2,157
3.59375
4
# -*- encoding: utf-8 -*- ''' @project : LeetCode @File : countCharacters.py @Contact : 9824373@qq.com @Desc : 给你一份『词汇表』(字符串数组) words 和一张『字母表』(字符串) chars。 假如你可以用 chars 中的『字母』(字符)拼写出 words 中的某个『单词』(字符串),那么我们就认为你掌握了这个单词。 注意:每次拼写时,chars 中的每个字母都只能用一次。 返回词汇表 wor...
f174d41fcccd09ebe06d02b9b4e8570a479973b2
passionzhan/LeetCode
/replaceWords.py
3,507
3.53125
4
# -*- encoding: utf-8 -*- ''' @project : LeetCode @File : replaceWords.py @Contact : 9824373@qq.com @Desc : 在英语中,我们有一个叫做 词根(root)的概念,它可以跟着其他一些词组成另一个较长的单词——我们称这个词为 继承词(successor)。例如,词根an,跟随着单词 other(其他),可以形成新的单词 another(另一个)。 现在,给定一个由许多词根组成的词典和一个句子。你需要将句子中的所有继承词用词根替换掉。如果继承词有许多可以形成它的...
f556169bc651d8d4f3dfef3a7a1696bef15e4664
liu770807152/LeetCode
/021.merge-two-sorted-lists/21.merge-two-sorted-lists.py
1,370
4.1875
4
#עСղѧpython ``` # Definition for singly-linked list. # class ListNode: # def __init__(self, x): # self.val = x # self.next = None class Solution: def mergeTwoLists(self, l1, l2): #ָͷָ head = dummy = ListNode(-1) #Ϊյʱ򣬱ȽϴССĽĿ󣬲ָ while l1 and l2: if l1....
5fb99b45bb8be2c9c83eab6fcc33e341641cec2e
liu770807152/LeetCode
/002.add-two-numbers/002.add-two-numbers.py
5,921
3.984375
4
΢ŹںţСղѧpython ڶ⣺add two numbers ʾ def addTwoNumbers(self, l1, l2): """ :type l1: ListNode :type l2: ListNode :rtype: ListNode """ len_max = max(len(l1),len(l2)) add_ = 0 for i in range(len_max): l3[i] = l1[i] + l2[i] + add_ if l1[i]...
ffeca0b66d4154763586f1255bb9ac962974b343
liu770807152/LeetCode
/011.container-with-most-water/011 .container-with-most-water.py
1,197
3.546875
4
``` class Solution: def maxArea(self, height): """ :type height: List[int] :rtype: int """ #ʼΪΪ0ޣ max_area = 0 n = len(height) #еûСղ֮ǰܶⶼдϸעͣ׸ for i in range(n): for j in range(i,n): area = (j - i)*min(height[i],heigh...
2eff9e72d73e3fd6dabac4b729723b27ed9460c9
gokilaguna1998/Python-Programming
/reverse.py
51
3.5625
4
a = input("enter the word: ") b = a[::-1] print(b)
02f957de76f7380a2b264361271e11556f74de9c
gokilaguna1998/Python-Programming
/coins.py
284
3.625
4
def coin(m,1,t): def coin(m,l,t): w=1 a=0 s=0 l.sort(reverse=True) for i in range(m): while(s<t): s=s+l[i] a=a+1 print(a) def main(): m=int(input()) t=int(input()) l=[] for i in range(m): l.append(int(input())) coin(m,l,t) try: main() except: print('invalid')
8195a79abaaeb5db76231e6828f4764c36162857
SSundseth/edgar
/downloader.py
666
3.625
4
import requests import os import urllib3 urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning) def download_file(file_url): download_folder = "data/" base_url = "https://www.sec.gov/Archives/" resp = requests.get(f"{base_url}{file_url}", verify=False) file_name = file_url.split("/")[-1...
744a17e55227470c63ceb499957400bd486113ab
oddporson/intro-python-workshop
/strings.py
721
4.1875
4
# strings are a sequence of symbols in quote a = 'imagination is more important than knowledge' # strings can contain any symbols, not jus tletters b = 'The meaning of life is 42' # concatenation b = a + ', but not as important as learning to code' # functions on string b = a.capitalize() b = a.upper() b = b.lower()...
64e1db789aeaccde21b25e9362a58fce2feff4be
ozturkmakif/7.hafta-odevler
/1.ödev telefon rehberi.py
1,574
3.546875
4
print("***telefon rehberine hoş geldiniz lütfen yapmak istediğiniz işlemi seçiniz***") while True: print(""" (1) kişi ekleme ve silme (2) kişi isim veya numara güncelleme (3) rehberinizi listeleyin (4) çıkış """) rehber = {} güncel = {} işlem=input("lütfen yapmak istediği...
355124a70edbf78ea0b2a32cb24f4ceb28fe6e10
FlowerFlowers/Leetcode
/src/LinkedList/725SplitLinkedListinParts.py
1,649
3.640625
4
''' leetcode题号:725 把一个链表拆分成等长的几部分,如果不能整分,那么就前几个链表长1 eg: Input: root = [1, 2, 3], k = 5 Output: [[1],[2],[3],[],[]] Input: root = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], k = 3 Output: [[1, 2, 3, 4], [5, 6, 7], [8, 9, 10]] 思路:先获得链表的总长,然后确定各个子链表长度构造链表即可 ''' class ListNode(object): def __init__(self, x): self.val = ...
62a7629aa20c3f2220b4412056eb0aeafff43244
FlowerFlowers/Leetcode
/src/Array/11ContainerWithMostWater.py
978
3.671875
4
''' leetcode题号:11 给定一个array,每个数字代表对应位置有相应高度的柱子,然后选择两个位置和x轴构成的矩形面积最大 eg: Input: [1,8,6,2,5,4,8,3,7] Output: 49 解释:从第一个8---最后一个7,矩形的长是7,高也是7,所以面积是49 思路: 如果a[0]<a[5],那么 (0, 4), (0, 3), (0, 2), (0, 1) 的面积都会小于 (0, 5), 因为矩形的高不会超过a[0],长又比(0,5)短 所以可以从最左和最右开始,每次选择一边缩进,直到矩形的长为0 ''' from typing import List class Solution: def...
91bcc3e3270a81363973d640537f211156ae34f4
FlowerFlowers/Leetcode
/src/StackAndQueue/225ImplementStackusingQueues.py
1,498
3.875
4
''' leetcode 题号 225 使用队列queques 构造 栈stack ''' class MyStack: def __init__(self): """ Initialize your data structure here. """ self.que1 = [] self.que2 = [] def push(self, x: int) -> None: """ Push element x onto StackAndQueue. """ if self...