blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
983c771a5cc847922c06bcde64016d7761467a2c
YGragon/PythonSelfStudy
/test_case/case22.py
740
3.671875
4
# 题目:两个乒乓球队进行比赛,各出三人。甲队为a,b,c三人,乙队为x,y,z三人。已抽签决定比赛名单。 # 有人向队员打听比赛的名单。a说他不和x比,c说他不和x,z比,请编程序找出三队赛手的名单。 #!/usr/bin/python # -*- coding: UTF-8 -*- # ord() : 返回单字符在ASCII中对应的整数 for a in range(ord('x'),ord('z') + 1): for b in range(ord('x'),ord('z') + 1): if a != b: for c in range(ord(...
6f83e05994cbc3999fffcd69829e97af2134ad65
bhavyay/git_clone
/utils.py
597
3.5625
4
import os def repo_file(repo, *path, mkdir=False): if (repo_dir(repo, *path[:-1], mkdir=mkdir)): return repo_path(repo, *path) def repo_path(repo, *path): """Compute path under repo's gitdir.""" return os.path.join(repo.gitdir, *path) def repo_dir(repo, *path, mkdir=False): """Same as repo_path, but mkd...
5924adb1df7bc6ea11f59744a44cd9074db77572
KernelDeimos/mines-python-pygame
/mines/minesboard.py
6,125
3.671875
4
import pygame.freetype as fonts import sys, pygame """ This module contains the Minesweeper board - GameBoardTile - GameBoard """ class GameBoardTile: def __init__(self): self.isMine = False self.isVisible = False self.isFlagged = False self.value = 0 self.font = None def is_mine(self, value=None): ...
bab247771025074a1ab56a02fad99ba004fb777e
geek312/Python-excerise
/plot1.py
624
3.796875
4
from turtle import Turtle def tree(tList, length, angle, factor): if length > 5: lst = [] for t in tList: t.forward(length); temp = t.clone(); t.left(angle); temp.right(angle); lst.append(t); lst.append(temp); tree(lst...
57dbd97c0abbc7643c139f4e4646963b7229d947
alvesouza/ces-22
/aula 15/fabricaAb.py
1,256
3.859375
4
#O padrão Fábrica Abstrata oferece interfaces para uso e criação #sem especificar suas classes. Ele funciona da seguinte forma: o cliente interage #com a fábrica abstrata, a qual poderá utilizar uma de diversas implementações #da fábrica concreta para instanciar um objeto. O cliente receberá um objeto #abstrato da requ...
7604b3e33b5ef35af21d73ee1e4ee1d98a54e560
ThiagoBaader/Beginner-Python-Projects
/Web scraper to get news article content/ScrapeArticle.py
1,082
3.6875
4
# Library imports import requests from bs4 import BeautifulSoup def scrapeArticle(URL): """ Web scraper to get news article content :param URL: the url of the article to be scrapped :return: the article html parsed and the article content """ page = requests.get(URL) soup = BeautifulSoup(...
de8f88a03fc04ac6c30ff2f618c06f2a5f05da0f
samux87/nd013-1
/04_18/multilayer_perceptron.py
1,127
3.875
4
# import numpy as np # from data_prep import features # # # Number of records and input units # n_records, n_inputs = features.shape # # # Number of hidden units # n_hidden = 2 # weights_input_to_hidden = np.random.normal(0, n_inputs**-0.5, size=(n_inputs, n_hidden)) # # hidden_inputs = np.dot(features.values, weights_...
1bae1b763c3da0f535aa9bdcca09249eaa31c816
chaviotics/ZTM-Complete-Python-Developer
/6. Advanced Python Object Oriented Programming/22. Multiple Inheritance.py
1,103
3.625
4
class User(object): def sign_in(self): return "Signed In" def attack(self): print("Do nothings") class Wizard(User): def __init__(self, name, power): self.name = name self.power = power def attack(self): # User.attack(self) # goes to user class and then ...
6f25a01dab3208a16ef9fef56bedd274b2d12bfc
fishleongxhh/LeetCode
/DynamicProgramming/3_LongestSubstringWithoutRepeatingCharacters.py
882
3.875
4
# -*- coding: utf-8 -*- # Author: Xu Hanhui # 此程序用来求解LeetCode3: Longest Substring Without Repeating Characters问题 def lengthOfLongestSubstring(s): #res[i]记录以s[i]结尾同时不包含重复字符的最长连续子数组的长度 #dic用来记录一个字符上次出现的位置 res, dic = [0]*len(s), {} maxLen = 0 #用来记录最大长度 for i, item in enumerate(s): if item not ...
673de1c250f5758a75841cb61641f8316ac9d7a7
BayesForDays/distribu_ted
/word2vec/word2vec.py
2,802
3.65625
4
#!/usr/bin/env python # coding: utf-8 # # Training a skip-gram (word2vec) model on a small TED talk corpus # ### Prerequisites: pandas, gensim, nltk, plotnine, and UMAP # In[1]: import pandas as pd from umap import UMAP from plotnine import * from nltk.tokenize import word_tokenize from gensim.models.word2vec impo...
fa115dc7dcea3b0f00bd16a411ecc266f0d0caaa
aasthagoyal46/Encryption
/Asgn_10/ECC.py
2,043
3.859375
4
# Defining initial values for global variables s1 = 1 s2 = 0 t1 = 0 t2 = 1 inv = 0 g = 1 p = 1 # Function to calculate multiplicative inverse - Used from previous assignments def mulInverse(r1, r2, s1, s2, t1, t2): global inv global g global p q=r1//r2 r=r1%r2 s=s1-q*s2 t=t1-q*t2 # Iterate till remainder is n...
91c24e7c1b771cc9036af25f12263eaa8150b514
1605125/newthing11
/decision making.py
416
3.859375
4
a=13 if a==10 : print("A: {0}".format(a)) elif a==12: print("A: {0}".format(a)) elif a==13: print("A: {0}".format(a)) else: print("else block") # nested if a1=10 b=11 c=122 if(a1==10): if(b==11): if(c==12): print("Done") else: print("Failed at c check point") ...
af77c294cb7216c864e1da4d3e9e41e5cab4fd81
eileencuevas/Graphs
/projects/adventure/queue.py
422
3.65625
4
class Queue: def __init__(self): self.queue_size = 0 self.storage = [] def enqueue(self, item): self.queue_size += 1 self.storage.append(item) def dequeue(self): if self.queue_size > 0: self.queue_size -= 1 return self.storage.pop(0) def...
9b246ec8a39207fd969fff5d91aa929924c5930a
mooja/dailyprogrammer
/challenge107easy.py
1,242
3.703125
4
#!/usr/bin/env python # encoding: utf-8 # Daily Programmer Challenge 107 Easy # # http://www.reddit.com/r/dailyprogrammer/comments/122c4t/10252012_challenge_107_easy_all_possible_decodings/ # # May.11.2015 from string import ascii_lowercase from itertools import combinations def break_down(num): digits = list...
5fa426430c77a0c676893149904b2dc7c07348c5
SpokoSpartan/GeneticAlgorithm
/History.py
388
3.6875
4
import matplotlib.pyplot as plt class History: def __init__(self, history): self.history = history def print_plot(self): start = 5 stop = len(self.history) step = 2 plt.figure(figsize=(12, 8)) plt.plot([i for i in range(start, stop, step)], self.history[start:s...
3476001e15c24a54fa379573e8b315c00f571d14
erinnlebaron3/python
/python_import/libs/helper.py
592
3.5
4
# just function with new file made in terminal # all in python terminal without print def greeting(first, last): return f'Hi {first} {last}' # >>> import helper # >>> helper.greeting('Erinn', 'LeBaron') # 'Hi Erinn LeBaron' # >>> # # also works with just putting print # def greeting(first, last): # return ...
77fdf6eadd47a1530e84ba05032909e1215eebc5
yanyan1161/CC2020
/Question2.py
488
3.625
4
# You may change this function parameters def findMaxProfit(numOfPredictedTimes, predictedSharePrices): # Participants code will be here return -1 def main(): line = input().split() numOfPredictedTimes = int(line[0]) predictedSharePrices = list(map(int, line[1:])) answer = findMaxProfit(numOfP...
bc2e6400b8ebd319fcdfc54279b21a65408b640a
bhaskarfx/Programming-in-Python
/dogClass.py
360
4.15625
4
class Dog: species = 'mammal'; print('In class Dog is', species); print('In class Dog'); def __init__(self, age, name): self.age=age; self.name=name; def bark(self): for i in range (1, self.age): print('bark'); tom=Dog(7, ...
82252a56ea9d5b61aba6c29793d78f1414c630c0
eLtronicsVilla/Opencv-Tutorial
/Python-work/drawing.py
372
3.84375
4
#Define the dimention of the image , create the image with numpy arrays ,Create black background by filling the array with zeros.Implement drawing functions. import numpy as np import cv2 pic = np.zeros((500,500,3), dtype = 'uint8') cv2.rectangle(pic, (0,0), (500,150), (123,200,98),3,lineType=8,shift=0) cv2.imshow(...
23421d998f009eeac27da1029d9638be6155d654
MrHamdulay/csc3-capstone
/examples/data/Assignment_7/bswamy001/util.py
1,570
3.515625
4
"""" Amy Bosworth, Assignment 7, Question 2""" #create a 4x4 grid grid=[] def create_grid(grid): for row in range (4): grid.append ([0] * 4) def print_grid (grid): print('+','-'*20,'+',sep='') for row in range(4): print('|',end='') for col in range (4): if grid[row][col]==0: ...
c4fe44a368aff265385038d30ed27885bc044faa
YI-DING/daily-leetcode
/garbage.py
202
3.515625
4
def mySqrt(x): if x==1:return 1 l=0 r=x while 1<=r: mid=(r+1)//2 if mid*mid <=x<(mid+1)*(mid+1): return mid elif x<mid*mid: r=mid else: l=mid print(mySqrt(12379237))
d25539f85047001a8a55b4157f300a3fd54fa389
rob-by-w/Invent-with-Python
/Chapter_32_Gullible/Gullible.py
425
3.5
4
if __name__ == "__main__": print('Gullible') while True: print('Do you want to know how to keep a gullible person busy for hours? Y/N') userAnswer = input('> ') if userAnswer.lower() in ['n', 'no']: break if userAnswer.lower() in ['y', 'yes']: continue ...
f1a66192156a0cc710a593627f865af5feb881ef
AngelValAngelov/Python-Basics
/While-Loop - Lab/08. Graduation pt.2.py
619
3.921875
4
name = input() year_mark = float(input()) years = 1 result = 0 count_bad_marks = 0 while years <= 12: if year_mark >= 4.00: years += 1 result = result + year_mark if years == 13: print(f"{name} graduated. Average grade: {result / 12:.2f}") break ...
0a0729ac98b115b342c9ada848b1d312bf207767
JavaRod/SP_Python220B_2019
/students/mint_k/lesson05/assignment/codes/database.py
5,855
3.671875
4
"""This is for lesson05""" import os import csv import logging from pymongo import MongoClient logging.basicConfig(level=logging.INFO) LOGGER = logging.getLogger(__name__) class MongoDBConnection(): """MongoDB Connection""" def __init__(self, host='127.0.0.1', port=27017): """ be sure to use the ip ...
dfd9d96ed9ed96a014403e54f29f041283b55c71
rain-zhao/leetcode
/py/Task72.py
1,686
3.640625
4
# 给你两个单词 word1 和 word2,请你计算出将 word1 转换成 word2 所使用的最少操作数 。 # 你可以对一个单词进行如下三种操作: # 插入一个字符 # 删除一个字符 # 替换一个字符 #   # 示例 1: # 输入:word1 = "horse", word2 = "ros" # 输出:3 # 解释: # horse -> rorse (将 'h' 替换为 'r') # rorse -> rose (删除 'r') # rose -> ros (删除 'e') # 示例 2: # 输入:word1 = "intention", word2 = "execution" # 输出:5 # 解释: #...
ae79b48997aba4b57074319a094fe5684b40d275
rafaelperazzo/programacao-web
/moodledata/vpl_data/445/usersdata/328/102535/submittedfiles/matriz2.py
137
3.859375
4
# -*- coding: utf-8 -*- while n<2: n=int(input('Digite a dimensão da matriz:')) linhas=n colunas=n m=([linhas,colunas]) print(m)
674c27f5d96cde2cc5b1a8948c5f2824534aa47e
wojciodataist/Turtle-stuff
/turtle_race.py
3,700
3.703125
4
import turtle import time import math from turtle import * from random import randint turtle.setup(1000,800) turtle.bgcolor('forestgreen') turtle.hideturtle() #Track outline drawing with a color fill track = turtle.Turtle() track.speed(0) track.penup() track.setpos(-180,310) track.pendown() track.showturtle() track....
2334daec8b3cc39bd2ea1a09d0e193cc1aca0d1e
superhg2012/cs208
/File-I-O/IO_test.py
988
3.875
4
##### creating file objects for input(test.txt) and output(morgan.txt) ##### input_file = open('test.txt', 'r') output = open('morgan.txt', 'w') ##### Find number of characters in file ##### num_chars = len(input_file.read()) input_file.seek(0) ##### Find # of lines in file and # of words per line ##### line_words =...
5b792fd66f744cf08742a217c00cd9fe72efd141
wOutlaw/projecteuler
/python/problem4.py
368
3.984375
4
''' A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 × 99. Find the largest palindrome made from the product of two 3-digit numbers. ''' l = 0 for i in range(100, 999, 1): for j in range(100, 999, 1): n = i * j if str(n) =...
8a786a9682530be736bd15fa195539b24b64f4b9
yangzongwu/leetcode
/20200215Python-China/0728. Self Dividing Numbers.py
1,081
4.125
4
''' A self-dividing number is a number that is divisible by every digit it contains. For example, 128 is a self-dividing number because 128 % 1 == 0, 128 % 2 == 0, and 128 % 8 == 0. Also, a self-dividing number is not allowed to contain the digit zero. Given a lower and upper number bound, output a list of every pos...
d6abad376e95f75f93c841c711b22acbbe1a2790
Shaker-Hussien/udemy-stores-rest-api
/models/user.py
1,564
3.515625
4
import sqlite3 from db import db class UserModel(db.Model): __tablename__ = "users" id = db.Column(db.Integer, primary_key=True) username = db.Column(db.String(80)) password = db.Column(db.String(80)) def __init__(self, username, password): self.username = username self.password ...
629ad709425366d65b022e9cd93489dae9dde92a
ABenxj/leetcode
/150 evalRPN.py
904
3.59375
4
#!/usr/bin/env pyhton # -*- coding: utf-8 -*- # # Copyright (c) 2021 , Inc. All Rights Reserved # """ Authors: jufei Date: 2021/5/26 7:34 上午 """ from typing import List class Solution: def evalRPN(self, tokens: List[str]) -> int: """ :param tokens: :return: """ ans = [...
776ff2f2858a235c506a970ae057e43e02f9d121
l0rennareis/Algoritmo
/Tabuada.py
107
3.8125
4
l=int(input("digite o valor: ")) x=0 while (x<=10): print ("%d x%d = %d" % (l, x, l*x)) x=x+1
d40e7be91028b1cd30e5656804f429ecb5af76c0
jordancharest/Deep-Learning
/Artificial-Neural-Networks/ann.py
4,831
3.859375
4
# Artificial Neural Network # Data Preprocessing import numpy as np import pandas as pd # Import the dataset dataset = pd.read_csv('Churn_Modeling.csv') X = dataset.iloc[:, 3:13].values y = dataset.iloc[:, 13].values # Encode categorical data (country and gender) from sklearn.preprocessing import LabelEncoder, One...
43e8da4d51596953bc6cda165dc5414c68d29296
111110100/my-leetcode-codewars-hackerrank-submissions
/leetcode/missingNumber.py
1,718
3.65625
4
class Solution: def missingNumber(self, nums): n = min(nums) o = max(nums) for _ in nums: n += 1 o -= 1 if n not in nums: return n if o not in nums: return o return class Solution2: def missingNumb...
95552782f389f3472c9b2b4c7e183b2b7bf4976b
AngelBlack18/Progra-Avanzada-01
/Tkinter.py
779
3.5625
4
from tkinter import * root = Tk() #etiqueta= Label(root,text ="pelada",bg="purple") #etiqueta.pack() topFrame= Frame(root) topFrame.pack() bottomFrame = Frame(root) bottomFrame.pack(side=BOTTOM) def comando1(): print("Rojo") def comando2(): print("Azul") def comando3(): print("Naraja") def comando4(): ...
4d0b5bc04e56aee0ae6a163287ee0f8e03368c54
bbriano/daily-coding-problem
/2021-03-06:order_log.py
1,003
3.578125
4
class Node: def __init__(self, val): self.val = val self.next = None class OrderLog: def __init__(self): self.head = None def record(self, order_id): """ adds order_id to the log Time: O(1) """ new_order = Node(order_id) new_order.ne...
4a310c9cf89d17dcce1ce0f57d39ada19f367797
rsquir/learning-ai-python
/old_projects/not_ai/music_tree.py
666
4
4
class Node(object): def __init__(self, data): self.data = data self.children = [] def add_child(self, obj): self.children.append(obj) m_i = Node('c') m_i_i = Node('c') m_i.add_child(m_i_i) m_i_i_i = Node('c') m_i_i.add_child(m_i_i_i) m_i_i_ii = Node('d') m_i_i.add_child(m_i_i_ii) m_i...
1843ae1e2a9b480d8175cf52ec6863132a46d105
kumopro/pro-tech
/lesson4/challenge4.py
529
3.71875
4
def print_name_age(name, age): print("Name: " + name) print("Age: {}".format(age)) if age >= 65: price = 6700 elif age >= 18: price = 7400 elif age >= 12: price = 6400 elif age >= 4: price = 4800 else: price = 0 if price > 0: print("Price...
9d4a7b48d5de0319caf1dc3ef4f3a4ae84d1871a
dalaAM/month-01
/day05_all/day05/exercise08.py
208
3.9375
4
list01 = ["北京",["上海","深圳"]] list02 = list01 list03 = list01[:] list03[0] = "北京03" list03[1][1] = "深圳03" print(list01) # ? list02[0] = "北京02" list02[1][1] = "深圳02" print(list02) # ?
09a55e65cd105c20bf22f5abad83898a732760d2
sgarcia031/programacionces
/Clases/ejemploswhile.py
836
4.25
4
#--Entradas---# MENSAJE_BIENVENIDA = 'Muy buenos dias, despierte que estamos en clase de 6' PREGUNTA_MENU = ''' Ingrese: 1. Para mostrar los numeros del 1-5 2. Para preguntar tu nombre 3. Para mostrar el año en el que estamos 4. Salir ''' PREGUNTA_NOMBRE = "Cual es su nombre?: " MENSAJE_ERROR = 'Por fa...
053a585d3bcd09a0894207c78bcedf573e6f5a60
JerinPaulS/Python-Programs
/NumberToHexa.py
914
4.1875
4
''' Given an integer num, return a string representing its hexadecimal representation. For negative integers, two's complement method is used. All the letters in the answer string should be lowercase characters, and there should not be any leading zeros in the answer except for the zero itself. Note: You are not allo...
0f6376b7347525ed97feec1b443b21e81ee523fc
RachelYang02/ToolBox-WordFrequency
/frequency.py
2,094
4.21875
4
""" Analyzes the word frequencies in a book downloaded from Project Gutenberg """ import string from nltk.corpus import stopwords def get_word_list(file_name): """ Reads the specified project Gutenberg book. Header comments, punctuation, and whitespace are stripped away. The function returns a list of the w...
d04ba1fe6a76e59724b7b878b0fbe9da6302e83e
ljia2/leetcode.py
/solutions/trie/425.Word.Squares.py
6,810
3.859375
4
# from collections import defaultdict # # class Solution: # def wordSquares(self, words): # """ # Given a set of words (without duplicates), find all word squares you can build from them. # # A sequence of words forms a valid word square if the kth row and column read the exact same string, ...
0791118e48e7785c852bd22fade36d532425b4b9
WorldOnAScreen/BouncingBallSimulation
/StackedBalls.py
3,426
4.15625
4
# Bouncing Balls Simulation # WorldOnAScreen (https://www.youtube.com/channel/UCJCSiOFqLz9sg6WZQ225jBg) # Created 14th September 2015 # vv is the vertical velocity # sv is the vertical displacement import pygame import random import math # Constants (Created through trial and error rather than using SI units) g =...
02e64eb10b130db04c5782791116b92ce8661715
sinha414tanya/repo2
/linear_search.py
389
3.90625
4
num=(int(input("Enter a number to be searched "))) array=list(map(int,input("Enter the elements ").split())) def linear_search(num,array): if num in array: return True else: return False if linear_search(num,array)==True: print("{} - found! Search successfull!!" .format(num)) el...
1b1840049422505578e831941f4accfe7f117bf1
Sophia-PeiJin-SU/100-Days-of-Code
/Day4-list/rock-paper-scissors-start.py
1,197
4.0625
4
import random rock = ''' _______ ---' ____) (_____) (_____) (____) ---.__(___) ''' paper = ''' _______ ---' ____)____ ______) _______) _______) ---.__________) ''' scissors = ''' _______ ---' ____)____ ______) __________) (____) ...
6b38691a16bd8c2f3118798d4c1c639f2ed62bc4
Emily9023/Projects_Seam_Carving
/gomoku.py
23,553
4.34375
4
"""Gomoku starter code You should complete every incomplete function, and add more functions and variables as needed. Note that incomplete functions have 'pass' as the first statement: pass is a Python keyword; it is a statement that does nothing. This is a placeholder that you should remove once you modify the ...
4f5a06931785c8b616efe7a4b676fcf991cf914e
RicardoMart922/estudo_Python
/Exercicios/Exercicio047.py
1,737
4.09375
4
# Crie um programa que faça o computador jogar Jokenpô com você. from random import randint from time import sleep computador = randint(0, 2) print('Suas Opções:') print('[ 0 ] - PEDRA\n[ 1 ] - PAPEL\n[ 2 ] - TESOURA') jogador = int(input('Qual é sua jogada? ')) print('JO') sleep(1) print('KEN') sleep(1) print('PÔ!!!')...
e50f1063b59175979e0061e59f7ea3d654ac4b6e
SubhamDyno/Python
/StringManipulation.py
1,694
4.46875
4
import operator Str = "Hello I am a small string and i have less than 30 words" print(f"Printing the String:\n\n{Str}") Length = len(Str) print(f" \n1. Length of the string is : {Length}\n") #Manupulation of Index in a String print("2. Index Char") for i,j in enumerate(Str): print(i,"\t\t",j) Set = set(Str...
ee9ad71ab7008fb3c9c9429bbc85d8b3910a1d85
SSSD/sssd-gdb
/sssd_gdb/printers/__init__.py
357
3.5625
4
import textwrap class PrettyPrinter(object): def __init__(self, val): self.val = val def to_string(self): raise NotImplementedError('to_string method is not implemented') def use(self, cls, val): return cls(val).to_string() def indent(self, cls, val): return textwrap...
c348cd3d7276e533942ccaf0842ea0c9214c5b5c
adnan-77/data_science
/5th May Assignments/case study 2/question_2.py
195
4.65625
5
# 2.What will be the output? # d ={"john":40, "peter":45} # print(list(d.keys())) # It will select all keys of dictionary that is ["john", "peter"] # So output will dict_keys(['john', 'peter'])
8698b1bea026e1a2e577305161b4f13ae9b98c63
evan-leung/Group-Project
/catFun.py
5,816
4.15625
4
import runWorld as rw import drawWorld as dw import pygame as pg ################################################################ # This program is an interactive simulation/game. A cat starts # to move across the screen. The direction of movement is reversed # on each "mouse down" event. # # The state of the cat is ...
b31cb7bdd32635acb4f735eeb9e798fd0eab73d9
H-Cong/LeetCode
/14_LongestCommonPrefix/14_LongestCommonPrefix_2.py
794
3.703125
4
class Solution: def longestCommonPrefix(self, strs: List[str]) -> str: # Vertical Scan if not strs: return "" for i in range(len(strs[0])): c = strs[0][i] for j in range(1, len(strs)): if i > len(strs[j]) - 1 or c != strs[j][i]: ret...
393dedf22e1db541454d558767c173c6aefdae91
Jeong-AYeong/a-star-pathfinding
/maze-solver/main.py
3,799
3.90625
4
""" Maze solver using A* algorithm. """ import pygame from graph import Graph from maze import generate_maze from constants import WIDTH, HEIGHT, ROWS, COLUMNS, PADDING, NODE_SIZE from a_star import a_star from buttons import Button pygame.init() # Set up window BACKGROUND = (0x00, 0x17, 0x1F) WINDOW = pygame.display...
7bb79a7dd5557d4127e6550232f53f22ea607476
Deepikap7801/the-united-sparks
/addition/addition.py
77
3.859375
4
addition function def addition(): a=5 b=10 add=a+b print(add)
315e7647982dd1cec23637aa7935e27491e301e4
yang00-74/python_demo
/demo/test1.py
1,939
3.578125
4
# -*- coding:utf-8 -*- __all__ = ['func'] # x = 0 # while x < 100: # x += 1 # print x # else: # print 'count end' for i in "i am a little children".split(' ') : print i, if len(i) > 3: print "more than 3" # for 最后一个遍历的值将被保留 else: print i # 按照原本顺序输出字符串中出现过的字符 a = "AdmlkjjghgfgfaA" a_lis...
471c5c36cae51f6c6c0df7919f76a27395439873
dnewbie25/App-Academy-Python-Version
/Intro to programming with Python/Dictionaries Exercises/AE_count.py
399
3.984375
4
def ae_count(str): hash = {} arr_from_str = list(str) for char in arr_from_str: if (char == 'a' or char == 'e') and (char not in hash.keys()): hash.update({char: 1}) elif char == 'a' or char == 'e': hash[char] += 1 return hash print(ae_count("everyone can progr...
a610379d89347f357b7c784b809e4de7262cfac6
ConnorH2582/abc-bank-python
/abcbank/account.py
2,368
3.578125
4
from abcbank.transaction import Transaction from datetime import datetime, timedelta class Account: def __init__(self, accountType): self.accountType = accountType self.dateOpened = datetime.now() self.transactions = [] self.balance = 0 self.account_age_in_days = (datetime.n...
e96b84b7bb05e8221527416e5c01d8db22357590
SynTentional/CS-1.2
/Coursework/stackExamples/main.py
1,003
4.0625
4
class Stack: def __init__(self): self.items = [] #Checks to see if closings are balanced def isBalanced(expr): stack = [] for char in expr: if char in ["(","{","["]: #Add that character to the stack stack.append(char) else: #If the character is not an ...
84bbb725dfd51096e389027678ef8e53dfb76849
atgarg11/pProject
/queue.py
937
3.859375
4
from heaps import min_heap from heaps import max_heap class min_queue(min_heap): def __init__(self,n = [1,3,2,4]): min_heap.__init__(self,n) class max_queue(max_heap): def __init__(self,n = [1,3,2,4]): max_heap.__init__(self,n) class lnode: def __init__(self, key = None, data = None): ...
b10ca9ac29316b2d29a7aea860d6cfe86dec6c97
Dark-C-oder/practice1
/venv/practice-GUI.py
5,393
3.5
4
from tkinter import * from practice import * def onClickSubmit(): cRef = customer(None, None, None) cRef.name = entry_name.get() cRef.phone = entry_phone.get() cRef.email = entry_email.get() cRef.showCustomerDetails() db= dbHelper() db.saveCustomerInDB(cRef) def onClickUpdate(): ...
2408e7fa8b553e8e6aa395c800d1ca695d30770c
cedie1/Python_guanabara_100-exerc-cios-
/ex12.py
262
3.625
4
#faça um algoritimo que leia o preço de produto e mostre seu novo preço, com 5% de desconto. #Resolução preco = float(input("Digite o valor da peça: ")) valor_final = preco - (5/100)* preco print(f"Com o desconto de 5% o valore ficará R${ valor_final}")
9db0cade4f260b99109424d3305f05dad95082ab
ShihabAhmed09/HackerRank-Solutions-Python
/30 Days Of Code/Day_28_RegExPatternsAndIntroToDatabases.py
449
3.71875
4
import re if __name__ == '__main__': N = int(input()) data = [] for N_itr in range(N): firstNameEmailID = input().split() firstName = firstNameEmailID[0] emailID = firstNameEmailID[1] # email_pattern = r"^[a-z.]+@gmail\.com$" email_pattern = r".*@gmail\.c...
e62d8786e573c32ffb5b0e8a8e43db92c3a792fe
bobcaoge/my-code
/python/leetcode/1073_Adding_Two_Negabinary_Numbers.py
1,224
3.65625
4
# /usr/bin/python3.6 # -*- coding:utf-8 -*- class Solution(object): def addNegabinary(self, arr1, arr2): """ :type arr1: List[int] :type arr2: List[int] :rtype: List[int] """ pos1 = len(arr1)-1 pos2 = len(arr2)-1 ret = [] carry = 0 wh...
32943f2271a9000dda7a11bf822898ae2b6b9fa0
alex-bo/leetcode
/Valid Parentheses - LeetCode.py
773
3.9375
4
class Solution: def isValid(self, s: str) -> bool: stack = [] for c in s: if c in ('{', '(', '['): stack.append(c) elif stack and ( (c == ')' and stack[-1] == '(') or (c == ']' and stack[-1] == '[') or ...
c947ca6c7c25b05491399e884a3caa9cb47fe4ce
GolamRabbani20/PYTHON-A2Z
/PROBLEM_SOLVING/HackerRank/Algorithms_431/Easy_118/HackerRankInAString.py
251
3.703125
4
import re def hackerrankInString(s): print('YES' if re.search(r'.*h.*a.*c.*k.*e.*r.*r.*a.*n.*k.*',s) else 'NO') #print( (re.search('.*'.join("hackerrank"), s) and "YES") or "NO") for k in range(int(input())): hackerrankInString(input())
1d15405552dbfa53cc001c593d39e67573601150
vijay-Jonathan/Python_Training
/bin/38_Day_4_Summary.py
1,196
3.640625
4
""" Summary """ """ Complete Python Programming Language Structure ----------------------------------------------- Part-1 : Python Language (Basic to Advance Python Programming Language) a) Data Types : int, float,hex,bin,oct,str,list,tuple,set,dict,frozenset b) Conditional statements (if,if-el...
66e33f2fd4828f1a82f64cfcccb83532caf6c1d2
AriFleischer13/CSC15-Python
/as7/minime.py
1,059
3.6875
4
# return the sum of of an array of integers def getSum(arr): iSum = 0 for idx in arr: iSum += idx; return iSum; # return the number of odd numbers in an array def getCountOdd(arr): cOdd = 0 for x in arr: if x%2!=0: cOdd +=1 return cOdd; # return the max of an array of numbers def getMax(arr): max = arr[...
1ce2d37622db2916f2c30035c909a5e769c0e58e
raianmol172/data_structure_using_python
/Tree_data_structure/Binary_tree/invert_tree.py
774
3.828125
4
class Node: def __init__(self, data): self.data = data self.left = None self.right = None def preorderTraversal(root): if root is None: return None else: print(root.data, end=' ') preorderTraversal(root.left) preorderTraversal(root.right) def inver...
a8a0f6b12f8cf5bf883de855adc93fc129ca637f
HarshaRathi/PPL-Assignment
/Assign3/pentagon.py
699
4.125
4
import turtle class pentagon(): def __init__(self,arr = 50): self.__sides = arr def get_sides(self): return self.__sides def draw(self): t = turtle.Turtle() t.forward(self.__sides) t.left(72) t.forward(self.__sides) t.left(72) t.forw...
5ee93a6caa956a98886ed7b60fe323ecee594c2a
alhamzah/Project-Euler
/p016.py
501
3.625
4
def find_digits_of_power(n): num = [1] def helper(num): new_numb = [0]*(len(num)+1) for i in range(len(num)): current = 2*num[i]+new_numb[i] first_dig = (current % 10) new_numb[i] = first_dig if current > 9: new_numb[i+1] = (current-first_dig)//10 ...
f94ce117c9ad98c53a885399b8f624acccb069d7
Pradumnasaraf/Python-notes
/13 While Loops.py
259
3.859375
4
i =0 while i<5: print(" * "*i) i = i+1 print("Done") win_guess = 9 i=1 while i <= 3: user_guess = input(f"Guess {i} : ") i= i+1 if int(user_guess) == win_guess: print("You Win") break else: print("You Loose")
a30b2590121c5edc41837c1f105bb83e9e7e81c1
PykeChen/pythonBasicGramer
/sudo.py
1,545
3.5
4
class Solution: def isValidSudoku(self, board) -> bool: # 每行的元素以一个字典储存,key是数字,value统一为1. dic_row = [[], [], [], [], [], [], [], [], []] dic_col = [[], [], [], [], [], [], [], [], []] dic_box = [[], [], [], [], [], [], [], [], []] for i in range(len(board)): for j...
f8c47d41b6ccab3b1c8297e53a9d22bdcb082e20
Bernatovych/DZ_11
/phone_book.py
3,567
3.625
4
from datetime import datetime from collections import UserDict class AddressBook(UserDict): def add_record(self, record): self.data[record.name] = record def iterator(self, n): data_list = list(self.data.values()) while data_list: for i in data_list[:n]: yi...
bb8a224f78549aa6b1206bac1eedf00899f5f33d
rlampe2/Advent_of_Code2016
/Day12/one.py
2,053
3.546875
4
# Author: Ryan Lampe # 6/7/2020 # Advent of Code 2016 # Day 12, Problem 1 # Building part of a "simple processor!" Reminds me of my 230 days :) import copy class simple_processor: def __init__(self): # Build registers self.registers = {'a': 0, 'b': 0, 'c': 0, 'd': 0} # Build instruction ...
30d46ef025a223182362f1712e19549092f7459f
jennings/project-euler
/python/004-palendromic-product.py
655
4.28125
4
# A palindromic number reads the same both ways. The largest palindrome # made from the product of two 2-digit numbers is 9009 = 91 99. # # Find the largest palindrome made from the product of two 3-digit # numbers. def is_palendromic(n): nstr = str(n) nstrrev = nstr[::-1] return nstr == nstrrev def find...
e779285cd2ec9f9f80cb08b262f79c5ad2ba48ab
juaniscarafia/AnalisisNumerico
/Regresion/Lagrange.py
674
3.640625
4
import numpy as np import Sistemas_Ecuaciones as gj x = np.array([0,1,3,4,6], dtype = float) y = np.array([3,5,21,35,75], dtype = float) # m = np.array(([1,2,5], [4,3,10]), dtype=float) def lagrange(x, y, valorinterp): n = x.shape[0] - 1 soluc = 0 for j in range(0, n+1): numerador = 1 denominador = 1 for i...
327b9119dc005b439abe7ec19d3c246ee80f0113
bria051/test
/App/db_test_3.py
204
3.515625
4
import sqlite3 conn = sqlite3.connect("test.db") cur = conn.cursor() cur.execute("select * from shopping_list where ID = 'at01'") rows = cur.fetchall() for row in rows: print(row) conn.close()
2003253846c08d3efc237d193c2fe4a32e460dc6
MosaabShalek/Project-Euler-First-20-Problem
/project euler - problem(9).py
283
3.71875
4
while True: for c in range(10,1000): for b in range(5,c): for a in range(1, b): if (a**2 + b**2 == c**2) and (a + b + c == 1000): print('a = {}, b = {}, c = {}, a*b*c = {}'.format(a,b,c, a*b*c))
bc7651189b790adddd13768794ddd81f7c0cfaa4
Anh1223/C4T6-All
/học/dotrangxanh.py
471
3.9375
4
r=int(input("How many color red?")) b=int(input("How many color blue?")) from turtle import * speed(0) width(6) colormode(255) penup() left(180) forward(750) left(180) pendown() for i in range(20): for y in range(b): pendown() color("blue") forward(40) penup() ...
8fed260460bfffe44d5db095c45652f140f1b10c
remichartier/026_UdacityTechnicalInterviewPrep
/004_SearchingAndSorting/006_QuicksortImplemented.py
1,339
4.21875
4
"""Implement quick sort in Python. Input a list. Output a sorted list.""" def quicksort(array): if len(array) == 0: return array # take last element as a pivot pivot_pos = len(array) -1 pivot_val = array[pivot_pos] i = 0 while i < pivot_pos and pivot_pos -1 > 0: if array[i] ...
5331bac6802134ba05af11ee7162c668853330b3
panda311/AlgoBook
/python/graph_algorithms/Kahn_algorithm.py
2,013
4.1875
4
# Kahn Algorithm for topological sorting of a graph # Adjacency lists representation from collections import defaultdict class Graph: def __init__(self, vertices): self.graph = defaultdict(list) # dictionary containing adjacency List self.V = vertices # No. of vertices def addEdge(self, u,...
fccf593d88481fe3ff6016e285777d37d571c6ea
tails1434/Atcoder
/ABC/062/A.py
207
3.703125
4
x, y = map(int, input().split()) group_a = {1,3,5,7,8,10,12} group_b = {4,6,9,11} group_c = {2} if (x in group_a and y in group_a) or (x in group_b and y in group_b): print('Yes') else: print('No')
820650b1a4b8279ea8e65608609c70513b84c75f
Fiona08/leetcode
/Python/062 UniquePathI.py
708
4.0625
4
#62 # Time: O(m*n) m: rows, n:columns # Space: O(n) # A robot is located at the top-left corner of # a m x n grid (marked 'Start' in the diagram below). # # The robot can only move either down or right at any point in time. # The robot is trying to reach the bottom-right corner of the grid # (marked 'Finish' in...
8bfc8a5d937b3d506d45fb9e9a91d4fddbc1e627
MeTTacuS/pitono-kursas
/III/AreAllLowercase.py
185
3.734375
4
from string import ascii_letters, whitespace def IsLowercaseWithWhitespace(string): if set(string).difference(ascii_letters + whitespace): return False return string.islower()
8f2adae4ab8709a9c736bc8f5dfc9aadf5fa422a
Khahory/curso_de_python_yacklyon-trabajo-py
/Diccionarios/Diccionarios II.py
1,546
3.59375
4
#En OneNote estan los metodos para el uso de los diccionarios (basico) edades = {"Angel":20, "Jason":18, "Aura":12, "Maria":40} print(edades) print("\033[;36m"+"-------------------------------------"+'\033[0;m') edades = {"Angel":20, "Jason":18, "Aura":12, "Maria":40} diccionario = edades.copy() #Copy and paste prin...
cf56277c602da3792cc0ab7a70c6b9d4eeb22849
RadkaValkova/SoftUni-Web-Developer
/Programming Fundamentals Python/Final Exam preparation/03 plant_discovery.py
1,508
3.703125
4
n = int(input()) plants = {} for i in range(n): line = input().split('<->') plant = line[0] rarity = int(line[1]) if plant not in plants: plants[plant] = {'rarity': 0, 'rating': []} plants[plant]['rarity'] = rarity while True: line = input() if line == 'Exhibition': break ...
db57357857425060b0ce7b8344b11908cb7f40c0
0DanChristian/PLDassignment3
/NameAgeAddwF.py
582
4.09375
4
# ask for name then save to variable # ask for age then save to variable # ask for address then save to variable # print in format (Hi my name is _, I am _ years old and I live in _. ) def getName(): _name = input("Name: ") return _name def getAge(): _age = input("Age: ") return _age def getAddress(...
ddd200412648091c779eb687eaa98a3a303b7e63
qmnguyenw/python_py4e
/geeksforgeeks/python/python_all/179_5.py
2,071
3.78125
4
Python Program for Finding the vertex, focus and directrix of a parabola A set of points on a plain surface that forms a curve such that any point on that curve is equidistant from the focus is a **parabola.** **Vertex** of a parabola is the coordinate from which it takes the sharpest turn whereas a is the...
0a95ba07341fb67c539ab0458752232c4210f1bc
natiawhitehead/-MasterInterview_Udemy
/LeetCode/_1469_lonely_nodes.py
877
3.75
4
# In a binary tree, a lonely node is a node that is the only child of its parent node. # The root of the tree is not lonely because it does not have a parent node. # Given the root of a binary tree, return an array containing the values of all lonely nodes in the tree. # Return the list in any order. class Solution...
1ef52379d9f16ea0f8cbc160ae20c5c08b5f4bfb
srinitude/holbertonschool-higher_level_programming
/0x0B-python-input_output/8-load_from_json_file.py
471
4.09375
4
#!/usr/bin/python3 """ This module loads a Python object from a JSON file """ from json import JSONDecoder def load_from_json_file(filename): """ Returns object from JSON file Args: filename (str): The name of the file """ if type(filename) is not str: raise TypeError("filename ...
87e091354bb18bbc9f7a1c5f8d40df24b6133b0d
Software-chasers04/Python-Codes
/List-2.py
356
3.609375
4
# Using some library functions s =["C","C++","Java","Python","Basic"] print(len(s)) s.append("toc") print(s) s.insert(2,"os") print(s) s.remove("Basic") print(s) s.sort() print(s) s.reverse() print(s) s.pop() s.pop() print(s) s.clear() print(s) p = [20,10,3,3,399] p2 = p.copy() print(p2) pos = p.index(10) pri...
743eee8e590d954a516e00a7b33406e2d6c25c5d
Viccari073/extra_excercises
/exer_listas_compostas_5.py
884
4.0625
4
""" Faça um programa que ajude um jogador da mega sena a criar palpites. O programa vai perguntar quantos jogos serão gerados e vai sortear 6 números entre 1 e 60 para cada jogo, cadastrando tudo em uma lista composta. """ from random import randint from time import sleep lista_jogos = [] jogos = [] prin...
ef32ca98af2287223ac1744479982443d88f051b
xzlxiao/Test
/python2.7/字符串方法.py
2,490
3.515625
4
# -*- coding: cp936 -*- # ַ ################################################# ''' find ''' a = 'With a moo-moo here. and a moo-moo there'.find('moo') print 'a: %s' % a title = 'Monty Python\'s Flying Circus' print title print 'title.find(\'Monty\'): %s' % title.find('Monty') print 'title.find(\'Python\'): %s' % titl...
f2ff80b45ac1de650a5d661bdc4d763d3000a74d
abhishek-parashar/Right-From-Scratch
/python-dsa/print sequences with spaces.py
472
3.578125
4
# -*- coding: utf-8 -*- """ Created on Mon Sep 28 11:52:12 2020 @author: Abhishek Parashar """ def solve(ip,op): if len(ip)==0: print(op) return op1=op op2=op op1.append(" ") op1.append(ip[0]) op2.append(ip[0]) ip.pop(0) solve(ip,op1) solve(ip,op2) ...
860209b367989a8df758a3837dbe16d08db70051
yiswang/LeetCode
/isomorphic-strings/isomorphic-strings.py
2,233
3.859375
4
#!/usr/bin/python # -*- coding: utf-8 -*- ############################################################################### # # Author: Yishan Wang <wangys8807@gmail.com> # File: isomorphic-strings.py # Create Date: 2017-02-21 # Usage: isomorphic-strings.py # Description: # # LeetCode problem 205. Isom...
bd9f217aac476bf74200bddbc20dd046e97ac024
maxgresoro/Python_Unit_1
/Week 5/maxgresoro-EncryptandDecryptMessage.py
2,678
4.46875
4
# Max Gresoro - IT075 Sierra College # Chap 5 assingment to write a program that will encrypt a message # using a randomly generated alphabet key and then decrypt that message # using the same key to get back the original message # Remove any duplicate letters from the password. # Now split the alphabet into...
e6c1e4cce7a56a3008ef9fc2efb548e24dcd1168
jhonatacaiob/QUEST-ES-DA-PROVA-DE-L-GICA
/questao 2.py
265
3.78125
4
anoinicial = int(1995) ano=int(input("QUAL O ANO?: ")) Porcentagem = 1.5/100 Salário=1000 while anoinicial<ano: Salário=Salário+(Salário*Porcentagem) Porcentagem *= 2 anoinicial+=1 print("No ano de %i, ele irá receber %i" %(ano,Salário))
da8ec0b6d32509592021c383ce98af893e11e54e
jonahswift/pythonStudy1
/firstDay/studyWhileBreak.py
206
4
4
#break i=1 while i <= 5: if i==4: print('吃够了') break i +=1 #continue i=1 while i<=5: if i==3: print('跳过3') i +=1 continue print(i) i+=1