blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
fc80f7f6bd5bafc50dc024cceaa600ed668a29a0
ParaschivAlex/FMI-Thangs
/PA/Rezolvari/Lab 1/valori.py
291
3.875
4
n=int(input("care este numarul de valori dorite?")) max1, max2=0,0 for i in range (n): x=int(input()) if(x>max1): max2=max1 max1=x elif(x<max1 and x >max2): max2=x if max1!=0 and max2!=0: print(max1, " ", max2) else: print("Imposibil")
d17dcd9b81fb665df8db06b636c63c59bfe675a4
simonzg/leetcode-solutions
/315.Count_of_Smaller_Numbers_After_Self.py
702
3.703125
4
class Solution: def countSmaller(self, nums): """ :type nums: List[int] :rtype: List[int] """ def mergeSort(arr): half = len(arr)//2 if half: left, right = mergeSort(arr[:half]), mergeSort(arr[half:]) for i in range(len(...
ebeeb2216c6842494491e70ddcad0d0086d706ab
TomJSoftwire/DevOpsWorkshop1
/workshop/calculator.py
4,915
4.1875
4
import math allowed_operators = {'/','x','+','-','%','^'} def parse_calculation (parameter_list): if len(parameter_list) != 3: print('Incorrect number of values entered') return False if parameter_list[0] not in allowed_operators: print('Invalid operator') return False ...
d54a5558d5afcc055933579d4c51f8f44766214c
mhargroder/Python-Snips
/Collections_Counter.py
432
3.640625
4
#import the function from collections library from collections import Counter as c #sample object namelist = ['mike','john', 'gary','mike','john', 'mike'] print(c(namelist)) print(c(namelist).items()) print(c(namelist).most_common(2)) #Set the 2 most values and their counts to a lit of touples popul...
064e2b0d631c15ed711e80caa202f269cd46e3d4
CHAITHRALJ/countries
/restcountries.py
610
3.671875
4
import json,requests # importing the packages def getData(): # fuction to get the data url = "https://restcountries.eu/rest/v2/all?fields=name;topLevelDomain" # url which is containaing the information header = {'content-type': 'application/json'} # the data which is in JSON format r = requests.get(url).text...
a078cf8fd75a2c054b29362318f71da9b1b1f0c3
DamienHall/Maze-Maker
/MazeMaker.py
4,295
3.609375
4
import numpy as Math from random import randrange """ Script by https://github.com/LilZcrazyG """ class Grid: def __init__(self, window, size): self.window = window self.width, self.height = self.window.return_size() self.size = size self.rows = int(Math.floor(self.heig...
91ac17f90e64c6ab6bd27605f6803ed00b16a84c
vividsky/python-programs
/fibonacci_memiozation.py
479
4.0625
4
cache = {} def fib(n): if n == 1: return 1 elif n == 2: return 1 else: return fibonacci(n-1) + fibonacci(n-2) def fibonacci(n): if n in cache: return cache[n] else: if n == 1: return 1 elif n == 2: return 1 else: ...
242f590fdc7a777c98c7df517c5533455e6c4b3d
skayhan13/Python-Challenge
/PyPoll/Resources/main.py
4,319
4.25
4
# PyPoll # In this challenge, you are tasked with helping a small, rural town modernize its vote counting process. # You will be give a set of poll data called election_data.csv. The dataset is composed of three columns: Voter ID, County, and Candidate. Your task is to create a Python script that analyzes the votes and...
2f75ece734434751103d3109c3443d74949fdef4
lorarjohns/python_code_challenges
/challenges/minimumSwaps.py
732
4.1875
4
import math import os import random import re import sys """ You are given an unordered array consisting of consecutive integers [1, 2, 3, ..., n] without any duplicates. You are allowed to swap any two elements. You need to find the minimum number of swaps required to sort the array in ascending order. """ def min...
e0ef6b02faf36a8c00b2699f6241c8dc449a0e85
lyleRpalagar/sandbox
/Python/pig-latin-translator.py
618
3.8125
4
""" Simple Translator to use user input and translate the word into pig latin version 1.0 date: 3/13/2017 """ # assign variable to ay pyg = 'ay' #grab the users input original = input('Enter a word:') #force the user input to be lowercase word = original.lower() # variable contains first letter of the input first ...
e2bd48f427800ba4330a32b18e11206399eb6485
alu-rwa-dsa/week-1-list-complexity-jules
/.github/q1.py
220
3.6875
4
import time first_point = time.time() n = 0 while True: print("Hello") n = n + 1 if n == 10000: break last_point = time.time() time_n = last_point- first_point print("Time taken is: ") print(time_n)
baf5128d0790e874863a79513db879e1e0d4d88e
tleonhardt/CodingPlayground
/python/dictionary_challenge/dictionary_challenge.py
2,315
4.34375
4
#!/usr/bin/env python3 """ Given an English dictionary to search, create a program that will find all words in the dictionary which match the following criteria: The target word is exactly 7 letters long. The target word contains all the vowels [aeiou] exactly once. Two of the letters in the target word are not v...
c829a11c7f8af7c03cebe8236c02ed02483a28f8
jimdro/Election-Center
/voters_info.py
1,501
3.9375
4
""" Created by Dimitrios Drosos email: dimitriss.drosos@gmail.com """ class Voter: """ At this class i initiate voters name and age and some ohter parameters """ def __init__(self, name,age, address = 0, identity=0): self.name = name self.address = address self.ide...
51f4751df1143b5eb75c891267b1b6a5eade4f57
mbarlow12/treehouse-battleship
/validator.py
2,398
3.921875
4
def validate_cell_choice(input_string, board_size): columns = [chr(c) for c in range(ord('a'), (ord('a') + board_size))] input_list = input_string.split(" ") if len(input_list) != 2: raise ValueError( "Incorrect number of arguments. Please ensure there's a space between the row and c...
5518d952b5ec74fff6ae0711f0fb92bdbdde8881
l-duan/python_basic
/day4/Decorator/Inner_Functions.py
6,477
4.625
5
# -*- coding:utf-8 -*- __auth__ = 'christian' def outer(num1): def inner_increment(num1): # hidden from outer code return num1 + 1 num2 = inner_increment(num1) print (num1, num2) ''' Encapsulation: You use inner functions to protect them from anything happening outside of the function, meaning th...
4e9946250707a924d4add08715fff4d1791dd0f4
OnyisoChris/Python
/Numbers/mathsfunctions2.py
407
4.15625
4
# Number max()method - returns the largest of its arguments print('max(79, 110, 678) : ', max(79, 110, 678)) print('max(-30, 89, 100) : ', max(-30, 89, 100)) print('max(0, 39, -70) : ', max(0, 39, -70)) # Number min() Method - returns the smallest of its arguments print('min(79, 110, 678) : ', min(79, 110, 678)) print(...
0facfc4d546bfa4e2b95376e43edd5ee3c293059
Gaurangsharma/guiv
/covid_cc.py
656
3.5
4
check_name=["ACov","BCov","CCov","DCov","ECov","FCov"] check_letter=["A","B","C","D","E","F"] name=[] letter=[] stack_name=[] stack_letter=[] main=[] score=0 for _ in range(6): k=input() if(_!=5): input() main.append(k) k=list(k) name.append(k[-4::-1]) letter.append(k[-2]) for i in range...
6fd345c32acbfbbaf9119ae906f3b841626215b1
X-21/DeepLearning.ai-Assignments
/4. Convolutional Neural Networks/Week2 Deep Convolutional Models:Case Studies/1_1_Keras Tutorial.py
3,044
3.765625
4
from keras.layers import Input, Dense, Activation, ZeroPadding2D, BatchNormalization, Flatten, Conv2D from keras.layers import AveragePooling2D, MaxPooling2D, Dropout, GlobalMaxPooling2D, GlobalAveragePooling2D from keras.models import Model from kt_utils import * import keras.backend as K import keras def HappyMo...
1f83845d253317eef3a797fb17c63b03425dad02
divyamtalreja/basic-python-program
/uplow.py
299
3.859375
4
def uplow(s): uppercase=0 lowercase=0 for i in range(0,len(s)): if (s[i].isupper()): uppercase=uppercase+1 elif(s[i].islower()): lowercase=lowercase+1 print(uppercase) print(lowercase) uplow("The boy is Good")
015b5529980efbc4f88d7a0d595dadaf9c8ca95a
wgq1995/Data-Structures-and-Algorithms
/链表/链表.py
1,472
4.375
4
class Node: """ 链表结点类 """ def __init__(self, x): self.val = x self.next = None def build_linked_list(val_list): """ 从一个列表按顺序建立链表,返回头结点 :param val_list: list,存Node中的值 :return: Node, 头结点 """ if not val_list: return None head_node = Node(0) cur = he...
ba10b2a53e3229f6ac481fe3097292e0895050fd
saumya-singh/CodeLab
/HackerRank/Sorting/Intro_To_Tutorial_Challenges.py
533
3.984375
4
#!/bin/python3 #https://www.hackerrank.com/challenges/tutorial-intro/problem def binarySearch(v, n, ar): first = 0 last = len(ar) while first <= last: mid = (last + first)//2 if v < ar[mid]: last = mid elif v > ar[mid]: first = mid + 1 elif v ==...
78795d912121e76e533c9c9e6bfc0c56318fa537
rkitzrow/MidTerm
/MidTermProj.py
8,053
3.625
4
#This flask asks users to select a coin, investment value, and investment date and will return the current worth #This flask will also return a plot of the coin returns from the initial investment date to today #I import all the packages and libraries needed for this app. from flask import Flask, render_template, requ...
1287c57942faf60d12d03955509778cb830a3ce1
Danny7226/MyLeetcodeJourney
/normal_order_python/206.ReverseLinkedList.py
750
3.984375
4
''' 206. Reverse Linked List Easy Reverse a singly linked list. Example: Input: 1->2->3->4->5->NULL Output: 5->4->3->2->1->NULL Follow up: A linked list can be reversed either iteratively or recursively. Could you implement both? ''' class Solution: # iteratively def reverseList(self, head: ListNode) ->...
df15c52f70ba919734e53e109f679e220d475520
ChrisKneller/fundamentals
/sorting/mergesort.py
2,669
4.1875
4
from collections import deque import numpy as np def mergesort(iterable, final_length=False): ''' Return a new list containing all items from the iterable in ascending order. This uses a custom implementation of mergesort that utilises a deque. final_length should not be input and is there to ensure t...
e0637c28db4eec20241c1543e00b5b10aa08d872
Paruyr31/Basic-It-Center
/Basic/Homework.5/649_.py
269
3.546875
4
n = input("input the text: ") z1 = 0 z2 = -1 for i in range(len(n)): if n[i] == "z": z1 += i break for i in range(z1 + 1, len(n)): if n[i] == "z": z2 += i break count = z2 - z1 # count of simvols, from 'z' to 'z' print(count)
0627bc29400b783ed5bf32bd83ba5de53b3e152d
bjarki88/Projects
/prof1.py
525
4.15625
4
#secs = int(input("Input seconds: ")) # do not change this line #hours = secs//(60*60) #secs_remain = secs % 3600 #minutes = secs_remain // 60 #secs_remain2 = secs % 60 #seconds = secs_remain2 #print(hours,":",minutes,":",seconds) # do not change this line max_int = 0 num_int = int(input("Input a number: ")) # D...
e01e7b007f7041fccc232fc3e9ab9ecacb44dec4
kradical/ProjectEuler
/p9.py
467
4.15625
4
# A Pythagorean triplet is a set of three # natural numbers, a < b < c, for which, # a2 + b2 = c2 # For example, 32 + 42 = 9 + 16 = 25 = 52. # There exists exactly one Pythagorean triplet # for which a + b + c = 1000. # Find the product abc. def test(): for a in range(1, 333): for b in range(1000-a): ...
ee7a4a17a11e14be07256224feb495e51a6125d9
rajat00420/sandbox
/activity02.py
222
3.671875
4
__author__ = 'jc441938' scores = [] score = int(input("Score: ")) while scores >= 0: scores.append(scores) score = int(input("Score: ")) if scores !=[]: print("Your highest score is", max(scores))
d561371e0f6c240cc7bf7c2b9a27be937cb4e3e4
GuangkunYu/python
/数据分析/NumpyPro/3.2数组的基本操作1.py
281
3.5
4
import numpy as np # 数组操作的算术运算符会应用到元素级别 a = np.array([20, 30, 40, 50]) b = np.arange(4) print(a) print(b) # 减法操作 c = a - b print(c) # 乘方操作 print(b ** 2) # sin操作 print(10 * np.sin(a)) # 比较大小操作 print(a < 35)
2f377125ce3efe3515353417d9168d49f514ef43
Krondini/CSCI-3104
/Assignments/Assignment_PS7b/Rondini-Konlan-PS7b-Q3.py
774
3.9375
4
''' # Takes in a list and its bounds as parameters # Function will split the list in half recursively # in order to search for the maximum h-index # Will return the maximum h-index of the list ''' def calcIndex(N, left, right): median = len(N)//2 if (len(N)%2) == 0: #Even number of elements, adjust median medi...
ef2f528fb3f7a3641e261b3b6d9236943829086b
MirkoNardini/tomorrowdevs
/Workbook - cap7/Exercise_152_Number_the_Lines_in_a_File.py
678
3.515625
4
name1 = input("Inserire il nome del file: ") name2 = input('Inserire un nome per il nuovo file:') name1 = 'C:\\Users\\Mirco\\Desktop\\es python\\Files\\' + name1 name2 = 'C:\\Users\\Mirco\\Desktop\\es python\\Files\\' + name2 try: t = open(name1, "r") line = t.readline() count = 0 TFile_res = ...
555525fc583ceb3f1a49f2bf535079a354b19d78
renanaquinno/python3
/#ATIVIDADES_FABIO/#Atividade_Fabio_04_Repeticao_While/#Atividade_Fabio04_Repeticao_04_divisao_por_dois.py
176
4.1875
4
#entrada numero = int(input("Informe o Numero: ")) #processamento def divisao (numero): while numero > 1: numero = numero / 2 print(numero) divisao(numero)
0a0359597566f949b42b833b0e231563eba2fa71
yeshayaa/Projects
/makeArray.py
1,689
3.90625
4
from random import randint class SimpleMatrix: """ Two dimensionmatrix. Default matrix 3 x 3 represented as an N x N list of lists. The Matrix is initialized with random integers (0, 1000) """ def __init__(self, n=3): """ initializes random integers. """ sel...
4fde8dc290b8396b1b693d6cb5791cd01412bf53
cshintov/Integer-Sequences
/Fibonacci Sequence/fibonacci.py
577
4.4375
4
# This code will return the nth element of the Fibonacci sequence def fibonacci(n): n += 1 i=1 num1,num2=0,1 if n==1: return 0 elif n==2: return 1 else: while i<n-1: sum=num1+num2 num1,num2=num2,sum i += 1 ...
1b6e7c7232625eae14c07f1776cd4f2eaa8beb43
skanin/NTNU
/Informatikk/Bachelor/V2018/TTM4100/Skeleton UDPPingerClient.py
1,702
3.59375
4
# This skeleton is valid for both Python 2.7 and Python 3. # You should be aware of your additional code for compatibility of the Python version of your choice. import time from socket import * # Get the server hostname and port as command line arguments host = '127.0.0.1' # FILL IN END port = 12...
4d95331c8f69700dc0e14fa00aca28f61ada83b7
deepaktester365/Project_euler
/projects/project_7.py
1,228
3.828125
4
import numpy as np problem_title = "10001st prime" problem_lines = [ "By listing the first six prime numbers: 2, 3, 5, 7, 11, and 13, we can see that the 6th prime is 13.", "What is the 10001st prime number?" ] def problem_statement(): print("Problem Statement:") print("\t", problem_title) for p...
2836e923be98ce460600b4d1f602633f1e11d7de
RogerNoel/Python_workshop
/01 Introduction/syntaxe.py
515
3.84375
4
# est le signe pour commenter le code # assignation de variables : n = 7 message = « Welcome to our workshop » # Affichage avec print() # bloc conditionnel : l’utilisation des deux points « : » # conjuguée à l’indentation permet de délimiter les blocs : a = 0 if a > 0: print(« a est positif ») elif a < 0: p...
c1b92a86eb647ac13f9b7535d46f4ed3a7b01ff4
A01374974/Tarea-07-2
/TareaListas.py
12,324
3.796875
4
#encoding UTF-8 #Alejandro Chávez Campos, A01374974 #Este programa tiene distintas funciones que actúan sobre distintas listas ya asignadas en el programa. def resolverListaValoresPares(): #Esta función regresa los valores pares de listas ya dadas lista1= [1, 2, 3, 2, 4, 60, 5, 8, 3, 22, 44, 55] x=0 listaNu...
23d496fe14d911ec967b20b9f3791e67b66f22b6
sonnyfuture/Ch.05_Looping
/Test.py
197
4.15625
4
for i in range(5): print("I love Python!") for i in range(5): print("Please,") print("Help me learn Python!") for i in range(1,11): print(i) for i in range (2,12,2): print(i)
2b963e12f547ed95eb9b4e8523a02f498f594033
yonwu/thinkpython
/Strings/8.3.py
237
3.84375
4
def is_palindrome(s): if len(s) <= 1: return True elif len(s) > 2: if s == s[::-1]: return True return False if __name__ == "__main__": result = is_palindrome('emme') print(result)
78edc1e932090625704084dc68cb0a27defedad6
kwatts/interview_practice
/algorithms/scripts/incr_decimal_number.py
1,385
3.953125
4
#!/usr/bin/python def incr_decimal(num): """Increment a decimal coded number. [1,2,3] -> [1,2,3] # 123 -> 124. """ for idx in range(len(num) - 1, -1, -1): incremented = num[idx] + 1 num[idx] = incremented % 10 if incremented < 10: return num return [1] + [0] * l...
aad9ca401681db24374833e657c0041e36c2bd3c
zhangzongyan/python20180319
/day0a/m5.py
1,712
3.5625
4
# 高阶函数:函数通过参数传入的方式称为高阶函数 def sum2abs(a, b, f): return f(a) + f(b) n = abs(-10) print(n) # abs 函数名 xiaopang = abs print(xiaopang(-100)) ''' abs = 10 #这是允许的 但不要这么做 print(abs + 100) ''' print(sum2abs(5, -6, abs)) print(sum2abs(100, 120, str)) # 常用的高阶函数之 map def mypow(x, y = 2): return pow(x, y) import collec...
76a9797e9c01e9640937a1a00efa4dec9dfc198d
scissorsneedfoodtoo/automate-the-boring-stuff-coursework
/7-pattern-matching-with-regular-expressions/find-number-regex.py
246
3.546875
4
import re message = 'Call me at 415-555-1011 tomorrow. 415-555-9999 is my office.' phoneNumRegex = re.compile(r'\d\d\d-\d\d\d-\d\d\d\d') # matchObj = phoneNumRegex.search(message) # print(matchObj.group()) print(phoneNumRegex.findall(message))
2dd4aa314fd6dae0eafdb4ba75df3511260e532b
holzru/examples
/Meters_converter.py
1,226
3.6875
4
def meters(x): print x if x >= 10**24: print "{}Ym".format(int(x)/10**24 if float(x)/10**24 == int(x)/10**24 else float(x)/10**24) elif 10**24 > x >= 10**21: print "{}Zm".format(int(x)/10**21 if float(x)/10**21 == int(x)/10**21 else float(x)/10**21) elif 10**21 > x >= 10**18: pri...
5853fc0df29ab99e09b99a456e15d2c245ef9b93
wlsouza/pysnakegame
/pysnakegame/sprites/snake.py
3,890
3.703125
4
import pygame class Snake(pygame.sprite.Sprite): def __init__(self, screen, color, body_part_size): super().__init__() self.screen = screen self.color = color self.body_part_size = body_part_size self.current_direction = None self.body = [(0, 0)] self.rects ...
bc2bbd7212daa63a9bf03850f750761648bbb8ec
vrvelasco/Python-Programming
/[Exams]/victorExam3.py
3,391
4.21875
4
# Victor Velasco (Exam 3) 12/2/19 def main(): MAX = 10 # Constant for size of the list userNum = 0 # Number from the user numberList = [] # Holds numbers choice = 0 # User's menu option name = {1:'First', 2:'Second', 3:'Third', 4:'Fourth', 5:'Fifth', 6:'Sixth', \ 7:'Seventh', 8:'E...
304dbce11fa6de5dced7c50842bae6452edab07e
secondtonone1/python-
/爬虫/output.py
11,462
3.5
4
#-*-coding:utf-8-*- import re ''' from datetime import datetime now = datetime.now() print(now) print(type(now)) from datetime import datetime dt = datetime(2017,12,13,13,7) # 把datetime转换为timestamp print( dt.timestamp() ) from datetime import datetime t = 1429417200.0 print(datetime.fromtimestamp(t)) #根据时间戳转化为...
ed09abc19e382297d78c02e5ff9a5174243bf679
shankar7791/MI-10-DevOps
/Personel/Elankavi/python/practice/feb25/terninary_add.py
139
4.0625
4
a =int(input("Enter the frst number : ")) b = int(input("Enter the second number : ")) print("The largest number is : " , a if a>b else b)
f9b107989ae96ed51b33688f655b4c2003ff29f4
ViVaHa/Encryption_And_Hashing
/Task4.py
2,549
3.5
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Sun Sep 30 23:42:54 2018 @author: varshath """ import base64 from timeit import default_timer as timer from Crypto.Hash import SHA256,SHA512 from Crypto.Hash import SHA3_256 def writeFile(data,fileName): with open(fileName, 'w+') as f: f.wri...
da7d64f8af6bfea5b017a19124438d56585fcffe
magicyu90/LeetCode
/easy/array/baseBallGame.py
1,375
3.65625
4
# coding :utf-8 class Solution: """ 682. Baseball Game You're now a baseball game point recorder. Given a list of strings, each string can be one of the 4 following types: Integer (one round's score): Directly represents the number of points you get in this round. "+" (one round's score): Repr...
f72cc738ae70bbcb1bf0003f01500ed0405b8369
meena29/Python_Assignments
/arrays/maxsum_subarray.py
903
3.875
4
# Given an array of integers, find the contiguous subarray with the maximum sum. The array can contain both negative and positive integers. def maxsum_subarray(arr): maxSum = 0 currMax = 0 #start and end holds the maxSum subarray start = 0 end = 0 #begin is for current traversal begin = 0 for i in ran...
b1aba086196f9f0de02d22e5b6395d8770a1d1c2
yashjaiswal1/CTCI-DSA
/ds/stacks-and-queues/priorityQueueUsingLinkedLists.py
1,612
3.953125
4
from typing import Sized class Item: def __init__(self, priority, data): self.priority = priority self.data = data self.next = None class PriorityQueue: def __init__(self): self.header_node = None def enqueue(self, item): if self.header_node == None: ...
e2db3823e910dc4bc452fb2e363d499e9359c5fd
yangjingScarlett/pythonlearning
/a_basicPython/3datatypes/number.py
1,178
3.8125
4
# coding=utf-8 import math import random # create a object whose type is number num_var1 = 13 num_var2 = 0 # delete number objects del num_var1, num_var2 # number has four different types: create int, long integers, float, complex int_var = -13 long_int_var = 13L float_var = 13.24 complex_var = 3.14j print "======...
60d67202707b434c96bcc28e0da14cf90b57418e
lteu/alg
/dp/editdist.py
1,012
3.625
4
import numpy as np # Edit Distance 3.3 # https://www.geeksforgeeks.org/dynamic-programming-set-5-edit-distance/ # Given two strings str1 and str2 and below operations that can performed on str1. # Insert # Remove # Replace # 1 # str1 = "geek" # str2 = "gesek" # 1 # str1 = "cat" # str2 = "cut" # 3 str1 = "sunday" ...
319d6c1c5232d01e895666835550c1b5e0baf054
xzf199358/Leetcode-practice
/04两个排序数组的中位数.py
972
3.921875
4
#codding=UTF-8 ''' 题目: 给定两个大小为m 和n 的 有序数组nums1和nums2 请找出两个有序数组的中位数 示例:nums1 = [1,3] nums2 = [2] 中位数是2 示例: nums1 = [1,2] nums2 = [3,4] 中位数是2.5 ''' ''' 本题目的解法 可看做就是寻找中位数 因此需要将两个有序数组进行合并 并进行重新排序 重新排序之后 在进行中位数的寻找 ''' class solution: def __init__(self,nums1,nums2): self.nums1 = nums1 se...
529f2e0220752b389e1ea726642e0cd4c78ebf56
TheDycik/algPy
/les1/les_1_task_5.py
289
3.984375
4
# 5. Пользователь вводит номер буквы в алфавите. Определить, какая это буква. n = int(input("Введите номер буквы: ")) n = ord("a") + n - 1 print("Этот номер пренадлежит букве: ", chr(n))
18cda87023f634d62cf76ce538f9d57bdccfb490
tylerkuper11/ICS2019_2020
/Assignment05_HiLo/Program.py
475
3.8125
4
import random print("Welcome. I will give you a random number between 1 and 100 and your job is to guess it.\nPlease use only integers.") randnum = random.randint(1,100) def hiLo(n): if n == True: return if n == False: g =int(input("What's your guess?")) if g < randnum: print("Too low.") hiLo(False) ...
76c10438a341764037038a4c668216d972483b9e
cool-RR/python_toolbox
/python_toolbox/binary_search/functions.py
7,190
3.921875
4
# Copyright 2009-2017 Ram Rachum. # This program is distributed under the MIT license. '''Module for doing a binary search in a sequence.''' # Todo: wrap all things in tuples? # # todo: add option to specify `cmp`. # # todo: i think `binary_search_by_index` should have the core logic, and the # other one will use it....
7b040d19220030647c8445f96814c8dc9fcd2495
Quinton-10/Finance_Calculator
/Finance_calculater.py
2,307
4.3125
4
#Import math for math problems import math #Print user must choose investment or bond and print explenation of both print("Choose either 'investment' or 'bond' from the menu below to proceed:") print("\ninvestment -to calculate the amount of interest you'll earn on interest.") print("bond -to calcu...
e85e6eee3225913b9a9fa84460b0b9abba1f5004
Yumingyuan/algorithm_lab
/polygon_divide.py
2,022
3.546875
4
# -*- coding: utf-8 -*- #构造最优解 def print_solution(i,j,optim_k):#打印i->k->j三角形 if i+1==j:#如果不能形成三角形则返回 return else: print("(V"+str(i+1)+"V"+str(optim_k[i][j]+1)+"V"+str(j+1)+")",end='') print_solution(i,optim_k[i][j],optim_k)#递归多边形打印(Vi->Voptim_k[i][j]) print_solution(optim_k[i][j],j,optim_k)#递归打印(Voptim_k[i][j...
cac8f966ff1fe78313c333f5ee95c3fcfcce6ac8
bluerubic/pythonScripts
/anagrams.py
2,039
4.4375
4
#!/usr/bin/python '''Python Program to find all the anagrams in a file on disk with one line per word. Example input: python anagram.py <filename.txt> Example output: [emit, item, mite, time] [merit, miter, mitre, remit, timer] ''' import argparse from argparse import RawTextHelpFormatter import os import os.path ...
fe70a733c4cc6d914c730fa221d1ce21ecf92c31
akimi-yano/algorithm-practice
/lc/714.BestTimeToBuyAndSellStockw.py
1,556
3.859375
4
# 714. Best Time to Buy and Sell Stock with Transaction Fee # Medium # 2311 # 69 # Add to List # Share # You are given an array prices where prices[i] is the price of a given stock on the ith day, and an integer fee representing a transaction fee. # Find the maximum profit you can achieve. You may complete as many...
2bb3a9b4b3725590a016d7e15ebe4706879e9065
MUSKANJASSAL/PythonTraining2019
/Session5B.py
526
4.125
4
# String Formatting name = "Fionna" age = 31 print("Welcome to our club %s"%(name)) print("Your age is %d"%(age)) print("Hey. %s You are %d years old"%(name, age)) print("Hey",name,"You are",age,"years old") print("Hey" +name) print("Hey " +name) print("Hey, {} You are {} years old".format(name, age)) # Table of a ...
207d11c46caa0e5de02ef2ef6e9f7a1342bb22f7
Uche-Clare/python-challenge-solutions
/neoOkpara/Phase-1/Day7/sumNumbers.py
158
3.734375
4
def sum_of_n_numbers(num): full_sum = 0 for i in range(1, num + 1): full_sum = full_sum + i return full_sum print (sum_of_n_numbers(5))
8a1d3472c1ad4f9dca9956f75696b48a25ba3bd3
jasonlingo/RoadSafety
/Database/InsertHospitalData.py
2,429
3.5625
4
#!/usr/bin/python # -*- coding: utf-8 -*- """ @author: Jason, Li-Yi Lin """ import sys import os sys.path.append(os.path.join(os.path.dirname(__file__), '..')) import sqlite3 as lite from zipfile import ZipFile def ParseHospital(filename): """ Parse hospitals' information from a kmz file produced by "Go...
b706ea78e42e35f3bd3d3ffc59c2253d490801a1
AmonMcDuul/ProjectEuler
/euler9.py
400
4.0625
4
#A Pythagorean triplet is a set of three natural numbers, a < b < c, for which, #a2 + b2 = c2 #For example, 32 + 42 = 9 + 16 = 25 = 52. #There exists exactly one Pythagorean triplet for which a + b + c = 1000. #Find the product abc. nummer = 1000 for a in range(int(nummer/2)): for b in range(a+1,(int(nummer/2))):...
2259634738c2bbfeffdccda8464274622a2c418f
saad-ahmed/Udacity-CS-101--Building-a-Search-Engine
/unit_2_25-factorial.py
287
4
4
#Define a procedure, factorial, that #takes one number as its input #and returns the factorial of #that number. def factorial(k): i = 1 fact = 1 while i<k: n = k * (k - 1) k = k-2 fact = n * fact return fact print factorial(4) print factorial(5)
de610132460295e17b7e3fe58b8ea836943891f2
sernst/airplane_boarding
/boarding/ops/queue/grouping.py
3,041
3.5
4
import math import random import typing import pandas as pd def chunks( settings: dict, passengers: pd.DataFrame, queue: pd.DataFrame ) -> typing.List[typing.Tuple[int]]: """ Creates a list of start and end aisle pairings for the population groups as specified in the configuration...
59ab9b2a37fe7409141f7b4395c5ca39a566304b
kinegratii/PySnippet
/projects/py_pack/tk_demo.py
659
4
4
#coding=utf-8 """ 简单的tkGUI程序 Note:只在python2下有效 """ from Tkinter import * import tkMessageBox class ConfigWindow(Frame): def __init__(self, ): Frame.__init__(self) self.master.title('Tk Demo') self.master.geometry('500x300') self.master.resizable(False, False) self.pack(side...
b5044cc8ed1fb2542fc8a4b9003254d6f7a82455
anubhav-shukla/Learnpyhton
/list_vs_gen.py
406
3.921875
4
import time # list vs generator # memory usage , time # when to use list , when to use generator # list t1=time.time() l=[i**2 for i in range(10000000)] #10 million #it uses near 400 mb print(f"{time.time()-t1} second") # generator t2=time.time() g = (i**2 for i in range(10000000)) #10 million #too less ti...
9ae7822f3d90633db317c75405dce60a79f899df
AdrianMulawka/Udemy-Course
/savings.py
506
4.1875
4
#This program will help you calculate how much money you will save depending on the amount of funds deposited, the interest rate of the deposit and time. initialCapital = 20000 interest = 0.03 maxTimeYear = 10 capital = initialCapital i = 0 for i in range(i, maxTimeYear): capital = round((1 + interest) * capital...
3cc4052ab4a6c8e61dee7025b2ec83bbbea0fe40
awshx/blind_people
/pts_communs.py
6,467
3.65625
4
import cv2 import numpy as np import matplotlib.pyplot as plt def my_function(): print("Hello from a function") #cropImageLeft #Desc : return an img of the top left of an img #Params : # img : picture (from a cv.imread(...) ) #Return : # croppedImg : picture of the top left of the img in param def cropImageLef...
c0d4172e1dbd0128c405eb2db40f267fbe6319b8
erickclasen/PMLC
/lin-reg-basic/multivariate_lr.py
4,947
3.921875
4
import numpy as np def normalize(features): ''' features - (10, 3) features.T - (3, 10) We transpose the input matrix, swapping cols and rows to make vector math easier ''' for feature in features.T: fmean = np.mean(feature) frange = np.amax(feature) - np.amin(fe...
4e403624a90f323d18012966dbbfb5e80ac8904c
tsushiy/competitive-programming-submissions
/AtCoder/ABC/ABC001-050/abc023/abc023b.py
224
3.640625
4
n = int(input()) s = input() t = "b" if s==t: print(0) exit() for i in range(1, n+1): if i%3==1: t = "a"+t+"c" elif i%3==2: t = "c"+t+"a" else: t = "b"+t+"b" if s==t: print(i) exit() print(-1)
e6d5f3e2cd8e245cc8422689a4459bacccf4fb4b
wileyj/public-python
/z-re.py
737
3.671875
4
from operator import itemgetter import re class Solution(object): def test_email(self, email): try: x=re.search('(\w+[.|\w])*@(\w+[.])*\w+[.][a-z].*',email) return x.group() except: pass list = [ "santa.banta@gmail.co.in", "adsf@yahoo", "bo...
5d5ab4ca1e6b5a0119ae8ac7a7ab0c64c1f92441
python-programming-1/homework-3-awesome-k
/collatz.py
458
4.34375
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Tue Jul 16 21:04:45 2019 @author: awesome_k """ def collatz(num): while num != 1: if (num % 2 == 0): num = num // 2 print (num) elif (num % 2 == 1): num = ((num * 3) +1) print (nu...
00c1fe6c002fafedfdbadd6455a2953f18a28fbf
yamscha/repo_class
/03-Python/2/Activities/05-Ins_BasicRead/ReadFile.py
637
4.15625
4
# Store the file path associated with the file (note the backslash may be OS specific) file_name = 'Resources/input.txt' # Open the file in "read" mode ('r') and store the contents in the variable "text" with open(file_name, 'r') as file_object: print("what is file_object var?") print(file_object) print...
df6add4cdc398907c53ce1482dc2abd7d2f711a6
ejohnso9/programming
/AoC/2022/2022-04.py
3,162
3.828125
4
#!/usr/bin/env python """ Advent of Code solution for Day 3: Rucksack Reorganization https://adventofcode.com/2022/day/3 THOUGHTS/IDEAS/DISCUSSION: As on the previous two days, the general pattern is mapping a value function over rows of input, then aggregating (as sum) for all the inputs. That's a prett...
c615d66707c5d5f69d404845df38c38562060c04
vladn90/Algorithms
/Divide_and_conquer/count_inversions/count_inversions_dc.py
2,243
4
4
""" Count inversions in an array. Divide and conquer algorithm based on merge sort. Algorithm description: 1) Base case: length(array) <= 1, i.e. only 1 element in the array, no need to sort and no need to count inversions. 2) Divide array in two halves: left array and right array. 3) Sort recursively and count inversi...
5043495400a4456097e917f15066c5d6163a9a3e
sunnyyeti/Leetcode-solutions
/1147 Longest Chunked Palindrome Decomposition.py
1,580
3.734375
4
# Return the largest possible k such that there exists a_1, a_2, ..., a_k such that: # Each a_i is a non-empty string; # Their concatenation a_1 + a_2 + ... + a_k is equal to text; # For all 1 <= i <= k, a_i = a_{k+1 - i}. # Example 1: # Input: text = "ghiabcdefhelloadamhelloabcdefghi" # Output: 7 # Explanation: ...
b602a3567cb777635b95880396a7ee5ded16b4f3
schultzjack95/Project_Euler
/Problem2/problem2.py
359
3.6875
4
class FibonacciComputer: prev = 0 current = 1 iteration = 0 def advance(self): self.prev, self.current = self.current, self.prev + self.current self.iteration += 1 fc = FibonacciComputer() total = 0 while (fc.current <= 4000000): fc.advance() if fc.current % 2 == 0: ...
135b2c11ce77f7b346c5d9de236f41b055f9fafc
kan2016/mylibrary
/library/algorithm/bipartiteMatching.py
1,093
3.90625
4
# written by Kazutoshi KAN, 2018 # -*- coding: utf-8 -*- from algorithm.graph import Edge # Ford-Fulkerson algorithm def augment(g, u, matchTo, visited): if u < 0: return True for e in g[u]: if not visited[e.dst]: visited[e.dst] = True if augment(g, matchTo[e.dst], matchTo, visited): matchT...
c999758a2e39e5ac18fbaa1deeb253a23c235eb7
VivekPatel15/Intro-to-Programming
/circle practice.py
465
4.28125
4
center = input('Enter the center point of the circle as x,y (no parenthesis): ') point = input('Enter a point of the circle as x,y (no parenthesis): ') #center = (x1, y1) #point = (x2, y2) x1 = float(center.split(',')[0]) x2 = float(point.split(',')[0]) y1 = float(center.split(',')[1]) y2 = float(point.split...
73ccfe6b45c22ad913948c36f25eeebf8d09c671
Built00/Leetcode
/3Sum.py
4,295
3.5625
4
# -*- encoding:utf-8 -*- # __author__=='Gan' # Given an array S of n integers, are there elements a, b, c in S such that a + b + c = 0? # Find all unique triplets in the array which gives the sum of zero. # Note: The solution set must not contain duplicate triplets. # For example, given array S = [-1, 0, 1, 2, -1, -4...
d26db5f0f7742b61c5da643a5854c24d9c93fc58
Prakruthi94/Pylearning
/Simple interest.py
120
3.75
4
p=int(input("Principal Amount")) r=float(input("Rate of interest")) t=int(input("Time period")) si=p*r*t/100 print(si)
6aad85fd1475a9d1207d411cf4bc65858a3cbf97
coryrc/interview-problem-n
/gen_random.py
619
3.6875
4
import random num_sellers = 13 num_buyers = 6 fb = open('buyers.csv','w') remaining_sellers = num_sellers for i in range(num_buyers): print("On buyer %d, remaining sellers %d, how many sellers?" % (i,remaining_sellers)) sellers = int(input()) remaining_sellers -= sellers seller_priority = list(range(nu...
13b94c94b3e939d895284cdb5d98b753c3d8715d
amkelso1/module-6
/more_functions/string_functions.py
258
3.5
4
""" Author: Alex Kelso program: function_parameter.py date: 10/6/2020 purpose: """ def multiply_string(message, n): """return a message a certain number of times""" return message * n if __name__ == '__main__': print(multiply_string('alex', 7))
1c659894c152eb35db37edd1e76645f683b1510f
DenBlacky808/--Python
/3. salary data.py
624
3.515625
4
sum_sal = 0 workers_list = [] salary_list = [] with open("text_3.txt", 'r', encoding='utf-8') as fi_1: words_list = sum([word.split() for word in [line.rstrip() for line in fi_1.readlines()]], []) for i in range(1, len(words_list), 2): salary_list.append(words_list[i]) workers_list.append(words_...
7bbdf30cb8c193d84bb3065b296907950ad0d869
otmane-chaibe/TCP
/Client.py
905
3.96875
4
import sys from socket import* # Get the server hostname, port and data length as command line arguments argv = sys.argv host = argv[1] port = argv[2] count = argv[3] # Command line argument is a string, change the port and data length into integer port = int(port) count = int(count) # Initialize and print data to be...
4001bc48352c8730bfea44916541ed4cb19bbb9d
wisvem/holbertonschool-higher_level_programming
/0x0A-python-inheritance/11-square.py
553
4
4
#!/usr/bin/python3 """Square module""" Rect = __import__('9-rectangle').Rectangle class Square(Rect): """Square class""" def __init__(self, size): """[summary] Args: size (int): size of square """ self.integer_validator("size", size) super().__init__(size,...
0f651b7ce7c9361d5bd480f473d69d51da5acab3
utsav7011/python-prg
/atm card.py
2,427
3.953125
4
#!/usr/bin/env python # coding: utf-8 # In[ ]: print ("welcome to bank kanjoos") restart = 'Y' chances = 3 balance=67.14 while chances>=0: pin=int(input("\n enter the pin of you kanjoos bank card")) if pin == (1234): print("\n you have entered the correct pin \n") while restart not in ('n','n...
96723a3364c1dbbb4bec94c78f53011cfa1fff7d
Mike-droid/CursoPythonIntermedio
/proyecto_2/lists_and_dicts.py
724
3.859375
4
def run(): my_list = [1, "Hello", True, 4.5] #!Lista my_dict = {"firstname": "Miguel" , "lastname": "Reyes"} #!Diccionario super_list = [ #!Lista de diccionarios {"firstname": "Miguel" , "lastname": "Reyes"}, {"firstname": "Facundo" , "lastname": "García"}, {"firstname": "Oscar" , "lastname": "Guerra...
75d2b7cab197fe15fda53d6189cefb4b2157d68e
ignaciorosso/Practica-diaria---Ejercicios-Python
/Listas - Mayor y menor elemento/Problema4.py
718
3.671875
4
# Cargar una lista con 5 elementos enteros. Imprimir el mayor y un mensaje si se repite dentro de la lista (es decir si dicho valor se encuentra en 2 o más posiciones en la lista) entero = [] for f in range(5): entero.append(int(input('Ingrese valor: '))) entero_mayor = entero[0] cont = 0 for x in ran...
5c2a41d3acc0f7dd078608d780a4137a5baa83d3
Nickruti/HackerRank-Python-Problems-
/Validating_phone_numbers.py
467
4.03125
4
#https://www.hackerrank.com/challenges/validating-the-phone-number/problem?isFullScreen=true # Enter your code here. Read input from STDIN. Print output to STDOUT import re n = int(input()) for i in range(0, n): mobNum = str(input()) if len(mobNum) != 10: print("NO") elif len(re.findall("^(7|8|9)",...
960a433ea11af052e6200efbc60cc5bbf8d3be14
Future-Aperture/Python
/exercícios_python/exercíciosMiguel/Curso_Em_Vídeo/Exercícios_61-75/Mundo_2_Ex_64.py
315
4
4
num, soma, count = 0, 0, 0 print("Digite o número '999' para parar o programa.\n") num = int(input("Digite um número inteiro: ")) while num != 999: soma += num count += 1 num = int(input("Digite um número inteiro: ")) print(f"\nVocê digitou {count} números, e\na soma total deles é: {soma}.")
bc6cefcc7cad726d225cbb06c4acf929ee40946c
uneeth/Map-Reduce
/Task2/mapperTask2_1.py
135
3.578125
4
#!/usr/bin/env python3 import sys for line in sys.stdin: words, count=line.strip().lower().split(":") print("%s\t%s"%(words,count))
15cf5a9ef1a1d97a83430ea9a167f5042080d819
lldingding/Python_note
/01-认识python/hm_05_格式化输出.py
344
3.96875
4
#格式化输出 我爱小明 #定义变量 name="小明" #输出 print("我爱%s" % name) #输出float num=12.9764357473536805357821353 print("数值为%.02f" % num) #%.2f同%.02f #输出百分比 25.00% a=25 print("数值为 %.2f%%" % a) print("数值为 %.2f%%" % a*10) #重复十次 print("数值为 %.2f%%" % (a*10)) #输出a*10
552ecb145a836a53c1d7dea17ab8e0f841631f85
mreishus/leetcode
/2020-02/1143.py
2,273
4.09375
4
#!/usr/bin/env python """ Given two strings text1 and text2, return the length of their longest common subsequence. A subsequence of a string is a new string generated from the original string with some characters(can be none) deleted without changing the relative order of the remaining characters. (eg, "ace" is a su...
b5aa146e3d74d45e2cf46df153b4b038bf0302e8
nick-newton2/python_implementations
/topological_sort/passcode.py
1,421
4.03125
4
#!/usr/bin/env python3 import sys import collections ### CHALLENGE 19 Graph = collections.namedtuple('Graph', 'edges degrees') #read from stdin def read_graph(): # Store edges and degrees edges = collections.defaultdict(set) degrees = collections.defaultdict(int) for line in sys.stdin: nums=[...
726427de3aa8d0ad15a5ce7e0b5becb928109400
muzindahub-2018-01/Tarie
/report_card.py
1,892
3.90625
4
import random import os report_book = [] def clear_screen(): os.system("cls" if os.name == "nt" else "clear") def show_help(): clear_screen() print("Would you care to enter a new subject? ") print(""" Enter 'DONE' to stop adding subjects. Enter 'HELP' for help. Enter 'SHOW' to see your...