blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
9cc71f16f7cad2a30d3f397de07a4e57aed6e407
Ling-Alma/my_python_notes
/04_02_svm.py
5,554
4.0625
4
# Author: Justin A Johnson. Adapted from sklearn documentation and original content. License: Modified BSD License. # SciPy import numpy as np import scipy import sklearn from sklearn import datasets import pandas as pd import os # One of the canonical datasets in sklearn is a series of images of handwritten digits. ...
7c9054d89481154736b3766775408948036a47a9
Gabriel1521/leetcode
/46_Permutations.py
948
3.78125
4
# 46. Permutations class Solution(object): def permute(self, nums): """ :type nums: List[int] :rtype: List[List[int]] """ res = [] self.dfs(nums, [], res) return res def dfs(self,nums, path,res): if not nums: res.append(path) ...
4ff655e7a1fa886fe509102222821292165e3df2
arsaikia/Data_Structures_and_Algorithms
/prepalgo/Trees/binary-tree-preorder-traversal.py
735
3.5
4
# O(N) Time | O(N) Space def recursivePreorderTraversal(self, root: Optional[TreeNode]) -> List[int]: result = [] def recursivePreorder(node): if not node: return result.append(node.val) recursivePreorder(node.left) recursivePreorder(node.right) return node...
c0ad694e07241edde8792b0f86a7be63d36ef2cb
Brian14/testpy
/chapter2/input1.py
166
3.515625
4
__author__ = 'bao' print("age") age = input() print("height") height = input() print("input age is: " + age) print("input height is: " + height) # # input("age?")
8c7b43ba0d1d6c2dd5c0aedbc68061bbef19cf98
thesyd1982/scrapedia
/models/unit.py
206
3.734375
4
from enum import Enum class Unit(Enum): LITER = 'Liter' KG = 'Kg' PIECE = 'Piece' if __name__ == "__main__": print(Unit.LITER.value) print(Unit.KG.value) print(Unit.PIECE.value)
f2e038026d5ebc666d6e410d0617ebd2d361977a
biyoner/-offer_python_code
/44数字序列中某一位的数字.py
1,254
3.953125
4
#coding=utf-8 #author:Biyoner def digitAtIndex(index): if index<=0: return 0 digits = 1 while 1: numbers = countOfIntegers(digits) if index > numbers*digits: index -= numbers*digits digits += 1 else: break nums, digs = in...
0517da29d406084e850fae4b74e8b80f86242a73
SafonovMikhail/python_000577
/001146StepikPyBegin/Stepik001146PyBeginсh13p03st07_functions_QUESTION06_20210227.py
224
4.125
4
''' Что покажет приведенная ниже программа? def swap(a, b): a, b = b, a a = 4 b = 3 swap(a, b) print(a - b) ''' def swap(a, b): a, b = b, a a = 4 b = 3 swap(a, b) print(a - b)
9fb4bd81599e2c8a9a9a631f6272710f766486e5
hhs44/interview
/并发编程/电影院抢票.py
508
3.640625
4
import time import threading n =100 def plus(): print("开始抢票") global n mutex.acquire() temp = n time.sleep(1) n = temp -1 print('购买成功,还剩%d票 ' % n) mutex.release() if __name__ == '__main__': mutex = threading.Lock() t_l = [] print("---主线程开始----") for i in range(10):...
c90b029f3d692476ce48ee98b1dbc13f03a25988
Hyunjae-r/The-python-workbook-solutions
/ex77.py
234
4
4
string = list(input('Enter the binary: ')) cnt = 0 decimal = 0 if string.pop() == '1': decimal += 1 while string != []: binary = string.pop() cnt += 1 if binary == '1': decimal += pow(2, cnt) print(decimal)
51244ef9ddf6a172919175585bab2ea47af78fbd
daianarodrig20/PythonProyects
/DataStructure/Iterator_DoublyLinkedList.py
1,930
4.40625
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ - Los iteradores fueron inspirados en los punteros, imitando su sintaxis y uso - El tipo de iterador depende de la estructura de datos sobre la que itera y, a su vez, está limita las capacidades del iterador(por ejemplo, no es buena idea un iterador de acceso a...
37f3e3db27ba275b7f8de4dd3c122dfaecd951d9
Jeemusu/euler-solutions
/33.py
1,525
3.609375
4
from euler import * import time #start timer start = time.time() #question number questionno = 33 #print the problem print_problem(questionno) # # Solution # def is_non_trivial(x,y): if(x[0] == y[0] or x[-1] == y[-1]): return False return True def get_common(x,y): for i in x: if(i in y...
6df45401a34d3beae3790f373f0042622e77a9a8
mi-kei-la/holbertonschool-higher_level_programming
/0x07-python-test_driven_development/3-say_my_name.py
630
4.5
4
#!/usr/bin/python3 """ Single function module. This function prints a name. """ def say_my_name(first_name, last_name=""): """This function prints "My name is " followed by user given parameters. Args: first_name (str): mandatory first name last_name (str): empty string by default Raise...
8ee39000017b8d8bffd3dd11d03e73158efbf90a
yang-official/LC
/Python/1_Lists_and_Strings/5_string_functions/7_reverse_integer.py
535
3.953125
4
# https://leetcode.com/problems/reverse-integer/ # 7. Reverse Integer # Given a 32-bit signed integer, reverse digits of an integer. # Example 1: # Input: 123 # Output: 321 # Example 2: # Input: -123 # Output: -321 # Example 3: # Input: 120 # Output: 21 def reverse(x): if x == 0: return 0 x_list = list...
835cd7d42c7ca773301ea48f9e858df155696bb2
MysticalGuest/Advanced-Python
/CourseReview/calculate_areas.py
794
4.3125
4
"""*************************************************************************** calculate_areas.py Calculate areas of geometric shapes ***************************************************************************""" # To run this program, start python and then type: # calculate_areas...
1dafc47e77d904133b24fb94a1eee4b3afe85d9e
Northwestern-CS348/assignment-3-part-2-uninformed-solvers-dylanjkennedy
/student_code_game_masters.py
8,566
3.59375
4
from game_master import GameMaster from read import * from util import * class TowerOfHanoiGame(GameMaster): def __init__(self): super().__init__() def produceMovableQuery(self): """ See overridden parent class method for more information. Returns: A Fact...
73da709298d7e77a4cd925ac52bffb2737d07fb3
sbcshop/Raspberry-Pi-Webinars
/GUI Development/Example codes/Example11.py
553
4.28125
4
''' Example to learn about image on label ''' from tkinter import * window = Tk() # to change the title of window window.title('My GUI') # create a image twitter = PhotoImage(file='/home/pi/Downloads/twitter.png') # to create a label w1 = Label(window, image=twitter) w1.grid(row=0, column=0) w2 = Label(window, ...
ec299a7ab2189c6ae2b192190aa64cf7cbf4af23
aly22/cspython
/week7_functions/week7_assesment1.py
453
3.828125
4
# 1 def int_return(n): return n # 2 def add(n): n += 2 return n # 3 def change(s): s += "Nice to meet you!" return s # 4 def accum(lst): accum = 0 for num in lst: accum += num return accum # 5 def length(lst): if len(lst) >= 5: return "Longer than 5" ...
29d0ab37ba4fa13e332a9d234317c54af8b034a3
sanskruti01/Social-Book
/Social Book App/User-Scan.py
735
3.734375
4
import csv from getpass import getpass def main(): with open("users.txt","r") as file: fileReader=csv.reader(file) user_find(fileReader) file.close() def user_find(file): user=input("Username:") userpass=getpass("Password:") for row in file: for field in row: ...
8aea3d4fe8c51cf924a61c349222eabd6e2b0210
RahulTechTutorials/PythonPrograms
/Lists/mergesort.py
823
4.03125
4
def merge(lst1,lst2): sortedlst = [] while len(lst1) != 0 and len(lst2) != 0: if lst1[0] < lst2[0]: sortedlst.append(lst1[0]) lst1.remove(lst1[0]) else: sortedlst.append(lst2[0]) lst2.remove(lst2[0]) if len(lst1) ==0 : sorte...
79098cc7dcc02a259263cdd3344585c2acaa5974
astilleman/MI
/4_lijsten_samenvoegen.py
996
3.671875
4
""" Schrijf een programma dat gegeven twee lijsten deze in een lijst samenvoegt waarvan de elementen alterneren. Dus als de eerste lijst [1, 4, 9, 16] is en de tweede lijst [9, 7, 4, 9, 11] dan wordt het resultaat [1, 9, 4, 7, 9, 4, 16, 9, 11] Je mag de lijsten hier direct in het geheugen plaatsen en hoeft...
d38a9dc39ebff3288361cfb92f642896001afc18
kien6034/CSFoundation
/1_Array/7_rotate_matrix/main.py
762
3.953125
4
#given N x N matrix, write a method to rotate it 90 degree import numpy as np def rotate(mtx): new_matrix = np.zeros(mtx.shape) for i in range(mtx.shape[0]): for j in range(mtx.shape[1]): new_matrix[j, i] = mtx[i, 3-j] return new_matrix def rotate2(mtx): N = mtx.shape[0] ...
c47c83146eff19f5005fc335082bd028f80e47f6
zhsheng26/PythonLesson
/高级特性/5_迭代器.py
1,129
3.984375
4
#!/usr/bin/env python # -*- coding: utf-8 -*- # @Time : 2017/9/14 10:10 # @Author : zhangsheng # 一类是集合数据类型,如list、tuple、dict、set、str等; # 一类是generator,包括生成器和带yield的generator function。 # 可以直接作用于for循环的对象统称为可迭代对象:Iterable # 可以被next()函数调用并不断返回下一个值的对象称为迭代器:Iterator # 生成器都是Iterator对象,但list、dict、str虽然是Iterable,却不是Itera...
e1964de3d4ef5e4280c51fe7e784063e9ecc5b98
Pizzabakerz/codingsuperstar
/python-codes/codes/9.set_example.py
2,663
4.5625
5
# set of integers my_set = {1, 2, 3} print(my_set) # set of mixed datatypes my_set = {1.0, "Hello", (1, 2, 3)} print(my_set) # set do not have duplicates # Output: {1, 2, 3, 4} my_set = {1,2,3,4,3,2} print(my_set) # set cannot have mutable items # here [3, 4] is a mutable list # If you uncomment line #12, # this wi...
859f81af3a0b54aabf828f791b774062820e315f
TopHatCroat/advent-of-code-2018
/day08/first.py
835
3.8125
4
from collections import namedtuple from typing import List class Node(): def __init__(self, num_children: int, num_meta: int, children: List, meta: List[int]) -> None: self.num_children = num_children self.num_meta = num_meta self.children = children self.meta = meta def populate(n...
4d3d59b366e9486c0603af8e8f01b1b4442203b4
MOON-CLJ/learning_python
/llm/exercises_1_3_10_2.py
1,676
3.578125
4
# -*- coding: UTF-8 -*- #b׼ʽ룬ȫűʽ from link_stack import LinkStack def infix_to_postfix(s): result = "" stack_operator = LinkStack(None, 0) for i in s: if i.isdigit(): result += " %s"%i elif i == ")": while True: oper = stack_operator.pop() ...
cfc28297d704b281dfab4e67248493ecd398b456
wwtang/code02
/sortAlgorithm/merge.py
1,354
4.0625
4
""" merge sort """ import random import time N = 20 list1 = [] for i in range(0, N): list1.append(random.randint(0,N-1)) def merge_sort(list2): merge_sort_r(list2, 0, len(list2) - 1) def merge_sort_r(list2, first, last): if first <last: sred = (first+last)/2 merge_sort_r(list2, fi...
d629eab7a46695d766b177e687926e04fca7637b
DreEleventh/python-3-object-oriented-programming
/ch11/formatter_factory.py
4,927
4.625
5
import datetime """ Demonstration of the abstract factory pattern. The abstract factory pattern is used when there are multiple possible implementations of a system that depend on some configuration or platform. The client code requests an object from the abstract factory without knowing the specific class of object ...
521ed65fa9621c6a7a9a3478634a66c6a7cf96c2
devendraingale2/PythonPrograms
/matricesequalornot.py
451
3.703125
4
def areSame(A,B): for i in range(N): for j in range(N): if (A[i][j] != B[i][j]): return 0 return 1 A= [ [1, 1, 1, 1], [2, 2, 2, 2], [3, 3, 3, 3], [4, 4, 4, 4]] B= [ [1, 1, 1, 1], [2, 2, 2, 2], [3, 3, 3, 3], [4, 4, 4, 4]] N=4 ...
5ba6c3b852035c713a529de9562a18c8171ff8da
naikvikrant92/Edabit
/EdaBit/Python/Calculate Exponent.py
145
3.59375
4
def calculate_exponent(num,exp): print("%d raised to the power is %d" %(num,exp) ,num ** exp) return num ** exp calculate_exponent(2,16)
277fb52b5954cb6928465e1448891e1e92a596c6
hernanefabiano/test
/tree.py
1,031
3.84375
4
#! /usr/bin/python class BinaryTree(): def __init__(self,root): self.left = None self.right = None self.root = root def get_left_data(self): return self.left def get_right_data(self): return self.right def set_node(self,value): self.root = value def get_node(self): return self.root def set_r...
0234ee18023033b1c8ef1138e0161a6a74d767d6
SriRam-Macha/HackerRank
/Morgan and a String.py
244
3.9375
4
def morganAndString(a, b): a += "z" b += "z" for _ in range(len(a) + len(b) - 2): if a < b: yield a[0] a = a[1:] else: yield b[0] b = b[1:] # at last ''.joint(result)
4488dda73bf992d7800baaa3696f56b02365a018
Jay23Cee/100_Day_Challenge
/Python/LinkedList.py
1,100
4.0625
4
class Node: def __init__(self, data): self.data = data self.next = None def __repr__(self): return self.data class LinkedList: def __init__(self, nodes = None): self.head =None if nodes is not None: node= Node(data=nodes.pop(0)) self.head = node ...
1f4c2a4888c6ac8c7db51fc7616256402b76d3b7
osantoslucas/PECIFPI
/questao05.py
667
3.96875
4
# recebe os valores correspondentes a largura, altura e comprimento da sala largura = float(input('Insira a largura da sala: ')) altura = float(input('Insira a altura da parede da sala: ')) comprimento = float(input('Insira o comprimento da sala: ')) # calcula os valores de área e volume area_piso = largura * co...
da311cd53ad1ce001e712b1812bf5f06ce2faceb
daniel-schroeder-dev/alien-invasion
/ship.py
1,634
3.984375
4
import pygame class Ship: """A Ship for Alien Invasion.""" def __init__(self, screen, ship_speed_factor): """Initialize the ship and set its starting position.""" self.ship_speed_factor = ship_speed_factor self.screen = screen # Load the ship image and get its rect. se...
a418cfcdbec8910165eacf068f171ec3bf8c0113
scchy/My_Learn
/pyspark/chap2/2_sum_by_reducebykey.py
959
3.625
4
# python 3.6 # author(learning): Scc_hy # original url: https://github.com/mahmoudparsian/pyspark-algorithms/blob/master/code/chap02/sum_by_reducebykey.py # create date: 2019-12-16 # function: sum_by_reducebykey # data: https://github.com/mahmoudparsian/pyspark-algorithms/blob/master/code/chap02/sum_by_groupbykey.log ...
be49cbc795566c6caf11e6d4c5e15ae01537c2a1
aabhishek-chaurasia-au17/python_practice
/DSA/searching/practice/Binary_search.py
760
4.09375
4
""" Given a sorted Integer array , Write a Program to search the target element using Binary Search, If target element is found return the index . Otherwise return -1 . Input : arr = [1,2,3,15,16,19,23,55,1000] , target = 15 Output: - 3 Explanation: Just Use Binary search method Sample : def Binarysearch(arr , target):...
5e6ec02318ad9a993188de8b5cdbcf301b06fc0d
PauloVilarinho/algoritmos
/problemas uri/Problema1168.py
199
3.828125
4
letras = [6,2,5,5,4,5,6,3,7,6] quantity = int(input()) for i in range(quantity): leds = 0 display = input() for j in display : leds += letras[int(j)] print("%d leds" %leds)
19a586bc8cb8bc3150652b0fe2757834d4ea1a77
Michael-vdL/ANS_State_Machine
/workshop/SM_Transition_Editor.py
6,547
3.671875
4
# Proto def workshop_transition_editor(current_trans_dict, start_trans_dict): trans_dict = {} print("#################################") print("Welcome to Transition Editor") print("#################################") choice = input("What would you like to do? (New, Edit, Remove, List, Exit, No ...
589e1b06531e1162c2380cc6893946f3c8ab8214
alexgreendev/python-project-lvl1
/brain_games/games/even.py
308
3.5625
4
import random from typing import Tuple def get_description(): return 'Answer "yes" if the number is even, otherwise answer "no".' def make_question_with_answer() -> Tuple[str, str]: question = random.randrange(1, 100) answer = 'no' if question % 2 else 'yes' return str(question), answer
300314ee19a71a9278561704e2a0327ee07cd6d1
AtharvaTiwari56/guessing-game
/guessingGame.py
504
4.0625
4
import random number = random.randint(1, 9) chances = 5 while chances != 0 : guess = int(input('Try to guess the number: ') ) chances= chances - 1 if guess == number: print('WOW! YOU WON!') break elif guess < number: print(number, ' is too low, try guessing some...
47db0a102f68f3597c1675a744aa9bb4c2801556
camilooob/holbertonschool-higher_level_programming
/0x07-python-test_driven_development/4-print_square.py
558
4.34375
4
#!/usr/bin/python3 def print_square(size): """ ''def print_square(size):'' Always is a entiger number. If the number is float, this number need be close and positive.""" if type(size) not in [int, float]: raise TypeError("size must be an integer") elif type(size) is float and size < 0: ...
9d67f96287902743eb71165d53333311a464633c
leeo1116/PyCharm
/Algorithms/leetcode/107_binary_tree_level_order_traversal_II.py
1,304
3.8125
4
__author__ = 'liangl2' from collections import deque # Definition for a binary tree node. class TreeNode(object): def __init__(self, x): self.val = x self.left = None self.right = None class Solution(object): def levelOrderBottom(self, root): """ :type root: TreeNode ...
736bbf6541039928564f8fb54e3351caba2a4795
chaoticgoodpanda/simple-banking-tuples-dicts
/submit/bank_accounts_tests.py
4,755
3.734375
4
import unittest from bank_accounts import * class BankAccounts_Tests(unittest.TestCase): # runs before each function starting with 'test_' def setUp(self): #attach test data to self self.bank_accounts = init_bank_accounts('accounts.txt', 'deposits.csv', 'withdrawals.csv') def test_init_...
5da9a16e3ce0844315429449a91f036e50252acc
rakeshsukla53/interview-preparation
/Rakesh/graph-theory-algorithms/topological_sorting_important_cycle_find.py
1,198
4.03125
4
# In topological sorting you can have different sorting order from collections import deque def topological_sorting(graph): topological_order, elements, state = deque(), set(graph), {} def dfs(node): state[node] = 'V' # V stands for visited for k in graph[node]: sk = state.get(k,...
5af06a60b378563cc886491c503d268d534789e1
AndrejLehmann/my_pfn_2019
/Vorlesung/src/Basic/findall.py
172
3.703125
4
#!/usr/bin/env python3 import re s = 'cruel world' print(re.findall(r'\w+',s)) print(re.findall(r'...',s)) print(re.findall(r'(...)',s)) print(re.findall(r'(..)(..)',s))
5fa5fd3b7dea78f75f8498a36b8ee0bd56e64cc4
johngalt191/PythonHomework
/practical_tasks/session1.py
1,953
3.84375
4
#task1.1 def replace_quotes(input_string): return input_string.translate( input_string.maketrans({"'":'"', '"': "'"}) ) str = input('write text with \" or \' and press enter: ') print(replace_quotes(str)) #task1.2 def palindrome(pl): if pl == pl[::-1]: print('This is palindrome') else:...
37da9b3163de54628d15f54edec18ec148fccdef
SeraphDev6/python_bank_app
/user.py
1,074
3.53125
4
from bank_account import Bank_Account class User: def __init__(self,name,email): self.name=name self.email=email self.accounts=[] self.create_new_account() def make_deposit(self,amount,account_index=0): self.accounts[account_index].deposit(amount) return self ...
8257969c69aafa1bdf210b25fd151fc84fad24c0
Liza-c/skillup
/lesson3-4_28-06/1.py
592
4.3125
4
""" Написать функцию-декоратор, которая подносит к квадрату значения, которое возвращает функция, к которой декоратор применяется. """ def decorator_sqare(func): def wrapped(arg): res = func(arg) print(f"Число {arg} в квадрате: {res**2}") return wrapped @decorator_sqare def function(number): ...
8aa581bddb496770fcf8b797e4b2851b2230f09b
krishna-rawat-hp/PythonProgramming
/data types/codes/testdatatypes.py
215
3.953125
4
#decalre and initialize variables a = "Hello python" b = 10 c = 25.50 # Print datatypes unsing type() method print("Data type of a: ", type(a)) print("Data type of b: ", type(b)) print("Data type of c: ", type(c))
da807d67082977600e93c0b1cc6b0b40e853f6ac
srihariprasad-r/workable-code
/500_Practise Problems/increase_decrease_subarray.py
1,160
3.65625
4
""" Differences between number of increasing subarrays and decreasing subarrays in k sized windows nums = {10, 20, 30, 15, 15}; Output: 3, 0 , -1 """ def decreaseincreasearray(x, k): inc_lis = [1] * (len(x) -1) dec_lis = [1] * (len(x) -1) same_lis = [1] * (len(x) -1) window_dict = {} inc_count= 0...
f5c628fce14ac8d0367f6a565509cc1f0a73aeaf
htphuc/12StepsToNavierStokes
/step6/2D_NonlinearConvection.py
1,799
3.59375
4
# Step6: 2D Nonlinear Convection # the ecuations to be solved are: du/dt + u*du/dx +v*du/dy = 0 # dv/dt + u*dv/dx +v*dv/dy = 0 # in this equation we have the acumulation and convection terms # but this time the convection is nonlinear and the equations are coupled # this time the problem...
8d9d7a3d0261c267926e05c280d42e4b19a88b1f
charlottegiseleweil/MOOCs
/DS.py.1.Intro/assignment2 copie.py
4,110
3.671875
4
def answer_one(): maximum = max(df['Gold']) return df[df['Gold']>= maximum].index[0] answer_one() def answer_two(): biggest_diff = max(df['Gold']-df['Gold.1']) return df[(df['Gold']-df['Gold.1'])>= biggest_diff].index[0] answer_two() def answer_three(): #Only include cou...
185f0b360bcd73507ca49806e01aaa1547acda7d
Bennito14/Pagnia_web
/Python programas/programa 1.py
466
4
4
('\n Registro 2021 \n') registro = [] si=1 while si <= 3: eleccion = input('Desea agregar un nuevo usuario(si/no): ') if eleccion == 'si': usuario=input('Ingrese el nuevo nombre de usuario: ') registro.append(usuario) elif eleccion == 'no': print('Muchas Gracias, vuelva pronto.')...
8130929c7cf8deb2830edda44be3b046701a3c04
KrishnaManeeshaDendukuri/ProjectEuler
/Problem5 and 6.py
546
3.546875
4
""" #Problem 5 def hcf(a,b): max=1 if (a>b): for i in range(1,b+1): if (a%i==0 and b%i==0): if (max<i): max=i return max else: for i in range(1,a+1): if (a%i==0 and b%i==0): if (max<i): ...
9fdf5baa5d49081238b0901c85eb3e9fbba5663f
lz023231/CX.PY
/字典/字典.py
1,759
4.1875
4
''' 概述:使用键值(Key-value),拥有极快的查找速度 注意:字典是无序的 Key的特性: 1.字典中的Key必须唯一 2。Key必须是不可变的对象 3.字符串、整数等都是不可变的,可以作为Key 4。list不能用Key ''' dict1 = {"tom":60, "lilei":70} #元素的访问 #获取:字典名[Key] print(dict1["lilei"]) print(dict1.get("zunck"))#字典中没有“zunck”,会报错,前面加.get会打印None #添加: dict1["hanmeimei"] = 99 #因为一个Key对应一个value,所以,多次对一个value赋值,其实...
f82906747c02aa90a9ad7d124a52984a14d6a7b4
zacdevil10/Advent-of-Code-2017
/AoC day 1.py
394
3.609375
4
total1 = 0 total2 = 0 sequence = str(1122) #Put any sequence here length = len(sequence) for x in range(length): n = int((x + 1) % length) total1 += int(sequence[x]) if sequence[x] == sequence[n] else 0 print("Part 1:", total1) for x in range(length): n = int((x + (length/2)) % length) total2 += int(s...
496103ecafa0bdf694caa5800e6213cc0f35ec67
SimeonTsvetanov/Coding-Lessons
/SoftUni Lessons/Python Development/Python Fundamentals September 2019/Problems And Files/41 PAST EXAMS/Final Exams/09. 20 December 2018 Retake Final Exam/01. Vapor Winter Sale.py
1,115
3.53125
4
""" Technology Fundamentals Retake Final Exam - 20 December 2018 link: https://judge.softuni.bg/Contests/Practice/Index/1394#0 Name: 01. Vapor Winter Sale """ all_games = {} games = input().split(", ") for game in games: if "-" in game: name = game.split("-")[0] price = float(game.split(...
e7cb34a2d84b1dae2137f7663ccc8dc4e58f8765
dhankhar313/Coding
/Python/HackerRank/arrayrotation.py
311
3.765625
4
def rotate(array, ops): i = 0 while i < ops: i += 1 temp = array[0] array.pop(0) array.append(temp) for i in array: print(i, end=" ") size, rotations = [int(i) for i in input().split()] numbers = [int(i) for i in input().split()] rotate(numbers, rotations)
a9f8ea48664c598e9e19c8bba2314b5a9e81add2
waltercoan/ALPC1ano2018
/videos/repeticaoenquanto05.py
956
4.40625
4
'''Faça um algoritmo que calcule a média de todas as turmas de uma escola. Considere como entradas o número de turmas e o número de alunos de cada turma. A média de cada turma deve ser apresentada, além da média geral, que será o resultado da média das turmas.''' print("Digite o número de turmas") numturmas = int(input...
c53ee26e6219aeaf0eb5806a682fb471fc30bab7
jancyranij/python
/pgm14.py
232
4.09375
4
print("DISPLAY ODD NUMBERS BETWEEN 2 INTERVALS") a=int(input("enter the number")) b=int(input("enter the number")) if(a<=100000)&(b<=10000): for x in range(a,b+1): if(x%2!=0): print(x) else: print("invalid")
c9ad73068b0021bf9281a853f1253aa53060e2df
loide/hackerrank
/python/exercise5-3.py
1,377
4.5625
5
""" Think Python by Allen B. Downey http://thinkpython.com Exercise 5.3 Fermat's Last Theorem says that there are no positive integers a, b, and c such that aˆn + bˆn = cˆn for any values of n greater than 2. 1. Write a function named check_fermat that takes four parameters - a, b, c, and n - and that...
9d7cdd7fd77dcf0fb123e2078c0753b4e6b24d4d
rkeable/common_operations
/basic_math.py
1,122
3.921875
4
import numpy as np from __future__ import division # now will show decimals in division addition = 5 + 5 subtraction = 5 - 5 multiplication = 5 * 5 division = 5 / 5 exponiation = 5**5 modulo = 5%5 # modulo is the remainder print addition print subtraction print multiplication print division print exponiation pri...
bc9e992f25c5fab736abb94c1b7e24ed204a5bbd
its-me-sv/Solutions-For-Project-Euler-s-Problems
/Largest_Product_In_Series/workout.py
470
3.625
4
from time import time def iterativeSolution(n, k): start = time() def getProduct(lst): product = 1 for no in lst: product *= no return product no = [int(i) for i in str(n)] maxProduct = 0 for i in range(len(no) - k): prodLst = getProduct(no[i:i+k]) if prodLst > maxProduct: maxProduct = prodLst pr...
0cf6b90ab9e3f15dd5f8e79bd2e80f84f799dfa6
pengyuhou/git_test1
/leetcode/141. 环形链表(again).py
408
3.6875
4
# Definition for singly-linked list. class ListNode: def __init__(self, x): self.val = x self.next = None class Solution: def hasCycle(self, head: ListNode) -> bool: ret = [] cur = head while cur: if cur not in ret: ret.append(cur) ...
dcfccbed28a2660fbdb1fac1b813c4c098c9ae58
rohitsuv/Project-Euler
/euler71.py
613
3.625
4
class Fraction(object): def __init__(self,num,den): self.numerator = num self.denominator = den self.value = num/float(den) def __lt__(self,other): return self.value < other.value def __str__(self): return " (%d / %d )" % (self.numerator,self.denominator) def __repr__(self): return self.__str_...
1e290dd2934fb534bebb864753fec8bd336a6a23
dzinrai/my_euler_proj
/e19.py
1,763
3.796875
4
2000 year = [1,2,3,4,5,6,7,8,9,10,11,12] list_years = [] list_mon = [] visoc = False for years in range(1900,2001): if years % 4 == 0: visoc = True if years % 100 == 0 and years % 400 != 0: visoc = False else: visoc = False list_mon = [] for month in year...
f0de62da3051c0266ae4d17505b133bf07267bba
aleksanderhan/ProjectEuler
/fibonacci_benchmark.py
716
3.84375
4
from time import time import fibonacci as pf import cFibonacci as cf n = 1000000 t1 = time() pf.ifib(n) t2 = time() cf.ifib(n) t3 = time() print print "n=" + str(n) print "Iterative fibonacci time in Python: " + str(t2-t1) print "Iterative fibonacci time in C: " + str(t3-t2) print "C/Python ratio: " + ...
732a1f1edc5c0bd51d46889c6a093ac656f20f60
shiraz19-meet/meet2017y1lab4
/caght_speeding.py
373
3.96875
4
speed=50 is_birthday=True if is_birthday: if speed<36: print("ticket") elif speed>35 and speed<56: print("small ticket") elif speed>55: print("big ticket") else: if speed<31: print("ticket") elif speed>30 and speed<51: print("small tic...
1788a9b7575b90b7ba3d28ebcd59b3f85412585d
nghia992004/C4T39-Nam-Nghia
/season7/dagiac.py
154
3.734375
4
from turtle import * n = int(input("So canh ma ban muon:")) shape ("turtle") for i in range(n): forward(200) right(180-((n-2)*(180/n))) mainloop()
0f450938e1088fe5bc6d7364b1d2677d20f98ce0
indraputra147/belajarpython
/evenodd35.py
125
4.28125
4
x = int(input("Enter a number : ")) if x % 2 == 0: print("It's an even number!") else: print("It's an odd number!")
1fe13ea7ca4da27dc0f26ec4089d8b53ff70a178
lizooo/Algo-lab-1
/managers/insertion_sort.py
1,083
3.796875
4
from timeit import default_timer as timer from datetime import timedelta class InsertSort: def __init__(self, swap_count=0, comparison_count=0): self.swap_count = swap_count self.comparison_count = comparison_count def insertion_sort(self, entry_list, key=lambda obj: obj): ...
7e214a8921423c300bc17b88568d96161fa29999
vijay-14/fluent-python
/14-it-generator/comb_genfun_Stdlib.py
351
3.59375
4
import itertools # The combinations, combinations_with_replacement and permutations generator # functions — together with product — are called the combinatoric generators in the # itertools documentation page list(itertools.combinations('ABC',2)) list(itertools.combinations_with_replacement('ABC', 2)) list(itertool...
04a374b678dc78b9a8f96f7ea1b7261a03b1be71
HenriqueHideaki/100DaysOfAlgo
/Day 97/1.py
3,801
3.703125
4
''' class MinHeapNode: def __init__(self, data, freq): self.data = data self.freq = freq self.left = None self.right = None ''' import heapq minheap = [] heapq.heapify(minheap) cnt=0 codes = {} freq = {} class MinHeapNode: def __init__(self, data, freq): self.data = dat...
8a5bebf6758cef26f575bfb4a2178b0a81852a41
uhrwecker/extrem-epic-excessive-enthusiastic-elf-elevator-1
/classes/alignment.py
1,404
3.640625
4
class Alignment(): ''' Interface for creating an Alignment. Needs a method for adjusting the Base stats. ''' def __init__(self, verbose=False): self.verbose = verbose def adjust_stats(self, HP, STAM): ''' Adjust the HP and STAM (stats) that you can get from the r...
dd318a348215dce4d309d5a4d47d5d47ed6ca49f
NobuyukiInoue/LeetCode
/Problems/0100_0199/0117_Populating_Next_Right_Pointers_in_Each_Node_II/Project_Python3/Populating_Next_Right_Pointers_in_Each_Node_II.py
2,687
3.546875
4
# coding: utf-8 import os import sys import time from Node.Node import Node from Node.OperateNode import OperateNode class Solution: def connect(self, root: 'Node') -> 'Node': # 52ms node = root tail = dummy = Node(0) while node: tail.next = node.left if ta...
76a113cf27c360d1ff9818c45912597c54b50b12
JackKoLing/python_study_notes
/Other-Python-Notes/L11.py
2,645
4.1875
4
# coding : utf-8 """ 学习元组tuple、访问 """ tuples = ('x' , 'y' , 'z') # 也可以写成 tuples = 'x' , 'y' , 'z' 括号或没有括号的是元组,[]是列表 print(tuples) print(type(tuples)) tuples1 = () # 空元组 tuples2 = (123) # 这个是整数类型 tuples3 = (123 , ) # 这个才是元组,一个元素的元组必须加逗号,但是一个元素的列表不用逗号 print(type(tuples3)) print(tuples[1]) # 访问和列表是一样的,用 [i] # tuples[1]...
1d52ae45bf697d4b71830543334ffc49dc5ca229
mibri/project-fa19
/solver.py
6,433
3.59375
4
import os import sys sys.path.append('..') sys.path.append('../..') import argparse import utils """ Student Imports """ import networkx as nx from networkx.algorithms import approximation import matplotlib as plt import math import random from student_utils import * """ ==============================================...
2dbc93522248bd6dcbf54f2c8f3320a3e6893324
oJacker/_python
/pandas_code/essential_functionalty/axis_indexes_with_duplicate_values.py
351
3.59375
4
# -*- coding: utf-8 -*- import numpy as np from pandas import Series, DataFrame print('重复的索引') obj = Series(range(5), index=['a', 'a', 'b', 'b', 'c']) print(obj.index.is_unique) # 判断是非有重复索引 print(obj['a']) df =DataFrame(np.random.randn(4,3), index= ['a', 'a', 'b', 'b']) print(df.ix['b'].ix[0]) print(df.ix['b'].ix[1...
9ebf88c578d216e4eca43365fe3e796dcffbe951
AjaySingala/July2021BigDataPython
/SparkSamples/pyspark_foreach.py
2,028
3.765625
4
# pyspark_foreach.py from pyspark.sql import SparkSession spark = SparkSession.builder.appName('ajaysingala.com').getOrCreate() # Create a dataframe. data = [('James','Smith','M',30),('Anna','Rose','F',41), ('Robert','Williams','M',62), ] columns = ["firstname","lastname","gender","salary"] df = spark.createDataFra...
44599b96d69aa553518af0db383f5537057ec565
logd-py/simple-calc
/python-progs/understanding_function.py
768
3.59375
4
# this is a program to expalin function #importing datetime module import datetime #importing getpass module for getting username imput import getpass cdt=datetime.datetime.now() x=cdt.hour print("Today's Date is", cdt.strftime('%d/%m/%Y')) print("current time is ",cdt.strftime('%H:%M:%S')) print("") #print(cdt.strf...
c47ce002c557379df96587dfb9181a6ad20bd707
hegde10122/DSA_PYTHON
/sorting/mergesort.py
2,575
4.375
4
import time from merging_lists import * # takes in a list or array of integers as the input parameter # uses the divide and conquer strategy # solve each part seperately # combine the solutions efficiently ''' To sort A[0:n] into B[0:n] If n is 1, nothing to be done Otherwise, Sort A[0:n//2] into L(left) Sort A[n//2:...
3e41643d9568886113dac50982f126fa98df1ed2
sandeepkumar8713/pythonapps
/02_string/08_form_palindrome_with_min_insertion.py
1,543
4.15625
4
# https://www.geeksforgeeks.org/minimum-insertions-to-form-a-palindrome-dp-28/ # Question : Given a string, find the minimum number of characters to be inserted to # convert it to palindrome. Note that insertion can be in start, middle or end. # ab: Number of insertions required is 1. bab # aa: Number of insertions req...
2b7db5e70b1fd443187db8673b58f3fb20e718d4
frclasso/Python3-essential-training-Bill-Weinman-2017
/05-Variables-Objects-Values/variables2.py
350
4.25
4
#!/usr/bin/python def main(): n = 42 s = "This is the number {} ".format(n) # Python3 s2 = "This is the number %d " % n # Python2 - obsoleto mystring = '''\ this is a string line after line of text and more text. ''' print(s) print(s2) print() print(mystring) if...
de9b38e56cc2dc25a81684485380c68c4e636f88
cooper-mj/Nifty-Coding-Projects
/ics_parser.py
3,388
3.671875
4
''' File: ics_parser.py Author: Michael Cooper Description: This file parses .ics files, and extracts the email addresses of non-organization employees who have sent and received invitations to events on the calendar. ''' import re def isOrganizationEmail(oragnization, email): ''' Returns whether or not the ...
0959cfc0aa115493290fb8c221dc78bb236cc57c
NanoClem/Graph_Langage
/ProjAlgo/Schedule.py
2,790
3.546875
4
""" creator : decoopmc """ import datetime from datetime import time class Schedule : """ Cette classe definie les horaires d'un bus, pour les heures regulieres et week-end/vacances, pur chaque arret """ def __init__(self, num, regularGo={}, regularBack={}, weHolidaysGo={}, weHolidaysBack={}...
a522b8f0da6b8518d0530940719e528fcd248c58
gabywang/cs61a
/demo/18.py
3,271
4.0625
4
"""Linked lists""" class Link: """A linked list. >>> s = Link(3, Link(4, Link(5))) >>> len(s) 3 >>> s[2] 5 >>> s Link(3, Link(4, Link(5))) >>> s.first = 6 >>> s.second = 7 >>> s.rest.rest = Link.empty >>> s Link(6, Link(7)) """ empty = () def __init__(s...
618dd63c441845658b445c7adaf0ad940cba0979
ia7ck/competitive-programming
/AtCoder/abc238/src/bin/e/generate.py
254
3.6875
4
import random n = random.randint(1, 10) q = random.randint(1, min(10, n * (n + 1) / 2)) print(n, q) lr = set() while len(lr) < q: l = random.randint(1, n) r = random.randint(l, n) lr.add((l, r)) for l, r in lr: print(l, r)
35ddb8da48c3d6724b5a2092073f0315009922a3
gabriel-portuga/Exercicios_Python
/ex022_analisandotexto.py
507
3.96875
4
print('Seja bem vindo!') nome = input('Digite seu nome completo: ').strip() print('Seu nome em maiusculo é: ', nome.upper()) print('Seu nome em minusculo é: ', nome.lower()) # semEspaco = nome.count(' ') # comEspaco = len(nome) # total = comEspaco - semEspaco # print('Seu nome tem {} letras ao todo'.format(total)) pr...
e2e818b59bac7eeaa8df8c34101a8ddf8ed61f71
YJL33/LeetCode
/old_session/session_1/_151/python/_151_redo.py
1,705
3.828125
4
""" 151. Reverse Words in a String Total Accepted: 141210 Total Submissions: 898175 Difficulty: Medium Contributors: Admin Given an input string, reverse the string word by word. For example, Given s = "the sky is blue", return "blue is sky the". Update (2015-02-12): For C programmers: Try to solve...
0ab7c7cc83865799418fd5a306ec1144a9032f69
crystallopezz/hackbright-homework
/underpaid-customers/accounting.py
1,525
4.34375
4
def incorrect_payment(customer_orders_file): '''incorrect_payment should take the file of customers and return if any of the customer did not pay the correct price for melons for each customer, find the customer name find the numbe of melons purchased find how much they paid find out how much ...
3966b222b9d3a38220cb84e62dec288bc045d4f7
J-Greenlee/numpy
/numpy_exercise.py
237
3.59375
4
import numpy as np import random grades = np.random.randint(60,101,12).reshape(3,4) print(grades) print("ALl grades: ",grades.mean()) print("Avg by each test: ",grades.mean(axis=0)) print("Avg by each student: ",grades.mean(axis=1))
3c3c94fdcc20774b63d664c39cc0d692f535b930
henrylin2008/Python_Bootcamp
/lists.py
5,638
4.84375
5
Lists Earlier when discussing strings we introduced the concept of a sequence in Python. Lists can be thought of the most general version of a sequence in Python. Unlike strings, they are mutable, meaning the elements inside a list can be changed! In this section we will learn about: 1.) Creating lists 2.) Indexing a...
60aa356338f9b4353bf1b0b4b72169179011d9ac
hetvaghela/FLASK-TUTORIAL
/createtable.py
286
3.734375
4
import sqlite3 conn = sqlite3.connect('database.db') data = conn.execute("select * from Employees") for row in data: print ("ID = ", row[0] ) print ("NAME = ", row[1]) print ("ADDRESS = ", row[2]) print ("SALARY = ", row[3], "\n") conn.close()
2f66ad0daa8bc662ec7757961432d51ce263f80f
AbhinavSingh-21f1002369/ns_21t2_cs1002-ProgrammingAssignments
/week1/PPA4.py
38
3.65625
4
num = int(input()) print((3**35)//num)
05d280432c37980565076329a3210fddaabd380a
checimovic/project_euler
/python/euler_35.py
1,392
3.859375
4
#! /usr/bin/python # Project Euler problem 35 # http://projecteuler.net/problem=35 def isprime(n): # 0 and 1 are not primes. if n < 2: return False # 2 is the only even prime number. if n == 2: return True # All other even numbers are not primes. if not n & ...
20b6b39e724fd02c425df784d693243794c36439
eopr12/pythonmine
/st01.Python기초/py14리스트/py14_ex01_리스트연습.py
3,558
3.765625
4
############################ # 리스트의 CRUD2S 사용법을 익힌다. # 리스트에 담을 수 있는 것은? ==> 다 # 리스트 선언 ==> [] , list() # 리스트 추가(C) ==> .append(), .insert() # 리스트 읽기(R) ==> [방번호] # 리스트 수정(U) ==> [방번호] = 값 # 리스트 삭제(D) ==> .pop() # 리스트 정렬(S) ==> sorted() # 리스트 정렬(S) ==> .find() + 반복문 , .rfind() + 반복문 # 리스트 길이 ==> len() ###############...
8d94a8208268782686092b093023e00c606ad914
Soobe/nguyentheanhvu-fundamental-c4e20
/Session01/circle_area.py
63
3.6875
4
r = int(input("Radius ?")) area = 3.14 * (r**2) print(area)
a94faf86d60b45b53371bd527c87125c91e69638
SwathiChandran/Wizards
/reading_csv.py
289
4.09375
4
import csv def reading_csv(): csv_name=raw_input("enter the csv file name:") csv_list=[] with open(csv_name,"rb") as f: reader=csv.reader(f,delimiter=",") for line in reader: csv_list.append(line) print(csv_list) f.close() reading_csv()
32b946eb37f5aa79af227ce587a04c08f1c4a00b
eboladev/Study
/ProgrammingLanguage/Python/Lovely Python/CDays/CDay-5/LeapYear.py
363
3.875
4
#! /usr/bin/env python def read() : a = int(raw_input("Please input a number: ")) return a def isLeapYear(a) : if (a%400==0 or (a%4==0 and a%100!=0)) : return True return False def main() : while (True) : a = read() if (isLeapYear(a)) : print "%d is LeapYear." %(a) else : print "%d isn't LeapYear....
7affb98444db4c57c22dfa92e17a2eedda4631b6
aarthinagireddy/Python
/Lab 1/Code/LA3.py
2,215
3.984375
4
class Flight: def __init__(self, flight_number, airways): self.f_n=flight_number self.a=airways def display_flight(self): print("flight number is", self.f_n) print("airways is", self.a) class Employee: def __init__(self, employee_id, employee_name, employee_gender): ...