blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
e58eae9f3603be7750ae6d25bd5d48dcd1510c3f
bulongo/Scraper
/deleter.py
1,218
4.1875
4
#This script is written to delete items from a file that are too #random and that would take a lot of time to select one at a time #so it will be fed a list and a target directory to look in. If the files #it is fed are in the directory then it will delete them.Else it will retur #none. #V 0.01 import os,sys one,t...
7c0d52d8a08f4bf917f654a0f918ae787bc5664b
avallbona/python-crash-course
/comprehension_list.py
1,193
3.890625
4
def is_prime(value): primes = {1, 2, 3, 5, 7} return value in primes print("lista") some_list = [element + 5 for element in range(10) if is_prime(element)] print(some_list) print("diccionario") results = {element: element + 5 for element in range(10) if is_prime(element)} print(results) print("diccionario2 ...
221bb16f7517aa2c350773f5839d8cce3eceaf88
lightening0907/algorithm
/treeprint.py
1,124
3.65625
4
__author__ = 'ChiYuan' class treenode: def __init__(self,value): self.left = None self.right = None self.value = value def treeprint(root): q_par = [] q_par.append(root) q_child = [] order = 1 while len(q_par)>0: while len(q_par)>0: if o...
c9d9b87fcd9464fe32f6ced2f0a3281e7ade9d2c
gmlwhd2092/haedal
/a.py
723
3.6875
4
class soccer: soccer_count = 0 def __init__(self, name, position, club, country): self.name = name self.position = position self.club = club self.country = country soccer.soccer_count += 1 def info(self): print(f'축구선수: {self.name}') print(f'포지션: {se...
107ddc75e1d9ae6838ea5952db496a9c1d67f45e
fitigf15/PYTHON-VICTOR
/Algorismica avançada - UB/Pau/(ALGA)Algorismica avançada/(ALGA)Algorismica avançada/practica11.py
1,294
3.5625
4
import networkx as nx def llegir_graf(): '''lee el grafo de un fichero de texto''' global Grafo Grafo = nx.Graph() nom = raw_input("Doneu el nom del graf: ") Grafo = nx.read_adjlist(nom,create_using=nx.DiGraph(),nodetype = int) def crea_mat_adj(): global mat_adj mat_adj = [] num_node...
03f45ff2ff6391bd8680cc2d35b6b059cc0d0280
IrtazaChohan/Python_Essentials
/lists2.py
254
3.6875
4
student_grades = [9.1, 8.8, 7.5] dir(list) dir(int) # shows the builtin functions of python..like print etc dir(__builtins__) # find the average using number of items in list mysum = (sum(student_grades)) / len(student_grades) print(mysum) dir(len)
743d45975b5db721890246d70b650620bd9f0869
pazodilei/Smart_Calculator
/Problems/Palindrome/main.py
142
4.0625
4
word = input() if word == ''.join([word[i] for i in range(len(word) - 1, -1, -1)]): print("Palindrome") else: print("Not palindrome")
918f599630a4b3a3caa6278bc8902f1e1942fcf5
parivgabriela/Coursera
/Python-DB/prueba-semana3.py
334
3.984375
4
import sqlite3 conn = sqlite3.connect(':memory:') cursor = conn.cursor() cursor.execute("""CREATE TABLE table_1 (ID integer primary key, name text)""") cursor.execute("INSERT INTO table_1 VALUES (1, 'prueba')") conn.commit() query = "SELECT * FROM table_1" currencies = cursor.execute(query).fetchall() print(currencies)...
5ab90c5c71ccce403e88c1022a8ced4afb55c2b6
enzodiaz25/Scrabble
/codigo/logica/check_palabra.py
7,190
3.828125
4
''' Versión de check_palabra según última modificación propuesta por la Cátedra. Se mantiene la valuación de palabras con tilde, puesto que es una mejora en las posibilidades del usuario. ''' import pattern.es as pes from pattern.es import verbs, tag, spelling, lexicon import itertools as it def posibles_palabras (pa...
ca6b42c11324f5d0a6967d5b4554eef518b75ebc
dede1751/tcp_chess
/board_gui.py
5,821
3.625
4
""" This module implements solely the gui elements of the chess game. It does not care for efficiency, implements no logic and simply allows the player to see and interact with the board. The board is a 1D vector, indexed from the top left to bottom right (A8,B8, ... , G1, H1). For more info check engine module. """ ...
48837ba41dd80c5d783e0d20d22890afd8af53f4
ba-talibe/lab_netacad
/the_digit_of_life.py
194
3.5625
4
n = input(">>>") def digit(n): if len(n) == 1: return int(n) sum = 0 for i in range(len(n)): sum += int(n[i]) return digit(str(sum)) print(digit(n))
e98e8a5e4f936f769267764ec05bf0faee78ecfa
pureoym/leetcode
/array/566_Reshape_the_Matrix.py
1,785
3.6875
4
# -*- coding: utf-8 -*- # author: pureoym # time: 2017/12/15 9:59 # Copyright 2017 pureoym. All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/...
7f91df5090e36ee3c8a64c390abd7698ffdb77db
PyRPy/algorithms_books
/leetcode/add_digits.py
308
3.640625
4
# add_digits.py class Solution: def addDigits(self, num: int) -> int: if num <= 0: return 0 else: result = (num - 1) % 9 + 1 return result num = 383 sol = Solution() print(num) print(sol.addDigits(num)) # think about it again !
4257c2a7532e6ae0f4912bead9e91cf99a024516
wisesky/LeetCode-Practice
/src/206.reverse-linked-list.py
1,381
4.03125
4
# # @lc app=leetcode id=206 lang=python3 # # [206] Reverse Linked List # # https://leetcode.com/problems/reverse-linked-list/description/ # # algorithms # Easy (66.47%) # Likes: 7386 # Dislikes: 138 # Total Accepted: 1.5M # Total Submissions: 2.2M # Testcase Example: '[1,2,3,4,5]' # # Given the head of a singly ...
4007ae49ed5554864b3d2aceb339db6204a60d3e
sarkarChanchal105/Coding
/HackerRank/python/Easy/ctci-array-left-rotation.py
2,344
4.40625
4
""" https://www.hackerrank.com/challenges/ctci-array-left-rotation/problem A left rotation operation on an array shifts each of the array's elements unit to the left. For example, if left rotations are performed on array , then the array would become . Note that the lowest index item moves to the highest index in a ...
6ce2e593f6f01bd793f14ead1451067f6b93dc76
machukhinktato/test_tasks_python
/task4/SRC/task4.py
1,013
3.875
4
def main(str1=None, str2=None): """ Функция сравнивает два строчных элемента, где в качестве второго элемента, может быть передана строка, внутри которой есть символ '*', заменяющий любое кол-во любых символов. """ if str1 == None or str2 == None: return print('В функцию не были пере...
0387cdec127355d3098d47cb058420ebf0105116
mohan78/PythonProgramming
/advanced/closure.py
3,823
4.5
4
""" A closure is a function object that remembers the data in enclosed scopes. To know more about closure, we need to know about types of scopes in Python. There are 3 types of scopes in python Built-in, Global, Local, Non-Local or Enclosing scope. 1. Built-in scope: This is the widest scope. This cons...
a950f4779ec053b7004de84f56f9411c4909b4d0
MrHamdulay/csc3-capstone
/examples/data/Assignment_8/mzwrun001/question2.py
366
3.921875
4
"""Program to check for paired letters in a string Runako Muzwidzwa 06/05/2014""" v=input("Enter a message:\n") def pairs(v): if len(v)<2: return 0 #to return number elif v[0] == v[1]: n=v[2:] return 1 + pairs(n) else: return pairs(v[1:])#calls function with the m...
1d2853474fd5c24f18e9f32b98efcf15fa82b2e1
smartLp/Sort
/Sort_Algorithm.py
5,782
3.828125
4
# coding: utf-8 # # 几种常见的排序算法 # ## 1.插入排序 # In[2]: import time from functools import wraps def fn_timer(function): @wraps(function) def function_timer(*args, **kwargs): t0 = time.time() for i in range(100000): result = function(*args, **kwargs) t1 = time.time() print ("Tot...
e300db0fa9aadd9675ad77d253285ee01bf5357d
faidev/python
/day1/6.guess.py
234
4.09375
4
#!/usr/bin/env python3 age_of_wayne = 28 guess_age = int(input("guess age:")) if guess_age == age_of_wayne: print("yes,you got it.") elif guess_age > age_of_wayne: print("think smaller...") else: print("think bigger!")
a56a8f4ea047b3daed4c8b340e9b1af09d721c87
lukashaverbeck/parknet
/util/concurrent.py
3,878
3.625
4
import math import time from typing import Any, Callable import util def stabilized_concurrent(name: str, min_delay: float, max_delay: float, steps: int, daemon: bool = True) -> Callable: """ Decorator factory for concurrently executing a function with dynamic delays in between. Whenever a function is d...
e4733b2b9ef857b4fa3180a72bf6d0f44d9c44cc
kevinelong/AM_2015_04_06
/Week2/bitmask.py
1,458
3.8125
4
class permissions(): READ = 4 WRITE = 2 EXECUTE = 1 def __init__(self): self.permissions = 0 def allow(self, permission): #USE "OR" (vertical bar) to set a bit self.permissions = self.permissions | permission def revoke(self, permission): #USE "AND" (ampersand)...
552bef72b059809ae77c2658dcec7f47e76fa136
jiaozhennan/python300
/012-dotProduct.py
406
3.5
4
class Solution: def dotProduct(self, A, B): if len(A) == 0 or len(B) == 0 or len(A) != len(B): return -1 ans = 0 for i in range(len(A)): ans += A[i] * B[i] return ans if __name__ == '__main__': A = [1, 1, 1] B = [2, 2, 2] solution = Solution() ...
0c2fcb7529b603ffb5eef3c1de0bd5cea60fac38
rentes/Euler
/problem1.py
577
3.671875
4
"""Project Euler - Problem 1 - http://projecteuler.net/problem=1""" import sys import time import tools.timeutils as timeutils def sum_numbers(): """ Sums all natural numbers below 1000 that are multiples of 3 or 5 Returns: int """ a, b = 1, 0 while a < 1000: if (a % 3 == 0) or (a % 5 ...
41789e171b1594aa69ef8a5447f5c244b3842946
trgreenman88/CS_21
/greenman_archery.py
3,766
4.0625
4
# Trent Greenman # CS 21, Fall 2018 # Program: Archery # Import graphics from graphics import * # This function creates the target def create_target_window(): # Creates the graphics window win = GraphWin() # Set the size of the graph win.setCoords(-6, -6, 6, 6) # Set the color of the background ...
8464c89eb3726f9c3cd7220785e869cf59d95c6c
jad2192/babys_first_repo
/random/graph_algs.py
5,058
3.796875
4
# Most of these algorithms are derived from psuedocode in Cormen et. al. inf = float('inf') class Vertex(object): """ Adjacent list implementation of a graph. Create a vertex (v) and then its adjacent edges are stored in the list v.edges. A graph will then just be a set of vertex objects. Can use this to implement...
de18edf082547b02c9e908203eb93078dfb86dee
thackerdynasty/Guess-the-number-
/main.py
118
3.546875
4
from game import * import random Guesses = 0 name = input("Hello! What is your name? ") number = random.randint(1, 20)
8aa1825e40be87360a91c93838a8a6e7224fca1a
MechaMonst3r/Python-Assignment-1
/Assignment 1/dayoldbread.py
918
3.90625
4
# Name: Luke Bowden # Student Number: t00040951 # Lab Number: 1 # Date: 2020-09-16 # Description: Takes in input from a user who wishes to buy old # bread at a discount price and produces the total. #Defining Constants and variables. BREADCOST = 3.49; DISCOUNT = 0.6; totalBread = 0.0; totalDiscount = 0.0...
bfa4c8529f95a85f03cd0cce65bd3d03827c369a
SaiHarsh/twitter_anaslysis_Search
/crowd dynamics programs/date_max_min_median.py
2,126
3.5
4
#find median of hours group by date #step one median for a next step of median of median #find the min, max, sum, mean, median values per date and day #change the group by option from date/day or any suitable as needed. import pandas as pd from datetime import datetime import csv cols = ['date', 'startTime', 'en...
899c4d0d162f993e54f66f0d390873ac0a7b4d84
lgauing/Guias-dispositivas-y-ejercicios-en-clase_Lady
/condicion.py
846
3.984375
4
# Lady Mishell Gauin Gusñay # 3er semestre de software A1 class condicion: def __init__(self,num1,num2): self.numero1=num1 self.numero2=num2 numeros=self.numero1+self.numero2 self.numero3=numeros def usoIf(self): #if...elif ... else ...: permiten condicionar la ejecuci...
041bc3ba085aa319a4bdf8fc4cdb822f35aebc82
tylors1/Leetcode
/Problems/findLargestSum.py
429
4.0625
4
# Given a list of integers, write a function that returns the largest sum of non-adjacent numbers. Numbers can be 0 or negative. # For example, [2, 4, 6, 8] should return 12, since we pick 4 and 8. [5, 1, 1, 5] should return 10, since we pick 5 and 5. def findSum(nums): max1 = nums[0] maxi = 0 for i in range(le...
ab3a82c04326e59c7f2c1b5123640f162b57edf4
XuSShuai/data-structure-and-algorithm
/inverse_pair.py
1,259
3.65625
4
import numpy as np def merge_sort(arr, L, R): if L == R: return 0 mid = (L + R) // 2 return merge_sort(arr, L, mid) + merge_sort(arr, mid + 1, R) + merge(arr, L, mid, R) def merge(arr, L, mid, R): p = L q = mid + 1 res = 0 auxiliary = [] while p <= mid and q <= R: if ...
288e1ade1b1ef44ec163d087d0d8b009bb5012c0
headend/frontend
/utils/__init__.py
703
4.21875
4
import datetime import time # Python Program to Convert seconds # into hours, minutes and seconds def convert_seconds_to_day(seconds): days = seconds // (24 * 3600) seconds = seconds % (24 * 3600) hour = seconds // 3600 seconds %= 3600 minutes = seconds // 60 seconds %= 60 return "%dd ...
c4cd16869254cf214071eb40d6c9966d5d362ce1
VladimirKrgn/triangle_test_task
/triangle.py
815
3.8125
4
class Triangle: def __init__(self, a, b, c): self.a = a self.b = b self.c = c self.ab_length = (pow(a[0] - b[0], 2) + pow(a[1] - b[1], 2)) ** 0.5 self.ac_length = (pow(a[0] - c[0], 2) + pow(a[1] - c[1], 2)) ** 0.5 self.bc_length = (pow(b[0] - c[0], 2) + pow(b[1] - c[1...
52c224954489725a2530ef63cec51b3cfecd16fc
likaon100/pythonbootcamp
/dzień 2/cwiczenie 3.py
408
3.546875
4
Miasto_A = str(input("Miasto A:")) Miasto_B = str(input("Maisto B:")) Dystans_z_Miasto_A_do_Miasto_B = int(input(f"Dystand {Miasto_A}-{Miasto_B}:")) Cena_paliwa = float(input("podaj cene paliwa:")) spalaniekm = float(input("Spalanie na 100 km:")) koszt = round((Dystans_z_Miasto_A_do_Miasto_B / 100) * spalaniekm * Cena_...
b50cae8c4fb8c80d5e705c3a940f0e6bdf6079bb
vinodrajendran001/python-interview-prep
/array_rotation.py
649
3.75
4
''' Left array rotation d = 4 [1 2 3 4 5] -> [2 3 4 5 1] -> [3 4 5 1 2] -> [4 5 1 2 3] -> [5 1 2 3 4] ''' class Stack: def __init__(self): self.items = [] def isEmpty(self): return self.items == [] def push(self, item): self.items.append(item) def pop(self, item): return self.items.pop(item) def peek...
8f0d39fc984a0a82530f1196170914bad6d68cb9
elikaski/BF-it
/Compiler/Functions.py
1,223
3.59375
4
from copy import deepcopy from Exceptions import BFSemanticError functions = dict() # Global dictionary of function_name --> FunctionCompiler objects def insert_function_object(function): functions[function.name] = function def get_function_object(name): """ must return a copy of the function beca...
f18fc0dd2e198b463a419d0b8c0fba0f426d2c68
cybelewang/leetcode-python
/code726NumberOfAtoms.py
4,089
4.375
4
""" 726 Number of Atoms Given a chemical formula (given as a string), return the count of each atom. An atomic element always starts with an uppercase character, then zero or more lowercase letters, representing the name. 1 or more digits representing the count of that element may follow if the count is great...
87d0969fb317ffbb90bbfcc0ff280fa4e717df0b
MFTI-winter-20-21/LebedevDanya
/07 палендром.py
160
3.796875
4
k1 = input("слово_") k2 = k1[::-1].lower() if k1.lower() == k2: print ("это палиндром") else: print ("это не палиндром")
f22fc3e370897c2b7585e3ab8b2a6a0eb0fc6179
Lusarom/progAvanzada
/ejercicio30.py
247
3.609375
4
KPascal = float(input('Ingresa presion en KPascales:')) PSI = KPascal * 0.14508 mmHg = KPascal * 0.13332 atm = KPascal / 101.325 print('\n lb in^2: %.3f'%(PSI),'(PSI)') print('\n mmHg: %.3f'%(mmHg),'(mmHg)') print('\n atm: %.3f'%(atm),'(atm)')
0154ba072831f115ce83a7171852107bee81ce7b
narasimha7854/qazi
/str1.py
131
3.796875
4
#example of String datatype str="Welcome to Python" print(str) print(str[0]) print(str[3:7]) print(str[11:]) print(str[-1])
4749198dbedff2acf22ce821be69fcdd5a60293f
alcantara17/dminer
/dminer/ingestion/helpers/helpers.py
2,219
3.671875
4
""" This module provides a set of general purpose helpers for use in parser logic. """ import os def build_filename_timestamp(regex_matcher, base_year=2000): """ Given a `re.match` object, this function will return a formatted timestamp in the format of: "yyyy:MM:dd HH:mm:ss:SSS" This functio...
0330ed19241e54b4dcadb420c67ff4a52435f0eb
python-control/python-control
/examples/cruise-control.py
17,248
4.25
4
# cruise-control.py - Cruise control example from FBS # RMM, 16 May 2019 # # The cruise control system of a car is a common feedback system encountered # in everyday life. The system attempts to maintain a constant velocity in the # presence of disturbances primarily caused by changes in the slope of a # road. The cont...
b51722b7d3dae2e6ecdb5ee9362900c154384a72
Aziz1Diallo/python
/rectangle.py
249
4.03125
4
value=eval(input('type the height of the triangle : ')) row=0 while row<value: count=0 while count<row: print(end="") count+=1 count=0 while count<value: print(end="*") count+=1 print() row+=1
f8d7202b89d29c3f595ddc572a09f3d430fca7a1
nfscan/fuzzy_cnpj_matcher
/models/Cnpj.py
3,995
3.5
4
__author__ = 'paulo.rodenas' import random class Cnpj: """ Utilty class defines certain methods related to Brazilian CNPJs validation """ @staticmethod def validate(cnpj): """ Method to validate brazilian cnpjs Tests: >>> print Cnpj.validate('61882613000194') ...
fa26b38bb75533aa689f4d28c0a2d076764eab09
Sisyphus235/tech_lab
/algorithm/array/search_sorted_2d_array.py
1,021
3.984375
4
# -*- coding: utf8 -*- """ 一个包含整数的二维数组,左到右递增,上到下递增 判断一个整数是否在二维数组中 """ def search_sorted_2d_array(array, n): row_len = len(array) col_len = len(array[0]) row = 0 col = col_len - 1 while row < row_len and col >= 0: if array[row][col] == n: return True elif array[row][co...
0b1c255e8c2cc6e6775c72050919280a3ff0d361
lilianakemi/Projeto_Python_Exemplos_Exercicios
/Desenvolve_py/GravarArquvio,Invetario, Leitura,JSON_5/gravarArquivo.py
412
3.953125
4
with open("pagina.html", "w") as pagina: pagina.write("<body><h1> Esta é uma pagina WEB </h1>") pagina.write("<br><h2> Abaixo seguem alguns nomes importantes para o projeto: </h2>") pagina.write("<h3>") nome=" " while nome!="SAIR": nome=input("Digite um nome ou SAIR: ").upper() if n...
8dbebf62eb3446030cfe9502f6ba7f8d1839500b
aizigao/keepTraining
/algorithm/leetCode_xx/380.o-1-时间插入、删除和获取随机元素.py
1,212
3.625
4
# # @lc app=leetcode.cn id=380 lang=python3 # # [380] O(1) 时间插入、删除和获取随机元素 # # @lc code=start # 变长数组 + 哈希表 class RandomizedSet: def __init__(self): self.nums = [] self.indeces = {} # 如果 val 不存在集合中,则插入并返回 true,否则直接返回 false def insert(self, val: int) -> bool: if val in self.indeces:...
4caf13581ab1f7ce234cadd399146a1dd3f5de26
scorp6969/Python-Tutorial
/math/math.py
424
3.734375
4
import math pi = 3.1414 pi_n = -3.1414 a = 10 b = 20 c = 30 # round off the value print(round(pi)) # round off to the nearest top(ceiling) value print(math.ceil(pi)) # round off to the nearest low(floor) value print(math.floor(pi)) # give absolute value print(abs(pi_n)) # gives power print(pow(a, 2)) # gives squ...
a1f8005dbce02f4b98a191beb6f4c6e781c6ac5e
uwseds-sp18/homework-3-dwhite105
/test_homework3.py
1,207
3.859375
4
# coding: utf-8 # (5 points). Create a python module named test_homework3.py that tests the code in homework3.py. Write at least 3 tests (e.g., checking column names, number of rows, and verifying which columns constitute a key). Also, write a test to check that the correct exception is generated when an invalid path...
525212302d7411619f01585ec9af0e93cb47c769
Mus1cBreaker/Smart-Calculator-Hyperskill
/Problems/The sum of numbers in a range/task.py
315
3.84375
4
def range_sum(numbers, a, b): sum_of_specified_elements = 0 for number in numbers: if a <= int(number) <= b: sum_of_specified_elements += int(number) return sum_of_specified_elements _numbers = input().split() _a, _b = input().split() print(range_sum(_numbers, int(_a), int(_b)))
490d3dc9ba6a5f750c73d854e24dfe60b649388a
Sroczka/URL
/Python/programmation_objet/wyklad/iteracja.py
738
3.859375
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Fri Nov 16 14:00:33 2018 @author: janik """ class Sequentiel(): def __init__(self): self.i = 0 def __iter__(self): return self def __next__(self): self.i += 1 if self.i>1000: raise StopIteration("fi...
bea057491b6d86e77c55c375bb3dc845a7e11a92
daniel-reich/turbo-robot
/EyzmkffNRiEBtjAmf_20.py
972
4.53125
5
""" Write the function that takes three dimensions of a brick: height(a), width(b) and depth(c) and returns `True` if this brick can fit into a hole with the width(w) and height(h). ### Examples does_brick_fit(1, 1, 1, 1, 1) ➞ True does_brick_fit(1, 2, 1, 1, 1) ➞ True does_brick_fit(1, 2, 2, ...
33a25b0b58fc38d6aac5496b6fd232d1b97394b1
cfranchi/CS4850-Project
/TreeBuilder/csvParser.py
1,469
3.671875
4
class csvParser: def __init__(self, hierarchy, scanner): self.hierarchy = hierarchy self.attributes = scanner.attributes self.attributeNames = scanner.attributeNames def sortToHierarchy(self): print("sorting by hierarchy...") for i in range(0, len(self.attributes)): ...
d2f90a6f2e5494d137644d909c66b98902b3cae0
N-ickMorris/Location-Assignment
/assignment.py
4,662
3.796875
4
# facilities planning: assignment IP # this model is intended to minimize the total cost of investing in a set of producers to supply a set of consumers # ---- setup the model ---- from pyomo.environ import * # imports the pyomo envoirnment model = AbstractModel() # creates an abstract model model.name = "Assig...
bbf940cb21fa2d1dfce5bff3d2180bfb5f333db2
praxpk/Weather_accidents_prediction
/merge_thread.py
7,765
3.546875
4
import pandas as pd import datetime import time import threading from selenium import webdriver import queue import traceback class w_sel: def __init__(self,muni,num): """ The queue stores tuples where each tuple contains start and end indices of the rows of the dataframe. :param muni: the ...
00da040a1625724485f3ccfb1db5610cffa16990
james153dot/csp-p2-millard
/toobased.py
3,409
3.75
4
######################################################################### ## # # Code Maker - By James Lu # # last revised: 9/24/21 # # ...
090ce23803d6268131fbd6bcefa9774a702a368e
gauravdal/write_config_in_csv
/python_to_csv.py
1,199
3.875
4
import json import csv #making columns for csv files csv_columns = ['interface','mac'] #Taking input from json file and converting it into dictionary data format with open('mac_address_table_sw1','r') as read_mac_sw1: fout = json.loads(read_mac_sw1.read()) print(fout) #naming a csv file csv_file = 'names.csv' tr...
7b95143b47168036304e3bbe9c9dec95fa444d12
peterjen/MyPython
/D19_Sort_list_tuple_obj.py
1,366
3.84375
4
li = [9,1,8,2,7,3,6,4,5] s_li = sorted(li) print('Sorted list variable\t',s_li) print('Original list variable\t',li) li.sort() print('Original list \t',li) s_li = sorted(li,reverse=True) print('Sorted list variable\t',s_li) print('#####################') tup = (9,1,8,2,7,3,6,4,5) s_tup = sorted(tup) print('Sorted t...
e527860b7b40e86c4904d708638b8f9155fd6451
Aasthaengg/IBMdataset
/Python_codes/p03502/s059117073.py
133
3.5
4
N = int(input()) fx = 0 Nx = N for i in range(8): fx += Nx % 10 Nx = Nx // 10 if N % fx == 0: print("Yes") else: print("No")
c1dc8e8e5ab3a961a46db3cd2900afc6a68eba65
crowddynamics/crowddynamics-research
/data_analysis/radial_mean.py
2,626
3.875
4
import numpy as np def radial_mean(speed, crowd_pressure, cell_size, width, height): """ An approximate method to calculate average speed and crowd pressure at different distances from the exit. Points at equal spacing along a semicircle are generated, and then it is identified to which cells in the g...
dadf1f67c82e4bf5e0dba1beded55c604ef846e2
salvadb23/CS2.2
/challenges/challenge_3.py
4,367
4.1875
4
#!python """ Vertex Class A helper class for the Graph class that defines vertices and vertex neighbors. """ from sys import argv class Vertex(object): def __init__(self, vertex): """initialize a vertex and its neighbors neighbors: set of vertices adjacent to self, stored in a dictionar...
ff9488069257e1b9251dc2a6e7d13b6c4e4049e4
johnchoiniere/advent_of_code_2019
/day_3/day3.py
2,068
3.6875
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Tue Dec 3 00:19:41 2019 @author: john """ # read in input with open('input.txt') as f: infile = f.readlines() # make it intotwo nice, easy lists of steps wire1 = infile[0].split(',') wire2 = infile[1].split(',') def intersect_finder(wire1, wire2)...
5eaf7215636ff6ab4f41e2d6455c251a57ba7ed0
Hallyson34/uPython
/numeuler.py
199
3.53125
4
#Professor fez/code runner x = float(input()) n = int(input()) valor=0.0 for i in range(0,n+1): fat=1 for j in range(1,i+1): fat=fat*j valor=valor + x**i/fat print(f"{valor:.4f}")
59a2bdad1a9604398014265be7ecac9878f73b55
ernestoarbitrio/python-conference-beginners-day
/challenges/basic/boolean_expressions.py
1,573
4.40625
4
""" EXERCISES: ======================================================================================================================== Es.1 Given vars a and b float, print "a > b" if a greater than b else print "a <= b" if b is greater than or equal to a. Es.2 Given two strings 'banana' 'watermelon' check which word ...
8d764d588205566023cde227edd314455cf89a6d
mariavidrasc19/plusivo-tutorials
/RPI Lesson 02 Dim an LED/main.py
1,583
4.09375
4
from time import sleep #we import the sleep module from the time library import RPi.GPIO as GPIO #we import the RPi.GPIO library with the name of GPIO GPIO.setmode(GPIO.BOARD) #we set the pin numbering to the GPIO.BOARD numbering #for more details check the guide atached to this code GPIO.set...
92ead6f875e82d780d89a676e0c602737dafb509
mhelal/COMM054
/python/evennumberedexercise/Exercise03_06.py
175
4.21875
4
# Prompt the user to enter a degree in Celsius code = eval(input("Enter an ASCII code: ")) # Display result print("The character for ASCII code", code, "is", chr(code))
61c1a344a26ab2bf0f5bab6e191cdf1dc7c1979e
Sophia-Li888/python-learning
/Guess the number.py
2,581
4.09375
4
NAME = input("Hi! What is your name?") print("Hi,",NAME,"! You will be guessing from 1 to 10.") randomRangeLimit = 10 import random number = random.randrange(1, randomRangeLimit) game = "start" level = 1 attempts = [] attemptsLimit = 5 AGAIN = "yes" while AGAIN =="yes": while game == "start": if len(atte...
34226704f82c324265397c9e8d2c68032271461a
trejp404/banking-program
/banking_program.py
4,051
4.28125
4
# Prepedigna Trejo # Assignment 8.1 # Parent Class - Account class BankAccount: def __init__(self, num, bal): self.accountNumber = num self.balance = float(bal) print("A Pre-Paid Account has been created") print("The account number is " + str(self.accountNumber)) print("The balance is $" + '{:,.2f}'.format...
32f2db9ca8ab3c43a6955102c87024a7665ba404
rgj7/coding_challenges
/projeuler/problem_12.py
456
3.78125
4
import math def getDivisorCount(n): divisors = 0 start = 1 end = math.floor(math.sqrt(n)) while start <= end: if n % start == 0: if start == n//start: divisors += 1 else: divisors += 2 start += 1 return divisors divisors = 0 i...
784ef46e6c2bc0219f0566bd7ad57385a2314538
nownabe/competitive_programming
/AizuOnlineJudge/ITP1_Introduction_to_Programming_1/ITP1_2_D_Circle_in_a_Rectangle.py
279
3.640625
4
def determine(w, h, x, y, r): if x - r < 0 or x + r > w: return False if y - r < 0 or y + r > h: return False return True w, h, x, y, r = input().split() if determine(int(w), int(h), int(x), int(y), int(r)): print('Yes') else: print('No')
b644303feef1a0b0046d086b0487dca7e7c3e0d1
asdf2014/algorithm
/Codes/asdf2014/4_median_of_two_sorted_arrays/median_of_two_sorted_arrays.py
1,479
4.0625
4
# https://leetcode.com/problems/median-of-two-sorted-arrays/ # There are two sorted arrays nums1 and nums2 of size m and n respectively. # # Find the median of the two sorted arrays. The overall run time complexity should be O(log (m+n)). # # You may assume nums1 and nums2 cannot be both empty. # # Example 1: # nums1 ...
6bce92b143014d8f86d5655a5869daaa5222db1a
acemodou/Working-Copy
/DataStructures/v1/Queue/circular_queue.py
1,162
3.71875
4
class CircularQueue: def __init__(self, n): self.front = 0 self.rear = 0 self.size = n self.Q = self.buildQueue() def buildQueue(self): self.Q = [0 for _ in range(self.size)] return self.Q def Enqueue(self, value): if self.is_Full():...
f826330e546a6da4c7ed25111e45295a87987fdd
spencerhhall/gone-fishing
/event.py
1,787
3.9375
4
# Contains code for Event object. import datetime speciesCount = { # Number of trout and average size "rainbow trout": [0, 0], "brown trout": [0, 0], "brook trout": [0, 0], "cutthroat trout": [0, 0], "golden trout": [0, 0], "bull trout": [0, 0], "Arctic grayling": [0, 0] } class Event: ...
9262f6d671851eab6592884f54821ff631c28966
MikyPopescu/DataProcessingUsingPython
/tema1.py
10,541
4
4
# Tema 1 # 1. Să se creeze o listă de numere întregi pozitive si negative de 10 elemente. # Să se filtreze elementele listei astfel incat acestea sa fie pozitive și să se afișeze lista ordonata crescător. ''' from pip._vendor.distlib.compat import raw_input nrElementeLista = 10 lista = [] for element in range(nrElem...
05e25645f3889eea27c58351d5de0fbe8bc7f744
abhigyan709/dsalgo
/hackerrank_python_problems/finding_the_percentage.py
396
3.953125
4
number_of_students = int(input("Enter number of students: ")) students_marks = {} for _ in range(number_of_students): name, *line = input().split() scores = list(map(float, line)) students_marks[name] = scores query_name = input() from decimal import Decimal query_score = students_marks[query_name] total_...
1620c51512627e034a4abab208aec284e581a216
yangninghua/python_songsong
/Week1(39集)/day4(9集)/代码/test.py
636
3.625
4
a,b=3,5 # a=3 b=5 print(a,b) # a=3,b=5 # print(a,b) a=b=c=3 print(a,b,c) num = int(input('输入四位整数:')) # 8654 ge = num%10 num = num//10 # 865 shi = num%10 num = num//10 # 86 bai = num%10 num = num//10 # 8 print(num,bai,shi,ge) # num = 9 if num%2==0: print('偶数') el...
cb68983155f712023ac82d566b4cd02d616233f7
aakriti-sharma/Mini-Projects
/SOP-POS-converter/SOP-POS-converter-master/sop.py
588
3.515625
4
print("SOP CONVERSION") print("Enter variables:") v=list(input().split()) n=len(v) print("Enter expression:") ne=list(input().split("+")) e=[] def sop(t,a): e.remove(t) nt=t+a e.append(nt) e.append(nt+"'") for j in v: if nt.find(j)==-1: sop(nt,j) sop(nt...
36033de9464a200141bc4f3e13ab69fefaaf86fd
WAT36/procon_work
/procon_python/src/atcoder/abc/past/D_166.py
526
3.65625
4
x=int(input()) b=0 while(True): bi=b**5 ai=x+bi # print(ai,bi,(ai**(1/5))%1.0) #X-B^5 は整数を5乗した数か判定 if(int((ai**(1/5))%1.0) == 0): aj=int((ai**(1/5))//1) # print(ai,aj,bi,b) if((aj**5)==ai): print(aj,b) break b*=-1 bi=b**5 ai=x+bi if(a...
74978d6d511a44992d3dfeb398f0a9c6498f04e7
hikyru/Python
/HW1MakingShapes.py
1,107
3.75
4
# -*- coding: utf-8 -*- """ Created on Sat Feb 8 1:45 2020 @author: KatherineYu """ # making a right triangle print("* * * *", end = '\n' '\n' '\n') print("* * *", end = '\n' '\n' '\n' ) print("* *", end = '\n' '\n' '\n' ) print("*", end = '\n' '\n' '\n' ) # making a isoceles triangle print(" *", end = '\n' '\n' '...
08f4e875029f0191e4dcc89c139d82f7b272b440
malwadkarrk/Python
/guessnumber.py
666
4.0625
4
import random guesscount = 0 number = random.randint(1,100) username = input("Hello, what's your name?") print(f"Well, {username}, you will get 10 chances to guess the number between (1,100) ") while guesscount < 10: print(f"{username}, take a guess:") guess = int(input()) guesscount += 1 ...
c21d9b152c0f7360f317ab1f093291fc635e9bda
hooloong/My_TensorFlow
/Test29_tf/apis/dropout.py
1,093
3.6875
4
''' dropout( x, keep_prob, noise_shape=None, seed=None, name=None ) 功能说明: 原理可参考 CS231n: Convolutional Neural Networks for Visual Recognition 参数列表: 参数名 必选 类型 说明 x 是 tensor 输出元素是 x 中的元素以 keep_prob 概率除以 keep_prob,否则为 0 keep_prob 是 scalar Tensor dropout 的概率,一般是占位符 noise_shape 否 tensor 默认情况下...
4084b554985dc01c396f9362d77ef7ef0f6f35b0
GodsloveIsuor123/holbertonschool-higher_level_programming-3
/0x07-python-test_driven_development/2-matrix_divided.py
1,162
4
4
#!/usr/bin/python3 """ 2-matrix_divided.py file Functions: -> matrix_divided(matrix, div) """ def matrix_divided(matrix, div): """ divides all elements of a matrix matrix must be a list of lists of integers or floats Each row of the matrix must be of the same size div must be a number...
662989cbcc71953064d31693b425500aba3c794a
niteesh2268/coding-prepation
/placement-test/pcpt6/Linus-installs-Linux.py
517
3.546875
4
def getAns(string): entries = string.split('/') stack = [] for entry in entries: if entry == '..': if stack: stack.pop() elif entry == '': continue elif entry == '.': continue else: stack.append(entry...
2a1ad4353767190f403019d7513b7c646fff7b48
marcenavuc/python_listings
/1_basics.py
1,319
3.65625
4
from collections import defaultdict, Counter, namedtuple import heapq import enum # Tuple a = tuple() a = () a = 12, 13 a = ('s', ) a = tuple("Hello, world!") print(a) # Операции print(a.index("l")) print(a[0]) print(a[1:5]) print(a.count("l")) # List a = list() a = list("Hello") a = [] a = [1,2,3] # Операции a.app...
b8ca3c2f2a5d94ba85ad886a2c9193121b61d53a
niripsa/python
/20170728.py
2,151
4.1875
4
### 使用python进行数学运算 ### # 加法 # print(1 + 1) # 减法 # print(2 - 1) # 乘法 # print(2 * 4) # 除法 # print(5 / 2) # 求余 # print(5 % 2) # 地板除 # print(5 // 2) # 乘方 # print(2 ** 3) ### 格式控制符 ### # print("%f" % (5/3)) # 1.666667 # print("%.2f" % (5/3)) # 1.67 # print("%f" % (415 * 20.2)) # 8383.000000 # print("%0.f" % (415 ...
d2cff5feb2ae49a6bc0607c602ce4b2522a49182
nilesh7808/CodingNinjaDSA
/BasicPythons/HeapSort.py
291
3.96875
4
from heapq import heappop, heappush def heap_sort(array): heap = [] for i in array: heappush(heap, i) HeapSort = [] while heap is True: HeapSort.append(heappop(heap)) return HeapSort array = [13, 21, 15, 5, 26, 4, 17, 18, 24, 2] print(heap_sort(array))
7cc989d93e084c3e90445991dac5f33f2600750e
kajendranL/Daily-Practice
/loops_exec/01.divi_multi.py
260
4.03125
4
print ('''Write a Python program to find those numbers which are divisible by 7 and multiple of 5, between 1500 and 2700 (both included)''') print() num = [] for num in range (1500, 2700): if num % 7 ==0 and num % 5 == 0: print(num, end=',')
e0d9894638d0428c986b3211b1f57798468d8915
BenHesketh21/QA-Academy-Training
/Powers.py
163
4.125
4
number1 = float(input("First Number: ")) sqr = number1 ** 2 print(sqr) number2 = float(input("To the power of: ")) answer = number1 ** number2 print(answer)
32b8a3f340960e8824d6831f217bde6c73e564d0
ptanoop/pythonTips
/Return multiple values from functions.py
149
3.84375
4
# function returning multiple values. def x(): return 1, 2, 3, 4 # Calling the above function. a, b, c, d = x() print(a, b, c, d) #-> 1 2 3 4
2d5941b7a577ecda00108139603d32675557bb03
jocespitia/EE381
/project 6/lab6.py
456
3.703125
4
''' EE 381 ''' p = float(input("Enter probability of a jump. ")) S = int(input("Enter the standing position. ")) N = int(input("Enter the boundry position.")) J = int(input("Enter the number of jumps wanted. ")) import random for k in range(J): r = random.uniform(0, 1) if S == 0: S = 1 if S == N:...
e7f600640ab9293a4788739e1fcb5f8e4ce1df24
zoltankiss/ctci_problems
/ch-3/3-5/python/sort_stack.py
957
3.890625
4
class Stack: def __init__(self, lst): self.lst = lst def push(self, e): self.lst.append(e) def pop(self): return self.lst.pop() def peek(self): return self.lst[-1] def isEmpty(self): return self.lst == [] class SortStack: def __init__(self): s...
2ffb6bdaf1fc035d9ba7e827d6730a924911b485
sharanyavenkat25/modelcompression
/data.py
2,176
3.546875
4
from keras.datasets import mnist from keras.datasets import cifar10 from keras.utils import np_utils # Import other necessary packages import numpy as np def get_data_cifar(num_classes=10): """ Get the CIFAR dataset. Parameters: None Returns: train_data - training data split train_labels - training label...
209534f1df40749a6eab5038e1e2abccad088e91
Oniwa/CodinGame
/There_is_no_Spoon_Episode_1/spoon.py
2,786
3.65625
4
import sys import math # Don't let the machines win. You are humanity's last hope... class Node(object): def __init__(self, x_location, y_location): self.x = x_location self.y = y_location self.coordinate = f'{self.x}, {self.y}' self.x_right = -1 self.y_right = -1 ...
255299efedd954180cd741c90bb264451f19bd0c
juliapetiteau/ComputerScience
/do now 1.30.18.py
280
4.15625
4
#code for luggage weight price weight = float(input("How much does your luggage weigh?")) if weight >120: print("Your luggage is too heavy for this flight") elif weight > 50: print ("There is a $25 fee for this luggage") else: print("Your luggage is accepted as is")
a39ba3bceaee7b53a960c3d7629ad0ef16c239e4
fixik338/subject_269
/Lab3.26.py
214
3.6875
4
M = int(input("Кол-во строк = ")) z = input("Введите слог = ").lower() i = 0 while(i < M): arr = input("Введите строку = ").lower() arr = arr.replace(z, "") print(arr) i+=1
fbc62544545866c4d36a6e324ef1737a7b098714
daniel-reich/turbo-robot
/MSX7AHcNiCZpCsiXY_17.py
646
4.34375
4
""" Create a function which returns how many **Friday 13ths** there are in a given year. ### Examples how_unlucky(2020) ➞ 2 how_unlucky(2026) ➞ 3 how_unlucky(2016) ➞ 1 ### Notes Check **Resources** for some helpful tutorials on the Python `datetime` module. """ def how_unlucky(yr): i...
764a8bceb1f69e1a50db3bfabd68f247b3b15a25
cmgn/problems
/kattis/mirror/mirror.py
353
3.65625
4
#!/usr/bin/env python3 def main(): t = int(input()) for test in range(t): n, m = map(int, input().split()) output = [] for _ in range(n): output.append(input()[::-1]) print("Test " + str(test + 1)) for item in reversed(output): print(item) if _...
14b6ecf05f7d01e10ea35a66d34ab6fe81019510
kpy4a/python
/Lesson 9/Lesson9_2.py
456
3.734375
4
class Road: __weight = 25 # удельный вес 1 кв м __thickness = 5 # толщина def __init__(self, length, width): self._length = length self._width = width def calculate_weight(self): return self.__weight * self.__thickness * self._length * self._width length = 5000 ...
a04744731e767ecba828583544ac33a6e8c1e8b5
Seva-N/Physics
/phys_2/phys.py
18,419
3.8125
4
import math # Welcome to the Module "Phys" 2.1 def help(): print("Dear Guest!") print("Welcome to the physics module _Phys_ 2.1!") print("My name is Seva Naumov. Program is made by me.") print(" You can find a lot of physical \ constans or calculate some physical values from Mechanics.") print("So...