blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
c226d699c20039120e6a6fd4a6d763d7855ed109
Pigslayerbear/bank_account
/Bank Security.py
13,753
3.796875
4
import hashlib import os.path accounts = {} salts = [] #------------------------------------------------------------------------------------------- def has_num(password): numbers = "1 2 3 4 5 6 7 8 9 0".split(" ") for character in password: if character in numbers: ...
ab8bff5afc1046f76fe1864036076de78837d356
beOk91/code_up
/code_up1620.py
278
3.78125
4
def f(num_list): result=num_list while True: result2=0 for i in range(len(result)): result2+=int(result[i]) result=str(result2) if len(result)==1: break return result num_list=input().strip() print(f(num_list))
cb9686c76b0b788f784e3e24ac1bd4a1dd6c8a17
ramyasutraye/python_programming-1
/player/vowels.py
114
3.984375
4
a=input("enter the letter") if a in range('a','e','i','o','u'): print("vowels") else: print("consonants")
d1cf9bfc8722cb8c7ca0fb410a1e4a0e21f6f9cc
paynesa/bilingual-vot
/data_processing/parse_childes_dir.py
1,745
3.8125
4
""" Written by Sarah Brogden Payne, Novemeber 2020 Processes all files produced by a 2-year-old in a given directory and outputs the results to a text file containing only the child's productions""" import os import argparse def process(dir : str, out_file : str, speakers: int): """Process the data in the input ...
e188903d11c8c65abdc8ef112408f550b86182ee
ksamokhin/python
/Lesson1/task5.py
822
3.796875
4
cost = int(input('Какие издержки у вашей компании? ')) proceeds = int(input('Какая выручка у вашей компании? ')) if proceeds > cost: rent = (proceeds - cost) / proceeds * 100 print('Поздраляем Ваша компания в плюсе. Рентабельность выручки составляет %.2f' % (rent)) staff = int(input('Сколько сотрудников в ...
ef03cc61a60496c7c3e1431b572c6b875a422f3d
AkshdeepSharma/Classroom
/Kattis/anotherbrick.py
440
3.71875
4
def goodBricks(bricks, h, w): curr = 0 for i in range(len(bricks)): curr += bricks[i] if curr == w: curr = 0 if h - 1 == 0: return "YES" h -= 1 if curr > w: return "NO" def main(): h, w, n = map(int, input().split()) ...
45edc5d679b2219b25b80ad6319070d85b4a6bd7
leofigs/bag
/bag/console.py
2,035
4.09375
4
# -*- coding: utf-8 -*- '''Functions for user interaction at the console.''' from __future__ import (absolute_import, division, print_function, unicode_literals) from nine import str, input def ask(prompt='', default=None): if prompt: if default: prompt = prompt + ' [...
72ab0580eb4d699e5e64f8b7eb8544b466ee1127
joedeller/pymine
/findtreasure.py
5,294
4.125
4
#! /usr/bin/python # Joe Deller 2014 # Minecraft find the treasure chest game # Level : Intermediate # Uses : Libraries, variables, operators, logic, loops # First the libraries we will be using in the game # We want a random number helper to hide our treasure, # the time library so we can wait a bit before telling...
04191b4c1fd7ee006cf2a601f3dbebc351b15d02
wangzhiqing999/my-python-sample
/A0031_BasicControl/for.py
1,287
3.75
4
# coding:utf-8 # for 的测试. # Python 中的 for, 与 C/C++ 中的 for(int i=1; i < 5; i++) 不同. # Python 中的 for, 相当于 C# 中的 foreach(int i in new int[]{1,2,3,4}) # 这里的 range返回一个序列的数。 # 这个序列从第一个数开始到第二个数为止。 # 例如,range(1,5)给出序列[1, 2, 3, 4]。 # 默认地,range的步长为1。 # 如果我们为range提供第三个数,那么它将成为步长。 # 例如,range(1,5,2)给出[1,3]。 # 记住,range 向上 延伸到...
fcc8231a3b482839283daf7763c58ef516107dea
Delizald/crafting-quality-code
/Week-5/Assignment/a2.py
7,980
3.953125
4
# Do not import any modules. If you do, the tester may reject your submission. # Constants for the contents of the maze. # The visual representation of a wall. WALL = '#' # The visual representation of a hallway. HALL = '.' # The visual representation of a brussels sprout. SPROUT = '@' # Constants for the directio...
d094f7a1e8e684563e229e98f020f9cc10dcadfa
MikayelB/Learning_Python
/CS EX/max_and_min_of_a_list_another_way.py
291
3.90625
4
mylist = [] for i in range(0 , 10): mylist.append(int(input("Please input a number"))) minnum = mylist[0] maxnum = mylist[0] for character in mylist: if maxnum < character: maxnum = character elif minnum > character: minnum = character print(maxnum) print(minnum)
ef38684b29ee51efa6538c9f58c1fa72b44d2674
Pratik3199/Python
/DMY.py
228
3.984375
4
#Pratik Singh d=int(input("Date")) m=int(input("Month")) y=int(input("Year")) old_year=(2018-y) print("Your Date of Birth is",d,"-",m,"-",y) print("Your current year is", old_year) if(old_year > 32): print("Your are my uncle ")
87eae0f1d780d25ef9858e59e3b8286139814dd7
jgardner8/NPuzzle
/heuristics.py
1,239
3.921875
4
""" Heuristics estimate cost of the cheapest path from current_state to desired_state to inform search strategies. Each of these are "admissable" - they never overestimate the cost. Each of these are also "consistent" or "monotone" - the value of the heuristic for a given state is less than or equal to the heuristic f...
9a742e8bcd32f2bc03636482444ae37936566ebc
kouyalong/StudyCode
/python_data_structure/leetcode/338.counting-bits.py
562
3.53125
4
# -*- coding: utf-8 -*- from typing import List class Solution: def countBits(self, num: int) -> List[int]: ret = [0, 1] if num <= 1: return ret[:num+1] flag = 1 for i in range(2, num+1): if (flag << 1) == i: flag = flag << 1 ...
8695397674c684d4366acfc273c8ba83566dca4e
omarakamal/Teaching-Python
/optional Parameter.py
263
4.46875
4
#optional parameters def func(x, text='2'): #optional parameter is putting = after the variable to give it n optional parameter print(x) if text == '1': print("text is equal to 1") else: print("text is not equal to 1") func('hello')
551701b2d4bfa24846173e63e498258acdcd9754
sudo-sunil/pstem
/pstem.py
7,604
3.828125
4
s=input().lower() #print(s) l=[] m=0 vowels=['a','e','i','o','u'] def vowel_or_not(x): if x in vowels: return True elif x=='y' and len(l)>=1 and l[-1] == 'c': return True else: return False for i in range(len(s)): if vowel_or_not(s[i]) == True: l.append('v') else:...
8947b3b13a3af7bb5af28661a8785726981f3486
Cjz-Y/shuati
/leetcode/450.py
2,168
3.5625
4
from leetcode.TreeNode import TreeNode class Solution: def deleteNode(self, root: TreeNode, key: int) -> TreeNode: if not root: return None if key == root.val: if not root.right and not root.left: return None if root.right: succes...
fe3e26620ba139639d3d2342715d173ef82e8293
kondrashov-do/hackerrank
/algorithms/implementation/apple_and_orange.py
927
3.796875
4
#!/bin/python3 import os import sys def fruit_count(s, t, tree_postion, fruits): fruit_count = 0 for fruit in fruits: fruit_position = tree_postion + fruit if fruit_position >= s and fruit_position <= t: fruit_count += 1 return fruit_count # # Complete the countApplesAndOrange...
02a0be652cfbdc499933ef879c920672c33e46ff
ageekymonk/playground-1Kk9xRSj
/python-project/collections_defaultdict.py
194
3.546875
4
from collections import defaultdict addressbook = defaultdict(lambda: "unknown") addressbook['jason'] = {'name': 'jason bourne', 'age': 40} print(addressbook['jason']) print(addressbook['ironman'])
2a75500ad98cf1673bbdcad31f347a8cc14959dc
Upasana360/All-My-Python-Programs
/is_evenfun.py
119
3.890625
4
def is_even(n): if n%2==0: return "Even" else: return "Odd" print(is_even(6)) print(is_even(5))
f97c8286b536ec0a53a446170d7c870b3461614b
JBielan/leetcode-py-js
/python/binary_linked_list.py
509
3.734375
4
class Solution: def getDecimalValue(self, head: ListNode) -> int: binary = '' # binary representation will be stored here while True: # it's infinite loop but there's break in the end to check the condition in the end binary += str(head.val) # add digit to binary representation head = head.next ...
04eab4e7f645fa33c4cee703ed892fac1f1027a5
dinkarjuyal/algorithmic-toolbox
/assignment 1/_ae30a0104a8cbaedfb1b770d1905238a_01_introduction_starter_files/fibonacci_last_digit/fibonacci_last_digit.py
363
3.890625
4
# Uses python3 import sys def get_fibonacci_last_digit_naive(n): f=1 s=1 t=1 if n <= 1: return n i=2 while i < n: t = (f + s)%10 f = s%10 s = t i += 1 return t if __name__ == '__main__': input = sys.stdin.read() n = int(input) ...
0fd78c1c2b3db81b47043e87b9febd2544d3f2e9
abinesh1/pythonHackerRank
/sets/prob36.py
262
3.828125
4
## https://www.hackerrank.com/challenges/py-the-captains-room/problem k, rooms = input(), input().split() single, multiple = set(), set() for room in rooms: single.add(room) if room not in single else multiple.add(room) print(*(single.difference(multiple)))
4f41c48a604d5046e1a5e698005397c3a5e2b9d4
ekomissarov/edu
/py-basics/based_on_tutorial/5_list_construct.py
399
4.03125
4
#https://docs.python.org/3/tutorial/datastructures.html#list-comprehensions from math import pi squares = list(map(lambda x: x**2, range(10))) print(squares) squares = [x**2 for x in range(10)] print(squares) a = [(x, y) for x in [1,2,3] for y in [3,1,4] if x == y] print(a) a = [(x, y) for x in [1,2,3] for y in [3,1...
0f88125c54ee6691e4b8a369ca38f9c8d5358fed
RFSOU/Curso-Python
/exercicios/exercicio_042_elif.py
790
4.25
4
'''refaça o desafio 35 dos triamgulos acrescentando o recurso de mostrar que tipo de triangulo sera formado: - Equilatero: todos os lados iguais - Isoceles: dois lados iguais - Escaleno: Todos os lados diferentes ''' a = float(input('Escreva o comprimento da reta 1 =')) b = float(input('Escreva o comprimento da reta 2 ...
0a612ccbdc10da6110453c91e3c471a76690e052
KendiGrace/Python_Bank
/bank.py
1,754
3.765625
4
class Account: def __init__(self,name,number,password): self.name=name self.number=number self.password=password self.balance=0.0 def deposit(self,deposit): if deposit<0: return "The amount has to be greater than zero" ...
acf84155755be09abc1b4041fc0409b3b9bfce70
leprechaunne/leetcode
/167-Two_Sum_II.py
870
3.5
4
""" 167. Two Sum II - Input array is sorted https://leetcode.com/problems/two-sum-ii-input-array-is-sorted/ """ class Solution(object): def twoSum(self, numbers, target): """ :type numbers: List[int] :type target: int :rtype: List[int] """ runner_left = 0 ...
a5c2ec740ecb7f2acca73994f36ae4c3052f366c
HypeDis/leet-code-practice
/easy/168-excel-column-title.py
984
3.96875
4
""" Given a positive integer, return its corresponding column title as appear in an Excel sheet. For example: 1 -> A 2 -> B 3 -> C ... 26 -> Z 27 -> AA 28 -> AB ... Example 1: Input: 1 Output: "A" Example 2: Input: 28 Output: "AB" Example 3: Input: 701 ...
425cc1c10c824a0843178bb06de16efefccf9d19
reticpy/retic
/retic/services/general/time.py
339
3.8125
4
# Time import time def sleep(seconds: int = 0): """The Python sleep () time method suspends execution for the given number of seconds. The argument can be a floating point number to indicate a more accurate sleep time. :param seconds: Total of seconds that the program will be sleeping """ t...
a523db61aa3fa33341d5a392778e50fd0d1f4f97
RustPython/RustPython
/Lib/test/test_string_literals.py
10,209
3.53125
4
r"""Test correct treatment of various string literals by the parser. There are four types of string literals: 'abc' -- normal str r'abc' -- raw str b'xyz' -- normal bytes br'xyz' | rb'xyz' -- raw bytes The difference between normal and raw strings is of course that i...
e6c45ebfd3be10bf9d91922d379b7fd6619031bc
kasm2015/PythonExamples
/TrainingDay1/Day2/interestcalculation.py
656
3.9375
4
''' script name : interestcalculation.py Author : Syed Maqbul Date : 06-Dec-2018 Description : Write a program to enter principl amount,Rate of interest, time as input values from keyboard and calclate simple interest. Note : Formul...
a46b63796813396cf5f27b0c2a94d8e2a901303f
DiyanKalaydzhiev23/OOP---Python
/Polymorphism and Abstraction - Exercise/Account.py
2,158
3.578125
4
class Account: def __init__(self, owner, amount=0): self.owner = owner self.amount = amount self._transactions = [] def add_transaction(self, amount): if not isinstance(amount, int): raise ValueError("please use int for amount") self._transactions.append(amo...
06f292eeada5617dc43f457da543acbcefb72e02
wuli133144/py_learn
/list.py
1,671
4
4
''' simple implentment ''' class ListNode(object): ''' list just for algorithm ''' def __init__(self,v): self.value=v self.next=None def add(self,v): t=ListNode(v) head=self; while head.next != None: head=head.next head.next=t d...
21cbe7d5243b356c492470eee92ed2670a0a5ca8
Bhaktidave/my_first_blog
/function.py
181
3.796875
4
list=["bhakti","mahi","abc"] """def hi(): print("hello") hi()""" """def hi(): for i in list: print("hello"+i) hi()""" def hi(name): print("hie"+name) hi("mahi")
b31e135033c7d9ceb214da99c0ef5f9a79e3d203
gary-liu/python-study
/basic/DistDemo.py
941
4.21875
4
''' 键必须是唯一的,但值则不必。 值可以取任何数据类型,但键必须是不可变的,如字符串,数字或元组。 ''' dict = {"name":"gary",'age':20,'class':'first'} dict1 = {'abc':12,12.3:37} print(dict['name']) print('dict[age]:',dict['age']) dict["age"]= 21 dict['school'] ="luban" print(dict) del dict['name'] print(dict) # dict.clear() print(dict) # del dict print(dict) pri...
0d58004d71fbb13db13d901679d7c649a1b8a9c3
Alexandr-Bessonov/python_basic
/Lesson_03/practical_task_05_3.py
971
3.78125
4
print("This is the solution to task 5 to lesson 3") print('_' * 150) def func_0(str_a): try: str_a.index("q") except ValueError: return -2 return list(str_a.index("q")) def func_1(a): list_a = [] i = 1 while i < len(a): a.pop(i) i += 1 for el in a: ...
6ec4814fd809fb0618c78d6e047ea68b996548b6
luiguiMV/TP3
/operar.py
2,360
3.65625
4
valores=[["x",7],["y",6],["t",[1,2,3,4,5]]] #Funcion que realiza las operaciones hasta llegar al ultimo parentesis def recorrerexpresion(operacion): indice=0 valortemp=0 operando="" bandera=False resultado=0 while indice!=len(operacion): if tipodato(operacion[indice])=="variab...
220c9ef78d59599d12f8778da2f429cd52f1b63c
vaibhavyesalwad/Python-Bootcamp-Programs
/FrequencyCount.py
485
3.984375
4
string = input('Enter string:') words= string.split() for i in range(len(words)-1): min = i for j in range(i+1,len(words)): if words[j] < words[min]: min = j words[min],words[i]= words[i],words[min] print(words) unique = [] for word in words: if word not in unique: uniqu...
66bd4580e197cf0fb2464b57ae50eee12806dc8f
jagadish5729/demo
/maxnum.py
179
4.09375
4
a = [] n = int(input("enter the size of list : ")) for i in range(0,n): ele = int(input("enter element: ")) a.append(ele) print(a) print 'max number in the list is ',max(a)
695272ecc56ea5c78fdfa7391858aea32981f860
Kuldr/G53IDS-EA-Pokemon-Team-Building
/Code/proofOfConcept/sumSquares.py
4,002
3.5625
4
import random from proofOfConcept.sumSquaresIndividual import sumSquaresIndividual class sumSquares: def compareFitness(self, fitness1, fitness2): if( fitness1 <= fitness2 ): return True else: return False def initialiseIndividual(self): #Initialises all the In...
bb25e2b87553854fc92d05ae49445a5bb749e2e2
proTao/leetcode
/8. Tree/094.py
716
3.671875
4
from treetools import TreeNode, stringToTreeNode, prettyPrintTree def InOrderTraversal(root:TreeNode, returnval=True): if root is None: raise StopIteration stack = [] curr = root while stack or curr: while curr: stack.append(curr) curr = curr.left curr = ...
ae1b2923235b0ff9aba6729734d72776bad76f23
Link-God/Algorithm
/queue_array.py
3,643
3.734375
4
from sys import stdin, argv from enum import Enum class StrType(Enum): PUSH = 1 POP = 2 PRINT = 3 SET_SIZE = 4 class Queue: def __init__(self, size): # self.arr = array.array('i', [0] * size) self.arr = [0] * size self.max_size = size self.tail = 0 self.he...
fa6e17369191389a4b42d70006118d9280871658
tkeren/AI
/Computer Vision/Smart Crop/LinkedList.py
1,961
3.796875
4
class node: def __init__(self, data): self.data = data self.nex = None self.prev = None class LinkedList: def __init__(self): self.head = None self.tail = None self.size = 0 def add(self, val): n = node(val) if self.size == 0: ...
917df1c601c73da751431ae7c900afd7e618eade
joe-arriaga/portfolio
/spark_python/16-flatmap/course-word-count.py
577
4.25
4
# course-word-count.py # August 3, 2020 # # Solution script provided by course. # Count the number of occurrences of each word in a text file. # Using the 'Book' text file. from pyspark import SparkConf, SparkContext conf = SparkConf().setMaster('local').setAppName('word-count') sc = SparkContext(conf = conf) line...
00cd9b6793dfa8ddcf22ec462b2aa8acdb93f2d7
eignatenkov/aoc2020
/solutions/day_03.py
1,182
3.859375
4
""" https://adventofcode.com/2020/day/3 """ import numpy as np def line_to_array(line: str) -> np.array: result = np.zeros(len(line), dtype=bool) for i, s in enumerate(line): if s == '#': result[i] = True return result def read_input(filename): """ reads the input file, retur...
86fa00b6c7a745bf3fad734448bc9d4717d8f160
jasminegrewal/algos
/algorithms/heap_sort.py
1,060
3.890625
4
# -*- coding: utf-8 -*- """ Created on Tue Apr 18 11:18:04 2017 @author: jasmine """ def maxHeapify(a,i,heapSize): left=2*i+1 right=2*i+2 if (left<heapSize and a[left]>a[i]): print('left is max') largest=left else: largest=i print('root is max') if(right<heapSize an...
a8d1d7e81612f0d26561c5a38a79392f829d7f81
JaneNjeri/Think_Python
/ex_11_05.py
711
4.09375
4
#!/usr/bin/python #AUTHOR: alexxa #DATE: 29.12.2013 #SOURCE: Think Python: How to Think Like a Computer Scientist by Allen B. Downey # http://www.greenteapress.com/thinkpython/html/index.html #PURPOSE: Chapter 11. Dictionaries # Exercise 11.5 # Read the documentation of the dictionary method setdefault # and use it t...
1ed690055f92f5f1711b9206526eb215599574bd
TenaciousZ/Workspace
/Document/Python/Py_basics_01/class.py
2,443
4.0625
4
#-*-coding:utf8-*- import inspect #类的继承 class Student(object): ''' Class doc 幼儿园类 ''' name = 'zsl' score = '99' subject = 'game' def __init__(self,name='zsl'): self.name = name instance = Student('sl') print instance #实例对象 print Student #类 print 'child name is >>>',instance.name class Student_small(Student...
1f732069d9bdeeb87cb6b7ed46a15d54486483a6
zachsaeed/python_notes
/099 Notes Under preparation/old/etc note files. Need to move to main files and delete/Jupiterised/30-CompositeDataTypes/30.4-SequenceTypes/30.4.4-list-tuple-And-range/30.4.4.8-Tuples.py
1,606
4.625
5
# tuples are similar to lists except that # 1- tuples are immutable # 2- Created using (items) or tuple( (items) ) function sample_tuple = (1, 2, 3, 4, 5, 6, 7, 8) sample_tuple2 = tuple((1, 2, 3, 4, 5, 6, 7, 8)) print(type(sample_tuple)) # <class 'tuple'> print(type(sample_tuple2)) # <class 'tuple'> # Are immutable...
166c3200870596f4bdd4e91d9e5acc987fbdafe3
mikegleen/hrmsrc
/trans/image_to_jpg.py
1,348
3.546875
4
#!/usr/bin/python """ Convert an image file to JPEG using the OSX utility sips. The files must reside in a subdirectory of the directory named as the first parameter. To use this script, copy your image file to the "tif" subdirectory of the base directory. The script will create a JPEG file in the "jpg" subdirectory...
cb134a63d240783ef699d16b019e7b11f02ff0fc
Amrita2000/Data-Structure-and-Algorithm
/LAPIN.py
441
3.578125
4
from collections import Counter for i in range(0,int(input())): k=input() m=len(k)//2 if(len(k)%2==0): first_half=k[:m] second_half=k[m:] count1= Counter(first_half) count2 = Counter(second_half) if(count1==count2): print("YES") else: print("NO") else: first_half=k[:m] second_half=k[m+1:] ...
fa8cbd602191bc4f5b82c33e2baa863c54354cec
AbdoA2/AtlasLearn
/FullyConnectedNet.py
10,381
3.875
4
import numpy as np from utils.layers import * from utils.layers_utils import * class FullyConnectedNet(object): """ A fully-connected neural network with an arbitrary number of hidden layers, ReLU nonlinearities, and a softmax loss function. This will also implement dropout and batch normalization as ...
26b2f6cb8d1b06c3e0e9a10e95349b234339f29b
S-EmreCat/PythonKursuDersleri
/03-Obje ve Veri Yapıları/3.11.uygulama.py
667
4.09375
4
website="https://www.sadikturan.com" course= "Pyton Kursu: Baştan Sona Python Programlama Rehberiniz (40 saat)" #2 # website=website.replace(https://," "),(.com," ") # print(website) #3 course=course.lower() print(course) #4 sayi=website.count("a") print(f"{sayi}tane a vardır.") #5 isBas=website.sta...
6afe1538f2dc63705e5fd25baaa8876284d93eec
ourSSUNG/CodeSignalPractice
/InterviewPractice/DataStructure/HeapsStacksQueues/simplifyPath.py
669
3.734375
4
def simplifyPath(path): n = len(path) i = 0 mid = [] while(i<n): tmp = "" tmp = tmp + path[i] i = i + 1 while(i<n and path[i]!="/"): tmp = tmp + path[i] i = i + 1 if len(tmp) < 2: continue elif tmp == "/.": c...
f7b8964fb5c4bf9816100da06e632fc4bb814d57
Helgehelo/INF200-2019-Exercises
/src/helge_helo_klemetsdal_ex/pa01/snakes_and_ladders.py
2,567
3.84375
4
# -*- coding: utf-8 -*- __author__ = 'Helge Helo Klemetsdal', 'Anders Mølmen Høst' __email__ = 'hegkleme@nmbu.no' 'anderhos@nmbu.no' import random as rd import numpy as np def single_game(num_players): """ Returns duration of single game. Arguments --------- num_players : int Number of ...
aa1f6cdbff083149a44df49f75d904b19b7cbe14
sak25/Email-Content-Extraction-and-Message-Classification-
/code.py
2,284
3.53125
4
import imaplib import email mail = imaplib.IMAP4_SSL('imap.gmail.com') # imaplib module implements connection based on IMAPv4 protocol mail.login('username at gmail.com', 'password') # >> ('OK', [username at gmail.com Saksham authenticated (Success)']) Selecting a Label Your GMail inbox has multiple labels like ...
eb30ca65cdd788fe3bae32b3d95e752b1151f6cd
apatnoe/Homework_3
/PyBank/main.py
2,835
4.28125
4
# name dependencies import os import csv # create file path input_path = "Resources/budget_data.csv" # variables for month count and lists month_count = 0 month_list = [] profit_list = [] monthly_change = [] # function to create a list of monthly profit/losses def finances(monthly_data): # name variables fo...
f03cc375a2d3ba738aeeb6888cb5d0c324b45da7
jharinkesh/machine_learning
/topics/linear regression/salary_prediction.py
761
3.875
4
# -*- coding: utf-8 -*- # data pre processing import pandas as pd import numpy as np # importing the data into data frame dataset = pd.read_csv('Salary_Data.csv') X = dataset.iloc[:,:-1].values Y = dataset.iloc[:,1].values # spliting of data into training set and test set from sklearn.cross_validation import train...
d659d297c2647513c3fab81f1f6f8cecdb5d7154
EstuardoReyes/LFP_Proyecto2
/prueba1.py
211
4
4
diccionario = {'nombres' : 'Carlos', 'edad' : 'A', 'cursos':23 } for key in diccionario: if key == 'nombre': print("saltar") else: if diccionario[key] == 'A': print("es libre")
0839b67a3773aa7d5909539fa7ce2c8137384557
barchuckie/co-co
/zad7/szum.py
1,449
3.734375
4
#!/usr/bin/env python import argparse import contextlib import random from inout_bits import BitInputStream, BitOutputStream def parse_arguments(): """ Handle and parse program arguments. Returns: argparse.Namespace: namespace with 3 parsed arguments: - p -- probability of bit to be...
4a828f6bb6573d360871f184731a07783a6fccbd
hanrick2000/LeetcodePy
/leetcode/dp/word_break_ii_dfs_dp.py
1,327
3.671875
4
from typing import List class Solution: """ Runtime: 136 ms, faster than 5.08% https://leetcode.com/problems/word-break-ii/discuss/44368/Python-easy-to-understand-solution-(DP%2BDFS%2BBacktracking). """ def wordBreak(self, s: str, wordDict: List[str]) -> List[str]: res = [] """ ...
75bbb8cec97c884eea16abe3feb8996fe7793d41
scsd3211/AILOGPDT
/justify.py
520
3.9375
4
# 这样我就不用写 tkinter from tkinter import * root = Tk() # 注意Tk的大小写 #photo = PhotoImage(file=‘1.png‘) theLabel = Label(root,text='博客园\n舍名利 - --',justify = LEFT) theLabel.pack() theLabel = Label(root,text='2323博客园\n舍名利 - --',justify = LEFT) theLabel.pack() theLabel = Label(root,text='博客23423园\n舍名利 - --',justify = LEFT...
d73e19aa44752330628989a52207cf521255a3d5
Demon1630/python
/bankaccount.py
950
4.25
4
# 定义一个银行账户模块 class Bankaccount: #定义一个初始账户额 def __init__(self,bal): #bal 为输入的初始额度 self.__balance = bal #定义存钱过程 def deposit(self,account): self.__balance += account #定义取钱过程 def withdraw(self,account): # 判断账户中是否有足够的钱,够的话取出来,不够报错 if self.__balan...
31e9cbfc9ed60a7976a376a7f8a9620f2a0d0c7d
prasannagiri2072/python-practice
/spreedsheet work1/task-9.py
363
4.1875
4
#Distance formula (x1,x2) and (y1,y2) from math import sqrt x1 = int(input("input value of x1 :")) x2 = int(input("input value of x2 :")) y1 = int(input("input value of y1 :")) y2 = int(input("input value of y2 :")) distance = sqrt((x2 - x1)**2 + (y2 - y1)**2) print("the distance is =", distance) 2 2 #Solution by ...
a62b4720c75c3d980e75e5bb4222878daf81803a
Katherinaxxx/leetcode
/LCOF62. 圆圈中最后剩下的数字.py
1,103
3.9375
4
#!/usr/bin/env python # -*- coding: utf-8 -*- """ @Time : 2020/9/12 下午5:06 @Author : Catherinexxx @Site : @File : LCOF62. 圆圈中最后剩下的数字.py @Software: PyCharm """ """ 0,1,,n-1这n个数字排成一个圆圈,从数字0开始,每次从这个圆圈里删除第m个数字。求出这个圆圈里剩下的最后一个数字。 例如,0、1、2、3、4这5个数字组成一个圆圈,从数字0开始每次删除第3个数字,则删除的前4个数字依次是2、0、4、1,因此最后剩下的数字是3。 题解: https://leetcode-...
546aa0d6e3af77cdf139ce68c4b39cfd850399aa
brian-mcrae/Election_Analysis
/Week_3_Practice/hello.py
1,061
4.25
4
#%% print("hello") # %% somestring = "Test" print (somestring) type(somestring) # Python's six datatypes myName = "Brian McRae" myAge = 50 myBDay = '06/01/1970' # String interpolation myIntroduction = f""" My name is {myName} and I am {myAge} years old. I was born {myBDay} """ print(myIntroduction) # %% # Use non-de...
314a6010488de79fbbaa4e8f333de69e718f14e4
pecanjk/leetcode_solution
/169_majorityElement.py
1,316
3.890625
4
''' 多数元素 给定一个大小为 n 的数组,找到其中的多数元素。多数元素是指在数组中出现次数 大于 ⌊ n/2 ⌋ 的元素。 你可以假设数组是非空的,并且给定的数组总是存在多数元素 输入:[2,2,1,1,1,2,2] 输出:2 尝试设计时间复杂度为 O(n)、空间复杂度为 O(1) 的算法解决此问题。 ''' def majorityElement(nums:list)->int: hash_dict=dict() max_counts=0 for v in nums: if v not in hash_dict: hash_dict[v]=1 else: hash_dict[v]+=1 ...
68d6ac4431ea7a608b2a6d87e4dfe2d1b9bca717
JayChan1982/Language
/Python/Basic/guess_the_num.py
2,158
3.84375
4
from random import random # 生成随机数后,接受用户输入,判断用户猜的数字是否正确 def guessthenum(): # 随机生成1-100之间的整数 guessnum = int(random() * 100) # 定义循环变量 flag = True # 循环处理 while flag: # 判断自动生成的随机数与输入的数字是否相等 # 相等,提示猜对了 if guessnum == int(input("请输入猜的数字: ")): print("您猜对啦...
f621e85646a020bff1b52eb643021a63e2d3dc66
githubvit/study
/7协程/8构建自己的python Async底层框架/9.py
11,101
3.625
4
# 用 协程 async/await 来 实现 单线程 并发 socket 2 select # 用 select 做代理 收发 # 应用程序 把要连接的 socket对象 都交给 select, 自己可以干点别的,不会阻塞。 # select 会和 系统的io接口 打交道,当某个socket 有返回,就通知应用程序的该socket来取。 # 这样 就可以 让 应用程序 起一堆socket,可以保证并发,不阻塞。 # select做了哪些事? # 1 设定 server 为 非阻塞 等于 # server.setblocking(False) # 2 与系统io接口打交道,轮询 三个...
09bda24f8c002d88241665a8be5d5fcf11864bd8
joanna-salek/internship_tasks
/task_three.py
4,567
4.03125
4
#!/usr/bin/python # -*- coding: UTF-8 -*- import time class Road: # class representing straight road with maximal speed allowed in m/s, distance in m and turn in angles def __init__(self, max_speed, distance, turn=0): self.max_speed = max_speed self.distance = distance self.turn = tur...
6e09e3711bb13430aac7c7c827f22714c943ed5e
AleksandarShishkov/_my.Py-projects
/Python_lists/menu.py
1,028
4.125
4
def menu_option(): print("\n\tSelect between the following: \n") # printing the options in the menu print("\t'1' to search an element on the list") print("\t'2' to s...
a8ee66572d987637470a2475a591dc36633bea3f
Anmol1696/MapReduce
/src/file_manage/read_file.py
1,024
3.75
4
""" In this module the file is read into chunks of lines at a time for each cluster """ from itertools import islice def read_file(num_lines_per_node, num_nodes, cluster_rank, file_obj): """ This is for a cluster. For each cluster it will read files as genrator cluster_rank -> Rank of the clu...
2e559d7c34ff06eb3b25e68d29af1aac417a3601
rricher/CodingDojo
/python_stack/pthyon/fundementals/function_basics2.py
549
3.515625
4
#countdown def countdown(a): x = [] for i in range(a, -1, -1): x.append(i) return x # Print and Run def printRun(a): print(a[0]) return a[1] # First plus Length def plusLength(a): return a[0] + len(a) # Values greater than second def greatSecond(a): if len(a) < 2: return F...
8f5463e2d034ec0fc52fc7e5e84914efcbd2965b
uNashCS/Python
/10-sb-condicionales-if-else.py
458
3.828125
4
print("Verificación de acceso: ") edad_user=int(input("Introduce edad del usuario: ")) if edad_user<18: print("Acceso denegado") elif(edad_user>100): print("Edad incorrecta") else: print("Acceso concedido") print("El programa ha finalizado") nota_alumno=int(input("Ingresa la nota: ")) if(nota_alumno<5): ...
f4ce1338f6a5852003b3a281249a166e54c0f0b2
samelstob/notes
/management-notes/seven_languages/python/stream_file.py
825
3.75
4
#!/usr/bin/env python import sys, time, datetime def datetime_from_time_tuple(time_tuple): """ Construct a datetime object from a time tuple. I'm sure there is an easier way to do this. I just can't work it out. """ return datetime.datetime.fromtimestamp(time.mktime(time_tuple)) def parse_date(d...
d008d433b6f7f9d3dc548f97b8320ff7651e05ba
debsankha/generalized-cycle
/src/cube_network.py
9,109
3.5625
4
#!/usr/bin/env python """ cube_network.py Creates a 3d cubic lattice graph, calculates the cycle basis and then checks perturbations """ from collections import defaultdict from itertools import combinations import numpy as np import matplotlib.pyplot as plt import matplotlib.colors as colors import mat...
a70606786c090cc90ed89d5c32df7b7ce7b3d445
dhenriquedba/code-combat
/Masmorra-Kithgard/know-enemy.py
400
3.6875
4
#Use sua primeira variável para conseguir a vitória. # Você pode usar uma variável como um "crachá de identificação". enemy1 = "Kratt" enemy2 = "Gert" enemy3 = "Ursa" while True: if enemy1: hero.attack(enemy1) hero.attack(enemy1) if enemy2: hero.attack(enemy2) hero.attack(enemy...
517b06b9229aa22f927715aee6e8082682c1e6cf
kckotcherlakota/algoexpert-data-structures-algorithms
/Hard/merge-linked-list.py
1,469
4.03125
4
# MERGE LINKED LIST # This is an input class. Do not edit. class LinkedList: def __init__(self, value): self.value = value self.next = None # O(N + M) time, O(1) space def mergeLinkedLists(headOne, headTwo): # Write your code here. startingNode = headOne if headOne.value < headTwo.value e...
b726f1e32a9bd239a8ffa20efd1a675eb9d3b3ca
Pamellavsl/Uri
/2136.py
835
3.546875
4
entrada = [] listaNomes = [] contNomes = [] listAmigos = [] listNotAmigos = [] while True: entrada = [i for i in input().split()] if entrada[0] == "FIM": for i in listAmigos: cont = 0 for char in i: cont = cont + 1 contNomes.append(cont) contMinimo = max(contNomes) index = ...
e6f4996ad87e5f071f8262b7e2397c13f6f4d416
cardstdani/data-structures
/LinkedList.py
1,393
3.90625
4
class node(): def __init__(self, d, n): self.data = d self.next = n def __str__(self): return(str(self.data) + " " + str(self.next)) def insert(d, index=None): temp = head if index == None: while not temp.next == None: temp = temp.next temp.next = node(d, None) else: for i in r...
931c3d2669e7bd0c11214304e63eb6a75a276d3a
touhiduzzaman-tuhin/python-code-university-life
/Udemy - Python Data Science basics with Numpy, Pandas and Matplotlib/3.py
733
3.71875
4
a = 10 print(a) print(type(a)) a = 10.5 print(a) print(type(a)) a = 10 + 8j print(a) print(type(a)) a = 20 b = 13 print(a + b) print(a - b) print(a * b) print(a / b) print(a // b) print(a % b) print(2 ** 3) a = 10 b = 11 print(a == b) print(a != b) print(a <= b) print(a < b) print(a >= b) print(a > b) a...
f85856c7cc68de7e3c97e00e97ad78618b7c96a2
melioratus/homework
/kcs/notes/rock-paper-scissors.py
1,078
4.21875
4
#!/usr/bin/env python # # Start # r=3 i=0 def checkwinner(p1,p2): if p1 == p2: return 'Tie' elif p1 == 'rock' and p2 == 'scissors': return 'Player 1 wins!' elif p1 == 'rock' and p2 == 'paper': return 'Player 2 wins!' elif p1 == 'paper' and p2 == 'rock': retu...
36c3e07bd088785cbbcd82528526154f4762e186
jainendrak/python-training
/Examples/5Magic Methods/nestedClass.py
226
3.71875
4
''' class A: class B: count=0 obj = A.B() print(obj.count) ''' ############################################ outer=123 def a(): def b(): c= secret+1 return c secret=0 return b x=a()() print(x)
039a7a2268968e49e72dafda8eaba49ea984e457
voidyao/mytest
/squares.py
148
3.71875
4
squares = [] for value in range(1,11): squares.append(value**2) print(squares) squares2 = [value2**2 for value2 in range(1,11)] print(squares2)
797975db134ec99cc1875a05e183144cfeef13b0
rjones18/Reverse-Dictionary-Lookup
/Reverse.py
454
4.15625
4
def reverse_lookup(rev1,rev2): for key, value in phonebook.items(): if value == rev2: return key phonebook = { 'Joe': '702-555-6495', 'Silvio': '504-555-3234', 'Greta': '213-555-4364', 'Jill': '415-555-5864' } print(reverse_lookup(phonebook, '504-555-3234')) #--> Silvio's number print(r...
32007c83834dcdc653eb752251007f679d4d8e8c
wding-dev/coding-challenge
/longest_substring_without_repeating_characters/main.py
530
4.09375
4
""" Given a string s, find the length of the longest substring without repeating characters. Example 1: Input: s = "abcabcbb" Output: 3 Example 2: Input: s = "pwwkew" Output: 3 """ def solution(s: str) -> int: substr = "" max_substr_length = 0 for ele in s: if ele not in substr: s...
b0f0b811ee1c61a49979946dc2e9a85b7ac104dd
mcornielje090404/Challenges
/middleLetter.py
373
4.09375
4
##Function that returns the middle letter of a word if the word has 2 middle letters it returns blank space repeat = True def mid(): word = input("What word would you like to use? ") test = len(word) middleLetter = word[len(word)//2] if test % 2 > 0: print(middleLetter) else: ...
a7924f2ff7611609b7b12ee679546dd6cf40232d
450703035/Data-Structures-Algorithms
/1_data_structures/3_recursion/4_reverse_a_string.py
1,027
4.46875
4
''' Reversing a String: The goal in this notebook will be to get practice with a problem that is frequently solved by recursion: Reversing a string. Note that Python has a built-in function that you could use for this, but the goal here is to avoid that and understand how it can be done using recursion instead. ''' # ...
256b611a176fb467bf7fdcf9580768bbe06794bc
harshitherobotist/OpenCv
/0.7.py
1,177
3.6875
4
'''Program for color subtraction Red, Green ,Blue ''' import numpy as np import cv2 as cv image1 = cv.imread('Test Image 3.png') BlueMatrix = image1[:,:,0] GreenMatrix = image1[:,:,1] RedMatrix = image1[:,:,2] print('BlueMatrix\n',BlueMatrix) print('GreenMatrix\n',GreenMatrix) print('RedMatrix\n',RedMat...
b3a8738d513552bc8dd57e09516055f30fcb4553
Brian-Mascitello/Advent-of-Code
/Advent of Code 2018/Day 2 2018/Day2Q1 2018.py
785
3.734375
4
""" Author: Brian Mascitello Date: 12/2/2018 Websites: https://adventofcode.com/2018/day/2 Info: --- Day 2: Inventory Management System --- """ def get_data(input_text): with open(input_text) as file: data_from_file = file.read() file.close() return data_from_file data = get_da...
c043855ab781e13f6da38b60507bc7bdfbb5d3b7
AjinkyaTaranekar/LeetCode
/1768.merge-strings-alternately.py
688
3.546875
4
# # @lc app=leetcode id=1768 lang=python3 # # [1768] Merge Strings Alternately # # @lc code=start class Solution: def mergeAlternately(self, word1: str, word2: str) -> str: res = [0]*(len(word1)+len(word2)) i,j,k = 0,0,0 while i < len(word1) and j < len(word2): if k%2: ...
bcb3d080806849cd414aa59dfd0c389f240096f4
Snoblomma/HackerRank
/Python/Regex and Parsing/Regex Substitution/Regex Substitution.py
380
3.828125
4
import re def replace(line): line = line.rstrip('\n') regexp = re.compile(r'( && )|( \|\| )') while regexp.search(line): line = re.sub(r"( && )", ' and ', line) line = re.sub(r"( \|\| )", ' or ', line) return line if __name__ == '__main__': num = int(input()) for i in r...
9a4160671380f88e34b71b28d29ad7fcc47dc5b6
KeenanJones1/python-intro
/py_json.py
464
3.6875
4
# JSON, commonly used with data apis. Here how we can parse JSON into a python dictionary. import json # naming the file json.py would cause a conflict when importing this module. # Sample JSon userJSON = '{"first_name": "John", "last_name": "Doe", "age": 30}' # parse to dict user = json.loads(userJSON) # print(user)...
618a51dd459a36c40c65faf913cb3eae88439c5d
fabiommendes/apc-teste
/fib.py
109
3.71875
4
n = int(input("n: ")) fibs = [1, 1] while len(fibs) < n: fibs.append(fibs[-1] + fib[-2]) print(fibs)
76a54081e40d549375bef90365d1b5270c6680ea
Subratmishra1999/Programs
/paras.py
899
3.890625
4
# Efficient Python program to make sorted array # elements distinct by incrementing elements # and keeping sum to minimum. # To find minimum sum of unique elements def minSum(arr, n): sum = arr[0]; prev = arr[0] for i in range(1, n): # If violation happens, make current # value as 1 plus prev...
be15a6dd741862a8060a61afe204393777314e94
camillanore/Studies
/python/ball_qa.py
868
3.703125
4
# -*- coding: utf-8 -*- """ Created on Tue Sep 15 14:52:51 2015 @author: Camilla Nore """ """ Exercise 4.9: Prompt the user for input to a formula Consider the simplest program for evaluating the formula y(t) = v0t − 1 2 gt2: v0 = 3; g = 9.81; t = 0.6 y = v0*t - 0.5*g*t**2 print y Modify this code so that the program ...
13df8bc6ef2e442945e96f7b31a53dd986dcad88
peterjpierce/project_euler
/solutions/003.py
857
3.640625
4
""" Problem 3 The prime factors of 13195 are 5, 7, 13 and 29. What is the largest prime factor of the number 600851475143 ? """ from math import sqrt from shared import util def run(): start_time = util.now() given_number = 600851475143 # given_number = 13195 unsolved_portion, factors = given_number...
14256674b0606a9f9a31b10f1b09d95aef34f391
cboopen/algorithm004-04
/Week 07/id_069/LeetCode-231-069.py
453
3.578125
4
# 20191129 class Solution: def isPowerOfTwo(self, n: int) -> bool: if n <= 0: return False counter = 0 tmp = n while True: if n == 1: break n >>= 1 counter += 1 return 2**counter == tmp class Solution: def...
601ff1b0a956546ffcaa0203ed2a5b0ed00403aa
edisonlz/c1_course_python
/_dict_/3_2_练习.py
923
4
4
1. 问:怎样在两个字典中寻寻找相同点? a = { 'x' : 1, 'y' : 2, 'z' : 3 } b = { 'w' : 10, 'y' : 2, 'z' : 3, } print(a.keys() & b.keys()) 2.问:假设你有一个单词列表并且想找出哪个单词出现频率最高? words = [ 'look', 'into', 'my', 'eyes', 'look', 'into', 'my', 'eyes', 'the', 'eyes', 'the', 'eyes', 'the', 'eyes', 'not', 'around'...
9a7cf40afc0d72c0173b603e8a857b57aa78980a
canopus-n/playground
/special_palindrome_counter.py
1,368
4.0625
4
# A string is said to be a special string if either of two conditions is met: # - All of the characters are the same, e.g. aaa. # - All characters except the middle one are the same, e.g. aadaa. # A special substring is any substring of a string which meets one of those criteria. # Given a string, determine how many ...