blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
7aa1b2431f13e796bf200eaba15a3634f742509d
daledet/Python-Tkinter
/frame.py
393
3.671875
4
from tkinter import * root = Tk() root.title('Frames') root.iconbitmap('img/ecco.ico') frame = LabelFrame(root, text="Label The Frame", padx=50, pady=50) frame.pack(padx=10, pady=10) # Put things in the frame instead of root button = Button(frame, text="Don't Click This") button2 = Button(frame, text="Or This") butt...
72f0abce92f0ededa13fd6cb5311fce8c5382fda
yangboyubyron/DS_Recipes
/zSnips_Python/Math/RateOfChange.py
3,381
4.25
4
#---------------------------------------------------------- # EXAMPLE 1 # calculate instantaneous velocity at specified points import numpy from numpy import arange, cos import matplotlib.pyplot from matplotlib.pyplot import * # defines the derivative def der(x,delta): delta = float(delta) if delta < (0.0000001):...
2dc474a9f6729153923224becce3cd0a79038b1d
kpimaker/team_analytics
/customers/main.py
1,111
3.734375
4
# coding: utf-8 import pandas as pd import sqlite3 def create_customers_table(connection): """Пересоздает таблицу customers, используя соединение connection""" cur = connection.cursor() cur.execute('DROP TABLE IF EXISTS customers') cur.execute(""" CREATE TABLE customers( user_id...
fad68c7a60c17880819b11d3b6ed8524c95763cb
Desperado1/mini-projects
/practice problems(Data Structures)/NoOfWaysToMakeChange.py
385
3.984375
4
"""DYNAMIC PROGRAMMING a given array representing coin denominations and a non negative target amount function returns ways to make change for that target amount. """ def numberOfWaysToMakeChange(n, denoms): # Write your code here. d = [0 for i in range(n + 1)] d[0] = 1 for denom in denoms: for i in range(1, ...
8933b2883fd69aa927b1200ee641ed0c8f9b39e2
Littlemansmg/pyClass
/Week 1 Assn/Project 2/2-4.py
309
3.765625
4
print("Price Comparison") detergent64 = input("Price of 64 oz size: ") detergent32 = input("Price of 32 oz size: ") print("\nPrice per oz (64 oz): \t{}\n" "Price per oz (32 oz): \t{}".format(round(float(detergent64)/64, 2), round(float(detergent32)/32, 2)))
1dfe4af7e9bed1de9bf2279ee59d7071563f4b4b
yuhao12345/computational_Physics
/Ques4.1.py
344
3.96875
4
# -*- coding: utf-8 -*- """ Created on Sat Sep 16 18:00:22 2017 @author: user """ def factorial(n): f=int(1.0) #f=1.0 for i in range(1,n+1): f*=i return f a=factorial(200) print(a) # using integer variables can get right answer, while floating-point return inf # floating number has max...
3e8fd2625fb9b43e4f888e3fd36dbe6b0217b10c
nicefuu/leetCode-python3
/884.py
1,432
4.125
4
"""给定两个句子 A 和 B 。 (句子是一串由空格分隔的单词。每个单词仅由小写字母组成。) 如果一个单词在其中一个句子中只出现一次,在另一个句子中却没有出现,那么这个单词就是不常见的。 返回所有不常用单词的列表。 您可以按任何顺序返回列表。 示例 1: 输入:A = "this apple is sweet", B = "this apple is sour" 输出:["sweet","sour"] 示例 2: 输入:A = "apple apple", B = "banana" 输出:["banana"] """ class Solution: def uncommonFromSentences(self,...
ae55283dc747cf19f4f17fe75a43f155f15cb07d
dishant470266/hacker_rank
/ex_15.py
207
3.703125
4
def reverce_list(l): return[i[::-1] for i in l] print(reverce_list(['abc','bvc'])) #if statement list comprehsion names = [1,2,3,4,5,67,8,9,10] name = [i for i in names if i%2==0] print(name)
acb734e06dc5a6adb1c5f0c66d6f266b6dee3820
colin-pm/hashcode-2021
/hashcode/input.py
1,147
3.59375
4
from .data_types import Street, Car, Intersection def read_file(file_path): with open(file_path, 'r') as f: time, number_of_intersections, number_of_streets, number_of_cars, score = [int(val) for val in f.readline().split(' ')] streets = {} cars = [] intersections = [] fo...
03ca9dae71d38dafc4db2f95659b079be2db103e
Chunzhen/leetcode_python
/problem_20.py
532
3.875
4
#! /usr/bin/env python # -*- coding:utf-8 -*- class Solution(object): def isValid(self, s): """ :type s: str :rtype: bool """ stack=[] d={'{':'}','[':']','(':')'} for v in s: print v print stack if v=='(' or v=='{' or v=='[': stack.append(v) else: if len(stack)==0 or d[stack[-1]]!=v...
59b533bba3d844ab6f116bcb14d13381b07ae589
cheretka/Tic-Tac-Toe
/Board.py
2,825
3.96875
4
class Board: def __init__(self): # table with all marks self.values = [' ' for x in range(9)] # stack with stores copies of a grid after each step of the game self.stack = [] self.current_player = "X" # Function displays a 3×3 grid def print(self): print("\...
d0f028dfd06c76257d38080cefaf4f0b1047d73a
huangqiank/Algorithm
/leetcode/binarySearch/search_in_rotated_sorted_array3.py
1,291
4.1875
4
##Suppose an array sorted in ascending order is rotated ##at some pivot unknown to you beforehand. ##(i.e., [0,0,1,2,2,5,6] might become [2,5,6,0,0,1,2]). ##You are given a target value to search. # If found in the array return true, otherwise return false. ##Example 1: ##Input: nums = [2,5,6,0,0,1,2], target = 0 ##Out...
81e92704b2b2fb3f48e5f42a9ea945d0b2e85e4f
rahul-relekar/fcc-yt-py
/Madlibs/Madlibs.py
887
4.21875
4
""" Basic methods of concatenating string in a string """ # Choose first, second, third, fourth, fifth or final print("Let us play Madlibs") year = input("Your current year of study (ex. Final): ") degree = input("Your complete current degree (ex. BEng): ") university = input("Your University Name (ex. CityUHK) : ...
9d32fa5ce69fafcc2b54d9dea535803402160a6e
Ugenteraan/Software-Design-Patterns
/Factory_Method/main.py
886
4.5
4
''' Python implementation of the Factory Design Pattern. The example code here illustrates how a car manufacturing company that manufactures different brand of cars such as Toyota, Honda, and Nissan may write their software logics using the Factory method. ''' from factories import CarFactory def client_code(reques...
aa8f0bb0c4ad48e178a710667a483aa4ddf42d1f
Bgumel/Automate-The-Boring-Stuff
/Practice-Projects/Ch 12 - Multiplication Table
2,307
4.21875
4
#! python3 # multiplication_table.py - creates a multiplication table in excel with N rows """ Create a program multiplicationTable.py that takes a number N from the command line and creates an N×N multiplication table in an Excel spreadsheet. Note with this module! There have been updates to openpyxl since Automate T...
326029a4497d66896a35482c0e0bec9414b8215e
DanielMalheiros/geekuniversity_programacao_em_python_essencial
/Exercicios/secao06_estruturas_de_repeticao/exercicio17.py
295
4
4
"""17- Faça um programa que leia um número inteiro positivo N e calcule a soma dos N primeiros números naturais.""" n = int(input("Digite um número inteiro e positivo: ")) soma = 0 if n > 0: for x in range(n+1): soma = soma + x else: print("Número inválido.") print(soma)
36b216ad9883f5bb8724b978975d30e88c1ca49b
mateobassini/trabajo-final-programacion-
/player.py
961
3.515625
4
class Player(): def __init__(self, name, max_weight): self.name = name self.max_weight = max_weight self.items = {} self.ataque = 1 self.defensa = 1 self.equipment = {'casco': None, 'arma': None, 'armadura': None} def setItem(self, item): ...
5a0e4b7c1c6111ce948c098836892ca3f9a5e4c2
JasirDonte1/TESU_Python_Projects_and_Assignments
/COS-205_assignment4a_.py
870
3.6875
4
dictionary = { 'A': 1, 'a' : 1, 'B': 2, 'b' : 2, 'C': 3, 'c' : 3, 'D': 4, 'd': 4, 'E': 5, 'e': 5, 'F': 6, 'f': 6, 'G': 7, 'g': 7, 'H': 8, 'h': 8, 'I': 9, 'i': 9, 'J': 10,'j': 10, 'K': 11,'k': 11, 'L': 12,'l': 12, 'M': 13,'m': 13, 'N': 14,'n': 14, 'O': 15,'o':...
76382d87ea95921519590ddbad449eb4b15b0857
seyong/csc2511-nlc-a1
/buildarff.py
3,813
3.640625
4
#!/usr/bin/python #! -*- encoding: utf-8 -*- ################## # Assignments 1-2 # Gathering feature information # Created by Seyong Ha # # Extract 20 features from the tweet data # - Counts(17) # First person pronouns # Second person pronouns # Third person pronouns # Coordinating conjunctions # Past-tense verb...
a323b322c71b879c73455c8c34f73d057657c20a
TamarFurman/DNA
/data_base/dna_sequence.py
4,585
3.84375
4
import re class Dna_Sequence: """ class of DNA Sequence """ def __init__(self, dna_string, name, id): """ initialization the dna string ,name and id. :param dna_string: sequence of dna nucleotide. :param name: name of the dna sequence. :param id: id of the dna ...
845ed462c60d016380c058cd2025e143fa4025cf
evgeniy-arapov/geekbrains-python-base
/lesson14/exercise2(generators)/part2.py
330
3.84375
4
import random numbers = [random.randint(1, 100) for i in range(1, 10)] print(numbers) numbers = [1, 2, 3, -4] numbers = [number ** 2 for number in numbers] print(numbers) names = ['Артурт', 'Генадий', 'Виолета', 'Тимофей'] names = [name for name in names if name.startswith('А')] print(names)
954228499d91460fac19ef55af9105247db24150
jedzej/tietopythontraining-basic
/students/burko_szymon/lesson_02_flow_control/knight_move.py
384
3.8125
4
import math startX = int(input("Give start x position: ")) startY = int(input("Give start y position: ")) endX = int(input("Give end x position: ")) endY = int(input("Give end y position: ")) if (abs(startX - endX) == 2 and abs(startY - endY) == 1) or (abs(startX - endX) == 1 and 2 ...
ca8125a3f7e4efbaecfa916e7adb20bc3f7dc0f5
loganyu/leetcode
/problems/218_the_skyline_problem.py
3,639
3.828125
4
''' A city's skyline is the outer contour of the silhouette formed by all the buildings in that city when viewed from a distance. Now suppose you are given the locations and height of all the buildings as shown on a cityscape photo (Figure A), write a program to output the skyline formed by these buildings collectively...
61d0e27f69dfbb4e164fd9e33babd242315772a1
qwerty1092/Coursera
/week2/iterables/dict_ex.py
1,680
3.640625
4
zen = """The Zen of Python, by Tim Peters Beautiful is better than ugly. Explicit is better than implicit. Simple is better than complex. Complex is better than complicated. Flat is better than nested. Sparse is better than dense. Readability counts. Special cases aren't special enough to break the rules. Alth...
e754e2b700156d1c418331e61c4366ae953dc548
dou-du/tool-layer-raman-ir
/compute/utils/linalg.py
1,209
4.0625
4
import numpy as np def shortest_vector_index(array): """ Takes an array of vectors and finds the shortest one. :param array: array of vectors :return idx: the index of the shortest vector in the array """ idx = np.array([np.linalg.norm(vector) for vector in array]).argmin() return int(idx...
15cfc0f0113f3d2785abc71618313f3cfc5b9b6e
lare-cay/CSCI-12700
/10-3-19.py
346
4.1875
4
#Name: Clare Lee #Email: Clare.Lee94@myhunter.cuny.edu #Date: October 3, 2019 #This program asks for 5 whole numbers and moves turtle according to those numbers numArray = [] for i in range(5): num = int(input("Enter a number: ")) numArray.append(num) import turtle tom = turtle.Turtle() for i in...
968339b56169d96bc3e43124a1853b661cd85eb8
programacionurbana2017/programacion1
/python/taller5/multiplo.py
119
3.75
4
a = 6 b = 3 c = (a/b)*b if c == a: print ((b), " es multiplo de", (a)) else: print ((b), " No es multiplo de", (a))
ea1ea2334c4c75eca117739489589c3fff691288
Daniel20806/hi
/4.py
209
4.03125
4
age = input('請輸入你的年紀:') age = int(age) if age < 13: print('國小生') elif age >= 13 and age < 18: print('國高中') elif age >= 18 and age < 22: print('大學') else: print('你很老XD')
16fcc9e8a1739d2bcb4e04fa82e58b21eb92c2f2
blademaw/pysweeper
/minetest.py
1,168
3.578125
4
def getOthers(a, b, board): oA, oB = a, b a, b = a-1, b-1 res, coords = [], [] for loc in range(9): if not(a < 0 or b < 0): try: if not(a == oA and b == oB): res += [board[a][b]] coords += [(a, b)] except IndexError:...
b31a8bbe58e080372550f60d2350c4f9c6a434b0
akadir/CodingInterviewSolutions
/FromLast/FromLast.py
3,185
3.765625
4
import unittest def from_last(linked_list, index): slow = linked_list.get_first() fast = linked_list.get_first() for i in range(0, index): fast = fast.next_node while fast.next_node is not None: slow = slow.next_node fast = fast.next_node return slow c...
f502b8e4fc06c8cd472b6a66424afe3e3d8840f8
CaueVieira/curso
/Cap 3/Usuario.py
1,402
3.78125
4
# Criar um programa cadastroUsuario.py contendo os seguintes dados: nome, idade, cpf, identidade, nacionalidade, naturalidade, endereço, # sexo, time de futebol e profissão. O mesmo deve ter tres saidas, uma pessoal (nome, idade, time de futebol) outra profissional # nome, identidade, cpf e profissao) e por ultima, uma...
9f0f57eb6c0a8b276cbc9a43c52f8492494d393e
LaurenBoehme/program-arcade-games
/Lab 01 - Calculator/lab_01_part_c.py
173
4.09375
4
#!/usr/bin/env python3 # Lab 01 # Lauren Boehme # 11/1/17 PI = int(3.14159) radius=int(input('What is the radius of the circle? ') circle_rad = PI * (radius)**2 print(circle_rad)
d6dcd17121b8ad5a3ef96fa27990c040c0720087
hrkim28/TCT
/20190227/TCT_NaTaeUng.py
458
3.53125
4
def funMaxMulti(inputData): for i in inputData : result = list() mid = i[1]//i[0] if mid < 1 : result.append(-1) else : for j in range(1,i[0]+1): if j == i[0] : result.append(mid+i[1]%i[0]) else : result.append(mid) pri...
fe07db55d5b8251f741de6bd142bd67dc8918acb
helkbore/learn-python_note
/python基础/6面向对象编程/1类和实例.py
1,054
4.03125
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- '面向对象编程-类和实例 2017年11月6日' __author__ = 'Gentiana' # 类定义 class Student(object): pass ''' (object),表示该类是从哪个类继承下来的 通常,如果没有合适的继承类,就使用object类 ''' # 实例化 bart = Student() print(bart) print(Student) bart.name = 'Bart Simpson' print(bart.name) # __init__ class Student(...
58f5842615920d74c04ce43e149760a9debeb6b6
tianyunzqs/LeetCodePractise
/leetcode_21_40/30_findSubstring.py
1,396
3.890625
4
# -*- coding: utf-8 -*- # @Time : 2019/6/16 13:39 # @Author : tianyunzqs # @Description : """ 30. Substring with Concatenation of All Words Hard You are given a string, s, and a list of words, words, that are all of the same length. Find all starting indices of substring(s) in s that is a concatenation of...
a05b1861af29c4421e6a7fb8363aa9b38c615241
rtslt/scads-ir
/stopwords/common.py
311
3.734375
4
from abc import abstractmethod from typing import List @abstractmethod def get_stopwords(filename: str) -> List[str]: """ Get the list of stop words from file. :param filename: Filename in the same directory. :return: Stop words. :rtype: List of str. """ raise NotImplementedError
10fc872fdfc79965552777631d4ede87a1c295c6
agatachamula/flight-delay-prediction-model
/Data_Cleaning/remove_NaN.py
1,108
3.5
4
import pandas as pd from tkinter import Tk, filedialog import os #display all rows with airline code KH #show all columns pd.set_option('display.max_row', 1000) pd.set_option('display.max_columns', None) root=Tk() root.withdraw() directory= filedialog.askdirectory(parent=root, initialdir="/", title='Plea...
800463a1ff5ec7186e61978d547e8a448216be23
Lok-Aravind-Palu/python-practice
/PythonIntermediate/ExceptionHandlingExmaple.py
1,586
3.53125
4
import sys from math import log def convert(s): try: return int(s) except (TypeError,KeyError,ValueError) as e: print("Conversion Error: {}"\ .format(str(e)),file =sys.stderr) return -1 print(convert("123")) print(convert("Elephant")) print(convert([2,5,6,8,9])) # we ca...
dd6f83a71772d98f330dcf42b5385c9a582e8082
EdisonZhu33/Algorithm
/备战2020/085-卡牌分组.py
1,455
3.78125
4
""" @file : 085-卡牌分组.py @author : xiaolu @time : 2020-03-27 """ ''' 给定一副牌,每张牌上都写着一个整数。 此时,你需要选定一个数字 X,使我们可以将整副牌按下述规则分成 1 组或更多组: 每组都有 X 张牌。 组内所有的牌上都写着相同的整数。 仅当你可选的 X >= 2 时返回 true。 示例 1: 输入:[1,2,3,4,4,3,2,1] 输出:true 解释:可行的分组是 [1,1],[2,2],[3,3],[4,4] 示例 2: 输入:[1,1,1,2,2,2,3,3] 输出:false 解释:没有满足要求的分组。 ''' from ty...
301e83d09709753bd6d3507ad819cdbc66a96a07
mehdi-ahmed/python-introduction
/conditionals.py
510
4.03125
4
is_hot = False is_cold = True if is_hot: print('It is a hot day !!') elif is_cold: print('I love cold days!') else: print('I love average days!') # Indentation is important !! # and or has_high_income = True has_good_credit = True has_criminal_record = True if has_high_income and has_good_credit: p...
357208d288e3e4360bd0eda1d7a38fbbb2a0dd82
Gomez5sh/holbertonschool-web_back_end
/0x00-python_variable_annotations/1-concat.py
187
3.59375
4
#!/usr/bin/env python3 """Basic annotations concat""" def concat(str1: str, str2: str) -> str: """ >>> concat("hello", "world") 'helloworld' """ return str1 + str2
34624c24456f4acb5c406d9685c74af15dc12b29
RichardTabaka/Learn-Python
/TechMentorProblem2/TechMentorProblem2.py
2,084
4.28125
4
# Write a function that accepts a non-empty array of distinct integers and an integer representing a target value. # If any two numbers in the input array sum up to the target value, the function should return those two numbers in any order. # If no two numbers in the input array sum up to the target value, the functio...
c88b3505ed1c6db1eaf22997bdf23bdbc5328de1
chenhongbiao/My_Web_Spider
/Web Scraping with Python/Chapter1/3-exceptionHandling/3-exceptionHandling/_3_exceptionHandling.py
1,554
3.671875
4
from urllib.request import urlopen from urllib.error import HTTPError from bs4 import BeautifulSoup def getTitle(url): try: html = urlopen(url) except HTTPError as e: #The page is not found on the server - 404 (or there was some error in retrieving it) #urlopen() would throw HTTPError ...
5752df023c1b9ce34d807d193f351f176886d359
Anupalsi/karthika
/pro1.py
215
3.609375
4
nu=int(input()) l=[] for i in range(nu): l.append(input()) l.sort() a,b=l[0],l[-1] l1=[] for i in range(len(a)): if a[i]==b[i]: l1.append(a[i]) else: break print("".join(l1))
0788bbcc779edaa4950aa0fa7af5fcb73038ce7d
TesztLokhajtasosmokus/velox-syllabus
/week-03/2-functions-data-structures/solutions/36.py
526
4.1875
4
numbers = [3, 4, 5, 6, 7] # write a function that reverses a list def revert(input): reverse = [] for i in range(len(input)-1, -1, -1): reverse += [input[i]] return reverse print(revert(numbers)) def test(expected, actual, message): if expected == actual: print('check') else: ...
bb121f7c10f7ee6a8af7606d895b94234e44619f
HenryZelonka/chatbot
/main.py
504
3.53125
4
#imports from time import sleep as s import sys import parser #---------------------------------------------------------- #functions #scrolly text def scroll(string): for letter in string: print(letter, end = "") sys.stdout.flush() s(0.05) #---------------------------------------------------------- #...
5d600dd6a45f4e7fda210a11c19c5c18c57d3f52
aleksiheikkila/HackerRank_Python_Problems
/Time_Conversion.py
693
4
4
''' HackerRank problem Domain : Python Author : Aleksi Heikkilä Created : Aug 2019 Problem : https://www.hackerrank.com/challenges/time-conversion/problem ''' #!/bin/python3 import os import sys # # Complete the timeConversion function below. # def timeConversion(s): # # Write your code here. #...
34eaf0758d9cf91fe1a1e8bb03a3aa44b7f1ef04
joseangel-sc/CodeFights
/Arcade/SpringOfIntegration/ArrayConversion.py
1,263
3.5625
4
#Given an array of 2k integers (for some integer k), perform the following operations until the array contains only one element: #On the 1st, 3rd, 5th, etc. iterations (1-based) replace each pair of consecutive elements with their sum; #On the 2nd, 4th, 6th, etc. iterations replace each pair of consecutive elements wi...
4bbd38c6135558e44fc970cf596a9e8f27c56604
WellseeC/Python
/HW/hw6Files/20161104_Homework 6 Checkpoint 1(W).py
6,957
3.875
4
''' This program is going to see how many steps the user will use to find a villain in a chain from of the top ten most popular villains. ''' def read_file(): for line in f: x=line.split('\t') y=x[7].strip().lower().split(',') set_of_stories = set() for i in y: set_of_sto...
bcf692319e8da2caf9953e59665fd1c56bcf048d
cesarmayo/ejercicios_python
/1. Variables, Entrada y Salida y Operaciones aritméticas elementales/fahrenheit_a_celsius.py
485
4.09375
4
# coding=utf-8 """ Escriba un programa que pida una temperatura en grados Fahrenheit y que escriba esa temperatura en grados Celsius Se recuerda que la relación entre grados Celsius (C) y grados Fahrenheit (F) es la siguiente: C = (F - 32) / 1,8 """ print("===================================") print("CONVERTIDOR DE FAH...
834091c9eba8c9c021f575bab09bfc6441fe53ef
l0neaadil/Python_for_beginner
/33_random.py
182
3.828125
4
# Choosing_Leader import random Group = ['Faiz', 'Niyazi', 'Zahoor', 'Ashiq', 'Zubair', 'Irfan', 'Zawar'] leader = random.choice(Group) print(f'{leader} will be our next president')
696870712864aef5360a2c128bf9842ea223c0ce
shri9098/Pythoin_list
/fun/demo8.py
731
3.9375
4
def isAlphabet(s): if 'a' <= s <= 'z' or 'A' <= s <= 'Z': return True return False def swap(a, b): return b, a def tolist1(string): lst1 = [] for i in string: lst1.append(i) return lst1 def toString(lst1): return ''.join(lst1) def reverse(string): lst = tolist1(st...
c14aed1cb86cf33e0f52f11f19ca999f87e14535
XWxiaowei/Python_learn
/python_function_learn/com/jay/python/SubList.py
334
3.84375
4
L=['Xiang','Li','Wang','Bob','Liu'] r=[] n=3 for i in range(n): r.append(L[i]) print(r) # 切片方式 # 取出前三个,但是不包括索引3 print(L[0:3]) print(L[1:3]) print(L[-1]) L=list(range(100)) print(L) print(L[:10]) print(L[:]) # tuple也是一种list,唯一 # 的区别是tuple不可变 print((0,1,2,3,4,5)[:3])
47805fee88cb1fcf06005a9dd402c2e52e19225d
renatodev95/curso-python
/secao5-modulos-python/zip1.py
922
4.09375
4
# ZIP - Compactando/Descompactando arquivos from zipfile import ZipFile import os caminho = 'O CAMINHO DO ARQUIVO VEM AQUI!' # usando o context manager da classe ZipFile para criar uma pasta zip e incluir arquivos dentro dela. with ZipFile('arquivo.zip', 'w') as zip: # o `for` abaixo está listando apenas os arqui...
4db67bd72cdf2f75289c3eba2f6c2424d40b3cbe
mdickinson/deccoeff
/profile.py
811
3.703125
4
# Timings for multiplication import timeit from random import randrange from deccoeff import Deccoeff as D def getvals(N): a = randrange(10**N) b = randrange(10**N) return a, b # test multiplication of two random n-digit numbers N = 4000 T = timeit.Timer('c = a*b', 'from __main__ impor...
09f41df7a496075c4045ce4da9cbc1cbc49a1f7e
rohitsai31997/Bangalore-Real-Estate-Prediction-Model
/model.py
10,248
3.8125
4
import pandas as pd import numpy as np from matplotlib import pyplot as plt import matplotlib matplotlib.rcParams["figure.figsize"] = (20,10) df1 = pd.read_csv(r"C:\Users\rohit\Desktop\Datasets\Bengaluru_House_Data.csv") #Gives the number of rows and columns # print(df1.shape) #To get the number of rows in ...
83ccdff0a21d0be7c46999d87484abad53c91a68
CemNurlu/DeepOkey
/unittest.py
601
3.609375
4
# -*- coding: utf-8 -*- """ Unit tests: ADD MORE @author: CemPC """ from Game import Game import unittest class TestStringMethods(unittest.TestCase): def test_deck_count(self): self.assertEqual(len(g.decklist), 4) def test_tile_count_deck(self): tilecount = [] for deck in g.de...
34d67f46571233dd1766d9d6d1d26e336ce7742f
tansuluu/DataAnalysis
/eagle.py
392
3.765625
4
import math num=int(input()) max=0 list3=[] index=0 for i in range(0, num): numin=int(input()) for k in range(0,numin): m,p=map(int, input().strip().split()) result=math.sqrt(m*m+p*p) p=0 if max<result: max=result index=k list3.append(index+1) for y i...
2546f70de6bba45aff7e3acbd0cdd178a139b0e6
leohck/python_exercises
/EX_EstruturaDeDecisao/ex1.py
286
3.9375
4
__author__ = 'leohck' print('>.....----- EX 1 ----.....< ') """ Faça um Programa que peça dois números e imprima o maior deles. """ x,y = float(input('digite um numero: ')),float(input('digite mais um numero: ')) if x > y: print(x) elif y > x: print(y) else: print (x,y)
0e238c03b5a854aaf6c4cf0931f951052611cf63
SyedJawadShah/CS5590Python-Spring2018
/Assignment 1 lab 1/Lab 1- Source/Q1 Lab Assignment 1.py
3,776
4.40625
4
password= input("Please select your password:") # asking user to enter a password lencheck= len(password) # variable to store the length of password that will be used for validation a = ['$','@','!','*'] # a list that contains special characters that will be used for validation checklen = False # flag that will be s...
73a5a2c12edba0812c79c12970e322d2f148df95
shubham3121/algorithms
/binary_trees.py
5,888
4.0625
4
class Node: def __init__(self, val): self.parent = None self.left = None self.right = None self.val = val def __str__(self): return self.val def __repr__(self): return self.__str__() class BinarySearchTree: def __init__(self): self.root = None ...
9a87ee9135fbf7255aec44f35bb3062c32d79751
KeymoniSS/CTI110
/P2T1_SalesPrediction_KeymoniSakil-Slack.py
509
3.96875
4
# This code displays the profit made from the projected amount of total sales # September 10, 2018 # CTI-110 P2T1 - Sales Prediction # Keymoni Sakil-Slack # # Get the projected total sales total_sales = float(input ('Enter the projeted sales: ')) # Calculate the profit as 23 percent percent of total sales p...
cf1637c1b12b26677f2055521d4b9252c1ca9a7d
KwdeGit/kwde_python
/die.py
296
3.59375
4
from random import randint """表示一个骰子类""" class Die(): def __init__(self,num_side=6): self.num_side = num_side self.sum = 0 def roll(self): return randint(1,self.num_side) def sum_f(self): i = 0 while i < self.num_side: self.sum += i i = i +1 return self.sum
61ce140ceed8ae0d9f0abd3da7b830732d5247c1
syurskyi/Python_Topics
/125_algorithms/_exercises/templates/_algorithms_challenges/leetcode/leetCode/Tree/331_VerifyPreorderSerializationOfBinaryTree.py
1,662
3.640625
4
#! /usr/bin/env python # -*- coding: utf-8 -*- # @Author: xuezaigds@gmail.com c.. Solution o.. ___ isValidSerialization preorder """ When there are two consecutive "#" characters on top of the stack, pop both of them and replace the top element on the remain stack with "#". """ ...
7991ec6824baf95e59e662a7260a955ebee397e7
laukikpanse/Python-Practice-Examples
/un.py
188
3.640625
4
list1 = [1,2,3,4,5,6,6,6,7,8,9] pointer1 = 0 pointer2 = 1 while pointer2 <=len(list1)-1: if list1[pointer1] == list1[pointer2]: print(list1[pointer2]) pointer2 += 1 pointer1 += 1
a06cac0d72ea2c6789c1050b806948111c4bbef1
jahokas/Python_Workout_50_Essential_Exercises_by_Reuven_M_Lerner
/exercise_39_ise_cream_bowl/exercise_39_book_shelf.py
999
3.734375
4
class TooManyBookOnShelfError(Exception): pass class Book(): def __init__(self, title: str, author: str, price: int, width: int): self.title = title self.author = author self.price = price self.width = width class Shelf(): def __init__(self, width): self.books = [...
4ce8383bd6f7300f926180b59596348067ba294e
zhlinh/leetcode
/0299.Bulls and Cows/solution.py
2,240
4.46875
4
#!/usr/bin/env python # -*- coding: utf-8 -*- ''' ***************************************** Author: zhlinh Email: zhlinhng@gmail.com Version: 0.0.1 Created Time: 2016-05-03 Last_modify: 2016-05-03 ****************************************** ''' ''' You are playing the following Bulls and Co...
afeab13dd05c42c671573c439c788fecd316698d
InternetJohnny/advent-of-code
/2017/day 4/04.py
416
3.609375
4
def is_valid(line): passphrase = line.split() if len(passphrase) < 2: return 0 i = 0 while i < len(passphrase) - 1: j = i + 1 while j < len(passphrase): # if passphrase[i] == passphrase[j]: if sorted(passphrase[i]) == sorted(passphrase[j]): return 0 j += 1 i += 1 return 1 with open('input.txt...
07c9544927ff7122c93820261d10d69dbb068085
mmcloughlin/problems
/elements/python/12/4/soln.py
1,688
4.03125
4
def find_shift_amount(A): """ find_shift_amount assumes A is a sorted array that has been cyclically shifted, and finds the shift amount. """ l = 0 r = len(A)-1 if A[l] < A[r]: return 0 while r-l > 1 and A[l] >= A[r]: m = l + (r-l)//2 if A[l] > A[m]: r...
a53533398f82a06f93758188fadef425b99a69cc
junyechen/PAT-Advanced-Level-Practice
/1054 The Dominant Color.py
3,437
3.640625
4
""" Behind the scenes in the computer's memory, color is always talked about as a series of 24 bits of information for each pixel. In an image, the color with the largest proportional area is called the dominant color. A strictly dominant color takes more than half of the total area. Now given an image of resolution M ...
e8a0952cb39d7e6d47696254d494e289a1c8f427
edithalice/metis_project_bensen
/percent_daily.py
4,052
3.890625
4
""" Provides functions for plotting percent of daily entries (pct_de) data And for returning the top stations by pct_de functions: - clean_data(): preps the df and adds pct_de column - pct_dist(): draws distplot of pct_de - pct_plot(): draws plot of how many stations capture what pct_de (e.g. top 50 stations -> 38%...
3029f69535a3e829be12fd7d9ba52611a8d1eef4
oguzhancelikarslan/Data-Structures
/counting_sort.py
400
3.59375
4
def counting_sort(array,maxval): m = maxval + 1 # 0 dan başladığı için +1 gerekir. count = [0] * m # max sayı kadarlık bir dizi başlatırız. for a in array: count[a] +=1 i = 0 for a in range(m): for s in range(count[a]): array[i] = a i = i+1 ...
af3555e8615d650b13fe137029a577f0e3fb0ec9
rbsec/pentest
/john/genwordlist.py
726
3.90625
4
#!/usr/bin/env python3 # Simple script to generate a sorted unique wordlist from an input file # Usage: $ ./genwordlist.py <inputfile> # Saves output to wordlist.txt # Saves output to wordlist.txt if not outfile specified import re import sys wordlist = set() with open(sys.argv[1]) as f: lines = f.readlines() fo...
7611019cf8e248b02d302ef8e2a13186f7e0f80b
teojcryan/rosalind
/code/revc.py
375
3.703125
4
# Complementing a Strand of DNA """ Problem Given: A DNA string s of length at most 1000 bp. Return: The reverse complement sc of s. """ f = open("Bioinformatics Stronghold/rosalind_revc.txt", "r") input = f.read().replace("\n", "") def comp(input_str): return input_str.replace("A", "t").replace("T", "a").replace(...
252ffb2f1ddd7d7840f26a97dae64ece80857d85
lapisanlangit/belajarpython
/14_forlanjutan.py
259
3.734375
4
for i in range(0,10): print(i) print('-'*10) #dengan increment for i in range(100,200,5): print(i) print('-'*10) # break angka_dicari = 25 for i in range(0,40): print(i) if i is angka_dicari: print("angka ditemukan0",i) break
1397bef6643327e70b0030d2e4ea294105445fd9
wekesa/python_practise
/data_structures/stack.py
2,255
3.96875
4
# A stack is a linear data structure that stores items in a Last-In/ First-Out (LIFO) or # First-In /Last-Out (FIFO) manner. # - The insert and delete operations are often called push and pop # - Functions associated with stack are # 1. empty() - returns whether stack is empty - Time complexity: O(1) # 2. size()...
70f74719ed05defbc5d1791f3321d7e574909690
ywtail/leetcode
/76_242.py
1,101
3.546875
4
# coding:utf-8 # 242. Valid Anagram 有效变形词 # 78ms beats 79.36% class Solution(object): def isAnagram(self, s, t): """ :type s: str :type t: str :rtype: bool """ if len(s) != len(t): return False re_s = [0] * 26 for x in s: re_s[...
9be56b4a74f6078a971840bfb2424df4629e6caa
Alokpatek2392/Word-Game
/Wordgame.py
4,539
4.125
4
from helper import * import time def compChooseWord(hand, wordList, n): """ Given a hand and a wordList, find the word that gives the maximum value score, and return it. This word should be calculated by considering all the words in the wordList. If no words in the wordList can be made from ...
9949403e003a70afd303129062018727283bc92d
snowlance7/Python-Projects
/week1/change_calculator.py
501
3.84375
4
print('Change Calculator') cont = 'y' while cont.lower() == 'y': cents = int(input('\nEnter number of cents (0-99): ')) quarters = cents // 25 cents = cents % 25 dimes = cents // 10 cents = cents % 10 nickels = cents // 5 cents = cents % 5 pennies = cents print('\nQuarters: ' + s...
ea622e03faa43fe134786224737a3e459f80048d
hamin7/ITE3035_Python
/Python/Lecture5/5-2.py
299
3.796875
4
# 이진검색(Binary Seach) print('I am thinking of a number of from 10 to 50, guess it.') start=10 end=50 answer=37 guess=input() if answer > int(guess): print('smaller than the answer') if answer < int(guess): print('bigger than the answer') if answer == int(guess): print('correct')
475f89387445a6270c3a8b58dd001d893a8f8001
wayne214/PycharmProjects
/firstPyton/test/regular.py
3,403
3.5625
4
#!/usr/bin/python # -*- coding: UTF-8 -*- # 正则表达式 import re # re.match函数 # re.match 尝试从字符串的起始位置匹配一个模式,如果不是起始位置匹配成功的话,match()就返回none。 print (re.match('www', 'www.baidu.com').span()) # 在起始位置匹配 print (re.match('com', 'www.baidu.com')) # 不在起始位置匹配 line = "Cats are smater than dogs" matchObj = re.match(r'(.*) are (.*?)...
e25c132f83806b32e4fdc44797db3f3ffe655f8a
venkateshvadlamudi/Pythontesting
/pythonPractice/Takinginputfromuser.py
672
4.1875
4
"""num1=int(input ("Enter first number :")) num2=int(input ("Enter second number :")) print(num1+num2) num1=input ("Enter first number :") num2=input ("Enter second number :") print(int(num1)+int(num2)) ### type conversion ### num1=input ("Enter first decimal number :") num2=input ("Enter second decimal number :") ...
78ec7a31212164b9816b8727f032e74b124e8718
GuthiMahesh/n-code-it-pvt-ltd
/white spaces.py
299
4.03125
4
# Example x = 10 while(x != 0): if(x > 5): # Line 1 print('x > 5') # Line 2 else: # Line 3 print('x < 5') # Line 4 x -= 2 # Line 5 """ Lines 1, 3, 5 are on same level Line 2 will only be executed if if condition becomes true. Line 4 will only be executed if if condition becomes false. """
05fbe07c55f06a6d16e41ccd2067890d77d04c28
jreit920/first_repo
/Problem Set 10.py
2,255
3.859375
4
watchlist= [] symbol= input("Please type in the tickers of the stocks you want on your watchlist:") if symbol != '': while symbol != '': watchlist.append(symbol) symbol= input("If you would like to input another ticker, please do so. Otherwise, hit enter:") else: print("You did not ente...
6cb1ea6431dd95bd7ccce7d05c370ac517e3642a
Pushpadant07/KNN
/KNN_glass.py
1,298
3.5625
4
import pandas as pd import numpy as np glass = pd.read_csv("D:\\ExcelR Data\\Assignments\\KNN\\glass.csv") # Training and Test data using from sklearn.model_selection import train_test_split train,test = train_test_split(glass,test_size = 0.2) # 0.2 => 20 percent of entire data # KNN using sklearn # Impor...
50fbe933e1d54367eb19501f1221059e73439877
majidgourkani/python
/100Code/26.py
453
3.9375
4
class employee: def __init__(self, firstname, lastname): self.fname = firstname self.lname = lastname def employee(self): return self.fname + ' ' + self.lname names = [] for i in range(2): firstname = input("insert fisrt name: ") lastname = input("insert last name: ") names....
dbf55c749214bf21293e973f62c4a06db3f6b863
mattmcguin/hacker-rank-challenges
/day2/day2.py
700
3.5
4
def minimumBribes(q): minimum_bribes = 0 for x, p in enumerate(q): # If the person is more than 2 places ahead then it's too chaotic if (p - 1) - x > 2: print("Too chaotic") return # Check at most two places in front of where we are and see if bribes took place ...
e87de1935a1afe9b01e90cf3a95ffc83a3df3f6f
massey-high-school/2020-91896-7-assessment-chhabrap71760
/02_Choose_shape.py
2,625
4.375
4
# Component 2 - Choose shape # Shape Choosing Function (Allows the user to enter the right letter assigned to their desired shape) def choose_shape(shape_list): valid = False while not valid: shape_input = input(''' ----------------------------------------------- Which shape would you like to use out...
36de01450f10d08c8f23d91c3ca005d5e3485cf3
June-fu/python365
/2021/02february/07read_fwf.py
814
3.5
4
#!/usr/bin/pyton ''' # @ Author: june-fu # @ Create Time: 2021-03-13 23:17:28 # @ Modified by: june-fu # @ Modified time: 2021-03-13 23:17:31 # @ Description: the read_fwf() function works with data files that have known and fixed column widths. ''' import pandas as pd # a typical fixed-width data file "bar.cs...
eca821fecb22c3e9da0d2074ca8cf1549d5bbce0
euyouer/python-cev
/curso-aula_em_video/Ex 004 - Verificação de um input.py
630
3.953125
4
recebido = input('Digite algo: ') tipo_primitivo = type(recebido) espaco = recebido.isspace() numero = recebido.isdigit() alfab = recebido.isalpha() alfanum = recebido.isalnum() maiu = recebido.isupper() minu = recebido.islower() capit = recebido.istitle() print('O tipo primitivo é {}'.format(tipo_primitivo)) print('...
75a1a3637b259467adb262be3b9ee952e6c18430
anryzhang/python
/python_base/for.py
323
3.890625
4
#coding:utf-8 fruits = ['banana','apple','mango'] for index in range(len(fruits)): print "Current fruits is " + fruits[index] else: print 'no fruits' print "="*10 for t in fruits: print 'current fruits is ' + t if t == 'apple': print 'my love it ' + t else: print 'are you love i...
15b8f315a833aba87a82c41f8d83415688004653
aswin24/python-program
/positiveorneg.py
105
3.96875
4
n = input("Enter a number") if int(n) > 0: print ("Positive") elif int(n) < 0: print("Negative")
eb1af9b176fd63b260b908c85f932b852115edc3
gabriellaec/desoft-analise-exercicios
/backup/user_346/ch74_2019_04_04_15_08_10_445388.py
306
3.59375
4
def conta_bigramas(string): dicionario={} lista=[] i=0 while i<len(string)-1: lista.append(string[i]+string[i+1]) for e in lista: if e in dicionario: dicionario[e]+=1 else: dicionario[e]=1 return dicionario
ce8ad1bdc86f6408f36d77cb34be2e64425ee610
amakaa/dev-sprint4
/chap11.py
921
3.765625
4
#Amaka Atoyebi #11.9 readFile = open('words.txt') line = readFile.readline() word = line.strip #11.10 def rotate_word(string, integer): letters = string.split() new = "" for letters in string: if letters.isupper(): start = ord('A') - 1 elif letters.islower(): start = ord('a') - 1 else: return letter...
4b5a62d268f888ccf499bfbcd9f5d4726a79be54
BrettMcGregor/w3resource
/string28.py
223
3.8125
4
# Write a Python program to add a prefix text # to all of the lines in a string def add_prefix(): text = "just\nsome\nlines\nof\ntext." for line in text.splitlines(): print("." * 10 + line) add_prefix()
2d1f0d95cc9aa065714ba11dbd89c2dc8d1922ea
ChaosNyaruko/leetcode_cn
/208.实现-trie-前缀树.py
2,272
4.15625
4
# # @lc app=leetcode.cn id=208 lang=python3 # # [208] 实现 Trie (前缀树) # # https://leetcode-cn.com/problems/implement-trie-prefix-tree/description/ # # algorithms # Medium (69.38%) # Likes: 481 # Dislikes: 0 # Total Accepted: 64.7K # Total Submissions: 93.2K # Testcase Example: '["Trie","insert","search","search","...
6d4de4d4b020205a4c7422a13fd3ae805d8a4e45
YuyaKagawa/atcoder
/ABC/030/A_勝率計算.py
156
3.5625
4
##### 解けた ##### A,B,C,D=list(map(int,input().split(" "))) if B/A>D/C: print("TAKAHASHI") elif B/A<D/C: print("AOKI") else: print("DRAW")
35a508162181454534fe1cedb503deda741f71af
Linuxfun1990/python-projektek
/03_constructor.py
522
3.6875
4
class Cup: color = None empty = True def __init__(self, color, empty): self.color = color self.empty = empty class Empoloyee: def __init__(self, name, email, phone, address): self.name = name self.email = email self.phone = phone self.address = address john = Empoloyee( "John", "john@gmail.com",...
6243e5931cb0ea57074cb88ebb6985d6279f664b
guweimo/Previous-exercises
/python/python demo/demo.py
1,526
3.984375
4
# coding=utf-8 class Stack(): # 栈 def __init__(self, size): self.size = size self.stack = [] self.top = -1 def push(self, ele): # 入栈 if self.isfull(): raise exception("out of range") else: self.stack.append(ele) self.top += 1...
22dfe9c3d3b755009da234d3c4e6ade5d8bdbeb1
JackKimUSA/leetcode-python-solutions
/344-reverse-string.py
1,746
4.03125
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Sat Nov 21 03:53:17 2020 @author: Jack Kim """ """ Problem: Write a function that reverses a string. The input string is given as an array of characters char[]. Do not allocate extra space for another array, you must do this by modifying the input array i...