blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
30720872f4126e68d7544c211b48b2ac8f9bc44b
CARLOSC10/T07_LIZA.DAMIAN_ROJAS.CUBAS
/LIZA_DAMIAN_CARLOS/ITERACION_RANGO/bucle_iteracion_rango03.py
290
3.515625
4
#REPETITIVAS ITERACION RANGO QUE CALCULA CUALQUER CADENA CON SU RESPECTIVO NUMERO DEL 0 AL 15 import os #ARGUMENTO #ASIGNACION DE VALORES cadena=os.sys.argv[1] #PROCESSING DE LA ESTRUCTURA "INTERACION RANGO" for x in range(0,16): print(cadena,"",x) #fin_iterar print("FIN DEL BUCLE")
546670a5f6a51627123c5b1c8f03f307f368fc65
wizardshowing/pyctise
/count_words.py
1,139
4.375
4
# # Count the words in a string. Usually we use regular expression to do this kind of string related works. # from typing import Dict def filter_str(sentence: str) -> str: """Filter a sentence, replacing every the non-alphabet character with a space. """ chars = list(sentence) for i in range(len(char...
7ac94d0ae75a5bec4014b289114f8c3f5db881c3
urchaug/python-scripts
/hcf and gcd.py
699
4.09375
4
# -*- coding: utf-8 -*- """ Created on Fri Aug 31 10:18:52 2018 @author: Urchaug """ #python program to find the HCF of two input number #define a function def hcf(x,y): """this function takes two integers and returns the HCF""" # choose the smaller number if x>y: smal...
09cea7ebd9298becabf9c476dbfbf0aba1f85122
JohnnyRisk/intro_to_robotics
/project_runaway_robot_chase.py
16,508
3.515625
4
# ---------- # Part Three # # Now you'll actually track down and recover the runaway Traxbot. # In this step, your speed will be about twice as fast the runaway bot, # which means that your bot's distance parameter will be about twice that # of the runaway. You can move less than this parameter if you'd # like to slow ...
c8c9f7b0e7109683be9b8620c53e67fbf0ec487a
chendonna/interview_practice
/mergeSort.py
1,591
3.890625
4
""" mergeSort.py """ def mergeTwoLists(l1, l2): # if not l1 and not l2: # return [] i = 0 j = 0 newList = [] while (i != len(l1)) and (j != len(l2)): if l1[i] < l2[j]: newList.append(l1[i]) i = i + 1 else: newList.append(l2[j]) ...
6b32aabbeb120a16e40cdebb1d07bbd82eee12f3
Neodim5/GeekPython
/lesson2/test02/test1.py
320
3.875
4
for el in reversed("abrakadbra"): print(el) print(len("abrakadbra")) print("раз два три".split()) print("четыре_пять_шесть".split('_')) print('_'.join(['раз', 'два', 'три'])) print(''.join(['раз', 'два', 'три'])) print("ехал грека через реку".title())
ae5dd255fc15694ac7d81b09a9f914617ac4010d
AssiaHristova/SoftUni-Software-Engineering
/Programming Fundamentals/list_advanced/inventory.py
909
3.828125
4
journal = input().split(', ') command = input() while not command == "Craft!": command_list = command.split(" - ") if 'Collect' in command_list: if command_list[1] not in journal: journal.append(command_list[1]) elif "Drop" in command_list: if command_list[1] in journal: ...
511bc4d9e44f395dfff24c81d5cec9235d42bd6f
AlexanderMer/SkillUp
/Python/Homeworks/Black_Jack_GUI/Test.py
219
3.578125
4
from tkinter import * main = Tk() canvas = Canvas(main, height=500, width=500, bg="pink") canvas.grid() rec = canvas.create_rectangle(50, 50, 150, 150) print(canvas.coords(rec)) canvas.move(rec, 50, 50) main.mainloop()
f85e0e2325671358dee94874f6009a3e94b43c84
akbota123/BFDjango
/week1/informatics/inf2E.py
113
3.8125
4
import math x=int(input()) y=int(input()) if x>y: print("1") if x<y: print("2") if x==y: print("0")
8fa337e71a30f574228737e2c5123458e7a5ad5c
webable9/webable-python
/codeing_interview/125_Vaild_Palindrome.py
591
3.90625
4
# page_138 : 유효한 팰린드롬 import re # 단순 해결 방법 def isPalindrome(s): return s == s[::-1] s = "malayalam" ans = isPalindrome(s) if ans: print("Yes") else: print("No") # 두번때 해결 방법 class Solution: def isPalindrome2(self, s: str) -> bool: s = s.lower() # 소문자로 변경 s = re.sub('[^a-z0-9]', '', s...
cc7e92738caa9f06bb08d645ed939c006e2bbdb3
nandakishore723/cspp-1
/cspp1-assignments/m11/p4/p4/assignment4.py
1,002
3.84375
4
''' @author : nandakishore723 #Exercise: Assignment-4 #We are now ready to begin writing the code that interacts with the player. # We'll be implementing the playHand function. This function allows the user # to play out a single hand. # First, though, you'll need to implement the helper calculateHandlen function, #whi...
409c23bb3bd1c8af62911e0baf29558bbc8a4f4f
annalundberg/raw-patient-data-to-sql
/py_scripts/timedate.py
6,622
3.875
4
#!/usr/bin/env python '''This program was written to convert various time and date forms found in raw patient csvs into SQL smalldatetime format''' import argparse def get_arguments(): parser = argparse.ArgumentParser( description="reads in csv file, designates columns to convert time&date and designate...
74d69f7228d50cf43f8b181e949616109f8edf1c
JovanJevtic/Algorithms
/py/Quicksort.py
508
3.5625
4
def partition(arr, l, r): i = l - 1 pivot = arr[r] for j in range(l, r): if arr[j] <= pivot: i += 1 arr[i], arr[j] = arr[j], arr[i] arr[i+1], arr[r] = arr[r], arr[i+1] return i + 1 def qs(arr, l, r): if l >= r: return arr p = partition(arr, l, ...
8d9be2afe4604be7dc515a0c17315176697175d0
nchriz/Euler
/proj12/main.py
999
3.578125
4
import math INF = float('inf') def numberOfDiv(n): x = 0 nsqrt = math.sqrt(n) for i in range(1, int(nsqrt)+1): if n%i == 0: x += 2 if nsqrt*nsqrt == n: x-=1 return x def tri(stop): sum = 0 n = 1 while n < stop: sum += n yield sum n +=...
1b74f4c1e5eb8c8e9f91d1b271c9f7ce345d2a07
marcosfelt/sysid-neural-structures-fitting
/common/metrics.py
704
3.5
4
import numpy as np def r_square(y_pred, y_true, w=1, time_axis=0): """ Get the r-square fit criterion per time signal """ SSE = np.sum((y_pred - y_true)**2, axis=time_axis) y_mean = np.mean(y_true, axis=time_axis) SST = np.sum((y_true - y_mean)**2, axis=time_axis) return 1.0 - SSE/SST def error...
d8cf70210d0463734838b24dfc61709d8095a495
junaid340/AnomalyDetection-in-SurveillanceVideos
/Evaluate_V2.py
2,271
3.65625
4
from matplotlib import pyplot as plt import pickle def PlotHistory(history, name, show=True, save=False, path=None): ''' A function to plot the Training loss and Validation loss of the model. Parameters ---------- history : dictionary Dictionary that contains all the training loss ...
39648326d277b4462cdaa937e9958f58d0f9e424
pvr30/Python-Tutorial
/Basic Of Python Section 1 of Course/Strings in Python.py
1,621
4.75
5
my_string = "Hello Python" print(my_string) my_string = 'Hello Python2' # we can also use '' in python print(my_string) another_string = "Hello! 'What are you doing'." print(another_string) another_string = 'Hello ! "What are you doing". ' print(another_string) first_string = "Vishal Parmar" print("Hello "+first_strin...
4b34bbc30595863c8f248a5e64a294abcd700b54
deepakdas777/anandology
/Modules/wget.py
441
4.15625
4
"""Write a program wget.py to download a given URL. The program should accept a URL as argument, download it and save it with the basename of the URL. If the URL ends with a /, consider the basename as index.html.""" import os import urllib import sys def wget(x): r=urllib.urlopen(x) cont=r.read() name=x.split('/')...
a01fc4a94ac45814fe041db385d746ad87487adf
rafaelperazzo/programacao-web
/moodledata/vpl_data/59/usersdata/158/47434/submittedfiles/testes.py
103
3.828125
4
# -*- coding: utf-8 -*- #COMECE AQUI ABAIXO l=int(input('digite o valor de l:')) a=l*l A=a*a print(A)
c42e9e31a2ffd2d59b576aabef22283c4a7ed0ee
Kunika28/positive-numbers-in-a-list
/list.py
184
3.8125
4
list1=[12,-7,5,64,-14] for num in list1: if num>=0: print(num,end=",") list2=[12,14,-95,3] for num2 in list2: if num2>=0: print(num2,end=",")
994b0186a999afd8386d63144b4ef1b565236f07
iamsid2/Machine-Learning-using-Python
/Part 2 - Regression/Section 6 - Polynomial Regression/PolynomialRegression.py
1,356
3.65625
4
#polynomial regression import pandas as pd import numpy as np import matplotlib.pyplot as plt #getting the dataset dataset = pd.read_csv("Position_Salaries.csv") X = dataset.iloc[:,1:2].values y = dataset.iloc[:,2].values #fitting linear regression in the model from sklearn.linear_model import LinearRegression lin_re...
9ae9ccd2971941bc7438c58ae952af50d89b6a3b
tsuganoki/practice_exercises
/ProjectEuler/4.py
515
4.125
4
"""A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 * 99. Find the largest palindrome made from the product of two 3-digit numbers. 998001 10000 """ import itertools import functools def is_pal(n): fwd = list(str(n)) back = list(r...
4008e011efc9d7f07f84df1ace49027f8130e447
sunilktm23/Python-Practice
/for_loop_list.py
69
3.5
4
fruits=['orange','apple','kiwi'] for fruits in fruits: print(fruits)
827ab4519ca041ff32394a5b77afee3db2c627a3
swati-1008/Miles-to-Km-Converter
/main.py
694
4.03125
4
from tkinter import * window = Tk() window.title("Miles to Km Converter") window.minsize(width=400, height=300) window.config(padx = 20, pady = 20) entry = Entry() entry.grid(row = 0, column = 1) label1 = Label(text = "Miles") label1.grid(row = 0, column = 2) label2 = Label(text = "is equal to") label2.grid(row = ...
032cb390599f9b0b085efb52176a63473cf85848
Leyni/mycode
/acm/leetcode_0009.py
479
3.625
4
# -*- coding: utf-8 -*- class Solution(object): def isPalindrome(self, x): """ :type x: int :rtype: bool """ if x < 0 : return False y = 0 z = x while z != 0 : y = y * 10 + z % 10 z = z / 10 if x == y : r...
9906bd4ba9a1f27f07612c2ee197381b94857fc3
Rubixdude7/Python
/DijkstraAlgorithm.py
1,390
3.78125
4
#Python 3 #Nolan Aubuchon #Dijkstra's Algorithm ''' Still needs work, but nonetheless is a proof of concept Note: the leftmost entry of the matrix is the starting position. The furthest right is the goal With the given graph.txt file the output is: minimum cost: 8 0 -> 4 -> 5 -> 6 -> 7 ''' from Matrix i...
5a7b64c01048c0cbae17f299247b58370de7f21c
noobcakes33/Ladder11
/282A_bit++.py
254
4.0625
4
statements = int(input()) x = 0 for i in range(statements): statement = input() if ("++X" in statement) or ("X++" in statement): x += 1 elif ("--X" in statement) or ("X--" in statement): x -= 1 else: pass print(x)
3cd48bd12673a18c17c16ff9f02a890ab51826b1
tkoz0/problems-project-euler
/p193a.py
898
3.625
4
import libtkoz as lib import math limit = 2**50 # count with inclusion-exclusion # subtract numbers with 1 prime square as a factor # add numbers with 2 prime squares as a factor # continue until limit / (2^2*3^2*5^2*7^2*...) is 0 # ~45sec (pypy / i5-2540m) plist = lib.list_primes2(int(math.sqrt(limit))) print(': li...
2375fc9ba793e91170bd7d3b3526ee22d92eaca9
NearJiang/PythonReview
/Class.py
880
3.90625
4
#在Python中,实例的变量名如果以__开头,就变成了一个私有变量(private) #只有内部可以访问,外部不能访问 class Student(object): def __init__(self, name, gender): self.name = name self.__gender = gender def get_gender(self): #get获取什么的 直接return就行 return self.__gender def set_gender(self,gender): #set底下要加= ...
4500f2a8fefcee1b622eb8e5dab68bd6ee0ea933
Suvey57/assignment2
/pa10.py
702
3.953125
4
def change_snake_case(str): res = [str[0].lower()] for c in str[1:]: if c in ('ABCDEFGHIJKLMNOPQRSTUVWXYZ'): res.append('_') res.append(c.lower()) else: res.append(c) return ''.join(res) def changekebabcase(str): res = [str[0].lower()]...
e1f049b8cf95110cda5d2f786b58892881075320
fhansmann/coding-basics
/module-1/email-slicer.py
328
3.9375
4
# get user email email = input("What is your email address?:").strip() # slice out user name user = email[:email.index("@")] # slice out domain name domain = email[email.index("@")+1:] # format message output = "Your username is {} and you domain name is {}".format(user,domain) # display output message print(o...
5f8112047b4f9cd13c544e00e4e2bfdb68857517
pockerman/tech3python
/applications/numerics/example_2.py
1,075
3.6875
4
""" Category: Numerics, Integration ID: Example 2 Description: Calculate PI using Monte Carlo integration Taken From the book: Kalman and Bayesian Filters in Python Dependencies: Details: # TODO: Write details for Monte Carlo integration """ import matplotlib.pyplot as plt import numpy as np from numpy.random impor...
fc988e33387dbdc8c5c68687efca8aa8eba5105d
kashyap92/python-training
/file1.py
263
3.59375
4
#!/usr/bin/python import sys #file=raw_input("enter the file name:") #filename=sys.argv[0] #file=str(sys.argv[1]) file1=open(str(sys.argv[1])) lines=file1.readline() a=1 while lines: print a,lines lines=file1.readline() a+=1 file1.close()
be6e414d39a47cd95a32531efdf81bfb0aef89c4
gahan9/DS_lab
/LPW/two_pass_sort_based.py
11,522
3.84375
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Author: Gahan Saraiya GiT: https://github.com/gahan9 StackOverflow: https://stackoverflow.com/users/story/7664524 Implementation of sorting based two pass algorithm for difference operator """ import os import math from itertools import islice from faker import Faker...
4328f2e45afab5e8e4eef6cf21f440e3fd530f49
Lucas-vdr-Horst/Mastermind-extraExercises
/exercise-1/Palindroom.py
336
4.0625
4
def reverse_string(string): return string[::-1] """new_string = "" for i in range(len(string)): new_string += string[len(string) - (i+1)] return new_string""" def is_palindrome(string): return string.lower() == reverse_string(string).lower() if __name__ == "__main__": print(is_palind...
945d56447945142d04c61682df1a13794d043a23
MastProTech/Advent-of-Code
/2015/25.py
665
3.609375
4
def part_1(find_row, find_col): size=max(find_col, find_row)*2 # Because the table should be square (cols=rows) and half of the table is zero table=[[0 for i in range(size)] for i in range(size)] # Declaring table with zeros num=20151125 # Initial number for limit in range(0,size+1): for i in ra...
57127981adcc3f050b48217c3f8423419983565d
SvenLC/CESI-Algorithmique
/boucles/exercice1.py
282
3.953125
4
# Ecrire un algorithme demande à l’utilisateur un nombre compris entre 1 et 3 jusqu’à ce que la réponse convienne. def nombre_entre_1_et_3(): nb = 0 while (nb < 1 or nb > 3): nb = int(input("Veuillez saisir un nombre entre 1 et 3")) nombre_entre_1_et_3()
9aea7e155bb6f5ac47460baa2c1ac732f321c507
shifteight/python
/pythontips/decorator_demo.py
566
3.640625
4
from functools import wraps def a_new_decorator(a_func): @wraps(a_func) def wrapTheFunction(): print("I am doing some boring work before executing a_func()") a_func() print("I am doing some boring work after executing a_func()") return wrapTheFunction @a_new_decorator def a_functio...
30ada7240528be8d842042b57b97b202e8e553a3
IntAlgambra/candyapi
/candyapi/candyapi/utils.py
866
3.921875
4
from datetime import datetime class WrongTimezoneError(Exception): """ Возвращается при попытке передать дату и время не в UTC или без временной зоны """ def __init__(self): super(WrongTimezoneError, self).__init__("Datetime is not timezone aware") def format_time(t: datetime) -> str: ""...
959fcee23e4fac49ebfbf745cc7ec6f3e38e3a2e
ElephantGit/tensorflow_learn
/tf_basic/my_mnist.py
3,439
3.59375
4
import tensorflow as tf from tensorflow.examples.tutorials.mnist import input_data # save mnist dataset in the folder of MNIST_data mnist = input_data.read_data_sets('MNIST_data', one_hot=True) # define variable weights and biases def weight_variable(shape): initial = tf.random_normal(shape) return tf.Variabl...
bec44ca975a1444b5a61b738d9a62b3eea96c5f0
zipxup/SearchAlgorithm
/SearchAlgorithm/WeightedGraph.py
4,167
3.765625
4
class Node: def __init__(self, key, heuristic = 0): # self.key is the key of node # self.successors are the successors nodes # self.weight is the weight of edges self.key, self.heuristic = key, heuristic self.precessors, self.weight_precessors = [], {} self.successor...
3f165f5bdaa14f0808d4b416beb188e707ff0384
ruozhizhang/leetcode
/problems/string/Maximum_Score_After_Splitting_a_String.py
1,288
3.921875
4
''' https://leetcode.com/problems/maximum-score-after-splitting-a-string/ Given a string s of zeros and ones, return the maximum score after splitting the string into two non-empty substrings (i.e. left substring and right substring). The score after splitting a string is the number of zeros in the left substring plu...
0abab0a476f9870916343fbd4bbea8c8ccd09e86
collin-li/mitx-6.00.1x
/ps4/ps4_2.py
1,434
4.25
4
# PROBLEM # # The player starts with a hand, a set of letters. As the player spells out # words, letters from this set are used up. For example, the player could start # out with the following hand: a, q, l, m, u, i, l. The player could choose to # spell the word quail. This would leave the following letters in the ...
439a0bc5f2b7091c4452deac803ccea1a0e5b756
19973466719/Python--
/图灵学院课程/self learning/003、分支结构/2、循环结构.py
1,304
3.640625
4
''' for循环 for 变量 in 序列: 语句1 语句2... ''' stu_list=['王大燕','李美丽','王晓静'] for stu in stu_list: if stu=='王晓静': print('ni you') else: print('sorry') ''' for else语句 打印列表中的同学, 如果没有在列表中,我们需要打印提示语句表示循环结束 ''' ''' break:无条件结束整个循环,循环猝死 continue:继续下一次循环 pass:占位符 ,代表这句话啥也不干,没有跳过的功能 ''' #break 确定是否包含7 确定就直接打...
ac24d2718663efeea5d745a125c24df26192c41d
lotar69/projet_lj
/src/file.py
461
3.609375
4
#Class Imports: import pandas as pd import numpy as np import matplotlib.pyplot as plt import seaborn as sns df = pd.read_csv("data/water_potability.csv") #Class Info: print(df.info()) print(df.shape) print(df.head()) #Class Cleaning: print(df["Potability"].value_counts()) print(df.isna().sum()) df["Potability...
d3cc5d7da27a71e943eb97d010c98e3d651f34e7
psaux0/ExData_Plotting1
/fl.py
504
3.625
4
#! /usr/bin/env python3.5 def main(): i = 0 with open("data.txt") as f: for line in f: if line.startswith("1/2/2007"): j = i break else: i += 1 for line in f: if line.startswith("3/2/2007"): k = ...
f5950952a13e2e244ae58adda6cedb959870aa36
thisisparthjoshi/Basic-Programs
/Swap.py
156
4.0625
4
# -*- coding: utf-8 -*- x=eval(input("enter x")) y=eval(input("enter y")) x,y=y,x print("after swapping x =",x) print("after swapping y =",y)
2e3fa9b718fb26a1bbf67ed442a65fcb3820e137
ansj11/DeepLearning
/code/python/find_value.py
455
3.703125
4
# -*- coding:utf-8 -*- class Solution: def Find(self,target,array): if len(array)==1 and len(array[0])==0: return False has_value = 0 for i in array: for j in i: if j==target: has_value += 1 else: ...
ccea36440cb4663ff9fb4edfc78779bb64bf795a
MrHamdulay/csc3-capstone
/examples/data/Assignment_8/mrkpet004/question1.py
554
4.34375
4
"""program with a recursive function to calculate whether or not a string is a palindrome peter m muriuki 9/5/14""" def reverse(string): # base case - empty string if len(string)==0: return string # recursive step else: return reverse(string[1:]) + string[0] string=input("E...
203ca8622da45f73d6f198a9bf5a85b0ea51fb00
engineer-kufre/Python-Task-1
/app.py
128
4.28125
4
radius = int(input('Enter radius: ')) area = 3.142 * radius ** 2 print(f'The area of a circle with radius {radius} is {area}')
8eca291454dad5c0db3ed8bcb9412f6fff2552ae
JoaoCFN/Exercicios_DS2
/contabanco/Banco.py
564
3.578125
4
class Banco(): def __init__(self, nome_banco, ano_fundacao): self.nome_banco = nome_banco self.ano_fundacao = ano_fundacao self._lista_agencias = [] def adicionar_agencia(self, agencia): agencia_nao_existe = self._lista_agencias.count(agencia) == 0 if agencia_nao_existe:...
b7f09db495f6a0cdcafc68293537472b22853c30
mervecakirr/study.lib
/2_sinif/donem2/h2/algo_odev_1/main.py
1,602
3.703125
4
# python 3.7 ile çalıştırım0 from collections import defaultdict class Graph: def __init__(self, matrix, select): self.visited = [] self.select = select; self.graph = defaultdict(list); self.edge_count = 0 for ix, line in enumerate(matrix): for iy, edge in enume...
56fff0c8cd74a37ea1d5bf58a310fcc2f0dd0eb7
SwathiChennamaneni/repo1
/Assignments/Assignment_15.py
324
4.3125
4
#Assignment 15 #Take a string from the user and check contains atleast one small letter or not? user_string = raw_input("Enter a String:") count = False for char in user_string: if char.islower(): count = True if count == True: print "\nContains Small Letter" else: print "\nContains No Small Lette...
fded9b144cddb6c04e4789421b4fc11ab1bc4849
KrylovKA/Pytest_iTrack
/Learning Python/Learning_Python.py
1,579
3.875
4
import sys """Day_1 - 23.03.2020""" # Chapter_1(Arguments) print('Hello World!') var = 555 # Целое число print(var) var = 3.155 # Число с плавающей точкой print(var) var = True # Булевая логика True/False print(var) semantic = 5 print(semantic*5+5) # Chapter_2(Input) # # Инициализируем переменную значением, введен...
90bf7f7191abc70e67746a2664f2cff2109596ef
arif-zaman/CSE_BUET
/pagerank-simulation/pagerank.py
6,655
3.71875
4
# CSE411 - Simulation and Modeling """ Instructions: This assignment is to "simulate" Google's pagerank as discussed in class. This is a skeleton program where you need to add your code in places. The program first reads web.txt to load the page network. Each row refers to a page and 0/1 indicates which other pages...
9b7bbc53bdfaeb2e7ba2e2d23c4783c4d55a7cf6
sendos/matlab_utils_for_python
/utils_test.py
1,688
3.59375
4
""" Script with sample usage of the functions in matlab_utils.py Copyright (c) 2017 Andrew Sendonaris. """ # In this script, we convert the following Matlab script for use in Python """ function D = mydist(X) if isempty(X) error('Input matrix is empty\n'); end % Get the number of ...
6dc8cc63107b9593c6bb622fa9e35e0f7af20e09
krumbot/data-structures
/linked_list.py
2,299
4.125
4
# Linked List implementation class Node: def __init__(self, val=None, next=None): self.val = val self.next = next class LinkedList: def __init__(self, head=None): self.head = head def insert_first(self, val): first_node = Node(val) first_node.next = self.head ...
bca421661bc6664f385afaba96ce2d0b18d53ea9
xigaoli/lc-challenges
/295. Find Median from Data Stream.py
1,396
3.8125
4
class MedianFinder: def __init__(self): """ initialize your data structure here. """ #store larger half of numbers self.minh=[] #store smaller half of numbers self.maxh=[] #max heap store the negative value of elem def balance(self)->None: ...
36724dbda0c2945978342c0c8e3d3f86efee2127
angelm1974/Python-zajecia
/pakiety/pakiet_szkoleniowy/moj_modul2.py
2,649
4
4
import time import locale # Korzystając z bibiloteki time oraz metody sleep(): # Program 1 # Napisz program, który odlicza od 1 do 5, wypisując liczby co sekundę. def count_down1(number): for i in range(number): print(i+1) time.sleep(1) #count_down(5) # for a in range(1,6): # time.sleep(1) #...
0efcc274ca440345ef531c17f95d883d001eb664
LeeKrane/Python1
/chapters/chapter2/Part04.py
175
3.59375
4
from random import randrange a = randrange(100, 401) b = randrange(100, 401) if a < b: print("{:3d} < {:3d}".format(a, b)) else: print("{:3d} < {:3d}".format(b, a))
90c6b4d1a25ee75a6caa5f98e3ed6c17411e9abf
sundaqing221/test1101
/工作空间0801/python0807/P0807/__init__.py
490
3.78125
4
# -*- coding: UTF-8 -*- # 1 print "hello world !"; # 打印 # 所以如果大家在学习过程中,代码中包含中文,就需要在头部指定编码。 counter = 100 # 整型变量 miles = 1000.0 # 浮点型变量 name = "runoob" # 字符串 print (counter) print (miles) print (name) # Key=True # # if Key==True: # print "Answer" # print "True" # else: # print "A...
85024025e0f9d66d54b1d2c1fb2079aa858d86f1
gwambui/MathLogic
/Q3c.py
1,458
3.59375
4
#[p -> (q -> r)] -> [(p -> q) -> r] def IMP(a): # imlies method result =[] for row in a: if row[0] == row[1]: result.append(1) elif row[0] > row[1]: result.append(0) elif row[0] < row[1]: result.append(1) return ...
4eecdd704a6b975d31487b2ba8b2824edd62a3ed
edneyefs/curso_python_fundamentos
/08DESAFIO017.py
237
4.125
4
from math import sqrt co = float(input('Digite o comprimento do cateto oposto: ')) ca = float(input('Digite o comprimento do cateto adjacente: ')) hy = (co**2) + (ca**2) print('O comprimento da hipotenusa é de {:.2f}'.format(sqrt(hy)))
4f438d90649683115f9c7f299b45a61c76d5bf07
christophemcguinness/DifferentTypesofListsProgram
/main.py
1,316
4.0625
4
num_strings = ['13', '44', '100', '23'] num_int = [13, 44, 100, 23] num_float = [2.0, 3.4, 55.0, 12] num_list = [[1, 2, 3], [2.3, 34.4, 100.0], ['test', 'new', '12345'], [4, 3, 2]] # Stings print("\nThe variable num_strings is a {0}".format(type(num_strings))) print("It contains the elements: {0}".format(num_strings))...
9f2763a042e319ff7023c2e05f351d95d87e0954
Uncccle/Learning-Python
/22.py
1,517
3.640625
4
# 面向对象 # 面向对象就是化简代码 # 面向对象就是将变成当成一个事物(洗衣机) # 面向对象--类和对象 # 面向对象编程过程中,有两个重要的组成部分: 类与对象 # 编程就是设置洗衣机能够做什么事情,再用这个洗衣机 # 那么洗衣机怎么来的? # 回答:--------工厂 # 准确回答是: 工厂工人根据设计师的功能图纸设计出来的 # 详细细节回答: 图纸 ---> 洗衣机 ---> 洗衣服 # 图纸: 用来创建洗衣机 # 在面向对象编程中: # “类” 就是这个图纸; “对象” 就是这个实物(洗衣机) # 类和对象的关系: 用类...
a5a9b31ef832af71f58347688f3df331ab0d96c9
zxldev/helloPy
/hello/helloLIstGen.py
637
3.78125
4
# -*- coding: utf-8 -*- import os #生成列表 print([x*x for x in range(1,50)]) #带条件生成 print([x*x for x in range(1,50) if x % 5 == 0]) #循环生成 print ([(m,n) for m in 'ABC' for n in range(1,6)]) #循环生成,带条件 print([ (a,b,c) for a in range(1,100) for b in range(a,100) for c in range(b,100) if (a*a + b*b == c*c)]) #打印当前目录文件 print ...
de20e0ad8a269698e996fb09ff3ab8ae16d201da
aloix123/Simple-pingpong
/ball.py
827
3.515625
4
import pygame from settings import Settings """klasa , która tworzy piłeczkę , jej rozmiary krztałt i ruch""" class Ball(Settings):# piłeczka def __init__(self, screen,f): super().__init__() self.bal_rect=pygame.Rect(self.ball_gps1,self.ball_gps2,self.ball_size,self.ball_size)# kwadracik ...
88d434e8be5945e48062950cda5a7ebbd52a3ad2
109156247/C109156247
/41.py
257
3.703125
4
import math a = int(input("a:")) b = int(input("b:")) c = int(input("c:")) x1 = (-b+(((b**2)-(4*a*c)))**0.5)/(2*a) x2 = (-b-(((b**2)-(4*a*c)))**0.5)/(2*a) if x1==x2: print(str(x1)) elif (b*2)-(4*a*c)<0: print("0") else: print(str(x1),str(x2))
33aaebf0bebff605ed5fa4cb112064b4abbb76a0
freeshyam/lc
/207_course_schedule.py
3,116
3.734375
4
#!/usr/bin/env python import unittest from collections import deque, defaultdict """ class Solution(object): def canFinish(self, numCourses, prerequisites): # :type numCourses: int # :type prerequisites: List[List[int]] # :rtype: bool courses = list(range(numCourses)) cour...
43871db3ced13d9cc15b9710d9135ae57324a32d
AngryBird3/gotta_code
/leetcode_oj/countAndSay.py
866
3.90625
4
''' The count-and-say sequence is the sequence of integers beginning as follows: 1, 11, 21, 1211, 111221, ... 1 is read off as "one 1" or 11. 11 is read off as "two 1s" or 21. 21 is read off as "one 2, then one 1" or 1211. Given an integer n, generate the nth sequence. ''' class Solution(object): def countAndSay(self...
f30b80441fb7eceeae3a87da409555ffb262dbbb
alvinaashraf/PythonAssignment
/assignment1.py
485
3.890625
4
import sys import datetime print("Twinkle , twinkle little star, \n \t how wonder what you are\n\t\t up above the world so high\n\t\tlike a diamond in the sky\n twinkle twinke little star\n \t how i wonder what you are ") print(sys.version) n=datetime.datetime.now() print(n.time) print(n.date) num = i...
9131710037a5917640893e39b18afb207d242106
esraertsak/Python-Projelerim
/Kosullu Durumlar/ödev_1.py
767
4.09375
4
""" Problem 1 Kullanıcıdan alınan boy ve kilo değerlerine göre beden kitle indeksini hesaplayın ve şu kurallara göre ekrana şu yazıları yazdırın. Beden Kitle İndeksi: Kilo / Boy(m) * Boy(m) BKİ 18.5'un altındaysa -------> Zayıf BKİ 18.5 ile 25 arasındaysa ------> Normal BKİ 25 ile 30 arasındaysa --------> Fazl...
472e0df87d0ecd7acdba9b52e68b36ee8401b118
sellenth/algorithms
/q1.4.py
422
3.640625
4
def isPalindrome(s1): d = {} for c in s1: if c is not ' ': if c not in d: d[c] = 1; else: d[c] += 1; found_single = False; for key in d: if d[key] % 2 != 0: if found_single == False: found_single = True...
08028043ced5a509a9614954724650a435235378
SebaGiordano/Programacion_Orientada_a_Objetos
/Ejercitacion_2/ejercicio_8.py
1,050
4.5
4
''' 8. Operaciones de orden con tres números Realizar un programa que tome tres números, los ordene de mayor a menor, y diga si el tercero es el resto de la división de los dos primeros. ''' print("Debera ingresar 3 numeros\n") lista = [] for i in range(0, 3): num = input(f"Numero {i+1}: ") lista.append(num) ...
02c3a59708f89e6c76f6a077433e67e386e4758b
Brendan8497/game_example
/ex45.py
20,127
3.96875
4
# Brendan Ryan # 11/2/2016 # Ex45 from sys import exit from random import randint from stats import luckCount from stats import strength from stats import stealth from stats import intelligence class Scene(object): def enter(self): print "This scene has not been made." exit(1) # ends the program # Engine of t...
3f4e02068c4da5c08bce30b7b943e42db67afaa5
rayvantsahni/after-MATH
/Permutations/permutations_with_repetition.py
480
3.984375
4
def get_permutations(arr, left, right): if left == right: print("".join(arr)) else: for i in range(left, right + 1): arr[i], arr[left] = arr[left], arr[i] get_permutations(arr, left + 1, right) arr[i], arr[left] = arr[left], arr[i] if __name__ == "__main__":...
8264db493d518586e15cb77bebcb1b4929b92a60
GiangHo/CodeFight
/14_alternating_sums.py
213
3.71875
4
def alternatingSums(a): team_1 = 0 team_2 = 0 for i in range(len(a)): if i%2 ==0: team_1 = team_1 + a[i] else: team_2 = team_2 +a[i] return [team_1, team_2]
4a4782022e2cbe606e5874298e8a232c79d9b311
sligocki/wikitree
/graph_min_cycle.py
1,977
3.578125
4
""" Find minimal cycles through a given node in graph. """ import argparse import random import networkx as nx import graph_tools import utils def min_cycle(graph, start_node): # Map node -> path paths = {start_node: []} todos = [] # Start us off with neighbors of start_node (the path directions). for d...
eb36bb76c20d62f8a8b0d3ba0d9d34dbc4ce653c
sidaf/scripts
/missing_numbers.py
1,528
3.53125
4
#!/usr/bin/env python2.7 import argparse import sys def missing_numbers(num_list, start, end): original_list = [x for x in range(start, end + 1)] num_list = set(num_list) return (list(num_list ^ set(original_list))) ######## # MAIN # ######## if __name__ == '__main__': desc = 'List missing ports fr...
06b23549b897c22fe42f321b12adbbd3b831c33c
mahesh4555/python_scripts
/copy_files_from_a_sub_dir_to_same_sub_dir_in_another_main_dir.py
1,806
3.65625
4
# handles the incremental_updates # move(replace or add) the files present in main1 dir to main2 dir #main1 and main2 directories have the same directory structure, that is, it contains the same sub-directories #If any files are present in main1 dir, it will be moved to the main2 dir def copy_files_from_a_sub_dir_to_...
208cc27dabf53e926c3de6ff66e585c51dd11197
e56485766/280201109
/lab3/example1.py
206
4.4375
4
# Write a Python code that asks the user for # a number, calculate the absolute value of # the number and print it. number = float(input("Number: ")) if number < 0: number = number * -1 print(number)
66b92f6764c866037dcac4a24288eea2ab8898fb
luca-tansini/advanced_programming
/Cyber/ngrams.py
670
3.609375
4
def findngramsinword(word,ngramlen,dictionary): for i in range(0,1+len(word)-ngramlen): ngram = word[i:i+ngramlen] if(dictionary.get(ngram)): dictionary[ngram] += 1 else: dictionary[ngram] = 1 def isword(str): for w in str: if(not('A' <= w <= 'Z' or 'a' <= w <= 'z' or '0' <= w <...
a09b650302114c97cbba965cd07bf4422cfada58
AmritaDeb/Automation_Repo
/PythonBasics/py_programas/Assignment_13_12_18/Fibonacii.py
164
3.515625
4
class Fibonacii: def fibonacii(self,n): a, b = 0, 1 for i in range(n): print(a) a,b=b,a+b ob=Fibonacii() ob.fibonacii(4)
a074eb1eb1d7751d8ce3f8d601f97157314b4427
takafumihoriuchi/learning_ReadableCode
/original1.py
8,569
3.765625
4
#a game of reversi (original) import sys class Board(object): board = [] def __init__(self, row, col, blank): self.row = row self.col = col self.blank = blank def createBoard(self): for i in range(self.row): self.board.append([self.blank]*self.col) def setBoard(self, set_row, set_col...
878ffea24ca0d8889c77f800551742ab3b515878
munger100/ProjectEulerPython
/Completed/4.py
292
4
4
largest = 0 for one in range(100, 1000): for two in range(100, 1000): num = one * two if str(num) == str(num)[::-1]: if num > largest: largest = num print("Largest Palindrome Product of two 3 digit numbers is %s." % largest) # Answer: 906609
be49779c1e197373cbf73b3294a06f68d1b01dc1
saurabh-kumar88/Coding-Practice-
/Codebasics/Python_Advance_topics/multiprocess.py
1,204
3.953125
4
from multiprocessing import Process import time import math #passing data B/w process using global variable....... result = [] def cal_sqr(sqr): for n in sqr: result.append(n*n) print("\nFrom Inside of function :" +str(result)) def cal_cube(cube): for m in cube: result.append(m*m*m) print("\nFrom ...
fe4fc9a259a6a06cfc82768f0c1528298f7e3944
p7on/epictasks1
/6.3.del_element_list.py
126
3.984375
4
names = ['John', 'Paul', 'George', 'Ringo'] names = [elem for elem in names if elem == 'John' or elem == 'Paul'] print(names)
73fb819191c49ef12da49f614a9b440cda98994a
antoninabondarchuk/algorithms_and_data_structures
/linked lists/unique_list.py
813
3.84375
4
# Definition for singly-linked list. class ListNode: def __init__(self, x): self.val = x self.next = None def __str__(self): result = '' s = self while s: result += str(s.val) + '->' s = s.next return result[:-2] def deleteDuplicates(hea...
e49eb2c43f8aff63e8f821cd1f4d25a2f1c79c7b
akrias/projects
/practice/flip.py
828
3.625
4
#!/bin/python import numpy as np def flipAndInvertImage(A): """ :type A: List[List[int]] :rtype: List[List[int]] """ #print len(A) #print len(A[0]) output = [] for mat in A: mat = mat[::-1] #print mat # numpy solution '''a = np.array(mat) ...
cfd369359d34757d936a22db8c618dd86f2b5a9c
sling254/madlibs
/madlibs game.py
1,508
3.828125
4
name = raw_input("enter your name: ") name2 = raw_input("enter your name: ") chore = raw_input("Chore you hate to do:") Adjective = raw_input("Adjective (a word that describes someone): ") chore2 = raw_input("Another chore you hate to do: ") party = raw_input("Name a kind of party: ") noun = raw_input(" Noun (thing, o...
0f140b5b3e9efab6f23212372a6df2f579f962b7
D4nB113/Euler_Projects
/Euler3.py
270
3.609375
4
def largest_prime_factor(number): factor = number counter = 2 while counter <= factor ** 0.5: if factor % counter == 0: factor = factor / counter counter -= 1 counter += 1 if factor >= 2: return factor
1f416156238c48ff1e88c674f70d69363c28c9a1
B-R-H/Tic-tac-toe
/player.py
1,902
3.59375
4
import random as r def random_player(board): #Random player not_placed = True while not_placed: x=r.randint(0,2) y=r.randint(0,2) if board[x][y]==None: return [x,y] def check_line(start_cordinate,direction,board): line_values = [] if direction == "v": #virtical code for i in range(3): line_value...
cbbd9ea34445ee45c301e2ff90433526e44f8c76
fanliu1991/LeetCodeProblems
/43_Multiply_Strings.py
2,308
4.3125
4
''' Given two non-negative integers num1 and num2 represented as strings, return the product of num1 and num2, also represented as a string. Note: The length of both num1 and num2 is < 110. Both num1 and num2 contain only digits 0-9. Both num1 and num2 do not contain any leading zero, except the number 0 itself. You ...
5d6e3416acd2d5c88595513385d1537173caa66a
shadowkael/some_single_py
/LintCode/search_matrix.py
497
3.90625
4
def searchMatrix(matrix, target): # write your code here if not matrix: return False if target < matrix[0][0]: return False if target > matrix[-1][-1]: return False for item in matrix: if item[-1] >= target: for num in item: if n...
54ac12d913965204f925a85f5a1d914e1751edc1
navneettomar11/learn-py
/hackerrank/NestedList.py
813
3.75
4
from typing import List def findStudentSecondLowestGrade(students: List): lowest = 9999999999 secondLowest = 0 nameList = [] for student in students: score = student[1] if lowest > score: secondLowest = lowest lowest = score elif lowest != score and seco...
38b09fdc75c81cf254cf28a3edfba630fdfe080a
xxd/algorithm004-04
/Week 08/id_049/LeetCode_151_049.py
233
3.625
4
class Solution: def reverseWords(self, s: str) -> str: s = s.strip() tmp = [] for i in s.split(" "): if i != "": tmp.append(i) tmp.reverse() return " ".join(tmp)
7ccd8f02b4089baa1f82f88d04019fca23926e50
fbhs-cs/CS1-classcode
/Misc/matrix.py
4,171
3.59375
4
#!/usr/bin/env python3 import random import curses import time #Sleep between frame after refresh so that user can see the frame. Value 0.01 or lower results in flickering because the # animation is too fast. SLEEP_BETWEEN_FRAME = .04 #How fast the rain should fall. In config, we change it according to screen. FALLI...
accfeb2823421760f736c87a13bd14ee62100ff9
pentagram5/Python_study
/조건문 반복문 활용하기.py
13,918
3.96875
4
# -*- coding: utf-8 -*- ############################################################################################# """if문 활용하기""" a = 200 a = 50 if a<100: print("100보다 작다 ") else : print("100보다 크다 ") print("==========결과================") price = int(input("구입금액을 입력하시오:")) if price > 100000: price = pri...
2562a5e6bb63c7e94a0488fda432697bba45638a
sunrain0707/python_exercise_100
/ex44.py
339
3.828125
4
#44.两个 3 行 3 列的矩阵,实现其对应位置的数据相加,并返回一个新矩阵: X = [[12,7,3], [4 ,5,6], [7 ,8,9]] Y = [[5,8,1], [6,7,3], [4,5,9]] sum = [[0,0,0], [0,0,0], [0,0,0]] for i in range(0,3): for j in range(0,3): sum[i][j]=(X[i][j]+Y[i][j]) print(sum)
47d5e896d05111a48b4f4fcd441e7b5d98992bcc
shantanu609/Competitive-Coding-10
/PeekingIterator.py
1,108
4.03125
4
# Did this code successfully run on Leetcode : Yes # Any problem you faced while coding this : No # Your code here along with comments explaining your approach class PeekingIterator: temp = None def __init__(self, iterator): """ Initialize your data structure here. :type iterator: Itera...