blob_id
stringlengths
40
40
repo_name
stringlengths
5
127
path
stringlengths
2
523
length_bytes
int64
22
545k
score
float64
3.5
5.34
int_score
int64
4
5
text
stringlengths
22
545k
a8e5c4bc11d9a28b1ef139cbd0f3f6b7377e6780
itsmedachan/yuri-python-workspace
/YuriPythonProject2/YuriPy2-6.py
337
4.21875
4
str_temperature = input("What is the temperature today? (celsius) : ") temperature = int(str_temperature) if temperature >= 27: message = "It's hot today." elif temperature >= 20: message = "It's warm and pleasant today." elif temperature >= 14: message = "It's coolish today." else: message = "It's cold today....
5adc56a96758e6d6d45a3f8aa14b3ec9950778b3
itsmedachan/yuri-python-workspace
/YuriPythonProject1/YuriPy1-7.py
359
3.65625
4
# 乱数 import random p = random.random() # 0 <= p < 1 q = random.randint(10, 99) # 10 <= q <= 99 (integer) print("random real number", p) print("random two digit integer", q) # first result # random real number 0.4030206261493706 (16桁) # random two digit integer 48 # second result # random real number 0.9965691087785...
842d8a380ff9e00479708f7ba7639166aba74308
itsmedachan/yuri-python-workspace
/YuriPythonProject3/YuriPy3-4.py
744
3.921875
4
import math class YuriPythonProject3no4: def rectangle_area(self): surroundings = side_a*2 + side_b*2 rectangle_area = side_a*side_b return "周囲は"+str(surroundings)+"、面積は"+str(rectangle_area)+"です" print('長方形の周囲と面積を求めます') side_a = float(input('一辺の長さを入力してください a:')) side_b = float(input('もう一辺の長さを入力してください...
8720293c3184ac1cd2c7bd634924223dc01a03b5
itsmedachan/yuri-python-workspace
/YuriPythonProject1/YuriPy1-8.py
140
3.828125
4
# サイコロを降るプログラム import random dice = random.randint(1, 6) # 1 <= dice <= 6 print("the number of the dice is", dice)
423247af19d550fbf231b08b655c6d6287ff84e2
itsmedachan/yuri-python-workspace
/YuriPythonProject5/YuriPy5-3.py
590
4.125
4
import math class YuriPythonProject5no3: def circle_area(self): circumference_length = 2*math.pi*radius circle_area = math.pi*radius*radius return "円周は"+str(circumference_length)+"、面積は"+str(circle_area)+"です" print('円の円周と面積を求めます') radius = float(input('半径を入力してください: ')) circle = YuriPythonPro...
5079c30dbdb327661f2959b057a192e45fa20319
itsmedachan/yuri-python-workspace
/YuriPythonProject2/YuriPy2-1.py
242
4.15625
4
str_score = input("Input your score: ") score = int(str_score) if score >= 90: grade = "A" elif score >= 80: grade = "B" elif score >= 70: grade = "C" elif score >= 60: grade = "D" else: grade = "F" print("Your grade is: ", grade)
d91a619b993f18bd032543333610e608816665c8
itsmedachan/yuri-python-workspace
/YuriPythonProject5/YuriPy5-5.py
959
3.84375
4
# サイコロを2回降るプログラム # 同じ目が出たら'lucky'と言う import random class YuriPythonProject5no5: def checktheluck(self): if self.first == self.second: return "Yay! You are lucky!" else: return "Oh, sorry. You must be lucky next time." dice1 = random.randint(1, 6) # 1 <= dice <= 6 dice2 = random.randint(1, 6) # ...
a14b096320becb181c9a30694aaee997219262be
itsmedachan/yuri-python-workspace
/YuriPythonProject6/YuriPy6-1.py
140
3.890625
4
import numpy as np np_array = np.array([2,1,3]) print(np_array) # [2 1 3] np_append = np.append(np_array,[0]) print(np_append) # [2 1 3 0]
6d7e09d00142a20629860144e649305b58111485
itsmedachan/yuri-python-workspace
/YuriPythonProject2/YuriPy2-3.py
188
4.0625
4
str_age = input("How old are you? : ") age = int(str_age) if age >= 20: print("Yay! You are allowed to drink in Japan.") else: print("Oh, You are not allowed to drink in Japan yet.")
62c253e2d1c59a86f79fd130db8aa4f2120db10b
DenisOliveira1/course_intro_to_machine_learning
/decision_tree/dt_author_id.py
2,713
3.859375
4
#!/usr/bin/python # -*- coding: cp1252 -*- """ This is the code to accompany the Lesson 3 (decision tree) mini-project. Use a Decision Tree to identify emails from the Enron corpus by author: Sara has label 0 Chris has label 1 """ import sys from time import time sys.path.append("../tools/")...
2a4a972ac56e79ebed8e9465d11f28454b27e991
w2kzx80/py_algs
/3/6.py
692
3.875
4
# 6. В одномерном массиве найти сумму элементов, находящихся между минимальным и максимальным элементами. # Сами минимальный и максимальный элементы в сумму не включать. import random a1 = [random.randint(0,100) for i in range(10)] print(a1) imin = 0 imax = 0 for k, v in enumerate(a1): if v > a1[imax]: i...
f1ba78e3dfb74f0e34341dfac03740be1fa1766b
w2kzx80/py_algs
/2/2_4.py
337
3.71875
4
#4. Найти сумму n элементов следующего ряда чисел: 1, -0.5, 0.25, -0.125,… Количество элементов (n) вводится с клавиатуры. n = int(input('Введите число: ')) cur = 1 sum = 0 for i in range(0,n): sum += cur cur = cur * (-0.5) print(sum)
99f82c6844428725cdfb07f8840d5c62ef631ca0
w2kzx80/py_algs
/1/1_2.py
685
3.703125
4
# 2. По введенным пользователем координатам двух точек вывести уравнение прямой вида y = kx + b, проходящей через эти точки. x1, y1 = [int(c) for c in input("Введите через пробел координаты первой точки: ").split()] x2, y2 = [int(c) for c in input("Введите через пробел координаты второй точки: ").split()] if (x1 == ...
ee25080def64093d78a483183d6eeea9286e640a
MarcusAvrelius/GolovinNick-Python-1-2021-
/6.py
151
3.84375
4
import turtle n = int(input()) for i in range(n): turtle.forward(50) turtle.stamp() turtle.backward(50) turtle.right(360/n)
c6e443e6d7347f3745d3fb99a87e778b1eefc246
charles-uno/project-euler
/python/helpers/__init__.py
244
3.59375
4
from .primes import * # ###################################################################### def fibonacci(): """Iterator that returns Fibonacci numbers forever.""" i, j = 0, 1 while True: yield i i, j = j, i+j
7fd88f6c44e54abed381c99c6d23f63f4faffaea
charles-uno/project-euler
/python/pe-091.py
1,796
3.59375
4
#!/usr/bin/env python3 """ Charles McEachern 2018-11-26 https://projecteuler.net/problem=91 The points P (x1, y1) and Q (x2, y2) are plotted at integer co-ordinates and are joined to the origin, O(0,0), to form triangle OPQ. There are exactly fourteen triangles containing a right angle that can be formed when each c...
9e4e87c3967f64174f68be70c35f537ce0f8252f
charles-uno/project-euler
/python/pe-012.py
515
3.59375
4
#!/usr/bin/env python3 """ Charles McEachern 2018-04-20 https://projecteuler.net/problem=12 """ import helpers # ###################################################################### def main(): n = 0 while True: n += 1 tri = n*(n+1)//2 ndivisors = helpers.ndivisors(tri) if ...
0fb1017d352a5b9ee9855bac217edb6aba6c57ac
tkieft/adventofcode-2019
/day20/day20.py
4,555
3.734375
4
from collections import defaultdict, namedtuple import pprint import sys Point = namedtuple("Point", "x y") NodeEdge = namedtuple("NodeEdge", "node depth") PointEdge = namedtuple("PointEdge", "point depth") class Node: def __init__(self, point): self.point = point self.edges = [] def __repr__...
0c416575e6e0410baf498c9fe53d95f262c542b8
tkieft/adventofcode-2019
/day24/day24.py
4,089
3.578125
4
import functools import itertools import sys powers_of_two = [2 ** i for i in range(25)] BUG = "#" EMPTY = "." def make_board(center = None): board = [[EMPTY for x in range(5)] for y in range(5)] if center: board[2][2] = center return board def make_boards(count): boards = [make_board()] for _ i...
c63a490b252561a3405faf014c21dd00990ebfaa
sicnarf1a/Intro-to-Programming
/4-Create-a-Movie-Website/IPND_Project4/entertainment_center.py
2,507
4.03125
4
# Lesson 3.4: Make Classes # Mini-Project: Movies Website # In this file, you will define instances of the class Movie defined # in media.py. After you follow along with Kunal, make some instances # of your own! # After you run this code, open the file fresh_tomatoes.html to # see your webpage! import media import f...
ce0c0f3e979fd62628ab4f526dc75d653074333b
coderkearns/school
/math/v2/circle.py
1,419
3.84375
4
#!/usr/bin/env python3 doc = """ ## Circle: (x-h)^2 + (y-k)^2 = r^2 Where center = Point(h, k) """ __doc__ = doc import matplotlib.pyplot as plt import math from point import Point class Circle(): __doc__ = doc def __init__(self, h, k, r): self.center = Point(h, k) self.radius = r d...
d0079957b0afb8fe3a9f6259868a3378f70ee173
coderkearns/school
/math/v1/chem/pressure/r.py
812
3.5
4
#!/usr/bin/env python3 # chem/osmotic_pressure.py """R constant: used in most equations dealing with pressure, "R" is different for each unit of pressure. R @: atm = 0.0821 torr = 62.4 mm Hg = 62.4 kPa = 8.31 # r(pressure_type) -> float """ R = { #all lowercase "atm": 0.0821, #no spaces g...
c36d1b0c9da2d9094ea4d417e4b75083160ccc9a
coderkearns/school
/math/v2/point.py
2,515
3.6875
4
#!/usr/bin/env python3 # classes/name_of_file.py doc = """ ## Point(x, y) ### Each of the following are both a classmethod and instancemethod distance = √( (x1 - x2)^2 + (y1-y2)^2 ) midpoint = ( (x1+x2)/2 , (y1+y2)/2 ) """ __doc__ = doc import sympy __all__ = ["__doc__", "Point"] class Point(): __doc__ = doc ...
5a05fa61d75ab84841b3152ff452266233d5b4cc
coderkearns/school
/math/v1/classes/point.py
1,078
3.75
4
#!/usr/bin/env python3 # classes/name_of_file.py doc = """ ## Point(x, y) ### Each of the following are both a classmethod and instancemethod distance = √( (x1 - x2)^2 + (y1-y2)^2 ) midpoint = ( (x1+x2)/2 , (y1+y2)/2 ) """ __doc__ = doc import sympy __all__ = ["__doc__", "Point"] class Point(): __doc__ = doc ...
a14af268d09f7d473a54b4aa8b1bb22f9a5e54da
coderkearns/school
/math/v1/quadratics/vertex_form.py
1,154
3.9375
4
#!/usr/bin/env python3 # vertex_form.py """Vertex Quadratic Formula y = a(x-h)^2 + k line of symetry = h vertex = (h, k) y-intercept = ( a*(0-h)^2 + k ) # vertex(h, k) -> str # y_intercept(a, h, k) -> float # vertex_form(a, h, k) -> str # format_func(a, h, k) """ from math import sqrt from util import strip_all...
b740256e0273fd04cac2843b0b19b081cf0bce80
AdamZeng1/analyzingImage
/count-areas.py
4,250
3.6875
4
import sys def binary_to_array(filename): """ convert base 16 binary data to integer and store the integer to a two-dimension array :return: two-dimensional array with lots of 255, 200, 0 which represent white pixels,grey pixels,black pixels """ # width and height of the image size = 256 # ...
9a7c82e92b8a89b9146ba95d7db7292e2073eaea
BirgerMoell/web-cognitive-test
/backend/setup_db.py
1,104
3.921875
4
import sqlite3 import os def setup_db(filename): # Remove db file and reset db os.remove(filename) con = sqlite3.connect(filename) cur = con.cursor() # Create table cur.execute('''CREATE TABLE "users" (name text, email text, password text, conversations list, create_date text, a...
5b1a84b53f2be45052c16c471d76c6089422aef6
evasu9582/python
/namedtuple.py
161
3.546875
4
from collections import namedtuple a=namedtuple('Car',['color','mileage']) ak=a('red',89.00) print(ak.color) print(ak.mileage) print(ak[0]) print(*ak) print(ak)
377e27d62665a367045ddb9588bde58ccd1398b9
evasu9582/python
/interview/sumoftwodiffernet.py
189
3.75
4
def or_arrays(arr1, arr2): arr=set(arr1+arr2) if len(arr)==len(arr1): return arr1 else: return [i+j for i,j in zip(arr1+arr2)] print(or_arrays([1,2,3],[1,2,3]))
c6b9db2bf3c98c763ebf1a80a735f5b9006e7f7d
evasu9582/python
/argument.py
125
3.796875
4
def last(*a): return a[0][len(a[0])-1] if type(a[0])==list or type(a[0])==str else a[len(a[0])-1] print(last([1,2,3,4]))
f033cea5c11cfc1bff1054ae3db04719555e3b48
PhillipHage202/python-testing
/python-testing/applications/list_of_squares.py
164
3.734375
4
def list_of_squares(n): d=dict() for i in range(1,n+1): d[i]=i*i return d ## it prints > {1: 0, 2: 0, 3: 0, 4: 0, 5: 0, 6: 0, 7: 0, 8: 0, 9: 0}
4836c5f90c0cff44872b5ee956f167c9af6ca8a1
goto4711/dimpah
/_build/jupyter_execute/Text/Text_1.py
22,157
4.0625
4
# Analysing Historical Cultures 1 Today we work on historical cultures. The methods are not very different from social analytics, which we have already discussed. But the data is often only available in texts, as your readings have discussed. That’s why we use this opportunity to concentrate on how to analyse texts. ...
dc49b9bb47f9d4e960b1b31948d61e9c77c3a763
goto4711/dimpah
/_build/jupyter_execute/VisualsArts/AdvancedVisualisation.py
3,101
4.1875
4
# Lots of fun with Python visualisations In this exercise, we use a simple dataset to experience more of the power of matplotlib or seaborn?. It is different from other exercises we have seen so far, as we really focus here on the technology rather than the exploration of real-life data. ## Our dataset today: Iris T...
9785df49c3660fe930aec71613d9e42c1b9e4735
goto4711/dimpah
/_build/jupyter_execute/HistoricalCultures/hate-speech-twitter.py
6,832
3.890625
4
# Hate Speech Detector In today's session, we learned that in order to detect sentiments we can simply compare freqeuencies of positive and negative words. To this end, we downloaded a dictionary of such terms from the web and then determined their respective frequency. If there are more positive terms in a document ...
531d128ba5af7cfed38d998243a57c2e7a2bf8eb
goto4711/dimpah
/_build/jupyter_execute/AI_for_society/ass3/Analysing_Communities_1.py
16,320
4.15625
4
# Detecting Political Communities of Practice ## The US Congress Today, we start exploring political and social community data using a popular exploration technique with association mining like clustering. It is very effective and easy to use. We will gain some real insights about US politics as well as communities ...
4b0de9bb8baee7be27f7b8980ba7357039977490
Vonewman/algorithm_toolbox
/week2_algorithic_warm-up/last_digit_of_fibonacci_number/fibonacci-last-digit-python/fibonacci_last_digit.py
676
3.96875
4
from sys import stdin def get_fibonacci_last_digit_naive(n): """ Naive Algorithm that compute the last fibonacci number """ if n <= 1: return n previous = 0 current = 1 for _ in range(n-1): previous, current = current, (previous + current) % 10 return current def las...
e8161436b936c64329b17ac3f32d439ce3cddd58
Vonewman/algorithm_toolbox
/week2_algorithic_warm-up/last_digit_of_fibonacci_number/fibonacci-last-digit-python/last_digit_of_fibonacci_number.py
368
4
4
# Optimized Python 3 Program to find last # Digit of fibonacci number. # Time Complexity O(1) # Finds nth fibonacci number def fib(f, n): # 0th and list number of # the series are 0 and 1 for i in range(2, n+1): f[i] = (f[i-1] + f[i-2]) % 10 return f def findLastDigit(n): f = [0] * 61 ...
6fafef499b39d4a0fa12ccc1273145e93d605539
oliveromondi65/Prime_number_solution
/Datatype.py
607
4.03125
4
def data_type(arg): if arg is None: #testing for none return 'no value' elif type(arg) == str: #testing for strings length = len(arg) return length elif type(arg) == bool: #testing for boolean return arg elif type(arg) == int: #testing for integer if arg<100: return 'le...
b8fdfb4b1279ba7ae634a64035304b15505e6a0a
louielolo/LeetCodeFMH
/hw/跳台阶/frogjump.py
693
3.859375
4
# -*- coding:utf-8 -*- class Solution: def jumpFloor_recur(self, number): if number ==1: return 1 if number == 2: return 2 return self.jumpFloor_recur(number-1)+self.jumpFloor_recur(number-2) # write code here def jumpFloor_loop(self,number): ...
2b184b7e7fab902b11cc4da35abf17b89075ce78
louielolo/LeetCodeFMH
/BinTree/二叉树中结点和最大的二叉搜索树/binarySearchTreeOperation.py
2,751
3.765625
4
# Definition for a binary tree node. class TreeNode: def __init__(self, x): self.val = x self.left = None self.right = None class Solution: def __init__(self): self.treelist = [] self.leftmax = 0 self.rightmin = 0 def inorder(self,root: TreeNode)->list: ...
0b5d8f76a5767a6c913dce4b8107f4399cfd77b2
louielolo/LeetCodeFMH
/BinTree/二叉树中结点和最大的二叉搜索树/largestBST.py
2,281
4.25
4
""" 给你一棵以 root 为根的 二叉树 ,请你返回 任意 二叉搜索子树的最大键值和。 二叉搜索树的定义如下: 任意节点的左子树中的键值都 小于 此节点的键值。 任意节点的右子树中的键值都 大于 此节点的键值。 任意节点的左子树和右子树都是二叉搜索树。   来源:力扣(LeetCode) 链接:https://leetcode-cn.com/problems/maximum-sum-bst-in-binary-tree 著作权归领扣网络所有。商业转载请联系官方授权,非商业转载请注明出处。 """ class TreeNode: def __init__(self,val=0,left=None,right=None...
aaec72fd8b72de96a079fe0bb11d493a4638aa65
louielolo/LeetCodeFMH
/leetcode/队列的最大值/queue_max.py
379
3.703125
4
from collections import deque class MaxQueue: def __init__(self): self.dq = deque() def max_value(self) -> int: if self.q: return max(self.dq) else: return -1 def push_back(self, value: int) -> None: self.dq.append(value) def pop_front(self) ...
0d86e72490a05d7d6f0c1ad43459cd5fdbb9c170
soniccc/regexp
/regexp4.py
256
3.875
4
#Example : find a substring within words in a sentence. Notice that Tart and start # are not printed from the for loop import re sentence = "Tart, start, apart, cart" all_examples = re.findall("[tsac]art", sentence) for i in all_examples: print(i)
ad5f7bd7652559a42904eee699f9f3b0238689c8
soniccc/regexp
/regexp2.py
386
4.53125
5
# Example: To verify a string contans a particular word import re paragraph = ''' The regular expression isolates the document's namespace value, which is then used to compose findable values for tag names ''' word = 'namespace' if re.search(word, paragraph): print(f"The paragraph contains the word : '{word}'")...
9040c41779a066dbc781ad7188054468c31a487d
metobom/hackerrank_solutions
/diagonal_difference.py
211
3.671875
4
def diagonalDifference(arr): n = len(arr) s1 = 0 s2 = 0 j = n - 1 for i in range(n): s1 += arr[i][j] s2 += arr[i][i] j-=1 out = abs(s2-s1) return out
9d080cd0599f6077bcdad6b4288ea0a468e4cc13
ochim/python-lessons
/myapp16.py
450
3.546875
4
# class # method class User: # clss variable count = 0 # constructor def __init__(self,name): User.count += 1 self.name = name # instance method def say_hello(self): print ("hello {0}".format(self.name)) # class method @classmethod def show_info(cls): ...
21057abe3e46a5fbd000ae49b17705d88e7e52ec
ochim/python-lessons
/myapp9.py
157
3.921875
4
# for # for var in collection #for i in range(0,10): for i in range(10): if i == 8: #break continue print(i) else: print("end")
9a723942b2c26b76500af2d2bd8e36806d250343
AntonioGuletskiy/GBPython
/123.py
1,142
3.5625
4
import re # # def email_parse(email_address): # result = (re.split(r'@', email_address)) # if '.' not in result[1]: # print('некорректный email') # else: # new_dict = dict(username=result[0], domain=result[1]) # print(new_dict) # return # # # email_parse('someone@geekbrains.ru') ...
c50996345949e25f2bc5e6ab451e8a22f6a0c5fb
DanielFleming11/Name
/AverageScores.py
551
4.28125
4
#Initialize all variables to 0 numberOfScores = 0 score = 0 total = 0 scoreCount = 0 average = 0.0 #Accept the number of scores to average numberOfScores = int(input("Please enter the number of scores you want to input: ")) #Add a loop to make this code repeat until scoreCount = numberOfScores while(scoreCount != n...
221a661ba52f4393d984a377511f87f7ca1e285d
iwasnevergivenaname/recursion_rocks
/factorial.py
328
4.40625
4
# You will have to figure out what parameters to include # 🚨 All functions must use recursion 🚨 # This function returns the factorial of a given number. def factorial(n, result = 1): # Write code here result *= n n -= 1 if n == 1: return result return factorial(n, result) print(factorial...
0abc15bef6b41476735fb3a72788c665c6b9e1c3
vilgelm88/homework
/task_6.py
1,418
3.84375
4
import random SIZE = 10 MIN_ITEM = 1 MAX_ITEM = 100 array = [random.randint(MIN_ITEM, MAX_ITEM) for _ in range(SIZE)] max_number = array[0] min_number = array[0] imax = 0 imin = 0 print('Сгенерированный массив случайных натуральных чисел:', array) for i in range(1, SIZE): if array[i] >= max_number: max...
61c24cc84c42fdabcec0425f3f5af35bb74583ef
brod26/leetCodeSolutions
/containerWithMostWaterArrays.py
1,099
3.75
4
# Given n non-negative integers a1, a2, ..., an , where each represents a point at coordinate (i, ai). n vertical lines are drawn such that the two endpoints of the line i is at (i, ai) and (i, 0). Find two lines, which, together with the x-axis forms a container, such that the container contains the most water. # Exam...
a28bc5ac6ac16a0e655ea69ca8050b717070fd14
traviskirker/codingbat-python-solutions
/string-2.py
789
4
4
# Given a string, return a string where for every char in the original, there are # two chars. def double_char(str): x = "" for i in range(len(str)): x = x + 2*str[i] return x # Return the number of times that the string "hi" appears anywhere in the given string. def count_hi(str): count = 0 for i in...
08f3b9b019676d2461c1b7114cabf0c6df1e0141
OscarHoekstra/ClassifyNPDB
/Scripts/GetSqlIDs.py
1,347
3.578125
4
#!/usr/bin/env python3 """ Author: Oscar Hoekstra Student Number: 961007346130 Email: oscarhoekstra@wur.nl Description: Get all the NP_IDs from the NPDB and puts them in a list. """ import sqlite3 import sys from Scripts import InteractWithSQL as Sql def Retrieve_NP_IDs(sqlite_file,table_name,id_column = "structure_id...
726666c89092dfedb4bbd3451f9fa56c104fe829
michaelaye/LASP-REU-Python
/lasp_reu_python_tutorial_day2_exercises.py
7,730
4.25
4
# coding: utf-8 # # Exploring Data Through Plotting # # (based on Morgan Rehnberg's previous tutorial exercices. Adapted to use pandas by K.-Michael Aye) # # Realizing that there’s more to the solar system than just the Sun, you have commandeered the Cassini spacecraft and performed a stellar occultation of the rin...
0c208d133a6c2eaa111c447b09f15c3ef6208749
valer-whylabs/whylogs
/examples/log_df_to_whylabs.py
880
3.640625
4
""" Log a dataframe and send the profile to WhyLabs for visualization =============== Example for logging a dataframe and sending the results to WhyLabs, where the data can be explored further """ import pandas as pd from whylogs.app.session import start_whylabs_session # Load some sample data df = pd.read_csv("data...
1bad6137e5ccf4062d8df61ca7865e9d871a41ca
valer-whylabs/whylogs
/examples/whylabs/log_df_with_api_key.py
944
3.546875
4
""" Log a dataframe to WhyLabs =============== Example of logging a dataframe with log rotation to WhyLabs """ import logging import os import time import pandas as pd from whylogs.app.session import get_or_create_session os.environ["WHYLABS_API_KEY"] = "<API-KEY>" os.environ["WHYLABS_API_ENDPOINT"] = "<end point o...
f42f83953a31dfbfd33eb9198aaab9690cdcf726
valer-whylabs/whylogs
/examples/anonymous_session_csv_with_timestamp.py
1,757
3.734375
4
""" Log a series of dataframes grouped by date and send to WhyLabs for visualization =============== Using data from a Kaggle dataset (https://www.kaggle.com/yugagrawal95/sample-media-spends-data), split the dataset up by each day using the Calendar_Week column and log each of the data for that day using whylogs. """ ...
7c4c69f06368aa4d9ce8f44b9ab313a49d3ea3e5
sjallal/pythonProgramming
/OOPS/01ClassDemo.py
540
3.875
4
class Computer: def __init__(self, name, os, mem, ram): self.name = name self.os = os self.mem = mem self.ram = ram def getInfo(self): print('name of the Computer is: ',self.name) print('os is: ',self.os) print('memeory is: ',self.mem) print('ram i...
ae191f32c0b8238dd78c7cc292188d58cea19fbf
DracoRex679/Rewire
/Python Calculator.py
4,398
4.09375
4
from tkinter import * root = Tk() root.title("Python Calculator") entry = Entry(root, width=35, borderwidth=5) entry.grid(row=0, column=0, columnspan=5, padx=10, pady=10) def button_add(number): current = entry.get() entry.delete(0, END) entry.insert(0, str(current) + str(number)) return ...
766f53feb373a9f6428ab5787cd7acc0ee5a30e6
LukasZavrel/project_euler
/euler_34.py
245
3.6875
4
import math total_sum = 0 for i in range(10,10**7): curr_nr = str(i) partial_sum = 0 for nr in curr_nr: partial_sum += math.factorial(int(nr)) if partial_sum == i: print(i) total_sum += i print(total_sum)
f5ec832841891ec876c1fc06f57a6113a4f636c9
LukasZavrel/project_euler
/euler_76.py
494
3.609375
4
# %% dynamic_dict = {} def how_many_ways(max_used, remaining_sum): if (max_used, remaining_sum) not in dynamic_dict: if max_used == 1 or remaining_sum == 0: dynamic_dict[(max_used, remaining_sum)] = 1 else: dynamic_dict[(max_used, remaining_sum)] = sum( [how...
ca82e7e796161718315fee64b99a6169cfaf2da4
LukasZavrel/project_euler
/euler_52.py
359
3.75
4
#%% for exponent in range(10): print(f'current exponent is {exponent}') for i in range(10**exponent, 10**(exponent + 1)//6): if sorted([j for j in str(i)]) == sorted([j for j in str(2*i)]) == sorted([j for j in str(3*i)]) == sorted([j for j in str(4*i)]) == sorted([j for j in str(5 *i)]) == sorted([j fo...
9ab7885c5382dae062a7dfa2becb3af3e95a451d
LukasZavrel/project_euler
/euler_14.py
568
3.84375
4
collatz_dict = {1: 1} # %% def collatz(num): if num in collatz_dict: return collatz_dict[num] elif num % 2: next_seq = collatz(3 * num + 1) collatz_dict[num] = next_seq + 1 return next_seq + 1 else: next_seq = collatz(num // 2) collatz_dict[num] = next_seq +...
e971942afb3557ed982c613a14e4c63937e385d1
limicala/DSA
/Dynamic/chorus.py
7,595
3.5
4
# -*- coding: utf-8 -*- """ 题目链接:https://www.nowcoder.com/practice/661c49118ca241909add3a11c96408c8 题目描述 有 n 个学生站成一排,每个学生有一个能力值, 牛牛想从这 n 个学生中按照顺序选取 k 名学生, 要求相邻两个学生的位置编号的差不超过 d, 使得这 k 个学生的能力值的乘积最大,你能返回最大的乘积吗? ------------------------------------------------------------------------------ 若先考虑不限制相邻学生的位置编号之...
b2e6d5d485409a42c565292fa84db602445778a4
eugenesamozdran/lits-homework
/homework8_in_progress.py
1,178
4.3125
4
from collections.abc import Iterable def bubble_sort(iter_obj, key=None, reverse=False): # first, we check if argument is iterable # if yes and if it is not 'list', we convert the argument to a list if isinstance(iter_obj, Iterable): # here we check if some function was passed a...
f57bd69684d5a8a29b1132ca9c8366803850db96
360cid/project-euler
/python/prob3.py
819
3.765625
4
# project euler problem 3: # The prime factors of 13195 are 5, 7, 13 and 29. # What is the largest prime factor of the number 600851475143 ? # determine whether number is prime def isPrime(number): for i in xrange(2,number/2): if number % i == 0: # print "%d is a factor of %d" % (i,number) ...
be43710389c2c891e11812c9e7395cc964b8c016
zulfikarbayu/prak_ASD_B
/Modul2/SoalNo1.py
1,068
3.78125
4
class Pesan(object): """ Sebuah class bernama Pesan. Untuk memahami konsep Class dan Object. """ def __init__(self, sebuahString): self.teks = sebuahString def cetakIni(self): print(self.teks) def cetakPakaiHurufKapital(self): print(str.upper(self.te...
ec644ee4fc130e6afb4dd54b5762f7e8e43249bc
swheatley/python_scraping
/scrape_practice/scrape_test.py
802
3.546875
4
#!/usr/bin/env python import urllib import urllib2 from lxml import etree import StringIO result = urllib.urlopen("http://www.slcolibrary.org/") html = result.read() parser = etree.HTMLParser() tree = etree.parse(StringIO.StringIO(html), parser) href_xpath = "//*[@id='main-nav']/li/a/@href" filtered_html = tree....
c42ca4d5e5e3252598958aa66cc999714fdf2c55
sauravbiswasiupr/Google_algo_problems
/AddNumbersAsArrays.py
561
4.0625
4
###Algorithm to add two numbers represented as arrays # n1 = [1, 2, 3]; n2 = [4, 5, 6] #res = [5, 7, 9] def addNumberArrays(a1, a2): res = [] assert len(a1) == len(a2) N = len(a1) carry = 0 for i in range(N-1, -1, -1): tempSum = a1[i] + a2[i] + carry if tempSum > 10: carry = 1 res.appen...
1d8d1463a46019de0a64faeb6d56f3ad79cb3415
Guilherme-Almeidaa/trybe-exercises
/Computer-science/34.1-python/exer6.py
255
4.0625
4
def triangle_type(l1, l2, l3): if l1 == l2 == l3: return "Triângulo Equilátero" elif l1 == l2 or l1 == l3 or l2 == l3: return "Triângulo Isósceles" else: return "Triângulo Escaleno" print(triangle_type(3, 1, 2))
4dae27c8080219b6b7734a679c9c9cea65ff2029
saumyaagrahari123/ifelse
/Q2.PY
141
3.5625
4
salary=50000 year=5 if("50000==salary"): print("give the bonus") if("5==year"): print("yes give the bonus") else:("no bonus")
1f9c9dca58549e0639477b4f5622a5b5f09d58d6
saumyaagrahari123/ifelse
/Q15.PY
379
4
4
day=(input("enter the day")) if day==("monday"): print("rajma chaval") if day==("tuesday"): print("puri & sabzi") if day==("wednesday"): print("pizza") if day==("thursday"): print("chhole bhature") if day==("friday"): print("samose") if day==("saturday"): print("roti sabzi") if day==("sunday"): ...
a6d4b45e357e54cd78cc1022fdbb02d3e154452d
Diego-18/python-algorithmic-exercises
/v1/_1.py
338
3.71875
4
cadena = raw_input('Escribe una frase: ') while cadena != '': cambios = 0 for i in range(1, len(cadena)): if cadena[i] == ' ' and cadena[i-1] != ' ': cambios = cambios + 1 if cadena[-1] == ' ': cambios = cambios - 1 palabras = cambios + 1 print 'Palabras:', palabras cadena = raw_input('Escr...
585effa4ddc287e80607c91690bdd46ea1bcaaf5
Diego-18/python-algorithmic-exercises
/2. PROGRAMACION MODULAR/NUMEROS/numeros.py
1,631
3.9375
4
#!/usr/bin/env python #-*- coding:UTF8 -*- ################################ # Elaborado por: DIEGO CHAVEZ # ################################ #Algoritmo capaz de mostrar los numeros pares, primos, positivos, perfectos, enteros, de los numeros del 1 al 100 #Inicio def fbprimo (pinumero): licont=0 for...
0e6a5273de9075c5929cf5adfe5a2b34fa8abc10
Diego-18/python-algorithmic-exercises
/6. PILAS & COLAS/Articulo.py
2,236
3.765625
4
#!/usr/bin/env python #-*- coding: UTF-8 -*- ################################ # Elaborado por: DIEGO CHAVEZ # ################################ import os from collections import deque #Funciones: def fiLeerI(psTexto): liVarI=int(raw_input(psTexto)) return liVarI def fsLeerS(psTexto): lsVarS=raw_input(p...
7acc25c12d7f688d0b428849de5b3015086c2644
Diego-18/python-algorithmic-exercises
/1. PROGRAMACION ESTRUCTURADA/NUMEROS/par y primo.py
704
4.125
4
#!/usr/bin/env python #-*- coding: cp1252 -*- ################################ # Elaborado por: DIEGO CHAVEZ # ################################ #Algoritmo capaz de verificar si un numero es par y primo lsseguir="s" licont=0 while lsseguir=="s" or lsseguir=="S": linumero=int(raw_input("Introduzca el numero: ")...
57b282d46d9d8bdb3fa911f08434283989f5b44b
Diego-18/python-algorithmic-exercises
/v1/decimal.py
181
3.765625
4
bits = raw_input('Dame un nmero binario: ') n = len(bits) valor = 0 for bit in bits: if bit == '1': valor = valor + 2 ** (n-1) n -= 1 print 'Su valor decimal es', valor
e247a059e921ef1c1fc26ee5d669583417961d75
Diego-18/python-algorithmic-exercises
/1. PROGRAMACION ESTRUCTURADA/CALCULOS/Carpinteria.py
783
3.734375
4
#!/usr/bin/env python # -*- coding: UTF8 -*- ################################ # Elaborado por: DIEGO CHAVEZ # ################################ #Algoritmo capaz de calcular el costo unitario y al mayor de un articulo lsnombre=raw_input("Introduzca el nombre del articulo: ") lfgmanodeobra=float(raw_input("Introduzca ...
ed551aca7efc6d5fbf8e8de1de4f15c930edc300
Diego-18/python-algorithmic-exercises
/4. ARREGLO/10numeros.py
1,519
3.671875
4
#!/usr/bin/env python #-*- coding: UTF8 -*- ################################ # Elaborado por: DIEGO CHAVEZ # ################################ #realize un algoritmo que cargue 10 numeros y los arreglo con quicksort def fiLeerI(psTexto): liVar=int(raw_input(psTexto)) return liVar def fsLeerS(psTexto): lsVar=raw_...
4328a0410bc39c3e5372415fb14b7cdfae305b98
Diego-18/python-algorithmic-exercises
/1. PROGRAMACION ESTRUCTURADA/GEOMETRIA/area de un rectangulo.py
407
3.796875
4
#!/usr/bin/env python # -*- coding: UTF8 -*- ################################ # Elaborado por: DIEGO CHAVEZ # ################################ #Algoritmo capaz de calcular el area de un rectangulo lflado=float(raw_input("Introduzca el lado del rectangulo: ")) lfancho=float(raw_input("Introduzca el ancho del rectang...
6da0d64dc5336c676a07ea254324bb9ebd9e5758
Diego-18/python-algorithmic-exercises
/1. PROGRAMACION ESTRUCTURADA/CALCULOS/Blacberry.py
651
3.859375
4
#!/usr/bin/env python # -*- coding: UTF8 -*- ################################ # Elaborado por: DIEGO CHAVEZ # ################################ #Algoritmo capaz de calcular la cantidad de telefonos blackberry introducidos al sistema liacum=0 licont=0 lsseguir="s" while lsseguir=="s" or lsseguir=="S": lsempresa=...
47003bac387db7d82194f1dbf9d5c817f4ebe55a
Diego-18/python-algorithmic-exercises
/v1/hanoi.py
312
3.5625
4
def resuelve_hanoi(n, inicial, final, libre): if n == 1: print 'Mover disco superior de aguja', inicial, 'a', final else: resuelve_hanoi(n-1, inicial, libre, final) print 'Mover disco superior de aguja', inicial, 'a', final resuelve_hanoi(n-1, libre, final, inicial) resuelve_hanoi(4,1,3,2)
ad2ed3e2fffff86e97d7fb447d2d427a5ba8950c
Diego-18/python-algorithmic-exercises
/1. PROGRAMACION ESTRUCTURADA/CALCULOS/restaurant.py
1,151
4.09375
4
#!/usr/bin/env python #-*-coding:UTF-8-*- ################################ # Elaborado por: DIEGO CHAVEZ # ################################ #Algoritmo capaz de facturar el total a pagar en un restaurante lsseguir="s" liacum=0 licont=0 while lsseguir=="S" or lsseguir=="s": lfplato1=float(raw_input("Introduzca e...
21c526146b56dda9bfb766bf078f1698b2132427
Diego-18/python-algorithmic-exercises
/7. POO/Telefono.py
6,717
3.859375
4
#!/usr/bin/env python #-*- coding:cp1252 -*- ################################ # Elaborado por: DIEGO CHAVEZ # ################################ #Clases: class ClsTelefono(object): Marca="" Modelo="" def __Init__(Self): Self.Marca="" Self.Modelo="" def GetMarca(Self,pmarca): ...
d1aa420a6625c6c17305a5fd84f180a976a57307
Diego-18/python-algorithmic-exercises
/1. PROGRAMACION ESTRUCTURADA/CALCULOS/empresa polar.py
666
3.65625
4
#!/usr/bin/env python #-*- coding: UTF8 -*- ################################ # Elaborado por: DIEGO CHAVEZ # ################################ #Algoritmo capaz de calcular el sueldo neto de un empleado con deducciones y bonificacion #Inicio #Entrada lsnombre=raw_input("Introduzca el nombre del empleado: ") lssexo=ra...
b92f0c7574dbe6d8d08a47c09b92e99d2faca9f8
Diego-18/python-algorithmic-exercises
/7. POO/colegio(inscripcion).py
3,069
4.0625
4
#!/usr/bin/env python #-*- coding: UTF-8 -*- #Inicio: class Persona(object): Nombre="" Apellido="" Cedula="" def __Init__(self): self.Nombre="" self.Apellido="" self.Cedula="" def GetNombre(self, pnombre): self.Nombre=pnombre def GetApellido(self, papellido): self.Apellido=papellido def GetCe...
1688b124c437634064cf278ec6ec7dee50902ac5
Diego-18/python-algorithmic-exercises
/v1/parametros_6.py
96
3.59375
4
def incrementa(a): a = a + 1 return a a = 1 b = incrementa(a) print 'a:', a print 'b:', b
b251d95aa8f1d216ba4578c0471295cc7431bae1
realDavidChen/Python-resources
/Scripts/dict10.py
118
4.03125
4
'''10. Write a Python program to sum all the items in a dictionary.''' dict={1:10,2:20,3:30} print(sum(dict.values()))
47a4b98446615a78e3c7b56c141ceb8b854467d0
DenisLezin/algorithms_GB
/lesson7_hw.py
1,290
3.859375
4
# Пару месяцев назад небходимо было отсортировать довольно большой массив (~200 000) # Нашел быструю сортировку. Не совсем понял как она работает, но использовал. # Наконец вы объяснили, сасибо. Я понял принцип. Могу осознанно применять с рекурсией. # Одако ту, что я использовал использует что-то типа стека - вот ее по...
376b9ca280ffaeefae3b7c181edbb25022ba2734
genesisschaerrer/oop
/custom-iterator.py
657
3.5
4
class Lineup: def__init__(self, players): self.players = players def __iter__(self): self.n = 0 return self def __next__(self): if self.n < (len(self.players)) -1): player = self.players[self.n] self.n += 1 return player elif self....
8b5644a4ad592c1c4e95bf2bfb757dba462af78a
ufpa-organization-repositories/numerical-methods
/methods/cap_2_roots/cap2_2_false-position/main.py
5,290
3.609375
4
import numpy as np import matplotlib.pyplot as plt from modules import * ERROR_THRESHOLD = 0.01 N_MAX_ITERATIONS = 10 # Entrada de valores # Passo 1: definir [a,b] a partir de análise visual a = calc_truncate(0) b = calc_truncate(1) # Output: Receives the ROOT retrivied for the program ROOT = None ERROR = None #...
7064d05454a908f49cf02145046f5f520f8d998c
ufpa-organization-repositories/numerical-methods
/methods/cap_2_roots/cap2_1_bissection/modules.py
1,205
3.609375
4
import numpy as np N_FLOATING_POINTS = 4 def calc_truncate(number: float, N_FLOATING_POINTS: int = 4) -> float: """ Truncate the number to the specified floating points """ string = str(number) if '.' in string: for index, elem in enumerate(string): if elem == '.': return float(string[:index + 1 + ...
5711afdfef0c8df08d062d5b1aceb402f6ddaf52
compengevfan/Python
/Learn Python Programming Masterclass/2. Variables.py
617
3.609375
4
# greeting = "Bruce" # _myName = "Tim" # Tim45 = "Good" # Tim_Was_57 = "Hello" # Greeting = "There" # print(Tim_Was_57 + ' ' + greeting) # age = 24 # print(age) # #This doesn't work # #print(greeting + age) # a = 12 # b = 3 # print(a + b) # print(a - b) # print(a * b) # print(a / b) # print(a // b) # print(a % b) ...
b764efb23f3f2c5ecb4cd4b004a41e6ef86c6561
SpirosOrfanos/Credit-Suisse-GCC-2021-Solutions
/D. Pair of Candlesticks/Solution.py
600
3.5
4
### KNOWLEDGE IS POWER ### def totalPairs(n, values): # Participants code will be here no_of_pairs = 0 length = len(values)-1 for index in range(length): for index2 in range(length, index+1, -1): if max(values[index+1:index2]) < values[index] and max(values[index+1:index2]) < valu...
12ca3949ce6f3d218ed13f58ee0ab0a0e06f4ab4
geyunxiang/mmdps
/mmdps/util/clock.py
1,760
4.34375
4
""" Clock and time related utils. """ import datetime from datetime import date def add_years(d, years): """ Return a date that's `years` years after the date (or datetime) object `d`. Return the same calendar date (month and day) in the destination year, if it exists, otherwise use the following day ...
9002c81e6429f4984c4fb2e5b840e61342cc0d81
tyleryasaka/rosalind-solutions
/BA1B.py
731
3.703125
4
from BA1A import patternCount datasetFile = open("datasets/rosalind_ba1b.txt", "r") text = datasetFile.readline().strip() k = int(datasetFile.readline().strip()) print("Find the Most Frequent Words in a String\n") def frequentWords(text, k): frequentPatterns = set() maxCount = None for i in range(len(tex...
8c15bbfe7a6495d592e6ab54d2a82f6a9e44bb95
MicheleCattaneo/USI_Algo_Bible
/DynamicProgramming/minimumCoinChange.py
1,702
3.9375
4
''' Given a list of coins, find the minimum number of coins to get to a certain value For Example: coins={1,2,3} V=5 Output: 2 (3+2=5) Note: the list must always contain a coin of value 1, so in the worst case the output will be V*'coin 1' ''' def minCoin(coins, amount): return minCoin_(coins, amoun...
bab0da78776dc0284d5150f9de9909f5d4bd1c9c
MicheleCattaneo/USI_Algo_Bible
/DynamicProgramming/makeCoinChange.py
1,634
3.734375
4
''' Given unlimited supply of coins, find the way to add up to the given number the coins to make that number. Ex: coins ={1,2,3} V=5 Output: 5 possiblities {1,1,1,1,1} {1,1,1,2}, {1,2,2}, {1,1,3} {2,3} ''' def makeChangeIter(coins, n): # MAKE DP DP = [] for i in range(len(coins)+1): col = ...
ede7a680317cd11026685abafb2d33cf00b53771
MicheleCattaneo/USI_Algo_Bible
/Sorting/bubbleSort.py
262
3.84375
4
def bubbleSort(A): for i in range(len(A)): for j in range(len(A) - 1, i, -1): if A[j] < A[j - 1]: A[j], A[j - 1] = A[j - 1], A[j] print(A) return A A = [5, 6, 12, 8, 4, 10, 3, 12, 11, 1] bubbleSort(A)