blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
43f484dc485ff29975bea1a2427d8b502d0ff4b6
eeandr/assignments-Andronov
/Assignment_4_AE.py
1,081
3.5
4
#! /usr/bin/env python from __future__ import print_function, division # Task 2 """" :param a: str :param b: str """"" def p_distance(a,b): if len(a) != len(b): raise ValueError('lengths differ') diffs = 0 gaps = 0 for pair in zip(a,b): if pair[0] == pair[1]: ...
b60c5b69b64f747b0e8006ac22b56979d6f16198
Sravaniram/pythonprogramming
/mirror list or not.py
108
3.640625
4
s=int(input()) a=input().split() l=input().split() if(sorted(l)==a): print("yes") else: print("no")
38179717b10493e88e3763bd31da34707767ed05
Alessandro-Francia/Compiti-per-10-12
/es_3.py
486
3.9375
4
vocali = ["a","e","i","o","u", " "] while True: italiano = input ("dimmi una parola o una frase in italiano") rovarspraket = "" for lettera in italiano: if lettera not in vocali: rovarspraket += lettera + "o" + lettera else: rovarspraket += lettera pr...
fe8bd8d77032563b3fc5f61a43463c583b845983
erick1984linares/t08_linares_rojas
/rojas/iteracion.py
1,184
4.1875
4
#6. ITERACION+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ #1.Imprimir la palabra nam="mejor" for letra in nam: print(letra) #2.Imprimir la palabra nem="ser" for letra in nem: print(letra) #3.Imprimir la palabra pen="temido" for letra in pen: ...
ce770d24d7ebbdb7ce872495559d9cca76b6cedb
yejiiha/BaekJoon_step
/for/2739.py
191
3.8125
4
# Say the multiplication tables. n = int(input()) if 1 <= n <= 9: for i in range(1, 10): print(f"{n} * {i} = {n*i}") else: print("1~9 범위의 정수를 입력하시오. ")
4aabaf3d797a74ae0aead09a958e14408fe8fa83
khand420/Learn-Python
/Exersice/Try_Catch_Exception.py
445
3.859375
4
# a = input("What is your Name") # b = input("How much do you Earn") # if int(b) == 0: # raise ZeroDivisionError("b is 0 so stopping the Program") # if a.isnumeric(): # raise Exception("Number are not allowed") # print(f"Hello{a}") c = input("Enter you name: ") try: print(a) except Exception as e: ...
1773a9a7ae20bb934ec85ee643a9f50f8fd3ffcf
genkinanodesu/competitive
/AtCoder/ABC/abc107/abc107d.py
1,782
3.609375
4
''' ☆長さnの数列Aの中央値がxであるとは 1.x以上の要素が (n + 1)// 2 個以上 2.そのようなxの中で最小 ということ。 ''' class BIT: def __init__(self, n): self.bit = [0] * (n+1) def sum(self, i): ''' :param i: :return: bit[i]までの和 ''' s = 0 while i > 0: s += self.bit[i]...
d80d6ef2509569dc71fbdf40e168b650e8731030
Bagnis-Gabriele/Sistemi_e_Reti_Quarta
/python/00007_carte.py
1,183
3.953125
4
""" Bagnis Gabriele Esercizio 7: Correzione della verifica sulle carte """ import random """ classi: carta """ #creazione della struttura class carta(object): def __init__(self, seme, numero): self.seme = seme self.numero = numero def stampa(self): print(f"la carta ha seme {self.seme} ...
50e673f64544f95a18e7781a1627d5b07207632e
DenisYavetsky/PythonBasic
/lesson6/task5.py
1,449
3.703125
4
# 5. Реализовать класс Stationery (канцелярская принадлежность). Определить в нем атрибут title (название) и метод draw # (отрисовка). Метод выводит сообщение “Запуск отрисовки.” Создать три дочерних класса Pen (ручка), Pencil (карандаш), # Handle (маркер). В каждом из классов реализовать переопределение метода draw. Д...
22e0d7c2ead704db650cf27a148aeb513695c466
Maykit/fizzbuzz
/fizzbuzz.py
449
4.34375
4
# Fizzbuzz counts up to entered number and prints "fizz" if a number can be divided by 3, "buzz" if a number can be divided by 5 and "fizzbuzz" if a number can be divided by both 3 and 5. enter = int(raw_input("Select a number between 1 and 100: "))+1 for var in range(1,enter): if var % 15 ==0: print "fi...
ab6b7cdf2aa3fe423fb8db14887587dfcec9d393
ricardowiest/Python_CURSO
/Ex042.py
522
4.0625
4
m1=float(input('Digite a 1ª medida: ')) m2=float(input('Digite a 2ª medida: ')) m3=float(input('Digite a 3ª medida: ')) if m1+m2>m3 and m2+m3>m1 and m1+m3>m2: print ('Pode ser formado um triângulo.') if m1==m2==m3: print ('\033[1:31mEsse triângulo é equilátero.\033[m') elif m1!=m2!=m3!=m1: ...
9ab8dbc702336569a990e175e350ea06883662c2
williamHuang5468/leetcode
/Third Week/347 Top K Frequent Elements.py
1,864
3.71875
4
''' 法一 使用 build-in,去排序 dictiionary ''' ''' class Solution(object): def topKFrequent(self, nums, k): """ :type nums: List[int] :type k: int :rtype: List[int] """ numberDict = {} for i in nums: if i not in numberDict: n...
53ff9ae81f67500932ccb3ed4dc09619b44bddf7
jinruiiii/MIT-6.0001
/Pset1/Pset1c.py
2,238
4
4
# Part C: Finding the right amount to save away # User input annual salary salary = int(input("Enter starting salary: ")) # Calculate the initial monthly salary monthly_salary = float(salary/12) # Cost of dream house total_cost = 1000000 # Cost of down payment down_payment = 1000000 * 0.25 # Initializing number of st...
9859bfe30175d9c14a11798c1737872495778e10
Mauricio-KND/holbertonschool-higher_level_programming
/0x02-python-import_modules/0-add.py~
173
3.890625
4
#!/usr/bin/python3 from add_0 import add def adding(): a = 1 b = 2 print("{:d} + {:d} = {:d}".format(a, b, add(a, b))) if __name__ == "__adding__": adding()
3e53c0331261f783aed4dbeeb966a16999b99b47
rafaelperazzo/programacao-web
/moodledata/vpl_data/29/usersdata/109/9642/submittedfiles/atividade.py
193
3.71875
4
# -*- coding: utf-8 -*- from __future__ import division import math n=int(input('Digite o valor de n:')) cont=0 while True: s=(n//10) cont=cont+1 n=s if s<1: break print cont
b6b6ff27aef268805658abbfc90af042eafa9058
ursu1964/Algorithms-in-Python-1
/06-Stacks-Queues-Deques/Exercises/Project/P6-34.py
720
4
4
import stackarray as Stack def postfix_evaluate(expr): """Evaluate the given postfix operation""" stack = Stack.ArrayStack() operators = ['*','+','-','/','^'] for char in expr: if char not in operators: stack.push(int(char)) else: num1 = stack.pop() ...
f9cf1f688a94969ad4a17440cabd0995c80825d8
Arj09/mca101_manisha
/evil.py
196
3.59375
4
def evilNumber(num): count = 0 binnum = bin(num) length = len(binnum) for i in range(2,length): if binnum[i] == '1': count += 1 if count % 2 == 0: return True else: return False
3e5e9df93970036f8ef7bbda4b6fb74579b396b8
xiu-du-du/akk8
/Python-directory/0905.py
3,432
4.21875
4
# 选择结构 ''' year = 2020 # 单分支 if year > 2021: print("不是2021") # 双分支 if year > 3030: print("未来") else: print("现在") # 多分支 if year < 1998: print("1") elif year == 2000: print("2") elif year >= 2020: print("3") else: print("4") # 多层选择结构的使用 day = 2020 moon = True if day >= 2020: if moon: ...
4226389aa2099cee2b9bff59483e77f77c195077
CBJNovels/python_study
/venv/Training/P3_Training_exception.py
1,492
4.15625
4
# #异常 # try: # print(5/0) # except: # print("You can't divide by zero!") # # #处理ZeroDivisionError异常 # print("Give me two numbers,and I'll divide them.") # print("Enter 'q' to quit.") # # while True: # first_number=input("\nFirst number: ") # if first_number == 'q': # break # second_number=in...
f59927407db804c0469205b9df7640a40cee03d0
AdamZhouSE/pythonHomework
/Code/CodeRecords/2120/60631/254317.py
153
3.90625
4
n = int(input()) if n==2: print(1) else: three = n//3 el = n%3 if 3**three*el==27: print(36) else: print(3**three*el)
8bf0b2ea708648027644c80bdb0bb09b7bbb5a2c
AkiraXD0712/LeetCode-Exercises
/Container With Most Water.py
1,269
3.859375
4
import json """ Given n non-negative integers a1, a2, ..., an, where each represents a point at coordinate (i, ai). n vertical lines are drawn such that the two endpoints of line i is at (i, ai) and (i, 0). Find two lines, which together with x-axis forms a container, such that the container contains the most water. N...
1dfe30c1be5f61a95a450188504d8323711ecd7e
RonCoves/Distributed_Systems
/week_02/domain/visit.py
1,611
3.53125
4
from datatype.enums import DartMultiplier class Dart: def __init__(self, multiplier, segment): self.multiplier = multiplier # see datatype.enums.DartType; optionally create this as a property and validate self.segment = segment # 1 to 20, 0 for miss / double-bull / single-bull def get_sc...
1907cff370cca0dfda185d0ee2b5684525c4817b
darraes/coding_questions
/v2/_leet_code_/0040_combination_sum.py
2,741
3.53125
4
import itertools def sort_list(k): for l in k: l.sort() k.sort() return list(k for k, _ in itertools.groupby(k)) class Solution: def combinationSum2(self, candidates, target): """ :type candidates: List[int] :type target: int :rtype: List[List[int]] ""...
1a22f23fabe7fcc68a864e8f1be6e22c7b5cf3b9
gabriaraujo/uri
/src/python/1015.py
244
4
4
# -*- coding: utf-8 -*- import math x1, y1 = input().split() x2, y2 = input().split() x1 = float(x1) x2 = float(x2) y1 = float(y1) y2 = float(y2) distance = math.sqrt((x2 - x1) ** 2 + (y2 - y1) ** 2) print("%.4f" %(distance))
8b78b378e37dd2a0231bee8d2bf60076f19bb626
sakorrap/courses-algos
/Assignments/Lab4_quickSort.py
601
3.765625
4
def PARTITION(A,p,r): x=A[r] i=p-1 for j in range(p,r): if (A[j] <= x): i = i+1 temp = A[j] A[j] = A[i] A[i] = temp temp = A[i+1] A[i+1] = A[r] A[r] = temp return i+1 def QUICKSORT(A,p,r): if (p<r) : q = PARTITION(A, p, r) QUICKSORT(A,p,q-1) QUICKSORT(A,q+1,r) return A def main(): # given...
a93ee8593491a8afb2f5a312a2658a4065e334b1
OctopusHugz/holbertonschool-web_back_end
/0x00-python_variable_annotations/102-type_checking.py
409
3.921875
4
#!/usr/bin/env python3 """This module focuses on using mypy""" from typing import Iterator, List, Tuple def zoom_array(lst: Tuple, factor: int = 2) -> List: """This function returns zoomed tuple""" zoomed_in: Iterator = ( item for item in lst for i in range(factor) ) return list(zoomed...
cae3ca78923b99003507998de297aae844773b91
zhanglintc/leetcode
/Python/Sudoku Solver.py
2,958
3.984375
4
# Sudoku Solver # for leetcode problems # 2015.03.20 by zhanglin # Problem Link: # https://leetcode.com/problems/sudoku-solver/ # Problem: # Write a program to solve a Sudoku puzzle by filling the empty cells. # Empty cells are indicated by the character '.'. # You may assume that there will be only one unique solu...
0572e94ace21c3508f5383571fa20526ad0fd90c
RDinary/python_06_20
/guess_game.py
375
4.09375
4
from random import randint low = int(input("enter low number")) high = int(input("enter high number")) random_num = randint(low, high) while True: guess = int(input("enter your guess")) if guess > random_num: print("enter lower number") elif guess < random_num: print("enter higher number"...
14d0fe2a9f095e0e6bfe5a81d2f2f4cc4166744b
crazywiden/Leetcode_daily_submit
/Widen/LC765_Couples_Holding_Hands.py
1,827
3.703125
4
""" 765. Couples Holding Hands N couples sit in 2N seats arranged in a row and want to hold hands. We want to know the minimum number of swaps so that every couple is sitting side by side. A swap consists of choosing any two people, then they stand up and switch seats. The people and seats are represented by an intege...
6b466e7914697eb0b8e3e07431eb52146bdbb992
HugoValim/DAF
/daf/core/math_utils.py
1,255
3.59375
4
import numpy as np import math def unit_vector(vector): """Returns the unit vector of the vector.""" return vector / np.linalg.norm(vector) def vector_angle(v1, v2, deg=False): """Returns the angle in radians between vectors 'v1' and 'v2':: >>> angle_between((1, 0, 0), (0, 1, 0)) 1.570796326794...
bab4132702a9523be7535168068bb2d2d7c765ed
milanix13/COVID-19
/src/analysis.py
8,652
3.734375
4
'''Code for analysis of data''' from data_munging import * from plotting import * import scipy.stats as stats import numpy as np def death_case_frequency(total_death_case, total_cases): '''Inputs: total_death - total # covid deaths proportional to population total_cases - total # covid cases propor...
06283fa1eb839b639a3d7f40568095a4b84e96d1
AlexFine/CS109
/pset5/p12.py
2,563
3.671875
4
import csv import random import statistics N = 100000 # Reads a files into a 2d array. There are # other ways of doing this (do check out) # numpy. But this shows def loadCsvData(fileName): arr = [] # open a file with open(fileName) as f: reader = csv.reader(f) # loop over each row in the file for row in read...
3e8a2e039c0c5f9f6f2e00d8e9438f7b16c3c4f6
wolffereast/chinese_solitaire
/gameboard.py
10,861
3.65625
4
''' Created on Feb 10, 2018 @author: stephen ''' import Tkinter from random import randrange from time import sleep class Gameboard(Tkinter.Frame): # Board layouts must be an array of equal length arrays, one per column, # and they must only contain 0, -1, and 1. def verifyGameboard(self, boardLayo...
aec70871bb17bcf569b304c2ec4744e6f79bf774
alverad-katsuro/Python
/python-examples-master/pilha-poo.py
2,673
4.0625
4
#!/usr/bin/env python # -*- coding: utf-8 -*- from os import system class Cliente(object): # Classe cliente, vazia pois pode ser atribuido pass # propriedades mais tarde class Pilha(object): # Classe Pilha def __init__(self): # metodo construtor self.pilha...
9e9c672f09e8e2f91f5c64076e54f461c02262c9
jaishivnani/Python-Practice-Problems
/3. Chapter 3 Strings/Practice problems/45_string.py
439
4.1875
4
'''Exercise Question 4: Arrange string characters such that lowercase letters should come first Sample Input str1 = PyNaTive Sample Output yaivePNT ''' str1 = "PyNaTive" def lowerfirst(str1): lower = [] upper = [] for char in str1: if char.islower(): lower.append(char) else: ...
34c5815d7d70b0c78b7f600e4a83e7802f5b4433
mchorney/Python
/Basics/string_list.py
546
3.875
4
# Replace "day" with "month" in string words = "It's thanksgiving day. It's my birthday,too!" words = words.replace("day", "month") print words # Min and Max from List x = [2, 54, -2, 7, 12, 98] min = min(x) max = max(x) print "Min: ", min print "Max: ", max # First and Last x = [19, 2, 54, -2, 7, 12, 98, 32, 10...
b9529cf77edbbb0edacce51390046025007b56ab
haukurarna/2018-T-111-PROG
/solutions_to_programming_exercises/assignment23_while.py
221
4.0625
4
low = int(input("Input the lower bound: ")) high = int(input("Input the higher bound: ")) sum_of_odd = 0 while low <= high : if low % 2 == 1 : sum_of_odd += low low += 1 print("The sum is ", sum_of_odd)
ec4b2ab3728b5a4a28cbf7951387c4abcca4546b
woodongk/python-algorithm-study
/파이썬 알고리즘 인터뷰/[7-08] 42. Trapping Rain Water.py
4,089
3.984375
4
""" Given n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it can trap after raining. Example 1: Input: height = [0,1,0,2,1,0,1,3,2,1,2,1] Output: 6 Explanation: The above elevation map (black section) is represented by array [0,1,0,2,1,0,1,3,2,1,2,1]. ...
0dc15a9f95f73c93b0f0f8920ad77ef9a010e4af
iangregson/euler
/problem-two.py
359
3.890625
4
a, b = 0, 1 def fibonacci(): global a, b while True: a, b = b, a + b yield a def main(): f = fibonacci() last_number = 0 fib_sum = 0 while last_number < 4e6: last_number = next(f) if last_number % 2 == 0: fib_sum += last_number print(fib_sum) ...
545132a6c874c80258fc9249db817195417918a0
tze18/AI
/python-training/number-string.py
229
3.78125
4
# !/usr/bin/python # -*-coding:utf-8 -*- #數字運算 #x=2+3 #print(x) #x+=1 #x=x+1 #將變數中的數字+1 #字串運算 #字串會對內部的字元編號(索引),從0開始算起 s="hello" print(s[:4]) # # #
2096631b580b5904bfcbf4f924513550ce969039
syurskyi/Python_Topics
/030_control_flow/example/Python-from-Zero-to-Hero/03-Коллеции, циклы, логика/15-ДЗ-Угадай число_solution.py
615
4.0625
4
import random tries = 0 number = random.randint(1, 50) print('Hmmm... Try to guess what number between 1 and 50 I was thinking about :)') while tries < 6: guess = int(input('Take a guess: ')) tries+=1 if guess < number: print('Your guess is too low') if guess > number: ...
1980d95a51d20e6c4bd9c6d9a6cb4986ec7dea4d
ayeshaaamir123/Online-Shopping-System
/A1_CS19020_26_4.py
6,518
3.90625
4
class userInterfaceProduct: def __init__(self): print('\t-------PRODUCT IN ONLINE SHOP--------') print('\t=============================\n') p=Order() #when object of Order class is instantiated all the available products with price and qu...
a5255d45a2e5b2bc9571ca3ffffbee86bd84eea8
alanvenneman/Programming
/Alan_Exam2/shooter_rec.py
630
4
4
import random # ROOM = random.randint(1, 500) # Comment in the next line and choose 65 to test. ROOM = 65 room_sizes = [] again = 'Y' while again.upper() == 'Y': # print("Not found yet.") sqft = int(input("Enter square footage of room: \n")) room_sizes.append(sqft) again = input("Enter another room siz...
b53037ebc8fef4530e81d2804b38c1eec3a5377c
Sabakalsoom/Learning-Python
/numbers.py
180
3.84375
4
int_num = 10 float_num = 20.0 print(int_num) print(float_num) a = 10 b = 20 add = a+b print(add) sub = b-a print(sub) multi = a*b print(multi) div = b/a print(div)
5d81a96e4683a555172a6cf53ded0d295edf6889
vparjunmohan/Python
/Basics-Part-II/program41.py
486
4.1875
4
'''Write a Python program that accepts six numbers as input and sorts them in descending order. Input: Input consists of six numbers n1, n2, n3, n4, n5, n6 (-100000 = n1, n2, n3, n4, n5, n6 = 100000). The six numbers are separated by a space. Input six integers: 15 30 25 14 35 40 After sorting the said integers: 40 35...
d1d1513faed9c23caf460a7cb1f69009795bdec1
jagadeeshwithu/Data-Structures-and-Algos-Python
/MergeSort.py
902
4.0625
4
""" Merge Sort implementation: Recursive way Time complexity: O(nlogn) Space complexity: O(n) """ def mergeSort(inputlist): arraylen = len(inputlist) if arraylen > 1: mid = arraylen//2 left = inputlist[:mid] right = inputlist[mid:] mergeSort(left) mergeSort(right) ...
d7d8a6280b2064f0e43819a33698b8a4343041e4
armcburney/practice
/python/ctci/arrays_and_strings/palindrome_permutation.py
788
4.125
4
#!/usr/bin/python3 """ palindrome_permutation.py @author: Andrew Robert McBurney @info: Cracking the Coding Interview question. """ import re def palindrome_permutation(s): """Checks if the string is a valid permutation of a palindrome.""" chars_count = {} # Ignore whitespace s = re.sub("\s+", "...
c1329d1da410c7cef73a0585f444890d1d86ce1d
RapunzeI/Python
/Chapter_6/31.py
527
3.8125
4
from random import * def craps(): dice1 = randint(1, 6) dice2 = randint(1, 6) sum = dice1 + dice2 if sum == 7 or sum == 11: return 1 elif sum == 2 or sum == 3 or sum == 12: return 0 else: while True: dice1 = randint(1, 6) dice2 = ra...
e584c18e59a3187bbf8038a1f9a52505b6a0b21a
asiajo/python-training-files
/Really small various scripts/Condensing Sentences.py
234
3.96875
4
import re """It removes multiplied consecutive groups of letters""" def condensing_sentences(s): return re.sub('(\S+)\s+\\1', '\\1', s) text = 'Digital alarm clocks scare area children.' print(condensing_sentences(text))
d12ecefab68f42468f32a3b13a130fdee72c7f7f
alexalvg/cursoPython
/EjsBucles.py/ÑIA3.9.py
785
4.09375
4
#Escribir un programa que almacene la cadena de # caracteres contraseña en una variable, # pregunte al usuario por la contraseña # hasta que introduzca la contraseña correcta. #contraseña = "password" #ask = str(input("¿Cuál es la contraseña?: ")) #key = "contraseña" #password="" #NO ENTIENDO PARA QUE PONE ESTO,...
5fef74fb4ebd6be519c353acfedf542c8d28d9e2
sgrade/pytest
/testdome/binary_search_tree.py
2,251
3.859375
4
# """Binary search tree (BST) is a binary tree where the value of each node is larger or equal to the values in all the nodes in that node's left subtree and is smaller than the values in all the nodes in that node's right subtree. Write a function that checks if a given binary search tree contains a given value. Fo...
8c37b00a3c1d1ef62f15d3849165df8dec44a430
abhishekanand10/dataStructurePy3
/mislPy/mergeSort.py
878
3.796875
4
def mergesort(a): if len(a) == 1: return else: # tmp = [] mid = len(a) // 2 ll = a[:mid] rr = a[mid:] mergesort(ll) mergesort(rr) merge(a, ll, rr) return a def merge(a, leftlist, rightlist): ln = len(leftlist) rn = len(rightlist)...
f653269d1f3cc3d6d6b15c8943aa291d6193e52c
djinnome/MaxMass
/src/codebase/GPR.py
1,946
3.578125
4
from pyparsing import * import types import pdb class Node(object): def __init__(self, data): self.data = data self.children = [] def add_child(self, obj): self.children.append(obj) def other_name(self, level=0): print '\t' * level + repr(self.data) for child i...
b9b2906004f832bbcff77c649ae59fca51e65f84
rksam24/MCA
/Sem 1/DM/Q6.Planer.py
671
4.25
4
#Program to check if graph is planer or not #this program not work for K3,3 def main(): #taking total number vertex and edges from user vertex=int(input("Enter the Total number of vertex in the graph: ")) edges=int(input('Enter the Total number of edges in the graph: ')) #max edge of vertex max=ve...
cb78f864b309c19bc51cf0a8f05f8d70f6b9be3e
radics100/radix_sandbox_python
/first_codes/pelda4.py
267
3.84375
4
x = [1, 'two', 3.0, [4, 'four'], 5] y= [1, 'two', 3.0, [4, 'four'], 5] print('x is {}'.format(x)) print(id(x)) print(id(y)) if isinstance(y, tuple): print("tuple") elif isinstance(y, list): print('list') else: print('nope') print(type(x))
8ee9a2f9a7858471b417acc0dd09f10d05a395d5
lukaskiss222/PTS_DU1
/decorator.py
1,813
3.65625
4
import login def login_decorator(Cls): """decorate class, make it login :Cls: input class :returns: decorated class """ class NewCls(object): """decorated class""" def __init__(self,*args,**kwargs): """ Constructor""" self.login = login.Login() ...
7f070a5fafe17272bea460844a6a0dba83f61ba8
johnkle/FunProgramming
/Python/pythonBasic/thread1.py
903
3.5625
4
import threading import time class mythread(threading.Thread): def __init__(self,threadID,name,count): #表示定义 加self #threading.Thread.__init__(self) #表示调用 不加self super().__init__() self.threadID = threadID self.name = name self.count = count def run(self): ...
101017e4c713c49124e944a56c341b266f6e7699
shulme801/Python101
/motorcycles.py
850
4.09375
4
# Stephen H. Hulme 8 Nov 2020 # Basic work with lists. Experiments are commented out motorcycles = [] motorcycles.append('honda') motorcycles.append('harley davidson') motorcycles.append('ducati') # motorcycles.append(14) This works b/c you can have a list with heterogenous types. This stmt adds an integer to the ...
c633e1f4f8e76d3d3c3fb02544674377c00fd336
ArunCSK/PythonWeek1
/sets.py
1,089
4.25
4
#create set def createset(): iset = {"1","2","3"} print("Sets: ",iset) #iterate set def iterate(): iset = {"1","2","3"} print("Sets: ",iset) for val in iset: print(val) #add set def add(): iset = {"1","2","3"} print("Sets: ",iset) item = input("Enter item to be add:") iset...
5941e7e4a95cbfdf1b4379a2e238a2763ecaa41c
Philtesting/Exercice-Python
/7eme cours/Programme/Ex60.py
182
3.5625
4
def hascap(s): mots = s.split() majs = [] for m in mots: if m[0].isupper(): majs.append(m) return majs print(hascap("Il était une fois, Jean François"))
a4aba4d46753772a4a90e2f515e59e57837373d3
TijanaSekaric/SP-Homework00
/ex4.py
170
3.84375
4
def sum_of_squares2(n): n -= 1 sum = 0 while n > 0: if n % 2 != 0: sum += n * n n -= 1 return sum print(sum_of_squares2(8))
9afc2fee6a3d8df799ba4745db8254147449204e
lucianamaroun/probabilistic-ranking
/src/auxiliary.py
468
3.984375
4
""" Contains common and simple procedures used by several modules. """ import os def adequate_dir(dirname): """ Formats a directory name in order to terminate with '/' if absent and creates it if necessary. Args: dirname: the string name of the directory to format. Returns: A string with the ...
f229b0c47a9c025bc032a0cba5a3e945e7df4cc4
tanghowl/Leetcode
/topic2.py
1,130
4.03125
4
""" 给出两个 非空 的链表用来表示两个非负的整数。其中,它们各自的位数是按照 逆序 的方式存储的,并且它们的每个节点只能存储 一位 数字。 如果,我们将这两个数相加起来,则会返回一个新的链表来表示它们的和。 您可以假设除了数字 0 之外,这两个数都不会以 0 开头。 示例: 输入:(2 -> 4 -> 3) + (5 -> 6 -> 4) 输出:7 -> 0 -> 8 原因:342 + 465 = 807 """ # Definition for singly-linked list. class ListNode: def __init__(self, x): self.val = x ...
4f33d8ebabfb181d0e0758eb4a72545bb496c230
ksaubhri12/ds_algo
/geeksForGeeks/algorithms/search/ternarySearch.py
506
3.9375
4
def ternarySearch(arr, l, r, x, ): if r >= l: mid1 = l + (r - l) / 3 mid2 = mid1 + (r - l) / 3 if arr[mid1] == x: return mid1 if arr[mid2] == x: return mid2 if arr[mid1] > x: return ternarySearch(arr, l, mid1 - 1, x) if arr[mid1] ...
042f7e1c0ea571ed55130757e1044f3ecfa8865c
arunekuriakose/MyPython
/diooo.py
8,633
3.71875
4
sel=[] tp=[] def p_menu(): l=[[1,"PA",230,330,430],[2,"PB",240,340,440,],[3,"PC",250,350,450]] print() print("*************************************") print("** S.no Pizza **") print("*************************************") for i in l: print("** ...
c0be8db2b10db10c3d7c5db073adbe6c35d015a0
xoempire/Python-Challanges
/22-reading-from-a-file.py
524
4.0625
4
# logc: # reading from a file which has multiple names in it # we woudl print the content of the file # the program woudl tell us how many names there are in the list # the program would also tell us the number of times that a name has been repeated counter_dict = {} with open("/Users/xoempire/Desktop/names.txt") as fi...
0bcb5ba32604b44e75f754a85d94677f73358726
EduardoEspinosaLahoz/Primera-Evaluaci-n
/bucle_10.py
840
3.703125
4
def bucle_10(): print"*******************" print"* PARES E IMPARES *" print"*******************" #Suma de numeros pares e impares nfinal=input("Hasta que numero quieres sumar?") #Definimos una variable para contar los pares n_pares=0 #Inicializamos la variable a cero ...
43dad805e7cf76e29341030e8ea042c5dee770e5
Leal31/cursopython
/Ejercicios_condiciones.py
2,903
4.03125
4
#Dos numeros y los compara para ver cual es par o cual es impar numero1 = int(input("Digita un numero: ")) numero2 = int(input("Digita otro numero: ")) if numero1 % 2 == 0 and numero2 % 2 == 0: print("Ambos son pares") elif numero1 % 2 == 0 and numero2 % 2 != 0: print(f"{numero1} es par") elif numero1 % 2 != 0...
c98ce3a929d63eb2eb06a3c85f8a0bbdca88c72c
lzhui/python_space
/函数式编程/hign-order.py
2,007
3.96875
4
#!/usr/bin/python # -*- coding: UTF-8 -*- print abs(-10) print abs a = abs(-10) print a #变量可以指向函数 a = abs print a def add(x, y, f): return f(x) + f(y) print add(-5, 6, abs) def f(x): return x * x print map(f, [1, 2, 3, 4, 5, 6, 7, 8, 9]) print map(str, [1, 2, 3, 4, 5, 6, 7, 8, 9]) def add(x, y): ret...
bda83b9c946726011def3734ddf0ec5b0616108e
MayankVerma105/Python_Programs
/percentage1.py
611
3.890625
4
def main(): totalMarks = 0 nSubjects = 0 while True: marks = input('Marks for Subject ' + str(nSubjects + 1) + ' : ') if marks == '': break marks = float(marks) if marks < 0 and marks > 100: print('INVALID MARKS') continue ...
56e28766976a316b765f72c37fb61052173d9463
suhanacharya/python-jetbrains-academy
/Vowels/task.py
156
4.1875
4
vowels = 'aeiou' # create your list here letters = list(input()) vowel_in_word = [letter for letter in letters if letter in vowels] print(vowel_in_word)
3749be2d3a105643592b7338474903194c1a7022
Kawser-nerd/CLCDSA
/Source Codes/AtCoder/arc007/A/4778782.py
91
3.71875
4
X = input() s = input() result = "".join([c for c in s if c not in X]) print(result)
489a2172e583e0e54a3ea91faf82df4097e11077
NSASiddhartha/BitsHyderabad_NSASiddhartha
/IdentyQ5.py
288
3.78125
4
#Question5: import numpy as np list1 = [] array1 = np.random.randint(100, size = 10) tf = np.array([True, False]) array2 = np.random.choice(tf, len(array1)) for x in range(0,len(array1)): if array2[x] is True: list1.append(array1[i]) print(array1) print(array2) print(list1)
6e2203f3479146a72bc4baab919f336e6922ff08
SimonBuettner/MachineLearning
/Decision Tree/decision_tree.py
1,646
3.9375
4
"""This code gives an overview how to create a decision tree """ import pandas as pd import graphviz from sklearn.model_selection import train_test_split from sklearn.tree import DecisionTreeClassifier from sklearn.tree import export_graphviz from helper import plot_classifier # Read CSV-File: DF = pd.read_csv("desea...
d03a99d55933462219041a0b05994c1976d92358
higor-gomes93/curso_programacao_python_udemy
/Sessão 13 - Exercícios/ex4.py
799
4.09375
4
''' Faça um programa que receba do usuário um arquivo de texto e mostre na tela quantas letras são vogais e quantas são consoantes. ''' raiz = 'c:/Users/Higor H/Documents/Estudos/Python' pasta = raiz + '/Curso de Programação em Python (Udemy)/Notas de Aula/Sessão_3_Entrada.py' vogais = ['a', 'e', 'i', 'o', 'u'] vogais...
e344ead13ab8527e36c10f52370e82bd158b9ab6
hyang012/leetcode-algorithms-questions
/005. Longest Palindromic Substring/Longest_Palindromin_Substring.py
1,020
4.03125
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Leetcode 5. Longest Palindromin Substring Given a string s, find the longest palindromic substring in s. You may assume that the maximum length of s is 1000. Example 1: Input: "babad" dabab Output: "bab" Note: "aba" is also a valid answer. Example 2: Input: "cbbd...
53c1ad3297fd3526ceed8d23689c5b127d340262
mbeven/FINM_2016_SPRING
/FINM 33150/HW2/Michael_Beven_HW2.py
14,563
3.515625
4
# Michael Beven # University of Chicago - Financial Mathematics # FINM 33150 - Quantitative Strategies and Regression # Homework 2 # make plots come up in this window - ipython notebook # %matplotlib inline # import packages import matplotlib.pyplot as plt import pandas as pd import keyring import numpy as np import ...
6624c0f47f5aafcfc38304cced29e9e224438269
jmseb3/bakjoon
/34.문자열 알고리즘 1/4354.py
350
3.5
4
while True: s = input() if s == ".": break elif s =="": print(0) else: for length in range(len(s),0,-1): cnt,ck =divmod(len(s),length) if ck != 0: continue temp = s[:cnt] if (temp)*length == s: print(...
8971ca0d33d22c03314421d84ce6e18194c6ac46
lidongze6/leetcode-
/实现 strStr() 函数.py
450
3.734375
4
def strStr(haystack, needle): l = len(needle) h = len(haystack) if l == 0: return 0 if l == h: if needle == haystack: return 0 else: return -1 else: for i in range(h - l+1): if haystack[i:i + l] == needle: return i ...
e49bef1824062f10c6aa86c3e2410c6ab6f9c1c6
michealodwyer26/MPT-Senior
/Homework/Week 3/rightAngledTriangle.py
1,039
4.28125
4
''' This program finds if the real numbers a, b, c form a right angled triangle Inputs: a, b, c - float Output: ans - boolean How to do it? Input a, b, c as float Test if the variables are positive Test if the variables form a triangle Test if the variables satisfy Pythagoras Theorem ''' # import modules import math ...
71530c2e7223b411fa99971c2883ef9835543c1e
arlexmolina/dojopython
/app/test/test_romano.py
2,028
3.8125
4
import unittest numeros = [1000,900,500,400,100,90,50,40,10,9,5,4,1] valor_romano=['M','CM','D','CD','C','XC','L','XL','X','IX','V','IV','I'] class NumeroRomano(object): def test(self, numero): numero = int(numero) pendiente = numero resultado = '' for i in range(len(numeros)): ...
bb93485529a293daf7b55014f7e31359eaab1c2f
kevinhan29/python_fundamentals
/08_file_io/08_01_words_analysis.py
1,826
4.125
4
''' Write a script that reads in the words from the words.txt file and finds and prints: 1. The shortest word (if there is a tie, print all) 2. The longest word (if there is a tie, print all) 3. The total number of words in the file. ''' with open("/Users/kevinhan/Documents/CodingNomads/labs/08_file_io/words.txt", ...
10d2360912103ff1531468663cac1d47ec806a32
slawektestowy/bootcamp_d3
/dzien3/przypomnienie.py
351
3.984375
4
# aaa = (3,4,"a",55,44,21) # # print(aaa) # print(aaa[2]) # print(aaa[1:4]) lista = [1,2,6,7,8,34,88] # print(lista) # a = max(lista) # print(a) # b = min(lista) # print(b) # # c = lista.index(a) # print(c) # d = lista.index(b) # print(d) lista_indexow = list((range(len(lista)))) print(lista_indexow) for i in lis...
8447fd685bf203b3c582463e6208c02639522942
esddse/leetcode
/medium/380_insert_delete_getrandom_o1.py
1,444
4.09375
4
import random class RandomizedSet: def __init__(self): """ Initialize your data structure here. """ self.items = [] self.val2idx = {} def insert(self, val: int) -> bool: """ Inserts a value to the set. Returns true if the set di...
d48564ed42502e693d2b3680e1873f32f36a4fbc
thinhld80/python3
/python3-13/python3-13.py
502
4
4
#For loop and range #For loop on lists, tuples, sets l = [1,2,3,4] #List t = (1,2,3,4) #Tuple s = {1,2,3,4} #Set for i in s: print(f'i = {i}') #For loop on dictionaries x = dict(Bryan=46,Tammy=48, Heather=28,Chris=30) print(x) for k in x.keys(): print(f'Keys: {k} = {x[k]}') for k,v in x.items(): print(...
5ef93d4f94dd027b1f45504ed81a3da6ebfa718e
slevinsps/python_prog
/python_labs/интересные задачки/points in area2.py
1,684
3.578125
4
# Спасенов Иван ИУ7-13 # Выписать точки, области которых находятся остальные точки from tkinter import * from math import sqrt # Функция, которая считает угол между векторами def ugol(a1, a2, a3): k1 = [a3[0] - a2[0], a3[1] - a2[1]] k2 = [a1[0] - a2[0], a1[1] - a2[1]] u = (k1[0] * k2[0] + k1[1] *...
1c5ac6edb8312d08872937fd453317eaab9462fa
Tuchev/Python-Fundamentals---january---2021
/02.Data_Types_and_Variables/02.Exercise/04. Sum of Chars.py
174
3.875
4
n = int(input()) count = 0 total_sum = 0 while count != n: symbol = input() total_sum += ord(symbol) count += 1 print(f"The sum equals: {total_sum}")
225741f619a693a2f41a1eccaf328fa232854e6a
rosannaz/hello-world
/projectEuler3.py
824
4
4
#Problem 3 #The prime factors of 13195 are 5, 7, 13 and 29. #What is the largest prime factor of the number 600851475143 ? def isPrime(x): global largest for i in range(2, int(x**(0.5) + 1)): if x % i == 0: return False return True def findLargestPrimeFactor(number): fac...
181a3630188e37b842736c61ebd0109c5f47be07
jfriend15/visualize-convo
/v1.0/helper.py
372
3.8125
4
''' Helper functions. ''' import math def generate_rgb(xyz): ''' Create an rgb value from a list of three floats TODO create a function that maps more intentionally ''' def map_btwn_01(x): freq = 1 # TODO custom freq return 0.5 * math.sin(freq * x) + 0.5 return [map_btwn_01(xyz[0]), map_btwn_01(xyz[1]), ma...
b2cb2dab52101f7647a50e7e3d33a8965fb87fd0
JuanMelendres/The-Modern-Python-3-Bootcamp
/Boolean&Conditional_Logic/calling_in_sick.py
1,499
4.0625
4
''' Calling in sick in this exercise you will be given a few variables that will be set randomly to boolean values (True or False) * actually_sick - when you legit have the flu! * kinda_sick - you´re feeling under the weather and it´s enough to treat yoself with a day off if you can spare it. * hate_your_job - work suc...
6bee560f3cd058eed70a286a52adfc9acc5a0775
jliving207/CodeCademy
/Loops_Cheatsheet.py
1,327
4.6875
5
# for <temporary variable> in <list variable>: # <action statement> # <action statement> #each num in nums will be printed below nums = [1,2,3,4,5] for num in nums: print(num) numbers = [0, 254, 2, -1, 3] for num in numbers: if (num < 0): print("Negative number detected!") break print(num) print("--...
a05ee462dee18c0d8d08637ddf1f6eb6a7050f0c
MartinR2295/University-Exercises-Artificial-Intelligence
/cellular_systems/src/rule.py
1,269
3.59375
4
from .cell import Cell ''' Rule class To handle the rules in the cellular system. Here you can set start_state, end_state and min+max alive neighbours. ''' class Rule(object): def __init__(self, start_state, end_state, min_alive_neighbours, max_alive_neighbours=None): self.start_state = start_state ...
830fc1f3f3a19d7bc6c18d2eeb2879b613cc6de0
Madhava-mng/li5tgen
/bin/lib/edit.py
2,444
3.578125
4
#!/bin/env python3 from itertools import product from lib.core import Element def Replace(str_, list_): return str_.replace(list_[0],list_[1]) def Crop(str_, list_): front = int(list_[0] or 0) back = int(list_[1] or 0) return str_[front:len(str_)-back] def Join(str_, list_): front = list_[0] or "...
e77f8089b4c089c3710990adbe6662f243940d2b
vothin/code
/代码/day2-1/A.IfDemo1.py
679
4.03125
4
""" if单分支选择语句 if(条件表达式): 选择体 一条或者多条语句 条件表达式:结果为boolean类型的表达式。 表达式可以为常量、变量、比较运算、逻辑运算 当条件表达式结果为true时,选择体中的语句就会执行。 当条件表达式结果为false时,选择体中的语句不会执行。 Python中没有switch条件分支语句 """ number = int(input('请输入你的年纪:')) if number > 18: # 广东省 print("你已经成年了.....") # 深圳市 print("你可以工作了") pri...
b8c6a858e3d066422639939621483912fd057846
aira26/homework4
/1dna.py
394
3.921875
4
with open('rosalind_dna.txt') as input_data: dna = input_data.read() #i opened the file in order to read it ans then i created an empty list, # in order to append it with the result of the counting count = [] for nucleotide in ['A', 'C', 'G', 'T']:...
ac45ac853223a56fc459d84357a5a79c91dcc41c
faisalraza33/leetcode
/Python/1567. Maximum Length of Subarray With Positive Product.py
2,427
4.03125
4
# Given an array of integers nums, find the maximum length of a subarray where the product of all its elements is positive. # A subarray of an array is a consecutive sequence of zero or more values taken out of that array. # Return the maximum length of a subarray with positive product. # # Example 1: # # Input: nums =...
a77765a1c7890b5ad2d7699006fa131e51f895c9
millerg09/python_lesson
/ex3.py
1,282
4.5
4
print "I will now count my chickens:" # prints a line of text print "Hens", 25.0 + 30.0 / 6.0 # prints a line of text, and then performs addition and division print "Rooster", 100.0 - 25.0 * 3.0 % 4.0 # prints a line of text, and then performs subtraction, multiplication, and fmod (3 to the power of 4) print "Now I w...
fb989b24c718f4b468e156647dc688e5d59d4bec
YannThorimbert/Thorpy
/examples/guessthenumber.py
1,725
3.609375
4
#ThorPy minigame tutorial. Guess the number : start menu import thorpy import _mygame as mygame def launch_game(): #launch the game using parameters from varset global varset, e_background game = mygame.MyGame(player_name=varset.get_value("player name"), min_val=varset.get_value("minva...
ff77b522589127dd2a137675011129461910635a
chriswolfdesign/MIT600
/psets/pset4/Problem2/ps4b.py
1,107
3.78125
4
# Problem Set 4 # Chris Wolf # 2:00 # # Problem 2 # def nestEggVariable(salary, save, growthRates): savings = [] years = len(growthRates) for year in range(0, years): if year == 0: savings.append(salary * save * 0.01) else: savings.append(savings[year - 1] * (1...
2e7de9540157e06fe9f90a14b034b615ae4b0673
vvvm23/ADS_Algorithms
/binary_search.py
403
3.828125
4
def search(L, x, left=-1, right=-1): if left == -1 or right == -1: left = 0 right = len(L) - 1 if right == left and L[left] != x: print(x, "does is not in the inputted list!") return -1 p = (left + right) // 2 if L[p] == x: return p if x > L[p]: re...