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
d85efdbf7e4b40051bf2026e43254286c014e3f8
SueAli/cs-problems
/LeetCode/Intersection_of_Two_Arrays.py
743
3.640625
4
class Solution(object): def intersection(self, nums1, nums2): """ :type nums1: List[int] :type nums2: List[int] :rtype: List[int] Let's say len(nums1) = n & len(nums2)=m Total time complexity = O(min(n,m)) + O(n * logn) + O(m * log m) Auxilary space compexity...
2ec167e6cf4f0ae7c47029c30fa9d4028ad13b3e
J21TK/GuessGame
/GuessGame_3.py
2,738
3.875
4
#coding: utf-8 import random class Player: def __init__(self, test_range): self.low = 1 self.high = test_range self.history = [] def interpreter(self, func_name): if func_name == 1: return self.random_guess elif func_name == 2: return self.half...
75acbd59c9dd91a23a6501c2bf21cd925e3ab93f
waterwheel31/datastructure_algoithm_1
/Task2.py
1,160
3.984375
4
""" Read file into texts and calls. It's ok if you don't understand how to read files """ import csv with open('texts.csv', 'r') as f: reader = csv.reader(f) texts = list(reader) with open('calls.csv', 'r') as f: reader = csv.reader(f) calls = list(reader) """ TASK 2: Which telephone number spent the ...
1832690e4d251f909954ec86aa3cdef3bbfc6424
Rapt0r399/HackerRank
/Python/Introduction/Print Function.py
279
3.625
4
# Enter your code here. Read input from STDIN. Print output to STDOUT x = raw_input() x = int(x) i = 1 p = 0 while (i<=x) : if i< 10 : p = p*10 + i elif i>=10 and i<100 : p = p*100 +i elif i>=100 and i<10000 : p = p*1000 +i i = i+1 print p
0a829bccb2463a108e2d99be621c41dca24c8268
jaylyerly/python_demo
/some_builtins.py
1,888
4.28125
4
#!/usr/bin/env python # Built-in python functions # Most import -- help() and dir() # help(foo) -- return the docstring for foo. Most built-ins are documented # this way. help(open) # display the docs for 'open' (used to open files) help("foo".lstrip) # display the docs for the string method lstrip # dir(...
bbb4755a86a912ca506911d40454da7d63943c47
alane001/Comp-Methods
/Week2/Ex1.py
1,555
3.859375
4
import numpy as np #This is for a general integration, the function must be calculated before putting it through this subroutine. These functions take in two arrays, on as the x value and one as the y value from the input of x into the y function #Trapezoidal rule def trapez(x, y): # Trapezoid equation: I = h [0.5*f...
2e6981efe05195bf6357a09c1cc4d5fe387429e1
Bertram-Liu/Note
/NOTE/15_Data_analysis/day04/demo06_aaa.py
302
3.734375
4
""" demo06_aaa.py 轴向汇总 """ import numpy as np data = np.arange(1, 13).reshape(3, 4) print(data) # 轴向汇总 def func(ary): return np.max(ary), np.mean(ary), \ np.min(ary) r = np.apply_along_axis(func, 1, data) print(r) r = np.apply_along_axis(func, 0, data) print(r)
17e558516903ce093450d17f34ed4b15e35791af
negibokken/sandbox
/leetcode/2085_count_common_words_with_one_occurrence/main.py
734
3.515625
4
#!/usr/bin/python3 from typing import List import json from bplib.butil import TreeNode, arr2TreeNode, btreeconnect class Solution: def countWords(self, words1: List[str], words2: List[str]) -> int: mp = {} for w in words1: if w not in mp: mp[w] = 0 mp[w] +...
57e46a78bc76176251772eb087f691be1ff8bf1b
LauraValentinaHernandez/Taller-estructuras-de-control-selectivo
/Ejercicio9.py
1,941
4.3125
4
""" En una tienda efectúan un descuento a los clientes dependiendo del monto de la compra. El descuento se efectúa con base en el siguiente criterio: a. Si el monto es inferior a $50.000 COP, no hay descuento. b. Si está comprendido entre $50.000 COP y $100.000 COP inclusive, se hace un descuento del 5%. c. Si está com...
5a60c70ad95dc80dee999928ea3b5c12206fbbef
dbomard/BingMap
/TileSystem.py
5,345
3.625
4
""" Adaptation en Python d'après fichier microsoft initialement écrit en C# par Joe Schwartz 30/05/2020 David Bomard """ from math import cos, pi, sin, log, atan, exp EARTH_RADIUS = 6378137 MIN_LATITUDE = -85.05112878 MAX_LATITUDE = 85.05112878 MIN_LONGITUDE = -180 MAX_LONGITUDE = 180 def Clip(n, min_value, max_val...
4e754c0af31bf67635c80c77ba7dca756660e98e
kdockman96/CS0008-f2016
/Ch6-Ex/ch6-ex5.py
384
3.71875
4
# Define the main function def main(): # Initiate an accumulator variable total = 0 # Open the numbers.txt file infile = open('numbers.txt', 'r') # Read the numbers from the file for line in infile: amount = int(line) total += amount # Close the file infile.close() # ...
e58fb669809b04bbdb729c07306e2e9fdf439d4b
Helen-Sk-2020/Loan_Calculator
/Topics/Elif statement/The farm/main.py
716
3.796875
4
chicken = 23 goat = 678 pig = 1296 cow = 3848 sheep = 6769 count = 1 money = int(input()) if money < chicken: print('None') elif goat > money >= chicken: n = money // chicken if n == count: print(f'{n} chicken') else: print(f'{n} chickens') elif pig > money >= goat: n = money // goat...
413fa2dc4777dbfc4c4ae27ba0ecf39bb1546937
ydwng/UCI_MATH_10
/sections/sec_05/Vector.py
1,014
4.09375
4
#!/usr/bin/env python # coding: utf-8 # In[1]: class VectorV5: '''define the vector''' # this is the document string dim = 2 # this is the attribute def __init__(self, x=0.0, y=0.0): # any method in Class requires the first parameter to be self! '''initialize the vector by providing x and...
450e6a25d0f8f8d6f8e6d32d1796b397e3a6bd0f
rpm1995/LeetCode
/1057_Campus_Bikes.py
1,012
3.609375
4
import heapq class Solution: def assignBikes(self, workers: List[List[int]], bikes: List[List[int]]) -> List[int]: distances = [] for worker, (work_x, work_y) in enumerate(workers): distance = [] for bike, (bike_x, bike_y) in enumerate(bikes): manhattan =...
98712493db3f1057a20001b30678b4d2b2070495
magedu-pythons/python-14
/tianwei/week11/Sentence.py
572
3.8125
4
#根据字典,从一个抹去空格的字符串里面提取出全部单词组合,并且拼接成正常的句子: #例如: 输入一个字符串:"thisisanexample", 程序输出: "this is an example" dic={'1':'this','2':'is','3':'an','4':'example','5':'hello'} str="thisisanexample" def sentence(dic,str): strout="" start=0 while True: if start==len(str): break for v in dic.values(): ...
1017748992394a10c00a4ee3e8f9d9a081e12bab
SebastianMaciasI/Mision-02
/auto.py
547
3.71875
4
# Autor: Sebastian Macias Ibarra, A01376492 # Descripcion: Sacar los kilómetros recorridos para 7 y 4.5 horas y el tiempo para 791 km # Escribe tu programa después de esta línea. velocidad = int (input ("Escribe la velocidad del auto en km/h: ")) distancia1 = velocidad * 7 distancia2 = velocidad * 4.5 tiempo = 791 / ...
a84b4ab62861e5466f6b40e26c9c152986a06d8b
Talha089/Python-for-Everybody
/Using Python to Access Web Data/Week2_RegEx/extractingdata1.py
190
3.9375
4
import re # matching and extracting numbers #[0-9] one digit # + means that it will give the one or more digit x = 'My 2 favorite numbers are 19 and 42' y = re.findall('[0-9]+', x) print(y)
3e20b402579636bc2c55132c22587a7d52c3293b
srajulu/Python-basics
/sumfunction.py
176
3.6875
4
def sum4(l): "Print sum of four numbers" s=sum(l) return s l=[] for i in range(0,4): l.append(int(input("Enter num: "))) k=sum4(l) print("Sum is: ",k)
22fc995c5ed441448e9647e8a5c5a03954a6fbfe
sharozraees802/Data_Structure-python-
/A1/A.py
2,947
3.796875
4
import numpy as Array # import nparray as ar user = int(input("Enter a number of Element: ")) fib = Array.array([0 for i in range(user+1)]) fib1 = Array.array([0 for i in range(user+1)]) fib2 = Array.array([0 for i in range(user+1)]) # s = ar.array([0 for i in range(user+1)]) # fib=Array.insert() fib[0]=0 fib[1]=1 f = ...
1a6389725f0431e487b35900823fcc4cf7a51eb1
Muhammad12344/ca117
/week07/lab1/point_071.py
302
3.71875
4
from math import sqrt class Point(object): def __init__(self, x=0, y=0): self.x = x self.y = y def reflect(self): self.x = -self.x self.y = -self.y def distance(self, p): dist = sqrt((p.x - self.x) ** 2 + (p.y - self.y) ** 2) return dist
c3b996bf62b6cbd83e724bde3f307c2c7164ce14
Nuhvok/Work-Show-
/functions.py
526
4.125
4
#!/usr/bin/env python3 # -*- coding: cp1252 -*- def main(): print_name() give_temp() if_test() give_temp() def print_name(): fname = input("Enter your first name: ") lname = input("Enter your last name: ") fullname = fname + " " + lname print("Your name is:", fullname) ...
86d14c67fee0480429d3bed5d61866ed91dbd84f
kuljotanand/cornell-tech
/crypto/hw1/MyFeistel.py
9,239
4.03125
4
# Homework 1 (CS5830) # Daniel Speiser and Haiwei Su from cryptography.hazmat.primitives import hashes, padding, ciphers from cryptography.hazmat.backends import default_backend import base64 import binascii import os def xor(a,b): """ xors two raw byte streams. """ assert len(a) == len(b), "Lengths o...
ee4cfef63d5ba17af1242afe7d5aadfdb023d11b
Poojapanchal1208/Poojapanchal1208
/Pooja Docs/PoojaAssignment#1.py
3,088
4.09375
4
import sys def Menu(): print("...........Menu.........") print("1:Grilled Sandwich $10 ") print("2:Hakka Noodles $22 ") Snacks = int(input("Choose your snack:")) if Snacks == 1: price = 10 return price, str("Grilled Sandwich") else: price = 22 return price, str...
a82c6a7bb32d56383b67c7b815ed73c048eeaa57
Lesuz/Python-Application-Course
/Applications/Week 9-10 Morse Coder.py
2,803
3.6875
4
#Week 9-10 Morse Coder from tkinter import * class MorseCoder: morseCode = {'A':'.-', 'B':'-...', 'C':'-.-.', 'D':'-..', 'E':'.', 'F':'..-.', 'G':'--.', 'H':'....', 'I':'..', ...
7ab19b2979a4c7d0bef776a7e2dcd43ec87ba180
az-cheng/Invaders_Game_Project
/invaders/wave.py
15,537
4.1875
4
""" Subcontroller module for Alien Invaders This module contains the subcontroller to manage a single level or wave in the Alien Invaders game. Instances of Wave represent a single wave. Whenever you move to a new level, you are expected to make a new instance of the class. The subcontroller Wave manages the ship, ...
d7e36ef7cd85974b4136cbf59bc9f92c80418e7d
Szymchack/CIT228
/Chapter10/glossary.py
2,994
3.953125
4
import json def menu(): selection= int(input("1-create file, 2-read file, 3-add to file, 4-quit")) while selection!=1 and selection!=2 and selection!=3 and selection!=4: print("You made an invalid selection, please try it again") return selection def create(object): overwrite = ...
6889b62ada6c775a00c29b47f0bbd26af6ecc622
yotaroy/python_algorithms
/algorithm/basic/gcd.py
603
3.90625
4
# 最大公約数を求める def gcd(x, y): if x < y: x, y = y, x if y == 0: return x return gcd(y, x % y) # 再帰を使わないバージョン def gcd2(x, y): if x < y: x, y = y, x while y != 0: r = x % y x = y y = r return x if __name__ == '__main__': problems = [(60, 36), (108...
33c953df48ee51816304e94012b6058200b3068b
leeeeeoy/Algorithm_Study
/Problems/5th_week/leetCode92/mingyu/Reverse_Linked_List_2.py
2,619
3.84375
4
""" LeetCode 92. 역순 연결 리스트 2 url: https://leetcode.com/problems/reverse-linked-list-ii/ writer: Mingyu Language: Python3 Date: 2021.02.14 Status: , Runtime: ms, Memory Usage: KB """ # 리스트노드의 구조 class ListNode: def __init__(self, val=0, next=None): self.val = val self.next = next class Solution: ...
392f5a9ab92ef7e8bf18a65930dc9b2756ea48b0
opencodeiiita/Road-CS
/Submission/Lalit(Week-4)/brute.py
1,003
3.65625
4
import zipfile import argparse def extractFile(zFile, password): try: zFile.extractall(pwd=password) print "[+] Found password = " + password return True except: return False def main(): parser = argparse.ArgumentParser("%prog -f <zipfile> -d <dictionary>") parser.add_argument("-f", dest="zna...
b94da4860518ca7474a2a6f0f24ce9973c182343
Atuan98/Demo_py1
/Lession_11/btvn_1.py
369
3.84375
4
class Dog: species = 'animal' def __init__(self, name, age): self.name = name self.age = age def get_biggest_number(*args): max_ = args[0] print(args) for i in args: if i > max_: max_ = i print(f"The oldest dog is {max_} year old") dog1 = Dog('Fake', 2) dog2 = Dog('Mickey', 7) dog3 = Dog('Fuk', 5...
dfbd9966b4359c0f891f9ead454a000a3a8d8006
ruraj/stackoverflow-python
/iterm.py
827
3.765625
4
"""http://stackoverflow.com/questions/24825366/python-how-to-cut-a-list-which-contains-lists/24827627#24827627 """ list1 = [ [1,2,3,4], [5,6,7,8], [9,10,11,12] ] list2 = [ [50,45,40,35], [30,25,20,15], [10,9,5,0] ] list3 = [ [101,2,3,33], [11,22,30,1], [1,22,33,] ] def func_index(reference, number): ind...
87f2df453df6318368fc482aa517c1ac294f7354
number09/atcoder
/code_thanks_festival_2017-a.py
102
3.65625
4
li_t = list() for i in range(8): li_t.append(int(input())) print(sorted(li_t, reverse=True)[0])
8a85ff96e2e4a4ff613d1f9a1d9bccd89e457407
gssasank/Basic-Algorithms-Projects
/Search-in-a-Rotated-Sorted-Array/problem_2.py
2,333
4.375
4
def rotated_array_search(input_list, number): """ Find the index by searching in a rotated sorted array Args: number: input_list(array), number(int): Input array to search and the target Returns: int: Index or -1 """ if len(input_list) == 0 or number is None: return...
dbdf72419af77fbd44e41188c97063c06e13b207
klrkdekira/adventofcode
/2021/15/main.py
1,649
3.625
4
import heapq grid = [] with open("input") as file: grid = list(map(lambda x: x.strip(), file)) def lookup(grid, p=(0, 0)): return int(grid[p[1]][p[0]]) adjacent = [ (0, 1), (1, 0), (0, -1), (-1, 0), ] def find_neighbours(grid, start=(0, 0)): x, y = start n = [] for dx, dy in ...
c44b1fbbada2c3e198a9de8fd37e5d985461826b
tomasmu/aoc2020
/aoc09.py
1,171
3.59375
4
# imports import collections import functools import itertools import os import re # input file = os.path.basename(__file__).replace('.py', '_input.txt') raw_input = open(file).read() if re.search('\n\n', raw_input): puzzle = raw_input.split('\n\n') else: puzzle = raw_input.splitlines() puzzle = [int(n) for ...
2de9c3ded00b7c2089146c2a1fbad81518d18606
Jose0Cicero1Ribeiro0Junior/Curso_em_Videos
/Python_3/Modulo 3/2 - Listas em Python/Exercício_079_Valores_únicos_em_uma_Lista_v0.py
708
4.25
4
#Exercício Python 079: Crie um programa onde o usuário possa digitar vários valores numéricos e cadastre-os em uma lista. Caso o número já exista lá dentro, ele não será adicionado. No final, serão exibidos todos os valores únicos digitados, em ordem crescente. lista_num = [] while True: num = int(input('Digite um ...
e3fe1734f9c19a9dc5ea92f9340e501c8b8a8e03
papan36125/python_exercises
/concepts/Exercises/list_functions.py
651
3.875
4
lucky_numbers = [4,8,15,16,23,42] friends = ['Kevin', 'Karen', 'Jim', 'Oscar','Toby'] print(lucky_numbers) print(friends) friends.extend(lucky_numbers) print(friends) friends.append('Creed') print(friends) friends.insert(1,'Kelly') print(friends) friends.remove('Jim') print(friends) friends.clear() print(f...
d36156c309b1ab80fa001162ada4a51694e851d1
cchlanger/python-bookclub
/101 python excercises_part1_MP.py
2,033
3.890625
4
import numpy as np print(np.__version__) np.arrange(0,10,1) np.ones((3,3), dtype=np.bool_) np.ones((3,3), dtype=bool) arr = np.array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) arr[1::2] arr = np.array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) arr[1::2]=-1 arr arr = np.array([0, 1, 2, 3, 4, 5, 6, 7, 8, 9]) arr_copy=arr.copy() arr_copy[1::2]...
8fc8598e20b8dc322be8b8dedc8f9134b31de25a
oratun/Py-LeetCode
/rotate_48.py
1,011
3.84375
4
""" 48 旋转数组 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 变换过程: matrix[i][j] -> matrix[j][n-1-i] matrix[j][n-1-i] -> matrix[n-1-i][n-1-j] matrix[n-1-i][n-1-j] -> matrix[n-1-j][i] matrix[n-1-j][i] -> matrix[i][j] """ from typing import List class Solution: def rotate(self, matrix: List[List[int]]) -> None: ...
3a2ab445be28e3da8491cc57473ba43252435d4a
ravisjoshi/python_snippets
/Strings/LongestUncommonSubsequenceI.py
1,496
4.21875
4
""" Given two strings, you need to find the longest uncommon subsequence of this two strings. The longest uncommon subsequence is defined as the longest subsequence of one of these strings and this subsequence should not be any subsequence of the other string. A subsequence is a sequence that can be derived from one se...
9a1951007bd2fbc1c6654b51947a2ed0d951c5f4
AveryHuo/PeefyLeetCode
/src/Python/701-800/746.MinCostClimbingStairs.py
601
3.671875
4
class Solution: def minCostClimbingStairs(self, cost): """ :type cost: List[int] :rtype: int """ p_2, p_1 = cost[0], cost[1] for c in cost[2:]: p_2, p_1 = p_1, min(p_1 + c, p_2 + c) return min(p_2, p_1) if __name__ == '__main__': solution ...
b281e50c15c0924adf57f766175f4865f44ad76a
FrancescoPenasa/UNITN-CS-2018-Intro2MachineLearning
/exercise/exercise1.py
1,007
4.21875
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Tue Feb 19 08:59:26 2019 @author: francesco """ # EXERCISE 1: #Given a list of integers, without using any package or built-in function, compute and print: # - mean of the list # - number of negative and positive numbers in the list # - two lists that conta...
d1d434292e892e72863a15da07423d262e15fd0f
BLACKGOATGG/python
/basic-knowledge/py_7_类及类模块/class:使用类和实例.py
3,347
4.0625
4
# =========================================================== print('\n使用类和实例') # 可以使用类来模拟现实世界中的很多情景。 # 类编写好后,你的大部分时间都将花在使用根据类创建的实例上。 # 你需要执行的一个重要任务是修改实例的属性。 # 你可以直接修改实例的属性,也可以编写方法以特定的方式进行修改。 class Car(): """一次模拟汽车的简单尝试""" def __init__(self, make, model, year): """初始化描述汽车的属性""" self.make = make...
7d407755c4c92cc788ec1098f1217f4881af146e
zaXai558/CodeForces_Easy
/codeforces/Team.py
148
3.59375
4
n=int(input()) num=0 while(n!=0): n-=1 k=input() if(k.count('1')>=2): num+=1 print(num)
9455b284047330f32a659d3ab45dade636135c5a
Maxim-Kazliakouski/Python_tasks
/Programmers_names.py
649
4
4
num = 0 while num != 1001: num = int(input("Введите новое число программистов: ")) if (num % 10 == 0) or (5 <= num % 10 <= 9) \ or num == 11 or num == 12 or num == 13 or num == 14 \ or num % 100 == 11 or num % 100 == 12 or num % 100 == 13 or num % 100 == 14: print(num, "программи...
65ef7708db1ca5337651df3d75ef8ee249e6a62c
Kristof95/LearnPythonTheHardway
/ex36.py
990
3.953125
4
def story(): print("Welcome AHYA!") print("""Your name is AHYA You're a warrior, in a merciless world your purpose is protect your village from the trolls, if you want to make an end of trolls attack, you must kill them.""") def fight(): begin = input("Do you want to kill some trolls?:") if begin.lowe...
69218353bd392839439d6084fed19cfedd4b57b0
cristinasofia/coding-practice
/graphs/python/bfs/word-ladder.py
1,043
3.53125
4
def ladderLength(beginWord, endWord, wordList): """ :type beginWord: str :type endWord: str :type wordList: List[str] :rtype: int """ import string q = [[beginWord,1]] while q: w, l = q.pop(0) if w == endWord: return l for i in ra...
e94d78ed9fbfa89018541fb7477076bd4d906035
CPE202-PAR/project-1-enzosison
/perm_lex.py
499
3.78125
4
# string -> List of strings # Returns list of permutations for input string # e.g. 'ab' -> ['ab', 'ba']; 'a' -> ['a']; '' -> [] def perm_gen_lex(str_in): list = [] if not str_in: return [] if len(str_in) == 1: return [str_in] for i in range(len(str_in)): new_string = st...
c014d57f3e5d7fb5e83032c0f0295e179594d5ae
Lok-Aravind-Palu/python-practice
/Practice/AbstractExample.py
365
3.796875
4
from abc import ABC, abstractmethod class ExampleAbstractMethod(ABC): @abstractmethod def move(self): print("Can walk and run....") class ExampleImportAbstractMethod(ExampleAbstractMethod): def move(self): print("can crawl") def main(): a = ExampleImportAbstractMethod() a.mo...
50972ff56a9607b3d72b9c526c20a03fe7b9d55b
gu9/testpython-
/pg01_gu9.py
11,816
3.578125
4
import time #ASSIGNMENT Submitted by Gurpreet Singh(1446185-Student_id) #provide Numeric input in the timeout varible otherwise program will not give required output #I have written this whole code by myself so there will be no external refrence link except python.org , stackoverflow.com and class notes #I am usi...
d93ad9834f32f1cb3878d2983722d3822b930aca
omrigo13/Intro
/hw6/hw6_ques1.py
2,092
3.75
4
# *************** EXERCISE 6 *************** # ************************************************************** # ************************ QUESTION 1 ************************** def partition(lst,values_lst,count_liora = 0, count_yossi = 0, mem = {}): """ gets a list of building prices to divide between Liora and...
99b5c382820df7f9207d46408a4b171fb24d2f4b
liangyf22/test
/01_函数/递归函数.py
719
3.859375
4
''' 1、函数里调用函数本身 2、有递归边界 通过递归函数实现任意数的阶乘 ''' import json def js(num): if num == 1: return 1 else: return num * js(num - 1) print(js(3)) # 斐波那契数列 # 斐波那契数列指的是这样一个数列 0, 1, 1, 2, 3, 5, 8, 13,特别指出:第0项是0,第1项是第一个1。从第三项开始,每一项都等于前两项之和。 def fbnq(n): if n == 1: return 0 elif (n == 2 o...
14bf166c43a1d423aa1cb630ae934c21f1182010
wangkangreg/LearnPython
/src/tuple/dict_sort.py
483
4.21875
4
# -*- coding:utf-8 -*- ''' Created on 2015年11月6日 @author: Administrator ''' dict = {'a':'apple', 'b':'banana', 'c':'orange', 'd':'banana'} print dict #{'a': 'apple', 'c': 'orange', 'b': 'banana', 'd': 'banana'} #按key排序 print sorted(dict.items(), key=lambda d: d[0]) #[('a', 'apple'), ('b', 'banana'), ('c', 'orange'),...
1a837bc9795ecf80d983728bb22188f464160a31
doronweiss/pythontesta
/AirTouch/SunCalc.py
762
3.796875
4
import math from math import * import plotly.express as px import numpy as np import matplotlib.pyplot as plt # https://www.pveducation.org/pvcdrom/properties-of-sunlight/elevation-angle # https://www.pveducation.org/pvcdrom/properties-of-sunlight/declination-angle latitude = radians(31.240239) longitude = radians(34....
1653d80773e66a6a61a2adaac0a57c0592ce1c3d
JerrodTanner/negative-strip-colorizer
/hw01_tanner.py
4,178
3.578125
4
''' Author: Jerrod Tanner Date: 20 February 2020 ''' import numpy as np import cv2 import matplotlib.pyplot as plt import sys xTranslation = 0 yTranslation = 0 def translate(I, x, y): ''' Translate the given image by the given offset in the x and y directions. ''' rows, cols = I.shape[:2]...
5d52f6e0064d514e1663d27fffad0dbc8d468620
bkz7354/python_sem4
/HW_1/task1.py
1,248
3.953125
4
#!/usr/bin/env python3 class Human: default_name = "Aaron" default_age = 40 def __init__(self, name=default_name, age=default_age): self.name = name self.age = age self.__money = 0 self.__house = None def info(self): return self.name, self.age, self.__money, s...
6ba324b43d767a32fb32b6e60b14138838ff7478
v1ktos/Python_RTU_08_20
/Diena_6_lists/lists_g2.py
2,537
3.671875
4
# a1 = 5 # a2 = 6 # a3 = 7 my_list = [5, 6, 7] print(my_list) my_list[0] gen_list = my_list + ["Valdis", "Līga", True, 3.14] print(gen_list) print(min(my_list), max(my_list)) sum(my_list) sum(gen_list) gen_list gen_list[:3] gen_list[-3:] gen_list gen_list[1::2] gen_list[1:4:2] gen_list[::-1] 6 in gen_list 8 in gen_list...
85273bf25f97a8620b33dcb00a660fcec4fd142f
CodeForContribute/Algos-DataStructures
/DP/matrixChainOrder.py
1,275
4.1875
4
""" Problem Statement ================= Given an array p[] which represents the chain of matrices such that the ith matrix Ai is of dimension p[i-1] x p[i]. We need to write a function matrix_chain_order() that should return the minimum number of multiplications needed to multiply the chain. Video ----- * https://youtu...
39f466dd693667723a126509177a4871f35bd9fe
RainEnigma/Final_project-ITEA
/contact_book/main_functional/main.py
1,153
3.90625
4
import file_operstions, input_contact,finding_contact import CONSTANCE def main(): while True: print() inputed_letter = input("-=Please type what you want to do with your adressbook?=-\n" "a - add a user\n" "c - close\n" ...
0e2354791d7115ea89589234f2f2b9c5ec50aeca
TyrannousHail03/PythonProjects
/DiceRollingGame.py
1,083
4.34375
4
'''This program rolls a pair of dice and asks the user to guess the sum of the dice. If the user guesses correctly, they win. his program was initially written during my run through of CodeAcademy's Python course.''' from random import randint from time import sleep def get_user_guess(): guess = int(input("Wh...
bacaf5bce0f805d33fc4754a7c03c0e7735a62f9
moon729/PythonAlgorithm
/2.배열/max_of_test_randint.py
455
3.84375
4
#배열 원소의 최댓값을 구해서 출력하기(원솟값을 난수로 생성) import random from max import max_of print('난수의 최댓값 구하기') num = int(input('난수의 개수 입력 : ' )) min = int(input('난수의 최솟값 입력 : ' )) max = int(input('난수의 최댓값 입력 : ' )) x = [None] * num for i in range(num): x[i] = random.randint(min, max) print(f'{x}') print(f'배열에서 최댓값은 {max_of(x)}임...
b342f84f9a2bb44e8d8ffb00e6330024956c8a7a
Autodidact7999/Attendance-System-Using-Face-Identification
/sample.py
2,564
3.71875
4
import tkinter as tk window=tk.Tk() window.title("Face_Recogniser") dialog_title = 'QUIT' dialog_text = 'Are you sure?' # answer = messagebox.askquestion(dialog_title, dialog_text) # window.geometry('1280x720') window.configure(background='black') # window.attributes('-fullscreen', True) window.grid_rowconfigure(0, ...
b50bb8377fa39af919017d81b46de920f9e2273c
altanai/computervision
/colorspace/colorspace_rgb.py
1,044
3.8125
4
import cv2 image = cv2.imread('ramudroidimg.jpg') # opencv's split function splits the image into each color index B,G,R = cv2.split(image) cv2.imshow("Red",R) cv2.imshow("Green",G) cv2.imshow("Blue",B) # make the original image by merging the individual color components merged = cv2.merge([B,G,R]) cv2.imshow("merged...
8aee25cff17263fca15fcfbe29870b79b00f70ee
mateoadann/Ej-por-semana
/Ficha 2/ejercicio2Ficha2.py
639
4
4
# 2. Descuento en medicinas # Calcular el descuento y el monto a pagar por un medicamento cualquiera en una farmacia (cargar por teclado el precio de ese medicamento) # sabiendo que todos los medicamentos tienen un descuento del 35%. # Mostrar el precio actual, el monto del descuento y el monto final a pagar # Dates m...
1a28b452ec8b00641d596b98374897d65a1b4ae2
FalseF/Algorithms-and-Problem-Solving-with-Python
/FalsePositionMethod.py
623
3.890625
4
def FalsePosition(f,x1,x2,tol=1.0*10**-6,maxfpos=20): xh = 0 fpos = 0 if f(x1) * f(x2) < 0: for fpos in range(1,maxfpos+1): xh = x2 - (x2-x1)/(f(x2)-f(x1)) * f(x2) if abs(f(xh)) < tol: break elif f(x1) * f(xh) < 0: x2 = xh else...
eabce618fad53351bf4d8557486ad4009b532939
gabriellaec/desoft-analise-exercicios
/backup/user_282/ch23_2020_03_04_22_48_31_712702.py
157
3.671875
4
velocidade = int(input('qual eh a velocidade? ')) if velocidade>80: print('multa de R${0}'.format((velocidade-80)*5)) else: print('Não foi multado')
6721bbc0b0db2e360b464fdb1526c983d3c327e5
zouvier/Calculator
/TkinterCalculator.py
4,863
3.828125
4
# todo: [SOLVED] Create an interface for calculator # ~used tkinter # todo: [SOLVED] Work on multiplication function(figure out how to implement the function) # ~ created an if/elif statement that takes in a global variable that is altered depending on the function # ~ this allows me to keep track of which ...
12227a4840bfef6b0d127f8d2b4afca49599498e
Xnkr/py-vigilant-barnacle
/interactivepython/bubblesort.py
464
3.78125
4
def bubblesort(a): num_iter = len(a)-1 for passes in range(num_iter,0,-1): for i in range(passes): if a[i] > a[i+1]: temp = a[i] a[i] = a[i+1] a[i+1] = temp return a def shortbubble(a): exchange = True num_iter = len(a)-1 while num_iter > 0 and exchange: exchange = False for i in range(n...
1f6c3c550438b9216aaa0b604fade3f6bb880883
JDGC2002/Algoritmos-y-estructuras-de-datos
/Clases/CLASE 6-09/ejercicio4.py
243
3.859375
4
# convierta la siguiente frase en un diccionario: words = "Biomédica:35-Medicina:14-Nutrición:22-Derecho:2" words = words.replace(':', '-') words1 = words.split('-') print(words1) it = iter(words1) res_dct = dict(zip(it, it)) print(res_dct)
0028ff8519ade12e06ef945b6439a4b36e17d851
chevery/Project2
/FINAL GAMES/CHARLIE.py
12,512
3.5625
4
#/usr/bin/python """ A simple game of whacking simple things with a hammer """ #import modules import os, pygame import sys from random import choice BLACK = (0, 0, 0) WHITE = (255, 255, 255) RED = (255, 0, 0) GREEN = (0, 255, 0) BLUE = (0, 0, 255) GRAY80 = (26, 26, 26) YELLOW = (255, 255, 0) GR...
775e499117ecc325d71ac163d0a0895846a15e9b
CheesyModz/Python-Games
/Pacman/myPacmanSprites.py
2,638
3.90625
4
import pygame, random class Cherry(pygame.sprite.Sprite): '''A simple Sprite subclass to represent static Cherry sprites.''' def __init__(self, screen): # Call the parent __init__() method pygame.sprite.Sprite.__init__(self) # Set the image and rect attributes for the cherrie...
30692c110f46fb5517f4373d487517fceb39da54
toujoursfatigue/ING231-Algoritma
/Alistirmalar-II/alistirma-1.py
1,262
3.515625
4
import random def masterminddef(): try: kullanici_sayisi = int(input("10 ile 98 arasinda bir sayi gir")) if not 10<kullanici_sayisi<98: masterminddef() return kullanici_sayisi except: print("lütfen doğru rakam girin") masterminddef() bilgisayar_sayisi = rand...
c58c1723c8f60c68663bd485e289b6bfb91b4385
yuanlanda/lt2212-v20-example-trigram
/trimodule.py
9,937
3.5625
4
import sys import os import random class TrigramModel: def __init__(self, inputstring): self.tridict = {} for position in range(len(inputstring) - 2): char0 = inputstring[position] char1 = inputstring[position + 1] char2 = inputstring[position + 2] i...
d06e7e5a61ffd9ea88f17011d4b48fa25af1cf24
julianandrews/adventofcode
/2019/python/utils/primes.py
571
3.90625
4
def is_prime(n): d = 2 while d * d <= n: if n % d == 0: return False d += 1 return n > 1 def prime_factors(n): i = 2 while i <= n: while n and n % i == 0: yield i n //= i i += 1 def primes_upto(limit): is_prime = [False] * 2...
d44c25d0eed1b2f6881169bc9e8bc290fe22f620
MrHamdulay/csc3-capstone
/examples/data/Assignment_4/oslcon001/ndom.py
1,259
3.8125
4
# Conor O'Sullivan # Convers to base 6 (visa versa) # 4/01/2014 #ndom_to_decimal (a), that converts a Ndom number to decimal def ndom_to_decimal(a): dec = 0 for x in range(a+1): ndom = decimal_to_ndom(x) if ndom == a: dec = x break return dec ...
661ce04901ef64076812556e6a273a2ca7663bb5
pizza-steve/Minions-Quiz
/01_Menu_GUI_v1.py
761
3.5
4
from tkinter import * class Quiz: def __init__(self): # formatting variables background_color = "yellow" # quiz main screen GUI self.quiz_frame = Frame(width=300, height=300, bg=background_color) self.quiz_frame.grid() # minions quiz heading self.minion_co...
65fa63d2793d2c595cdfdb3b2c52a134ac3565a3
Sofia1306/Python_Clases
/Ejercicio_DecimalBinario.py
329
3.859375
4
"""Ejercicio Decimal a Binario """ import math numero = int(input('Ingresa un número: \n')) binario = '' while (numero > 0): if (numero%2 == 0): binario = '0' + binario else: binario = '1' + binario numero = int(math.floor(numero/2)) print(f'El número en binario es {binario...
ca1090d0d85c6eb9f5bbf95105ba801041f0c3d0
BaronVladziu/Project-Euterpe
/notes/chord.py
1,053
3.78125
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- from notes.pitch import Pitch class Chord: def __init__(self, pitches=list()): """ Set of pitches used as a whole. """ self._pitches = pitches self._pitches.sort( key=lambda x: x.get_cents_from_a() ) de...
fec521d95527ee3cac4d52514d1fa61148103433
sidv/Assignments
/Ramya_R/Ass17Augd17/Employee/org.py
1,854
4.0625
4
#employees = {} #empty List organization = {} def org_menu(): print("\t1.Add organization") print("\t2.view organization") print("\t3.edit organization") print("\t4.delete organization") #print("\t5.exit") def manage_all_organizations(): org_menu() ch = int(input("\tEnter your choice ")) if ch == 1: #Crea...
9d3c3c06d6d0ab3c5c9c6c7929c62c722de46cbf
alpha-kwhn/Baekjun
/powerful104/10798.py
221
3.5
4
li=[] max=0 for _ in range(5): s=input().strip() if max<len(s): max=len(s) li.append(s) for i in range(max): for j in range(5): if len(li[j])>i: print(li[j][i],end="")
7afbae0e567b1d8662499fc6d7c05b73c630ff55
suglanova/CodecademyChallenges
/Lists/lists_challenge0.py
905
4
4
#Advanced Python Code Challenges: Lists def every_three_nums(start): return list(range(start, 101, 3)) print(every_three_nums(91)) def remove_middle(lst, start, end): lst = lst[:start] + lst[end+1:] return (lst) print(remove_middle([4, 8, 15, 16, 23, 42], 1, 3)) def more_frequent_item(lst, item1, item...
86f3b004db37dc8eb69625dd958be6b713ac9271
lfteixeira996/Coding-Bat
/Python/Warmup-2/last2.py
621
4.1875
4
import unittest ''' Given a string, return the count of the number of times that a substring length 2 appears in the string and also as the last 2 chars of the string, so "hixxxhi" yields 1 (we won't count the end substring). last2('hixxhi') -> 1 last2('xaxxaxaxx') -> 1 last2('axxxaaxx') -> 2 ''' def last2(str):...
4cfaf97cb4ac24e51aa7dc9a898f5e3db1497afa
CosmicTomato/ProjectEuler
/eul98.py
2,323
4
4
#Anagramic squares #By replacing each of the letters in the word CARE with 1, 2, 9, and 6 respectively, we form a square number: 1296 = 362. What is remarkable is that, by using the same digital substitutions, the anagram, RACE, also forms a square number: 9216 = 962. We shall call CARE (and RACE) a square anagram wor...
197869df44e1acf8980a5031681fe644c5f8ba68
knight-peter/item-python-HeadFirst
/1.寻找自己的方式/猜数字游戏1.2.py
486
3.8125
4
#这两行代码用来生成随机数 from random import randint secret=randint(1,10) print("欢迎,这是一个猜数字游戏。") guess=0 ''' 检查答案是否等于那个secret变量中设定的随机数。 ''' while guess!=secret: g=input("请输入一个数字:") guess=int(g) if guess==secret: print("你猜对了!") else: if guess>secret: print("太高了") else: ...
97ff9a40ad1d6e9f83bedaba8d637946bfd569a5
Adam-Hoelscher/ProjectEuler.py
/Problem52.py
509
3.578125
4
def Solve(): add = 0 target = 6 while True: baseDigits = ['1'] + [d for d in str(add)] test = int(''.join(baseDigits)) baseDigits.sort() for m in range(2, target + 1): mult = test * m testDigits = [d for d in str(mult)] testDigits.sort() ...
1b76a6be56b08a028c19772d3c9f9c6927078cf9
GeovaniSantosHub/Learning_Pyton
/Mundo 2/desafio 44.py
678
3.75
4
preco = float(input('Qual o preço das compras ?')) print('''Qual opção de pagamento você deseja efetuar [1] à vista/cheque [2] à vista no cartão [3] 2x no cartão [4] 3x ou mais no cartão''') opcão = int(input('Qual opção deseja ? ')) if opcão == 1: print(f'Você pagará {preco * 90 / 100}, pois terá 10% de desconto')...
ad429ecf7e59dd704443e0be5de1354b70c69536
LXYDETZT/zhangsan
/demo01.py
2,319
4.03125
4
''' 33333333333333 print('哈哈',2333,2.333) print('哈哈'+'嘻嘻') #字符串的拼接,但是只能相同数据类型,不过整数和小数可以一起 print('哈哈'*3) print(((1+2)*100-99)/2) print(2>3) print(4>3) #变量和赋值-开始 #浪晋说变量必须是小写字母!为什么大写也没问题 name='张三' #把张三这个值赋值给了a这个变量 print(name) #变量和赋值-结束 a=input('请输入:') print(a) a=input('请输入:') b=input('请输入:') print('input获取...
e0df06bbdb580cd320a913fe7ccc9be4d43876bf
Bacmel/Boids-Boids-Boids
/src/sim/perceptions/range.py
871
3.515625
4
# -*- coding: utf-8 -*- from numpy.linalg import norm from .perception import Perception class Range(Perception): """The class implements a range based perception of the neighbors.""" def __init__(self, perception_range, border, perception=None): """Build a new Range perception. Args: ...
a32fa47fe2f8e571a862e53e89d76ab67efebc21
Lalesh-code/PythonLearn
/Oops_Encapsulation.py
1,484
4.4375
4
# Encapsulation: this restrict the access to methods and variables. This can prevent the data from being get modified accidently or by security point of view. This is achived by using the private methods and variables. # Private methods denoted by "__" sign. # Public methods can be accessed from anywhere but Private me...
3fdf3a936265b9c32c7570a993230b7c6d3f2897
bilakuingat/Project-PBO
/Pencatatan Kas.py
1,176
4.03125
4
balance = 600 def withdraw(): # asks for withdrawal amount, withdraws amount from balance, returns the balance amount counter = 0 while counter <= 2: while counter == 0: withdraw = int(input("Enter the amount you want to withdraw: ")) counter = counter + 1 while...
a685464e7cfbc5424cac532db87abc56a451e9cc
anillava1999/Innomatics-Intership-Task
/Task 3/Task3.py
924
4.25
4
''' Therefore, . Point is the midpoint of hypotenuse . You are given the lengths and . Your task is to find (angle , as shown in the figure) in degrees. Input Format The first line contains the length of side . The second line contains the length of side . Constraints Lengths and are natural numbers. Output ...
06723e712d519dc9bf4cf1c90ce0a05d833dc480
ParkJongOh/python-starter
/week2/function4.py
157
3.96875
4
def is_odd(number): if number%2==0: print("짝수입니다.") elif number%2!=0: print("홀수입니다.") aa = int(input()) is_odd()
8cf084e2ad16f7ea359a6de1acb4e505f935be1e
awesaem/awesaem-python.saem
/st01.Python기초/py07선택문/py07_03ex5_큰수.py
231
3.984375
4
x = input("첫번째 정수 : ") y = input("두번째 정수 : ") #문자열로 비교할 때와 숫자열로 비교할 때의 값이 다르므로 주의해야 함 x = int(x) y = int(y) if x > y : print(x) else: print(y)
27d332a89a66214e7120f66c9f8fd2e77484090b
sowbhakya/python-programming
/multiplytable.py
133
3.921875
4
a=input("Enter the number") b=input("enter the multiplication range") for c in range(1,b): print a,"*",c,"=",a*c
fd2c93cf36fd8c7ad51c3f45263c768beb9f4555
Anjalkhadka/pycharmproject
/three.py
105
3.65625
4
for i in range(4): num = ('enter the positive number') else: num = ('enter the negative number')
8e311469a7ab1545e29a5d80156e95cb4dffb0c2
gabrielizalo/jetbrains-academy-python-coffee-machine
/Coffee Machine/task/machine/coffee_machine.py
3,492
4.21875
4
# Ini machine_money = 550 machine_water = 400 machine_milk = 540 machine_beans = 120 machine_cups = 9 # Functions def action_remaining(): print("The coffee machine has:") print(machine_water, "of water") print(machine_milk, "of milk") print(machine_beans, "of coffee beans") print(machine_cups, "of...
df38b1d404b01498a368916adb754a496f354c1e
callumr1/Programming_1_Pracs
/Prac 4/number_list.py
681
4.15625
4
def main(): numbers = [] print("Please input 5 numbers") for count in range(1, 6): num = int(input("Enter number {}: ".format(count))) numbers.append(num) average = calc_average(numbers) print_numbers(numbers, average) def calc_average(numbers): average = sum(numbers) / len(nu...
de9523d08674b05bfe0e84b4ebedb4f32da26b1f
mitkrieg/CS112-Spring2012
/hw04/sect4_for.py
946
4.15625
4
#!/usr/bin/env python from hwtools import * print "Section 4: For Loops" print "-----------------------------" nums = input_nums() total = 0 # 1. What is the sum of all the numbers in nums? for i in range(0,len(nums)): total += nums[i] print "1.", total, "\n" # 2. Print every even number in nums print "2. even...
2a8e1683f2356ac2227718aa618cf7f4f4058646
rossirahmayani/test-python
/exception.py
262
3.765625
4
x = -5 y = 0 # raise # if x < 0: # raise Exception('x should be positive') # assert # assert(x >= 0), 'x is not positive' # try catxh try: a = x / y except Exception as e: print('Error: {}'.format(e)) else: print(a) finally: print('DONE')
2cc56f3a35c9a2cba490750aa17aa7f01a42216f
angegon/Python
/001_Sintaxis_Basica.py
590
4.1875
4
# No hay ; en el fin de línea en python print ("Hola Mundo") # Práctica no recomendable, más de una instrucción en una línea print ("Hola Ángel"); print("Adios") # Para separar una instrucción en varias líneas usamos "\" mi_nombre = "mi nombre es Juan!" mi_nombre = "Mi nombre es\ Juan" print(mi_nombre) # El tipo de...