blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
a5bbac270cad0cceb93b8c4d5332ebf489ef6d5e
czer0/python_work
/Chapter3/3-8_seeing_the_world.py
252
3.71875
4
# places = ['norway', 'iceland', 'ireland', 'belgium', 'japan'] print(places) print(sorted(places)) print(places) places.reverse() print(places) places.reverse() print(places) places.sort() print(places) places.sort(reverse=True) print(places)
2162056917d4013954895beae53a693d89f696d2
Lava97/Project-Euler
/Euler's Project(Problem 16).py
194
3.75
4
number = 2**1000 onumber = number sum_of_digits = 0 for i in str(onumber): remainder = number %10 sum_of_digits = sum_of_digits + remainder number = number //10 print(sum_of_digits)
402f10a959bdecaa7fe4cf5a00668690aa716067
howardsukuan/practice
/sport_classification/intent/Loki_badminton.py
26,325
3.734375
4
#!/usr/bin/env python3 # -*- coding:utf-8 -*- """ Loki module for badminton Input: inputSTR str, utterance str, args str[], resultDICT dict Output: resultDICT dict """ DEBUG_badminton = True userDefinedDICT = {"全國賽": [""]} # 將符合句型的參數列表印出。這...
d560d10e5358352b1b99755f08c5ca21bf28b21d
JuanRojasC/Python-Mision-TIC-2021
/Control Flow Statements/Ejercicio 21 - Aumento Sueldo.py
181
3.71875
4
sueldo = float(input('Ingrese el monto de su salario: ')) if sueldo >= 1000000 : sueldo = sueldo * 1.12 if sueldo < 1000000 : sueldo = sueldo * 1.15 print(round(sueldo))
b273045479313ebb2a4d0992f16d04799856d9c0
Prat9501/Data_Structure
/leetcode/234-Palindrome_Linked_List.py
930
3.8125
4
# Example 1: # # Input: 1->2 # Output: false # Example 2: # # Input: 1->2->2->1 # Output: true # Definition for singly-linked list. # class ListNode: # def __init__(self, val=0, next=None): # self.val = val # self.next = next class Solution: def isPalindrome(self, head: ListNode) -> bool: ...
a462a302f381150eaf86a6981e9000862ab2cbc6
grivis/MNik
/Test6.py
629
4.46875
4
## Кто твой отец? Версия 2 dict = {"Антон":{"Father":"Павел","Grandfather":"Иван"},"Михаил":{"Father":"Сергей","Grandfather":"Семён"},\ "Александр":{"Father":"Анатолий","Grandfather":"Николай"}} name = input("name: ") #print(dict[name]) if name in dict: print(dict[name]["Father"]) print(dict[name]["Gran...
e0ccda2a72723ac4746f68911eb456109de759c4
vml-msmith/omp
/omush/commands/communicationcommands/commandsay.py
1,208
3.515625
4
"""Defines commands that can be used from the login screen. """ from ..command import Command import re class CommandSay(Command): """ """ from ...actions.actionlogin import ActionSay command = "say" action = ActionSay @classmethod def _get_matchers(cls): """Return an array of re...
efd67455fd3745d8f368f333205d459f82eb110f
bagreve/Nivelacion
/29082019/004225.py
405
3.671875
4
import numpy as np a = np.arange(25) a = a.reshape(5,5) print a red = a[:,1::2] print red,"\n" yellow = a[4,:] print yellow,"\n" blue = a[1::2,:-2:2] print blue,"\n" # En este caso hay que tener cuidado, porque si le hago un cambio a red red[-1,-1] = 0 # le hago un cambio a "a", siguen ligados, si quiero camb...
2b88dd9d998aa75a8c8fa083efd73373a86e8a94
Deviloxide/Introduction-to-Machine-Learning
/1.4 Data Modeling with Scikit-Learn/7.1 Scikit-Learn Training and Testing.py
3,612
3.90625
4
import numpy as np from sklearn.model_selection import train_test_split data = np.array([ [10.2 , 0.5 ], [ 8.7 , 0.9 ], [ 9.3 , 0.8 ], [10.1 , 0.4 ], [ 9.5 , 0.77], [ 9.1 , 0.68], [ 7.7 , 0.9 ], [ 8.3 , 0.8 ]]) labels = np.array([1.4, 1.2, 1.6, 1.5, 1.6, 1.3, 1.1, 1.2]) # Tra...
174a87193a9d24a725b0beadfbb07341b71d521a
jazywica/Computing
/_06_Algorithmic_Thinking_2/alg_cluster.py
4,971
3.828125
4
""" Cluster class for Module 3 """ import math class Cluster: """ Class for creating and merging clusters of counties """ def __init__(self, fips_codes, horiz_pos, vert_pos, population, risk): """ Create a cluster based the models a set of counties' data """ self._fips_codes = fips_cod...
190cfe0eedd6f685e434e62147ffc6f7b78c48c9
MilkyLatte/PythonPractice
/Week1/2IfandMod.py
418
4
4
num = int(input("Give me a number")) if (num % 4) == 0: print("You gave me an even number divisible by 4") elif (num % 2) == 0: print ("You gave me an even number") else: print("You gave me an odd number") (num, check) = int(input("num?")), int(input("check")) if (num % check) == 0: div = str(int(num/c...
06955ce4737c958f3aca927149a12428dcd79585
SalmonTheWise/python-course
/homeworks/homework-3/t0.py
4,415
3.53125
4
def invert_my_dict(dict): inv_dict = {} for key in dict: val = dict[key] if val not in inv_dict: inv_dict[val] = [key] else: inv_dict[val].append(key) return inv_dict class Song: def __init__(self, artist, name, album, position, year, duration): s...
45934508d570c772f78cf8780a2d30384b79b213
crittelmeyer/ProjectEuler
/Python/problem22.py
913
3.578125
4
import sys def main(): # parse file into array names = sys.stdin.read() namesArray = names.replace("\"", "").replace("\n", "").split(",") # init total score to 0 currTotalScore = 0 # sort names alphabetically namesArray.sort() for i in range(0, len(namesArray)): currAlphaValue = getAlphabeticalValue(name...
f001e969e08444d12d69c3a7be96e47d602aee74
jaychsu/algorithm
/lintcode/605_sequence_reconstruction.py
1,355
3.515625
4
""" Main Concept: Topological Sort 1. record `edges` and `indegrees` from `seqs`, and only allow `num` in `org` 2. iterate `org` in order, check if there is only one path to get `org[-1]` """ class Solution: def sequenceReconstruction(self, org, seqs): """ :type org: list[int] :type seqs:...
0588782d7dbba45e4ae966ebe4ff946a1e7f48b0
PreranaPandit/PythonLab_29A_29B
/LabOne/five.py
1,664
4.25
4
''' 5. A school decided to replace the desks in three classrooms. Each desk sits two students. Given the number of students in each class, print the smallest possible number of desks that can be purchased. The program should read three integers: the number of students in each of the three classes, a, b and c respective...
1da92285356db6c01ffab310fc2e959358aa4ebd
minhphuong1804/truongminhphuong-fundamentals-c4e25
/Session3/homework/conrua1.py
396
3.890625
4
from turtle import * shape("turtle") speed = 0 pencolor("red") for i in range (3): forward(100) left(120) pencolor("blue") for i in range(4): forward(100) left(90) pencolor("brown") for i in range(5): forward(100) left(72) pencolor("yellow") for i in range(6): forward(100) left(60) penco...
99dff02cabb3c75df7adcd1acf0189ac69631abf
Wang-Jifan/159251
/Simplecalculator.py
742
4.1875
4
# define functions def add(x, y): return x + y def subtract(x, y): return x - y def multiply(x, y): return x * y def divide(x, y): return x / y # take input from the user print("Choose an operation:") print("1.(+)") print("2.(-)") print("3.(*)") print("4.(/)") choice = input("Enter ...
1eeeace46d9ded696276b44998a667ac9a4d7617
katoluo/Python_Crash_Course
/chapter_08/8-12.py
751
3.546875
4
#!/usr/bin/env python3 # encoding: utf-8 # coding style: pep8 # ==================================================== # Copyright (C) 2021 All rights reserved # # Author : kato # Email : 1123629751@qq.com # File Name : 8-12.py # Last Modified : 2021-01-07 00:50 # Describe : # # ====...
fbe912a8caa7b92b78ed832267e4866d26f94ca5
danalrds/FP
/Salvat/tema/operations/Controller.py
14,942
3.6875
4
class StudentController: """ Controller class for students """ def __init__(self, repo,repod,repog): """ calls the repository and initialize the entities """ self.__repo = repo self.__repod = repod self.__repog = repog self.__undo = [] def add...
ccd8d0b2459d04c8471432cc08327ec0a7fd2732
nataliasantis/PythonFiles
/FizzBuzz.py
239
4.03125
4
#FizzBuzz for number in range(1, 100): if ((number%3)== 0) and ((number%5)==0): print("FizzBuzz") elif ((number%3)== 0): print("Fizz") elif ((number%5)==0): print("Buzz") else: print(number)
38b96f7223b8e330ee098b4048d045bf8c87adbe
biao111/learn_python
/range/sample2.py
110
3.609375
4
#利用range遍历其他序列 c = "abcdefg" for i in range(0,len(c)): letter = c[i] print(letter)
7aab2847dea25fa1f873d83ff03faa89d6ac2a11
caiomilanic/DNA-Test
/dna.py
2,082
4.1875
4
from sys import argv, exit import csv import re # Get arguments or print usage if len(argv) != 3: print("Usage: python dna.py data.csv sequence.txt") exit(1) # Open csv and txt sequence and read contents into memory else: with open(f"{argv[1]}", newline='') as csvfile: database = csv.reader(csvf...
ee7e0fcb917912e3b4c053c25a6278aa1045960a
Ambareeshvs/machine-learning
/Regression/my_decision_tree.py
712
3.765625
4
# IMPORTS import numpy as np import matplotlib.pyplot as plt import pandas as pd # INCLUDING THE DATASETS dataset=pd.read_csv('Position_Salaries.csv') X = dataset.iloc[:,1:-1].values y = dataset.iloc[:,:-1].values # TRAINING THE DATASETS from sklearn.tree import DecisionTreeRegressor regressor = DecisionTreeRegressor...
d880e4e8663d29d723457c90a32ec395a3d55457
Dmitry-Igoshin/SkillFactory
/Unit_0/r_and_ph_2.py
662
3.515625
4
heads = 35 # количество голов legs = 94 # количество ног for r in range(heads + 1): # количество кроликов ph = heads - r legs_curent = r * 4 + ph * 2 print(f'Количество кроликов {r}, Количество фазанов {ph}, Количество ног {legs_curent} ') # если суммарное количество ног равно заданному, то выводим...
0fc365dc54c7ac552d79cff418a885384f32eb31
VladCincean/homework
/Computational Logic/UI/console.py
8,914
3.65625
4
''' Created on 30 nov. 2015 @author: Vlad Cincean ''' from utils.utils import check_representation from domain.operations import add, sub, mul, div from domain.conversions import substitution_method, successive_divisions_method from domain.rapid_conversions import rapid_convert def main_menu(): do_exit = False ...
e313be47353bf44f2087cd78ff0b6a883cb6cac6
AnkitMitraOfficial/python_learning
/Python_Section3 - Basic/tuples.py
1,126
4.34375
4
# Tuple items are ordered, unchangeable, and allow duplicate values. my_tuple = (1,2,3,4,5) print(my_tuple[1]) #Check for items in tuple my_tuple = (1,2,3,4,5,2) print(4 in my_tuple) # Python has two built-in methods that you can use on tuples. # 1. count() --> Returns the number of times a specified value occurs in...
6f15043d642307c8a158a68084cba39ff4c5e3b7
eschwabe/interview-practice
/leetcode/group_anagrams.py
523
3.78125
4
# Leetcode 49 - Group Anagrams class Solution(object): def groupAnagrams(self, strs): """ :type strs: List[str] :rtype: List[List[str]] """ strs = sorted(strs) groups = {} for s in strs: key = ''.join(sorted(s)) if key in groups: ...
d55eb870368b09ca2ab56050e22e2f24cc659b26
homjan/Training-projects
/Geekbrains/phyton/домашняя работа 1/les_1_task_7.py
496
4.21875
4
#7. Определить, является ли год, который ввел пользователь, високосным или не високосным. #Вводим год e = int(input("Введите год: ")) if (e%400==0): print (f'{e} - Високосный год') elif(e%100==0): print (f'{e} - Не високосный год') elif(e%4==0): print(f'{e} - Високосный год') else: print(f'{...
f111b2eeb4330bd51da75b5bada14dca4e387a2c
cpra/dlvc2018
/assignments/reference/dlvc/ops.py
2,028
3.671875
4
import numpy as np from typing import List, Callable # All operations are functions that take and return numpy arrays # See https://docs.python.org/3/library/typing.html#typing.Callable for what this line means Op = Callable[[np.ndarray], np.ndarray] def chain(ops: List[Op]) -> Op: ''' Chain a list of opera...
a6185a8d92764f91cc8e07466a8958fa110b03ac
thinkerajay/PythonCode
/CoolProject/patternpackage/patternpackage.py
923
3.828125
4
''' Created on Jun 19, 2016 @author: Admin ''' class LunchMenu: def __init__(self): self.menuItems = list() def addItem(self,menuItem): self.menuItems.append(menuItem) def printMenu(self): for item in self.menuItems: print(item) class DinnerMenu: def __init__(self):...
59331e5d74627ee8423114b1e583ed2379745d32
shanksms/python-algo-problems
/string/WeighTheString.py
373
3.796875
4
def heavierString(s1, s2): sum1 = sum2 = 0 for c in s1: sum1 = sum1 + ord(c) for c in s2: sum2 = sum2 + ord(c) if sum1 > sum2: return s1 elif sum1 < sum2: return s2 else: return 'equal' if __name__ == '__main__': tc = int(input()) for c in range...
fd957c7d11f321fbbd65e2706df0974b2432a9e2
AlexBarnes86/Algorithms
/src/main/python/gfg/IDFS.py
1,005
3.546875
4
from Graph import Graph def idfs(v, fun, graph, max_depth, visited=None, cur_depth=0): if not visited: visited = set() if (cur_depth > max_depth) or (v in visited): return visited.add(v) fun(v) for adj in graph.adjacent(v): idfs(adj, fun, graph, max_depth, visited, cur_dep...
dc9f7324eca59ae32f1d95c869e051cd8b8b054e
icoding2016/study
/PY/free_exercise/battleship_game_report.py
5,232
3.875
4
# A battleship question # # Given list of battleship positions and hits, find how many ships have been sunk and how many ships have been hit, but not sunk # Sink criteria: >=3 hit # # The battleships are represented with 'X's, empty slots are represented with '.'s. # You may assume the following rules: # You recei...
533ebfe8783100e07ed7e5231d9c844c6f84d1f7
kamilnowak05/nauka
/Python podstawy/1_Zadania/Dzien_1/2_Funkcje/exercise_1.py
324
3.71875
4
# tutaj napisz funkcję z zadania 1 def square(x, y = 2): z = x ** y return z # poniższe linijki przetestują Twoją funkcję: print("2 podniesione do potęgi drugiej, to:", square(2)) # powinno być 4 print("16^2=", square(16)) # powinno być 256 print("256 do potęgi 2 =", square(256)) # powinno być 65536
3210e6189123ab651611e6cee7a783df2f009661
Tech-Helper504/Windows-Siri
/credit_score_calculator.py
2,563
3.875
4
class credit_scrore_calculator_and_saver(): age = input("What's your age?\n") gender = input("What's your gender?\n") payment_history = input("How many loans you have you paid\n") loans = input("How many loans do you have?\n") loans_paid = input("How many loans you have paid\n") credit_car...
cd42314b2c0e35059aadbb795066304ba5e6a0c1
Debasmita-01/Competitive-Programming
/Practice/Coding Blocks/Competitive Warriors Challenge 3.0/Inversion Count.py
1,055
3.625
4
def merge(data, start, mid, end): n1 = mid - start + 1 n2 = end - mid a = [0] * (n1) b = [0] * (n2) for i in xrange(n1): a[i] = data[start + i] for i in xrange(n2): b[i] = data[mid + 1 + i] i = 0 j = 0 k = start ans = 0 while i < n1 and j < n2: if a[i]...
65153c572ae92a9d2a6e5acd7f2dcaf83383ea76
Alraemon/electricMeterSpider
/getTemperature.py
1,026
3.71875
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Tue Jul 3 21:13:32 2018 Use Weather API to get temperature data of Shanghai in last one year And save it to temperature.data @author: erwin """ import requests import time import pickle dataset=[] raw_today=requests.get("http://v.juhe.cn/weather/index?c...
0e9a64f9f40ed5caa08702c9817efd5178f1fd18
kawnayeen/hackerrank-python
/src/_4_set/_9_subset.py
376
3.53125
4
# https://www.hackerrank.com/challenges/py-check-subset/problem if __name__ == '__main__': n = int(input()) for i in range(0, n): int(input()) set_a = set(map(int, input().split())) int(input()) set_b = set(map(int, input().split())) if set_a.issubset(set_b): ...
1fe0675192a2438deaf0dbc92c331f71c50180e1
tsaxena/Master_Thesis
/NetAdapt/utils/compute_table/wideresnet_tf.py
1,005
3.71875
4
"""functions used to create smaller models that are to be used in the tables in tensorflow""" from tensorflow.keras.layers import BatchNormalization, Conv2D, AveragePooling2D, Dense, Activation, Flatten from tensorflow.keras.models import Model def make_conv_model(inputs, out_channels, stride, kernel_size=3): """...
104e183a6e8e28697f307f2c5d25b073b9849beb
jstocks/trivia_maze
/cell.py
2,724
4.125
4
class Cell: """class holds the game board cell attributes and methods to change these attributes, including entrance, exit, and paths""" path_pairs = {"N": "S", "S": "N", "E": "W", "W": "E"} def __init__(self, x, y): self.__exit = False self.__entrance = False self.__current_cel...
597aa685c1c0e3aaf86c9971cc149bc55493d276
GaneshSparkz/OCR-Sudoku-Solver
/utils/sudoku.py
2,683
4.1875
4
class Sudoku: def __init__(self, board, n_rows, n_cols): self.board = board self.n_rows = n_rows self.n_cols = n_cols def find_empty(self): """Find an empty cell in the board""" for i in range(self.n_rows): for j in range(self.n_cols): ...
5185d24c51bf9b11d612535488eee4bcc6a4afd6
py-yyc/coverage-example
/ttt/board.py
2,595
4.15625
4
""" TicTacToe x goes first board is a list of 9 elements from ['x','o','.']. '.' means empty spot. """ class GameStates(object): """ Enumeration of the possible games states """ invalid = 0 unfinished = 1 x_wins = 2 o_wins = 3 draw = 4 def x_count(board): """ count how many ...
0015f53f602881e11ce01a6f6470bfa402a2765a
rafaelperazzo/programacao-web
/moodledata/vpl_data/117/usersdata/147/26827/submittedfiles/al2.py
80
3.921875
4
# -*- coding: utf-8 -*- n=float(input("digite um numero real:")) print('%.d' %n)
1a22e3559507cd80b976d491939100f8e90fe4b7
wglee0511/hh99-ch2
/app.py
143
3.8125
4
input = [3, 5, 6, 1, 2, 4] def find_max_num(array): array[2] = array[2] + 2 return array result = find_max_num(input) print(result)
d20a3504a453c8db584d08396766dfe8d3b7e681
jnash67/eulerpython
/eulerutils/pandigital.py
1,388
3.609375
4
import eulerutils as eu def is_nine_digit_pandigital(numList): allstr = "" for a in numList: allstr = allstr + str(a) resultSet = set() found = True for char in allstr: if char in resultSet: found = False else: resultSet.add(char) if found: ...
647848dab1efe73f2e4d674147df5d2b8cee9d1c
kylapurcell/A01088856_1510_assignments
/A1/time_calculator.py
998
4.375
4
# Kyla Purcell # A01088856 # February 3rd 2019 # A program that converts time in seconds to various different units def time_calculator(seconds): """ Convert seconds to days, hours, and minutes PARAM: seconds, a positive integer PRE-CONDITION: seconds must be a positive integer POST-CONDITION:...
2382dde516fbd657de6fdecc9869324a60a69959
dchen3121/algo
/Leetcode/41_first_missing_positive.py
1,177
3.546875
4
# QUESTION: # Given an unsorted integer array nums, find the smallest missing positive integer. # You must implement an algorithm that runs in O(n) time and uses constant extra space. from typing import List class Solution: def firstMissingPositive(self, nums: List[int]) -> int: for i, num in enumerate(nu...
f8ebb336e50cfd8eb34f68db68ca8b89bf4b7a3b
Boasbabs/contact_manager
/mest.py
1,630
3.75
4
# this is to model MEST class Person: def __init__(self, name, nationality): self.name = name self.nationality = nationality class Eit(Person): def __init__(self, name, nationality, fun_fact): super().__init__(name, nationality) self.fun_fact = fun_fact def recite_fun_...
69ddb57cbe37a1163512479af25d2d3ee2d4c4f4
henrylu518/LeetCode
/Add Two Number.py
1,933
3.8125
4
""" Author: Henry, henrylu518@gmail.com Date: May 8, 2015 Problem: Add Two Numbers Difficulty: easy Source: http://www.leetcode.com/onlinejudge Notes: You are given two linked lists representing two non-negative numbers. The digits are stored in reverse order and each of their nodes contain a ...
21d9391eceac401933e000d66939fc9152fef602
lancelote/stepik_algorithms_1
/src/module_2/big_fibonacci.py
365
3.71875
4
def fib_mod(n: int, m: int) -> int: modules = [0, 1] i = 2 while not (modules[i - 2] == 0 and modules[i - 1] == 1) or i <= 2: modules.append((modules[i - 2] + modules[i - 1]) % m) i += 1 return modules[n % (i - 2)] def main(): n, m = map(int, input().split()) print(fib_mod(n,...
89f6aa9178284d5dca985e93533173e2278fe23c
dougBelcher/Scripts
/ATBS/1 - Hello Name.py
411
4.09375
4
# Their This program says Hello and asks for my name print(f'Hello, world') # print(f'What is your name?') # ask for their name myName = input('What is your name? ') print(f'It is good to meet you, {myName}') print(f'The length of your name is: {len(myName)}') # print(f'What is your age?:') # ask for their ag...
d8d0a41244d974bc4b34332e642f8dc85f179cab
FleeaniCh/python
/first_step/ood/oo_game.py
1,109
4.03125
4
""" 体会:类区别行为的不同 """ class Player: def __init__(self, atk, hp): self.atk = atk self.hp = hp def attack(self, other): # 打的逻辑 print("玩家攻击敌人") # 通过敌人对象地址,调用实例方法 other.damage(self.atk) def damage(self, value): print("玩家受伤") self.hp -= value ...
15af8fb493ffe2379a582cbbc65cfe8a403c938c
sensoumya/myPython
/Algos/Extras/Prime Numbers.py
1,048
3.78125
4
#Eratosthenes method def f(n): if n<2: return 0 isPrime = [0,0]+[1]*(n-2) for i in range(2, math.ceil(math.sqrt(n))): if isPrime[i]: for j in range(i*i, n, i): isPrime[j] = 0 return sum(isPrime) # nth prime number def nth_prime_no(n): if n == 1: ...
4562d3f33efe1c5c388accc18fc70e063268958c
fidelis111/fidelis1
/aluguel carro.py
264
3.515625
4
km = float(input('Digite a quilometragem percorrida: ')) tempo = int(input('Digite por quantos dias o carro foi utilizado: ')) vtempo = tempo * 60 vkm = km * 0.15 vt = vtempo + vkm print('Com base nos dados acima, o valor do aluguel é: R$ {:.2f}'.format(vt))
17a1e87f237b9c4961a841d4941baf97dead6910
YodaFace/Python-Lists-Loops-Programming
/exercises/13.1-Filter_and_list/app.py
1,206
4.03125
4
all_names = ["Romario","Boby","Roosevelt","Emiliy", "Michael", "Greta", "Patricia", "Danzalee"] #Your code go here: # def only_rs(names): # names_with_rs = [] # if "R" in names: # #if "R" in names and "None" not in names: # return names # # return names if "R" in names # # only_rs() # res...
7a495fb8a748c5bbd307d258702cb7d7e143d3f4
yukakumumu/python001
/06_if.py
330
3.703125
4
x=100 if x<50: y= "val001" elif x<120: y = "val002" elif (x>=120) and (x<500): y = "val003" elif 600<x<700: y = "val004" elif x<800: y = "val005" else: y = "val006" print(y) x = "" if not x: y = True else: y = False print(y) x = 10 y = 100 if x<20 else 200 #3項演算子のかわり print(y)
0a63be8ffd91c582c3c0fa3d8785cb2d043befe0
BrennoBernardoDeAraujo/ALGORITMOS-2019.2
/A1.Q10.py
335
3.546875
4
CS = float (input)("Comprimento da sala: ") LS = float (input("Largura da sala: ")) CC = float (input("Comprimento da carteira: ")) LC = float (input("Largura da carteira: ")) QCC = float (CS - 1.3)//(CC + 0.2) QCL = float (LS - 0.5)//(LC + 0.5) totalC = float QCC * QCL print ("Cabem na sala de aula ",totalC...
c6dd9f800be2af7735ce9769963654a8449a0813
t-dawei/offer-code
/python-code/34.二叉树中和为某一值的路径.py
1,081
3.515625
4
#!/usr/bin/python # -*- coding: utf-8 -*- # @author: T ''' 题:输入一颗二叉树和一个整数,打印出二叉树中结点值的和为输入整数的所有路径。 路径定义为从树的根结点开始往下一直到叶结点所经过的结点形成一条路径。 ''' class TreeNode: def __init__(self, val): self.val = val self.left = None self.right = None class Solution: def findPath(root, experctedSum): ...
02e1090ae91602f09fff92691c79cc5ceba5b70b
artcheng/TeachKidsCoding
/lab/misc/misc.py
372
3.75
4
import time start = time.time() n=100000000 total=0 for i in range (1,n+1): total=total+i end = time.time() print "the total of 1+2+3+4+5...+",n,"equals", total, 'loop uses', end - start, 'seconds' print "---------" start = time.time() total = n*(n+1)/2 end = time.time() print "the total of 1+2+3+4+5...+",n,"equ...
ee5878683eeec854ca23d3451a7c276e30d4235c
benman1/dython
/dython/model_utils.py
7,045
3.53125
4
import numpy as np import matplotlib.pyplot as plt from scipy import interp from sklearn.metrics import roc_curve, auc from dython._private import convert def _display_plot(): plt.plot([0, 1], [0, 1], color='grey', lw=1, linestyle='--') plt.xlim([0.0, 1.0]) plt.ylim([0.0, 1.02]) plt.xlabel('False Posi...
ed58c11c4eb53505d47bfb29cfed35390890d571
Ivy-Walobwa/PythonGames
/RockPaperScissors.py
1,040
4.125
4
import random def rock_paper_scissors_game(): weapons = ['r', 'p', 's'] random_number = random.randint(0, 2) comp_weapon = weapons[random_number] user_weapon = input('Rock(r), Paper(p) or Scissors(s)? ').lower() print(f'You picked {user_weapon}') print(f'Computer picks {comp_weapon}') if ...
ec94eacd878113ffafcd52a9939645007924a9bd
JuanDiazUPB/LogicaProgramacionUPB
/Taller algoritmos/Ejercicio 36.py
200
3.890625
4
n = str(input('Introduzca un número menor a 100.000: ')) if len(n) >= 6: print('El número es mayor o igual a 100.000...') else: print(f'El número introducido tiene {len(n)} dígitos')
e3b527ef18d1431f09797f697363e60d21a9cc31
Soluspero/coding_practice
/techgig_solutions/python_practice/strings/string_join.py
331
3.765625
4
''' Read input from STDIN. Print your output to STDOUT ''' #Use input() to read input from STDIN and use print to write your output to STDOUT import sys def main(): # Write code here c= input() sl=[] try: while True: d = input() sl.append(d) except: pass sys.stdout.write(c.join(sl)...
342532300e2e44c09730bc663c23c8a5e78fa336
vauchok/python_course
/05/task.py
4,178
3.71875
4
"""Script to get PR(Pull Request) statistics from GitHub""" import datetime import requests github_api_name = input("Input Github_login: ") github_api_password = input("Input Github_password: ") def help_f(): """Display program manual""" print("""Usage: pr-stats [options] <user> [<repo>] pr-stats --ver...
bcc4803b7ce47b708bf17193749ae9ea3d5a46a5
MeghanaDeshmukh/Python-program
/shortestDist.py
1,045
3.734375
4
def checkExistence(low,high,array): diff = abs(high - low); if diff > len(array): for index in range (0, len(array)): if array[index] < high and array[index] > low: return False; else: for index in range(low+1, high): if index in array: return False; return True; def solution(): #A=...
e35843c93faad94f6ced015be37f76d21a94884e
riyan-eng/Praxis_Academy
/Materi Pertemuan/01-01/4.3. The range Function.py
310
3.9375
4
for i in range(5): print (i) for i in range(5, 10): print (i) for i in range(1, 10, 3): print (i) for i in range(-10, -100, -30): print (i) a = ['Mary', 'had', 'a', 'little', 'lamb'] for i in range(len(a)): print (i, a[i]) print (range(10)) print (sum(range(4))) print (list(range(4)))
d99aec5e63b1da57c8b1c6e508d7b9c618402985
Atrolantra/reddit-dailyprogrammer-problems
/237 [Easy] Broken Keyboard/broken_keyboard.py
502
3.78125
4
# https://www.reddit.com/r/dailyprogrammer/comments/3pcb3i/20151019_challenge_237_easy_broken_keyboard/ dictWordList = open('enable1.txt').read().splitlines() inputs = ["edcf", "bnik", "poil", "vybu"] def check(keyString): longest = max(len(entry) for entry in dictWordList if (set(entry).issubset(set(keyString))...
497ecb815b4b90adc24209f400c66ee1e109c6cd
bhanurangani/code-days-ml-code100
/code/day-2/5.Getting Input From User/Input.py
130
4.09375
4
#just a 2 line code to understand how input function works to get the input age=input("enter your age") print("your age is",age)
1a86943da5ba963499377c318acec334b5b9034c
OliverSekiro/python_log
/matplotlib/line2.py
232
3.71875
4
import matplotlib.pyplot as plt #To plot x versus y,u can write plt.plot([1,2,3,4],[1,4,9,16],'ro') # 'ro' indicates red pie #indicate x ranges 0 to 6 and y ranges 0 to 20 #axis[xmin,xmax,ymin,ymax] plt.axis([0,6,0,20]) plt.show()
c089b2ec13e35e95e802978a767177f97130d80a
privateHmmmm/leetcode
/680-valid-palindrome-ii/valid-palindrome-ii.py
831
4.21875
4
# -*- coding:utf-8 -*- # # Given a non-empty string s, you may delete at most one character. Judge whether you can make it a palindrome. # # # Example 1: # # Input: "aba" # Output: True # # # # Example 2: # # Input: "abca" # Output: True # Explanation: You could delete the character 'c'. # # # # Note: # # T...
120b7512d94567b8b8638785b2ea71fd38429631
jkwaters/EulerProject
/Python/018.py
612
3.53125
4
# Project Euler | Problem 18 | Jacob Waters # By starting at the top of the triangle below and moving to adjacent numbers # on the row below find the maximum total from top to bottom of the triangle. # 1074 # date : 2015.07.20 def maxPathSum(data): triangle = [[int(num) for num in line.split(' ')] for lin...
cb22fec45179dc300d0b20787c190610ae27fc8f
alexisjcarr/cs-module-project-iterative-sorting
/src/searching/searching.py
867
4.09375
4
def linear_search(arr, target): for idx, num in enumerate(arr): if num == target: return idx return -1 # Write an iterative implementation of Binary Search def binary_search(arr, target): start = 0 end = (len(arr) - 1) found = -1 while end >= start and found == -1: ...
aa563964eed670f7e079d220f32d036164bb420e
DmitryAPetrov/python
/DZ1.py
1,372
3.984375
4
##----------------------Задание №1---------------------- # nameUser = input("Введите свое имя: ") # surnameUser =input("Введите свою фамилию: ") # print(f"Добрый день {nameUser} {surnameUser}") ##----------------------Задание №2---------------------- # second = int(input("Введите длительность времени в секундах: ...
d4156dc9103e47a96c8e663e445cde77dd4ecb19
DeathShadow171/PythonLesson
/Operator Precendence.py
157
3.515625
4
a=2 b=3 c=4 d=5 print(b**2 -c) print(b**2 -c *d) print(a + b**2 -c *d) print(a**2 *b -c +d) print(a + b**2 *c -d) print(a - b**2 +c *d) print(a* +b -c**2 -d)
72a73c0e19507706729b79e42563a3b6fb8f61fc
cpeixin/leetcode-bbbbrent
/company/bytedance/trapping-rain-water.py
1,686
4.1875
4
# coding: utf-8 # Author:Brent # Date :2020/8/31 11:03 PM # Tool :PyCharm # Describe :给定 n 个非负整数表示每个宽度为 1 的柱子的高度图,计算按此排列的柱子,下雨之后能接多少雨水。 # # # # 上面是由数组 [0,1,0,2,1,0,1,3,2,1,2,1] 表示的高度图,在这种情况下,可以接 6 个单位的雨水(蓝色部分表示雨水)。 感谢 Marcos 贡献此图。 # # 示例: # # 输入: [0,1,0,2,1,0,1,3,2,1,2,1] # 输出: 6 # # 来源:力扣(LeetCode) # 链接:https://leetco...
2753d977b6c3691a0bc2842e283b5d0f4b9206fb
andrewghaddad/OOP
/OOP/Notes/Week4/number_guessing_game.py
640
4.125
4
""" Pick a secret number between 1 and 10 (hard code to be 7) Input: ask the user to enter a number between 1 and 10 Processing: if the user is correct: print congratulations if the user's guess is too low: print appropriate message if the user's guess is too high: print appropri...
228793766f39a2adac61a5019b4c2e817225e8be
OkayJosh/pythonSololearn
/functional programming/quest5.py
536
4.40625
4
## The function map takes a function and an iterable as arguments, and returns a new iterable # with the function applied to each argument def add_five(x): return x + 5 nums = [11,22,33,44,55] results = list(map(add_five,nums)) ## to convert the result into a list we use the list explicitly print(results) #### y...
aa52f07bf7a1d92f4d353e3acb063b074fc18240
nguyenmanhtrung/trungza1
/nguyenmanhtrung_44617_cp5/nguyenmanhtrung_44617_cp5/Exercises/page_149_exercise_02.py
481
3.75
4
""" Author:Nguyễn Mạnh Trung Date: 11/10/2021 Problem: Define a function named even. This function expects a number as an argument and returns True if the number is divisible by 2, or it returns False otherwise. (Hint: A number is evenly divisible by 2 if the remainder is 0.) Solution: Pass th...
f5b190e371eb59f3dccce5145d980443d3e8bd0d
andreaton/kids-code
/Silvia/1-100.txt.py
850
3.8125
4
mylist=list(range(1,101)) oddlist=list() evenlist=list() fivelist=list() sevenlist=list() threelist=list() randomvariable="hello everybody" for number in mylist: #print ("This is count " + str(number)) if (number % 2 == 0): evenlist.append(number) if (number % 5 == 0): fivelist.append(num...
5ea00187af3e5f1e6ea019462ece361ff3abbd5f
Z-Gomes/python_bootcamp
/python_bootcamp/chapter_4/Work_with_parts_of_lists.py
1,250
4.5625
5
# to slice a list, indicate the first and last index of the items in the list you want to work with players = ['charles', 'chris', 'steven', 'jj', 'josh', 'zach'] print(players[0:3]) # without a starting item in the index, python starts with the first item in the list print(players[:5]) # omitting the ending...
4ab2ba2bdc06210c57ce5bce606bc4c7701bdddd
wilbertgeng/LeetCode_exercise
/694.py
876
3.53125
4
"""694. Number of Distinct Islands""" class Solution(object): def numDistinctIslands(self, grid): """ :type grid: List[List[int]] :rtype: int """ ####### Use string to record shape of island and store in hashset m = len(grid) n = len(grid[0]) def dfs(...
de2acd6dc58dcab097ac7f8b4a3452036f8fad8f
zhaoxinlu/leetcode-algorithms
/lintcode/02IntArray/050ProductExcludeItself.py
1,021
3.953125
4
# -*- coding: utf-8 -*- """ Editor: Zhao Xinlu School: BUPT Date: 2018-03-02 算法思想: 数组剔除元素后的乘积 """ class Solution: """ @param: nums: Given an integers array A @return: A long long array B and B[i]= A[0] * ... * A[i-1] * A[i+1] * ... * A[n-1] """ def productExcludeItself(self, nums): # write y...
534be6b5bde3376ec726ae50fb8f9b0af6adae82
amirtha4501/Guvi
/algorithms/algorithm10.py
75
3.640625
4
s = str(input()) st = s[::-1] if s==st: print('yes') else: print('no')
3d1664e8961e30859a2301e51cf5c8a106553bf3
Ting0718/Leetcode
/Breath_First_Search/200_number_of_islands_bfs.py
906
3.515625
4
'''bfs solution''' class Solution: def numIslands(self, grid: List[List[str]]) -> int: visited = set() rows, cols = len(grid), len(grid[0]) islands = 0 def bfs(r, c): queue = [(r, c)] visited.add((r,c)) while queue: r, c = queue.po...
61e15d31e6e3ed5d3359499c35e68e9e463c202e
GledsonLScruz/Learning-Python
/ex002.py
502
3.78125
4
import random #n1 = int(input("Digite um numero:")) #n2 = int(input("Digite outro Numero")) #n3 = int(input("Digite outro Numero")) #lista [n1, n2, n3] #print("O maior valor foi: {}".format(random.radiant(>))) a1 = str(input("Digite o nome do aluno:")) a2 = str(input("Digite outro nome do aluno:")) a3 = str(input(...
387ecfe0c0f1ef9b8fa3e91d2a04677c75906914
gan-gan777/Python_Crash_Course
/09/9-5_login_attempts.py
1,377
3.90625
4
# -*- coding:UTF-8 -*- class User(): """模拟描述用户基本信息""" def __init__(self, first, last, age, sex): """初始化用户基本信息""" self.first_name = first self.last_name = last self.age = age self.sex = sex self.login_attempts = 0 def describe_user(self): """描述用户的基本信息""" full_name = self.first_name + self.last_na...
6c1ca71be6f7c1564abcb6c9666c57e83755b6ba
kittytian/learningfishcpy3
/36example.py
1,067
4.125
4
''' 36例子 对象 = 属性 + 方法 代码定义了对象的特征(属性)和行为(方法),但还不是一个完整的对象,将定义的这些称为类(Class)。 需要使用类来创建一个真正的对象,这个对象就叫作这个类的一个实例(Instance)也叫实例对象(Instance Objects) 类名约定大写字母开头 创建一个对象,也叫类的实例化: #先运行程序 tt = Turtle() 创建一个实例对象 ''' class Turtle: # Python 中的类名约定以大写字母开头 """关于类的一个简单例子""" # 属性(变量 静态特征) color = 'green' weight = 10 ...
47e8c4787d2f6333f3e87e6ebc8aca127d762821
henriquekirchheck/Curso-em-Video-Python
/aula/aula007.py
786
3.890625
4
from time import sleep print("Aula N°7 \n") sleep(2) ''' Começo do Codigo ''' ''' Formatação da linha ''' ''' nome = input('Qual é seu nome?: ') print('Prazer em te conhecer {:20}!' .format(nome)) print('Prazer em te conhecer {:>20}!' .format(nome)) print('Prazer em te conhecer {:<20}!' .format(nome)) print('Prazer...
d0c619f0826fdb65f5ce02cedfcf30924d87749c
stoptrollingmymind/UniversityTasks
/Python_Learning/integral.py
2,558
4.5625
5
steps = 1000000 def rectangle_method(start: float, end: float, case, f): """ Calculates the integral sum by dividing it into rectangles equal in x and summing it up, taking the left vertical side of the rectangle with height f(x) as the value of the function Parameters: ...
6c9439bf3a33eec34b5bf1a36f79834d75c50244
RNTejas/CodewithMosh-Python
/CodeWithMosh Python/Data_Structures/Lists/adding_and_removing_items.py
965
4.5
4
# ADDING # you can add or remove items in lists because they're mutable sequence types # if you want to add a utem at the end of the list you can use .append method letters = ["a", "b", "c"] letters.append("d") print(letters) # if you want to add a item at the specific position you should use the .insert method l...
ef3cf2389c6f288218ad9e36cccf06587eb10eda
ryotokuro/hackerrank
/algorithms/appendAndDelete.py
3,167
4.09375
4
# PROBLEM # Given a string of lowercase English alphabetic letters. # You can perform two types of operations on the string: # 1. Append a lowercase English alphabetic letter to the end of the string. # 2. Delete the last character in the string. # **Performing this operation on an empty string results in an empt...
ae054cd2d0989999398cfa43d2b06549b4afa76c
TimothyDJones/project-euler-python
/project_euler_2.py
692
3.875
4
# Project Euler Problem #2 # Even Fibonacci numbers # Problem 2 # Each new term in the Fibonacci sequence is generated by adding the previous two terms. By starting with 1 and 2, the first 10 terms will be: # 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ... # By considering the terms in the Fibonacci sequence whose values do not...
c0defa3bb54b606cd646f7c1f19ac820c1e3c8b0
LianaKhazaliya/BSU
/Algo/Sorts/merge_sort.py
1,065
3.546875
4
#! usr/bin/env python2.7 # coding: utf-8 from random import randint, sample #def order(lst): # if lst[0].isalpha() == True: # def __lt__(self, other): # return chr(min(ord(self), ord(other))) def merge_sort(lst): if len(lst) < 2: return lst mid = len(lst)/ 2 return merge(merge_sort(l...
2c000f0548c196bd9fbc141dd1fc18d984115f88
Transi-ent/LeetcodeSolver
/47.py
1,435
3.53125
4
""" Solution1:在题解46的基础上,将求得的结果去重,或者在添加的时候就不去添加; Solution2:在进行函数的参数传递时,可以使用数值变量和字符串变量,而非列表, 其可以放入集合之内,达到去重的目的 """ class Solution: def permuteUnique(self, nums: list) -> list: if nums == []: return [] if len(nums) == 1: return [nums] res = [] alrea...
7dece8dba9f631cf6413a0f64b572370983cb847
Maxim-nwb/Clicker
/Clicker.py
993
3.578125
4
import GUI import keyboard import mouse # variables for storing the number of actions cliks = 0 keystrokes = 0 # function for saving an action def set_action(action, stat): stat.statistic[action] = stat.statistic.get(action, 0) + 1 # function for counting actions def pressed(action, window): # checking the ty...
8ed62ff3b665c95bb10e703f7eabe0b0535a41b8
13424010187/python
/源码/【15】秘密星轨-课程资料/15.py
2,748
4.125
4
'''''' ''' 绘制指定半径的圆弧:t.circle(半径,弧度) 弧度:不写,默认是360度 半径:正:正左侧(半径为正圆心在左侧) 负:负右侧(半径为负圆心在右侧) 弧度:正:向海龟方向前进 负:向海龟方向后退(海龟方向不变) 设置填充颜色:t.fillcolor(颜色的字符串) red blue white cyan 开始填充:t.begin_fill() 必须与t.end_fill()搭配使用 结束填充t.end_fill() 必须与t.begin_fill()搭配使用 填充三剑客:t.begin_fill()与t.end_fill()搭配使用 填充区域:起点和终点连线后所围成的封...
98eb098911d22541a46469299287dace89f660f8
KingoCengo/BA4318--Homework
/HW 3 PHYTON.py
240
3.984375
4
age = 24 if age < 1: print ('Anıl is an infant.') elif age >= 0 and age < 10: print ('Anıl is a child.') elif age >= 10 and age < 19: print ('Anıl is a child and an adolescent.') else: print ('Anıl is an adult.')
d4afb8541d2a0b30ee30870d22f4979d7f803425
marialobillo/dataquest
/python_basics/python6/04_multiple_returns.py
229
3.75
4
wonder_woman = ['Wonder Woman','Patty Jenkins','Color',141,'Gal Gadot','English','USA',2017] def is_usa(movie): if movie[6].lower() == 'usa': return True else: return False wonder_woman_usa = is_usa(wonder_woman)
93e3c08ac07e1e38159436f2ee87e2a834b2e4a7
b-camacho/PROM
/Software/bugMultiDetectFast.py
846
3.625
4
''' Author: pw897 This module has a detect function that takes in an image and returns coordinates of rectangles that contain a bug. ''' import os from PIL import Image import numpy as np #Returns the square distance def distS3(x1,y1,z1,x2,y2,z2): return (x2-x1)**2 + (y2-y1)**2 + (z2-z1)**2 def detect(im,poss): m...
00847a6571125950d326ca1cb0ec82acf0b9e542
MalachiStoll/MIS3640
/mypolygon.py
778
3.65625
4
import turtle alex = turtle.Turtle() #print(alex) for i in range(4): alex.fd(100) alex.lt(90) #square(alex, 250) def square(t, length): for i in range(4): t.fd(length) t.lt(90) #square(alex, 50) def polygon(t, length, n): for i in range(n): t.fd(length) t.lt(360/n...