blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
35484e36b3380655ece43c59245b42c28a155dda
yharsha/Python
/WebScraping/demo.py
2,030
3.78125
4
print("Starting web scrapping.....!!!") #specify the url wiki = "https://en.wikipedia.org/wiki/List_of_state_and_union_territory_capitals_in_India" #import the library used to query a website from urllib.request import urlopen page =urlopen(wiki) print("page...............") print(page) #import the Beautiful soup funct...
0731bccc1011b80b088801562280498daea84de7
rawanvib/edx_course
/problem set 1/problem_3.py
283
3.953125
4
# Paste your code into this box s res = '' tmp = '' for i in range(len(s)): tmp += s[i] if len(tmp) > len(res): res = tmp if i > len(s)-2: break if s[i] > s[i+1]: tmp = '' print("Longest substring in alphabetical order is: {}".format(res))
2194394e6f72942dca942645728429fd4d0aed55
lingerssgood/AI
/DataShow/special.py
2,323
3.5
4
''' 对应的颜色简写: b 蓝色 m magenta(品红) g 绿色 y 黄色 r 红色 k 黑色(black) c 青色(cyan) w 白色 使用十六进制表示颜色,如#0F0F0F 使用浮点数的字符串表示,即灰度表示方法,如color=“0.4” 使用浮点数的RGB元组表示,如(0.1, 0.3, 0.5) ''' import numpy as np import matplotlib.pyplot as plt x=np.arange(1,10,0.1) y=x*2 plt.plot(x,y,color="c") plt.plot(x,y+1,color="#0F0F0F") plt.plot(x,y+2,color="...
801bee6bbe5a7f9d75b3242586514131def26e9b
pepitogrilho/learning_python
/xSoloLearn_basics/comments.py
511
4.125
4
# -*- coding: utf-8 -*- #..................................................... #comment: number of days in a year d=365 #comment: number of months i a year m=12 print(d/m) #average number of days in a month #..................................................... def shout(word): """ Print a word with an ex...
88465f9b94b20cdfa836bd72c9ceca1d745496af
Testwjm/python_basic
/Basics/iterator_generator.py
3,149
4.28125
4
"""python3迭代器与生成器""" # 迭代是python最强大的功能之一,是访问集合元素的一种方式 # 迭代器是一个可以记住遍历的位置的对象 # 迭代器对象从集合的第一个元素开始访问,直到所有的元素被访问完结束,迭代器只能往前不会后退 # 迭代器有两个基本的方法:iter()和next() # 字符串,列表或元组对象都可用于创建迭代器: list = [1, 2, 3, 4] it = iter(list) # 创建迭代器对象 print(next(it)) # 输出迭代器的下一个元素 # 迭代器对象可以使用常规for语句进行遍历: list = [1, 2, 3, 4] it = iter(list) # 创建迭代...
3f211cfb97ae7d469ea18a7807a7eac613a73697
kangjianma/Card-Game
/Card Game Source Files/test_case.py
6,963
3.546875
4
from CardGame import * test_case = 4 # Functional Test Case if test_case == 1: # Test Case 1 # Test the card is initiated correctly. cardgame = CardGame(card_number=[2, 4, 6], suits=['red', 'yellow', 'green'], points={'red': 3, 'yellow': 2, 'green': 1}, deck_number=1) print(...
a1fa83bcf4c0635ac4eb3d3efd49a44762332ac7
andrewbeattycourseware/pands2021
/code/week07-files/Lecture/messingWithFiles.py
391
3.78125
4
# This program is to demonstrate file io # as part of my lecture # Author: Andrew Beatty with open(".\lecture1.txt", "w") as f: print ("create a file") with open("testdata.txt", "rt") as f : #data = f.read(2) #print (data) for line in f: print ("we got: ", line.strip()) with open("../output.t...
f6a1b9b13d598ec97023f84759402d3d81dd3584
umairgillani93/data-structures-algorithms
/Array_Sequences/Array_Problems/Array_Problem02.py
285
3.5625
4
def pairSum(arr, k): # Edge case if len(arr) < 2: return else: tup_list = [(i,j) for i in arr for j in arr if i+j == k] tup_set = set(tup_list) # return tup_set print('\n'.join(map(str, tup_set))) print(pairSum([1,3,2,2], 4))
e04bdc004935290413ceefbe6faef61333a16c47
yaoshengzhe/project-euler
/problems/python/049.py
1,001
3.578125
4
#! /usr/bin/python import itertools from util.prime import is_prime def is_anagram(num_coll): if num_coll is None or len(num_coll) < 1: return True signiture = None for i in num_coll: sig = ''.join(sorted(str(i))) if signiture is None: signiture = sig elif si...
151f84bf0147d6a063eea1da14dff10112d2beaf
Umutonipamera/pyQuiz
/quiz.py
143
4.25
4
def divisible_by_three(n): new_list= range(n,n+1) for a in new_list: if(a%3==0): print(a) divisible_by_three(100)
6cda3ecc30f9e647ff621fe354705e9269e54440
Julio-vg/Entra21_Julio
/Exercicios/exercicios aula 04/operacao_matematica/exercicio13.py
212
4.15625
4
# Exercicio 13 # Crie um programa que solicite o valor de x (inteiro) # # calcule usando a fórmula x+3 # # mostre o resultado x = int(input("Digite um número:")) formula = x + 3 print("Resultado:", formula)
254a44b662c3f699763e5bedcf8bb81b30531ccc
Bageasw/python
/def.py
336
3.8125
4
dic = {"one": "один", "two": "два","three": "три", "four": "четыре", "five": "пять", "six": "шесть", "seven": "семь", "eight": "восемь", "nine": "девять", "ten": "десять"} def num_translate(): k = input("ввидите слово: ") print(dic.get(k)) num_translate()
f340b50988f1132253b37654ccb5845acde104a3
AbdelaaliElou/forumsWork
/atm/atm_refactored.py
887
3.765625
4
def withdraw(balance, request): if request < 0: print 'pls enter a positive number :)' return balance if request > balance: print('we can\'t give that amount of value!!') return balance print 'current balance =', balance balance -= request while request > 0: ...
5ee2bdb3ee80f42c684179a39e932b2965a785de
amitchoudhary13/Python_Practice_program
/FileOps5.py
2,352
4.46875
4
''' #Open the file is read & write mode and apply following functions #a) All 13 functions mentioned in Tutorial File object table. ''' fo = open("file.txt", "r+") print("Name of the file: ", fo.name) # Close opened file fo.close() fo = open("file.txt", "r") print( "Name of the file: ", fo.name) fo.flush() fo.close...
fcd61a0f7cedde5985f5c8943bcef74bf96fe52d
rafaelperazzo/programacao-web
/moodledata/vpl_data/380/usersdata/334/90933/submittedfiles/testes.py
150
3.671875
4
# -*- coding: utf-8 -*- #COMECE AQUI ABAIXO def maximo int((a,b)): if a>b: return a else: return b x=input() y=input() print(maximo(a,b)
fd0d98228fd69ddee0295d10f5c8bcf5b3a9fb01
610yilingliu/leetcode
/Python3/270.closest-binary-search-tree-value.py
980
3.8125
4
# # @lc app=leetcode id=270 lang=python3 # # [270] Closest Binary Search Tree Value # # @lc code=start # Definition for a binary tree node. class TreeNode: def __init__(self, val=0, left=None, right=None): self.val = val self.left = left self.right = right class Solution: def closestVa...
0b79a2aff3d7465d1bf6347a5db5dd8690381551
bbsathyaa/PYTHON
/task 9.py
490
3.828125
4
#multiply two arguments z=lambda x,y:x*y print(z(2,5)) #fibonacci series def fib(n): r=[0,1] any(map(lambda _:r.append(r[-1]+r[-2]),range(2,n))) print(r) n=int(input("Enter number")) fib(n) #multiply a number to the list l=list(range(10)) l=list(map(lambda n:n*3,l)) print(l) #divisible b...
7ea9e89a89c58291844571f06eb2f1b09147f187
Hayk258/lesson
/kalkulyator.py
554
4
4
print (5 * 5) print (5 % 5) print(25 + 10 * 5 * 5) print(150 / 140) print(10*(6+19)) print(5**5) #aysinqn 5i 5 astichan print(8**(1/3)) print(20%6) print(10//4) print(20%6) #cuyca talis vor 20 bajanes 6 taki ostatken inchqana mnalu while True: x = input("num1 ") y = input('num2 ') if x.isdigit() and y.isdi...
93ee6d8d20734daeb1012c14309031c42b533cc2
Sheetal2304/list
/number.py
328
3.5625
4
list1=[2,1,3,4,5,6,3,2,3,1,4,2,4] list2=[] i=0 while i<len(list1): count=0 j=0 while j<len(list1): if list1[j]==list1[i]: count+=1 j+=1 if list1[i]in list2: i+=1 continue list2.append(list1[i]) if count%2==0: print(list1[i],"",count//2,"pair") ...
bf72dd9bd5d124bc2da84a1c384866e7665f5a12
cookjl/IntroductionToPython
/src/m5_your_turtles.py
2,196
3.6875
4
""" Your chance to explore Loops and Turtles! Authors: David Mutchler, Dave Fisher, Valerie Galluzzi, Amanda Stouder, their colleagues and Jack Cook. """ ######################################################################## # Done: 1. # On Line 5 above, replace PUT_YOUR_NAME_HERE with your own name. ####...
841234ba13cefd6eb016b139b2b297ea7fe9a2ea
Efimov-68/CoursesPython2.x-3.x
/list.py
242
4.03125
4
letters = ['a', 'b', 'c', 'd', 'e', 'f'] ''' if 'a1' in letters: print('Найдено "а" в списке letters') else: print('Символ "а" не найден в списке') ''' if 'a' in letters: letters.remove('a')
03d7d363ce292a8b7163588c556956168888f550
nmap1208/2016-python-oldboy
/Day2/notebook.py
3,669
3.6875
4
# -*- coding:utf-8 -*- from collections import Counter, OrderedDict, defaultdict, namedtuple, deque # Counter是对字典类型的补充,用于追踪值的出现次数。 # ps:具备字典的所有功能 + 自己的功能 print("Counter".center(50, "-")) c = Counter('abcdeabcdabcaba') print(c.most_common(3)) print(''.join(c.elements())) print(''.join(sorted(c.elements()))) print(''.j...
53c12ff549cfb23f0b74f0682614b16a661c39e7
grogsy/python_exercises
/other/oop/contacts_example.py
1,496
3.984375
4
'''demonstrates inheritance and multiple inheritance''' class Contact: all_contacts = [] def __init__(self, name='', email='', **kwargs): super().__init__(**kwargs) self.name = name self.email = email self.all_contacts.append(self) def __repr__(self): # using a dict...
fb2f2523016b044177487fd1e205b3178ce4e7ee
sghwan28/PythonSelf-Learning
/Algorithm/Search/BinarySearch.py
1,256
3.765625
4
from typing import List ''' leetcode 33: 搜索旋转排序数组 set left, right while left < right: set mid if mid = target: return mid if mid > left: if target between left and mid: binary search the new range else: left += 1 elif mid < left: ...
1749024340ee277010fde341ea67f7cc5a41a3fc
r-azh/TestProject
/TestPython/design_patterns/behavioral/state/dofactory/state.py
5,063
3.6875
4
__author__ = 'R.Azh' # Allow an object to alter its behavior when its internal state changes. The object will appear to change its class. # State: defines an interface for encapsulating the behavior associated with a particular state of the Context. class State: _account = None _balance = None _interest ...
58953c5910dee224e691f3be8b79716d30d77171
liuweilin17/algorithm
/leetcode/671.py
1,631
3.734375
4
########################################### # Let's Have Some Fun # File Name: 671.py # Author: Weilin Liu # Mail: liuweilin17@qq.com # Created Time: Thu Jan 17 20:42:20 2019 ########################################### #coding=utf-8 #!/usr/bin/python # 671. Second Minimum Node In a Binary Tree # Definition for a bina...
8cc083cfc3622f478327771f0101e07ecb98927e
HeedishMunsaram/TOPIC_6
/basic form.py
211
4.0625
4
name = input("Enter name: ") age = input("Enter a proper age: ") if age > str(50): print(name + " - You are", age, "years old.") else: print(name + " - You are", age, "years old and still young!")
7474ffe2664a559bfa50636268cdf18929616cf1
maralla/geomet
/geomet/util.py
1,103
4.21875
4
def block_splitter(data, block_size): """ Creates a generator by slicing ``data`` into chunks of ``block_size``. >>> data = range(10) >>> list(block_splitter(data, 2)) [[0, 1], [2, 3], [4, 5], [6, 7], [8, 9]] If ``data`` cannot be evenly divided by ``block_size``, the last block will simpl...
844b5c02f027091294329f947743dcf421893fbb
ILikePythonAndDjango/python_basic
/python_work/name.py
246
3.703125
4
''' name = "ada lavelace" print(name.title()) print(name.upper()) print(name.lower()) ''' ''' Конкатенация ''' first_name = "ada" last_name = "lovelace" full_name = first_name + " " + last_name print("Hello, " + full_name.title() + "!")
402ba6c1512df6df2d4ab2d0cfaf942ab24add02
angelcabeza/AprendizajeAutomatico
/P1/practica1.py
26,940
3.578125
4
# -*- coding: utf-8 -*- """ TRABAJO 1. Nombre Estudiante: Ángel Cabeza Martín """ import numpy as np from sklearn import utils import matplotlib.pyplot as plt np.random.seed(1) print('EJERCICIO SOBRE LA BUSQUEDA ITERATIVA DE OPTIMOS\n') print('Ejercicio 1\n') #Derivada parcial de E con respecto a ...
a0dc1147aa5b828b0c582b9165029b6a780825e1
AntoineBlaud/hashcode
/prepa/TD6/letters.py
577
3.6875
4
def main(): letters = list(input()) letters_set = sorted(list(set(letters)), key = letters.index) best = -1 best_letter = letters[0] for letter in letters_set: indice = [i for i, x in enumerate(letters) if x == letter] if len(indice) < 2: continue current = max(tu...
ac0edb94b8364c0121dd312ed2a1d672c5a66779
taq225/AtCoder
/AGC023/B.py
496
3.5
4
import itertools N = int(input()) table = [input() for _ in range(N)] count = 0 for b in range(N): symmetric = True new_table = [] for i in range(N): string = table[i][b:] + table[i][:b] new_table.append(string) for i in range(N-1): string1 = new_table[i][i+1:] string...
4767e14d9157e6fc7033bf8cce47d6a88bff0c83
nestorghh/coding_interview
/ValidPalindrome.py
275
3.734375
4
def isPalindrome(s): if len(s)<=1: return True if s[0]==s[-1]: return isPalindrome(s[1:len(s)-1]) return False def validPalindrome(s): if isPalindrome(s): return True for i in range(len(s)): if isPalindrome(s[:i]+s[i+1:]): return True return False
ae6f20f8cef6b892a7f34f1f05b2cb367386abc9
Vnd443/python-competitve-codes
/removing-duplicate-in-list.py
706
3.796875
4
# removing duplicate var in given list by rearranging list def remove_duplicate(n, arr): if n == 0 or n == 1: return n temp = list(range(n)) j = 0 for i in range(0, n - 1): if arr[i] != arr[i + 1]: temp[j] = arr[i] j += 1 temp[j] = arr[n - ...
313454aeede2d2358c91076f98a7075fff7fc945
silvertakana/PythonCore
/hw10/code1.py
457
4
4
class Dog: species = 'mammal' def __init__(self, name, age): self.name = name self.age = age dogs = [] dogs.append(Dog("Fake",2)) dogs.append(Dog( "Mickey",7)) dogs.append(Dog("Fuk",5)) def get_oldest_dog(*args): """find the oldest dog""" oldest_dog = args[0] for d in args: if(d.age > old...
e4e5a415ee1862ab176df11b39c01d3a6da905fc
alvin319/book-notes
/tensorflow/mnist.py
3,743
3.53125
4
import tensorflow as tf from tensorflow.examples.tutorials.mnist import input_data # Downloading MNIST data mnist = input_data.read_data_sets("MNIST_data/", one_hot=True) x = tf.placeholder(tf.float32, [None, 784]) W = tf.Variable(tf.zeros([784, 10])) b = tf.Variable(tf.zeros([10])) # Standard soft max y = tf.nn.sof...
df17a6e2688448c756b68f0987f1e5b0e545eaff
benjaminborgen/Number-recognition
/KNearest.py
2,042
3.734375
4
import numpy as np from sklearn.neighbors import KNeighborsClassifier from sklearn import datasets from sklearn.model_selection import train_test_split import Printer as pt def main(): data_mnist = datasets.load_digits() algorithm_name = "K-nearest neighbors" # 75% for training and 25% for testing ...
5094c7be434b63b34be77255926d1a98d06ac708
RomanSPbGASU/Lessons-Python
/L5/L5E1.py
1,111
3.75
4
from re import compile def delete_spaces(strings: list): for i, string in enumerate(strings): string = list(string) for space in range(string.count(" ")): string.remove(" ") strings[i] = "".join(string) def delete_punctuation(strings: list): ptrn = compile(r"[а-яА-Я]+") ...
c8f22f5c536a41e594da037c7c14354b41ede285
jsfehler/stere
/stere/value_comparator.py
1,307
3.75
4
class ValueComparator: """Store a boolean result, along with the expected and actual value. For equality checks, the value of `result` will be used. This object is used to get more robust reporting from Field.value_contains and Field.value_equals when used with assertions. Arguments: resu...
d7e1ce8f19ebf25a73db61fb7b37ffa57f292c2d
hyc121110/LeetCodeProblems
/Sum/maxSubArray.py
591
4.1875
4
''' Given an integer array nums, find the contiguous subarray (containing at least one number) which has the largest sum and return its sum. ''' def maxSubArray(nums): # initialize max sum max_sum = nums[0] for i in range(1,len(nums)): if nums[i] + nums[i-1] > nums[i]: # replaced nums[i...
932d86e9f04277795488d05f5230700b7a727b40
camilogs1/Scripts_UCLA
/Taller1/Parte2/punto7.py
344
4.03125
4
print("\tIngrese los puntos en tres dimensiones para calcular distancia") x1 = int(input("X1: ")) y1 = int(input("Y1: ")) z1 = int(input("Z1: ")) x2 = float(input("X2: ")) y2 = float(input("Y2: ")) z2 = float(input("Z2: ")) d = float(((x2-(x1))**2+(y2-(y1))**2+(z2-(z1))**2)**0.5) print("La distancia entre los puntos...
e07c6bd4c194d8dc74c170717db5a04f2f87c914
Ukabix/python-basic
/core ideas/objects/variable dynamic.py
121
3.703125
4
x=input() print(x) print(type(x)) x=int(x) x=x+2 print(x) print(type(x)) x=float(x) x=x+0.5 print(x) print(type(x))
0f2e53c874185222365ec850f48a50b26f965dd6
Vijayoswalia/Py_work
/newdir/PythonTest.py
767
3.875
4
color_list = ["Red","Green","White" ,"Black"] print(color_list[0],color_list[-1]) import numpy as np data1 =[1,2,5,10,-20] def median(data): x=sorted(data1) if (len(x)%2 == 0): median =(x[len(x)/2]+x[len(x)/2+1])/2 return median else: median = x[int((len(x)-1)/2)] return m...
3c2bff0bbac649c1b842cce8116051ec87318323
kelvinchoiwc/DataScience_1082
/examples/大數據資料分析/範例程式/第10章/program10-5.py
193
3.578125
4
def main(): try: number = eval(input('Enter a number: ')) print('You enterde number is %d'%(number)) except NameError as ex: print('Exception : %s'%(ex)) main()
357fbb95aa5377bb1db3ec5c183b380ea4685284
sanidhyamangal/interviews_prep
/code_prep/searching_and_sorting/sort/sort_peaks_valleys.py
898
3.9375
4
# Reorder an array into peaks and valleys. __author__ = 'tchaton' def peaks_and_valleys(array): if len(array) < 3: return for index in range(len(array) - 1): if index % 2: if array[index] < array[index + 1]: array[index], array[index + 1] = array[index + 1], array[i...
1e64e71742544b857afed28a11ba49a4d37472ce
tharani247/PFSD-Python-Programs
/Module 1/Program-8.py
200
4.03125
4
'''Python script to dispaly largest number among two numbers''' a=int(input('Enter first value')) b=int(input('Enter Second value')) if a > b: print("a is big") else: print("b is big")
6fa899b861e6181e2df57ecc4add9a942a7d0085
theBlackBoxSociety/CodeCrashCourses
/code/RaspberryPiPICO/lcdDemo.py
4,344
3.5
4
# import the required libraries from machine import Pin, I2C from pico_i2c_lcd import I2cLcd import utime # declare pins for I2C communication sclPin = Pin(1) # serial clock pin sdaPin = Pin(0) # serial data pin # Initiate I2C i2c_object = I2C(0, # positional argument - I2C id ...
20510d6e25fdeda598d9c8402e7dd8ab04a66f3d
Hassan-Farid/PyTech-Review
/Computer Vision/Core OpenCV Operations/Basic Image Operations/Accesing Pixels of Image.py
1,079
3.78125
4
import cv2 import numpy as np import sys #Reading image from the Images folder img = cv2.imread('.\Images\image2.jpg') #Accessing pixel from an image using (row, column) coordinates px = img[100, 100] print(px) #Gives us the value of pixel present in the (100,100) coordinate #Accessing only a particular color of pix...
ea950969f8d8cba597b8a84f2692172f3f8edfdd
SERC-L1-Intro-Programming/python-examples
/week4/names.py
409
4.28125
4
# collecting names # program that collects a series of names names = [] while True: print("Enter the name of student number " + str(len(names) + 1) + ".") print("Enter nothing to stop.") new_name = input() if new_name == "": break else: names = names + [new_name] # list concate...
a2dd1b2ae39c27a1c0e67ce7af656e327b7835af
NutthanichN/grading-helper
/week_6/6210545963_lab6.py
8,056
3.96875
4
#1 def ll_sum(s): """ function that sum the list. >>> ll_sum([[1,2],[3],[4,5,6]]) 21 >>> ll_sum([[-5,-2],[11],[10,9,7]]) 30 >>> ll_sum([[4,5,6],[8],[1],2]) 26 >>> ll_sum([[-1,-2],[-3,-4],[-5,-6]]) -21 >>> ll_sum([[0],1]) 1 """ result = 0 for item in s: i...
2cc232c7001cf71e0d216ad22b85e1c2fc5f53e3
nick-snyder/Digital-Portfolio
/Python/Recipe Resizer.py
2,542
4.25
4
# Create a program for Ms. Vashaw that will change the yield output for a given recipe. # For example, if the given ingredients in a recipe serves 4, # the program should be able to increase the amounts in the recipe to (double it or triple it) # or reduce the amounts (half it or quarter it). # The user should be a...
b3fd4110468827f3105792599e8b36d7e39bbdda
srikanthajithy/Emerging-Tech
/Radius.py
119
4.15625
4
import math pi = 3.14 r = float(input("enter the radius:")) area = pi * r * r print("area of the circle:", str(area))
2af664775ca235e34bb20e01865ac428fa861891
snugdad/Intro_to_python
/Mentorship_rep/Day04/02_allyourbase.py
337
4.03125
4
#!/usr/bin/env python3 # By Elias Goodale import sys def ft_bin(n): if n == 0: return '' else: return ft_bin(n // 2) + str(n % 2) def is_integer(n): try: int(n) return True except: print('Not an Integer!') return False def main(argv): if len(argv) == 2 and is_integer(argv[1]): print(ft_bin(int(ar...
afe268f8f733d03240c2728d4fc3036c5c8f0599
vovo1234/pepelats
/games/tiltedtowers/draw_car.py
1,152
3.9375
4
import turtle def DrawCar(size, start_x, start_y): # increase speed turtle.speed(1000) # move to starting point turtle.penup() turtle.goto(start_x, start_y) # calculate scale k = 1.*size/240 # Make wheel turtle.color('black') turtle.begin_fill() turtle.left (90) ...
f89c86f1b91aec2ea043088c16eae6886d7c99bf
haquey/python-sql-database
/src/squeal.py
10,212
4.09375
4
from reading import * from database import * # Below, write: # *The cartesian_product function # *All other functions and helper functions # *Main code that obtains queries from the keyboard, # processes them, and uses the below function to output csv results # USED TO SPLICE THE WHERE CLAUSE BEFORE_OPERAT...
0a9cddc6028c0fed3cead489606187f2587343d9
ahmedhossammontasser/nasa
/nasa.py
1,871
4.28125
4
# python 3.8 import math def get_fuel(mass , gravity, mult_value, sub_value): ''' recursive function that calucalte fuel_needed for launch or land based on equation with gravity and mass (spaceship weigh or fuel_weigh), mult_value and sub_value as parameters :param mass: int gravity: floa...
5f29085f7fd0315c7fbfddd823c0f5c21b5b135a
samtaitai/py4e
/exercise0904.py
683
3.828125
4
#file handler file = input('Enter a file name: ') handle = open(file) lst = list() counts = dict() #find target line for line in handle: if line.startswith('From: ') != True: continue #collect email part and count else: piece = line.split() email = piece[1] lst.append(email) #ma...
10694681fc1cbca96ad21c5705d77481f8beae80
Alex-zhai/learn_practise
/leetcode/25.py
757
3.578125
4
def sum_m(): n_m = input() n, m = n_m.split() n = int(n) m = int(m) if n <= 0 or m <= 0: return arr = range(1, n + 1) result = list() path = list() pos = 0 recursion(arr, pos, m, path, result) for i in result[:-1]: print(' '.join([str(num) for num...
74712b9d0e4e7f798d1a8b96b06373b2f977d3b0
SherMM/programming-interview-questions
/epi/arrays/buy_sell_stock_once.py
1,143
3.765625
4
import sys import random def find_max_profit_bf(stocks): """ docstring """ best_buy, best_sell = 0, 0 max_profit = 0 for i in range(len(stocks)): buy = stocks[i] for j in range(i, len(stocks)): sell = stocks[j] profit = sell - buy if profit >...
0f511b18f43bda9d5703a6cec0a1ff7a7044abe0
massinat/ML
/part2.py
2,007
3.875
4
""" Classification related to part 2. KNN classification with variable K and euclidean distance. Votes are distance weighted. @Author: Massimiliano Natale """ from knn import KNN from resultHelper import ResultHelper """ Trigger the classification. Create the output file and the chart to visualize the result. """ if...
3649b8859547eb3e4112d11fdb84825062a1254e
pillmuncher/yogic
/src/yogic/functional.py
1,503
3.796875
4
# Copyright (c) 2021 Mick Krippendorf <m.krippendorf@freenet.de> ''' Provides functional programming utilities for Python, including functions for flipping argument order and performing a right fold operation on iterables. ''' from collections.abc import Iterable from functools import wraps, reduce as foldl from typi...
234ab716279c2c2de5f5fef056028f1917214ecb
AshishDatagrokr/Python_Assignment
/ques7.py
332
4.28125
4
""" extracting company name """ def extract_name(name): """ will convert name into list """ information = name information = information.split('@') company_name = information[1] company_name = company_name.split('.') print(company_name[0]) EMAIL = input("Enter EmailAddress") extract_n...
02bf6f23224514a497d6984948b4ade9e9c704bf
DianaBereniceSR/07PYTHON
/02SetenciasDeControl.py
146
4.03125
4
#SENTENCIAS DE CONTROL #1) IF a=232 b=87 c=9 if a<b: print("a es menor que b") elif:c<b: print("c es menor que b") else: print("b es menor")
8f90b11a4f4685f59d9ace809170f343ebad7c4d
Sheersha-jain/Data-Structures
/oops/class.py
535
3.625
4
class Test: """test class""" i = 23 def func(self): j=0 print("hello") Test.func(Test) x =Test() print(Test()) print(x) print(Test) print(Test()) class Practice: """practice class""" hello ='hey' def func(self): print("hey hi") print(Practice.__doc__) print(Practic...
85413b2f1af960618421d8d4770658b3238ea838
bghojogh/Curvature-Anomaly-Detection
/CAD/numerosity_reduction/sampleReduction_DROP.py
13,646
3.640625
4
import numpy as np from sklearn.neighbors import NearestNeighbors as KNN # http://scikit-learn.org/stable/modules/generated/sklearn.neighbors.KNeighborsClassifier.html # Sample Reduction with DROP: # Paper: Reduction Techniques for Instance-Based Learning Algorithms class SR_Drop: def __init__(self, X, ...
0aa1f7093254f63879020e7df6b8ef892879cd64
Hecvi/Tasks_on_python
/task12.py
232
3.734375
4
hours1 = int(input()) min1 = int(input()) sec1 = int(input()) hours2 = int(input()) min2 = int(input()) sec2 = int(input()) clock1 = hours1 * 3600 + min1 * 60 + sec1 clock2 = hours2 * 3600 + min2 * 60 + sec2 print(clock2 - clock1)
6a19453cd08176b474461fbe295cc2e29505a0cd
taku-yaponchik/tasks4
/task4.1.py
728
4.125
4
def season(month): #если меньше 3, то будет зима. month ровняю к 12. значит меньще 3(12,1,2) if month <=2 and month>=1 or month==12: return "Winter" #дою альтернативное условия если меньше или равно 5ти elif month <=5 and month>=3: return "Spring" #если меньше или равно 8 ...
f759561498d21e9f2492d381c20f2b78b53cee81
peguin40/cpy5p4
/q4_print_reverse.py
337
3.78125
4
#q4_print_reverse.py # reverses an integer def reverse_int(n): if int(n)<10: return str(n) else: return str(n%10)+reverse_int(n//10) # get inputs while True: try: n = int(input("Please enter an integer: ")) break except ValueError as e: print(e) # main print...
0c5d618176004517a11ee214e01b61348c0a2a0e
tharunnayak14/100-Days-of-Code-Python
/Day-4/coin_toss.py
100
3.65625
4
import random toss = random.randint(0, 1) if toss == 0: print("Heads") else: print("Tails")
8a12b3f829636c78873d0280d218ae0ae103ebdb
julika-77/kpk2016
/numbers/digits.py
295
3.8125
4
x = int(input()) n = 0 s = 0 p = 1 while x: digit = x%10 n+=1 s+=digit p*=digit x//=10 print('количество цифр:',n) print('сумма цифр:',s) print('произведение цифр:',p) print('среднее арифметическое цифр:',s/n)
ee5d1b68e9c322311080537e0362e7b1db05624c
AndrewZhaoLuo/Practice
/Euler/Problem88-.py
1,608
3.515625
4
# -*- coding: utf-8 -*- ''' A natural number, N, that can be written as the sum and product of a given set of at least two natural numbers,{a1, a2, ... , ak} is called a product-sum number: N = a1 + a2 + ... + ak = a1 × a2 × ... × ak. For example, 6 = 1 + 2 + 3 = 1 × 2 × 3. For a given set of size, k, we shall call t...
02552aac50df7d47002512b454cfcb0dc8d98b2d
prabin-lamichhane2000/Reverse-shell
/server.py
1,507
3.796875
4
import socket import sys # create a socket (connect to computers) def create_socket( ): try: global host global port global s host = "" port = 9999 s = socket.socket( ) except socket.error as msg: print( "Socket creation error: " + str...
cfa478c1b1a7fb2ef1ff4f339dd10613885970fb
navyhockey56/hackerrank
/HRordereredDict.py
449
3.640625
4
#https://www.hackerrank.com/challenges/py-collections-ordereddict/problem from collections import OrderedDict n = int(raw_input()) d = OrderedDict() for i in range(n): line = raw_input().split(" ") item = reduce(lambda x,y: x + " " + y, line[0:len(line) - 1]) price = int(line[len(line) - 1]) if item in ...
eccad8d5fa3e0fbe24043a1cdc54f51a5f556900
bhardwaj58/stock_backtester
/compare_plot_fn.py
4,401
3.578125
4
""" Function will take in a DataFrame, list of strategy names, amount of starting cash, ticker that's being tested and the image save location. Output is a plot of the net worth of each strategy in the portfolio over time. """ import os import matplotlib.pyplot as plt import matplotlib.dates as mdates import numpy a...
bbc6b361789515788d91045550139b517baa7f8e
joysn/leetcode
/leetcode1296_divide_array_k_consecutive_array.py
1,704
3.71875
4
# https://leetcode.com/problems/divide-array-in-sets-of-k-consecutive-numbers/ # 1296. Divide Array in Sets of K Consecutive Numbers # Given an array of integers nums and a positive integer k, find whether it's possible to divide this array into sets of k consecutive numbers # Return True if its possible otherwise...
2b581f5773a8fd644f63782766353242618de3ab
deiividramirez/MisionTIC2022
/Ciclo 1 (Grupo 36)/Clases/ControladorCRUD.py
2,587
3.625
4
import CRUD while True: ListaTareas = CRUD.Leer() print("\n---------------------------------------") print("Aplicación CRUD") print("1. Adicionar Tarea") print("2. Consultar Tareas") print("3. Actualizar Tarea") print("4. Eliminar Tarea") print("5. Salir") opci...
71eebfeb01cb46104d9dbe83ef64566bd17751fa
GudniNathan/SC-T-201-GSKI
/recursion 2/elfish.py
584
3.890625
4
def x_ish(a_string, x): if not x: return True if len(x) == 1: if not a_string: return False if a_string[-1] == x: return True return x_ish(a_string[:-1], x) if x_ish(a_string, x[-1]): return x_ish(a_string, x[:-1]) return False def x_ish(...
df3766a2a46a372087795b34b3c8353b8e9989b0
rushirg/LeetCode-Problems
/solutions/count-odd-numbers-in-an-interval-range.py
905
3.71875
4
""" 1523. Count Odd Numbers in an Interval Range - https://leetcode.com/contest/biweekly-contest-31/problems/count-odd-numbers-in-an-interval-range/ - https://leetcode.com/problems/count-odd-numbers-in-an-interval-range/ """ # Solution 1: class Solution: def countOdds(self, low: int, high: int) -> int: ...
ff76abcbedf119a43e9dcc07b62a6f7ae1dce54a
MingiPark/BaekJoon-Python
/Dynamic Programming/2193.py
207
3.609375
4
if __name__ == "__main__": n = int(input()) list = [0]*(90+1) list[0], list[1], list[2] = 0, 1, 1 for i in range(3, 90+1): list[i] = list[i-1] + list[i-2] print(list[n])
94284cfc16417172bf16d76d2ae2c85805613d14
sangm1n/problem-solving
/BOJ/17164.py
430
3.5
4
""" author : Lee Sang Min github : https://github.com/sangm1n e-mail : dltkd96als@naver.com title : Rainbow Beads description : Sliding Window """ N = int(input()) colors = list(input()) result, count = 0, 1 for i in range(1, N): if colors[i-1] == 'R' and colors[i] == 'B' or colors[i-1] == 'B' and colors[i] == '...
1d13e80bd12ae338b825f2881ffaa80a99b0a730
franciscovargas/SELP
/test/test_dice.py
1,191
3.5
4
from random import randint import unittest from app.map_graph import decision_at_node_N import sqlite3 class TestSequenceFunctions(unittest.TestCase): def setUp(self): self.weights = [randint(0,101), randint(0,101), randint(0,101), r...
afb73ba53e812e0d71615bd02dda5f8044cbc98a
IrenaVent/pong
/pruebas.py
852
3.578125
4
import pygame as pg #le ponemos un alias, para no escribir tanto pg.init() pantalla = pg.display.set_mode((800, 600)) # cogemos módulo display de pygame, devuelve una surface, un rectángulo // set_mode(size=(0, 0), flags=0, depth=0, display=0, vsync=0) -> Surface game_over = False while not game_over: eventos ...
60d3986cb6577eedc5b30ec318cacb095a06157a
TiesHoenselaar/AdventOfCode
/2022/day3/puzzle1/puzzle1.py
691
3.8125
4
input_file = "day3/puzzle1/intput.txt" # input_file = "day3/puzzle1/test_input.txt" total_priority = 0 with open(input_file, "r") as input_file: for line in input_file: text_line = line.strip() first_part = text_line[:int(len(text_line)/2)] second_part = text_line[int(len(text_line)/2):] ...
4e0a0c7a188671786a811f6a4f6db2a877bcefbb
nao-j3ster-koha/Py3_Practice
/Paiza_Prac/SkillChallenge/D-Rank/D-71_洗濯物と砂ぼこり/D-71_Washes-and-Dust.py
252
3.65625
4
t, m = map(int, input().split()) while ( t < 0 or t > 40) \ or ( m < 0 or m > 100): t, m = map(int, input().split()) if ( t >= 25 and m <= 40): rslt = 'No' elif( t >= 25 or m <= 40 ): rslt = 'Yes' else: rslt = 'No' print(rslt)
4a8a5741ac1ee2e66aba7092457b89ff684105da
solomonkinard/CtCI-6th-Edition-Python
/Chapter0/BigO/Example3.py
2,199
4.5625
5
def print_unordered_pairs(arr): n = len(arr) for i in range(n): for j in range(i+1, n): print(arr[i], arr[j]) print_unordered_pairs([2,3,4,5,6]) """ Example 3 This is very similar code to the above example, but now the inner for loop starts at i We can derive the runtime several ways. Counting the Ite...
ee4009557e559fd0e6859d6acba1a4c527cbb692
superyang713/Learn_C_from_Havard_CS50
/Duke_Coursera_Programming_C/course_2_Writing_Running_and_Fixing_Code_in_C/week_2/06_rect_practice_algrithm.py
1,626
3.765625
4
class Rect: def __init__(self, x, y, width, height): self.x = x self.y = y self.width = width self.height = height def canonicalize(self): if self.width < 0: self.x = self.x + self.width self.width = -self.width if self.height < 0: ...
0486e08fc8bccee06d79db378d3b3f88ddde81e5
fabriciolelis/python_studying
/coursera/Michigan/chapter_8/number_list.py
217
4.0625
4
numlist = list() while True: inp = input('Enter a number: ') if inp == 'done': break value = float(inp) numlist.append(value) print('Maximum: ', max(numlist)) print('Minimum: ', min(numlist))
b05053d9149a8452534b0fb4672c230b32e5d81a
Larionov0/Group3_Lessons
/Basics/Functions/Homeworks/main.py
159
3.640625
4
numbers = [1, 5, 3, 6, 2, 6, 3, 6, 4, 2, 3, 6] for i in range(len(numbers) - 1, -1, -1): if numbers[i] % 2 == 0: numbers.pop(i) print(numbers)
d115ba80d21a95092f5d249e58bf34391ba11833
toulondu/leetcode-repo
/other-easy/climbStairs.py
1,208
3.90625
4
''' 70. 爬楼梯 假设你正在爬楼梯。需要 n 阶你才能到达楼顶。 每次你可以爬 1 或 2 个台阶。你有多少种不同的方法可以爬到楼顶呢? 注意:给定 n 是一个正整数。 示例 1: 输入: 2 输出: 2 解释: 有两种方法可以爬到楼顶。 1. 1 阶 + 1 阶 2. 2 阶 示例 2: 输入: 3 输出: 3 解释: 有三种方法可以爬到楼顶。 1. 1 阶 + 1 阶 + 1 阶 2. 1 阶 + 2 阶 3. 2 阶 + 1 阶 ''' # 初次设想:可以化作一个数学问题 # 首先,n最多包含n/2个2 # 那么,全为1为一种策略 # 每次增加一个2,计算策略数,比如1个2的时候,总步数为n-1,...
a1665ac001227ad1abcb465ef9d4e83f1de0e227
pilagod/leetcode-python
/google-code-jam-round1-2016/C.py
2,067
3.5
4
class Solution(object): def getMaxCircle(self, num, bffs): def makePath(kid): firstRound = True result = [] result.append(kid) kid = bffs[kid] while True: # print(result, kid, bffs[kid]) if bffs[kid] == result[0]:...
f2316d0c2021c05f47a5ce9a11479d80766464ed
alex-radchenko-github/codewars-and-leetcode
/codewars/6 kyu/Character with longest consecutive repetition.py
869
3.578125
4
from itertools import groupby from collections import Counter def longest_repetition(chars): return list(map(lambda x: list(x[1]), groupby(chars))) # rez = [] # for i in groupby(chars): # rez.append([i[0], len(list(i[1]))]) # #for i in groupby(chars): # # print(list(i[1])) # return tuple...
2db4a62bdaead8d1c5d77dbd2cae32f1f7b1a03b
baobaozi705/answerOfCorePythonProgrammingEdit2
/chapter2/2-7.py
221
3.703125
4
userinput=raw_input('please input a string: ') i=0 while i<len(userinput): print userinput[i] i+=1 userinput=raw_input('please input a string: ') userinput.strip() for i in range(len(userinput)): print userinput[i]
680c60128ef819bcdc7af4a2ec64878a2bc939ac
calpuche/CollegeAssignments
/software2project/Java/softwareEngineeringII/src/MemoryTest.py
733
3.53125
4
# MemoryTest.py # # Author: Eddie # Simple script that performs a memory test on the SUT hardware # This test determines if the program can produce a list with one million items # Prints SUCCESS if successful, FAIL if not # # This program will run on a SUT import random import sys def generateList(someList): try...
cf88c36c9680a32e1386cdd635a9dda66061e6a9
ronika-das/HacktoberFest2019
/src/lab numbers/lab_number.py
416
4.03125
4
#To check whether a number is Lab Number or not def checkLab(n): if n==2: return False else: list1=[] for i in range(2, n//2): if n % i ==0: list1.append(i) list1.append(n/i) for i in list1: if i** 2 in list1: ...
c91efddd83818054eec03b3e4c8f4894b49cdc55
Licas/pythonwebprojects
/HelloWorld/conditions.py
240
4
4
is_warm = False is_cold = True if is_warm: print("It's a hot day") print('Drink a lot of water') elif is_cold: print("It's a cold day") print("Wear warm clothes") else: print("It's a lovely day") print("Enjoy your day")
486147d7ae977a9fa8aec27c0e94b91611ac2bcc
Pongsakorn0/BasicPython
/first.py
1,445
3.8125
4
# print("hello Python") # print(2+3) # print(2**3) # # ,end= ไว้สำหรับ ต่อข้อความ จากบรรทัดต่อไป ไม่งั้นจะขึ้นบรรทัดใหม่ เสมอ # #rint("sss", end="") # print("note_ZA "*3) # print(sum(range(1, 10))) # rang ไม่เอาตัวท้ายไปนับ มีแค่ 1-9 # print("\t pongsakorn") # \t = ย่อหน้า # print("This is = "+"Saturday") # print(...
52d809a6f2ab153f737580f75546440fa2896199
dayanandtekale/Python-Programs-
/fun_def.py
1,007
3.953125
4
#function Declaration and definition # def hello(): # print("Python") # a = hello() # print("called hello function and got value", a) a = int(input("Enter a number")) b = int(input("Enter a number")) def mul(a, b): print("a = ", a) print("b = ", b) return a * b # print(sum(5, 20)) ...
daa95aabfe2bdc399d2930250305e5c28768356e
mrparkonline/python3_for
/solutions/picturePerfect.py
1,203
3.5
4
# CCC 2003 J2 - Picture Perfect user_input = -1 while user_input != 0: user_input = int(input('Enter the number of pictures: ')) if user_input != 0: upper_limit = int(user_input ** 0.5) + 1 # sqrt of user_input # so that we may create squares min_perimeter = 0 side1...
907b642a547db2ef6fa26e584567bfbbd9b48e02
himanshu2801/leetcode_codes
/917. Reverse Only Letters.py
734
3.8125
4
""" Question... Given a string S, return the "reversed" string where all characters that are not a letter stay in the same place, and all letters reverse their positions. Example 1: Input: "ab-cd" Output: "dc-ba" Example 2: Input: "a-bC-dEf-ghIj" Output: "j-Ih-gfE-dCba" Solution... """ class Solution: def re...
ba6d5419577909a3b970eec3149d67d9799a2ef8
githubvit/study
/hfpython/day23/05 元类.py
3,901
3.65625
4
# code=""" # global x # x=0 # y=2 # """ # global_dic={'x':100000} # local_dic={} # exec(code,global_dic,local_dic) # # print(global_dic) # print(local_dic) # # code=""" # x=1 # y=2 # def f1(self,a,b): # pass # """ # local_dic={} # exec(code,{},local_dic) # print(local_dic) # #1、一切皆为对象: # Chinese=type(...) # cl...