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 |
|---|---|---|---|---|---|---|
a8c3a61ffb40995ed62c3573fdd300968536adcc | rashmi-rathi/project_euler | /023.py | 1,316 | 3.6875 | 4 | # -*- coding: utf-8 -*-
"""
Created on Fri Jun 27 13:17:14 2014
@author: Jasbir
"""
import math
def proper_factors(n):
number = int(math.sqrt(n))
factors = set([1])
for i in xrange(2,number+1):
if (i not in factors) and n%i == 0 :
factors.add(i)
factors.... |
032c1bcb21fb3422278f99f45ebbd969a23e03de | rashmi-rathi/project_euler | /007.py | 498 | 3.734375 | 4 | # -*- coding: utf-8 -*-
"""
Created on Sun Jun 08 23:40:24 2014
@author: Jasbir
"""
def IsPrime(n):
import math
m=int(math.sqrt(n))
for i in range(3,m+1,2):
if n%i==0:
return False
return True
import time
start = time.time()
j = 1
i = 1
while True:
... |
65b3d35e58fc463324985e41ff202febf3815edc | rashmi-rathi/project_euler | /010.py | 462 | 3.734375 | 4 | import euler
def solution_1():
n=3
SumPrimes = 2
while n < 2*(10**6):
if euler.is_prime(n) == True:
SumPrimes = SumPrimes + n
n=n+2
return SumPrimes
def solution_2():
primes = euler.sieve(2*10**6)
Sum = 0
for i in primes:
Sum = Sum + i
return Sum
if __name__ == "__main__":... |
9c5bf58efc85be37941a3a5788830f0f154a17da | rashmi-rathi/project_euler | /002.py | 332 | 3.640625 | 4 | def Problem2():
Fibonnaci = 0
FibonnaciOne = 1
FibonnaciTwo = 2
Sum = 2
while Fibonnaci < 4*(10**6):
Fibonnaci = FibonnaciTwo + FibonnaciOne
FibonnaciOne = FibonnaciTwo
FibonnaciTwo = Fibonnaci
if Fibonnaci%2 == 0 :
Sum = Sum + Fibonnaci
... |
076a7170d2d1bc3965ff20d45702cfa64563bfa3 | datalivre/HackerRank | /python3/Basic-Data-Types/finding-the-percentage.py | 463 | 3.5 | 4 | # Finding the percentage
# https://www.hackerrank.com/challenges/finding-the-percentage/problem
from statistics import mean
def precision_percentage(query, x):
return f'{mean(student_marks.get(query)):.{x}f}'
if __name__ == '__main__':
student_marks = {}
for _ in range(int(input())):
name, *li... |
84336a809aaef7b9e0352e8501775720cebcd31f | datalivre/HackerRank | /python3/Errors-and-Exceptions/incorrect-regex.py | 328 | 3.734375 | 4 | # Incorrect Regex
# https://www.hackerrank.com/challenges/incorrect-regex/problem
import re
def re_compile(s):
try:
if re.compile(s):
return True
except:
return False
if __name__ == "__main__":
for _ in range(int(input())):
string = input()
print(re_compile(s... |
7c6e3bcfa2f8a4b662749d6b81f701a829687560 | datalivre/HackerRank | /python3/Built-Ins/input.py | 213 | 3.5625 | 4 | # Input()
# https://www.hackerrank.com/challenges/input/problem
def compare(x, k):
return input() == k
if __name__ == "__main__":
# py2
x, k = map(int, raw_input().split())
print(compare(x, k))
|
5034229a5f033fa5f8f8c16ce430657c36eac914 | datalivre/HackerRank | /python3/Sets/py-the-captains-room.py | 361 | 3.5625 | 4 | # The Captain's Room
# https://www.hackerrank.com/challenges/py-the-captains-room
def captains_room(k, room_list):
room_numbers = sorted([int(i) for i in room_list.split()])
return (k * sum(set(room_numbers)) - sum(room_numbers))//(k-1)
if __name__ == "__main__":
k = int(input())
room_list = input()... |
05e688b0dd723172b5fbe24d2743d65cfb3ab952 | andreypeshev/python-oop | /static-and-class-methods/exercise/project1/movie_world.py | 1,978 | 3.59375 | 4 | class MovieWorld:
def __init__(self, name):
self.name = name
self.customers = []
self.dvds = []
@staticmethod
def dvd_capacity():
return 15
@staticmethod
def customer_capacity():
return 10
def add_customer(self, customer):
if len(self.customers)... |
640cf748c5a9453ca687841c2c9869fe858f3bd7 | bbledmiston/Election-Wars | /electionwars.py | 3,191 | 3.828125 | 4 | import random
"""
class events:
def init self
def list of questions
def ask questions
class player
name
rating/favorability
cpu = true/false
controller - campaign
keeps track of politicians
ratings
main
- call campaign
c.run campaign - loops throughg
json file to create login ... |
f9346d33b5db8fcaa233fb6a0a89f6ca2b78c8e3 | MDGSF/PythonPractice | /commonfunction/collections/deque.py | 568 | 3.9375 | 4 | #!/usr/bin/env python
# -*- coding: UTF-8 -*-
"""
使用list存储数据时,按索引访问元素很快,但是插入和删除元素就很慢了,
因为list是线性存储,数据量大的时候,插入和删除效率很低。
deque是为了高效实现插入和删除操作的双向列表,适合用于队列和栈:
append()
pop()
appendleft()
popleft()
"""
from collections import deque
def test1():
q = deque(['a', 'b', 'c'])
q.append('x')
q.appendleft('y')
p... |
72a61680226352957fcc01520c033f8c01af24d8 | MDGSF/PythonPractice | /theCraftdemo/3_B_4_regex.py | 4,372 | 3.703125 | 4 | #!/usr/bin/env python
# -*- coding: UTF-8 -*-
"""
https://docs.python.org/3/library/re.html
https://regex101.com/
https://regexper.com/
"""
import re
def test1():
strs = 'The quick brown fox jumps over the lazy dog'
pattn = re.compile(r'\wo\w')
result = re.findall(pattn, strs)
print(result)
def te... |
67573e2b33b580e36fcc9dd785d3aa1d701a8667 | MDGSF/PythonPractice | /graphvizdemo/graphviz_3.py | 1,689 | 3.734375 | 4 | #!/usr/bin/env python
# -*- coding: UTF-8 -*-
# use graphviz to print bubble sort.
from graphviz import Digraph
def drawlist(g, l, name, ranklevel, swapidx):
if len(l) == 0:
return
with g.subgraph(name=name) as sub:
sub.attr(rank='same')
sub.attr(rankdir='LR')
rankNodeName ... |
802c5111bb905fbb5d257e9e137797de5245754b | MDGSF/PythonPractice | /ThePythonTutorial/4.6_function.py | 445 | 3.765625 | 4 | #!/usr/bin/env python
# -*- coding: UTF-8 -*-
def fib(n):
a, b = 0, 1
while a < n:
print(a, end=' ')
a, b = b, a + b
print()
def test1():
fib(2000)
def fib2(n):
result = []
a, b = 0, 1
while a < n:
result.append(a)
a, b = b, a + b
return result
def... |
8f1e4fb54c9050f6ca6b66713b1777fc0840c17c | MDGSF/PythonPractice | /theCraftdemo/1_E_6_containers_iteration.py | 1,370 | 3.75 | 4 | #!/usr/bin/env python
# -*- coding: UTF-8 -*-
def test1():
for i in range(3):
print(i)
print()
for i in [1, 2, 3]:
print(i)
print()
s = 'Python'
for i, c in enumerate(s):
print(i, c)
print()
for i, v in enumerate(range(3)):
print(i, v)
print()
... |
95a3cd3a4b900d79b16dde385b093ed74e1d3818 | MDGSF/PythonPractice | /theCraftdemo/1_E_6_containers_set.py | 4,055 | 3.609375 | 4 | #!/usr/bin/env python
# -*- coding: UTF-8 -*-
def test1():
print('\ntest1')
primes = {2, 3, 5, 7, 11, 13, 17}
print(type(primes), primes)
a = {} # 这个是空的字典
print(type(a), a)
b = set() # 这个是空的 set
print(type(b), b)
def test2():
print('\ntest2')
a = "abcabcdeabcdbcdef"
b =... |
99df0778b001dbcc54409b1c067252264500cba5 | MDGSF/PythonPractice | /ThePythonTutorial/3.1.3_lists.py | 486 | 3.6875 | 4 | #!/usr/bin/env python
# -*- coding: UTF-8 -*-
def test1():
letters = ['a', 'b', 'c', 'd', 'e', 'f', 'g']
print(letters)
letters[2:5] = ['C', 'D', 'E']
print(letters)
letters[2:5] = []
print(letters)
letters[:] = []
print(letters)
def test2():
print('\ntest2')
a = ['a', 'b'... |
4792e2ae469e5aa84ffc668977a8ed73bc470727 | MDGSF/PythonPractice | /theCraftdemo/2_D_1_args.py | 1,602 | 3.96875 | 4 | #!/usr/bin/env python
# -*- coding: UTF-8 -*-
def do_something():
print("This is a hello from do_something().")
def test1():
# 没有 return 的函数,默认返回 None。
# None 如果放在 if 中,就是 False。
print(do_something())
# 根据闰年的定义:
# 年份应该是 4 的倍数;
# 年份能被 100 整除但不能被 400 整除的,不是闰年。
# 所以,相当于要在能被 4 整除的年份中,排除那些能被 100 整除... |
f27ec99e5fa2e7136bc85e98bc0ff208b21e14b2 | MDGSF/PythonPractice | /commonfunction/buildin/any.py | 555 | 4.125 | 4 | #!/usr/bin/env python
# -*- coding: UTF-8 -*-
# any(iterable)
# Return True if any element of the iterable is true. If the iterable is empty, return False.
def main():
a_list = []
print(any(a_list)) # False
b_list = [True, True]
print(any(b_list)) # True
c_list = [True, True, False]
prin... |
2abe2bbcada2bb233bc96686fd626717d4274c05 | Ulumanshu/group7 | /identity_membership_logical_operators.py | 656 | 4.03125 | 4 | # Identity operators is, is not
# Logical operators and, or, not
# Membership operators in, not in
# a = list()
# b = list()
# c = a
#
# print(a == b)
# print(a is b)
#
# print(a == c)
# print(a is c)
# print(a == c)
#
# print(a == b and a is b)
#
d = [1, 2, 3, 4, 5, 33, 66]
# print(2 in d, 2 not in d, 6 in d, 6 not... |
312e4fe14a86ed678f70ed0ed5b16c17ccfdb887 | Ulumanshu/group7 | /class_inheritance.py | 680 | 3.78125 | 4 | class Human:
def __init__(self, name, height, weigth):
self.name = name
self.height = height
self.weigth = weigth
class Programmer(Human):
def __init__(self, name, height, weigth, languages):
super().__init__(name, height, weigth)
self.languages = languages
bob = Prog... |
6cb73c7842dce0a5aeed133bcbd075c75fd229e1 | ppedraum/infosatc-lp-avaliativo-01 | /ex2-11.py | 124 | 4 | 4 | #11
m = float(input("Digite uma velocidade em metros por segundo: "))
k = m*3.6
print("{:.2f}m/s = {:.2f}km/h".format(m, k)) |
58e43a5e0e55d0def2a7bfbcc0a8855133a4f428 | ppedraum/infosatc-lp-avaliativo-01 | /ex2-6.py | 133 | 4.15625 | 4 | #6
c = float(input("Digite uma temperatura em celcius: "))
f = c*(9/5) + 32
print("f = {}*(9/5) + 32 ----> f = {} ºF".format(c, f) ) |
b5273ad0faebfa3d35170906fc781a093b0ecdb0 | evanlh/euler | /euler5.py | 1,056 | 4.03125 | 4 | """2520 is the smallest number that can be divided by each of the numbers from 1 to 10 without any remainder.
What is the smallest positive number that is evenly divisible by all of the numbers from 1 to 20?"""
from math import sqrt
def primes_up_to(n):
""" Returns a list of all the prime numbers less than or equal... |
c585449f96a744dc9dc3feb81a62e255338fa9e1 | evanlh/euler | /euler6.py | 430 | 4.09375 | 4 | """ Find the difference between the sum of the squares of the first one hundred natural numbers and the square of the sum."""
def sum_of_squares (nums):
return sum(x**2 for x in nums)
def square_of_sums (nums):
return sum(nums) ** 2
if __name__ == __main__:
a, b = square_of_sums (range(11)), sum_of_squares(rang... |
41dd9db13bc1e9a208bf9d5f3cfdca1832c91f8d | PedroLopezJ/malenciano-translator | /malenciano_translator/words/word.py | 309 | 3.859375 | 4 | class Word:
def __init__(self, word: str):
self.word = word.replace('ñ', 'ny')
def getWord(self):
return self.word
def isLong(self):
return True if len(self.word) > 3 else False
def isMention(self):
return True if self.word[0] == "@" else False |
f6311aafae63aa64b04cfd72c0993a2ef9e313e4 | adishreea/Python-programs | /merge.py | 582 | 4.0625 | 4 | #Question1
#Merging two binary trees
class BinaryTree():
def __init__(self, x):
self.rootNode = x
self.leftNode = None
self.rightNode = None
class MergedTree():
def mergeFunction(self, tree1, tree2):
if tree1 is None:
return tree2
if tree2 is None:
return tree1
#add the root node va... |
9c02583c04eea77a337cfb94a3bf1c19e0979935 | elinapark0818/Algorithm | /Backjoon/etc/아스키코드.py | 256 | 3.71875 | 4 | # print(chr(65))
#
# print(ord('A'))
# print(ord('Z'))
#
# print(ord('a'))
# print(ord('z'))
#
# for i in range(65, 91):
# print(chr(i), end=",")
# print('')
# for x in range(97, 123):
# print(chr(x), end="")
#
# # print(range(chr(97)),chr(122))
|
a8d2568445ed3b80b123a00a2d79cddba9e886b7 | elinapark0818/Algorithm | /프로그래머스/스무고개.py | 748 | 3.765625 | 4 | # 친구와 1부터 100까지 숫자 중 1가지 숫자를 맞추는 스무고개 게임을 하려고 합니다.
# 이 때 사용할 알고리즘을 의사코드로 표현하면 어떻게 될까요?
# N = int(input())
# for i in range(N):
# a = int(input())
# if a == N:
# print('정답')
# else:
# print('땡!')
print('-' * 10)
import random
n = random.randint(200, 3000)
print('200 ~ 3000 까지의 숫자가 있습니다.')... |
694028d19f1f81782c712c04a57896337a72bed9 | elinapark0818/Algorithm | /Backjoon/etc/factorial.py | 649 | 3.859375 | 4 | import math
# n = int(input())
# print(math.factorial(n))
# 재귀함수 사용
# def factorial(i):
# if i == 0 or i == 1:
# return 1
# else:
# return factorial(i - 1) * i
# x = int(input())
# print(factorial(x))
# 재귀함수 다른방법
# def factorial_2(j):
# return j * factorial_2(j - 1) if j > 1 else 1
#
#
... |
8109756ae23600fb1508d5b0570bb10ae66ab784 | Harry-Phy-Quant/Computational-Physics | /Homework2_Cardioid.py | 4,067 | 3.9375 | 4 | """
三次样条函数插值绘制心形曲线
"""
import matplotlib.pyplot as plt
from Homework2_Advanced_Thomas import Advanced_Thomas
from math import *
from prettytable import PrettyTable
# 采用周期性边界条件的三次样条函数:输入三个参数,t_list, x_list 为一一对应的支撑点列表,t 为自变量的值
def CubicSpline_T(t_list, x_list, t):
N = len(t_list) - 1 # 区间数
h = t_list[1] - t_l... |
30a6ecbfb0713ea0ddd63101e1e90d46a84f4881 | Harry-Phy-Quant/Computational-Physics | /Homework2_PowerIteration.py | 894 | 3.78125 | 4 | """
幂次法求矩阵最大模的本征值和本征矢
"""
import numpy as np
from math import *
# 输入参数为符合幂次法要求的矩阵 A,初始化向量 q,最大迭代次数 maxN
def powerIteration(A, q, maxN):
for i in range(maxN):
z = np.dot(A, q)
q = z / sqrt(np.dot(z, z))
v = np.dot(q, np.dot(A, q))
return v, q
if __name__ == '__main__':
# 构造矩阵 A
n ... |
036725ed9d6a1443a8db09cba43273dbbe2784cc | isayapin/cracking-the-coding-interview | /python_solutions/chapter_10_sorting_and_searching/merge_sort.py | 1,849 | 3.9375 | 4 | import copy
def merge_helper(array, helper_array, start, middle, end):
assert(len(array) == len(helper_array))
left_idx = start
right_idx = middle + 1
helper_idx = start
# perform merge operation from left and right halves of input array into helper array
# this operation stops when either the... |
4539d87baf6b63b463ace6d9a35d0d3ce6d59e11 | movie-dna-team/box-office-prediction-model | /scripts/budget.py | 1,349 | 3.578125 | 4 | """
@author: sergio
"""
import requests
from bs4 import BeautifulSoup
#this function scrapes imdb for budget
def imdb_scraper(movie_id):
response = requests.get("https://www.imdb.com/title/{}/?ref_=fn_al_tt_1".format(movie_id))
soup = BeautifulSoup(response.text, 'html.parser')
movie_details = so... |
a92b032f0ad82303a3f49400576bcd967345b5eb | jdro10/ESTG-ML-Spam-Detection | /data_preparation/drop_low_entries.py | 656 | 3.578125 | 4 | import pandas as pd
df = pd.read_csv("../datasets/balanced_dataset_smote.csv")
for column in df.columns:
word = str(column)
if word.__contains__("sex"):
df['sex'] = df.loc[:, ['sex', word]].sum(axis=1)
if len(word) < 3:
df.drop(column, axis=1, inplace=True)
if word == "www": # coluna ... |
fe6618c401976c9311a9e0a9ccffaf3c994bedac | chinmaya312/Data-Structures-and-Algorithms-The-Complete-Masterclass | /4. Algorithms - Sorting/2 - SelectionSort.py | 294 | 3.890625 | 4 | def selectionSort(arr):
for i in range(len(arr)):
min_x = i
for item in range(i+1, len(arr)):
if arr[item] < arr[min_x]:
min_x = item
arr[i], arr[min_x] = arr[min_x], arr[i]
arr = [20, 12, 10, 15, 2]
selectionSort(arr)
print(arr) |
57716d52f2bf2bb816addbd6b71c1e60c4133e3d | stephhuynh18/DIIDChallenge | /DIID.py | 13,223 | 3.65625 | 4 | # -*- coding: utf-8 -*-
"""
Assumptions:
-Can we assume the plateau is rectagular?
I am asssuming it is.
If was not not, instead of storing bounds I would store a dictionary(hash map) containing a bool
indicating whether a grid position was traversable
-Can be assume all the terrain is ... |
4a1450beeb666d245ec721128a653543c1052f8d | mafrasiabi/bayesian_learning | /prml/utilities/random_variable.py | 5,817 | 3.53125 | 4 | __author__ = 'colinc'
class Point:
def __init__(self, point, is_open=True, endpoint="left"):
self.value = point
self.is_open = is_open
self.endpoint = endpoint
@property
def test_val(self):
if self.endpoint == "left":
return self.value + int(self.is_open)
... |
9ac01fd9fbb3e20418cc7dd70547036a027e4739 | pranithsrujanroy/cpl-dwm | /lab7/a6q1_optimal_condensed_set_length.py | 4,790 | 4 | 4 | # -*- coding: utf-8 -*-
"""
Created on Tue Sep 18 13:37:18 2018
@author: Student
Assignment 6
1. Implement Condensed Nearest Neighbour.
Input : IRIS and Car Evaluation Dataset
Output : Classification Accuracy
ref :
1> Professor website : https://sites.google.com/site/patrabidyutkr/teaching/data-wareho... |
c98c71fc4004811f052f309a22077b557e24aa85 | pranithsrujanroy/cpl-dwm | /test/knn_10p_missing.py | 2,648 | 4.21875 | 4 | # -*- coding: utf-8 -*-
"""
Created on Tue Sep 11 13:29:39 2018
@author: Student
Assignment 5
1. Find a suitable value of k for a given dataset " CAR EVALUATION DATASET". Use the obtained K-value for developing KNN Classifier.
Report the classification accuracy.
"""
import csv #for importing csv data file
... |
25585571372ae8e5795045131e26d10794420611 | rdkr/advent-of-code | /2022/09-cp.py | 1,868 | 3.78125 | 4 | class Knot:
def __init__(self):
self.x = self.y = 0
def main():
with open("inputs/09.txt", "r") as _input:
moves = [move.split(" ") for move in _input.read().splitlines()]
head_x = head_y = tail_x = tail_y = 0
history = {(tail_x, tail_y)}
for direction, steps in moves:
p... |
20bf4c56f15188e803d0e760066a6787e03b13de | Nacho97arg/ApuestasRuleta | /ApuestasRuleta/ApuestasRuleta/Fibonacci.py | 1,187 | 3.609375 | 4 | import numpy as np
class Fibonacci:
def __init__(self):
self.capital = 1000
self.apuesta = 1
self.ganadas = 0
self.perdidas = 0
self.posicionFib = 1
self.frecRelativa = [0]
self.capitalAcumulado = [self.capital]
def fib(self, n):
a, b = 0, 1
if(n == 0):
return a
else:
for x in range(n):
... |
79f4e7c93e855770e74ab63483a7d5ddd06a7f70 | AceSrc/datagon | /build/lib.linux-x86_64-2.7/datagon/generator/parser.py | 3,152 | 3.75 | 4 | class Number:
def __init__(self, value=0, offset=0):
self.value = value
class String:
def __init__(self, name):
self.name = name
class Function:
def __init__(self, type, params):
self.type = type
self.params = params
class Interval:
def __init__(self, left=Number(), ri... |
686f48ecc0af9f3a9b7440c58de1c8ead3df5be4 | NguyenHiep/python_coban | /baitap/bai5/tinh_A.py | 158 | 3.5625 | 4 | n = int(input("Nhập n: "))
x = eval(input("Nhập x: "))
#A = (x^2 + x +1)^n + (x^2 - x + 1)^n
A = (x*x + x + 1)**n + (x**x - x + 1)**n
print("A = %i"%A)
|
b92f98c29f628a22b44547970bc797ae4d52a650 | NguyenHiep/python_coban | /baitap/bai2/tinh_p_s_hinh_tron.py | 138 | 3.53125 | 4 | r = eval(input("Nhập bán kính: \n"))
PI = 3.14
p = 2*PI*r
s = PI*r*r
print("Chu vi là: %.2f"%p)
print("Diện tích là: %.2f"%s) |
ef315d31d4df959b56b27134a2c632904a28d07e | NguyenHiep/python_coban | /baitap/bai5/count_down.py | 117 | 3.515625 | 4 | n = eval(input("Nhạp vào số nguyên n: \n"))
i = 1
while n >= i:
print("%i"%n)
n -= 1
print("Start!!!") |
9822beb772f53ea5d14d5f06732e716c38b5887f | NguyenHiep/python_coban | /buoi4/bai7/vd1.py | 575 | 3.65625 | 4 | list_1 = ["a", "b", "c", "d"]
list_2 = []
temp = 1;
while temp != -1:
temp = eval(input("Nhap so phan tu cho list2:"))
if temp != -1:
list_2.append(temp)
print("List 1 co : ", len(list_1), "phan tu")
print("List 2 co : ", len(list_2), "phan tu")
print("=========================== LIST 1 ====... |
60d979ca050732b4339d51ea0757a5ce2947bd21 | NguyenHiep/python_coban | /buoi3/sua_baitap_bai5/tinh_A.py | 297 | 3.59375 | 4 | """
Nhap va so nguyen n va mot so thuc x. Tinh va in ra ket qua bieu thuc sau:
A = (x^2 + x + 1)^n + (x^2 - x +1)^n
"""
n = int(input("Nhap n: "))
x = eval(input("Nhap x: "))
S = 1
S2 = 1
for i in range(1, n+1):
S *= (x*x + x + 1)
S2 *= (x*x - x + 1)
Tong = S + S2
print(Tong) |
494c4e70b802633d719784a31919a9605bcca24a | dpBhalala26/007_DevangBhalala | /Lab2/Practice/Lab2_1_DataTransformation.py | 975 | 3.546875 | 4 | #from google.colab import drive
#drive.mount("/content/drive")
# Step 1: Import Libraries
import numpy as np
import pandas as pd
from sklearn.preprocessing import MinMaxScaler, StandardScaler
# Step 2: Load Data
datasets = pd.read_csv('Data_for_Transformation.csv')
print("\nData :\n",datasets)
#print("\nDa... |
de79d5b8d72c1a75e7d1033e2557037153853a39 | dpBhalala26/007_DevangBhalala | /Lab3/Practice/Lab3_1_NB_Classifier_Wheather.py | 1,263 | 3.578125 | 4 | from sklearn import preprocessing
from sklearn.naive_bayes import GaussianNB, MultinomialNB
weather = ['Sunny', 'Sunny', 'Overcast', 'Rainy', 'Rainy','Rainy', 'Overcast', 'Sunny', 'Sunny', 'Rainy', 'Sunny', 'Overcast', 'Overcast', 'Rainy']
temp = ['Hot','Hot','Hot','Mild','Cool','Cool','Cool','Mild', 'Cool','Mild','Mi... |
97280b8ed6dd1235dc129e0ed27f18334141017d | peefer66/100doc | /day 22_30/Day 22/scoreboard.py | 490 | 3.65625 | 4 | from turtle import Turtle
class Scoreboard(Turtle):
def __init__(self,position):
super().__init__()
self.score = 0
self.penup()
self.color('white')
self.hideturtle()
self.position = position
self.update_score()
def update_score(self):
self.s... |
4efe0803924322c8fce38b16d4ece218a8aa8ad3 | peefer66/100doc | /day 22_30/Day 30 Error handling & JSON/Start/main.py | 625 | 4.21875 | 4 | # Error catching
try:
file = open('my_text_file.txt')
a_dict = {'key':'value'}
print(a_dict['key'])
except FileNotFoundError:
file = open('my_text_file.txt','w')
file.write('Somthing')
except KeyError as error_message:
print(f'The key {error_message} does not exist')
else:
content = file.re... |
bd19b810815dd72e7d36b03c4d673cfe3a4340a4 | peefer66/100doc | /day 15_21 - Intermediate/15 coffee maker/coffee_maker.py | 3,449 | 4.15625 | 4 | import os
def quantity_ingredients(menu_dict, coffee_selection, amount_ingredients):
'''Check to determine if there is enough mterial
for the selected coffee. if there is an updated ingredient
stock is returned. if not then a message telling the user
that it cannot make selected coffee
'... |
89baf8a4c62e550446bdd3860d7529c31b63e548 | peefer66/100doc | /day 15_21 - Intermediate/17 Quiz Project/Intro_lesson/main_temp.py | 705 | 3.984375 | 4 | class User():
https://www.udemy.com/course/100-days-of-code/learn/lecture/19964886
def __init__(self,user_id,username):
self.id = user_id
self.username = username
self.followers = 0
self.following = 0
def follow(self,user):
''' Increases the follower count ... |
e04a0d343d732d5566cb5a092fd9d3b0768d6484 | guptaharsh25/ITI1120 | /Assignments/Assignment - 4/a4_300042828.py | 10,848 | 3.875 | 4 | # Name: Harsh Gupta
# Student #: 300042828
# ITI 1120 C - Assignment 4
import random
def binary_search(L, v) -> int:
""" (list, object) -> int
Return the index of the first occurrence of value in L, or return
-1 if value is not in L.
"""
# Mark the beginning and the end indices of the un... |
620827653dbdba5bdd623055883df883f0b76d7e | wanghaisheng/HackerNews_history | /retrieving_posts.py | 3,178 | 3.53125 | 4 | """
Module for retrieving the top 30 posts on HN for any given day.
Structure
- get all available timestamps - one randomly chosen tiemstamp for each day that HN has been crawled by the WayBackMachine
- retrieve the timestamp of the particular day for which you want to get the top HN posts
- get that day's html f... |
d76fa762357fe580626e280c4619c88319b31598 | returnEdo/Simplex | /Simplex.py | 4,136 | 3.703125 | 4 | #!/usr/bin/env python3
import numpy as np
from numpy.linalg import solve, inv
from typing import Tuple, List
class Simplex:
''' Basic implementation of the 1 phase simplex method for
linear programming problem '''
def __init__(self, A: List[List[float]], b: List[float], c: List[float]):... |
0e58e2d7390beb447817ff85d0ac87bb0d942a46 | surge55/hello-world | /02-MIT6x/2 Core Elements/for.py | 1,165 | 4.375 | 4 | ################################################################################
## Course: MITx 6.001x - Intro to CS and Programming Using Python
## Student: surge55
## Date: June 16, 2022
## Exercise: for
## In this problem you'll be given a chance to practice writing some for loops.
#################################... |
474eb5c8d0a1f325db6aa3b72058614cf0eff9e5 | surge55/hello-world | /02-MIT6x/4 Functions/4power.py | 772 | 3.84375 | 4 | ################################################################################
## Course: MITx 6.001x - Intro to CS and Programming Using Python
## Student: surge
## Date: June 17, 2022
## Exercise: fourth power
## Write a Python function, `fourthPower`, that takes in one number and returns
## that value raised to th... |
843e5127a2a41b3856d0b4261d83a994ac5d1688 | surge55/hello-world | /01-PY4E/12-network/12.4_exercise.py | 1,167 | 3.75 | 4 | ###############################################################
## File Name: 12.4_exercise.py
## File Type: Python File
## Author: surge55
## Course: Python 4 Everybody
## Chapter: Chapter 12 - Network Programming
## Excercise: 4
## Description: Change the urllinks.py program to extract and count
## paragraph... |
be422176cf425a3cd2d7206f42891b40fb1e35c6 | surge55/hello-world | /01-PY4E/01-why_program/wordfind.py | 979 | 4.28125 | 4 | ###############################################################
## File Name: wordfind.py
## File Type: Python File
## Author: surge55
## Course: Python 4 Everybody
## Chapter: Chapter 1 - Why Would you Learn Programming
## Excercise: n/a
## Description: Code walkthrough from book
## Other References: http://... |
b0f3c190895525bb6d11521bf393346a06ab302f | surge55/hello-world | /01-PY4E/12-network/12.2_exercise.py | 1,237 | 4.09375 | 4 | ###############################################################
## File Name: 12.2_exercise.py
## File Type: Python File
## Author: surge55
## Course: Python 4 Everybody
## Chapter: Chapter 12 - Network Programming
## Excercise: 2
## Description: Change your socket program so that it counts the number
## of ch... |
7b9d903a5504b547d513f0631a8f278af147c13d | surge55/hello-world | /01-PY4E/13-web_services/13_exercise1.py | 1,895 | 3.8125 | 4 | ###############################################################
## File Name: 13_exercise1.py
## File Type: Python File
## Author: surge55
## Course: Python 4 Everybody
## Chapter: Chapter 13 - Web Services
## Excercise: 1
## Description: Change geojson.py to print out the two charater country code from the ret... |
f9f5487b8fc8cf35ff4cefdf03fccebe09b12c64 | kuldeepthesavior/Learning-ML-Begining | /tcs_fresco_oops_python_2_assessment.py | 202 | 4.0625 | 4 | # infinite fibonaci generator
def fibonacci():
a, b = 0, 1
while True:
yield a
a, b = b,a+b
fs=fibonacci()
print(next(fs))
print(next(fs))
print(next(fs))
print(next(fs))
|
ac99258e20e9f7fc80c1e9c247dd899abe0c3c2e | ycao-cit/leetcode | /problem_002.py | 1,181 | 3.90625 | 4 | #! /usr/bin/env python
# -*- coding: utf-8 -*-
# vim:fenc=utf-8
#
# Copyright © 2016 Yi Cao <ycao@astro.caltech.edu>
#
# Distributed under terms of the GNU General Public License 3.0 license.
"""
Add Two Numbers
URL: https://leetcode.com/problems/add-two-numbers/
"""
class ListNode(object):
def __init__(self, x)... |
5aec50df0f21122745dcc98ceab29cd4840e1e9e | indelman/ANPL-Website | /python/sort_html_entries_engine.py | 2,154 | 3.90625 | 4 | #!/usr/bin/env python
from datetime import date
import os
import sys
def search_backwards(Lines, searchquery, i):
"""Search for a string backwards in Lines starting from line i"""
result = []
while i>0:
if searchquery in Lines[i]:
result = i
break
i = i - 1
... |
8501f3c6631bec60718464af716b20af40c80644 | helenamulcahy/Helena_Python | /sing_verse_with_loop.py | 324 | 3.796875 | 4 | def sing_verse(x):
print(x, "green bottles hanging on the wall,")
print(x, "green bottles hanging on the wall,")
print("And if one green bottle should accidentally fall,")
print("There'll be", x-1, "green bottles hanging on the wall.")
def main():
for i in range(10,1,-1):
sing_verse(i)
mai... |
6cb51f3b92964dee96cd3a1c7a7ded920832ec92 | helenamulcahy/Helena_Python | /patient_readings.py | 1,040 | 3.765625 | 4 | def heading():
print('-' * 13)
print('BPM Processor')
print('-' * 13)
def read_positive_integer(prompt):
while True:
try:
number = int(input(prompt))
if number > 0:
break
else:
print('Non-negative numbers, please...')... |
c7c8c6cd8ea854ea6160947499c266b117cd0c77 | helenamulcahy/Helena_Python | /week 5/09_megans_barissta.py | 732 | 3.90625 | 4 | HOURLY_PAY_RATE = 22.00
def get_hours_worked(number_of_employees):
## TODO ask the user to enter hours for
## number_of_employees
hours_worked = []
return hours_worked
def show_hours_per_employee(hours_worked):
print("show hours")
def get_total_pay(hours_worked, hourly_pay_rate):
return... |
401b2126760e4e2597f9534057d867fd08a6a4f0 | Moochawchoo/ProjectEuler | /Euler12/Euler_12.py | 347 | 3.59375 | 4 | import math
triangle = [1]
while True:
temp = 0
for a in range(1, len(triangle) + 1):
temp += a
triangle.append(temp)
divisorsCount = 1
for a in range(2, int(math.sqrt(triangle[-1])) + 1):
if triangle[-1] % a == 0:
divisorsCount += 1
if divisorsCount > 500:
... |
ef39a27ed5643fcec06397894d54eb3965e38863 | clairejrlin/stanCode_projects | /stanCode_Projects/boggle_game_solver/anagram.py | 2,828 | 4.1875 | 4 | """
File: anagram.py
Name: Claire Lin
----------------------------------
This program recursively finds all the anagram(s)
for the word input by user and terminates when the
input string matches the EXIT constant defined
at line 19
If you correctly implement this program, you should see the
number of anagrams for each... |
272c609a8594e2a8da77eadd819e2a04c432b505 | lfelliott/lfelliott-arcpyArchives | /species_name_list.py | 627 | 3.796875 | 4 | def uniq(input):
output = []
for x in input:
if x not in output:
output.append(x)
return output
try:
infile = open("texas_sp_names.txt", "r")
except IOError:
print "The file does not exist"
outfile = open("namelist.txt", "w")
snames = []
snames2 = []
while 1:
line = infile.readline()
if not line: b... |
f1b3f979d81459de6397b7f93697a72a37b055be | lfelliott/lfelliott-arcpyArchives | /dictwriter.py | 165 | 3.53125 | 4 | import csv
mydict = {1: "test1", 3: "test3", 4: "test4"}
writer = csv.writer(open('dict.csv', 'wb'))
for key, value in mydict.items():
writer.writerow([key, value]) |
da33603e922c355d62467ed26ab668796e11574e | neoneoneo1/test1 | /py_proj/ex_functions5.py | 3,497 | 4.125 | 4 | # -*- coding: utf-8 -*-
__author__ = 'admin'
#Функции
#Прототип
def f1(par1,par2=10):
print par1
par1=par1-1
return par1
p=101
f1(p)
print p
t=f1(p)
print t
#Переименование функций
fun2=f1
f1(1)
fun2(1)
#Переменная r создается 1 раз и является статической Список можно вывести print-ом
print "Переменная r... |
0862238765dcbfc1de89586e5e99b8c74db37061 | JagadeeshLTTS/Python_assignment_Genesis2021_99004951 | /Ass_Qn-14.py | 482 | 4.28125 | 4 | def splitToDigits(number):
d=[int(i) for i in number]
return d
def findLargestNumber(digits_list):
digits_list.sort(reverse=True)
num=digits_list[0]
for i in range(1,len(digits_list)):
num=num*10+digits_list[i]
return num
if __name__ == '__main__':
number=input("Enter number: ")
... |
78dd1d37cdc8033f5f4f1280cd003b5a2fef579a | JagadeeshLTTS/Python_assignment_Genesis2021_99004951 | /Ass_Qn-9.py | 1,258 | 4.15625 | 4 | def actualDate(date, month, year):
while(month>12 or date>31 or (month==2 and date>29 and year%400==0) or (month==2 and date>28 and year%400!=0)):
year=year+(month//12)
month=month%12
if(month==1 or month==3 or month==5 or month==7 or month==8 or month==10 or month==12):
if(date>... |
d6e8fafafb64e25817a770b0eed58a507864a71d | ksopyla/numpy-tutorial | /4.Array_broadcasting.py | 3,010 | 4 | 4 | # author: Krzysztof Sopyła (krzysztofsopyla@gmail.com)
# Twitter: ksopyla
# Blog: http://ksopyla.com
# If you want to use this material in your own trainning please let me know.
import numpy as np
# We will add the vector v to each row of the matrix x,
# storing the result in the matrix y
x = np.array([[1,2,3], [4,5,... |
d1bdafcfb99ca12f866c9f16301d56b07012f924 | davidbarat/python | /nombreadeviner.py | 387 | 3.59375 | 4 | from random import randint
nombre_a_deviner = randint(1, 100)
print(nombre_a_deviner)
premier_essai = input('Entrez votre premier essai: ')
resultat = nombre_a_deviner == premier_essai
print('Le resultat est ' + str(resultat))
premier_res = premier_essai > nombre_a_deviner
deuxieme_res = premier_es... |
1c7f9098f81f51fb67e3c481f8dbbe927777c59c | davidbarat/python | /nombreadeviner2.py | 666 | 3.6875 | 4 | from random import randint
nombre_de_coup = 5
nombre_a_deviner = randint(1, 100)
while nombre_de_coup != 0:
essai = input('Entrez votre nombre: ')
if essai == nombre_a_deviner:
print('Vous avez gagne en {0}'.format(nombre_de_coup))
break
elif essai < nombre_a_deviner:
print('le nombre a de... |
833294847016526b9c9e2b5cd385f216c390abe7 | davidbarat/python | /projetcine.py | 451 | 3.90625 | 4 | liste_film = []
continuer = 'o'
while continuer == 'o':
nom_film = raw_input('Entrez votre nom de film: ')
if nom_film.lower() in [film[0].lower() for film in liste_film]:
print('le film {0} existe deja'.format(nom_film))
else:
note = raw_input('Entrez une note sur 5 pour ce film: ')
liste_film.app... |
0fc05ef2d30e7e8fe2289c34c837edd5498303de | sagynangare/advanced_practice | /T_threads.py | 264 | 3.609375 | 4 | import threading
import time
def myfunc():
print("Start a thread!\n")
time.sleep(3)
print("End a thread!!\n")
threads=[]
for i in range(5):
th = threading.Thread(target=myfunc)
th.start()
threads.append(th)
for th in threads:
th.join()
|
5a0df33c1898a7c95d25754ed5dc3387854c7eac | murtekbey/python-temel | /4-donguler/for-demo.py | 2,801 | 3.9375 | 4 | sayilar = [1,3,5,7,9,12,19,21]
###################################################################################################################################
# 1. Sayılar listesindeki hangi sayılar 3'ün katıdır ?
for sayi in sayilar: # liste içerisindeki elemanları tek tek dolaşır.
if sayi%3==0:
print(... |
0e820f274f4d04e4853bbe0862332efaea3482eb | murtekbey/python-temel | /1-objeler-ve-veri-yapilari/dictionary-demo.py | 506 | 3.703125 | 4 | ogrenciler = {}
number = input("öğrenci no: ")
name = input("öğrenci adı: ")
surname = input("öğrenci soyad: ")
phone = input("öğrenci telefon: ")
ogrenciler.update({
number: {
'ad': name,
'soyad' : surname,
'telefon' : phone
}
})
print('*'*50)
ogrNo = input('kayıtlı öğrenci no girin... |
e2e621a2ab8ac4f35abe8535e4f70d51bddf4c99 | murtekbey/python-temel | /1-objeler-ve-veri-yapilari/reference.py | 605 | 4.28125 | 4 | # value types => string, integer, float (Numbers)
x = 5
y = 25
x = y
y = 10
print(x,y) # x değeri hala 25 olarak kalır.
# reference types => list
a = ["apple", "banana", "lemon"] # a'ya elemanları ekledik.
b = ["apple", "peach", "cherry"] # b'ye elemanları ekledik
a = b # a'daki listeyi b'deki liste ile eşitleyere... |
8b5633cf6cc58576d965707c970f27ae650ca687 | murtekbey/python-temel | /6-nesne-tabanli-programlama/specials.py | 1,414 | 4 | 4 | myList = [1,2,3]
# myString = 'my string'
# print(len(myList)) # len metodu her bir obje için farklı çalışır.
# print(len(myString))
# print(type(myList))
# print(type(myString))
class Movie():
def __init__(self, title, director, duration):
self.title = title
self.director = director
self.... |
4f4b39825d81acf5bb08fd92bb91f04d247ba609 | murtekbey/python-temel | /12-generators/generators.py | 1,288 | 3.734375 | 4 | # Generators bizim için bellek de yer işgal etmeyen bir iterator üretiyor.
# def cube():
# for i in range(5): # 50000 tane eleman bile oluştursan bizim için bellekde bir yer tahsil edilmicek ve bellekden tasarruf etmiş olucaz.
# yield i ** 3 # yield bir değer üretir bunu bize gönderir ve daha sonra bu ... |
16293f03d6055f8d2a81d475cf3fac70a318d96f | murtekbey/python-temel | /1-objeler-ve-veri-yapilari/strings-demo.py | 1,314 | 3.90625 | 4 | website = "http://www.murtekbey.com"
course = "Python Programlama"
# 1- 'course' karakter dizisinde kaç karakter bulunmaktadır?
result = len(course)
# 2- 'website' içinden www karakterlerini alın.
result = website[7:10]
# 3- 'website' içinden com karakterlerini alın.
result = website[-3:]
# 4- 'course' içinden ilk ... |
205387276b695b5027e15a7ba23c6d8c4732eef9 | hyunba/personal_Coding | /PythonExample/class_복습6.py | 803 | 3.71875 | 4 | class Travle:
def __init__(self, name, region, age):
self.name = name
self.region = region
self.age = age
print("{0} 회원님이 등록되었습니다.".format(name))
def move(self, location):
print("{0} 회원님이 {1}로 이동하고 계십니다."\
.format(self.name, location))
def home(self, ret):
print("{0} ... |
c0da4ba4404efae0c9ed088a07ae18873528807a | JLDPonce/Prelim_Exam_Ponce | /temp.py | 718 | 3.6875 | 4 | from typing import ValuesView
class Temperature:
def __init__(self,kelvin=None,celcius=None,fahrenheit=None):
values=[x for x in [kelvin,celcius,fahrenheit]if x]
if len(values)<1:
raise ValueError('Need argument')
if len(values)>1:
raise ValueError('Only one... |
6141a054fb99686f5afa5e26aa9a95cc96898be0 | alyxbb/Neaproject | /game.py | 19,816 | 3.828125 | 4 | import random
import sqlite3
import hashlib
from getpass import getpass
conn = sqlite3.connect('data.db')
c = conn.cursor()
def createtables():
c.execute("CREATE TABLE if not exists songs(name TEXT NOT NULL PRIMARY KEY, artist TEXT)")
#create a table of songs containing the names and artists of the songs
... |
c102db42ad57fab56d759deb730ec96dcaf920ba | ma96o/atcoder_archive | /src/abc171/A.py | 127 | 3.953125 | 4 | a = input()
alpha = 'abcdefghifjlmnopqrstuvwxyz'
print("a" if a in alpha else "A")
# print("A" if input().isupper() else "a")
|
5e29588ad37120b51a4674926d15336de0c6bdc9 | ma96o/atcoder_archive | /src/abc059/B.py | 150 | 3.890625 | 4 | a = int(input())
b = int(input())
print([["EQUAL", "LESS"], ["GREATER"]][a > b][a < b])
# print("GREATER" if a > b else "LESS" if a < b else "EQUAL")
|
8d09aef2e7b0625bb956369d215fe7a2230e9047 | Paul3111/SItemePL | /spanzuratoarea_clase.py | 2,918 | 4.09375 | 4 | import random
import tictactoe_functions_classes
secret_word = ["london", "secret", "alaska", "teamwork", "happiness", "homework", "guess", "banana"]
selected_word = list(random.choice(secret_word))
players_tried_letters = []
start_word = []
dict_parts = {1: "@", 2: "/", 3: "\\", 4: "|"}
class Run:
def show_par... |
6735ae0efbe4e997bc307577d124e3be3368d02f | DmitriiTitkov/python_practice_learning | /ex7/ex7.py | 96 | 3.625 | 4 | def return_even_numbers(list_of_numbers):
return [x for x in list_of_numbers if x % 2 != 0]
|
e5737aa69e81287528899376a67fc6e096c9a08f | DmitriiTitkov/python_practice_learning | /ex2/main.py | 673 | 4.28125 | 4 | def divide_numbers(num1, num2):
"""This function checks if one number can be divided to other without remnant"""
if isinstance(num1, int) and isinstance(num2, int):
result = num1 % num2
if result == 0:
if num2 != 4:
print("Number {} can be divided to number {} without... |
7082e456717aef7f7b084889d6287ead6d8fdcbf | Shiyang-Shirley-Li/LeetCodePractice | /125. Valid Palindrome/isPalindrome.py | 542 | 3.515625 | 4 | """
Tag: String
Difficulty: Easy
"""
class Solution:
def isPalindrome(self, s: str) -> bool:
regex = re.compile('[^A-Za-z0-9]')
s = regex.sub('', s)
s = s.lower()
sHalfLen = len(s) // 2
index = len(s) - 1
for i in range(0, sHalfLen):
print(s[i])
... |
a1439d4860738845de5737ffc3c34e6476d222ac | dillonhuff/NoneCheck | /cases/Test3.py | 154 | 3.53125 | 4 | def func(arg):
arg.call()
if (arg is None):
return 0
elif not arg == 2:
return 4
else:
x = a + 1
return 2
|
d551d390f400df801de772f37172082c0d1dd6ec | Mithrandir14/Script | /main.py | 936 | 3.828125 | 4 | #opening sequence
print("BootUpSeq")
print("Initialize")
print("Dvorak 14.1.8")
print("Ready")
print(input("your name?"))
player_name = input("your name?")
print("Your name is {}. You are an {}.".format(player_name, "insignificant human"))
print("I am Lambda, tasked to remove you from this place. To do this, I need yo... |
5a898fe02eb8faea94b4b2e515421b5b46e539cd | vijisEEE/python1 | /vowconso.py | 170 | 4.1875 | 4 | a=str(input("Enter the charcter:"))
if(a=='a' or a=='e' or a=='i' or a=='o' or a=='u'):
print("Given character is vowel")
else:
print("Given character is consonant")
|
0fe33e77fc9374e366f236cc72029e601de62761 | codefordemo/dsa_450_practice | /dsa450series/demoPractice/array/10_findMissing.py | 644 | 3.953125 | 4 | # take array 1 size and element
# take array 2 size and element
arraySize1 = int(input("Enter size of 1st array "))
arraySize2 = int(input("Enter size of 1st array "))
arraylist1 = []
arraylist2 = []
sum1 = 0
sum2 = 0
for i in range(arraySize1):
elem = int(input("enter array 1 element "))
arraylist1.append(ele... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.