blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
afe0ef534b69888c879cae4ab334e9bccb71d9c2
csutjf/autoprogramming
/findvalue.py
536
3.96875
4
import fileinput from random import randint #for random threshold of filter from functions import * '''This script uses autowriting to modify the function calls and avoid the loop needed to find the optimum value run python findvalue.py in terminal''' opt=26 guess=0 guess=findOptimum(opt) '''Once the optimum value h...
48e8863a460152f27ec8ed065d98f5dbc73891c7
katryo/leetcode
/218-the-skyline-problem/solution2.py
2,429
3.546875
4
from typing import List from heapq import heappush, heappop class Solution: def getSkyline(self, buildings: List[List[int]]) -> List[List[int]]: heap = [] LEFT = 0 RIGHT = 1 END = 10 events = [] for left, right, height in buildings: left_event = [-hei...
75c5c39070b4adaa01001c4078d1e86b4b0e732b
Say10IsMe/SVBA-ED
/Examen Unidad II-Inciso 3- Suarez Abraham.py
3,009
3.671875
4
# -*- coding: utf-8 -*- """ Created on Sat Oct 6 01:10:26 2018 @author: pc """ #definimos el arreglo para la pila y el indice para las posiciones listaregistros=[] ind=1 #nuestro metodo para agregar registros def ingresarregistro(): #declaramos la variable global para poder utilizarla aquí global ...
76a43ad1106be8e70803625eb69e746d2f5a4113
officialGanesh/Dollar-Exchange
/main.py
1,512
3.828125
4
# Import the required modules import requests, json, os base_url = "http://apilayer.net/api/live?" access_key = os.getenv('currencyAPI') end_point = f"{base_url}access_key={access_key}" def main_function(): '''This function is used to get the json data and convert into python dictionary''' try: ...
a6058c0cfb99bf3958af0f1f05ea4bf9fe5a11a4
Asad1o1/Roboprener
/Test_2.py
451
4.25
4
# Write a Python Program to find the two largest numbers in an array. def find_largest(arr: list, n: int) -> list: largest_number = [] for i in range(n): arr.sort() x = arr.pop(len(arr) - 1) largest_number.append(x) return largest_number if __name__ == '__main__': total_larges...
c786d545d03713d179d3d381dd2cf016f5448223
Vitosh/AlgoTests
/abba1.py
189
3.53125
4
input_word = input() input_target = input() def a_to_end(input_word): return input_word + 'A' def b_to_end(input_word): input_word = input_word[::-1] return input_word + 'B'
4b23b20c70374163d5912baf20fe960b40467fa9
liudandanddl/python_study
/leetcode/test.py
11,057
3.78125
4
#!/usr/bin/env python # coding=utf-8 import Queue __author__ = 'ldd' def trailingZeroes(n): """ 求阶乘结果尾部0的个数.0是由2*5所得,计算能被多少个5,25,125.。。。。整除 :type n: int :rtype: int """ return 0 if n==0 else n/5 +trailingZeroes(n/5) def twoSum(nums, target): """ 从数组中查找两数相加=target,返回对应两数的下标。 :typ...
23a8a1b5f82bb4fb4f9612064747f939468c9583
lachlankuhr/AdventOfCode2017
/5/part2.py
408
3.65625
4
import numpy as np array = np.loadtxt("input.txt") index = 0 counter = 0 # my poor little laptop doesn't like this :( while (index < len(array)): value = array[int(index)] if value >= 3: array[int(index)] = array[int(index)] - 1 else: array[int(index)] = array[int(index)] + 1 index = i...
fe2fa9d08c08b441549b567e47bf95d733620a54
tathagata-c/everyday-tools
/ip_finder.py
1,567
3.671875
4
import re import os # Define regex to find any pattern of an IPv4 address pattern. r = re.compile(r'\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}') # Function to validate if the IPv4 address is valid or not. # Each octet should be a number between 0 - 255 for it to be valid IPv4 address. def validate_ip(ip): s = ip.sp...
451c444ede997f040e9fae046b6ee396990ad38e
BalaIyyappan/Guvi-Tasks
/Task-Completed/Area of triangle.py
188
3.984375
4
14. Write a program to enter base and height of a triangle and find its area. SOL: b=int(input("Enter Base:")) h=int(input("Enter Height:")) area=(h*b)*0.5 print("Area of triangle:",area)
116e63c75023b2bec36e5a0cc9ce30de2bfb5efa
ploew/uebungsaufgaben
/BA1l.py
495
3.625
4
pattern="GAA" def PatternToNumber(pattern): if pattern == '': return 0 return 4 * PatternToNumber(pattern[0:-1])+ SymbolToNumber(pattern[-1:]) def SymbolToNumber (symbol): if symbol == "A": return 0 if symbol == "C": ...
f5deb0fc5e34cdc8483b17c5a4a947763d582efa
maxim371/OOP_Zoo
/OOP_Zoo/tests.py
1,543
3.59375
4
import unittest from .animals import Animal, Doggo, Iguana, Human class TestAnimals(unittest.TestCase): def setUp(self) -> None: self.anim = Animal('Anim', 40) self.dog = Doggo('Watson', 11) self.lizi = Iguana('Lizi', 3) self.human = Human('Human', 40, 'Coding') def test_init...
26f81bdf0656a3912e8d7e0e690c13510cc56a30
optionalg/programming-introduction
/Aula 07/Aula7-Lab-10.py
389
3.71875
4
#!/usr/bin/python # -*- coding: utf-8 -*- # Aula 7 # Laboratório # Exercício 10 # Autor: Lucien Constantino def deltaPressure(target, current): return target - current targetPressure = int(input()) currentPressure = int(input()) assert deltaPressure(30, 18) == 12 assert deltaPressure(27, 27) == 0 assert deltaP...
057620ebdf9939f7b729748235756e29f1cab1d5
UWPCE-PythonCert-ClassRepos/Wi2018-Online
/students/Gorthi_kavita/4module/4Mailroom.py
5,409
3.640625
4
ltn =[] # user entered donar names with duplicate name lt = [] #donar names,amount of the donars with duplicate names ldupname = [] # all the names of the donar with duplicates names luniname = [] # no duplicate names lcountname = [] #this will count the names how many times donar donated lfinal = [] lfinalnam...
66d8a36d1676d5a2bd5f8e8afd11f87973f1ca49
Tracyee/visualization-of-gaussian-bayes-classifier
/gaussian.py
1,714
3.546875
4
import numpy as np import matplotlib.cm as cm import matplotlib.pyplot as plt from mpl_toolkits.mplot3d import Axes3D import math class BivariateGauss: def __init__(self, X, Y, mu, Sigma): self.X = X self.Y = Y self.mu = mu self.Sigma = Sigma # Pack X and Y into a single 3-d...
c7edc98fc235dc223fa7ad95fbf128aec1b61347
ramya-kiran/Connect-four-game
/board.py
3,784
3.78125
4
# Board class implements some of the basic functionalities of a connect four board. import numpy as np class Board: # initializing the board with a stack to keep track of the remaining moves # and a list to keep the board state. def __init__(self): self.stack = [] for i in range(7): ...
7e6057895343c2aafb0b4a2d9a0ab68894fdcb2c
AndyRachmat27/LihatApa-
/Kategori Usia.py
332
3.890625
4
print ("Program Usia") #input data usia = int(input("Masukkan usia : ")) #Rumus if usia < 5 : print ("Toddler") elif 6 < usia < 12 : print ("Kids") elif 13 < usia < 20 : print ("Teenager") elif 21 < usia < 40 : print ("Young") elif 41 < usia < 60 : print ("Adult") if usia > 60 : p...
05cb1521168d0320f080cd8c25137ea9ef6e91b9
dindamazeda/intro-to-python
/lesson2/exercises/3.number-guessing.py
821
4.1875
4
# Create list of numbers from 0 to 10 but with a random order (import random - see random module and usage) # Go through the list and on every iteration as a user to guess a number between 0 and 10 # At end the program needs to print how many times the user had correct and incorrect guesses # random_numbers = [5, 1, 3,...
f6a2fa59297411fb2987cdb5afb0dcbf8a855804
kavinandha/kavipriya
/prg53.py
119
3.96875
4
n1=int(input("enter the num1:")) n2=int(input("enter the num2:")) n3=int(input("enter the num3:")) n=n1+n2+n3 print(n)
35346551a5839520a3e1b07783ea39781c9883bc
tburcham/codepoetry
/dicts.py
336
3.96875
4
person = { "first_name": "Karl", "last_name": "Marx", "age":235, "pet": { "name":"Proleterry", "species": "parrot", "age": 12 } } print(person) print(person["age"]) print(person.get("abc")) # returns a truthy/falsy None if not found for key in person: print(key) pri...
f2aa66377636a32c7f74f5dfbd7589833f4035d4
cica-mica/domaci01
/1.1_zadatak.py
479
3.859375
4
""" 1. Napisati kod koji za date katete a i b (a>b) pravouglog trougla racuna povrsinu i zapreminu tijela koje se dobija rotacijom trougla oko manje katete. """ import math # rotacijom trougla oko katete b dobija se kupa s poluprecnikom a i visinom b a = 8 b = 6 # racunamo duzinu hipotenuze jer ce nam bit...
31649b7f357b54c05f4fa17054a01aacedf15c50
cationly/Huckel-Energy
/scripts/hamiltonian.py
10,281
3.859375
4
''' This is a class to implement a Hamiltonian variable parameters (now, up to 2) ''' class hamiltonian: def __init__(self): ''' We simulate the hamiltonian as an array. The action of a "2D array" is replicated by a 1D array and knowledge of the hamiltonian size. ...
a8d044d7db5cb6c0980dd69f582fb1a9ac34a6e5
LizaPleshkova/PythonLessonsPart2
/venv/lessons/5.py
841
3.859375
4
''' Entry - созздает однострочное текстовое поле, в которое пользователь может вводить какие-то данные, так же и для вывода информации для пользователя ''' from tkinter import * def add_str(): e.insert(END,'Hello!') def del_str(): e.delete(0,END) def get_str(): l_text['text'] = e.get() root = Tk() roo...
148478f52edb188a8a12d87bde52eb6e247cfd85
OnlyLoveLin/studentManageProject
/referTool.py
9,121
3.5
4
# 这是一个查询文件 # 导入需要的模块 import Io # 定义一个查询学生基本信息主界面 def referMainMenu(): while True: print("------------------------------------") print("\t教师客户端") print("\t\t1.按照学生的编号查询") print("\t\t2.按照学生的名字查询") print("\t\t3.按照学生的班级查询") print("\t\t4.查询所有学生") print("\t\t5.退出"...
da4e95647ee87343f14742d71d0428db277a8d07
Mariani-code/PythonProjects
/ProjectEuler/EP34.py
506
3.609375
4
from math import factorial import time start = time.time() result=0 # store all 10 factorial numbers in a dictionary d_factorial=dict() for t in range(0,10): d_factorial[str(t)] = factorial(t) max = 7 * d_factorial['9'] # print(max) for i in range(3,max+1): temp=0 for j in str(i): ...
5a091e78be66d3283ee6c6715753ead2fb197ca8
pcw263/py2-al
/Sort/bubble_sort.py
1,493
4.125
4
#!/usr/bin/env python2 #-*- coding:utf-8 -*- import time def bubble_sort(unorder_list): #start = time.time() count = 0 for epoch in range(len(unorder_list)-1,0,-1): ''' 这里迭代器是从大到小地生成序列(9,8,7,.....,1) 如:range(3,0,-1) ------> 依次生成 3,2,1 (注意递减生成时不包括最后一项) ''' for i in r...
701675b033b7e59954e5d3b5f5decc4ead4d2892
Rishika2022/Gitam-Python
/assignment july 10 2019.py
276
4.03125
4
#!/usr/bin/env python # coding: utf-8 # In[1]: def reverseFib(n): a = [0] * n a[0] = 0 a[1] = 1 for i in range(2, n): a[i] = a[i - 2] + a[i - 1] for i in range(n - 1, -1 , -1): print(a[i],end=" ") n = 5 reverseFib(n)
47a69e373e1ae8e3329cc2e9d826443146664aff
DaHuO/Supergraph
/codes/CodeJamCrawler/16_0_1/hrathore/CountingSheep.py
462
3.546875
4
t = int(raw_input()) # read a line with a single integer for x in xrange(1, t + 1): N = int(raw_input()) digits = ['\r'] i = 0; while True: if N == 0: print "Case #%d: %s" % (x, "INSOMNIA") break i = i + 1 n = N * i for s in str(n): ...
e9c6309be3ae341baf7a021b788a8d74a5d3da08
seongjaelee/ProjectEuler
/problem045.py
786
3.734375
4
import problem import math class Problem(problem.Problem): def __init__(self): number = 45 question = 'After 40755, what is the next triangle number that is also pentagonal and hexagonal?' problem.Problem.__init__(self, number, question) def getAnswer(self): # n^2 + n - 2x = 0 # n = [-1 + sqrt(1 + 8x)] /...
7de443002e36a1adb6885ec9a7e3b2436ed728eb
SzymonTurek/my-bioinf-tools
/motif.py
572
3.640625
4
def reada(filename): with open(filename) as file: seq='' line = file.readline() while line : if line[0]==">": seq+="," line = file.readline().rstrip() else: seq+=line line = file.readline().rstrip() lista = seq.split(",") lista.pop(0) slowo = '' longest = '' a = lista[1] ...
53ab4fbfa0a9e952fb0835dcdbf315ac50a42889
GSantos23/Crash_Course
/Chapter16/Exercises/ex16_2.py
2,385
3.59375
4
# Exercise 16.2 ''' Sitka-Death Valley Comparison: The temperature scales on the Sitka and Death Valley graphs reflect the different ranges of the data. To accu- rately compare the temperature range in Sitka to that of Death Valley, you need identical scales on the y-axis. Change the settings for the y-axis on one or b...
b9758c5aec684603419b50b006983a8ac06dd031
ArtyomKeller1/artyomkeller
/lesson2/homework5.py
368
3.859375
4
y = 0 while y < 10: numbers = [7, 5, 3, 3, 2] x1 = len(numbers) x = int(input()) if x in numbers: el_index = numbers.index(x) numbers.insert(el_index, x) numbers.sort() numbers.reverse() print(numbers) else: numbers.append(x) numbers.sort() ...
0db57e6d71eccb259f32be9e6f6441b0aae1df68
Jessmin/dl_utils
/convert_Dataset/table/iou.py
918
3.5
4
def calculate_IOU(rec1, rec2): """ 计算两个矩形框的交并比 Args: rec1: [left1,top1,right1,bottom1] # 其中(left1,top1)为矩形框rect1左上角的坐标,(right1, bottom1)为右下角的坐标,下同。 rec2: [left2,top2,right2,bottom2] Returns: 交并比IoU值 """ left_max = max(rec1[0], rec2[0]) top_max = max(rec1[1], rec2[1]) ...
d0a7c66cc2594046fa6cb14e201660e77f1da343
Lcast15/useful-functions
/number-to-ordinal.py
275
4.0625
4
def Ordinal(Num): Num = str(Num) if Num.endswith('1') and not Num.endswith('11'): return Num + 'st' elif Num.endswith('2') and not Num.endswith('12'): return Num + 'nd' elif Num.endswith('3') and not Num.endswith('13'): return Num + 'rd' else: return Num + 'th'
0c96bb02db92443ddf8ac29bdd0a4fd26c3bf3fc
jimengya/Algorithms
/实操演练/templates/t003.py
719
4.03125
4
def smallest_k_numbers(k, *args): """Return a collection containing the k smallest numbers Args: k: the number of numbers to return args: all given numbers Returns: A collection of results """ # Put your code here. pass if __name__ == "__main__": assert {1,2,3,4} ...
ecf4bc12d6b579aac8cd4a882ae5de7b5b84f728
gndit/datastructure
/preordertree.py
804
4.21875
4
#tree traversal in binary tree class node: def __init__(self,data): self.left=None self.right=None self.key=data def print_preorder(root): if root: print(root.key), print_preorder(root.left) print_preorder(root.right) #inorder traversal def print_inorder(ro...
842cabbb6135cc76a9354c43dae88a4cfe5da0f2
sivaneshl/python_data_analysis
/intro_data_science_python/statistical_analysis_in_python/assignment4/assignment4.0.py
14,871
3.65625
4
import pandas as pd import numpy as np from scipy import stats import re pd.options.display.float_format = '{:.8f}'.format # Definitions: # # A quarter is a specific three month period, # Q1 is January through March, # Q2 is April through June, # Q3 is July through September, # Q4 is October through December....
05c907ede171a51602d9d622f3a72f4a4d0edef7
Made-of-Dark-Matter/DSA-Agorithmic-Toolkit
/1-6-last_digit_of_fibonacci_number.py
678
3.984375
4
# python3 def last_digit_of_fibonacci_number_naive(n): assert 0 <= n <= 10 ** 7 if n <= 1: return n return (last_digit_of_fibonacci_number_naive(n - 1) + last_digit_of_fibonacci_number_naive(n - 2)) % 10 def last_digit_of_fibonacci_number(n): assert 0 <= n <= 10 ** 7 fib_1 = 0 fib...
298a75a3fae2e1c3d9274fdfd3e3a1c373b0bb49
ShivaniMadda/Python
/Basics/Q4.py
347
3.5625
4
#import math #a = 4 #b = math.sqrt(a) #print(b) s=input("Enter an integer sequence seperated by comma: ") list1 = list(s.split(",")) for i in range(0,len(list1)): list1[i] = int(list1[i]) C = 50 H = 30 for D in list1: if D != list1[len(list1)-1]: Q = int(((2*C*D)/H)**0.5) print(Q,end=",") else: Q = int(((...
fb715586393b211c9adab98ba1b8b5f07cf430be
u101022119/NTHU10220PHYS290000
/student/100021216/factorial_rec.py
241
3.9375
4
def factorial_rec(n): if n-int(n)!=0: return 'None' elif n<0: return 'None' elif n==0: return 1 else: return int(n*factorial_rec(n-1)) n=input('Enter a number:') m=factorial_rec(n) print m
db351e59cdc8d13da12f7f4526a075572627aa28
entropy2333/leetcode
/medium/24_swapPairs.py
608
3.734375
4
# Definition for singly-linked list. # class ListNode(object): # def __init__(self, x): # self.val = x # self.next = None class Solution(object): def swapPairs(self, head): """ :type head: ListNode :rtype: ListNode """ if not head or not head.next: ...
37c7d420d3a63def0df0ce6e55c60d7b567963f3
pastorcmentarny/DomJavaKB
/python/src/tools/text/enum_station_generator.py
449
3.59375
4
# left this empty after use stations = [] def convert_to_enum(station): return station.replace(" & ", "_AND_").replace(' ', '_').replace("'", "") \ .replace(" & ", "_AND_").replace('(', '_').replace(')', '_') \ .upper() + '("' + station + '",OVERGROUND),' def generate_station_enum(...
41d45cf69fb1d7be45da1bf321cc58b6e45a0174
cz-fish/sneeze-dodger
/sneeze/Actor.py
1,236
3.5
4
import abc from sneeze.Sprite import Sprite from sneeze.Types import * from typing import Optional class Actor(abc.ABC): def __init__(self): self.pos = Pos(0, 0) self.prev_pos = Pos(0, 0) self.speed_vec = Pos(0, 0) self.max_speed = 10 self.accel = 5 self.slowdown =...
605776446dab81c774ee111302a9247e7dd334e8
sankoudai/py-knowledge-center
/com.xulf.learn.py.basis/pattern/map_test.py
1,192
3.625
4
__author__ = 'quiet road' import unittest from printutil.printutil import printVar class MapTest(unittest.TestCase): """ map: map is a class, which implements iterable pattern and iterator pattern. constructor: map(f, iterator1, iterator2, ...) """ def setUp(self): ...
60b95897966791b80ac616599b0c594c2114fede
genevievepoint/CP1404_Assignment_Part1
/attempt1_fail.py
2,159
3.640625
4
# Genevieve Point# import csv # menu() # print("Items for Hire - By Genevieve Point")# 06/04/2016 workbook_file = open('items.csv', 'r') workbook_reader = csv.reader(workbook_file) sheets_list = [] for row in workbook_reader: print(row) # row = row.split() # row_info = row.strip('\n') sheets_list....
ffda68bf09d71286fff546cc89b24358b5b0d4be
jiangshanmeta/lintcode
/src/0104/solution.py
1,067
3.9375
4
""" Definition of ListNode class ListNode(object): def __init__(self, val, next=None): self.val = val self.next = next """ class Solution: """ @param lists: a list of ListNode @return: The head of one sorted list. """ def mergeKLists(self, lists): L = len(lists) ...
6815bb6567fcfd337a6110598f6bdc0d18c8d717
rahuljnv/rg_code
/Faulty_cal_ex2.py
1,097
4.09375
4
# Exercise 2 - Faulty Calculator # 45 * 3 = 555, 56+9 = 77, 56/6 = 4 # Design a calculator which will correctly solve all the problems except # the following ones: # 45 * 3 = 555, 56+9 = 77, 56/6 = 4 # Your program should take operator and the two numbers as input from the user # and then return the result va...
54120460b42ec334eb3b27f00a9e2544228429d6
Aboechko/Data-structures-and-algorithms-with-Python
/Simple methods.py
513
3.984375
4
#Implement the simple methods getNum and getDen that will return the numerator and denominator of a fraction. class Fraction: def __init__(self,top,bottom): self.num = top self.den = bottom def __str__(self): return str(self.num) + "/" + str(self.den) def getNum(self): return self.num def g...
db212199a7c81444fae95ecfd3ce1600ec2c4fab
NikitaFir/Leetcode
/Longest Uncommon Subsequence I.py
351
3.625
4
class Solution(object): def findLUSlength(self, a, b): n = len(a) m = len(b) if n > m: return n elif n < m: return m else: if a == b: return -1 else: return n print(Solution.findL...
620c75d5f8c78b2e592029e92e3019ab72887fad
curieshicy/My_Utilities_Code
/Grokking_the_Coding_Interviews/p60_search_bitonic_array.py
1,522
3.75
4
def search_bitonic_array(arr, key): # find the index of max l = 0 h = len(arr) - 1 while l < h: m = (l + h) // 2 if arr[m] < arr[m+1]: l = m + 1 else: h = m max_index = l # or h def binary_search(nums, low, high, target, ascending): ...
5378a84380410a10d532926a05ddee4edaf7df1e
pyliut/Rokos2021
/Wk4/Inverse_Digamma_bounds.py
717
3.640625
4
# -*- coding: utf-8 -*- """ Created on Tue Jul 20 11:55:29 2021 @author: pyliu """ import numpy as np import scipy as sp def Inverse_Digamma_bounds(k): """ From Batir paper on Inverse Digamma bounds The lower bound is a good approximation for the Inverse Digamma function Parameters ...
32a6ce46d53c593c21cf866114904d1981288389
razzledazze/Python-Turtle---10x10-Screen
/Pixel Screen.py
1,853
4.21875
4
from turtle import Turtle import csv colours = ['blue','red','yellow','green','orange','purple'] turtles = [] names = [] def MakeScreen(): for row in range(10): print("Setting up Column:"+str(row+1)) for column in range(10): name = str(row)+str(column) #makes a unique name...
a288ead6f0487ae3a361c5f8485b3c1bf4cb1bac
mare7811/Numerical-Methods
/HW_april10.py
3,763
3.578125
4
""" Miguel Mares Numerical Methods Homework Due 4/10/2020 """ #This function uses the finite difference method to solve the problem: #y'' + 2y' + (k^2)y = 0, y(0) = 0 and y(1) = 0 for acceptable values of k. #First different lambda values are swept from -40 to 0, and a determinant #for each lambda tested is ...
3bf798874e19fe35ef9d646b561d8014c1e381ac
abkunal/Data-Structures-and-Algorithms
/leetcode/easy/binary_tree_paths.py
1,306
4.125
4
""" Binary Tree Paths - https://leetcode.com/problems/binary-tree-paths/ Given a binary tree, return all root-to-leaf paths. For example, given the following binary tree: 1 / \ 2 3 \ 5 All root-to-leaf paths are: ["1->2->5", "1->3"] """ # Definition for a binary tre...
07e7e87b0a758df0dcc1f4db6e1ad7d1a8024770
williamf1/Maths-Cheating-Device
/long multiplication.py
307
3.5
4
import time print("test multi") #input no1=raw_input("1st number") no2=raw_input("times by") #calculator no1int=int(no1) no2int=int(no2) answer=no1int * no2int #printing print("in long multiplication") print(" ") print(str(no1)+" x") print(str(no2)) print("-----") print(str(answer))
af844f63f2d68cde7fd4b7c9c455ca325e17e0fa
whgmltn15/basic_grammar
/basic_loop.py
3,502
3.84375
4
''' for i in range (10): print("*"*i) for i in range (10): print("*"*(10-i)) for i in range (100): one = i % 10 if(one%3 == 0 and one != 0): print("*") else: print(i) for i in range (100): a = i % 10 b = i // 10 if b % 3 == 0 and a % 3 == 0: p...
7e79bea6f9d33873d5b8168bc57d68c8b113dc42
kapsali29/ml-exercises-coursera
/exercise4/kernels.py
823
3.84375
4
import numpy as np def gaussianKernel(x1, x2, sigma): """ Computes the radial basis function Returns a radial basis function kernel between x1 and x2. Parameters ---------- x1 : numpy ndarray A vector of size (n, ), representing the first datapoint. x2 : numpy ndarray A ...
bcc2045e953975bbdf2d78dc2888346072a0af24
chantigit/pythonbatch1_june2021data
/Python_9to10_June21Apps/project1/listapps/ex5.py
407
4.3125
4
#II.Reading list elements from console list1=list() size=int(input('Enter size of list:')) for i in range(size): list1.append(int(input('Enter an element:'))) print('List elements are:',list1) print('Iterating elements using for loop (index based accessing)') for i in range(size): print(list1[i]) print('Iterat...
d9db13350751482d3a3df3f3f8db800f77e05710
localsnet/Python-Learn
/PCC/ch10/105programming_poll.py
431
3.71875
4
#!/usr/bin/python3 filename = 'poll_responds.txt' name = '' respond = '' with open(filename, 'a') as file_object: while not (name and respond): name = input('What is your name? \n Answer: ') respond = input('Why you like programming? \n Answer: ') if not (name and respond): print('you must provide all request...
2948b578a5ae79c70fb852e22668897ecfbfb4ea
olivergoodman/food-recipes
/coding_util.py
4,327
3.765625
4
import re import string def find_term(sentence, term_list): ''' find which term in term_list exists in the sentence ''' terms =[] for term in term_list: m = re.search(term, sentence, re.IGNORECASE) if m: terms.append(term) return terms def find_term_by_direction(sentence, ...
006994e29c418e5cfe369fc039f4d813e5a79086
MWessels62/BasicInvestmentInterestCalculator
/Investment_Calculator.py
1,611
4.125
4
#Task12 #Compulsory_Task #Building an investment calculator to calculate interest earned and total investment value at end of investment period import math #Get user input principal = float(input("Please enter in the amount you are depositing: ")) #This is the principal amount to be invested interest_rate = (float(i...
69874c3931368518a761e6f994fe0c21a5f0e601
zhch-sun/leetcode_szc
/852.peak-index-in-a-mountain-array.py
829
3.515625
4
# # @lc app=leetcode id=852 lang=python # # [852] Peak Index in a Mountain Array # class Solution(object): def peakIndexInMountainArray(self, A): """ :type A: List[int] :rtype: int """ lo, hi = 1, len(A) - 2 while lo < hi: # invariant [lo, hi] mid = lo + ...
d6d884b0cc002bb2f946c59cfe529789bfbf41f7
C-CCM-TC1028-102-2113/tarea-1-programas-que-realizan-calculos-AndresEmiliano
/assignments/18CuentaBancaria/src/exercise.py
360
3.84375
4
def main(): #escribe tu código abajo de esta linea a = float(input("Dame el saldo del mes anterior:")) b = float(input("Dame los ingresos:")) c = float(input("Dame los egresos:")) d = int(input("Dame el número de cheques:")) e = d*13 f = a+b-c-e g = f*.075 h = f-g print("El saldo final de la cuenta es:") print(h) ...
7b2effbc1a14615bdc56191d52453af7043d27a7
sergeyuspenskyi/hillel_homeworks
/HW-16.py
226
3.90625
4
my_dict = {'orange': None, 'red': 'красный', 'green': None, 'yellow': 'желтый', 'black': None} result = {k: v for k, v in my_dict.items() if v is not None} print(result)
b3bcade2fca769788b045bfb1e740ad5268b5fc5
tomasderner97/customutils2
/mathutils/__init__.py
1,057
4.09375
4
from scipy.misc import derivative as _derivative def partial_derivative(f, with_respect_to, arguments, n=1, dx=1e-6): """ Calculates partial derivative of function f(a1, a2, a3,...) with respect to argument in position given by with_respect_to. Parameters ---------- f : callable, N arguments...
a2e8b66febf9087269581218ae54ca829e78d762
tlechien/PythonCrash
/Chapter 9/9.6.py
1,367
4.5625
5
""" 9-6. Ice Cream Stand: An ice cream stand is a specific kind of restaurant. Write a class called IceCreamStand that inherits from the Restaurant class you wrote in Exercise 9-1 (page 162) or Exercise 9-4 (page 167). Either version of the class will work; just pick the one you like better. Add an attribute called fla...
2123eec112ceb537b4912bc741876e3acb1e1e47
Lemito66/Python
/Derivadas_Ejemplo.py
695
4.0625
4
from sympy import Derivative, diff, simplify,Symbol x=Symbol('x') y=Symbol('y') fxy = x*2*y+x*2*y*2+x+y-3 dx=simplify(diff(fxy, x)) dy = Derivative(fxy, y).doit() simplify(dy) print (dx) print (dy) from sympy import Derivative, diff, simplify,Symbol x=Symbol('x') y=Symbol('y') fxy = x*2*y+x*y*2+x+y-3 dx=simplify(di...
a4b3ecac0f4f8cddbbc1e513eb8d70eb4ff8213b
dasqueel/lambda-challenges
/rotationPoint.py
832
3.859375
4
# def find_rotation_point(words): # sort = sorted(words) # return words.index(sort[0]) # def find_rotation_point(words): # idx = 0 # while (words[idx] < words[idx + 1]): idx += 1 # return idx + 1 def find_rotation_point(words): firstWord = words[0] floorIdx = 0 ceilIdx = len(words) -...
13401de098576b78c8b17c18ba18ba7a68deeeda
Eitherling/Python_homework1
/homework7_9.py
695
3.828125
4
# -*- coding:utf-8 -*- sandwich_orders = ['Babiq', 'pastrami', 'tuna', 'pastrami', 'cip', 'pastrami'] finished_sandwiches = [] while sandwich_orders: sandwich = sandwich_orders.pop() print('I made ' + sandwich + ' for you.') finished_sandwiches.append(sandwich) print("\nI have made these:") ...
eaa167afb1e87722575f3f247298d694de8f573d
Denzaaaaal/python_crash_course
/Chapter_7/multiple_of_ten.py
346
4.375
4
# Writing prompt prompt = "Let's find out if a number is a multiple of 10" prompt += "\nPlease enter a number: " number = input(prompt) number = int(number) # Finding out if the number is divisable by 10 if number % 10 == 0: print (f"The number {number} is a multiple of 10") else: print (f"The number {number}...
069f5c227fcdfe62c625d1188945fcac6873443e
nathan-builds/python_labs
/iterated_remove_pairs.py
360
3.578125
4
def iterated_remove_pairs(items): i = 1 while i < len(items) - 1: if items[i - 1] == items[i]: del (items[i - 1:i + 1]) i = 1 elif items[i + 1] == items[i]: del (items[i:i + 2]) i = 1 else: i += 1 if items[0] == items[1]: ...
dc594617ee9c31c59b456c7ef427491b4b80b574
shubhangi2803/Practice_Python
/Exercise 3.py
930
4.4375
4
# Take a list, say for example this one: # a = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89] # and write a program that prints out all the elements of the list # that are less than 5. # Extras: # 1. Instead of printing the elements one by one, make a new list # that has all the elements less than 5 from this list in it an...
ecccfaa71bdd2d5e80665c1eb81a4d8baac4a47a
Iamankitatiwari/Python-Basic-problems
/AddTwoNumber.py
117
3.8125
4
a = int(input("Enter first number to add:")) b = int(input("Enter second number to add:")) c = print(a + b) print (c)
05671b2a3c3c992f282743c33dc73c168e9a508d
eric496/leetcode.py
/two_pointers/167.two_sum_II_input_array_is_sorted.py
1,632
3.921875
4
""" Given an array of integers that is already sorted in ascending order, find two numbers such that they add up to a specific target number. The function twoSum should return indices of the two numbers such that they add up to the target, where index1 must be less than index2. Note: Your returned answers (both index1...
7d6ec622da12cb53fecdb7c31fa8dba9b526951e
nkandra/Udemy
/DSA/string_compression.py
1,289
3.953125
4
#String compression problem #example: AAAABBBCCC should give A4B3C3 from collections import OrderedDict def string_compression(string): count = OrderedDict() for char in string: if char in count: count[char] += 1 else: count[char] = 1 result = "" for k, v in cou...
319102a641d92426b0f6d4acc9c8587fc4024fec
YuxuanSu-Sean/learning
/learnpython/demo_parrot_pizza.py
391
4.03125
4
#编写一个循环,提示用户输入一系列的比萨配料,并在用户输入'quit'的时候结束循环。每当用户输入一种配料后,都打印一条消息,说我们会在比萨中添加这种配料。 prompt = "Please Enter a pizza topping!" prompt += "\n" while True: message = input(prompt) if message == 'quit': break else: print(message)
3d932a1f99d2dc012434a3bc9bc0ff8c285d90c4
TheWildMonk/automated-birthday-wisher-project
/main.py
1,247
3.578125
4
import os import random import smtplib import datetime as dt import pandas as pd # Emails & password email = "demo@email.com" password = "##########" # Create a dictionary from birthdays.csv df_birthdays = pd.read_csv("birthdays.csv") birthday_dict = df_birthdays.to_dict(orient="records") # Check whether any birthda...
f0ffd0cbe4d29ba673cc55ecacb2aaf15be2d0e5
niranjan-nagaraju/Development
/python/hackerrank/challenges/next_greater_element/next_greater_element.py
1,943
4.125
4
''' https://www.hackerrank.com/contests/second/challenges/next-greater-element Given an array, print the Next Greater Element (NGE) for every element. The Next greater Element for an element x is the first greater element on the right side of x in array. Elements for which no greater element exist, consider next great...
7e512dfc27cf3c632dea5db8e25eb4e472f2d9c7
TaylorWhitlatch/Python
/exercises.py
177
3.703125
4
i = 1 j = 1 for i in range (1, 11): print ("\n** %ss Multiplication Table **" % (i)) for j in range (1, 11): x = i * j print("%s X %s = %s" % (i, j, x))
c343c27a751aaaa6c63b56116f616a99e99651eb
alexsv/checkio
/sci_islands.py
1,424
3.828125
4
from collections import defaultdict def print_replaces(replaces): for k in sorted(replaces.keys()): print "%d: %d %s" % (k, replaces[k][0], sorted(replaces[k][1])) def checkio(data): def get_value(x,y): if x < 0 or y < 0 or x >= len(data[0]) or y >= len(data): return 0 else...
e60fc45ee4ca4a6726c0b4f6e1427243f46d7d8a
SatyaAccenture/PythonCodes
/arraysortandmaxelemlogic.py
496
3.671875
4
from numpy import * arr1=array([6,7,8,9,10,13]) arr2=array([15,13,9,3,21,7]) i=len(arr2) arr3=zeros(i,int) for a in range(0,i): arr3[a]=arr1[a]+arr2[a] a+=1 print(arr3) #sorting # for a in range(0,i): # for b in range(a+1,i): # temp=0 # if arr3[a] > arr3[b]: # temp=arr3[b] # arr3[b]=ar...
58d81ca1e08ec5647066bc68c6d337e06a4ba245
DahlitzFlorian/article-introduction-to-itertools-snippets
/itertools_combinations_with_replacement.py
202
3.5625
4
from itertools import combinations_with_replacement l = [1, 2, 3] result1 = list(combinations_with_replacement(l, 3)) result2 = list(combinations_with_replacement(l, 2)) print(result1) print(result2)
e4cccc5c85e8b3229dd1478552cac81eb175af4e
Citrie/Euler
/1.py
262
4.125
4
# If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23. # Find the sum of all the multiples of 3 or 5 below 1000. n = 0 for i in range(1000): if not i%3 or not i%5: n += i print n
b7aa0944354a84039537bdf5050afd72891ffcd3
jakubbaron/dailycodingproblem
/No010/main.py
2,292
4.1875
4
#!/usr/bin/env python # Good morning. Here's your coding interview problem for today. # This problem was asked by Apple. # # Implement a job scheduler which takes in a function f and an integer n, # and calls f after n milliseconds. import heapq import time import threading current_micros_time = lambda: int(round(ti...
e4f690fe509907d1283c9a449bea28edc889cc90
Gmle7/myPythonCode
/generator.py
582
3.640625
4
#生成器 # G = (i * i for i in range(1, 11)) # for g in G: # print(g) # def fibonacci(max): # n, a, b = 0, 0, 1 # while n < max: # yield (b) # a, b = b, a + b # n = n + 1 # return 'done' # F = fibonacci(8) # while True: # try: # x = next(F) # print('g', x) # ...
9d8d3fa0a9b42f9921e0c7d865354352fc151722
git-vish/Soft-Computing-Lab
/BackProp_XOR.py
1,880
3.703125
4
import numpy as np import matplotlib.pyplot as plt # STEP-1: initialization X = np.array([(0, 0), (0, 1), (1, 0), (1, 1)]) Y = np.array([[0], [1], [1], [0]]) Y_hat = None W1 = np.random.uniform(size=(2, 2)) b1 = np.zeros((1, 2)) W2 = np.random.uniform(size=(2, 1)) b2 = np.zeros((1, 1)) epochs = 10000 alpha = .1 E = {...
22ad2007c37cec25c6b09e923d55b8b4580c6e1e
codypeak/Intro-Python-II
/examples/seanplayer.py
306
3.578125
4
#player needs a starting place and ability to move around map class Player: def __init__(self, current_room): self.current_room = current_room def __repr__(self): return f"Player is in {self.current_room}" #if current room werent here computer would find out until run time.
f955471e6ad75b4896c9bdee3873cfaf40a39c4f
mbslak98/ScriptingEssentials
/Mod02Tutorial (1).py
2,120
4.0625
4
#Matthew Selakovich #Mod02Tutorial import random import copy def rando_insert(thing_being_inserted): position = random.randint(0,9) my_list.insert(position, thing_being_inserted) counter = 0 my_list = [] ints_only=copy.deepcopy((my_list)) while counter < 10: list_item = input('Please enter ...
abd365a52091e2c9511ec36084bddcd90df9c722
cbermudez97/fuzzy-logic-project
/fuzzy_logic/utils.py
560
3.578125
4
def isFloatIn(x, m=None, M=None): try: float(x) except: raise ValueError('Data must be a float.') if not m is None and not m <= float(x): raise ValueError(f'Data must be greater or equal than {m}.') if not M is None is None and not M >= float(x): raise ValueError(f'Data m...
43be5a287bb2b25ec85a22bcb5c8ba686ae8fe49
yandrea888/momento1-algoritmos
/algoritmo9.py
227
4.03125
4
num = int(input("Ingrese un número: ")) if num==0 : print("El número", num, "no es par ni impar") elif num % 2 == 0: print('El número', num, 'es par.') elif num %2 != 0: print('El número', num, 'es impar.')
308b140dd86db5b8b66fcc2e680d95a10a162fab
august110th/pythonProject2
/main.py
3,999
3.859375
4
class Student: def __init__(self, name, surname, gender): self.name = name self.surname = surname self.gender = gender self.finished_courses = [] self.courses_in_progress = [] self.grades = {} def add_courses(self, course_name): self.finished_courses.app...
bd7bae4035545ed93b0c920bc3fc1c6e826b5125
Dericrp6/CYPEricRP
/funciones.py
2,114
4.34375
4
#funciones python def sumar (x , y): z = x + y return z def restar (x , y): return x - y def mi_print( texto ): print(f"este es mi print: {texto}") def multiplica (valor, veces): if veces == None : print("Debes enviar el ssegundo argumento de la segunda funcion") else: print(...
9d004e03e146c7497ccd0ece9468a7483cefdc2f
Sahil12S/Working-with-PyGame
/BouncingBall/script.py
1,059
4.125
4
# Simple program to see working of PyGame # Import necessary modules import sys, pygame # Initialize PyGame pygame.init() size = width, height = 1280, 720 # Set window size speed = [2, 2] # Set movement speed black = 0, 0, 0 screen = pygame.display.set_mode(size) # Create graphical window ball...
e17fd8675face7223471fcf7f3ee15a094902d66
udhayajillu17/python_player
/hello5times.py
502
3.65625
4
#------------------------------------------------------------------------------- # Name: module1 # Purpose: # # Author: 16cse041 # # Created: 21/10/2017 # Copyright: (c) 16cse041 2017 # Licence: <your licence> #------------------------------------------------------------------------------...
b1ba5d1fe442e7af664c4afddd4999695f03076a
AlexandraMilts/Web_Crawler
/Replacement.py
578
3.734375
4
# Example 1 # marker = "AFK" #replacement = "away from keyboard" #line = "I will now go to sleep and be AFK until lunch time tomorrow." #Example 2 # uncomment this to test with different input marker = "EY" replacement = "Eyjafjallajokull" line = "The eruption of the volcano EY in 2010 disrupted air travel in ...
418170c2f2d6299ba5b533d7dc0b77e4ccb47455
gabrielsalesls/curso-em-video-python
/ex029.py
268
3.984375
4
num = float(input('Digite a velocidade do carro: ')) if num >= 80: multa = (num - 80) * 7 print('Você esta {} acima da velocidade maxima de 200km, sua multa é {}'.format(num - 80, multa)) else: print("Você esta dentro do limite de velocidade.")
6793cac9a32e623141ada2157cfbfb8850c80c9b
starswap/ComSoc-Blockchain
/RSA.py
275
3.5
4
import random def miller_rabin(integer): twoToS = 1 S = 0 while (integer%twoToS == 0): twoToS *= 2 S+=1 twoToS /= 2 S -= 1 q = integer/twoToS a = random.randint(1,integer) if (pow(a,q,integer)): return True else: for (i in range(S)):
0645d6ea95cf2d756e3010f87693185069f74f53
DouglasKosvoski/URI
/1051 - 1060/1052.py
423
3.875
4
# Accepted num = int(input()) if num == 1: print('January') elif num == 2: print('February') elif num == 3: print('March') elif num == 4: print('April') elif num == 5: print('May') elif num == 6: print('June') elif num == 7: print('July') elif num == 8: print('August') elif num == 9: print('September') e...
7173099848bc52181007cadbb86da3204f6d8d80
hossamelmansy/computer-algorithms
/app/bruteForce/python/closestPoints.py
814
3.65625
4
import math import argparse parser = argparse.ArgumentParser() parser.add_argument('--points') args = parser.parse_args() points = eval('[' + args.points + ']') minDistance = float('inf') print "Minimum distance:", minDistance print "" for i in range(len(points)): for j in range(i+1, len(points)): x1, y...
159c0d25e9fc9b12a5f3b11c8ac4b32afced063b
adarshk007/DATA-STURCTURES-and-ALGORITHMS
/DATA STRUCTURE/Linked_list/circular_linkedlist.py
2,615
4.59375
5
#Circular_linked_list #SUB TOPICS : """ * Insertion in an empty list * Insertion at the beginning of the list * Insertion at the end of the list * Insertion in between the nodes """ # ADARSH KUMAR #--------------------------------Description-----------------------------------# """ Circular li...