blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
cd147b8843f5b5d42b0c7a06018644353cb4b441
AdamZhouSE/pythonHomework
/Code/CodeRecords/2377/60628/266940.py
514
3.765625
4
def noncolinearPoints(coordinates): x_0 = coordinates[0][0] y_0 = coordinates[0][1] x_1 = coordinates[1][0] y_1 = coordinates[1][1] k = (y_0 - y_1) / (x_0 - x_1) if (x_0 != x_1) else 0 b = y_0 - k * x_0 x = coordinates[2][0] y = coordinates[2][1] if y != k * x + b: return "Tr...
ace8e962431dff0e87a243940823a0407d09b9ef
cocoon333/DSL
/data_structure_learning/lifegame/test.py
3,188
3.609375
4
import unittest from life import * class TestLife(unittest.TestCase): def setUp(self): pass def test_display(self): l = Life() s = l.display() expr_s = """\ 0 1 2 3 4 5 6 7 8 9 -------------------- 0 | 0 0 0 0 0 0 0 0 0 0 1 | 0 0 0 0 0 0 0 0 0 0 2 | 0 0 0 0 0 0 0 0 0 0 3...
12b32961246747de71ccc58b125b53170ea77a2c
hermetique/eso
/metafractran/metafractran.py
973
3.6875
4
import sys import re import pathlib import fractions as fr path = pathlib.Path(sys.argv[1]).resolve() if not path.is_file(): print("File does not exist") sys.exit(1) name, *parts = reversed(path.parts) is_fraction = re.compile(r"^(\d+):(\d+)$") fractions = [] for i in parts: match = is_fraction.match(i) ...
66bd3d05de32aeee63c3a9f1e5d4e397d61d06a9
tzphuang/python_work
/pythonJuly12.py
6,544
4.5
4
# ~~ PYTHON CLASS AND OBJECTS # ~~ PYTHON CLASSES/ INHERITANCE ~~ # within the real world we have inheritance # and real world objects that inherit are usually classed into parent-child relations # these relations are more specific as you go down a heirarchy # so for example we have a "car" # a very generic term but ...
be1cae86c7c3dbf3e3ecd9fd619c211c9ff21b39
Gsynf/PythonProject
/DayDayUp/DayDayUp.py
508
3.578125
4
#!usr/bin/env python3 #coding:utf-8 __author__ = 'hpf' # 工作日工作进步,双休日休息退步1%,相比于每天都工作进步1%,工作日多努力才能追的上 def dayUP(df): dayup = 1 for i in range(365): if i % 7 in [6,0]: dayup = dayup*(1-0.01) else: dayup = dayup*(1+df) return dayup dayfactor = 0.01 while dayUP(dayfactor) ...
dd421baa1790303f151487ef67d5b421434bdae5
richwandell/lc_python
/easy/21_merge_two_sorted_linked_lists.py
1,681
4.03125
4
# Definition for singly-linked list. class ListNode: def __init__(self, val=0, next=None): self.val = val self.next = next class Solution: def mergeTwoLists(self, l1: ListNode, l2: ListNode) -> ListNode: head = ListNode(-1) current = head while l1 is not None and l2 is ...
9f5252e0052f5dfdd3346ba200dae8bd1d372a24
Donnyvdm/dojo19
/team_10/haiku.py
1,278
3.671875
4
import wave import os import random import sys WORDS = { 1: [ 'a', 'and', 'the', 'code', 'get', 'dance', 'will', 'fork', 'git', 'snake', 'plant', 'trees', ], 2: [ 'python', 'dojo', 'danci...
a941b266004bf04d6ea4f4a26577c4e0623f46f8
rohanaurora/daily-coding-challenges
/Problems/running_sum.py
494
3.953125
4
# Given an array nums. We define a running sum of an array as runningSum[i] = sum(nums[0]…nums[i]). # # Return the running sum of nums. # Input: nums = [1,2,3,4] # Output: [1,3,6,10] # Explanation: Running sum is obtained as follows: [1, 1+2, 1+2+3, 1+2+3+4]. # class Solution: def runningSum(self, nums): ...
2353347781517c3c74dd937959ff3e556b5fd270
briant0618/Python
/Ch04/p99_example.py
471
4.0625
4
""" 날짜 : 2021/04/29 이름 : 김동현 내용 : 딕트 객체 예시 """ # dict 생성 1 dic = dict(key1=100, key2=200, key3=300) print(dic) # dict 생성 2 person = {'name': '홍길동', 'age': '25', 'address': '서울시'} print(person) print(person['name']) print(type(dic), type(person)) # 원소 수정 삭제 추가 person['age'] = 45 print(person) # 수정 del person['ad...
24d24d68e3850740464cacc684cc4f7cebb1910b
Adarbe/opsschool4-coding
/hw.py
453
3.5625
4
import json sorted_buckets = {} data_dict = {} def get_sorted_range(): return sorted(data_dict["buckets"]) with open("hw.json") as json_data: data_dict = json.load(json_data) print(data_dict) sorted_buckets = get_sorted_range() def if_in_range(min_age, max_age, age): return min_age <= age <= max_...
4ac453a9abcc30539027fefd20a64346e695ae2d
daniel-reich/ubiquitous-fiesta
/iLLqX4nC2HT2xxg3F_6.py
245
3.6875
4
def deepest(lst): count=0 maxi=0 print(str(lst)) for i in range(len(str(lst))): if(str(lst)[i]=='['): count+=1 if(count>maxi): maxi=count if(str(lst)[i]==']'): count-=1 print(count) return(maxi)
b65ca02c0d606c471e54e8f53b8bfaeba63919c9
shoriwe-upb/blackjack
/dependencies/card.py
624
3.734375
4
class Card(object): def __init__(self, card): self.__raw_card = card self.symbol = card[-1] self.raw_value = card[:-1] if card[:-1] in "AJQK": if card[:-1] == "A": self.value = 11 else: self.value = 10 else: ...
2813ddc764b31204b27ec868f090fcc30041c42a
yuvrajschn15/Source
/Python/26-lambda.py
372
4
4
# If i have to add 21 to a number i can make a function for that like: def add21_func(x): return x + 21 print(add21_func(79)) # In python we can do this in just one line add21 = lambda x: x + 21 print(add21(7)) # We can take two arguments too with a lambda function divide = lambda x,y: x/y q = int(input("> ...
1b59d84626211da1cdb7ba967f5d09e7ea5961eb
manolan1/PythonNotebooks
/Additional/0_Practice_Programs/Solutions/stopwatch.py
1,168
4.09375
4
#! /usr/bin/env python """ Script Name: stopwatch.py Function: This script mimics a stopwatch with a lap timer The directions are given below. Make sure you display start when the stopwatch start. Be sure that for a lap time you give the lap number ...
c9d8014aa4a23ebb3faac92f7f00e847449f8f4b
GMwang550146647/network
/0.leetcode/1.LeetCodeProblems/0.example/未记录/3.PalindromeNumber.py
1,902
4.25
4
''' Determine whether an integer is a palindrome. An integer is a palindrome when it reads the same backward as forward. Example 1: Input: 121 Output: true Example 2: Input: -121 Output: false Explanation: From left to right, it reads -121. From right to left, it becomes 121-. Therefore it is not a palindrome. Exa...
7b9139f0792e83819679dbd61f7e44b7340ac8ae
andymc1/ipc20161
/lista1/ipc_lista1.15.py
1,247
3.734375
4
#ipc_lista1.15 #Professor: Jucimar Junior #Any Mendes Carvalho - 1615310044 # # # # #Faça um Programa que pergunte quanto você ganha por hora e o número de horas trabalhadas no mês. Calcule e mostre o total do seu salário no referido mês, sabendo-se que são descontados 11% para o Imposto de Renda, 8% para o INSS e 5% p...
f81c910b6462f6beb4b0a6f9aa8a648de8e70a07
ccalsbeek/python-challenge
/PyBank/main.py
2,166
3.78125
4
#Dependencies import os import csv #define variables months = 0 net_profitloss = 0 profit = 0 profit_log = [] totalchange = 0 change = 0 avg_change = 0 gincrease = "0" gdecrease = "0" i_month = "" d_month = "" #define path to csv data path = os.path.join("Resources", "budget_data.csv") #read csv with open (path) ...
5f7ceffcee8710318b26536ac490428b986e8a19
Hoouoo/Backjoon_Python
/boj14916.py
331
3.703125
4
''' date : 2021-02-19 algorithm : math, dynamic programing, greedy, brute force boj 141916 ''' N = int(input()) mod = N % 5 ans = 0 if N == 1 or N == 3: ans = -1 print(ans) elif mod % 2 == 0: ans = (N // 5) + (N % 5 // 2) print(ans) else: ans = (N // 5 - 1) + ((N - (N // 5 -1 ) * 5 ) // 2) pri...
ef541533b69762b0f3f07e3c6005e8b0e489b31b
imzhen/Leetcode-Exercise
/src/divide-two-integers.py
1,234
3.59375
4
# # [29] Divide Two Integers # # https://leetcode.com/problems/divide-two-integers # # Medium (15.95%) # Total Accepted: 96016 # Total Submissions: 601498 # Testcase Example: '0\n1' # # # Divide two integers without using multiplication, division and mod # operator. # # # If it is overflow, return MAX_INT. # # cl...
e25405765d6013e96a00ec660e2591030217f32d
cuc496/Vulnerability-Analysis-of-Network-Tomography-under-Attacks
/dijkstra.py
1,429
3.65625
4
def edgebetw(u,v): for e in u.edges(): if e in v.edges(): return e return -1 def getAdjNodes(node): nodes = [] for e in node.edges(): if e.node1 != node: nodes.append(e.node1) if e.node2 != node: nodes.append(e.node2) return n...
b5d887b347ea5a23019afd6e948437009992b38e
Nandan093/Python
/Loop statements.py
634
4.25
4
#with/without vowel check a = ["hello", "bcd", "gcd", "hhmmm", "python"] print("Input list ",a) vowel= [] without_vowel = [] for i in a: if ("a" in i or "e" in i or "i" in i or "o" in i or "e" in i): vowel.append(i) else: without_vowel.append(i) print("The list with vowels ", vowe...
b86460c42c89f62c7830cde1b2562a9ff9394607
primeschool-it/Y13
/classes.py
1,386
4.46875
4
# 1.Classes # 2. Objects or Instance or Class Members # 3. Properties of Objects # 4. Getting Values from Objects # 5. Setting Values to Objects # 6. Deleting an object from datetime import datetime class Y11(): ###Initialization of the class def __init__(self, student_name, student_age, student_dob): p...
cfe676db3a8eb5a0b695a483d55f4c7e0d3c53bc
MrHamdulay/csc3-capstone
/examples/data/Assignment_8/allnas012/question1.py
448
4.0625
4
#Nasiha Ally #ALLNAS012 #May 2014 def pal(string): if (string): if (string[0] == string[-1]): result =pal(string[1:-1]) if result: return True else: return True return False if __name__ == "__main__": x = input("Enter a ...
b5df155f9988f5fbe4c49b8af760007806bf9030
g0v/nowin_core
/nowin_core/memory/audio_stream.py
5,536
3.734375
4
class AudioStream(object): """Audio stream """ def __init__(self, blockSize=1024, blockCount=128, base=0): """ The bytes is a big memory chunk, it buffers all incoming audio data. There are blocks in the memory chunk, they are the basic unit to send to peer. <--...
1be1170d58665ca75e143231abc438d3954a8021
piphind/MyPython
/User Functions.py
138
3.609375
4
def mean(mylist): calcmean = sum(mylist) / len(mylist) return calcmean print("The mean of my list is", mean([1,2,3,4,5]))
434dd644617117f863d8210439ef532f3d537816
padampadampadam/MLD-HandsOn
/Session-4/src/feature-3.py
1,540
3.5625
4
#!/usr/bin/env python import pandas as pd import numpy as np from sklearn.linear_model import LinearRegression from sklearn.preprocessing import StandardScaler # defining global variable dataset_path = "../dataset/train.csv" selected_variables = ["YearBuilt", "BedroomAbvGr", "KitchenAbvGr", "SalePrice"] target_variba...
4466641c4704999ece18d7cb34a8acb3e3f6d02d
UWPCE-PythonCert-ClassRepos/SP_Online_PY210
/students/kristoffer_jonson/lesson3/strformat_lab.py
1,793
3.859375
4
#!/usr/bin/env python3 #task one task_one_string = 'file_{:0>3} : {:.2f}, {:.2e}, {:.3g}' input_tuple = ( 2, 123.4567, 10000, 12345.67) print(task_one_string.format(*input_tuple)) #task two task_two_string = 'file_{file_name:0>3} : {file_attr_1:.2f}, {file_attr_2:.2e}, {file_attr_3:.3g}' print(task_two_string.form...
2f962b44ccd2c3e829885e3f549de7bbeff41f41
jogusuvarna/jala_technologies
/smaller_lyarge.p.py
300
4.09375
4
# Print the smaller and larger number l=[1,5,4,8,6,9,10] print(max(l)) print(min(l)) #and a=[] n=int(input("Enter size of a:")) for i in range(n): num=int(input("Enter the number:")) a.append(num) print("the largest number in a is:", max(a)) print("the smallest number in a is:",min(a))
ad2fe989d4b82221c5552f108986b0984fe67373
Edvinauskas/Project-Euler
/nr_017_python.py
1,485
3.703125
4
######################################### # Problem Nr. 17 # If the numbers 1 to 5 are written out in # words: one, two, three, four, five, then # there are 3 + 3 + 5 + 4 + 4 = 19 letters # used in total. # # If all the numbers from 1 to 1000 (one thousand) # inclusive were written out in words, how many # letters woul...
3e9a5b97743173f7ec8394bf1f22c889a0827df2
crashoverloaded/Data-Structures-and-Algos
/Day1/Stack/Convert_int2bin.py
261
3.75
4
#!/usr/bin/python3 from stack import Stack def div_by2(dec_num): s = Stack() while dec_num > 0: r = dec_num % 2 s.push(r) dec_num = dec_num // 2 bin_str="" while not s.is_empty(): bin_str += str(s.pop()) return bin_str print(div_by2(242))
78646abd065b5cea6c564d4a0c778c0d4c6accce
thunde47/CTCI
/1-arrays-and-strings/1.4-palindrome_permutation.py
303
3.6875
4
def palindrome(s): s=s.lower().replace(' ','') d=dict() for a in s: #O(N) if a in d: d[a]+=1 else: d[a]=1 odds=0 for key in d: #worst O(N) if d[key]%2==1: odds+=1 if odds>1: return False return True s="taCttt ca o ooooooioo" print(palindrome(s))
1c842a895fb006714d45b934a546e03bb5939167
Kaiepi/py-Hangman
/hangman.py
3,497
4.1875
4
#!/usr/bin/env python3 from random import choice class Hangman: """ self.target - the progress of the guessed word self.guessed - guessed letters self.guessed_words - guessed words self.wrong_answers - number of mistakes made, a maximum of 6 allowed self.ended - whether or...
d73b41abbdd6f1425d9b55ace4aac40268d3c0ca
mailsonalidhru/SATScore
/SATScore/SATScore.py
3,445
3.65625
4
##### Import Libraries Section ##### import pandas as pd import numpy as np import matplotlib.pyplot as plt ##### Variables Initialization ##### data = pd.read_csv("C:\\Personal\\Data\\scores.csv") ##### Processing Section ##### print('Highest average SAT Math score {} Lowest score {}.'.format( int(data['Averag...
06802b6e78e07a921d8c46b6dcab60252494d698
1oss1ess/HackBulgaria-Programming101-Python-2018
/week-7/engin/unit.py
3,655
3.546875
4
from weapon import Weapon from spell import Spell class Unit: def __init__(self, health, mana): if self.validate_value(health): raise TypeError('Value must be a number!') if self.validate_value(mana): raise TypeError('Value must be a number!') self.health ...
35cfc54ffaa0eb4abeff43f73faef737722d3b8b
smswajan/mis-210
/Chapter-5/5.09-Financial-application--compute-future-tuition.py
448
3.75
4
tuitionFee = 10000 year = 0 total = 0 while year < 10: tuitionFee = tuitionFee * 1.05 year = year + 1 tuitionFee = round(tuitionFee, 2) print("Tuition at the end of 10 years is ${0}".format(tuitionFee)) while year < 14: tuitionFee = tuitionFee * 1.05 year = year + 1 total = total + tu...
c559cde2cb28756ee7c4c4614819bd8d3f388c5a
zhouli01/python3
/List.py
145
3.828125
4
#!/usr/bin/python3 #coding:UTF-8 list1=['hello','world','zhouli'] list2=list(range(5)) list1.extend(list2) print ("扩展后的列表:", list1)
d80e44a169d155e4e11e4c2df431bf8c846448fa
juanmunoz22-bit/python-intermedio
/list_dicts.py
735
3.75
4
def run(): my_list = [1, 'Hello', True, 4.5] my_dict = {'firstname': 'Juan', 'lastname': 'Muñoz'} super_list = [ {'firstname': 'Juan', 'lastname': 'Muñoz'}, {'firstname': 'Pedro', 'lastname': 'Perez'}, {'firstname': 'Maria', 'lastname': 'Gonzalez'}, {'firstname': 'Jose', 'la...
c0326e9fc27cf1f4bcf863c98e3d611d10968b66
yinglang/MyCodeInUse
/MLInAction/base/pythonModeTest.py
2,648
3.828125
4
# coding=utf-8 import operator def sortedTest(): # list tuple 排序, key的参数是 for key in students students = [('john', 'A', 15), ('jane', 'B', 12), ('dave', 'B', 10),] print sorted(students, key=lambda student : student[2]) # sort by age print sorted(students, key=lambda student : student[2], reverse=Tru...
8783819041d1e27cb760785179dd036abf533bd5
mapu77/todo-list-kata-python
/src/Todo.py
744
3.703125
4
from Item import Item class Todo(object): def __init__(self): self.items = [] def add(self, description): self.items.append(Item(description)) def check(self, index): try: self.items[index].check() except IndexError: pass def print(self): ...
8a159f51bb1d239e6c613c375049434eb8b3f6e0
cianjinks/Python-Misc
/SectionOne/20.py
108
3.671875
4
d = {"a": 1, "b": 2, "c": 3} i = 0 for k in d: i += d[k] print(i) # also j = sum(d.values()) print(j)
85e5dd1596f72e231ec69674487146d978d7dd29
pengiun501/python
/烏龜 特殊圖形1.py
167
3.546875
4
import turtle t=turtle.Turtle() t.screen.reset() t.color('blue') t.shape('circle') t.pensize('5') i=1 while True: t.forward(i) t.left(30) i=i+1
2830be49b3ac85f14d2b31b17bfa43239aa4e5c6
devscheffer/SenacRS-Algoritmos-Programacao-3
/task_1/main/ex_1.py
804
4.09375
4
""" Escreva uma classe “Lampada” as quais suas características referem-se à - um modelo - um supermercado. """ """ Após, crie uma classe “TestaLampada” - onde os atributos são inicializados e mostrados na tela. - desenvolva os métodos para ligar e desligar a lâmpada """ class cls_Lampada: def __init__(self, model...
352b643aa76bc4140a6dd4949c26c707a79e1c8a
upsmancsr/Algorithms
/stock_prices/stock_prices.py
1,671
3.734375
4
#!/usr/bin/python import argparse # first attempt: create array of all possible buy/sell spreads, then find the largest # def find_max_profit(prices): # possible_spreads = [] # for i in prices: # # for idx, s in enumerate(prices, start = b ): # for j in prices[prices.index(i):]: # if j - i != 0: # ...
c6c2604e2e0e719fd28d386d7e7e7d51b11f548a
Teemakornsamsen633050338-2/python
/test.py
2,404
3.75
4
'''print("กรุณาเลือกรายการ\n") print("กด 1 เลือกเหมาจ่าย \nกด 2 เลือกจ่ายเพิ่ม") x =int(input("")) if x==1 : s =int(input("กรุณาบอกระยะทาง")) if s <=25: print("ค่าใช้จ่ายทั้งหมด 25 บาท") else : print("ค่าใช้จ่ายรวมทั้งหมด 55 บาท") elif x==2: s =int(input("กรุณาบอกระยะทาง")) if s <25:...
3aa85ee4dec8aa89fd646d4d9ad111bfa6ca9437
Washirican/pcc_2e
/chapter_07/tiy_7_5_movie_tickets.py
525
3.875
4
# --------------------------------------------------------------------------- # # D. Rodriguez, 2020-05-02 # --------------------------------------------------------------------------- # age = '' while age != 'done': prompt = '\nWhat is your age? (Enter \'done\' when done)' age = input(prompt) if age ==...
c6d199d1fb5d6b3ea55819a11edfccd3cd122aaa
rafaelri/coding-challenge-solutions
/python/fibonacci-dp/fibonacci_dp.py
256
3.921875
4
def fibonacci(n): if n == 0: return 0 elif n == 1: return 1 else: memo = (n+1) * [0] memo[0] = 0 memo[1] = 1 for i in range(2,n+1): memo[i]=memo[i-2]+memo[i-1] return memo[n]
d4f6d39ad20eb3c0d8b6c508e365f3f15df0b8cf
nzh1992/Interview
/py_language/file_operate/01_traverse_dir.py
1,307
3.53125
4
# -*- coding: utf-8 -*- """ Author: niziheng Created Date: 2021/6/4 Last Modified: 2021/6/4 Description: """ # 问题 # 设计实现遍历目录与子目录,抓取.py文件 # 方法一 import os def traverse_dir(dir, suffix): tmp_list = [] for root, dirs, files in os.walk(dir): for file_name in files: name, suf = os.path.splite...
d61b581c2d611d5f735010631de5e87b1f1328c7
cristiancmello/python-learning
/3-informal-intro-python/3.3-lists/script-1.py
1,172
4.46875
4
# Listas lista = [1, 2, 4, 5, 8] print(lista) # [1, 2, 4, 5, 8] # Indexação e Slicing print(lista[0]) # 1 print(lista[2:]) # [4, 5. 8] print(lista[:]) # lista <=> lista[:] => [1, 2, 4, 5, 8] # Concatenação print(lista + [-2, -4]) # IMPORTANTE! # Diferentemente das Strings, Listas SÃO MUTÁVEIS lista[2] = 2 **...
b8650cbed04d2e40b8ddf6723f87b320dd5f73b0
DanielJmz12/Evidenicas-Programacion-avanzada
/Evidencia38_for_notas.py
291
3.765625
4
aprobados = 0 reprobados = 0 for f in range (10): nota = int(input("ingresa la nota: ")) if nota>=7: aprobados = aprobados+1 else: reprobados = reprobados+1 print("alumnos aprobados: " + str(aprobados)) print("alumnos reprobados: " + str(reprobados))
a0e46063d68e34652dbb6b8b98582cac25783c2d
ANEP-ET/sorting-visualizer
/sorting/monkeysort.py
1,119
3.671875
4
# Script Name : monkeysort.py # Author : Howard Zhang # Created : 14th June 2018 # Last Modified : 14th June 2018 # Version : 1.0 # Modifications : # Description : Monkey sorting algorithm which can do nothing but be funny. import copy import random from .data import Data def mon...
3856f1f9afc2d5aa494ca522d649d9a0a025e29c
OmkarGangan/Cash-Counting-Notes-counting
/Count Notes in Amount.py
1,657
3.984375
4
# Count Total Number Of Notes required in Entered Amount. # List to store notes c = [2000,1000,500,200,100,50,20,10,5,2,1] # User entered amount stored in variable n n = int(input("Enter Amount:")) # storing user entered amount in temporary variable rs rs = n # variable i as a counter i=0 ...
a4342f9321594f380f210ed005b2ef79279f8043
zlodeyrip38/python_lessons
/rodjer.py
5,273
3.703125
4
from time import sleep from timeit import default_timer from random import randint, choice def select_mode(): print(''' Режимы: 1 - тренировка 0 - выход ''') mode = '' while not mode.isdigit(): print('Выбери режим:') mode = input() while not mode.isdigit(): ...
e6bc8d27c28cce359a88aa0501f926ae74f49921
DCtheTall/pygame-tutorial
/src/draw_circle.py
654
4.03125
4
""" PyGame tutorial: First sample program https://realpython.com/pygame-a-primer/ """ import pygame from typing import Callable def run_until_quit(func: Callable): running = True while running: for ev in pygame.event.get(): if ev.type == pygame.QUIT: running = False func() def draw_circl...
0925b2027b163d5f9ace48b29d2241572e275669
VakinduPhilliam/Python_Argparse_Interfaces
/Python_Argparse_Dest.py
1,939
3.890625
4
# Python argparse # argparse Parser for command-line options, arguments and sub-commands. # The argparse module makes it easy to write user-friendly command-line interfaces. # The program defines what arguments it requires, and argparse will figure out how to parse those out of sys.argv. # The argparse module also...
08c191a4a2bf97cc76eeb6dba40380d73498ae4b
Abusagit/practise
/Stepik/pycourse/Matrix_transposition.py
656
3.828125
4
import numpy as np def matrix_build(rows): matrix = [] for row in range(rows): matrix.append([int(i) for i in input().split()]) return matrix def matrix_transpose(matrix, rows, columns): matrix2 = [] for column in range(columns): tmp = [] for row in range(...
bf083e441af58686000d92b0753882e8dff6cbe1
msheshank1997/Hashing-1
/group_Anagrams.py
832
3.5
4
#Time Complexity : O(NK), where K is the length of each string and N is the length of the List. # Space Complexity = O(1) # Yes it ran on Leetcode. class Solution(object): def groupAnagrams(self, strs): primes = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, ...
af7421236d0323f647a3a6e7136d37d01f77542e
Aditya1108/akhileshwork
/demo8.py
3,675
3.8125
4
from tkinter import * root = Tk() root.title("story's") root.geometry("500x2000") scrollbar = Scrollbar(root) scrollbar.pack(side = RIGHT, fill = Y) scrollbar.config(command = root) label = Label(root, text="story 1 Never tell lie") label.config(font=("Arial", 30)) label.pack() label_2 = Label(root, text="There ...
fd3d470d54b6f8714cbfab175765420f4bb4518b
jennypeng/python-practice
/TurtleArena/catmouse.py
3,153
4.3125
4
""" step - moves forward one step in the simulator, -- asks each turtle to get its next state -- -- new_state = turtle.getnextstate() -- asks each turtle to set their state to next state -- -- turtle.setstate(new_state) *simulates parallel behavior run - loops over step over and over again stop - stop running quit - ...
7f3279d96fd8f2404ac47c69880084e2cc7051f0
romanannaev/python
/STEPIK/Stepic_module2/iterating.py
448
3.828125
4
# x = input().split() # xs = (int(i) for i in x) # # # # def even(x): # # return x % 2 == 0 # # evens = list(filter(lambda x: x % 2 == 0, xs)) # print(evens) x = [ ("Guido", "van", "Rossum"), ("Haskell", "Curry"), ("John", "Backus") ] import operator as op from functools import partial sort_by_last =...
5bb4ee246ad579704863059764f7248761864463
GeorgiTodorovDev/Python-Basic
/working_hours.py
216
4.125
4
hour = int(input()) day_from_week = input() result = "" if day_from_week == "Sunday": result = "closed" else: if 10 <= hour <= 18: result = "open" else: result = "closed" print(result)
81b4048741d9adcd981ec471c9a94b4775336ac1
JeanSavary/Genetic-Algo
/main.py
7,483
3.859375
4
#!/usr/bin/python # -*- coding: utf-8 -*- # -- External imports -- # import os import numpy as np import pandas as pd from random import uniform, sample import matplotlib.pyplot as plt # -- Internal imports -- # from src.city import City from src.population import Population from src.population import Route from va...
574b21b7ced58f8884e71860c45d04eae4f67fb3
jacob-liberty/area-and-perimiter-calculation-
/area_perimiter_calculation.py
508
3.765625
4
# Created by: Jacob Liberty # Created on: September 17 2017 # Created for: ICS3U # This program calculates the perimiter and area of a rectangle import ui def calculate_perimiter_touch_up_inside(sender): #calculate the perimiter of the shape view['perimiter_label'].text = 'The perimiter is ' + str(5+3+5+3) +...
50d2e40d899ddac62b5b0bddc00bfab1eb9e1dc9
bartkowiaktomasz/algorithmic-challenges
/LeetCode - Top Interview Questions/Pow.py
706
3.796875
4
""" Implement `pow(x, n)`, which calculates `x` raised to the power `n` """ from typing import Dict class Solution: def myPowRec(self, x: float, n: int, memo: Dict[int, float]) -> float: if n in memo: return memo[n] elif n == 1: return x else: res = self...
d2815f2cd8ad0e8951245d15b5d1d4b6cab6b646
gregoriovictorhugo/Curso-de-Python
/Mundo-01/pydesafio Mundo01/des011.py
267
3.828125
4
l = float(input('Largura da parede em metros: ')) a = float(input('Altura da parede em metros: ')) print('A área da parede é: {}'.format((l*a))) print('Considerando que um litro de tinta pinta dois metros quadrados, serão necessários {} litros'.format(((l*a)/2)))
74f252feaa14a8c481925f2fa048377aeb68b2ac
ddmin/CodeSnippets
/PY/DailyProgrammer/easy5.py
190
3.640625
4
# [Easy] Challenge 5 import sys import getpass pw = getpass.getpass("Enter your password: ") if not (pw == "password"): print("Wrong Password!") sys.exit() print("Hello World!")
2be3df714343ef414d9e72a6dd6e6ed459f0c9bf
piochelepiotr/crackingTheCode
/chp2/ex6.py
1,079
4.03125
4
import linked_list class Stack: def __init__(self): self.l = None def pop(self): if self.l is None: return None x = self.l.value self.l = self.l.next return x def push(self, x): self.l = linked_list.Node(x, self.l) def is_palindrome2(head)...
78a4dd740962ae092bb6d3458546dda23ac9ec58
LeeHeejae0908/python
/Day04/module_basic03.py
513
3.578125
4
''' * 사용자 정의 모듈 - 하나의 모듈 파일에 너무 많은 코드가 들어있다면 편집이 힘들어지고, 코드를 유지, 보수 하는데 어려움이 발생 - 관리 편의상 비슷한 기능들을 가진 코드를 여러개의 모듈에 나누어서 작성하는 것이 좋다. ''' import calculator as cal print(f'1인치: {cal.inch}cm') print('1~10 누적합: ', cal.calc_sum(10)) n1, n2 = map(int, input('정수 2개 입력: ').split()) print(f'{n1} + {n2} = {cal.add(n1, n2)}')
d2c6e2b38c20e6844c6e69103d3464f308032594
yami-five/SPOJ
/_1289.py
455
3.78125
4
while True: try: line=input() if line.count('>')>1 or line.count('<')>1: i,j=-1,0 for x in range(len(line)): if line[x] is '>': i=x+1 elif line[x] is '<' and i>0: j=x break ...
76bcb4d33dccaa16a0446c2e2617452b1c6122db
facedesk/prg1_homework
/hw6.py
1,722
4.21875
4
''' For this homework, your code must match the area called specs. This means you must use the correct function names, correct parameter names, and fulful the function needs. Good luck and happy sorting! ''' ''' Problem 1 Create a function called swap. This function will take in as parameters two varia...
ce9a266327931cce5db9c89e01992d5efc80adbd
Luccifer/PythonCourseraHSE
/w05/e15.py
231
3.703125
4
# Количество положительных def number_of_positive(nums): i = 0 for num in nums: if num > 0: i += 1 print(i) nums = list(map(int, input().split())) number_of_positive(nums)
fc8166124078b0a1ae8b859b6dc44c83edfb2576
dawtom/mikroKodRPi
/sqllite.py
545
3.609375
4
import sqlite3 def create_connection(db_file): """ create a database connection to a SQLite database """ try: return sqlite3.connect(db_file) except Error as e: print(e) def main(): connection = create_connection("/home/pi/Desktop/NRF24L01/pythonsqlite.db...
5439a1f86ebe96ff2c67ea0fa5e132b229a7cc76
tjmacphee/COP-1500-Integration
/Main (2).py
7,402
4.25
4
#Tyler MacPhee, Integration Project, COP-1500 #Import modules import turtle import wikipedia #Class creation for question system class Question: def __init__(self, prompt, answer): self.prompt = prompt self.answer = answer user = input("What is your name? ") while True: if user.isa...
cc297c955e8e16b5abbbb7a62465da38a0f6cef0
yassh-pandey/Data-Structures
/reverseString.py
194
4.15625
4
from stack1 import Stack print('Enter the string') string = input() s = Stack() for char in string: s.push(char) print("Reversing string") while not s.isEmpty(): print(s.pop(), end="")
b6c8e35763297978471c6a454524caafdd06051b
mickey-is-codin/OrbitCalculations
/manualArrayBleb.py
8,272
3.96875
4
#https://github.com/smit2300/OrbitCalculations import math import numpy as np class GetInput(object): def get_eye(self): self.eye_radius = float(input("Radius of the eyeball in mm: ")) #Method for getting eyeball radius input return self.eye_radius def get_bleb(self): #self.bleb_radius = float(input("Radiu...
a3c77cb583fc920629823bc6b1bf13d6d0663bc4
oskarmcd/project_euler
/problem_007_Python/problem7.py
512
4
4
""" By listing the first six prime numbers: 2, 3, 5, 7, 11, and 13, we can see that the 6th prime is 13. What is the 10 001st prime number?s """ def is_number_prime(number): if number % 2 == 0: return False for x in range ((number-1), 2 ,-1): if (number % x) == 0: return False ...
673c03547f729556e01cf8396d5d324745b1cdba
Trlan2723/My_Python
/0-100(2).py
1,285
3.984375
4
def instruction(): print("Задано число от 0 до 100.") print("Вам дано 7 попыток. Попробуйте отгадать ;)") def make_number(): """Загадывает число""" import random number = random.randrange(0,101) return number def ask_number(): """Спрашивает мнение""" guess = int(input("Ваше...
dcd45be8bf35850359bfea6b453667a9ea880aa9
steffenerickson/humanitiesTutorial
/08_loops1_while.py
532
4.5
4
# Loops allow you to execute code over and over again, which # is where much of the power of programmming lies # While loops execute as long as the condition is true. # Be careful with these, because it is easy to create an # infinite loop! i = 0 while i < 10: print(f"{i} is not yet 10.") # increment i. if i ...
e1ce89300e70c6edfef2976babcaf445104a782a
raunakshakya/PythonPractice
/numpy/10_arithmetic_operations.py
2,666
4.5625
5
# https://www.tutorialspoint.com/numpy/numpy_arithmetic_operations.htm import numpy as np a = np.arange(9, dtype=np.float_).reshape(3, 3) print('First array:') print(a) print() print('Second array:') b = np.array([10, 10, 10]) print(b) print() print('Add the two arrays:') print(np.add(a, b)) print() print('Subtra...
ae8c9d8194cc3b8df50095a6e2daf950c3c60afe
IlievaDayana/SOFTUNI
/Fundamentals/nikuldens meals.py
1,080
3.96875
4
preferences = {} dislikes = 0 command = input() while command != "Stop": command = command.split("-") guest = command[1] meal = command[2] if command[0]=="Like": if guest not in preferences.keys(): preferences[guest] = [meal] elif guest in preferences.keys() and m...
dca55144e32a2173818f8858dceb410d20dc0e06
guosaichong/personnel-management-system
/managerSystem.py
4,987
3.671875
4
from person import * class PersonManager(object): """人员管理类""" def __init__(self): # 存储数据所用的列表 self.person_list = [] # 程序入口函数 def run(self): # 加载文件里面的人员数据 self.load_person() while True: # 显示功能菜单 self.show_menu() # 用户输入目标功能序号...
d034787fe1923d60626fb15e9d45e44d6da358a0
dan8919/python
/class/Dog.py
701
3.96875
4
class Dog: a,b=0,0 def __init__(self,name): self.name = name print(self.name,"Dog was Born") def speak(self,a,b): print("yelop!",self.name,a,b) def wag(self): print("Dog's wag tail") def __q(self): print("__붙이면 비밀공간. 밖에서 못부름") def __del__(self): ...
2f118aa1863514eb8bcf6fc8ad46503b0648f1d8
abinesh1/pythonHackerRank
/strings/prob19.py
605
4
4
## https://www.hackerrank.com/challenges/string-validators/problem if __name__ == '__main__': s = input() print(True if any([x.isalnum() for x in s]) else False) print(True if any([x.isalpha() for x in s]) else False) print(True if any([x.isdigit() for x in s]) else False) print(True if any([x.isl...
1fe7f3ac457d602c5d319f3617484e866d511134
seclay2/ML_FinalProject
/LinearRegression/Tasks/Q_12.py
2,755
3.578125
4
def Q_12(self, X_train_scaled, X_test_scaled, y_train, y_test, learning_rate=0.001, nIteration=7000): # Task 12: Given the (X_train, y_train) pairs denoting input matrix and output vector respectively, # Fit a linear regression model using the stochastic gradient descent algorithm you learned in class to obtain...
bae0dcab2a84ee00200ef4ed9716a0d591ea3396
Senbagakumar/SelfLearnings
/Demos/InterviewPrepration/Prepration/Prepration/HackerRank/Implementation/Manasa and Stones/Solution.py
550
3.546875
4
#!/bin/python3 import sys """ The final stones are the values included in the range [a * (n - 1), b * (n - 1)] with step (b - a). """ if __name__ == '__main__': t = int(input().strip()) for a0 in range(t): n = int(input().strip()) a = int(input().strip()) b = int(input().strip()) ...
0096981248d518f9a592d5dd1579a5af929e0ada
danilogazzoli/estudopython
/cursoolist/aula02-01.py
987
4.0625
4
kind = "blank" def test_kind(): print("Test Kind:", kind) class Dog: kind = 'canine' #campo estático à classe def __init__(self, name): #definir todos os atributos no __init__ self.name = name def what_kind(self): print("Name:", self.name) print("Geral:", kind) ...
c08c35134e83ec5b22e8afd0881a4fd996090668
lumafragoso/Basico_Condicionais_Triangulo_Retangulo_Isoceles
/main.py
229
4.09375
4
import turtle from math import sqrt, pow t = turtle.Turtle() x = int(input('Digite o tamanho do lado do triângulo: ')) hipotenusa = sqrt(pow(x,2)+pow(x,2)) t.forward(x) t.left(135) t.forward(hipotenusa) t.left(135) t.forward(x)
67136615b5d15b679e9dc7ae40b473fe2c4a1444
VeraSa785/Python_practice
/object_oriented_programming_methods.py
589
3.53125
4
# Object oriented programming. Methods. class BankAccount: def __init__(self,client_id, client_first_name, client_last_name): self.client_id = client_id self.client_first_name = client_first_name self.client_last_name = client_last_name self.balance = 0.0 def add(self, amount): ...
538b553dfa370f9510d1264252198b864225d4bb
Geeky-har/Python-Files
/generators.py
432
4.25
4
# --------------Generators in python---------------- def gen(n): for i in range(1, n): yield i # it will provide value of i a = gen(2000) # a function for generatin no upto 2000 created print(a.__next__()) # will print 1 since it starts from 1 print(a.__next__()) # will pr...
f6fe0f8a5ba04963ef860a5dd42ea9d43ace7955
Kanrin-Cyou/BasicPY
/Class/test.py
2,387
3.640625
4
# 面向对象:封装(私有),继承(父子),多态(一种接口,多种形态,实现接口的重用) # 封装:把一些功能的实现细节不对外暴露 # 继承:代码的重用 #单继承 调用父类的方法 super(自身,self).__init__(name,age) #多继承 #组合 self.person = Person(self,job) 直接继承功能 # 多态:接口重用 #对象:实例化一个类之后的对象 #类: #属性:实例变量,类变量,私有属性(__var) #方法:构造方法(__init__),析构函数(__del__),私有方法(__method) #静态方法 @staticmethod 只是名义...
e15f023b2c499b049e7375e4f16d8da7376018c2
dmachibya/one_algorithm_a_day
/old/day2/linear_search.py
487
4.1875
4
""" Linear search algorithm When to use this Algorithm - When searching a short array which may be unsorted. """ #algorithm function def linear_search(array, target): for i in range(0, len(array)): if(array[i] == target): return i return None #testing function def verify(algorithm): ...
743a8d18768fdb4bfc269d20b5d3e16ab3586bef
scorpio-su/zerojudge
/python/c420.py
307
3.9375
4
# -*- coding: utf-8 -*- """ Created on Tue Jan 7 17:03:07 2020 @author: Username """ n=int(input()) for i in range(n): for j in range(n-i-1): print('_',end='') for j in range(i+1): print('*',end='') for j in range(i): print('*',end='') for j in range(n-i-1): print('_',end='') print()
58158f47d5a8737e93d8d8c2a9f5a988ef50f973
VitorAlvess/Estudos
/Arquivos/Curso Python Gustavo Guanabara/ex080.py
104
3.8125
4
numeros = [] for c in range(0, 5): numeros.append(int(input('Digite um valor'))) print(len(numeros))
5b783b0844b4058b07db542a074c5272b4ea78c4
Muhammadilhammubarok170/Tugas-Praktikum-pertemuan-ke-6
/Latihan 1.Lab 6.py
840
3.828125
4
import math def a(x): return x ** 2 def b(x, y): return math.sqrt(x ** 2 + y ** 2) def c(*args): return sum(args) / len(args) def d(s): return "".join(set(s)) # Dirubah menggunakan Lambda aa = lambda x: x ** 2 bb = lambda x, y: math.sqrt(x ** 2 + y ** 2) cc = lambda *ar...
11dda33d844093d9ddca1e6b4bcbf1ec23d428d4
dabiri1377/DS-AL_in_python3
/Chapter_1/1.4.1_test.py
404
3.890625
4
# Control flow #### # Conditionals # if first_condition : # first_body # elif second_condition: # second_condition # elif third_condition: # third_body # else: # fourth_body if 1 == 2: print("WTF!! 1 is not equal to 2!!") elif 2 == 3: print("wo wo wo WTF?!! 2 == 3?") elif 3 == 4: print("what are y...
f133f82aff1b4b7fa688405a0d06d2a084933cf5
ArthurZheng/python_hard_way
/functions_files.py
658
3.859375
4
from sys import argv script, input_file = argv def print_all(file_name): print file_name.read() return def rewind(file_name): return file_name.seek(0) def print_a_line(line_count, file_name): print line_count, file_name.readline() return current_file = open(input_file) print "First, let's print the whoel fil...
4cdee01ed32199814055f190829a99bf4b7252c8
yzl232/code_training
/mianJing111111/Google/给你一串正整数。1,2,3.。。。10, 11,12.。。。 给你一个int n,要你返回哪一位的数。比如 给你10,返回的就是1.给11,返回的就是0.py
1,841
4.375
4
# encoding=utf-8 ''' Imagine you have a sequence of the form 123456789101112131415... where each digit is in a position, for example the digit in the position 5 is 5, in the position 13 is 1, in the position 19 is 4, etc. Write a function that given a position returns the digit in that position. (You could think that...
8f1b0fa372271509462331a6debeeeeddf865dc4
wuyongqiang2017/AllCode
/day17/是否.py
92
3.515625
4
# l=["d","f","g","e","r","t","s"] # l.sort() # print(l) # l.sort(reverse=False) # print(l)
d033de683a30b3e964eebd99d7e02b02d416ad38
allertjan/LearningCommunityBasicTrack
/week 3/homework third part/3.8.py
185
3.859375
4
number_amount = int(input("Which size n would you like? ")) triangle_number = 0 for i in range(1, (number_amount + 1)): triangle_number += i print(i," ", triangle_number)
ffacd29a9d09672e0833abb2c6d099892d5524c5
yasharth328/Mini_Python_Projects
/caesar_solver.py
764
4.09375
4
print('caesar cipher solver') def bruteforce(): print('enter the ciphertext:') s = input() s.upper() for i in range(1,26): print('--------------------------------------') print('key = {}'.format(i)) c = '' for j in s: c+= chr((ord(j) + i-65) % 26 + 65) print(c) def encrypt(): s = input("enter text ...
d7512e664647c5120d5d14f727e2c8c32c6cc1ac
jawang35/project-euler
/python/lib/problem67.py
1,200
3.890625
4
''' Problem 67 - Maximum Path Sum II By starting at the top of the triangle below and moving to adjacent numbers on the row below, the maximum total from top to bottom is 23. 3 7 4 2 4 6 8 5 9 3 That is, 3 + 7 + 4 + 9 = 23. Find the maximum total from top to bottom in triangle.txt (right click and 'Save Link/...