blob_id
stringlengths
40
40
repo_name
stringlengths
5
119
path
stringlengths
2
424
length_bytes
int64
36
888k
score
float64
3.5
5.22
int_score
int64
4
5
text
stringlengths
27
888k
a048a2ad1041929246faca56575e18dc838d75d5
MrHamdulay/csc3-capstone
/examples/data/Assignment_6/bhrjam001/question3.py
608
4.09375
4
# James Behr # 2014-04-23 # Assignment 6 Question 3 parties = {} # dictionary to hold names print('Independent Electoral Commission') print('--------------------------------') print('Enter the names of parties (terminated by DONE):') # Loop until sentinel is reached while True: s = input() if s == '...
260de9addf92fc27a7b97be2a782b6007d21f692
cudjoeab/python_fundamentals3
/collections-iterations-1.py
3,406
3.734375
4
#LISTS fav_colours = ['black', 'turqouise', 'yellow'] family_ages = [25, 46, 34, 40, 41, 27] coin_flip = ['tails', 'heads', 'tails', 'tails','tails'] fav_artists = ['Janelle Monae', 'Tush', 'Lizzo'] #DICTIONARIES dictionary = { 'burgeon': 'to sprout, bloom, or flourish', 'lionize': 'to treat with great impor...
33ed90643046a0a7aa2cc4f6b6f542bf4d682a86
z-waterking/ClassicAlgorighthms
/LeetCode/1110.删点成林.py
967
3.515625
4
# # @lc app=LeetCode.cn id=1110 lang=python3 # # [1110] 删点成林 # # @lc code=start # Definition for a binary tree node. # class TreeNode: # def __init__(self, val=0, left=None, right=None): # self.val = val # self.left = left # self.right = right class Solution: def delNodes(self, root: Tr...
038ae8b6217b720f546edf2af295ab2be753acad
ParulProgrammingHub/assignment-1-DPexotic
/program 8.py
125
3.671875
4
print("enter parameters:") b = float(input("base:")) h = float(input("height:")) area = 0.5 * b * h print("area:",area)
cd518ee3aff65ee9fd14c88451e1fb55a4a2fc1d
MaximZolotukhin/erik_metiz
/chapter_8/exercise_8.6.py
716
4.125
4
""" Названия городов: напишите функцию city_country(), которая получает название города и страну. Функция должна возвращать строку в формате "Santiago, Chile". Вызовите свою функцию по карйне мере для трех пар "город - страна" и выведите возвращенное значение. """ def city_country(city, country): return f"{city} - ...
0c20855cfbdf23b6ad4e4b3978c3443401fcc31f
chulsea/TIL
/datascience/pandas_practice/selection_drop.py
882
4.03125
4
import pandas as pd, numpy as np # pandas data frame selection raw_data = { 'first_name': ['gyeongcheol', 'wooje', 'hohyun'], 'last_name': ['park', 'noh', 'kim'], 'age': [27, 27, 28] } df = pd.DataFrame(raw_data) print(df) # 한개의 column 선택 print(df['first_name']) # print(df['first']) 만약 없는 값인 경우 오류 # 한개 이...
dd544253f222a8362c85a35ee750ce84aabcb767
Nehagarde/etl
/control_flows_percentage.py
350
3.75
4
if __name__ == '__main__': percentage = int(input("Enter percentage: ")) if 100 >= percentage >= 80: print("Distinction") elif 79 >= percentage >= 70: print("First class") elif 69 >= percentage >= 60: print("Second class") elif 59 >= percentage >= 50: print("Pass") ...
143f8028856e5dfa0e3f2e41ef1d1c77039fa6ea
Silverchiffa/python
/sockscounter.py
828
3.78125
4
ar.sort() socksCounter = 0 while len(ar) > 1:     if ar[0] == ar[1]:         socksCounter += 1         ar.pop(0)             ar.pop(0)     else:         ar.pop(0)              return socksCounter def countingValleys(steps, path):     # Write your code here     # O(n + (n-1)) --> O(n)     # O(n...
3089839bedb9a595d186dae7d438976071e4a223
tmajest/project-euler
/python/p11/p11.py
1,320
3.609375
4
from operator import mul import sys # In the 2020 grid below, four numbers along a diagonal line have # been marked in red. # # (see input file in this directory) # # The product of these numbers is 26 63 78 14 = 1788696. # # What is the greatest product of four adjacent numbers in any # direction (up, down, left...
1976ba5518c9f20202b6fe8d5ba135b0f9e41b95
LaurelKuang/2017A2CS
/Ch23/stack.py
1,172
3.703125
4
# S3C2 Laurel Kuang NullPointer=-1 class StackNode: def __init__(self): self.value="" self.nextP=NullPointer class Stack: def __init__(self,length): self.tp=NullPointer self.fp=0 self.records=[] for i in range(length): NewNode=StackNode() ...
d4cdf6b52fe8ccfbe3eacc3df4e4640043677e80
connectlym/graph-search-dijkstra
/main.py
3,724
3.640625
4
# *********************************************************************************************************** # Graph Search - Shortest Path - Single Source Shortest Path # (Reference: http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=GRL_1_A) # *******************************************************************...
b6830dd085a7b3136c24a04eda602fbd1cd41d9f
zyhsna/Leetcode_practice
/problems/island-perimeter.py
659
3.578125
4
# _*_ coding:UTF-8 _*_ # 开发人员:zyh # 开发时间:2020/9/4 10:04 # 文件名:island-perimeter.py # 开发工具:PyCharm class Solution: def islandPerimeter(self, grid: list[list[int]]) -> int: c = 0 m, n = len(grid), len(grid[0]) for i in range(m): grid[i].insert(n, 0) grid[i].insert(0, 0) ...
40c6af945dee55671cda3203d343d7e4d621288a
movjc/pythontest
/13.py
897
3.59375
4
#coding=utf-8 """ date:2017-08-17 @author: ray 题目:打印出所有的"水仙花数",所谓"水仙花数"是指一个三位数,其各位数字立方和等于该数本身。例如:153是一个"水仙花数",因为153=1的三次方+5的三次方+3的三次方。 程序分析:利用for循环控制100-999个数,每个数分解出个位,十位,百位。 """ """ for n in range(100,1000): i = n/100 #百位上的数 j = n/10%10 #十位上的数 k = n%10 #各位上的数 if n == i**3 + j**3 + k**3: p...
56fe3dc9082a9b3c41a714316678475d7c334407
lcxidian/soga
/leetcode/90.py
76,333
4.03125
4
LeetCode题解整理版(二) Leetcode开始支持Python了,本篇题解中的题目都是用Python写的。(更新中..) 已更新完,本篇题解中共96题,按照Leetcode上的顺序从上向下。可以用CTRL+F查找,如果没有的话就是在前一篇题解中了。 因为时间原因,题解写的并不是很详细,大多数题目都只给出了关键思路。 Reverse Words in a String 将abc def形式的字符串翻转成def abc,并且去掉多余的空格。 先将这个字符串翻转过来,再逐次翻转每个词。(当然不是效率最高的办法,只是为了好写。) class Solution: # @param s, a string ...
a48468e70c0f7d95bc005bf1bb89c690e22a9000
Keilo104/faculdade-solucoes
/Semestre 1/AP1/exerciciosextra/atividadepratica01.py
2,874
3.6875
4
i = 0 prataCaro = 0 prataCaroNome = "" mais60k = 0 amarelo2010 = 0 amarelo2010media = 0 branco30k = 0 while True: i += 1 modelo = input("Digite o modelo do {}º carro: ".format(i)) # Faça um programa para informatizar o ano = int(input("Digite o ano de fabricação do {}º carro: ".format(i))) #...
60dec79e0b77b77a66f0711db817e1b5faf901ff
MuniraLinda/Python-Class
/numbers.py
208
4.3125
4
#Asignment : numeric datatypes ''' 1. Using the random library, Print out random numbers range from 10-100 2. Convert float to int ''' import random print(random.randrange(10,100)) #x = 35.3 #print(int(x))
9673fa64db4c85fd993a205190c199e0c86cbb2b
chandra10207/Python-tkinter-workouts
/Python Testing and Quality Assurance/Task1/count.py
308
3.625
4
def countNum(start, end, num): count = 0 for i in range(start, end): if str(num) in str(i): count = count + 1 return count print(countNum(1,5,8)) print(countNum(1,500,2)) print(countNum(-50,-5,6)) print(countNum(100,1000,42)) print(countNum(1,12,1)) print(countNum(5,5,5))
2519356335743ebefac9939d9798b1203c63beb1
dsurraobhcc/CSC-225-T1
/classes/class4/meetings.py
1,813
4.15625
4
# 1. Complete the code below: # a. Create a 'Meeting' class that stores the following information # about an event in your calendar: title, location, start time, end time # b. Instantiate the following events using this class and add them to a list # Doctor appointment, MGH, 10/18/2020 9-10 am # Soccer practice, BU a...
b9a52ccf1606f3031e663199d08138d2fde3a6c2
sfadiga/Hashsort
/hash_sort.py
1,011
4.53125
5
def hash_sort(arr): ''' this code will only work in python 2 A very simple and naive sort algorithm that uses a hash table as auxiliary structure A good use case for this algorithm is a list of numbers distributed randomly but with range approximate of the size of the list. ...
3a7aa11faef6c93d247032a8a146015e49ea8fdc
LXSkyhawk/ProjectEuler
/Sum_Square_Difference.py
198
3.671875
4
sum_of_squares = 0 square_of_sum = 0 for x in range(1, 101): sum_of_squares += x ** 2 square_of_sum += x square_of_sum **= 2 difference = square_of_sum - sum_of_squares print(difference)
d389ccdb165affecc327bf645a179037622889aa
vijayxtreme/ctci-challenge
/LinkedLists/removeDups.py
3,152
3.84375
4
#RemoveDups ''' Remove dups from an unsorted linked list. How would you solve this problem if a temporary buffer is not allowed? Questions: - Can I assume that 2 is different from "2"? - Are we allowing any types to be in LinkedList or is it strict? - Is this a doubly linked list or singly linked list? My Idea: Fil...
a7efe663b57f1b7397f6a43aeb12103dacf560ce
ryanlsmith4/space_man
/spaceman1.py
2,757
4
4
import random letters_guessed = [] correct_guesses = [] my_list = [] low_dash = [] def dictionary_list(): ''' This function reads the entire content of a file and puts them into a list then splits the dictionary with commas by the /n chars ''' f = open('dictionary.txt', 'r') dict_list = f.rea...
85d432cbce0229ce4cc63caf853a7063dc37d3fd
PrinceGumede20/100daycodechallenge
/myrnn.py
2,963
3.546875
4
# -*- coding: utf-8 -*- """ Created on Sat May 18 18:13:23 2019 @author: Prince """ #data preprocessing import numpy as np import matplotlib.pyplot as plt import pandas as pd dataset_train =pd.read_csv('Google_Stock_Price_Train.csv') training_set = dataset_train.iloc[:, 1:2].values #Feature Scalli...
76a54be82c232ed4329609118e76666847a9f6b8
RAmruthaVignesh/PythonHacks
/FileOperations/stream_textfile.py
658
3.84375
4
def stream_textfile_1(path): '''This function takes in the path input. It reads the entire file and returns each line in a list''' file_x = open(path,'rw+') lines = file_x.readlines() lines = [line.strip('\n') for line in lines] return lines textfile_1=stream_textfile_1("../FileOperations/samp...
d6e47eca3162c3ac9f953d6e67c467e273e202fb
mi-kei-la/holbertonschool-higher_level_programming
/0x0A-python-inheritance/1-my_list.py
364
3.890625
4
#!/usr/bin/python3 """This is a single class module. MyList is a subclass of the class List. """ class MyList(list): """This class is inherited from the class list. Methods: print_sorted: prints the list items in ascending order. """ def print_sorted(self): """Print int list in asce...
ffa458f2dd6d1327b0514ee0b70bb4fbc4cafcde
raushancena/Leetcode_April
/Search_in_rotated_sorted_array.py
834
3.90625
4
#Function to finding minimum element in nums:- def f(nums,left,right): print(nums) while(left<right): mid=left+(right-left)//2 if(nums[mid]>nums[right]): left=mid+1 else: right=mid return left #Function to find target in nums:- def bs(nums,left,right,target): while(left<=right): t,t...
a1ce476ad12f5b6c729a25d224844db2f4ecce14
DeadCereal/HackerRankCode
/Python3/WarmUps/ManasaAndStones.py
430
3.59375
4
numcases = int(input()) for _ in range(numcases): numstones = int(input())-1 one = int(input()) two = int(input()) b = max(one,two) a = min(one,two) difference = b-a maxval = b*numstones current = a*numstones if(a==b): print(str(current)) else: while(current <= ma...
c6823778f5f24194b0de575adf44630c93b78bf3
EnthusiasticTeslim/MIT6.00.1x
/other/HanoiTowers.py
416
3.875
4
# -*- coding: utf-8 -*- """ Created on Sun Jun 16 04:30:29 2019 @author: olayi """ def printMove(fro,to): print('move from' + str(fro) + " to " + str(to)) def Towers(n, fro, to, spare): if n == 1: printMove(fro, to) else: Towers(n-1, fro, spare, to) Towers(1, fr...
b2ea73a1b6a04800d2e27c7c950d805f69c8e809
SUTDNLP/ZPar
/scripts/ccg/evaluate/filterdeplen.py
723
3.671875
4
import sys def filterdeplen(path, lower, upper): file = open(path) for line in file: line = line[:-1] if line.startswith('#') or line.startswith('<c>') or not line: print line continue words = line.split() #assert len(words)==5 words[0] = words[0].split('_') ...
ac471c8fc3c189131417b9e6aef5acf87d9eae74
IslamAyesha/Assignments
/OTP GENERATOR.py
189
3.546875
4
import random as r import string length = 6 OTP = ' ' characters = string.ascii_letters + string.digits for i in range(length): OTP = OTP + r.choice(characters) print('OTP:',OTP)
0b89a776ed59d3b23aac2dede7f13c52e63ef436
gnavink/Python
/3_OOP/oop6.py
1,101
4.0625
4
#oop6.py #Illustrates: # i) Dunder Methods: __repr__, __str__ # ii) __add__, __len__ class Employee: raise_amt = 1.04 def __init__(self, first, last, pay): self.first = first self.last = last self.email = first + '.' + last + '@email.com' self.pay = pay def fulln...
0408fb192baec6ff32c7d03f1fb9fb2ee763c2d8
AnoopMasterCoder/python-course-docs
/6. Chapter 6/09_pr_07.py
138
4.09375
4
text = input("Enter your text: ") if 'harry' in text.lower(): print("Yes harry is present") else: print("No harry is not present")
5f1fd007a134244189f0ef127687858aedc0823a
Prashant-Bharaj/A-December-of-Algorithms
/December-27/python_crytotech.py
532
3.796875
4
def VowelSquare(a): for i in range(len(a)): for l in range(len(a[i])): if a[i][l] in 'aeiou' and a[i][l+1] in 'aeiou' and a[i+1][l] in 'aeiou' and a[i+1][l+1] in 'aeiou': return 'Top left Position of vowel square:' + str(i) + '-' + str(l) return 'Unavailable' lis=input("Enter...
4e02e01ecf358c5b8dfa3d5a4be95468c0fb61e4
gh4masha/dive_into_python
/dive_into_python/week4/week04_01.py
1,478
3.5625
4
import os import tempfile class File: file_name='' def __init__(self, file_name): self.file_name=file_name def __add__(self, other): with open(os.path.join(tempfile.gettempdir(), 'storage.data'),"w") as resfile: with open(self.file_name,'r') as f1: resfile.writ...
b737f9fdf7d83168cfa873ed2c39029c682ff75d
neba9/data-structures-and-algorithms
/python/array_shift/array_shift.py
99
3.828125
4
my_list = [1,2,4,5] # Insert the number 3 between the 2 and the 4 my_list[2:1] = [3] print(my_list)
f31412d63b03737056ab84c4af30308bf984e4ca
parulmehtaa/new_rep
/08_07_print_armstrong_numbers_till_n.py
614
4.125
4
def count_the_digits(n): j=1 i=0 while (n//j)>=1: i=i+1 j=j*10 return i def power_num(n,num_digits): sum=0 sum=n**num_digits return sum def is_strong(n): i=n rem=0 sum=0 fac=0 num_digits=count_the_digits(n) while i>0: rem=i%10 fac=p...
d7e6bfc489782f1789c0fdb1389958224e83414e
loisaidasam/adventofcode
/2015/day05/solution1.py
1,110
3.828125
4
import sys def _num_vowels(input_str): vowels = set(['a', 'e', 'i', 'o', 'u']) vowels_found = [char for char in input_str if char in vowels] return len(vowels_found) def _has_repeating_char(input_str): last_char = None for char in input_str: if char == last_char: return True...
f6cbc82ac8e769cc3269d21f5a40dd5229074a68
DreamDZhu/python
/week-3/day22_面向对象/人狗大战.py
1,753
3.78125
4
import random import time class Dog: def __init__(self, name, blood, ad, kind): self.dog_name = name self.hp = blood self.ad = ad self.kind = kind self.random = 10 # 舔舔攻击 def lick(self, person): # 方法,拥有一个必须传的参数 --> self hit = random.randint(1, self.random)...
0fa615a791e1fe97ddc7ca8bf9f73393235bbb74
WalczRobert/Module10
/invoice_class/__init__.py
2,067
4.09375
4
""" Robert Walczak""" #Write an Invoice class with the following data members, which are identified as required or optional in the constructor. # invoice_id - required # customer_id - required # last_name - required # first_name - required # phone_number - required # address - required # items_with_price - dictionary,...
f49a136c237cb9dfa6b250a2ced776131672fc39
julianalvarezcaro/holbertonschool-interview
/0x03-minimum_operations/0-minoperations.py
418
3.6875
4
#!/usr/bin/python3 """Finds the minimun operations needed to have a given amount of H characters """ from math import sqrt def minOperations(n): min_ops = 0 if n <= 1: return 0 for i in range(2, int(sqrt(n) + 1)): while n % i == 0: min_ops += i n = n / i ...
cfa1d8b38e5835b0884e2f34f411e97e3044bead
vipulsingh24/Python
/File_Handling.py
4,847
4.03125
4
# fp = open('test.txt') # print(fp.read()) # fp.close() # ------------------------------------ # with open('test.txt') as fp: # buffer = fp.read() # print(buffer) # --------------------------------------- # fp = open("test.txt") # while True: # buffer = fp.readline() # if buffer == '': # break #...
e5da29e5e28e58d13105585dd1b552bdf822a628
Alexkaer/dailyleetecode
/day003.py
1,654
3.921875
4
""" 地址:https://leetcode.com/problems/merge-sorted-array/description/ 描述: Given two sorted integer arrays nums1 and nums2, merge nums2 into nums1 as one sorted array. Note: The number of elements initialized in nums1 and nums2 are m and n respectively. You may assume that nums1 has enough space (size that is greater...
7a011dc1d165b1950a20fc5b95980e305bc4e9f0
seanxu229/LeetCodeSummary
/数据结构实现/BinarySearch.py
543
3.796875
4
'''前提是排好序了,有序的顺序表,必须相邻,即顺序表,不能是链条''' def binary_search(alist,item): n=len(alist) if n>0: mid=n/2 if alist[mid]==item: return True elif item<alist[mid]: binary_search(alist[:mid],item) else: binary_search(alist[mid+1:],item) return False def binary_search1(): #not recursion n=len(alist) first=0 ...
1c4318dd68fbeba4831586cd344ac09a7bf81d1f
ChupaChupaChups/Automatic-marking-system
/Documents/문제종류/sorting_answer.py
3,214
3.859375
4
## ===================== Binary Search ========================== def bSearch(L, e, low ,high): if high - low < 2: return L[low] == e or L[high] == e mid = low + int((high - low)/2) if L[mid] == e: return True if L[mid] > e: return bSearch(L, e, low, mid-1) else: re...
ad0452ce1add3e006c9c45d9ba5a71c87f9d72ca
sanchitahuja/CodingPractice
/leetcode/left_right_target.py
616
3.5625
4
import bisect from typing import * class Solution: def find_left_most_value(self, arr, x): i = bisect.bisect_left(arr, x) if i < len(arr) and i != -1 and arr[i] == x: return i else: return -1 def find_right_most_value(self, arr, x): i = bisect.bisect_ri...
f0bf8d62d136e561536e27456024c81a9dbd7faf
PQCuongCA18A1A/Ph-m-Qu-c-C-ng_CA18A1A
/PhamQuocCuong_44728_CH03/Exercise/page_72_exercise_04.py
312
3.8125
4
""" Author: Phạm Quốc Cường Date: 8/9/2021 Problem: Write a loop that outputs the numbers in a list named salaries. The outputs should be formatted in a column that is right-justified, with a field width of 12 and a precision of 2. Solution: """ a = 10000 b = 20000 print("%12.2f$ %12.2f$" % (a, b)...
6931feec4e641ddd9ffe73db230833ff47a3a1d7
maxwagner440/python_patterns
/Singleton.py
687
3.765625
4
class B: _shared_state = {} def __init__(self): self.__dict__ = self._shared_state class Singleton(B): """This class inherits from the B class every time its instantiated which allows access to the _shared_state object that is global""" def __init__(self, **kwargs): B.__init__(se...
977e98db9bc822e2c09627d93289be47a54b2d3f
py2k5/PyGeneralPurposeFunctions
/linkedList_newway.py
2,142
4.0625
4
class Node: def __init__(self,data=None): self.data = data self.next = None class LinkedList: def __init__(self, head=None): self.head = head def insert(self, newNode ): temp = newNode temp.next = self.head ...
c3dec6c1bc32c1277aa21ee8984b1e4745e9d7ce
trace7729/Intermediate-Python
/Lab 6 Multiprocessing/Lab06.py
3,881
4
4
from threading import Semaphore, Thread, Lock from queue import Queue, Empty from random import randint from time import sleep from os import system, name # Python II - Lab 6 - Annie Yen max_customers_in_bank = 10 # maximum number of customers that can be in the bank at one time max_customers = 30 # number of...
2c35834075de8091faa64f823df594a350698fd7
shiningPanther/Project-Euler
/Problem28.py
679
3.71875
4
''' Starting with the number 1 and moving to the right in a clockwise direction a 5 by 5 spiral is formed as follows: 21 22 23 24 25 20 7 8 9 10 19 6 1 2 11 18 5 4 3 12 17 16 15 14 13 It can be verified that the sum of the numbers on the diagonals is 101. What is the sum of the numbers on the diagonals in ...
8b2866b8788fdd01a495c264a5dc54ff2d554f51
xixijiushui/Python_algorithm
/algorithm/20-printMatrixInCircle.py
1,091
4.3125
4
def printMatrixClockwisely(numbers, columns, rows): if numbers == None or columns <= 0 or rows <= 0: return start = 0 while columns > start * 2 and rows > start * 2: printMatrixInCircle(numbers, columns, rows, start) start += 1 def printMatrixInCircle(numbers, columns, rows, start...
8b4228c7351e3c22e3949813e844ad7f42a58d57
rupaliwaghmare/python_list
/logicque.py
326
3.640625
4
name=["sharadda","rupali","anita"] i=0 while i<len(name): a=len(name[i]) print(name[i],a) i=i+1 # name=["Sakshi","Rupali","Anita"] # i=0 # while i<len(name): # a=len(name[i]) # if a%2==0: # print(name[i],a,"even number") # else: # print(name[i],a,"odd number") # i=i+1 ...
1f48c55eaaad7ff0a7fc4bdb26ebe2f75c0e1869
livochka/programming-project-semestr2
/nby_api.py
1,080
3.703125
4
# Module created to get information from National Bank of Ukraine import urllib.request, urllib.parse, urllib.error import json url = 'https://bank.gov.ua/NBUStatService/v1/statdirectory/inflation?period=m' \ '&date=' # Getting consumer price index (CPI) for 2013 and 2015 years in Lvivska obl date...
e03fce5d01f4a5d5be18bfb7c01d0d9489d457b8
JosephLevinthal/Research-projects
/5 - Notebooks e Data/1 - Análises numéricas/Arquivos David/Atualizados/logDicas-master/data/2019-1/226/users/4163/codes/1800_2571.py
118
3.765625
4
a = input("digite") saida = "" for i in range(len(a)): if a[i].lower() != 'a' : saida = saida + a[i] print(saida)
3a54f084e5fe36e69e530afc74d44dcfb8ae4ee6
SaiKrishnaBV/python-basics
/userDefinedExceptions.py
691
3.859375
4
''' User defined Exceptions ''' class Error(Exception): ''' Base class for other exceptions''' pass class ValueTooSmallError(Error): '''Raised when input value is too small''' pass class ValueTooLargeError(Error): '''Raised when input value is too large''' pass number = 10 while True: try: guess = int(i...
ce77149ff19356fccbbea7e1ebf57d92cf36a7df
Ankur-singh/computer_vision_book
/_build/jupyter_execute/course_material/02_drawing.py
7,276
4.65625
5
#!/usr/bin/env python # coding: utf-8 # # More on pixels # # In the first part of the notebook, we will learn about accessing and manipulating pixel values. In the second part, we will learn to draw different shapes on an image, using opencv. # In[1]: import cv2 import numpy as np # ## Accessing pixel values # ...
b70d83b68789fcb0395165b8132717dd93f4bf21
davelive/Homework
/hw5_David.py
2,522
4.15625
4
""" Problem 1 You have a list, you want to iterate over it and return the numbers that are divisible by 5. If you iterate over a number larger than 500, stop the loop. """ list = [5, 11, 30, 45, 175, 99, 106, 300, 490, 512, 890, 1000] N = 5 for num in list: if(num%N==0 and num <= 500): print (num) """ Problem ...
84fc179f24bc8f2811b45e36f0cc89fc731e945f
IAmAbszol/DailyProgrammingChallenges
/Problem_102/problem.py
604
3.78125
4
''' 1,2,3,4,5 sum = 9 ^ ^ 9 ''' # Bounding problem when right += 1 occurs, then accesses list. def problem(arr, k): if arr is None: return arr if k < arr[0]: return None left = 0 right = 0 # Since 1,1 is not in the array, only a single. total_sum = arr[left] while left < len(arr) and right < ...
33b665b0e6bce8e6e6e1f41600f3955c7ddce26b
spearfish/python-crash-course
/practice/04.11_pizzas.py
326
4.0625
4
#!/usr/bin/env python3 my_pizzas = ['pepperoni', 'cheeze', 'beef'] friend_pizzas = my_pizzas[:] my_pizzas.append('chilli') friend_pizzas.append('hawai') print("My favorite pizzas are : ") for pizza in my_pizzas : print(pizza) print("My friend's favorite pizzas are : ") for pizza in friend_pizzas : print(pi...
97be8e76b19c8b4db66c09bc554ad790b168e364
mzhao15/mylearning
/algorithms/Sort/insertion_sort.py
867
4.15625
4
""" Insertion Sort """ def sort_insertion(array): for i in range(len(array)): for j in range(i, 0, -1): if type(array[j]) != int and type(array[j] != float): return j if array[j] > array[j-1]: t = array[j] array[j] = array[j-1] ...
e0e3617dc599778aab76c14fa0fd131fab2fee24
defins/eksamens_a_roznieks
/4uzdevums.py
271
3.90625
4
def split(word): return [char for char in word] def listToString(s): str1 = "" c =len(s) for num in range(c,0,-1) : str1 += l[num-1] return str1 print("Ievadi Vārdu:") word = input() l = split(word) rinda= listToString(l) print(rinda)
11d3fd49014d6bf6a8fa3476dba733dec478e0ce
scifinet/Network_Automation
/DEVCOR/DEVASC/Birthday_JSON_p1.py
582
4.5
4
#### Creat Dictionary of people's birthdays and write a program that asks a user who's birthday they would like to look up ### ### CREATE DICTIONARY ### birthday_dict = { "Taylor":"04/15/1987", "Justin":"04/13/1990", "Ryan":"04/07/1990", "Nathan":"11/06/1991" } def main(): print("Welcome to the bi...
0c0f7ff5185a37d2d9c9d3ce49a68064c48341da
FatmanaK/leetcode-python
/solutions/reverse_nodes_in_k_group.py
2,166
3.84375
4
# Definition for singly-linked list. class ListNode: def __init__(self, x): self.val = x self.next = None class Solution: def reverseKGroup(self, head, k): """ :type head: ListNode :type k: int :rtype: ListNode """ if not head or not k: ...
eaaa5ae5e2ed33f7a34c5e78a3019bcbd6900b26
snowsmile1211/Be_A_Data_Scientist
/CSE 5526 Introduction to Neural Network/Programming Assignments/PA2/PA2 RBF online.py
7,214
3.890625
4
##### CSE 5526 Introduction to Neural Networks ##### ##### Programming Assignment 2 RBF ##### ##### Online Learning ##### import numpy as np import matplotlib.pyplot as plt class Cluster: def __init__(self,data,num_elements): ...
ec4bdd6c199cd240049a6c91d6fafc82f8ae9d90
pythonzhangfeilong/Python_WorkSpace
/9_Demo_数据分析常用模块/1_Matplotlib/2_NumPy Matplotlib/2_简单的绘图实例.py
503
3.578125
4
""" @File : 2_简单的绘图实例.py @Time : 2020/4/15 3:31 下午 @Author : FeiLong @Software: PyCharm """ import numpy from matplotlib import pyplot # 定义x轴的坐标 x=numpy.arange(1,11) # 定义y轴的坐标 y=2*x+5 # 坐标图的标题 pyplot.title('Matplotlib Demo') # x轴的名称 pyplot.xlabel('x axes') # y轴的名称 pyplot.ylabel('y axes') # 设置坐标参数 xp=[1,2,3,4] y...
252a97565b1f601b2b06c58081d0d18be726e7a2
Ritvik19/CodeBook
/data/Algorithms/Kth Smallest Element in BST.py
1,187
3.796875
4
class Node(): def __init__(self, data): self.data = data self.left = None self.right = None def __str__(self): return f"{self.data}" count = 0 def kthSmallestInBST(root, k): global count if root is None: return None left = kthSmallestInBST(root.left, k) ...
f8aba774f544c38fdd093a036d09cdcd589dfd20
Dieye-code/td_1
/python/exo26.py
602
3.53125
4
import array as ar n = 10 tab = ar.array('i', []) for i in range(n): print("entrer l'element à l'indice ", i+1) x = input() while x.isdigit == False or int(x) < 1 or int(x) > 100: x = input("Vous devez saisir un entier compris entre 1 et 100") tab.append(int(x)) dc = 1 c = 1 m = 1 for i in rang...
b527e0dc149e1c769f394ceaa9f9ae332c0fecfa
phaustin/ocgy-dataviewer
/station.py
473
3.53125
4
class Station: def __init__(self, type, lat, lon, name, colour): self.type = type self.lat = lat self.lon = lon self.name = name self.colour = colour def in_list(lat, lon, list): for s in list: if (s.lat == lat) & (s.lon == lon): return True retu...
e48aab14e9da972c252381366ac83b7042c42c01
zhangyan0814/python-homework
/python/sum-of-multiples/sum_of_multiples.py
200
3.65625
4
def sum_of_multiples(limit, multiples): count = 0 for i in range(limit): for x in multiples: if i%x == 0: count += i break return count
d030ac95158c21820c97764932f8605dbebdf953
phillybenh/Intro-Python-II
/src/player.py
2,068
3.765625
4
# Write a class to hold player information, e.g. what room they are in # currently. # * Put the Player class in `player.py`. # * Players should have a `name` and `current_room` attributes class Player: def __init__(self, name, current_room, victory=False): self.name = name self.current_room = cur...
bc6576d411f6b09e0bf38568568e16fc283dfd70
miketwo/euler
/p3.py
1,077
3.796875
4
#!/usr/bin/env python ''' The prime factors of 13195 are 5, 7, 13 and 29. What is the largest prime factor of the number 600851475143 ? ''' from itertools import count from time import time # Prints all primes for a given number. # Uses recursion def factor(number): # Divide the number by every prime lower than...
4dd2bf14a759e7fd7a3dd9e4488c0cd7c300713c
SouzaCadu/guppe
/Secao_06_Lista_Ex_62e/ex_53.py
331
3.96875
4
""" escreva um programa que leia um número inteiro positivo N e em seguida imprima N linhas do chamado Triangulo de Floyd. """ n = int(input("Digite o valor para o Triângulo de Floyd: ")) linhas = 1 for i in range(1, n + 1): for j in range(1, i + 1): print(linhas, end=" ") linhas = linhas + 1 ...
4371970da7d26c53e0900014804c0525cbc01b86
olgaloboda/Python-MIT
/Week2/Week2_task1.py
514
4.15625
4
# Write a program to calculate the credit card balance after one year if a person only pays the minimum monthly payment required by the credit card company each month. year = 12 while year >= 1: monthlyInterestRate = annualInterestRate / 12.0 minMonthlyPaymentRate = monthlyPaymentRate * balance monthlyUnpa...
a0a3ada9fd70ffaeacd75b8ee9c6944a243e620b
deep1409/Computer-Vision-Practicals
/practical2B.py
328
3.765625
4
# Python program to explain cv2.imread() method # importing cv2 import cv2 # path path = r'C:\\Users\\Deep\\Downloads\\\product-sans\\photo.jpg' # Using cv2.imread() method # Using 0 to read image in grayscale mode img = cv2.imread(path, 0) # Displaying the image cv2.imshow('image', img) cv2.waitKey(0) cv2.destroyAllWi...
9bc412b4791b001234141b5ad332fe989de0ee10
funnyuser97/HT_1
/task4.py
232
4.1875
4
# 4. Write a script to concatenate N strings. number=int(input('Input number of string: ')) list_string=[] for i in range(number): list_string.append(input()) all_string = ' '.join(list_string) print('All strings: ' ,all_string)
9597367f88e7e374c9513a665c61b482a91ab317
opentechschool-zurich/resources
/15-min-projects/ale/camel-case/main.py
356
4.21875
4
def dash_to_camel_case(text): result = '' nextUpper = False for c in text: if c == '_': nextUpper = True else: if nextUpper: result += c.upper() nextUpper = False else: result += c return result print(d...
bd8b7bc23b750074ff86be61c30e343ccd6803b4
msmr1109/Python
/area/fourbox_area.py
609
3.625
4
def area(boxes): s = [] for box in boxes: x1, y1, x2, y2 = box for x in xrange(x1, x2): for y in xrange(y1, y2): if contains(s, x, y): continue s.append((x,y)) return len(s) def contains(l, xpos, ypos): for t in l: x, y = t if...
1fd19d3051f81c7afe624225eabf8f5248f9af82
b0hd4n/multitarget_mt
/scripts/ignore_lines.py
1,069
3.625
4
#!/usr/bin/env python3 # filter out lines specified in another file import sys import argparse def main(): args = parse_args() skipped_lines_generator = get_skipped_line_generator(args.lines) with open(args.source, encoding='utf-8') as f_data: skip_line = next(skipped_lines_generator) for ...
916870799b9513e59d72c8eee773b140e84a67f0
ReWKing/StarttoPython
/if语句/5.4 使用if语句处理列表/voting.py
223
3.953125
4
age = 17 if age >= 18: print("You are old enough to vote!") print("Have you register to vote yet?") else: print("Sorry,you are to young to vote.") print("Please register to vote as soon as you turn to 18!")
12a2fc8796eb31a84a4d3f830739101321a68cdd
mohitraj/mohitcs
/Learntek_code/10_july_18/file1.py
136
3.5
4
file_txt = open("sample1.txt", 'r') i = 0 for line in file_txt: print line if 'is' in line: i = i+1 print i file_txt.close()
7be42beca9ceebe90fd285ce02a3c575fe8ca11f
rsairam34/sample
/range.py
251
4.1875
4
#range function print (range(10)) print (range(5,10)) print (range(0,10,3)) print (range(-10,-100,-30) list = ["mary","had","a","little","lamb"] for i in range(len(list)): print i,list[i] print "third edit locally" print "fifth change locally"
317061c9a2b60a7e897d0c054683f8fe67c22856
JKelle/ProjectEuler
/Euler060.py
1,244
3.515625
4
from math import sqrt import EulerUtils, sortedList maxSize = 1000000 sieve = EulerUtils.sieve(maxSize) primes = [i for i in xrange(len(sieve)) if sieve[i]] pairs = [] def isPrime(num): if num >= len(sieve): for n in xrange(2, int(sqrt(num))): if num % n == 0: return False return not num % in...
3d90761237e0030c401f5b0f5711d18d4d82bb84
ErrorCode51/ProjectEuler
/Euler_06.py
346
3.71875
4
import math sumSquares = 0 #de som van de kwadraten squareSum = 0 #het kwadraad van de som for i in range(100): sumSquares += math.pow(i+1, 2) for i in range(100): squareSum += (i + 1) squareSum = pow(squareSum, 2) print("sumSquares: ", sumSquares) print("squareSum: ", squareSum) print("Difference: ", ab...
b968535ae828d7df3dbc5c6789f6ac09c0b74310
ChengYaoYan/python-crash-course
/chapter2/name_cases.py
407
3.921875
4
name = "franklin liu" message = f"Hello, {name}. Would you like to learn Python today." print(message) name = "franklin liu" print(name.title()) print(name.lower()) print(name.upper()) person = "Albert Einstein" quote = "A person who never made a mistake never tried anything new" print(f'{person} once said, "{quote}"...
76cc72534bb68364221b5ff84077e781c953764f
thecodearrow/100-Days-Of-Code
/Primality Test.py
666
4.0625
4
t=int(input()) while(t!=0): t=t-1 #Fermat's theorem for primality #Remember Carmichael numbers fail this test n=int(input()) a=2 #test for a=3,4,5....n ferm=a**n-a if(ferm%n==0): print("yes") else: print("no") #OR n=int(input()) small_primes=[2,3,5,7,11,13,17...
2b490e27d1c3ef1d4175925360cad86098d6e3b9
ccdunn/euler
/e029.py
1,788
3.5625
4
""" Project Euler Problem 29 ======================== Consider all integer combinations of a^b for 2 a 5 and 2 b 5: 2^2=4, 2^3=8, 2^4=16, 2^5=32 3^2=9, 3^3=27, 3^4=81, 3^5=243 4^2=16, 4^3=64, 4^4=256, 4^5=1024 5^2=25, 5^3=125, 5^4=625, 5^5=3125 If they are then placed in numerical order, with any repeats rem...
a769f45b464fd82dad453d697d3d7728dc0becce
museHD/NCSS-Int-2020
/Cheer Squad/cheer_squad.py
598
4.3125
4
''' Write a program to cheer for your favourite sports teams! Your program should ask the user to input their team name and then print out a cheer like this: Team: Dolphins Give me a D! Give me a O! Give me a L! Give me a P! Give me a H! Give me a I! Give me a N! Give me a S! What does that spell? DOLPHINS! ​ Here's ...
bfa93e154cbe98ecb35f3915c505aba5c26ab406
Dreskiii1/CSE-231
/Exercises/Exercises Chapter 07/7.2.py
470
4.0625
4
##function 'return_list' goes here def return_list(the_string): new_list = [] the_string = the_string.replace(" ",",") the_string = the_string.split(",") if len(the_string) == 1: return the_string[0] else: for x in range(len(the_string)): new_list.append(the_string[x...
37083c7567c16e3feb4326f57e5657551549216b
imn00133/algorithm
/BaekJoonOnlineJudge/SolvedACClass/Class1/baekjoon_1330.py
182
3.78125
4
# https://www.acmicpc.net/problem/1330 # Solving Date: 20.03.27. a, b = (int(x) for x in input().split()) if a > b: print('>') elif a < b: print('<') else: print('==')
c24901df9f22915d7b0bb776ac5ff6630004da55
PrintTeamX/eBoys
/1D-2B.py
642
3.984375
4
a = float(input('Введіть магнітуду: ')) if a <= 2.0 and a >= 0: print('Мікро') elif a >= 2.0 and a <= 3.0 : print('Дуже слабкий') elif a >= 3.0 and a <= 4.0 : print('Слабкий') elif a >= 4.0 and a <= 5.0 : print('Легкий') elif a >= 5.0 and a <= 6.0 : print('Помірний') elif a >= 6.0 and a <= 7.0 : print...
40aca622b511e099e3f3ac8a37685bf8ec05d5b2
Adasumizox/ProgrammingChallenges
/codewars/Python/7 kyu/OddOrEven/oddOrEven_test.py
554
3.609375
4
from oddOrEven import oddOrEven import unittest from random import randint class TestOddOrEven(unittest.TestCase): def test(self): self.assertEqual(oddOrEven([0, 1, 2]), 'odd') self.assertEqual(oddOrEven([0, 1, 3]), 'even') self.assertEqual(oddOrEven([1023, 1, 2]), 'even') def tes...
728d67e559a99e78def4760679df473674c9a728
IvanIsCoding/OlympiadSolutions
/beecrowd/1165.py
547
3.59375
4
# Ivan Carvalho # Solution to https://www.beecrowd.com.br/judge/problems/view/1165 # -*- coding: utf-8 -*- """ Escreva a sua solução aqui Code your solution here Escriba su solución aquí """ ordem = int(input()) array = [] for i in range(ordem): array.append(int(input())) def primo(x): return ( x == ...
34e2e98b13cba6da6061d34ea85c3154549e0901
loc-dev/CursoEmVideo-Python
/Fase09/03_Transformacao_02.py
869
4.125
4
# Fase 09 - Manipulando Texto # Teoria # Técnica de Transformação # Iremos alterar o valor da variável 'frase' frase = ' Aprenda Python ' print('É comum na área de tecnologia, pessoas incluir espaços na caixa de texto') print(frase) # As linguagens de Programação apresenta funcionalidades internas para remoção d...
44dd3947ee1d77b13b833c33bbdb53ebe5464ad2
globocom/dojo
/2021_03_31/dojo.py
1,498
3.6875
4
def append_string_value(c, value): if len(value) == 0: return c return (int(value)*c) def main(input_string, max_length): value = "" decoded_string = "" for c in input_string: if c.isdigit(): value = value + c else: decoded_string += append_str...
aa6ff500dee33136a90c2b8a73889a062b6b65ce
DavidMFreeman34/NoahDavidCollab
/pinwheel_color_winter.py
2,834
3.53125
4
#----------------------------------------- # Python + matplotlib + numpy + mpmath # Created by David Freeman (2016) with consultation from Noah Weaver # Modified from http://www.bubuko.com/infodetail-911894.html #----------------------------------------- import matplotlib.pyplot as plt import matplotlib as mpl impor...
2c7bf82d0805dfbf4801c74fdb856e1de0de138c
prabhu30/coding
/Hackerrank/19 _ Capitalize!/solution.py
141
3.703125
4
# Complete the solve function below. def solve(s): a_string = s.split(' ') return ' '.join((word.capitalize() for word in a_string))
76a428d76b75b5aba3211ac7f1cbb67a88463186
HishamKhalil1990/data-structures-and-algorithms
/python/code_challenges/fifo_animal_shelter/fifo_animal_shelter/fifo_animal_shelter.py
2,641
4.03125
4
class Cat: def __init__(self,value = "cat"): self.value = value self.next = None def __str__(self): return f"{self.value}" class Dog: def __init__(self,value = "dog"): self.value = value self.next = None def __str__(self): return f"{self.value}" class ...
9b65ccc0564ef8ccafb36fb63cb6086619cde85a
scottberke/algorithms
/test/practice_problems/search/rotated_array_test.py
875
3.75
4
import unittest import random from collections import * from practice_problems.search.rotated_array import * class RotatedArrayTest(unittest.TestCase): def create_rotated_array(self, skip=1, high=100): arr = deque(list(range(1, high, skip))) rotate_by = random.randint(1, high//2) arr.rotat...
18820dbc56bdc76c3a400faadd34eab849fb63f3
adonismendozaperez/codewars-algorithm
/Algorithm/ConvertStringToCamelCase.py
501
4.4375
4
#Convert string to camel case # Complete the method/function so that it converts # dash/underscore delimited words into camel casing. # The first word within the output should be capitalized # only if the original word was capitalized. def to_camel_case(text): result = "" count = 0 for val in text.repl...
df19960b30479be8642f9f63908b65ffb85002ad
dinhthi1102/pam
/btth5.1.py
224
3.65625
4
## file : mymarth.py ## def square(n): return n*n def cube(n): return n*n*n def average(values): nvals = len(values) sum = 0.0 for v in values: sum += V return float(sum)/nvals