blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string |
|---|---|---|---|---|---|---|
31c6171ecaa7c8d8b56f44307017e2ae1865af7a | Elijah3502/CSE110 | /Programming Building Blocks/Week 2/04Prepare.py | 194 | 4.125 | 4 | #Convert program
get_temp = float(input("What is the temperature in Farenheit? : "))
convert_temp = ((get_temp - 32) * 5) / 9
print(f"The Temperature in celsius is {convert_temp:.2f} degrees.") |
7837ddfe5077efe1efb46a5fe416abea59f390bd | Elijah3502/CSE110 | /Programming Building Blocks/Week 1/prove01.py | 986 | 3.71875 | 4 | #prove assignment 01 Favorite color
#started 01/06/21
#gets favorite color from user
print("\n\n")
print("**************************************************")
print("**************************************************")
getName = input("What is your name?: ")
print("**************************************************")
... |
d29902782026c093cdb779a574549268470108f9 | raylawjr/web-caesar | /caesar.py | 650 | 3.859375 | 4 | def alphabet_position(letter):
alphabet = "abcdefghijklmnopqrstuvwxyz"
char = letter.lower()
for i in range(len(alphabet)):
if char == alphabet[i]:
return i
def rotate_character(char, rot):
alphabet = 'abcdefghijklmnopqrstuvwxyz'
alphabet2 = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
for ... |
c2d8b9bce165534ff9761ada355a75f470dd9ef5 | amberj87/CH603 | /programs/class3/diagonal.py | 180 | 4.40625 | 4 | #This is a program to diagonalize a matrix
import numpy as np
#Take a 3*3
A=np.array([[12,7,3],
[4,5,6],
[7,8,9]])
print('The eigen value')
print('print the eigen vectors')
|
f5b29f6c69ed33ede9e80d3dfabc5d82932e8997 | JiaMauJian/model-playground | /pca/1_pca_linear.py | 1,910 | 3.828125 | 4 | # http://stats.stackexchange.com/questions/2691/making-sense-of-principal-component-analysis-eigenvectors-eigenvalues
# 了解PCA是什麼東西
import pandas as pd
from sklearn.decomposition import PCA
from sklearn.preprocessing import StandardScaler
import matplotlib.pyplot as plt
import numpy as np
x1 = pd.Series(np.linspace(0,... |
7e4020ee909d282d754bb4d63699bba97510a8cb | kji0205/py | /cookbook/factorial.py | 209 | 4 | 4 | def recursive(x):
if x == 0:
return True
else:
return x * recursive(x - 1)
print(recursive(10))
def func(x):
for x in [x:0]:
y = x * (x - 1)
return print(y)
func(3)
|
5afc6641d574b27face060ac8770388883941770 | kji0205/py | /CHAPTER03/bw23.py | 1,630 | 3.75 | 4 | # 인터페이스가 간단하면 클래스 대신 함수를 받자
import logging
from pprint import pprint
from sys import stdout as STDOUT
names = ['Socrates', 'Archimedes', 'Plato', 'Aristotle']
names.sort(key=lambda x: len(x))
print(names)
# Example
from collections import defaultdict
def log_missing():
print('Key added')
return 0
current = {'gree... |
6152e812b3277e745d158dafb8d68d6aeae1b109 | kji0205/py | /CHAPTER04/bw31.py | 3,131 | 3.984375 | 4 | # 재사용 가능한 @property 메서드에는 디스크립터를 사용하자
import logging
from pprint import pprint
from sys import stdout as STDOUT
class Homework(object):
def __init__(self):
self._grade = 0
@property
def grade(self):
return self._grade
@grade.setter
def grade(self, value):
if not (0 <= value <= 100):
raise Val... |
2cbabcc6fa5ab1b191967afb3b47d89b0d7bd5b3 | kji0205/py | /CHAPTER02/bw14.py | 655 | 3.78125 | 4 | # def divide(a, b):
# try:
# return a / b
# except ZeroDivisionError:
# return None
# def divide(a, b):
# try:
# return True, a / b
# except ZeroDivisionError:
# return False, None
def divide(a, b):
try:
return a / b
except ZeroDivisionError as e:
... |
02de1d7993d07dda79e321c327405ea5d03368ee | kji0205/py | /cookbook/CHAPTER03/c3_9.py | 704 | 4.125 | 4 | '''큰 배열 계산'''
x = [1, 2, 3, 4]
y = [5, 6, 7, 8]
print(x * 2)
# print(x + 10)
print(x + y)
# Numpy
import numpy
ax = numpy.array([1, 2, 3, 4])
ay = numpy.array([5, 6, 7, 8])
print(ax * 2)
print(ax + 10)
print(ax + ay)
print(ax * ay)
def f(x):
return 3 * x ** 2 - 2 * x + 7
print(f(ax))
print(numpy.sqrt(ax))
prin... |
80aee2457259f7cf5cf18a483ed564ce2485433a | kji0205/py | /cookbook/CHAPTER02/2.1.py | 340 | 3.5 | 4 | """여러 구분자로 문자열 나누기"""
import re
line = 'asdf fjdk; afed, fjek,asdf, foo'
s = re.split(r'[;,\s]\s*', line)
print(s)
#
fileds = re.split(r'(;|,|\s)\s*', line)
print(fileds)
#
values = fileds[::2]
delimiters = fileds[1::2] + ['']
print(values)
print(delimiters)
#
s = re.split(r'(?:,|;|\s*)', line)
print(s)
|
de86ece6fe9a5e14813581cbe931dc459b0534e8 | kji0205/py | /CHAPTER03/bw25.py | 2,103 | 3.9375 | 4 | # super로 부모 클래스를 초기화하자
import logging
from pprint import pprint
from sys import stdout as STDOUT
class MyBaseClass(object):
def __init__(self, value):
self.value = value
class MyChildClass(MyBaseClass):
def __init__(self):
MyBaseClass.__init__(self, 5)
# Example
class TimesTwo(object):
def __init__(self):
... |
67b8ac39a98c532cfc034d4ee0ef399db756fdec | evikramsai/Python | /PYTHON/ETKURI VIKRAM SAI_PYTHON/lab2/day22.py | 207 | 4 | 4 | def max_in_list(listname) :
max = listname[0]
for i in listname :
if i > max :
max = i
print("Greatest number is ",max)
listnamex = [8,2,7,4,9]
max_in_list(listnamex)
|
1036dcec30c06a6e5bd5d62a703d6652a7a7a290 | evikramsai/Python | /PYTHON/ETKURI VIKRAM SAI_PYTHON/lab2/day25.py | 193 | 3.8125 | 4 | listw = ["Hello","Hi","How","Are","You"]
def filter_long_words(listname, number) :
for x in listname :
if len(x) > number :
print(x)
filter_long_words(listw, 3)
|
9f9903042bab76a30ce15272df51e3417ff8fe96 | kakaggarwal/ProjectEuler | /codility tests/EquiLeader.py | 724 | 3.640625 | 4 | # you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
def getLeader(A):
vals = set(A)
totalCount = 0
numCount = 0
threshold = len(A) // 2
for num in vals:
numCount = A.count(num)
if numCount > threshold:
return num
else:
... |
c27ce5d86644baf1921c121b7c6b4e7844901a20 | kakaggarwal/ProjectEuler | /euler/euler020.py | 409 | 3.53125 | 4 | import sys
factorials = [1, 1]
def getSumofDigits(num):
sum = 0
for i in str(num):
sum += int(i)
return sum
def factorial(n):
if n >= len(factorials):
factorials.append(n * factorial(n - 1))
return factorials[n]
def euler(n):
return getSumofDigits(factorial(n))
t = in... |
dc7e5d35537e8d1826f2edac028d1fcacefbbcba | kakaggarwal/ProjectEuler | /codility tests/Nesting.py | 478 | 3.609375 | 4 | def solution(S):
if len(S) % 2 != 0:
return 0
brackets = []
for bracket in S:
if bracket == '(':
brackets.append(bracket)
else:
if len(brackets) > 0:
brackets.pop()
else:
return 0
if len(bracket... |
67acc09d560859e5bfb38411780984304289a7d9 | codenara/PyQt1 | /Log1/HiPyQt3/HiPyQt31QLabel.py | 825 | 3.53125 | 4 | # HiPyQt version 3.1
# use QLabel
# use QPushButton
import sys
from PyQt5.QtWidgets import *
class MyWindow(QMainWindow):
def __init__(self):
super().__init__()
self.setWindowTitle("Hi PyQt")
self.setGeometry(50, 50, 400, 300)
# QLabel
self.label = QLabel("QLabel", self)
... |
c37e2fc09f9ca1064ed851cf666dd28d32f2da5d | aneem/CompilerDesign | /regex_to_grammar.py | 4,223 | 3.515625 | 4 | from grammar import Grammar
class RegexToGrammar(object):
def __init__(self, re):
self.re = re
self.stack = []
self.dictionary = {}
# operator count
self.X_no = map(str, range(1, self.re.count('*')+self.re.count('+')+1))
self.Y_no = map(str, range(1, self.re.count(... |
edefb024d1be72de1723fa0fdc26d5815797594c | ULYSSIS-KUL/ulyssisctf-writeups | /2018/reverse/one-step-beyond/tramp.py | 1,201 | 4.0625 | 4 | #!/usr/bin/env python3
def trampoline(func, *args):
result = func(*args)
while callable(result):
result = result()
return result
def fibonacci(i: int, previous: int = 1, past_previous: int = 0) -> int:
if i != 0:
return lambda: fibonacci(trampoline(decrease, i), previous + past_previo... |
168ca89853c1e2d20a6f3af8fc70231c639f85cb | Programming-Metholodogy-II-Fa18/midterm-a-joshcapistrano | /Problem 1/Problem1.py | 731 | 3.703125 | 4 | # -*- coding: utf-8 -*-
"""
Created on Fri Nov 2 17:03:13 2018
@author: ac1695
"""
def merge(a,b):
c = []
indexA = 0
indexB = 0
while indexA < len(a) and indexB <len(b):
if a[indexA] < b[indexB]:
c.append(a[indexA])
indexA+=1
else:
c.appen... |
7cf53d539092f78eb887ba89ac0bc97546b70428 | im-deepfriedwater/jenlang | /test/data/code-generation/python-programs/ifelseifelse.py | 147 | 3.78125 | 4 | pizzasEatenToday = 11
if pizzasEatenToday < 2:
print('Still hungry')
elif pizzasEatenToday >= 8:
print('Too full')
else:
print('Just Right')
|
646ba436ffcf763874df473a6f10c6b906a85fe6 | chengxxi/dailyBOJ | /2021. 2./1157.py | 550 | 3.703125 | 4 | # 1157: 단어 공부
word = input().upper()
count = []
for i in set(word):
count.append(word.count(i)) # 개수
idx = [i for i, x in enumerate(count) if x == max(count)] # 최댓값 위치 반환
if len(idx) > 1:
print("?") # 최댓값이 여러 개
else:
print(list(set(word))[count.index(max(count))])
"""
알파벳 대소문자로 된 단어가 주어지면, 이 단어에서 가장 많이 ... |
16dd9d80e20c148f5f3886cb2c8a0b6ec7af93c4 | chengxxi/dailyBOJ | /2021. 3./20341.py | 1,111 | 3.6875 | 4 | # 20341: Moderate Pace
n = int(input())
nlist = [list(map(int, input().split())) for _ in range(3)] # k, a, b
ans = [0] * len(nlist[0])
for i in range(len(nlist[0])):
tmp = []
for j in range(3):
tmp.append(nlist[j][i])
tmp.sort()
ans[i] = tmp[1]
print(*ans)
"""
An ultra-marathon is a race ... |
6323e046074b1f590f87bc637f74dc3b6001d869 | chengxxi/dailyBOJ | /2021. 3./11650.py | 418 | 3.59375 | 4 | # 11650: 좌표 정렬하기
nli = []
for _ in range(int(input())):
x, y = map(int, input().split())
nli.append((x, y))
nli.sort(key=lambda n: (n[0], n[1]))
for li in nli:
print(*li)
"""
2차원 평면 위의 점 N개가 주어진다.
좌표를 x좌표가 증가하는 순으로, x좌표가 같으면 y좌표가 증가하는 순서로 정렬한 다음 출력하는 프로그램을 작성하시오.
""" |
edbb6a1c018cd3c24a07d7812e192f0cc28f9460 | chengxxi/dailyBOJ | /2021. 4./1991.py | 1,383 | 3.921875 | 4 | ########## BOJ ##########
# 1991: 트리 순회
# 전위 순회
def preorder(node):
if node != '.':
print('{}'.format(node), end='')
preorder(tree[node][0]) # left
preorder(tree[node][1]) # right
# 중위 순회
def inorder(node):
if node != '.':
inorder(tree[node][0])
print('{}'.format(nod... |
20e83881dc95686b26bc936e90e739daea50dc6c | Kushagar-Mahajan/Python-Codes | /hello_world.py | 766 | 3.859375 | 4 | #here we are going to learn about strings
"hello" #method to write string is adding it in double quotes
name = "Raj" #storing string in variable
print(type(name))
#message = "John said to me "I will see you later"" will give you error
message = 'John said to me "I will see you later"' #way to avoid string breaking
... |
c8ba53b5b695f206073f598eb66a09f25741dc3e | Faviobrntn/soporte | /practico03/ejercicio11.py | 309 | 4 | 4 | def Divide(x,y):
try:
print( x/y )
except ZeroDivisionError:
print("No se puede dividir por cero")
except TypeError:
print("No se pueden dividir cosas que no sean numeros")
except Exception as f:
print("No se pduo realizar la division"+str(f))
Divide(2,False)
|
7d1dcb0fb760622147f0c88293198e5fa3b9c639 | Faviobrntn/soporte | /practico01/ejercicio01.py | 232 | 4.03125 | 4 |
def max(a,b):
if (a>b):
return(a)
else:
return(b)
assert (max(2, 5) == 5)
assert (max(2, 5.9) == 5.9)
assert (max(0, -3) == 0)
# num1=int(input("numero 1"))
# num2=int(input("numero 2"))
# max(num1,num2)
|
502a5ffef76700b2b2bf6da0c7c8732e9b107ba3 | cristopherolivares/Tarea2 | /EliminarLista.py | 569 | 3.796875 | 4 | """
Fecha de creación: 09/sep/21
Autor: Cristopher Olivares
"""
lista = [4,5,6,7,5,45,5,8,5]
contenidoLista = len(lista)
print ('La siguiente lista:',lista, 'tiene un total de', contenidoLista, 'elementos.')
a = contenidoLista % 2
c = contenidoLista / 2
if a == 0:
d = lista [int(c)]
lista.remove (d)
pri... |
ee2bb04f9bad88e1e9100afc33bae4edade070e1 | nickgiegerich/streamlit-crypto-dashboard | /myapp.py | 4,227 | 3.578125 | 4 | import streamlit as st
import pandas as pd
import datetime as dt
import numpy as np
import plotly.figure_factory as ff
import plotly.graph_objects as go
import time
from crypto_coin import Coin
import data_plot
# body_html = """
# <style>
# body {
# background-color: #282c34;
# col... |
93ed75df044d1dae736319b51d98e4fddfb0e07b | jyothin/coding | /sorting/pyfiles/insertion_sort/insertionSort.py | 672 | 3.765625 | 4 | #!/usr/bin/python
import sys
def insertionSort(llist):
for i in range (1, len(llist)):
j = i
while j > 0 and llist[j-1] > llist[j]:
temp = llist[j]
llist[j] = llist[j-1]
llist[j-1] = temp
j = j - 1
return llist
def main(filename):
try:
... |
aa240ab8672590cf854d16128363c463b5175f4d | WalterCoronel10/pruebas-git | /lenguaje.py | 436 | 3.953125 | 4 | num1 = input("Ingrese numero")
num2 = input("Ingrese otro numero")
res = num1 + num2
res2 = num1 - num2
res3 = num1 * num2
res4 = num1 / num2
res5 = num1 % num2
print "El resultado de la suma es: {}".format(res)
print "El resultado de la resta es: {}".format(res2)
print "El resultado de la multiplicacion e... |
6c68dd0b2a3d964e184387d9b8088bdc3613ed35 | Enzzza/law-scraper | /mailer/data/populate_sqlite.py | 971 | 3.546875 | 4 | import sqlite3
import json
import uuid
def connect_to_db(dbName):
global conn
global c
conn = sqlite3.connect(f"{dbName}.db")
c = conn.cursor()
def create_table():
c.execute("""CREATE TABLE lawyers (
id text UNIQUE,
name text,
email text,
sent inte... |
a644f639de8f94cfd988fc472219d18ede20c389 | Zalasyu/Chi-Square-Test | /Problem1.py | 5,603 | 4.25 | 4 | """
Problem 1 (10 points)
In an experiment to study the dependence of hypertension on smoking habits, the
following data were taken on 180 individuals:
'Observed' Data
________________________________________________________________________________
| Nonsmokers | Moderate - smokers | Hea... |
0b4a8d7ed71e75d20816bef3dfa2dc9a594ba5c8 | ponmanimanoharan/practice_files | /python-prac_till_functions/expressions and control flow.py | 202 | 3.703125 | 4 | for i in range(1 , 101):
print("I won't cheat on the exam!")
num = 0
for i in range(0 , 501):
if i%2 == 0:
num += i
#print(num)
n = 0
for i in range(1,5):
n += i
print(n)
|
9790fcf4beeb6cf797c1523b2e9ae13ea43a9787 | runningsnail-ltt/leetcode | /DPpart/DPPart.py | 2,747 | 3.5 | 4 | # -*- coding:utf-8 -*-
import os
import sys
from collections import Counter
class Solution(object):
def climbStairs(self, n):
"""
:type n: int
:rtype: int
"""
f_1 = 1
f_2 = 2
if n == 1:
return f_1
if n == 2:
return f_2
... |
75f10a00e47eff9a0a574cae83f3e6b95f2f773f | alexandrabrown/c4cs-w17-rpn | /rpn.py | 1,316 | 3.78125 | 4 | #!/usr/bin/env python3
# Alexandra Brown
# alexbro
# eecs398 w17 week 10
import operator
import readline
import colored
from colored import stylize
OPERATORS = {
'+' : operator.add,
'-' : operator.sub,
'*' : operator.mul,
'/' : operator.truediv,
'^' : oper... |
50cd660665ff07822bfaf7db05ded2cf6e000d93 | danielamelteck/Mesa_D_DataViz | /data/pie.py | 304 | 3.65625 | 4 | import matplotlib.pyplot as plt
hfont = { 'fontname' : 'Lato'}
#generate a pie chart with the Olympic data
values= [316, 203, 107]
labels= ["Gold", "Silver", "Bronze"]
plt.title("Medals obtained by Pol", pad=20, **hfont)
plt.pie(values, labels=labels, colors=colors)
# generate the chart
plt.show() |
f14c12209e37581901bed5c9aefa45bcec62b3f3 | foolchi/GA-Handwriting | /src/switchdata.py | 492 | 3.890625 | 4 | #!/usr/bin/python3
def implode(array):
''' Int array to string '''
string = ''
for i in array:
string += str(i)
return string
def explode(string):
''' String to int array '''
array = []
size = len(string)
for i in range(size):
array.append(int(string[i]))
return arr... |
3ecf001a6b0e7ec13e407c20829ce263129e2c01 | 2019-b-gr2-fundamentos/fund-rivera-yaselga-alberto-david | /Examen20192B/Rivera-Yaselga-Alberto-David-examen-1.py | 4,655 | 4.25 | 4 | #######Ejercicio N°1########
import math
if __name__=="__main__":
while(True):
print("*************CALCULADORA**********")
print("Suma (1)")
print("Resta (2)")
print("Multiplicacion (3)")
print("Division (4)")
print("Potenciacion (5)")
print("Radicacion (6)")
... |
e1a0af4f9b0d95f4ac38b5eed9f5c8fc8a4608e5 | viannegao/cs324-Data-Mining | /kNN/knn-cv.py | 9,885 | 3.640625 | 4 | '''
CS 324 Assignment 1 - kNN
This is a program that uses 5-fold cross validation on the training data to test the performance of knn algorithm, by
computing the confusion matrix and accuracy, using only the 900 images in the train_data.txt and
the K Nearest Neighbor Algorithm to predict which class the image belongs... |
434efcecf5f73781048a45c18e30bdcca62ba97d | forabetterjob/learning-python | /04-loops/count-controlled-while.py | 469 | 4.0625 | 4 | print('Numbers 1 to 20:')
number = 1
while number <= 20:
print(number)
number += 1
print('')
print('Sum of numbers 1 to 20:')
number = 1
sum = 0
while number <= 20:
print(str(sum) + ' + ' + str(number) + ' = ' + str(number + sum))
sum = number + sum
number += 1
print('')
print('2.3% on 100 over 10 years:')
bal... |
18e839387e916fdf5e6b7db348081cb27d6d061f | forabetterjob/learning-python | /08-functions/basics.py | 688 | 3.765625 | 4 | def square(n):
return n * n
def numVowels(string):
string = string.lower()
count = 0
for i in range(len(string)):
c = string[i]
if c == 'a' or c == 'e' or c == 'i' or c == 'o' or c == 'u':
count += 1
return count
def avg(a, b, c):
return (a + b + c) / 3.0
def ultimatePredicate(input):
return input == 4... |
412c1aa57cc06a3128f0cdaa2cf706f25c907ce1 | forabetterjob/learning-python | /02-input-output/basic-printing.py | 240 | 4.0625 | 4 | # printing a string
word = 'foobar'
print(word)
# printing a number
number = 42
print(number)
# printing a tuple
print('Hello', 'World')
print('Age', 22)
# format strings
name = 'Mark'
grade = 89.213235
print('%s: %.2f' % (name, grade))
|
dcd3f22a8799ff3608a47bbfd380a423a932f054 | anthonybotello/Coding_Dojo | /Python/python/fundamentals/arithmetic.py | 113 | 3.59375 | 4 | def add(x,y):
return x + y
def multiply(x,y):
return x * y
def subtract(x,y):
return x - y
|
1a30273bbd6550bb6ab27fa7cd0326e60c395a12 | anthonybotello/Coding_Dojo | /Python/Algorithms/sorting.py | 1,012 | 3.96875 | 4 | def bubbleSort(list):
sorted_list = True
for i in range(len(list)-1):
if list[i] > list[i+1]:
temp = list[i+1]
list[i+1] = list[i]
list[i] = temp
sorted_list = False
if sorted_list:
return list
else:
return bubbleSort(lis... |
35c712ce5419ab0d55124981ab048d4c0321dc62 | anthonybotello/Coding_Dojo | /Python/Algorithms/singly_linked_list.py | 1,567 | 3.84375 | 4 | class Node:
def __init__(self,val):
self.value = val
self.next = None
class SList:
def __init__(self):
self.head = None
def addtoFront(self,val): #adds value to front of list
new_node = Node(val)
new_node.next = self.head
self.head = new_node
... |
5595d4bbaa61c971b9e01838af91960756c22ed9 | doper0/firstcode | /ff5.py | 407 | 4.0625 | 4 | for x in range(22,49):
if x%2==0: print(x)
################ version[3.7.1]
# prints all the numbers even between 22 to 48
#for i in range(22,36):
#if i%2==0:
# print(i,',',end='')
#print('')
#for i in range(36, 49):
# if i % 2 == 0:
# print(i, ',', end='')
... |
c175ca8ad01b4aaf0055546b12859535fc12c034 | aAlejandroz/DiagramingProgram | /src/rectangle.py | 1,001 | 3.625 | 4 | class Rectangle:
def __init__(self, x, y, length, width):
self.x_coordinate = x
self.y_coordinate = y
self.length = length
self.width = width
def set_location(self, x, y):
self.x_coordinate = x
self.y_coordinate = y
def move_by(self, x, y):
self.set_location(self.x_coordinate + x, s... |
600aac00fb5b04c529c31ce24bdf3e8c576b223f | aAlejandroz/DiagramingProgram | /src/square.py | 981 | 3.578125 | 4 | class Square:
def __init__(self, x, y, side):
self.x_coordinate = x
self.y_coordinate = y
self.side = side
def set_location(self, x, y):
self.x_coordinate = x
self.y_coordinate = y
def move_by(self, x, y):
self.set_location(self.x_coordinate + x, self.y_coordinate + y)
def is_po... |
67f482ef1329f89d631a39932acc8b1ab8b78331 | Fianketto/MADE_2020-2021 | /algorithms/L03/L03_C.py | 366 | 3.53125 | 4 | def func(x):
return x ** 2 + x ** 0.5 - c
EPS = 10 ** (-6)
ITER_COUNT = 100
left_b, right_b = 0, 10 ** 5
c = float(input())
x = right_b / 2 + left_b / 2
for i in range(ITER_COUNT):
y = func(x)
if abs(y) < EPS:
break
elif y > 0:
right_b = x
else:
left_b = x
... |
02f7c7dfc6bac19ed263df4d4093733d61c05f0a | Fianketto/MADE_2020-2021 | /algorithms/L02/L02_A_v2.py | 3,138 | 3.5 | 4 | """
k-ая порядковая статистика
"""
import random
def get_median(arr, i1, i2, i3):
a1, a2, a3 = arr[i1], arr[i2], arr[i3]
if min(a1, a2, a3) == a1:
return min(a2, a3)
elif min(a1, a2, a3) == a2:
return min(a1, a3)
return min(a1, a2)
def get_k_statistic(arr, left, right,... |
f47acab45679763a2e6187176134d6ee7da5b5ee | offamitkumar/Kattis | /Oddities/oddities.py | 98 | 4.15625 | 4 | for _ in range(int(input())):
x=int(input())
print(x,"is odd" if x&1 is 1 else "is even")
|
237ace84079ed9f2b51f543fe3fa38b73abafaf5 | Naushikha/Old-Projects | /Python/Simple Tutorials/bin_to_deci_with_workings.py | 451 | 3.765625 | 4 | #17 Feb 2017
#Converts a binary into a decimal and shows the workings
#Coded by _xXHunt3rXx_
#inputs
num=input("Enter a binary number:")
n=list(num)
n.reverse()
p=tot=0
res=[]
print()#working
#process BIN>DEC
for x in n:
res.append(int(x)*2**p)
print("2 ^ "+str(p)+" x "+x+" = "+str(int(x)*2**... |
3bb75100c7b194e6ef6f86d8bcc23bac37ac7db0 | Naushikha/Old-Projects | /Python/Simple Tutorials/RW Files/Simple db/read_calc_display.py | 640 | 3.90625 | 4 | #17 Feb 2017
#Reads in a simple database
#Coded by _xXHunt3rXx_
#for fun, made 2 functions that imitate the behaviour of min and max(from scratch)
def f_max(lst):
mx=int(lst[0])
for x in lst:
if int(x)>mx:
mx=int(x)
return mx
def f_min(lst):
mn=int(lst[0])
for x in ... |
ed6ab2373ea9f98269d77124d377f2f28179c7ae | Ahsung-Prac/PRAC_AI_Deep_Neural_Netework | /prac.py | 765 | 3.953125 | 4 | import matplotlib.pyplot as plt
import numpy as np
# 계단함수 구현
def step_function(x):
a = np.array(x>0) # 0보다 큰값은 true 나머지는 false로 배정
return a.astype(np.int) #int 타입으로 변경 0 or 1
x = np.arange(-5.0,5.0,0.1)
y = step_function(x)
plt.plot(x,y)
plt.ylim(-0.1,1.1)
plt.show()
def sigmoid(x):
return 1/(1+np.exp... |
9c9187e842c47af17c1c851d1e56f85aa554489f | tupti/quiz_app | /main.py | 964 | 3.640625 | 4 | import json
import random
class Question:
def __init__(self, prompt, options: list, answer):
self.prompt = prompt
random.shuffle(options)
self.options = options
self.answer = answer
questionsData = []
with open('questions.json','r') as json_file:
questionsD... |
a5b9c3433999acdcf1000c96fff6d62f6e9372ff | frickerg/python_maze | /functions/console.py | 2,036 | 3.671875 | 4 | from os import system, name
from functions import utils
from termcolor import colored
from time import sleep
# define clear function
def clear():
# for windows
if name == "nt":
_ = system("cls")
# for mac and linux(here, os.name is 'posix')
else:
_ = system("clear")
# print the maze p... |
edd60dc5ce4fc291bf3ec89e84499a40f0f1034f | paulboal/pexpect-curses | /swearjar/test/curses01.py | 1,647 | 3.53125 | 4 | #!/usr/bin/python
import curses
import math
import os
import sys
import fcntl
import struct
import termios
import array
import logging
import time
logging.basicConfig(filename='example.log',level=logging.DEBUG)
__doc__="""\
The program presents a series of menus that we're going to use for testing.
1. Enter new pers... |
5b495d3c3ea3d0216b73f4cae52a3a56b55f3718 | ysumit99/Compi-Coding | /Extras/Python/march_long_2018_b.py | 499 | 3.515625 | 4 | t = int(input())
for i in range(t):
n = int(input())
loss = 0.0
for j in range(n):
temp = 0.0
temp2 = 0.0
string_input = input().split()
data = []
for single in string_input:
data.append(int(single))
price = data[0]
quantity = data[1]
discount = data[2]
temp = price + (price ... |
48dfd9928ff1943242522c3895a845336907f7fe | 0xchamin/Machine-Learning-Python | /Fundamentals/wave_data_set.py | 300 | 3.65625 | 4 |
import matplotlib.pyplot as plt
import pandas as pd
import numpy as np
import mglearn
#generate data set
X,y = mglearn.datasets.make_wave(n_samples = 40)
#plot dataset
plt.plot(X, y, 'o')
plt.ylim(-3, 3)
plt.xlabel("Feature")
plt.ylabel("Target")
plt.show()
print("X.shape:{}".format(X.shape))
|
6f3faedd86b8b08ea13d838c58828e4ca2f47d67 | 0xchamin/Machine-Learning-Python | /Fundamentals/python_sandbox_finished/classes.py | 1,070 | 4.25 | 4 | # A class is like a blueprint for creating objects. An object has properties and methods(functions) associated with it. Almost everything in Python is an object
# Create class
class User:
# Constructor
def __init__(self, name, email, age):
self.name = name
self.email = email
self.age = age
def greet... |
51611fd6fe5e8c819407cdf8e242670671fc455a | chrisengel3/WebFund | /Week_3_Python/OOP_Notes/tempCodeRunnerFile.py | 990 | 4.3125 | 4 | class Dog:
# CONSTRUCTOR FUNCTION
def __init__(self, name, age, hair_color):
# ATTRIBUTES (the date inside an object)
self.name = name
self.age = age
self.hair_color = hair_color
# METHODS ARE FUNCTIONS THAT IS PART OF A CLASS
def bark(self):
print(f"BORF BOOFIN ... |
4c3328c5e75ffbb8897eea1cc23f3e39f88e06a7 | liurong92/python-exercise | /exercises/dictionary/one.py | 930 | 4.5 | 4 | """
Create a dictionary that contains a list of people and one interesting fact about each of them.
Display each person and their interesting fact to the screen. Next, change a fact about one of
the people. Also add an additional person and corresponding fact. Display the new list of people
and facts. Run the program m... |
e86d3a8a018fc6bc10dc5e8b86ed1240c162ea90 | liurong92/python-exercise | /exercises/string/two.py | 117 | 3.640625 | 4 | customInput = input('Please type something and press enter:')
print('You entered:')
print('{}!'.format(customInput))
|
37ad2276f3c15631db6dfbfc684dc2387c126600 | paddumelanahalli/agile-programming | /practice-3.py | 1,248 | 4.21875 | 4 | # Python Practice - 3
# Author : Paddu Melanahalli
#
#
cars = 100
space_in_a_car = 4.0
drivers = 30
passengers = 90
cars_not_driven = cars - drivers
cars_driven = drivers
carpool_capacity = cars_driven * space_in_a_car
average_passengers_per_car = passengers / cars_driven
print("There are", cars, "cars available.")
p... |
5a5ca6bda8598aa6f51854578090b3bf01626c70 | paddumelanahalli/agile-programming | /tdd-banking.py | 1,404 | 4.09375 | 4 | import unittest
class Banking():
def __init__(self):
self.balance = 0
def credit(self, amount):
amount_type = (int, float, complex)
if isinstance(amount, amount_type):
self.balance += amount
return self.balance
else:
print("raises error")
... |
8a6cda1b3d271b877b47b8ca368e4b129551717d | paddumelanahalli/agile-programming | /practice-2.py | 1,312 | 4.75 | 5 | # Python Practice 2
# Author: Paddu Melanahalli
#
# +: plus
# -: minus
# /: slash
# *: asterisk
# %: mod
# <: less-than
# >: greater-than
# <=: less-than-equal
# >=: greater-than-equal
# Notice how the operations are missing? After you type in the code for this exercise, go back and figure out what each of these does a... |
32c73ee6c1e514a6d737390d8e13877c48886436 | josflesan/Sudopy | /src/controller/generate.py | 1,343 | 3.96875 | 4 | # Helper functions used to generate a random sudoku board
from controller.solver import check_valid, solve_backtrack
from copy import deepcopy
from random import randint as r
def generate_board():
"""
Function that generates a random, partially filled board
Returns:
(list[int][int]): ... |
5bf3e26caacaca9e3c10e0926ca6a6df92f6c362 | vincentereyes/pythonstringandlist | /mathdojo.py | 597 | 3.640625 | 4 | class MathDojo(object):
"""docstring for MathDojo"""
def __init__(self, temp):
self.temp = temp
def add(self, *num):
for i in num:
if type(i) == tuple or type(i) == list:
for j in i:
self.temp += j
else:
self.temp +=i
return self
def sub(self, *num):
for i in num:
if type(i) == tupl... |
b66dab51035ec907c19205c90676e824bf792566 | vincentereyes/pythonstringandlist | /a.py | 308 | 3.671875 | 4 | words = "It's thanksgiving day. It's my birthday, too!"
words1 = words.replace("day", "month")
x = ["hello",2,54,-2,7,12,98,"world"]
newx = []
newx.append(x[0])
newx.append(x[-1])
z = []
y = [19,2,54,-2,7,12,98,32,10,-3,6]
y.sort()
z.append(y[:5])
for count in range (5, 11):
z.append(y[count])
print words1 |
f90af69d895bd8f1b80643cd4b83ae262fe0da3f | vincentereyes/pythonstringandlist | /product.py | 921 | 3.59375 | 4 | class Product(object):
"""docstring for Product"""
def __init__(self, Price, ItemName, Weight, Brand):
super(Product, self).__init__()
self.Price = Price
self.ItemName = ItemName
self.Weight = Weight
self.Brand = Brand
self.Status = "for sale"
def sell(self):
self.Status = "sold"
return self
def add... |
23356d099519bcc9c455896ee9ee4111549330d4 | anomaly-detection-macrobase-benchmark/scripts | /utils/sizes.py | 369 | 3.578125 | 4 | units = ['', 'K', 'M']
def format_size(num):
for unit in units[:-1]:
if abs(num) < 1000:
return "%d%s" % (num, unit)
num /= 1000
return "%d%s" % (num, units[-1])
def parse_size(s):
s = s.upper()
unit_num = '000'
for unit in units[1:]:
s = s.replace(unit, unit_... |
6a5eeb07bc955f94323412bf3ff7500242d91460 | susyhaga/Challanges-Python | /Udemy python/PI/circle_area_v16.py | 746 | 3.828125 | 4 | #!/usr/bin/env python3
from math import pi
import sys
import errno
class TerninalColor:
ERROR = '\033[91m'
NORMAL = '\33[0m'
def help():
print("It is necessary to inform the radius of the circle")
print("Sintaxe:{} <raio>".format(sys.argv[0][2:]))
def circle(radius):
return pi * float(radius) ... |
5384d96d1de656593cb6d9ff1664876e2c0697d1 | susyhaga/Challanges-Python | /Udemy python/PI/circle_area_v8.py | 235 | 4.0625 | 4 | #!/usr/bin/env python3
from math import pi
def circle(radius):
print('Circle area', pi * float(radius) ** 2)
if __name__ == '__main__':
radius = input('Informe the radius: ')
circle(radius)
#""" No return function"""
|
91c560e856d701d0d6e6b132d7fc2b6276e184fa | frankenberga/Maze-Search | /uninformed_search.py | 2,263 | 3.609375 | 4 |
from collections import deque
from SearchSolution import SearchSolution
# you might find a SearchNode class useful to wrap state objects,
# keep track of current depth for the dfs, and point to parent nodes
class SearchNode:
# each search node except the root has a parent node
# and all search nodes wrap a s... |
b2ea57f72974afe7d1ac0d2f88f2f43dbee02bc7 | Jdb156158/python3.6.2_handouts | /数据类型-集合实例.py | 514 | 3.96875 | 4 | #!/usr/bin/python3
student = {'Helen', 'Eric', 'Jason', 'Jerry', 'Jerry', 'Rose'}
print(student) # 输出集合,重复的元素被自动去掉
# 成员测试
if('Rose' in student) :
print('Rose 在集合中')
else :
print('Rose 不在集合中')
# set可以进行集合运算
a = set('abracadabra')
b = set('alacazam')
print(a)
print(a - b) # a和b的差集
print(a | ... |
ecbc0b1ff99536a8d29a83635f12f43f9e130375 | PavloBryliak/CourseWorkSecond | /stack_example.py | 986 | 4.09375 | 4 | class Stack(object):
"""
Class for building a stack with defined properties
in which we can do some manipulations like
to push or pop elements and to define whether
stack is full or empty.
"""
def __init__(self, maxSize):
self.stack = list()
self.maxSize = maxSize
... |
8e41f8ef99ebad5bd15866f9fc7a6d951c14b92d | debojadebayo/flask-blog | /sql.py | 485 | 3.984375 | 4 | import sqlite3
with sqlite3.connect("blog.db") as connection:
c= connection.cursor()
#create table posts with title and post
c.execute("""CREATE TABLE posts (title TEXT, post TEXT)""")
#insert dummy data onto the table
c.execute('INSERT INTO posts VALUES("Good","I\'m good.")')
c.execute('INSERT INTO post... |
4bdb0dbe4cc63820c2916137f2c1fe3e78365698 | yagamiram/Machine_learning | /line_equation_estimator.py | 1,847 | 3.734375 | 4 | '''
This python file will return a line equation (slope, intercept) with less error.
To understand the concept, check the notes or the below link.
Link: http://jeremykun.com/2013/08/18/linear-regression/
'''
avg = lambda L: 1.0* sum(L)/len(L)
def bestLinearEstimator(points):
z = zip(*points)
print z
xAvg, yA... |
9524d39c7179d7680eccc654d6107999afff18a1 | anguyen216/Maze-Search-with-Cozmo | /FinalMaze.py | 6,377 | 3.828125 | 4 | #!/usr/bin/env python3
import cozmo
from cozmo.util import degrees, distance_mm, speed_mmps
class maze ():
# startCoord - starting location, direction - facing direction
# fixed order of navigation
def __init__(self,startCoord, direction, robot):
self.start = startCoord
self.startDirecti... |
447ff4641c76541b8c30597fcb6638a7876deb4a | rajeevs1992/myCodes | /codechef/error/error.py | 144 | 3.734375 | 4 | t=int(raw_input())
while t>0:
s = raw_input()
if '101' in s or '010' in s:
print "Good"
else:
print "Bad"
t=t-1
|
635a301af8413ed24f15fe03c2f77c2167697cb7 | whitebloc/dev_python | /grafik_mod.py | 648 | 3.5625 | 4 | from tkinter import *
fenetre = Tk()
label = Label(fenetre, text="Hello World")
label.pack()
bouton=Button(fenetre, text="Fermer", command=fenetre.quit)
bouton.pack()
label = Label(fenetre, text="Texte par défaut", bg="yellow")
label.pack()
value = StringVar()
value.set("texte par défaut")
string = '0'
e... |
59c0e093928f06c8f0cacc6f1b1ce47ab0b4f2c6 | betul-123/c-ba-lang- | /kosullu_durumlarla_kullanici_girisi.py | 332 | 3.796875 | 4 | #!/usr/bin/env python
# coding: utf-8
# In[4]:
name_s="Betul"
P1="12345"
kullanici_Adi=input("Lutfen kullanici adinizi giriniz.")
sifre=input("Lutfen sifrenizi giriniz.")
if kullanici_Adi!=name_s or sifre!=P1:
print("Kullanici adiniz veya sifreniz hatali!")
else:
print("Giris yapiliyor.")
# In[ ]:
#... |
521108d8d35a0cfd76d0eb93e02df7a1f54b7229 | sayeedm/python-ml-snippets | /linear-regression/lin-reg-closed.py | 891 | 3.625 | 4 | '''
linear regression closed form
using the equation theta = (XT.X)^-1.XT.y
Author: SayeedM
Date: 03-07-2014
'''
import numpy as np
# lets say we train a naive system to calculate y = 4x - 1
# we will generate a bunch of randoms as training data
X = np.random.rand(1000, 1)
y = -1 + 4 * X + np.random.... |
2ab0bc12b3427de81783c072b812c34fd6d7b3f6 | TomScavo/python | /compare1.py | 133 | 3.671875 | 4 | s=input("s ")
t=input("t ")
if s!=None and t!=None:
if s ==t:
print("same")
else:
print("different")
|
a6d484d845ae1007ab7d69c2077da1dcb35e0370 | TomScavo/python | /students.py | 318 | 3.921875 | 4 | import cs50
from student import Student
students=[]
for i in range(3):
print("name",end="")
name=cs50.get_string()
print("dorm",end="")
dorm=cs50.get_string()
students.append(Student(name,dorm))
for student in students:
print("name:{},dorm:{}".format(student.name,student.dorm)) |
ff50018f99a3e31404884f4158071f49b60c1240 | jorrychen123/shiyanlou | /calculator.py | 935 | 3.890625 | 4 | #!/usr/bin/env python3
import sys
# do something in ValueError
try:
salary = int(sys.argv[1])
cash = salary - 3500
if cash <= 0:
tax = cash * 0.00 - 0
print("%.2f" % tax)
elif cash > 0 and cash <= 1500:
tax = cash * 0.03 - 0
print("%.2f" % tax)
elif cash > 1500 and c... |
fac0a89a27959dfc6f498d306e6c7e8d1e2231bd | AuBiSY/aubi_deku | /py.py | 1,032 | 4.28125 | 4 | print('hello world!')
print('hello', 'world!') # 逗号自动添加空格
print('hello' + 'world!') # 加号表示字符拼接
print('hello', 'world', sep='***') # 单词间用***分隔
print('#' * 50) # *号表示重复50遍
print('how are you?', end='') # 默认print会打印回车,end=''表示不要回车
username = input('username: ')
print('welcome', username)
print('welcome ' + username)... |
3332b68ec52148b36fde177241e4b1c3010e529f | nouman-nn/hacker | /hacker.py | 329 | 3.796875 | 4 | marks = dict()
count = int(input())
for students in range(count):
name,mark1,mark2,mark3 = input().split()
marks[name] = [float(mark1),float(mark2),float(mark3)]
query = input()
print(query)
mark = marks.get(str(name))
print(mark)
#print(mark)
#print(sum(mark)/3)
avg = round(sum(mark)/3,2)
#print("{:.2f}".for... |
f111a57e38f9ccf65cde7d3010b6721c01a4de4b | HilmiAH/cits1401 | /lab_3/gcd.py | 568 | 3.96875 | 4 | # Solution to Q4
# finds the greatest common divisor of two positive integers using Euclid's algorithm
def gcd():
a = int(input("a: "))
b = int(input("b: "))
# input validation
while a < 1 or b < 1:
print("Error. Enter positive integers for a and b")
a = int(input("a: "))
b = in... |
a4b6f777f4267af8c2dbb0e5ed97e89a13c27f96 | ken2190/ml-demos | /301-object-detection/01-cnn-as-object-detector/classifier-to-detector/pyimagesearch/detection_helpers.py | 2,072 | 3.5625 | 4 | # import the necessary packages
import imutils
def sliding_window(image, step, ws):
'''Find where in the image an object is by sliding our
classification window from left-to-right (column-wise)
and top-to-bottom (row-wise)
Args:
image: The input image that we are going to loo... |
9b761305abce13e755ea0f7d4955d25bc6eeface | saribalazs/f0005 | /f0005d.py | 187 | 3.875 | 4 | szám = input('Adj meg egy egész számot!')
szám = int(szám)
if szám >=0:
print('A', szám, 'természetes szám.')
else:
print('A', szám , 'egy negatív egész szám') |
bb4ec2129773058c53580aec271bb85558088bee | Nukeguy5/OOP | /Homework/complexnumbers.py | 1,246 | 4.09375 | 4 |
class ComplexNumber:
def __init__(self, real, imaginary):
self.r = real
self.i = imaginary
def add(self, real, imaginary):
self.r += real
self.i += imaginary
def subtract(self, real, imaginary):
self.r -= real
self.i -= imaginary
def multiply(s... |
20e299a294d52b573b21aedf45b8cec7914d32b6 | Nukeguy5/OOP | /Midterm Review/challenges.py | 3,688 | 3.671875 | 4 | # PART 1
# In the game of Yahtzee, players will roll 5 dice and score them. Scoring works like this:
# You can choose to score for 1s, 2s, 3s, 4s, 5s, or 6s.
# If you score for 1s, you get 1 point for every 1.
# If you score for 2s, you get 2 points for every 2. etc.
# For example, if you roll 4 2 2 5 5
# If you scor... |
7fff9639415ab3e131cee73ccc2eca2380e9db0c | 3DRD/Python_basics | /app.py | 1,088 | 4.5 | 4 | # Part of modules
# utils.py part of this file
# also contains three ways to input list of integers
# import utils
from utils import max_from_list,min_from_list
n=int(input("Enter size of List "))
number=[]
# Type 1
# num=input("Enter the list of numbers seperated by space")
# num2=num.split()
# for i in n... |
f11dcf28eb23e0ef01348d261157b717eda92751 | ArieSH3/Harry-Potter-Webscrape | /Harry_Potter_Scrape.py | 2,686 | 3.828125 | 4 | ''' TODO: In function get char info, add all the information to a nested dictionary
where the key is character name and value is another nested dictionary in which
there will be all their information names as key and information as values
corresponding to those keys.
{char_name: {born : year
... |
9b86e1461986c75dbc2756f82dc3a9c7d1150798 | aoamusat/Labyrinthe | /serveur/models/labyrinthe.py | 2,451 | 3.890625 | 4 | # -*-coding:Utf-8 -*
""" Ce fichier contient la classe Labyrinthe.
"""
import random
import const
from .robot import Robot
from .carte import Carte
class Labyrinthe:
""" Classe représentant un labyrinthe. Un labyrinthe est définit par une carte et un robot"""
robots = {}
carte = None
def set_carte(s... |
f7737b256fb868dd06aa94866c7c1fb5a0f9d40f | DaniAlfa/AI_problem_solving | /Ascensores.py | 4,654 | 3.5625 | 4 | from search import *
from search import breadth_first_tree_search, depth_first_tree_search, depth_first_graph_search, breadth_first_graph_search
class Ascensores(Problem):
def __init__(self, initial, goal, ascen): ##estado (plantas de pasajeros, (plantas de ascensores))
self.ascen = ascen
##self.n... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.