blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
d7604f8619ea94a80c0b9a2ca2420711e9962e5d
jpaulo-kumulus/KumulusAcademy
/Exercícios Vinicius/Conditions/challenge.py
444
4
4
print('Você quer continuar?') continuar = input() if continuar == "n" or continuar == "não" or continuar == "N" or continuar == "Não" or continuar == "NÃO": print('Saindo') elif continuar == "s" or continuar == "sim" or continuar == "S" or continuar == "Sim" or continuar == "SIM": print('Continuando...') im...
f114aa85ab5a029da0b4bba7875aeb36f6aa1b7e
rewonderful/MLC
/src/第k大的数_LeetCode215.py
1,115
3.640625
4
#!/usr/bin/env python # _*_ coding:utf-8 _*_ def findKthLargest( nums, k): """ 快排的思想 根据pivot将左右两侧划分,在划分后就可以得到p,将p和k比较,如果k在p的左侧,那么就丢弃右侧,只排序左侧,如果k在右侧,那么就 丢弃左侧,只排序右侧, 要注意这里的partition一次排序是从大到小排 注意第k大,所以要 p+1 注意find_kth中的while是l<=r,有等于号 复杂度:On """ def partition(nums, l, r...
83bd5c902e33fb4fb5b1d747a756d477649d51eb
VitorSilvaDeveloper/exercicio_dicionario
/exercicio_senhas/exercicio_senhas_dicionario.py
1,342
4.0625
4
def linha(): print('-'*40) dicionario_senhas = {} linha() while True: print('O que deseja fazer?') print('[adicionar] | [remover] | [listar] | [sair] ') opcao = str(input()) opcao_nova = opcao.lower() if opcao_nova == 'adicionar': linha() usuario = input('Digite o novo usuario...
9af4a235aba467203d1445d51a469c5cc482a874
DanielPBak/Practice-Work
/minesweeper/minesweeper.py
2,069
3.734375
4
def to_matrix(l, n): return [l[i:i+n] for i in range(0, len(l), n)] import random num_rows = int(input('how many rows? ')) num_columns = int(input('how many columns? ')) num_bombs = int(input('how many bombs? ')) if num_bombs > num_rows * num_columns: exit('too many bombs') num_zeros = (num_rows * num_colum...
2f49c33b385f902a3b332ec91b64d947c7f35454
wenxuefeng3930/python_practice
/interview/program/seq_program/test_find_last_shown_index.py
874
3.90625
4
#!/usr/bin/env python # encoding: utf-8 """ 查找一个有序重复数组,比如,t1 = [1, 2, 2, 2, 3, 4],找出2在数组中最后的位置,要求时间复杂度为logn @author: cbr """ def find_last_shown_index(l, num): last_shown_index = None if l[0] > num or num > l[-1]: return None low = 0 high = len(l) - 1 while low <= high: mid = (lo...
9e4f6d5936a6f423506fc40102ffb3203544136f
Fenrir190/Random-Projects
/Algorithms/BubbleSort/client.py
143
3.53125
4
from BubbleSort import * items = [4,1,5,0,-1] obj = BubbleSort() obj.sort(items) sortedList = obj.getList() print("Sorted List: ", sortedList)
e82d3ae0051e800ca7a502997e7f75df1776d486
yang-12345678/GUI-Tkinter
/ch6_Radio_Button/02_选项按钮2.py
541
3.703125
4
# -*- coding: utf-8 -*- # Date: 2021/06/13 from tkinter import * def printSelection(): label.config(text="你是" + var.get()) root = Tk() root.title("test") var = StringVar() var.set("男生") label = Label(root, text="这是预设,尚未选择", bg="lightyellow", width=30) label.pack() rbman = Radiobutton(root, text="男生", variabl...
1ba9990fa230bf4e4d4891eaa9d8d7ce6814ddcd
yusuke-matsunaga/adc2019lite
/core/position.py
2,890
3.671875
4
#! /usr/bin/env python3 """Position の実装ファイル :file: position.py :author: Yusuke Matsunaga (松永 裕介) Copyright (C) 2019, 2020 Yusuke Matsunaga All rights reserved. """ class Position: """位置を表すクラス 内容はただの (x, y) のタプル ただし +/- や +=/-= の演算を定義している. また,メンバ変数は初期化時に設定された後は +=/-=演算以外では変更されない. :param int ...
e265c3ca39defe4c11c237cbc51eb13dbfe97904
Amazinggamer259/ALLL-DA-STUFF-IN-DA-YEAR-
/Thomas Chapter7.py
798
4
4
x = [1,2] print(x) print(x[0]) x[0] = 22 print(x) [22, 2] my_list = [101, 20, 10, 50, 60] for item in my_list: print(item) my_list = ["Spoon", "spork", "Knife"] for item in my_list: print(item) print(len(my_list)) my_list = [2, 4, 5, 6] print(my_list) my_list.append(9) print(my_list) #my_list ...
6ea83511016f22bfae7b1737569324b42027b58e
royliu317/Code-of-Learn-More-Python-THW
/mex07_1_mine.py
568
3.953125
4
import re import argparse parser = argparse.ArgumentParser() parser.add_argument('keyword', metavar='K', type=str, nargs=1, help='Input the keyword for the search') parser.add_argument('file', metavar='F', type=str, nargs=1, help='Input the (path and) file for the search ') args = parser.parse_args() in_file = ope...
0ec9385f3e95ab1257f9d3782a7d35c29aa07cd2
imsure/tech-interview-prep
/py/leetcode_py/581.py
7,654
3.84375
4
class Solution: def findUnsortedSubarray(self, nums): """ Make a copy of the input array and sort it. Compare the two arrays to find the leftmost and rightmost elements that mismatch. The sub-array lying between them is the shortest unsorted sub-array. time: O(NlogN) ...
506d0bbf89cbbeeb0a5343c43d955b853a526556
endreujhelyi/endreujhelyi
/week-04/day-4/02.py
212
4.1875
4
# 2. write a recursive function # that takes one parameter: n # and adds numbers from 1 to n def recursive(n): if n == 1: return (n) else: return n + recursive(n-1) print (recursive(5))
aefda9af15de17e06f6869eedfb38c09528c3954
JoshuaMaina/golclinics-dsa
/gol-assignments/stacks.py
676
3.71875
4
def reverse_string(string): stack = [] for chr in string: stack.append(chr) new_string = "" while len(stack): new_string += stack.pop() return new_string def brackets_match(string_of_brackets): close_to_open = { '}': '{', ')': '(', '[': ']' } s...
f6ec4cca959cb8ffb87c230dd40899ee7823f7f9
webclinic017/FinancesAuto
/finances/lib/preBOA.py
1,323
3.53125
4
import datetime from collections import OrderedDict from csv import reader class BOACSV(object): def __init__(self, csvLines): self.csvLines = csvLines def splitRow(self, rowList): if any(rowList): ###Remove Day from date string date = rowList[0] d = datetime...
506e802009e8d6d901abac6f12f94bfabc9ecbc0
saapooch/Carl-Chandra-Analysis
/old_code/analysis/emaStockResearch.py
8,250
3.921875
4
import quandl import pandas as pd import numpy as np import matplotlib.pyplot as plt #Quandl API key associated with my account quandl.ApiConfig.api_key = '2sBoxWDxwXqHmxGQoPys' #This program takes user input of stock tickers and calculates the returns that would have been generated if a portfolio #were constructed ...
64fe373406dcdacacda1bd3fb2d20c94fdb5b66b
janeon/automatedLabHelper
/testFiles/primes/primes71.py
867
4.21875
4
def isPrime(x): for f in range (2,x): if x%f==0: return False return True def twinPrimes(r): for j in range (3,r): if isPrime(r) and isPrime((r-2)): return True else: return False def main(): print() n=eval(inp...
32514a19a1fb1e628ac3e42f58444b804484d22f
dudealy/python-challenge
/PyBank/main.py
1,001
3.515625
4
import os import csv csvpath=os.path.join('.', 'Resources', 'budget_data.csv') total_profitLoss=0 average_diff=[] with open(csvpath, newline='') as csvfile: csvreader=csv.reader(csvfile, delimiter=',') csv_header=next(csvreader) count = 0 val = None for row in csvreader: if count == 0:...
16e26d7b1e07282e3c5689a60e4ad0deec12e50f
ArnoutSchepens/Python_3
/Oefeningen/standalone/while.py
236
4.03125
4
number = 1 while number <= 10: print(f"{number}") number += 1 # msg = input("What's the secret password? ") # while msg != "bananas": # print("WRONG!") # msg = input("What's the secret password? ") # print("CORRECT!")
d8ffccd70a13d6b5eae0aeb4c6a2d344b968509f
pindio58/Vasya-Clerk
/Vasya-Clerk.py
509
3.5
4
def tickets (people): if people[ 0 ] != 25: return 'NO' notes_25, notes_50 = 1, 0 for note in people [1: ]: if note == 25: notes_25 += 1 if note == 50: if not notes_25: return 'NO' else: notes_50 += 1 ; notes_25 -= 1 if note == 100: if not note...
d15719b38e4bf015eba34f7f383f74a11a66745a
JolanDejonckheere/5WWIPython
/04-Variabelen/oppervlakte circel.py
103
3.546875
4
#invoer r = float(input('geef de straal')) pi = 3.14159 #berekening o = pi * r**2 #uitvoer print(o)
5a3a692fca097a6612aaccf1bae236c2bcd7a8d8
yzl232/code_training
/mianJing111111/epic/In 1-9 keypad one key is not working. If some one enters a password then not working key will not be entered.py
1,050
3.71875
4
# encoding=utf-8 ''' In 1-9 keypad one key is not working. If some one enters a password then not working key will not be entered. You have given expected password and entered password. Check that entered password is valid or not Ex: entered 164, expected 18684 (you need to take care as when u enter 18684 and 164 only ...
fa0c322799dc6a0bb0c1ec89a164949d03a4c579
AIRGG/Faktorial-in-Py
/faktorial.py
219
3.890625
4
import os def faktorial(angkaNya): hasil = 1 for x in range(1, int(angkaNya)+1): hasil*=x return hasil isi = input(" Masukkan Angka: ") print(" Hasil Faktorial dari '{}' = '{}'".format(isi, faktorial(isi)))
bd88af6b259e3bed49223e6df0a0826834a7356b
cassyt821/astrophysica
/astrophysica-master/Two Body Orbit.py
6,344
3.609375
4
#!/usr/bin/env python # coding: utf-8 # When I was an undergraduate at UC Berkeley, I breezed through several exercises in a class I took on computer # simulations. The one that stumped me the most was the simulation of a standard 2-body Keplerian orbit. For some reason, I could not, for the life of me, replicate an e...
4223594c8f4b8c6a9a97028ee281ae4879114aab
contactshadab/data-structure-algo-python
/programs/leetcode/78_subsets.py
1,458
3.984375
4
''' https://leetcode.com/problems/subsets/ 78. Subsets Given an integer array nums, return all possible subsets (the power set). The solution set must not contain duplicate subsets. Example 1: Input: nums = [1,2,3] Output: [[],[1],[2],[1,2],[3],[1,3],[2,3],[1,2,3]] Example 2: Input: nums = [0] Output: [[],[0]] Con...
b7d17005f7eb1766a3f508f8e8db0f01f8bf9822
CragAddict/RainFlowChart
/Regen_3.py
1,378
4.09375
4
import sys import time while True: print('Is it raining?') answer1 = input() if answer1.upper() == 'NO': break if answer1.upper() =='YES': break if answer1.upper() != 'YES' or answer1.upper() != 'NO': print('Please answer with Yes or No !') continue if ans...
69f48c13bfc3265f696499733230b475e0784481
wuyijian123456/test1
/venv/case/demo8.py
341
3.90625
4
line=[] while True: a = input("请输入序列:") if a: line.append(a.upper()) else: break; for i in line: print(i) # lines = [] # while True: # s = input("请输入序列:") # if s: # lines.append(s.upper()) # else: # break; # # for sentence in lines: # print (sentence)
2cf533fcbdbac1c0204ae4d64c7bb5488785594e
JitendraAnnamreddy/AnnamreddyJitendra_Git
/conditoinal 1.py
154
3.921875
4
n=int(input()) if(n%3==0 and n%5==0): print("zoom") elif(n%3==0): print("zip") elif(n%5==0): print("zap") else: print("invalid")
14d0a84983314f305c09a83f27eedb06bf8e004c
DmiFomin/HW2
/venv/bornday.py
332
4.125
4
year = input('В каком году родился Пушкин А.С.? ') if (year == '1799'): day = input('А в какой день он родился? ') if (day == '26'): print('Верно') else: print('Неверный день рождения') else: print('Неверный год рождения')
2944c27c89388018f77ede4ee7e49cd2adc8994d
sendurr/spring-grading
/submission - lab6/set2/LUCKE OLIVEIRA LUZ_9461_assignsubmission_file_Lab6/P3.py
410
3.59375
4
# Name: Lucke Oliveira Luz Assignment: Lab 6 Exercise: 3 import argparse parser = argparse.ArgumentParser() parser.add_argument('-F', action='store', dest='F',default=0, help='Temperature in Fahrenheit') parser.add_argument('--version', action='version', version='%(prog)s 1.0') args = parser.parse_ar...
bc3029b6ae717e192d185775694849c348cc48d7
DanWro/Python
/Pythons/TicetForSpeed.py
247
3.5
4
a=float(input("podaj limit: ")) b=float(input("podaj predkosc: ")) x=list(range(1,10)) m=(b-a<=10) M=(b-a>10) m1=(b-a)*5 M1=((10*5)+(b-(a+10))*15) if m: print(m1, "zl") if M: print(M1, "zl")
854f948d3b7c26d5edd7c9ab407411873e88d218
ckcollab/plithos
/src/plithos/simulator.py
8,082
3.546875
4
import numpy as np import pygame from math import hypot from pygame import * from random import randint, choice from utils import circle_iterator class Entity(pygame.sprite.Sprite): def __init__(self, simulator): pygame.sprite.Sprite.__init__(self) self.simulator = simulator self.image ...
e3633bc3af469c797d075500e7be6b34cc42c20a
divyak1995/PythonFiles
/cyclic.py
475
3.890625
4
def cyclic(g): path = set() visited = set() def visit(vertex): if vertex in visited: return False visited.add(vertex) path.add(vertex) for neighbour in g.get(vertex, ()): if neighbour in path or visit(neighbour): return True pa...
ea395c4ac526c164c9db144af636e6f386d5c3d1
sharpchris/coding352
/talkpython_days/01-03-datetimes/bryan/game.py
545
4.0625
4
from datetime import datetime from datetime import date from datetime import timedelta today = datetime.today() todaydate = date.today() print(today.year) print(todaydate) age = input("What is your age?") age = int(age) agedelta = (today.year - age) secondagedelta = (today.year - age - 1) birthdayoccur = input("Ha...
846d661ce10dd0997cdb5c1d83ab35580e569363
minmul117/baekjoon
/2/2.add-two-numbers.py
1,868
3.9375
4
# # @lc app=leetcode id=2 lang=python3 # # [2] Add Two Numbers # # https://leetcode.com/problems/add-two-numbers/description/ # # algorithms # Medium (30.72%) # Total Accepted: 794K # Total Submissions: 2.6M # Testcase Example: '[2,4,3]\n[5,6,4]' # # You are given two non-empty linked lists representing two non-neg...
16187faa4272e9388c2ce7e154ec6e93c40347c2
lilyxiaoyy/python-28
/day02/格式化输出.py
366
4
4
# -*- coding: utf-8 -*- ''' %s 占位,字符串(所有的数据类型都可以传递给%s) %d 占位整数 %f 占位小数 ''' name = "lily" num = 2 str1 = "%s每天吃%s个苹果" % (name, num) # 这种方式的缺点是太长容易串 str2 = f"{name}每天吃{num}个苹果" # 这种方式只有python3.5以上的版本才会支持 print(str1) print(str2)
ab8f10e28ba37483f29abf33290322331fddb4fc
arian81/playground
/python3_hard_way/House.py
6,811
3.59375
4
from PIL import Image import tkinter from tkinter import messagebox from sys import exit timer = range(1,100) inventory = [] doors = ["wooden",'metallic','red','black','golden','gray'] def game_over(): img = Image.open("game_over.jpg") img.show() print("1.try again 2.exit") ...
b37d3496c2cf57e9ee0a5a90793b1702b9f56e82
ZoltanMG/holbertonschool-higher_level_programming
/0x0A-python-inheritance/2-is_same_class.py
335
3.78125
4
#!/usr/bin/python3 """ Function that returns True if: the object is exactly an instance of the specified class; otherwise False. """ def is_same_class(obj, a_class): """ Function that returns True if: the object is exactly an instance of the specified class; otherwise False. """ return obj.__clas...
5891ac78765524f32e06e214c40f5b8676b127e0
wolfecameron/structural_RNN
/gear.py
1,734
3.921875
4
"""this file implements a class for a gear that stores all information needed for a gear within a mechanism""" import numpy as np class Gear(): def __init__(self, rad, pos, prev_gear): """define all properties of the gear class, only radius, position, and prev gear are instantiated by the constructor """ ...
5e3b970985be6f45f30b15298b52eb0407b801c9
cooper0524/practice
/temp_conversion.py
89
3.875
4
c = input("Please enter Celsius: ") f = float(c) * (9/5) + 32 print("Fahrenheit is: ", f)
ad8202b6408d46b2448f1b1fb62d2423c38de868
bitepy/learn-python
/3 (2).py
98
3.515625
4
def square2(x): return x*x a=[1,2,3,4,5,6] b=[8,9] print(a,b) print (map(None,a,b))
d8eb93c9f668395be969a0f19307e0128467cbde
lavandalia/work
/Caribbean Online Judge/2397 - Helping Tomas in Training/main.py
298
3.5
4
from datetime import date T = int(raw_input()) for _ in range(T): A, B = raw_input().split() A = [int(x) for x in A.split('-')] B = [int(x) for x in B.split('-')] A = date(A[0], A[1], A[2]) B = date(B[0], B[1], B[2]) if B < A: A, B = B, A print (B - A).days
dde899553e212e745ea39fda4c659ed0da10987a
ErenBtrk/Python-Fundamentals
/Numpy/NumpyStatistics/Exercise12.py
2,337
4.46875
4
''' 12. Write a Python NumPy program to compute the weighted average along the specified axis of a given flattened array. From Wikipedia: The weighted arithmetic mean is similar to an ordinary arithmetic mean (the most common type of average), except that instead of each of the data points contributing equally to the ...
1192b631b47334793b7ff6f40b411824a88c8790
acheney/python-labs
/lab02/hguss/fibonacci.py
357
4.15625
4
# beer.py # gives a designated fibonacci place # # Henry Lionni Guss # 1/5/12 def main(): place = eval(input("Enter an integer 2 or greater: ")) numOne = 1 numTwo = 1 for i in range(place -1, 1, -1): temp = numOne numOne = numTwo numTwo = temp + numTwo print("The",place,"num...
d3ea6f2729ca639dc77e23e10b567a74be65815a
mariatmv/PythonAdvanced-Sept2020
/05.functions_advanced/08.even_or_odd.py
333
3.75
4
def even_odd(*args): cmd = args[-1] l = [] if cmd == 'even': for i in range(len(args) - 1): if args[i] % 2 == 0: l.append(args[i]) elif cmd == 'odd': for i in range(len(args) - 1): if args[i] % 2 != 0: l.append(args[i]) ...
bca316fc6d977d6901a7dea07e8154831f0a1e22
sat2493/CodingProblems
/Leetcode/Remove Linked List Elements.py
1,237
3.90625
4
# Definition for singly-linked list. # class ListNode: # def __init__(self, val=0, next=None): # self.val = val # self.next = next class Solution: def removeElements(self, head: ListNode, val: int) -> ListNode: print("here") # Check for head, and keep employing this for ...
ef5139635c776b46e04b4ea2c7e3eafd31dd36eb
Sharnol-Tec/Trabajo
/TrabajoDeFP/Ejercicio8.py
455
3.625
4
#datos de entrada inporte=float(input("digite el importe total vendido en el mes:")) #proceso sueldo_basico=300 comision_ventas=0.09*inporte sueldo_bruto=sueldo_basico + comision_ventas descuento=0.11*sueldo_bruto sueldo_neto=sueldo_bruto-descuento #salida print("sueldo basico:s/.",sueldo_basico) print("comision por ve...
fd7d1d580ad15e19e5ae37c1ce5af0f28712f87d
APotatoBoy/Leetcode
/168_convertToTitle.py
1,005
3.75
4
# encoding = utf-8 import string class Solution: def convertToTitle(self, Input): """ Given a positive integer, return its corresponding column title as appear in an Excel sheet :param Input:int :return:str """ if n < 0: return '' ...
49cddae9c2ee3ca255fa7d179730debe95bd82ad
markpalmer1/age-calculator
/src/how-long-have-you-lived-for.py
310
3.96875
4
print('Answer the questions to know how long you have been alive for!') name = input('Name: ') print('What is your age',(name),'?') age = int(input('age: ')) days = age* 365 minutes = age * 525948 seconds = age* 31556926 print(name, 'has been alive for:', days,"days",minutes,'minutes',seconds,'seconds' )
eb2bdf9b2c1100858c1023cc2f20858178fbb370
kalebass/euler
/036_double_base_palindromes.py
166
3.78125
4
def palindromic(string: str) -> bool: return string == string[::-1] print(sum(n for n in range(1000000) if palindromic(format(n, 'b')) and palindromic(str(n))))
7a977c284be62123989323384242899d9257d487
reggaedit/tax_calc
/tax_calculator.py
3,729
3.78125
4
#from Tkinter import #root = Tk() #filetest = Label(root, text="Calculate my Taxes, thanks.") #filetest.pack() #root.mainloop() import locale locale.setlocale( locale.LC_ALL, 'english-uk' ) # -*- coding: utf-8 -*- #Base Variables (ni=national insurance) print "What is your Gross pay/salary? (Please do not...
3b07144a58b640fe11b81d717b225696795870bf
garderobin/Leetcode
/leetcode_python2/lc350_intersection_of_two_arrays_2.py
2,476
3.671875
4
from abc import ABCMeta, abstractmethod from collections import Counter class IntersectionOfTwoArrays2: __metaclass__ = ABCMeta @abstractmethod def intersect(self, nums1, nums2): """ :type nums1: List[int] :type nums2: List[int] :rtype: List[int] """ class Inters...
38ed82e70caa4c38da40c547e99a42121fba8218
Kamokamocsai/pallida-exam-basics
/uniquechars/unique_chars_test.py
707
3.796875
4
import unittest from unique_chars import unique_characters class LetterCounterTest(unittest.TestCase): def test_empty(self): self.assertEqual(unique_characters(''), []) def test_one_letter(self): self.assertEqual(unique_characters("a"), ['a']) self.assertEqual(unique_character...
0ac4328242ae9d2054814e7e3818f3e0956f7770
jhosep7/holbertonschool-higher_level_programming
/0x0C-python-almost_a_circle/models/base.py
4,363
3.59375
4
#!/usr/bin/python3 """class base """ import json import turtle from random import choice as random import csv class Base: """class constructor definition to check for id """ __nb_objects = 0 def __init__(self, id=None): """checks for id """ if id is not None: self....
ece675b8d6ddd139e7b8777504beb6b188a5db4c
royrowe/python
/practic_chop.py
262
4.40625
4
#!/usr/bin/env python2 # -*- coding: utf-8 -*- """ Created on Thu Nov 15 15:45:32 2018 @author: luoming """ my_foods = ['pizza', 'falafel', 'carrot cake','coke','onion'] print("The first three items in the list are:") for food in my_foods[-3:]: print(food)
879ae809b1757ddc6aae8ef1ab0e14b7d63ddd37
Shweta2013/InfyTQ-Exercises-And-Assignments
/PROGRAMMING FUNDAMENTALS USING PYTHON/Day 7/#PF-Assgn-50.py
429
3.828125
4
#PF-Assgn-50 def sms_encoding(data): #start writing your code here splitted_data=data.split() consonents="" for word in splitted_data: if len(word)==1: consonents+=word for letter in word: if letter not in "aeiouAEIOU": consonents+=letter ...
22bf0637b2e1ed54d5e8b1aca43804be8f5fbfbf
ymerejsasnak/project-euler
/euler1.py
613
4.1875
4
# sum of all multiples of 3 and 5 below 1000 # basic formula for sum of numbers from 1 to n def summation(n): return n / 2 * (n + 1) # summation of multiples ('c' being the constant 'multiplier' # and 'n // c' being the highest multiple of c below n) def sum_multiples(c, n): return summation(n // c) * c ...
6b5f5ee403eec835a658db0350453011b9c1e764
inwk6312winter2019/week4labsubmissions-parth801736
/Lab5task1.py
421
4.03125
4
import math class point: def __init__(self): self.x=0 self.y=0 def distance_between_points(a,b): d1 = a.x - b.x d2 = a.y - b.y distance = math.sqrt(d1**2 + d2**2) return distance x = point() y = point() print(x) print(y) print(x != y) p0 = point() p0.x = 12 p0.y...
5fc717fdec747a8a29ab5c0c28e6cdc50fd9c807
bpbpublications/Advance-Core-Python-Programming
/Chapter 01/coding_question_10.py
306
3.828125
4
def fibonacci_seq(num): i = 0 j = 0 k = 0 for i in range(num): if i==0: print(j) elif i==1: j = 1 print(j) else: temp = j j = j+k k = temp print(j) fibonacci_seq(10)
2b99a7fc6687de3d2d22d2d57fd08b7c3fdc595a
ProfoundDonut/Elevator-Algorithm
/legacy.py
1,397
4
4
## Basic Controls elevatorFloor01 = 1 elevatorFloor02 = 1 elevatorFloor03 = 1 elevatorFloor04 = 1 elUser = 1 system = "on" while system == "on": elevatorFloor01int = str(elevatorFloor01) elevatorFloor02int = str(elevatorFloor02) elevatorFloor03int = str(elevatorFloor03) elevatorFloor04int = str(elevat...
779505ae53b67c9dc72d3331c678d998a0260069
CAUN94/tics1002021
/clase9/sec6/matriz_flag.py
498
3.703125
4
matriz = [[1,8,3,4],[4,8,6,7],[7,8,9,10]] # 3x4 nr = int(input('Que quieres buscar? ')) for i in range(len(matriz)): for j in range(len(matriz[i])): print(matriz[i][j],end=' ') print('') print('') print('Buscando...') print('') encontrado = False for i in range(len(matriz)): for j in range(len...
e85416e01ddafe3d8ac757363b0af46a465a4612
okha17/Codewars-Problems
/Find the Odd int/solution.py
401
4
4
from collections import Counter # import library that counts occurents of values in list def find_it(seq): new_list = Counter(seq) # make a dictionary for keys and values which are the number and occurences for key in new_list: if (new_list.get(key)) % 2: # loop over the dictionary to find the odd o...
671a1847a7622763c9e78eee9cc2af02c2ee32ea
ruthwik3690/foss-tasks
/tweepy.py
627
3.609375
4
import tweepy #importing the tweepy module (used for accessing python API) consumer_key = "78oHVqjgW5PkzPntQZL1c8eY0" consumer_secret="PQvmPpc9EElguXHPWYH7Xgv4vNcCNE0gqGQE6eZBjarYqrwP5x" #details of you account access_token="912243816-fia7iTT8YeUOUj2zEpfqgheaWv5uNNam1qsnWP0S" access_token_secret="mgoCHgSTJC9NPeP...
8fbc4c10b5eba580a49f5a90d7f2eb10fc8baac8
takecian/ProgrammingStudyLog
/LeetCode/mock_interview/google_phone_1/a.py
532
3.6875
4
# https://leetcode.com/problems/strobogrammatic-number/ class Solution: def isStrobogrammatic(self, num: str) -> bool: converter = {'0': '0', '1': '1', '6': '9', '8': '8', '9': '6', } cannot_convert_set = {'2', '3', '5', '4', '7'} rotated = [] for n in num: if n in canno...
f74f42d3aedc645f07e7981386e958d00ad6a675
nithinveer/leetcode-solutions
/count_chars.py
765
3.9375
4
def countCharacters( words, chars): act = {} rtn_val = 0 for each_char in chars: if each_char in act: act[each_char] +=1 else: act[each_char] =1 for each_word in words: temp = {} rtn_val += len(each_word) for each_char in each_word: ...
d77c6948c783c58c372f1a066eede8a28ab781fd
autozimu/projecteuler
/041/main2.py
896
4.03125
4
#!/usr/bin/env python from numpy import ones, sqrt def ispandigital(n): """check if a number is pandigital""" s = str(n) l = len(s) s = s.replace('0', '') # remove 0 s = ''.join(sorted(set(s))) # remove duplicates if len(s) == l and int(s[-1]) == l: return True else: retur...
b27c6afc72710e6174d70ce2f73d6169eafdc78e
Rafliramdhany/gabut
/arraypy.py
169
4.3125
4
n = [1,2,3,4,5] print("Original Array: ") for i in n: print(i, end="") print() n = n[::-1] print("Array in Reverse Order: ") for i in n: print(i, end="")
0690a895fa517e7763a7480d71ed1ddd06e524b0
GabrielCernei/codewars
/kyu6/Highest_Scoring_Word.py
458
3.546875
4
# https://www.codewars.com/kata/highest-scoring-word/train/python import string def high(x): word_scores = {} alphabet = dict( (key, string.ascii_lowercase.find(key)+1) for key in string.ascii_lowercase ) s = x.lower().split(" ") for word in s: current_score = 0 for c in word: ...
9b8dadcb859bb0eae096b5aa7e71f738a14fc859
kidpeterpan/my-python-tutorials
/org/konghiran/lesson/_07_an_error_handling/_00_try_except_finally.py
277
3.640625
4
# format 0 try: result = 10+10 except: print('program is error!') else: print(result) finally: print('======== end program') # format 1 try: result = 10+10 print(result) except: print('program is error!') finally: print('======== end program')
d1de06a2dc2bef494e1fb1bac39dc95187f5a011
queensland1990/HuyenNguyen-Fundamental-C4E17
/SS03/matrix2.py
200
3.71875
4
m=int(input("enter m:")) n=int(input("enter n:")) for i in range(n): for j in range(m): if(i+j)%2!=0: print("o",end="") else: print("*",end="") print()
24be0bae232d4d0cbc631eab2708e7f997b8daf8
brianmego/Chat-Message-Parser
/chat_parser.py
1,457
3.59375
4
''' This script will parse apart a chat string input into mentions, links, and emoticons ''' import argparse import json import re from urllib2 import Request, urlopen def parse_chat(message): ''' Takes a message string and outputs json of mentions, links, and emoticons ''' output = {} mentio...
7fc2ed402015ca4c3e8711f28efcaffbe6129550
lisvivar/prueba_git
/animales.py
691
3.578125
4
class Animal(): def__init__(self,**args): self.nombreCientifico = args["nombreCientifico"]if "nombreCientifico" in args else"" def setNombreCientifico(self,nombreCientifico): self.nombreCientifico = nombreCientifico def setNombreComun(self, nombreComun): self.nombreComun = nombreComun...
b7430bcb151b7fbe4c8033163e0c2f35bb25a173
AshleyNMarti/PythonCode
/obscured/soln/obscured.py
818
3.546875
4
line = list(map(int, input().split())) heights = line[:] height = -1 maxindex = 0 n=len(line) for index in range(n): if line[index]>height: height = heights[index] maxindex = index line[index] = 'X' else: j = index -1 while heights[index] > heights[j]: j = in...
c9f5cc99689123a8fcdc617d3f5dec8ce934b2bc
dsdshcym/LeetCode-Solutions
/algorithms/rotate_list.py
661
3.765625
4
# Definition for singly-linked list. # class ListNode(object): # def __init__(self, x): # self.val = x # self.next = None class Solution(object): def rotateRight(self, head, k): """ :type head: ListNode :type k: int :rtype: ListNode """ if not hea...
3239390245be03e19389fd9a4d17ba3e73dc260b
esergly/PytonStartLessonTwoTaskAll
/AllInTwo.py
589
4.03125
4
import math # Задача 1 x = int(input("Введите пятизначное число: ")) print(x // 10000) print((x // 1000) % 10) print((x // 100) % 10) print((x // 10) % 10) print(x % 10) # Задача 2 side_a = 5 side_b = 6 side_c = 7 p = (side_a + side_b + side_c) / 2 S = str(math.sqrt(p * (p - side_a) * (p - side_b) * (p - side_c))) pr...
5f5225886f7c926da4cccc6105a46569bd6a2415
jmattick/Python-Bioinformatics-Scripts
/Counting-Point-Mutations.py
258
3.5
4
#Ouputs number of point mutations from text file with two sequences f = open("CountingPointMutationsinput.txt", "r"); s = f.readline(); t = f.readline(); dH = 0; i = 0; while i<len(s): if (s[i] != t[i]): dH+=1; i = i+1; print dH; f.close();
fa7bfd0c519454eb0ae983d87964328eba9a2ae9
energy-100/LeetcodeTest
/最长回文子串.py
1,490
3.578125
4
def longestPalindrome( s: str) -> str: length = len(s) maxlen = 1 startindex = 0 bp = [[False for j in range(length)] for i in range(length)] for i in range(length): bp[i][i] = True for i in range(1, length): for j in range(i): if (s[j] != s[i]): bp[...
1e6efb8d87b6a72e415cc5983352c8ee0ee43faf
zhangshv123/superjump
/interview/linkedin/easy/LC716. Max Stack.py
1,281
3.828125
4
class MaxStack(object): def __init__(self): """ initialize your data structure here. """ self.stk = [] self.maxStack = [] def push(self, x): """ :type x: int :rtype: void """ self.stk.append(x) if len(self.maxStack) == 0 or x >= self.maxStack[-1]: self.maxStack.append(x) def pop(self): ...
6d33af8ebc8c7b7d034a8eddd4a5925571bc6159
tailaiwang/Competitive-Programming
/Leetcode/combination-sum.py
887
3.53125
4
#Combination Sum #https://leetcode.com/problems/combination-sum/ #Medium, 08/01/2022 #Tailai Wang class Solution(object): solution = [] target = 0 def combinationSumHelp(self, candidates, curSol, curSum): if (sum(curSol) == self.target): self.solution.append(curSol[:]) retur...
3e90991ef1de4ff9b58e6573108df429034c9609
YTK0520/Dice-Rolling-Simulator
/Dice Rolling Simulator.py
430
3.859375
4
#!/usr/bin/env python # coding: utf-8 # In[27]: import random import time print("This is a Dice Rolling Simulator.\n") time.sleep(1) dice_num=random.randint(1,6) print(f"The number is {dice_num}.\n") while True: ans=str(input("Do you want to roll the dice again?(yes/no)\n")) time.sleep(0.5) if ans=="yes"...
ad5b91ecdf34c9ce18c44680fb99dba43c3067ed
Jonatas-Arao-Estudos/2019-Etec-Itanhaem-BaixadaNERD-Introducao-ao-Phyton
/ex2.py
238
3.671875
4
valorM = float(input('Digite um valor em Metros: ')) valorMm = valorM / 1000 valorCm = valorM / 100 print('\nSeu valor em Metros: ', valorM , '\nSeu valor em Milímetros: ', valorMm, '\nSeu valor em Centímetros: ', valorCm)
40d94ebacf7b83aa948134a95b2c357bbd1ddbdd
poonamangne/Programming-Exercises-1
/Chapter13_03.py
999
4.25
4
# 13.3 Write a program that reads the scores from the file and displays their total and average. # Sample Input [scores.txt] def main(): while True: try: fileName = input("Enter a filename: ").strip() infile = open(fileName, "r") break except IOError: ...
4d77d1a1361189175af5b608b687f35a27d3218b
ChrisPenner/AdventOfCode
/2015/python/05/part1.py
283
3.875
4
import re g1 = re.compile('(.*[aeiou].*){3,}') # Has 3 vowels g2 = re.compile("([a-z])\\1") # Has double letter b = re.compile("ab|cd|pq|xy") with open('input.txt') as f: print len([ l for l in f if (not b.search(l)) and g1.search(l) and g2.search(l) ]) # 258
ab3ab620ccddef8423744613cfc36813ba2da32b
marcinszymura/python_kurs
/day6/operatory_przeciazenie.py
1,174
3.578125
4
import math class Kwadrat: def __init__(self, bok): self.bok = bok def __add__(self, other): bok = math.sqrt(self.pole + other.pole) return Kwadrat(bok) def __gt__(self, other): return self.bok > other.bok def __gte__(self, other): return self.bok >= other.bo...
73521ec81d51bc78eeda2c636402f9be0e796776
mahidhar93988/python-basics-nd-self
/difference_sum_even_odd_index.py
539
4.125
4
# difference_sum_even_odd_index # You should name your function as difference_sum_even_odd_index # It should take a list of integers # Return an integer def difference_sum_even_odd_index(arr): e = 0 o = 0 for i in range(len(arr)): if i % 2 == 0: e += arr[i] else: ...
4a7dbdea1d1b12194ba027b84f6c9ae663d2f0d5
younkyounghwan/python_class
/lab5_9.py
733
3.796875
4
""" 쳅터: day 5 주제: 매개변수릐 전달 방식 비교(call-by-reference), 전역변수(global variable) 문제: A. list를 받아서 마지막에 리스트의 요소의 개수를 요소로 추가하는 함수 addnum을 정의한다. 반환되는 값은 없다. B. [5, 9, 14, 3]을저장하는 list를 변수 l를 정의한다. C. l를 인수로 addnum함수를 호출한 후 l를 출력한다. 작성자: 윤경환 작성일: 18 10 10 """ #배개변수의 수정 여부 확인을 위한 함수 정의 # call-by-reference 방식으로 매개변수 값을 전달 globa...
0f9f5583067febbcbda4b0e2ed5bee10221f323f
skhan75/CoderAid
/DataStructures/Graphs/trees_in_a_forest.py
1,386
4.125
4
""" Given n nodes of a forest (collection of trees), find the number of trees in the forest. APPROACH : 1. Apply DFS on every node. 2. Increment count by one if every connected node is visited from one source. 3. Again perform DFS traversal if some nodes yet not visited. 4. Count will give the number of trees in fores...
64683912323356a9dd6a8c25de7fdb67feacabe5
SCSZCC/Python-Module-Learn
/Pygame/018 Pygame 碰撞检测.py
1,439
3.859375
4
""" 程序概述:实现角色之间的碰撞检测 工作逻辑: 检测碰撞 API: 1.rect1.colliderect(rect2) 检测两个角色之间是否发生了碰撞,返回True or False """ import pygame import sys pygame.init() screen_size = (800,800) screen = pygame.display.set_mode(screen_size) pygame.display.set_caption("Image Loader") red = pygame.image.load("./images//red_plane.png") red_plan...
8781a333c000c192b2e2d7fac8439e99518bc572
JefersonParra/fundaments-python
/converter_coin.py
700
3.796875
4
# variables pesos = 0 menu = ''' ********************************** CONVERTIDOR DE DÓLARES ********************************** Selecciona la opción de la moneda: 1) Argentina 2) Colombia 3) México ********************************** ''' # function def converter(type_peso, value_peso): pesos = str(round(dollars * ...
406f9a36bf5e6820af6c5211ed65eca063feb89d
kkacan/Osnove_Programiranja
/Vjezba3/vjezba3_zd10.py
852
3.796875
4
# Kristijan Kačan, 9.11.2017. # Vježba 3 zadatak 10 # unos niza znakova niz=input("Unesite niz od 5 znakova: ") # provjera dužine niza if len(niz)==5: # definiranje varijabli i pridruživanje vrijednosti a=niz[0] b=niz[1] c=niz[2] d=niz[3] e=niz[4] # provjera da li je niz palind...
26f47010ee1d7110e1d2d15162d41dc5c67437e5
drunkwater/leetcode
/medium/python3/c0253_515_find-largest-value-in-each-tree-row/00_leetcode_0253.py
712
3.703125
4
# DRUNKWATER TEMPLATE(add description and prototypes) # Question Title and Description on leetcode.com # Function Declaration and Function Prototypes on leetcode.com #515. Find Largest Value in Each Tree Row #You need to find the largest value in each row of a binary tree. #Example: #Input: # 1 # / \ ...
1bd4b48e3fb83f8f412fc11ce8243f4cacc90810
Rainmonth/PythonLearning
/libpil/demo.py
811
3.59375
4
#!/usr/bin/env python # -*- coding: UTF-8 -*- import sys from PIL import Image import os def open_image(path, name): try: im = Image.open(path + os.sep + name) # 打印图片格式、尺寸、色彩模式 print(im.format, im.size, im.mode) # 采用系统默认打开方式打开文件 im.show() except Exception as e: ...
4683239b268a278b210efdf3adeaed368474e186
Samuca47prog/Python_exercises_CursoEmVideo
/ex011.py
638
3.78125
4
########################################################################## # Author: Samuca # # brief: areas and painting calculator # # this is a list exercise available on youtube: # https://www.youtube.com/playlist?list=PLHz_AreHm4dm6wYOIW20Nyg12TAjmMGT- ############################################################...
3825c5f03924b9422703eecf98f3d39c9fd7bfd9
ankuagar/educative.io
/pair_with_given_sum.py
847
3.953125
4
#!/usr/bin/env python3 import unittest t = unittest.TestCase() def find_sum_of_two(A, val): ''' O(N) use extra space ''' s = set() for item in A: if (val - item) in s: return True else: s.add(item) return False A = [5, 7, 1, 2, 8, 4, 3] val = 10 t.ass...
c5b867e1420d10bb38778b184e3370898ed032f1
esquonk/devops_organizer_service
/src/devops_distributor/distributor.py
1,997
3.90625
4
from collections import namedtuple from typing import List def ceil_div(a, b): return -(-a // b) DataCenter = namedtuple('DataCenter', ['name', 'servers']) class Distributor: """ Given DM and DE capacity and a list of data centers, computes the best data center for DM placement and the amount ...
0e9dc365100de3a48816cf1a58358d09371c2609
Nzparra/holbertonschool-machine_learning
/supervised_learning/0x01-multiclass_classification/1-one_hot_decode.py
772
3.609375
4
#!/usr/bin/env python3 """ converts a numeric label vector into a one-hot matrix """ import numpy as np def one_hot_decode(one_hot): """ one_hot is a one-hot encoded numpy.ndarray with shape (classes, m) classes is the maximum number of classes m is the number of examples """ if ...
d5f84459171defd672514999b7f25c60e0aeaa02
CodeHemP/CAREER-TRACK-Data-Scientist-with-Python
/04_Data Manipulation with pandas/02_Aggregating Data/06_Counting categorical variables.py
3,243
4.28125
4
''' 06 - Counting categorical variables Counting is a great way to get an overview of your data and to spot curiosities that you might not notice otherwise. In this exercise, you'll count the number of each type of store and the number of each department number using the DataFrames you created in the previous ...
544bfada2f89ff843458bb3cad152529aee67f60
jakehoare/leetcode
/python_1_to_1000/088_Merge_Sorted_Array.py
1,160
4.0625
4
_author_ = 'jake' _project_ = 'leetcode' # https://leetcode.com/problems/merge-sorted-array/ # Given two sorted integer arrays nums1 and nums2, merge nums2 into nums1 as one sorted array. # You may assume that nums1 has enough space (size that is greater or equal to m + n) to hold additional elements from nums2. # The...
15a33dd8388cdb23a0e0768b394a12d6f9206bae
AdirthaBorgohain/python_practice
/Drawing/draw.py
755
4.125
4
import turtle def draw_square(): baby = turtle.Turtle() #grabs the turtle and names it chutiya baby.color("green") baby.shape("turtle") baby.speed(2) for i in range(0,4): baby.forward(100) baby.right(90) def draw_circle(): jhon = turtle.Turtle() jhon.shape("arrow") ...
3079f5a6f388cefdca34d21cf8bc9b7abf9af9e4
sonushahuji4/Data-Structure-and-Algorithm
/Linked_List_Queue/Basic_Q_Operations.py
2,042
4.125
4
class Node: def __init__(self,data): self.data=data self.next=None class BasicQOperations: def __init__(self): self.front=None self.rear=None self.size=0 def insertdata(self,data): if self.front is None and self.rear is None: new_node=Node(data) ...
e57dc5e0c4e6c8a746391cf401d93a197605b699
uultraviolettt/goit-python
/lesson1/hw1.py
78
3.796875
4
name = input('Enter your name, please:') res = f"Hello, {name} !" print (res)