blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string |
|---|---|---|---|---|---|---|
b3df870550943ee590f33253ac2dc3c2ab258038 | awan0senja/numerik | /python_script/grafik_subplot.py | 572 | 3.9375 | 4 | #grafik dengan bentuk subplot
import matplotlib.pyplot as plt
import numpy as np
x=np.arange(-10,11)
y1=x**3 - x**2 + x
y2=x**2
plt.figure(figsize=(9,9))
plt.subplot(2,2,1) #subplot(nrows,ncols,index(posisi grafik, mulai dari angka 1, dari kiri ke kanan))
plt.plot(x,y1,"g^-")
plt.title("Kurva pertama")
... |
2e7619f351f06f139ffee4847a6f46975efc3f18 | Kavakuo/PyECCArithmetic | /src/PyECCArithmetic/curve.py | 4,554 | 3.6875 | 4 | # coding=utf-8
class Curve(object):
"""
An elliptic curve that can be represented by a
Weierstrass equation y^2 = x^3 + a * x + b mod p
"""
def __init__(self, a, b, p, name=''):
self.a = a
self.b = b
self.p = p
self.name = name
# http://www.secg.org/sec2-v2.p... |
d751c03aa5c8fb440eae29df4a29c73d4daaf87a | mtkp/432-final-project | /app/userinput.py | 1,335 | 3.640625 | 4 | # File: userinput.py
# Authors: Matt Kipps, Greg Parker
# Date: June 2nd, 2014
# Class: CSS 432 A
# Professor: Brent Lagesse
# Assignment: Final Project
# Description:
# A class that the event manager uses to control keyboard input. this class
# will take keyboard input events from p... |
206a7d5ca5899aa61ba333fb76c2c6d7e5930f74 | GeekyShacklebolt/PYM_exercises | /day_6/unit_testing/factorial.py | 840 | 4.375 | 4 | #!/usr/bin/python3
import sys
def fact(num):
'''
Function to find the factorial of a given number.
args: a number
returns: factorial of a number
'''
if num == 0:
return 1
else:
return num * fact(num - 1)
def div(num):
'''
Function to divide 10 with the give... |
a22b404b03ea52b6c8840ba2aa206391d84c7b6f | rafabentoss/courses | /binomial.py | 275 | 3.890625 | 4 |
n = int(input("Digite o valor de n", ))
k = int(input("Digite o valor de k", ))
def fatorial(x):
fat = i = 1
while x >= i:
fat = fat * i
i = i + 1
return fat
binomial = fatorial(n) / (fatorial(k) * fatorial(n - k))
print(binomial) |
aa24dd4bd5add743afb163ae004d7db00a60044f | rebeca-maia/Programa-o-Funcional | /lista3.py | 3,734 | 3.921875 | 4 |
class Fibonacci():
def __init__(self):
self.seq = [0, 1]
#
def __iter__(self):
return self
def next(self):
self.seq.append(sum(se... |
0c9b8a0cb95828b393885989ad333606655a771a | Yaoaoaoao/LeetCode | /algorithms/96_unique_binary_search_tree.py | 591 | 3.578125 | 4 | class Solution(object):
def numTrees(self, n):
"""
:type n: int
:rtype: int
"""
### dp-memory
if n<=2:
return n
dp = [1,1,2] + [0 for _ in range(3, n+1)]
for ele in range(3, n+1):
for i in range(ele):
dp[ele] += ... |
cf80290d8b7856f5eb5b0bd9dd9bd1c245a7fc40 | defconfurs/dc26-fur-scripts | /animations/life.py | 2,490 | 3.6875 | 4 | ## Conway's Game of Life
import dcfurs
import random
class life:
def __init__(self):
self.fbuf = [bytearray(18),bytearray(18),bytearray(18),bytearray(18),bytearray(18),bytearray(18),bytearray(18)]
self.interval = 750
self.watchdog = 0
dcfurs.clear()
## populate the initial ... |
f5d94d16a538aa42328e2251ba6783460c4a6112 | ed-cetera/project-euler-python | /042_solution.py | 833 | 3.84375 | 4 | #!/usr/bin/env python3
import math
import time
def is_triangle_word(word):
word_value = 0
for character in word:
word_value += ord(character) - 64
return ((math.sqrt(8 * word_value + 1) - 1) / 2).is_integer()
def main():
try:
with open("p042_words.txt", "r") as words_file:
... |
d96e6f6b0adc988dc7982c63608e7b0009506a07 | Toshiyana/atcoder_study | /ABC/C_problems/49.py | 414 | 3.5625 | 4 | import re
S = input()
'''
https://qiita.com/hiroyuki_mrp/items/29e87bf5fe46de62983c
https://qiita.com/hiroyuki_mrp/items/29e87bf5fe46de62983c
メタ文字:
^ = 文字列の先頭、
| = OR
+ = 直前のパターンを1回以上繰り返し、
$ = 文字列の末尾
. = なんでも良い一文字
\:エスケープ
'''
if re.match("^(dream|dreamer|erase|eraser)+$", S):
print('YES')
else:
print('NO') |
6c9630664203f574a47e8ad4099817e613db4acd | KyattPL/algorithms-and-data-structures | /algorithms/bubbleSort.py | 815 | 4.125 | 4 | from random import random
def bubble_sort(arr):
comparisons = 0
array_accesses = 0
additional_space = 0
for i in range(len(arr)):
swapped = False
for j in range(len(arr) - i - 1):
comparisons += 1
array_accesses += 2
if arr[j] > arr[j + 1]:
... |
cd750b6a0bd337dae4086183c7be0c09ce055412 | arakaneyuta/python | /search_algorithm/linear_search.py | 162 | 3.75 | 4 | def linear(key,array):
for i in range(0,len(array)-1):
if array[i]==key:
print ("Yes")
else:
print ("No")
break
array=[2,1,3,4,5]
linear(6,array) |
be03d3d81880bde7c3d46612d744f4bdbbd501ba | Leslie1sMe/LeetCode | /965.独特的电子邮件地址.py | 996 | 3.84375 | 4 | #
# @lc app=leetcode.cn id=965 lang=python3
#
# [965] 独特的电子邮件地址
#
# https://leetcode-cn.com/problems/univalued-binary-tree/description/
#
# algorithms
# Easy (65.04%)
# Total Accepted: 3.4K
# Total Submissions: 5.2K
# Testcase Example: '[1,1,1,1,1,null,1]'
#
# 如果二叉树每个节点都具有相同的值,那么该二叉树就是单值二叉树。
#
# 只有给定的树是单值二叉树时,才返回 ... |
7e6a6c846ec0848fc25ecd5c85bef7b266f96bfa | SahilRailkar/game-of-life | /BooleanModel.py | 2,858 | 4 | 4 | class BooleanModel:
"""BooleanModel is the model built to hold the raw data behind the cells of LifeGUI."""
def __init__(self, grid: list):
"""Construct a BooleanModel object.
GRID is a two-dimensional Boolean list that describes each corresponding cell of LifeGUI.
GENERATION is the in... |
56888aa535ee5c33f476d621e6f3fcde0d24b9ee | SelinaBlijleven/MachineLearning | /10574689_Blijleven_Prog5/split_data.py | 2,064 | 3.84375 | 4 | """
Selina Blijleven 10574689
Programming Assignment 5
December 2015
"""
import csv
import numpy as np
def main(file_name="digist123-1.csv", train_p = 0.6, validation_p = 0.2, test_p = 0.2):
"""
Splits the data from a given file into smaller sets given
three proportions.
"""
data... |
160c8e971a9be48f37774548f1d0e7489e6249d5 | BrunoDantasMoreira/ProjectsPython | /python_teste/python_aulas/aula_75.py | 712 | 3.734375 | 4 | n1 = int(input('Digite um número: '))
n2 = int(input('Digite outro número: '))
n3 = int(input('Digite mais um número: '))
n4 = int(input('Digite o ultimo número: '))
lista = (n1, n2, n3, n4)
print(f'Você digitou o valores \033[34m{lista}\033[m')
print(f'O valor 9 apareceu \033[34m{lista.count(9)}\033[m vezes')
if lista... |
b75f71ac60c2820f9759ee8c719ac81be0213ea8 | liuzhijielzj/python-tutorial | /function/function.py | 6,614 | 3.96875 | 4 | '''函数名其实就是指向一个函数对象的引用,完全可以把函数名赋给一个变量,相当于给这个函数起了一个别名'''
a = abs
print(abs(3.5))
def nop():
pass
'''数据类型检查可以用内置函数isinstance()实现'''
def my_abs(x):
if not isinstance(x, (int, float)):
raise TypeError()
def hanno(n, a, b, c):
if 1 == n:
print(a, '-->', c)
return
hanno(n - 1, a, c,... |
f545c79247214ee74eb4229e31da665f5a40c583 | artisdom/_ebDev | /scripts/imgAndVideo/paletteCompareCIECAM02.py | 4,527 | 3.703125 | 4 | # DESCRIPTION
# Compares two palettes (.hexplt format, from parameter 1 and 2) and prints a dissimilarity ranking float between 0 and 1 (zero and one hundred percent). See USAGE for how it works.
# USAGE
# Run this script through a Python interpreter, with these parameters:
# - arvg[1] palette one file name, e.g. FD61... |
507033532c8581f4b5272eefe4c308c6b35d729b | katetushkan/MPP_Part_2 | /Lab1/media/attachments/BaseClasses.py | 2,797 | 3.53125 | 4 | import typing
class Department:
def __init__(self, name: str, employees: typing.Dict[str, float], budget: int):
self.name = name
self.employees = employees
self.budget = budget
class BudgetError(ValueError):
def __init__(self, message):
super(ValueError, self).__i... |
57e95f6a2d82e1a7f0e5127dcbef96334e3f72e6 | BushraImtiaz/quarter-1 | /q1_leapyear.py | 497 | 4.15625 | 4 |
#Question num 1:
''' FIND A LEAP YEAR '''
def get_year():
print("Please input year:")
year = int(input())
return year
def if_else(year):
if year % 4 == 0 and year % 100 != 0:
print("It's a leap year")
elif year % 400 == 0 and year % 100 != 0:
print("It's a leap year")
... |
f96293823f2baf192d931b6b360f7ece8ee36260 | sidv/Assignments | /Lekshmi_Pillai_185386/August_9/calc/calcmul.py | 143 | 4.0625 | 4 | num1 = input("Enter the first number")
num2 = input("Enter the second number")
mul = int(num1) * int(num2)
print ("Multiplication is : ",mul)
|
3c2b2c688ce639546068849eec6efc159e763ae4 | RickLee910/Leetcode_easy | /Tree_easy/offer_32.2.py | 1,568 | 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 kthLargest(self, root: TreeNode, k: int) -> int:
temp = []
def search(node):
if node:
s... |
671ea607545f62a2e7ad3ad00d1685414154b563 | WavemasterTsu/Extreme-Risk | /ExtremeRiskLibraries/RNG/Generator.py | 298 | 3.578125 | 4 | import random
class Generator():
# int roll(int) Method
@staticmethod
def roll(maxValue):
random.seed(None)
if maxValue is None or maxValue is not int:
maxValue = 6
return random.randint(0, maxValue)
# End roll Method |
9865bbb3ac6c28adf97f77eeaf1142216077f294 | Stheycee/Projeto-Python | /Stheyce_Souza_Jokenpo.py | 1,703 | 3.53125 | 4 | from time import sleep
rodadas = ['Rodada n1', 'Rodada n2', 'Rodada n3']
pp = 0
p = 0
print('''Bem vindo ao JokenPo.
intruções:
'1' para Pedra
'2' para Papel
'3' para Tesoura''')
nome = input('Login: ')
nome2 = input('Login: ')
print('=' * 80)
for n in rodadas:
print(n)
ppt = input('Pedra, Papel, Tesoura...').... |
6aedd2729a8dbc6d08bac0ddfb8df8386b19f9b0 | Anya97/pythonStart | /4.py | 151 | 3.6875 | 4 | my_list_1 = [2, 5, 8, 2, 12, 12, 4]
my_list_2 = [2, 7, 12, 3]
for i in my_list_1:
if i in my_list_2:
my_list_1.remove(i)
print(my_list_1)
|
f23ae456207a27bc252288b20a881634d5975fcf | bkerdsuwan/mycode | /challenge.py | 182 | 3.9375 | 4 | #!/usr/bin/env python3
user_input = input("Please enter a username: ")
user_input2 = input("What day is it? ")
print("Hello, " + user_input + "! Happy " + user_input2, end = '!\n')
|
cc81e4fe2386bcc5f010b62e501c01e98ad6c3d1 | karishmakaushik/Library-Management-System | /script_main.py | 1,243 | 3.609375 | 4 | from all_functions import*
import sys
while True:
print("**************************************************")
print('************Library Managemnet System**************')
print("**************************************************")
print('1.Add a Student member to library \n2.Add Faculty member to ... |
7dda5dda4332139653751be69532992bfcf9c9f7 | Arlyxs/PythonOnline | /Lessons/MyWrks/Aliens_Files/Aliens_FileHandling.py | 1,130 | 3.9375 | 4 | # allows reading of file in simple text format
f = open('Aliens_Files\MyData.txt', 'r')
print(f.read())
print('====')
f = open('Aliens_Files\MyData.txt', 'r')
# read is open *1
print(f.readline(), end='#')
print(f.readline())
print('====')
print(f.readlines())
'''
*1 ... so will read one line then all others when s... |
5c3b858c0af4c1590c809f96cc883594b267ba0c | nehertz/algorithm-implementations | /sort_in.py | 2,559 | 4.0625 | 4 | import os
import re
"""
Helper functions that collect input for sorts
"""
def manual_in():
""" Reads and returns user-entered input list from command line """
confirm = 'n'
while (confirm == 'n'):
# Collect input
in_str = input("> Please enter a list of numbers, separated by white space ... |
1b6f7ff5a8a95a56c2c1490a5868e1cf932d7639 | DUDA18/ProgISD20202-1 | /Maria_Eduarda/aula 7/Code2A7.py | 690 | 4.0625 | 4 | import math #Importando a biblioteca math para uso de operações como pow
#Função que calcula o IMC
def FuncImc(peso,altura):
imc= round(peso/math.pow(altura,2),2)
if (imc<17.0):
print ("Imc:",imc,"Muito abaixo do peso")
elif (imc>=17.0 and imc<18.5):
print ("Imc:",imc,"Abaixo do peso")
... |
ae54176dcfa773ec0636d58d7dd0a27b87fb7233 | EdwaRen/Competitve-Programming | /Leetcode/637-average_levels_binary_tree.py | 831 | 3.609375 | 4 | # Definition for a binary tree node.
# class TreeNode(object):
# def __init__(self, val=0, left=None, right=None):
# self.val = val
# self.left = left
# self.right = right
import collections
class Solution(object):
def averageOfLevels(self, root):
"""
:type root: TreeNod... |
b6026d95783ad41b8eaddbcd72d5789434000603 | OmarMWarraich/Assignments | /12-Area_of_Triangle.py | 231 | 4.1875 | 4 | # Ai Assignment 12 - Compute Area of Triangle by given base and height
b = float(input("Enter Base of Triangle : "))
h = float(input("Enter Height of Triangle : "))
area = (1/2) * b * h
print("Area of Triangle is : " + str(area)) |
49662fa8fc62a1dd580dee3d4b4f74d0a082ced4 | Built00/Leetcode | /Judge_Route_Circle.py | 1,352 | 4.125 | 4 | # -*- encoding:utf-8 -*-
# __author__=='Gan'
# Initially, there is a Robot at position (0, 0). Given a sequence of its moves,
# judge if this robot makes a circle, which means it moves back to the original place.
# The move sequence is represented by a string. And each move is represent by a character.
# The valid rob... |
e320ceb99c12169ed2a8a832c7c6c5b7049c28e9 | A-meerdervan/RushHourGit | /Alex/BlockingListEdition/BlockingList2.py | 15,531 | 3.59375 | 4 |
# This is used to emulate pass by value in the canMakeMove() function
from copy import deepcopy
from Car import Car
from CarsList import CarsList
from allBords import *
import random
import copy
from rushhour_visualisation import *
import Queue
WIDTH = 6
HEIGHT = 6
EMPTY_SPOT = "| _ "
EMPTY_SPOT_INT = 101
EMPTY_SPO... |
6832477e15d0f503b07502ccd72d2385c63ae1d3 | verblera/labs | /python_apis_databases/databases/Exercise_04.py | 5,380 | 3.5625 | 4 | """
Please create a new Python application that interfaces with a brand new database.
This application must demonstrate the ability to:
- create at least 3 tables +
- insert data to each table +
- update data in each table +
- select data from each table +
- delete data from each table +
- use... |
f72d2abd6610e1b1561da24db7d2c9ef4fe4000f | DanielCoelho112/pari_2020 | /Parte05/Tutorial/main.py | 1,811 | 3.90625 | 4 | #! /usr/bin/python
import cv2
from matplotlib import pyplot as plt
# openCV e uma ferramenta para processamento de imagens, visao artificial...
def main():
img = cv2.imread('../atlascar.png', 0)
#3 modos de leitura
#1 color image
#0 grayscale image
#-1 inclui alpha channel
cv2.imshow('Image',... |
de4482cebb02ed31a688e049eb03a23d5c16aa92 | StephenSnow379/variables | /numbers.py | 386 | 3.96875 | 4 | #Stephen Snow
#12/09/2014
#Integer addition
number_one=int(input("Please enter first number"))
number_two=int(input("Please enter a second number"))
number_three=int(input("Third number, if you'd be so kind"))
number_four=int(input("And a fourth number"))
Total_number= int(number_one + number_two + number_three ... |
97fd86b0d22e57295dd4b629e8197e30633b3d1e | natawik/python-project-lvl1 | /brain_games/engine.py | 603 | 3.703125 | 4 | import prompt
from brain_games import cli
def run(game):
print('Welcome to the Brain Games!')
print(game.DESCRIPTION)
name = cli.greet()
counter = 1
while counter <= 3:
question, right_answer = game.make_round()
print(cli.QUESTION.format(question))
answer = prompt.string('Y... |
054b51036b1a9c7027d7b82ecf58b68f0e3dac1b | raythurman2386/cs-recursive-sorting | /src/sorting/sorting.py | 2,089 | 4.125 | 4 | from random import shuffle
# TO-DO: complete the helper function below to merge 2 sorted arrays
my_arr = [num for num in range(1, 100)]
shuffle(my_arr)
def merge(left, right):
# If the left array is 0 return the right array
if len(left) == 0:
return right
# If the right array is 0 return the lef... |
c44d18d1be01d54c96eea7dd3959ba633501b267 | ryo8674/nlp100 | /01/05.py | 319 | 3.609375 | 4 | # -*- coding: utf-8 -*-
original = "I am an NLPer"
def ngram(input, n):
last = len(input) - n + 1
ret = []
for i in range(0, last):
ret.append(input[i:i+n])
print (ret)
ngram(original, 2) # 文字 n-gram
original = original.split()
ngram(original, 2) # 単語 n-gram |
b90b957ab965e803b2a509affa807ce2907423d6 | Python-Programming-basic-Project/CODING | /Program for Aromstong number.py | 320 | 4.21875 | 4 | # PROGRAM FOR VERIFY GIVEN NUMBER IS Armstrom Number OR NOT
num = int(input("ENTER THE NUMBER :"))
sum = 0
temp = num
while temp >0:
digit = temp%10
sum += digit ** 3
temp //= 10
if num == sum:
print(num ,"is an Aromstron number")
else :
print(num ,"is not Armstong number")
|
abb0177246a46f507fb9c31f3fb80da2a218d887 | xiaofeng0411/thread_process_study | /thread_test/producers_and_consumers.py | 584 | 3.671875 | 4 | '''
@Author: huxiaofeng
@Date : 2020-04-02 22:45
'''
import queue
import threading
import time
q=queue.Queue(maxsize=10)
def Producer(name):
count = 1
while True:
q.put("骨头%s" % count)
print('生产了%s骨头'%count)
count += 1
def Consumer(name):
while True:
print('[%s]取到【%s】,... |
c6e7fa987d04b9bba4a51e351a561b56137f2066 | Larionov0/DimaKindruk_Lessons | /OOP/List/test.py | 263 | 3.546875 | 4 | class Mouse:
l = 20
color = 'black'
def __eq__(self, other): # ==
if self.l == other.l and self.color == other.color:
return True
else:
return False
m1 = Mouse()
m1.color = 'white'
m2 = m1
print(m1 is m2)
|
e5fda084d6f625d186c9189a4180b1bc2cfa332a | HelloJinny/python-for-beginner | /Chapter05/turtle(5-2).py | 1,713 | 3.640625 | 4 | import turtle
import math
import random
## 전역 변수 선언 부분 ##
t1, t2, t3 = [None] * 3
t1X, t1Y, t2X, t2Y, t3X, t3Y = [0] * 6
swidth, sheight = 300, 300
## 메인 코드 부분 ##
if __name__ == "__main__":
turtle.title('거북이 만나기')
turtle.setup(width=swidth + 50, height=sheight + 50)
turtle.screensize(swidth, sheight)
... |
d8899742bd3ef47bc314a473e2f77680c28ca56c | t-bendet/python-old-games | /find_day.py | 278 | 4.15625 | 4 | import calendar
date = input("Enter a date(dd/mm/yyyy):")
year = int(date[6:])
month = int(date[3:5])
day = int(date[:2])
weekDays = ("Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday")
result =(calendar.weekday(year, month, day))
print(weekDays[result])
|
bc2f10732fdc39ca4507d4f9a579208e93ead713 | jxelremo/conecta4 | /run.py | 4,353 | 3.8125 | 4 | import games
import heuristica
# game = games.TicTacToe(h=3,v=3,k=3)
game = games.ConnectFour()
state = game.initial
# Valores iniciales
player = 'X'
# player1 = 'X'
# player2 = 'O'
dificultad1 = 'heuristica'
dificultad2 = 'none'
jugadas = 0
prof = 4
while dificultad1 == 'heuristica':
print "Seleccion de dificu... |
0c8b429c6801f3614174ede2376c816bb8800b97 | Adrian-Yan16/secondstage | /SecondStage/MySQL/query_word.py | 996 | 3.625 | 4 | """
单词查找
"""
import pymysql
class QueryWord:
def __init__(self,word):
self.__word = word
def __connect_database(self):
# 建立连接
db = pymysql.connect(host="localhost",
port=3306,
user="root",
passwd="1... |
d7f5d5e9b7062bae52cdd045a8642a6980dc5628 | tengopataraia123/PYTHON-BTU | /davwere.py | 877 | 4 | 4 | books = [
{ "author": "John Doe", "book": { "title": "Getting started with Golang", "rating": 4.2, "category": "programming" } } ,
{ "author": "John Doe", "book": { "title": "Best practices with Reactjs", "rating": 4.4, "category": "front-end" } } ,
{ "author": "Ann Hunter", "book": { "title": "React over Angular"... |
7e9a207b27f8d5ad033af352c34e8294b2e92ca5 | peppepel95/prova | /Progetto_1/verifica.py | 3,099 | 3.625 | 4 | from Progetto_1.MyList import MyList, suffix_iterative, suffix_ric
def verificaLista(lista, name):
print("La ", name, " contiene: ", lista)
# test di append
print("Inserimento di 5 alla fine della ", name)
lista.append(5)
print("La ", name, " contiene: ", lista)
# test di extend
print("Este... |
c05ed94b1716e72dabb9fb6992e8228ce3de508d | SureyaKS/Simple-fileHacks | /fileSearch.py | 1,781 | 4.1875 | 4 | """
Simple code to handle redundant task.
Inputs :
1. Folder to process : D:/myFolder/folder having all files/
* It would iterate through all sub-folders and files.
2. File extension to search: 'csv' or 'pdf' or 'xlsx' (or any valid file format)
3. Search Pattern: Type any words that a file has, so that, the code... |
cc3175d9cb6628bc995ac59f0ac01fe173df5875 | OwlFlash/proste_cw_na_poczatek | /C to F.py | 194 | 3.78125 | 4 | Celcius = float (input("Podaj wysokość temperatury w Celciuszach"))
Farenheit = (Celcius * (9/5)) + 32
print("Temperatura {} w C równa się {} w farenheitach".format(Celcius,Farenheit)) |
f0a5b0beab60575f98c742a98a8efe6cf7ae1ff6 | NurbaTron/psycopg2.randomData | /month1/troncode.py | 1,489 | 3.78125 | 4 | # my = "I speac {lang}, my favorite language is {fav}"
# print(my.format(lang = "Russia", fav = "English"))
# writer = "kalyhev nurbek"
# writer = writer.title()
# print(writer)
# ded = ["error", True, 65]
# login = input("Ты блять кто?!? ")
# if login == "Нурбек":
# print("Тогда иди нахуй пидр ебучий")
# eli... |
f9f0148f1fa91c1b8db3e62b36372a9e12969fa0 | randallarms/babynamer | /plot.py | 3,204 | 4.09375 | 4 | #======================================#
# BabyNamer #
# by Randall Arms #
# github.com/randallarms/babynamer #
#======================================#
# This program outputs a matplotlib/pyplot line graph of
# a name's popularity over the years, based on the SSA d... |
ca1093710e425059ab164aa225aa815b843378fe | QuantField/HDPCD-Spark-Exam | /knn/knn2.py | 1,717 | 3.765625 | 4 | # knn algorithm using spark
# finding the best number of nn for best classification
# the results are in knn2_res.txt
from pyspark import SparkContext,SparkConf
conf = SparkConf().setMaster("local").setAppName("KNN")
sc = SparkContext(conf = conf)
"""
from pyspark.sql import SQLContext, Row
sqC = SQLContext(sc)
df ... |
b1094bbe467d6a52b8418f21d6f24ea7ad42efc7 | cemdalay/alafortanfoni | /YMS4585/OOP/Lesson1/Lesson1/3_Class.py | 976 | 4 | 4 | class Student:
"""
self : Sınıf içerisinde yer alan metotların diğerlerinden farkı hangi sınıf içerisinden çalıştığını belirtmesidir.
Self anahtar kelimesini vererek metodun bu sınıf içerinde çalıştığını belirtmiş oluruz.
Tanımlama yapılırkn-en ekleniir fakat kullanım sırasında python bunu... |
74f1bf7f49d5e54558cac1374bbb5de46adf4a36 | StevenPZChan/pythonchallenge | /pyfiles/15uzi.py | 272 | 4 | 4 | import calendar
year_list = []
for year in range(1996, 1000, -10):
if calendar.isleap(year) and calendar.weekday(year, 1, 26) == 0:
year_list.append(year)
print(year_list) # he is the second youngest # google whose birthday is year_list[1]/1/27 --> Mozart
|
c3f935792223416b8a4b86994f99e9ad5c11b206 | krishnapriya333/python | /collections/list/sortlist.py | 198 | 3.515625 | 4 | employee=[[10,"ajay",15000],[11,"vijay",15000],[12,"saj",25000]]
for emp in employee:
if(emp[2]>18000):
print(emp[1])
else:
pass
lst=[-1,3,2,-2,1,0]
lst.sort()
print(lst)
|
34146ab3a9a182657d6c2778b747d52813e5f620 | ferozumair786/PRSNL-Names_Analysis | /approx_match_list.py | 1,053 | 4 | 4 | def approx_match_list(names, decision_boundary = 0.75):
"""
This function takes in a list of strings or names that are approximate matches
along with a decision boundary value of what percent of each of the strings
should be compared to the list itself.
The decision boundary is set to 0.75 or 75%... |
6ebcfcdf166ca20e6807eb6ffcc1f7fffa39291d | arun2chat191/pythonapril | /Giraffe/tic tac toe.py | 4,803 | 4.1875 | 4 | # The tic-tac-toe game!
# Instructions
X = "X"
O = "O"
EMPTY = " "
TIE = "TIE"
NUM_SQUARES = 9
def display_instructions():
# Displaying game Instructions.
print \
"""
Welcome to Tic-Tac-Toe, a showdown between a Human Brain and an
Intelligent Computer.
... |
a2425316f67c7ba4f7848256a97e79406b21c38f | jojonki/basic-algorithms | /sorting/quiqk_sort.py | 1,913 | 3.765625 | 4 | """quick sort
"""
import random
# def quick_sort(arr, ascending=True):
# if len(arr) <= 1: return arr
# pid = random.randint(0, len(arr)-1)
# pv = arr[pid]
# left, right = [], []
# for i in range(len(arr)):
# if i == pid: continue
# if arr[i] < pv:
# if ascending:
# ... |
72d7e4f4785a5fa2d00bb4fe2e16413a519de43d | SagarBose/TemperatureGrabber | /temp_grab v0.9.py | 2,718 | 4.03125 | 4 | ##This script downloads temperature data from https://www.timeanddate.com/
##for the entire year from January to December in TXT Format.
##The script returns °C or °F based on country you are running this script from (based on website)
##And Saves in a text file in the same folder. Parsed CSV WIP
##This script is v... |
1ad11405679aec8450719af12a83d237dc7c4bc3 | elitasheva/Python-Programming | /Exercises/exam_prep_14Feb/town_with_missing_data.py | 1,194 | 3.671875 | 4 | import csv
import iso8601
file_path = input()
towns = set()
data = dict()
try:
count_lines = 0
with open(file_path, encoding="utf-8") as csv_file:
reader = csv.reader(csv_file)
for line in reader:
if line:
count_lines += 1
date = iso8601.parse_date(lin... |
af6e2dbb9451c67391ee9d7d1cf976c39f7387a8 | jiangjiu/DataStruc-python | /Tree.py | 2,295 | 3.96875 | 4 | # -*- coding:utf-8 -*-
# myTree = ['a', ['b', ['d', [], []], ['e', [], []]], ['c', ['f', [], []], []]]
#
#
# # 定义二叉树
# def BinaryTree(r):
# return [r, [], []]
#
#
# # 插入左节点
# def insert_left(root, newBranch):
# t = root.pop(1)
# if len(t) > 1:
# root.insert(1, [newBranch, t, []])
# else:
# ... |
db77f77ed1976eb09beb97b29e9fc7b291052609 | ninabcdefghi/project-euler | /euler3.py | 759 | 3.96875 | 4 | ''''Largest prime factor (Problem 3)
"The prime factors of 13195 are 5, 7, 13 and 29. What is the largest prime factor of the number 600851475143 ?'''
import math
from eulerlibrary import prime_generator
def prime_factors(n):
'''finds all prime factors of a given number n'''
prime_factors = []
prime_numb... |
0495ad992191a2fc367b44cc2a8fadde4eba11be | ingwplanchez/Python | /Refresh/Ficheros/Leer_Forma2.py | 960 | 3.75 | 4 | # -*- coding: utf-8 -*-
# Parametros para Trabajar con ficheros
#Funcion open(Argumento1,Argumento2)
#Los Argumentos se colocan como String es decir entre comillas ""
#El Argumento1 es la ruta absoluta o relativa del archivo
#El Argumento2 es opcional y puede ser:
#'r':read,lectura.Abre el archivo en modo lectur... |
4edfb37c487599421f492319efeef1239d5bdbe2 | lucacaronti/Correct-windows-live-mail-folders | /renameFolder.py | 1,563 | 3.5625 | 4 | import argparse
import os
def fast_scandir(dirname):
subfolders= [f.path for f in os.scandir(dirname) if f.is_dir()]
for dirname in list(subfolders):
subfolders.extend(fast_scandir(dirname))
return subfolders
def rename_folder(dirname):
files = [f for f in os.listdir(dirname) if os.path.isfile(os.pat... |
a35146e7b79866e9c3338cf506ed3b4f2ed4855d | kunalprompt/numpy | /autoGenArrays.py | 488 | 3.578125 | 4 | '''
Hello World!
http://kunalprompt.github.io
'''
print (__doc__)
import numpy
start=9;stop=22;step=2
print "Auto generating a 1-D numpy object"
num_objA = numpy.arange(start, stop, step, 'float')
#arange(start, stop, step, dtype)
print num_objA
print "Auto generating a Multi-D numpy object"
num_objB = numpy.reshape... |
358e8db2bea1394dfe5c994829838917dd9c8738 | sivaprasadraju/iOSDiallerApplication | /main.py | 1,259 | 3.765625 | 4 | from add import AddContact
from search import Search
class Main:
AlphabetDict = {0: [' '], 1: [''], 2: ['a', 'b', 'c'], 3: ['d', 'e', 'f'], 4:['g', 'h', 'i'], 5:['j','k','l'], 6:['m','n','o'], 7:['p','q','r','s'], 8:['t','u','v'], 9:['w','x','y','z']}
ContactNames = ['Keanu Reeves', 'Brad Pitt', 'Trisha', 'Vijay S... |
9da5fbd850317a35cf8ca03637c8a002c79b6ab9 | florinrm/ASC-Lab-Tutorial | /Lab2/main.py | 977 | 3.671875 | 4 | from threading import Thread
class Song:
# self este echivalentul lui this din Java
# __init__ este constructorul unei clase din Python
def __init__(self, artist, title, year):
self.artist = artist
self.title = title
self.year = year
# echivalentul toString() din Java... |
0c9f6504178e37ce9caa4876762cf630ac937e3c | RodrigoRossetti/URI-OJ | /Volume 10 (1000 - 1099)/1060/1060.py | 131 | 3.859375 | 4 | #!/usr/bin/env python3
total = 0
for i in range(6):
k = float(input())
if k >= 0: total += 1
print(f"{total} valores positivos") |
bb93a02d771ec0bc4aaab617d663f43268723c5e | Waptor/phone-number-wifi-brute-forcer | /phone.py | 1,600 | 3.640625 | 4 | import os
import subprocess
import csv
import argparse
# to do: make sure the CSV has correct city names
# to do: input validation
city = 'NA'
state = 'NA'
exchanges = []
# set up command line arguments
parser = argparse.ArgumentParser(description='Enter your city and state abbreviation and this script will brute f... |
303951aecf2344bfc31cbf785933dda7fd3496b6 | zhangchizju2012/LeetCode | /101.py | 992 | 3.875 | 4 | #!/usr/bin/env python2
# -*- coding: utf-8 -*-
"""
Created on Tue Dec 13 20:16:08 2016
@author: zhangchi
"""
class TreeNode(object):
def __init__(self, x):
self.val = x
self.left = None
self.right = None
class Solution(object):
def helpCompare(self,left,right):
if left is None... |
8aff43c8833b1e52df0a0ba8e04ca6f689fb3e54 | rharish101/cs251 | /160552_a3/q1.py | 2,179 | 3.5625 | 4 | #!/usr/bin/env python
from __future__ import print_function
if hasattr(__builtins__, 'raw_input'):
input = raw_input
import argparse
# Base conversion
def base_conv(string, base):
output = 0
base_pow = 1 # Stores powers of the base
negative = 1 # 1 if no. is +ve, -1 if -ve
if string[0] == '-'... |
90167ea1d9589a06923cde25b38426950dd03905 | CodingFairy1/Guessing-Game | /guessing_game.py | 1,151 | 4.0625 | 4 | """
Python Web Development Techdegree
Project 1 - Number Guessing Game
--------------------------------
For this first project we will be using Workspaces.
NOTE: If you strongly prefer to work locally on your own computer, you can totally do that by clicking: File -> Download Workspace in the file menu after you for... |
2093d6b037b7209dd459cc1b5caa09c719c5ce15 | suryapython/loop | /demo7.py | 171 | 4 | 4 | total=int(input("enter total:"))
if total>360:
print("First class")
if total>=300 and total<360:
print("Second class")
if total <300:
print("Third class")
|
98c8fe942c3c9001ebe1c09a398951f0c31db54c | abhisek08/conditional-statements-and-loops | /even and odd.py | 352 | 4.28125 | 4 | '''
Write a Python program to count the number of even and odd numbers from a series of numbers.
Sample numbers : numbers = (1, 2, 3, 4, 5, 6, 7, 8, 9)
Expected Output :
Number of even numbers : 5
Number of odd numbers : 4
'''
numbers = (1, 2, 3, 4, 5, 6, 7, 8, 9)
c,d=0,0
for i in numbers:
if i%2==0:
c+=1
... |
5edf6846ce0ce429001034efbefcd11dd1953421 | crispto/algorithm | /jianzhi/src/list_remove.py | 981 | 3.9375 | 4 | class Node:
def __init__(self, data):
self.value =data
self.next = None
def show(self):
cur = self
while cur:
if cur.next != None:
print(cur.value, end='->')
else:
print(cur.value)
cur =cur.next
def remove(head... |
448acf93af788d974242c8b67a5e4de41b45d581 | armage17/Python-various-classes | /cs3100 Homework02/nthnumeric.py | 810 | 3.875 | 4 | from math import *
def homos(S,f):
"""String homomorphism wrt lambda f
homos("abcd",hm) --> 'bcde' where hm = lambda x: chr( (ord(x)+1) % 256 )
"""
return "".join(map(f,S))
def nthnumeric(N):
"""Assume that Sigma is {0, 1}. Produce the Nth string in numeric order, where N >= 0.
Idea : Given N,... |
0459c406ad3fef95614e91b5558012e1d58c7048 | eszepto/tictactoe_cli | /ttt_oop_with_designpattern.py | 4,155 | 3.953125 | 4 | import random
class Tictactoe():
def __init__(self):
self.board = Board()
self.players = [Player("O"), Player("X")]
self.outputter = Outputter()
self.current_player = random.randint(0,1)
def playgame(self):
self.outputter.print("player0's marker is O \nplayer1's marker... |
c1a7b2a8d98871c5f05923d43108aac1ae593a4e | sunflower0309/pytest | /DataStructure/SingleLinkedList.py | 5,123 | 3.828125 | 4 | import sys
class Node(object):
"""定义节点"""
def __init__(self, elem,index=None):
self.elem = elem
self.index=index
self.next = None
def get_elem(self):
return self.elem
class SingleLinkList(object):
"""单链表操作"""
def __init__(self, node=None):
"""初始化"""
... |
257b8187b1bcbc71cab3f479f510384972e7dbe4 | wonyeonglee/studyCT | /DFS&BFS/DFSPractice1.py | 741 | 3.578125 | 4 | #음료수 얼려 먹기
#얼음틀 크기 입력 받기
n,m = map(int,input("얼음 틀 크기").split())
#얼음틀 모양 입력 받기
graph = []
for i in range(n):
graph.append(list(map(int,input("얼음틀 모양"))))
print(graph)
def bfs(x,y):
#얼음틀을 벗어나면
if(x<0 or x>=n or y<0 or y>=m):
return False
#아직 방문하지 않았다면
if(graph[x][y]==0):
graph[x][... |
c9841ae1756603e361c84b448402c34512e3e973 | Rybak-a87/practice-first_steps | /Task/Tasks OOP/oop.py | 8,049 | 3.609375 | 4 | from time import time
def timeTest(func):
start_time = time()
func()
finish_time = time()
print(f"------------------------\nВремя выполнения программы: {finish_time - start_time} сек.")
# ---------Задание 1------------------------
class LittleBell:
@staticmethod
def sound():
... |
fd4696191c0230fdffb7f4e5beab06d357576ea8 | panjimassaid/Tugas-Pratikum-Alpro | /DataMahasiswa.py | 1,317 | 3.703125 | 4 | print("------------DATA MAHASISWA--------------\n")
Login=str(input("Hai apakah kamu berkuliah di Universitas Mulawarman? y/n "))
while Login=="y":
DataMahasiswa={
"Nama Mahasiswa": str(input("MASUKKAN NAMA ANDA: ")),
"NIM Mahasiswa": int(input("MASUKKAN NIM ANDA: ")),
"Universitas Mahasiswa": "Universitas ... |
a9f16f992b52e1ab11e8fbc018cd490278b03871 | niilohlin/Langan.py | /langan.py | 3,115 | 3.703125 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
# This prgam analyzes a text and tries to
# guess what language it is written in
def analyze(text):
"""Calculate the letterfrequency of each letter in
a string, and return it.
"""
return n_grams(text, 1)
def n_grams(text, n):
res = {}
for i in ran... |
c7596ab653696445502b326c84ea961bc7861f2e | PabloMessina/Competitive-Programming-Material | /Solved problems/kattis/MoneyForNothing/generator.py | 187 | 3.515625 | 4 | import random
m = 20
n = 20
minx = 1
maxx = 10
miny = 1
maxy = 10
print(m, n)
for _ in range(m+n):
x = random.randint(minx, maxx)
y = random.randint(miny, maxy)
print(x, y)
|
ddbfabce46328d069f0e898a1204db309b19920a | lizenghui1121/DS_algorithms | /名企真题/华为/2020.07.15提前批-给定距离的不同走法.py | 1,204 | 3.84375 | 4 | """
给定距离,并给出各种步长, nums[0]....nums[n-1],请问有多少种走法(不考虑走路顺序),先走短的,再走长的,步长互异
示例:
输入
4
1 2
输出:
3
1 + 1 + 1 + 1 = 4
1 + 1 + 2 = 4
2 + 2 = 4
@Author: Li Zenghui
@Date: 2020-07-23 10:50
"""
def route_count(nums, distance):
def dfs(path, begin, nums, path_value, target):
nonlocal res
if path_value == target... |
adc0c28798e2d3b3399ec9d79bf321bbb7f8e416 | EuonChou/MyLeetCode | /Top Interview Question/zy_13_Roman to Integer.py | 612 | 3.546875 | 4 | # Given a roman numeral, convert it to an integer.
# Input is guaranteed to be within the range from 1 to 3999.
class Solution:
def romanToInt(self, s):
"""
:type s: str
:rtype: int
"""
dic = {'I' : 1,
'V' : 5,
'X' : 10,
'L' : ... |
d2d17dcc67ac194f994060a3e8986b10dc34b6f1 | kwaper/iti0102-2018 | /ex15_solitaire/cards.py | 5,590 | 3.84375 | 4 | """Cards module that contains Card and Deck classes."""
from itertools import zip_longest
import random
class Card:
r"""
Card class representing a playing card.
Unicode values used for suits:
Clubs '\u2663' (♣)
Spades '\u2660' (â™ )
Diamonds '\u2666' (♦)
Hearts '\u2665' (♥)
... |
490b61d0df17e926b7ce2bf938431ae07d0f7a99 | vijay8451/myhack | /myfile.py | 733 | 3.953125 | 4 | import string
#def mycompany(name):
# for n in name:
# if n not in string.ascii_letters:
# raise CompError("This is not correct company")
#
# print(name)
#
#class CompError(Exception):
# def __init__(self,code):
# self.code = code
#if __name__ == '__main__':
#
# try:
# n... |
2dac0a3a3965c84fed7ef2c4f96b21e179feba86 | imvivek71/Python-complete-solution | /Task3PatternFun/PatternByAnshu.py | 441 | 3.96875 | 4 | """""
*
*
* * *
* * *
* * * * *
"""
row = int(input("enter the number of row "))
row = int(row/2)+1
for i in range(row+1):
for k in range(row-i):
print(" ",end="")
for j in range(2*i-1):
print("*",end="")
print("\n")
if i<row:
for k in range(row - ... |
e6e650c2fecd4db230c48fa993ed72acc6550b97 | fletchc/rookount | /maxgen.py | 902 | 3.9375 | 4 | from rookount import *
import random
rookNumbers = []
rookCounts = []
def insertBoard(board):
count = getRookCount(board)
if count in rookNumbers:
rookCounts[rookNumbers.index(count)] += 1
else:
rookNumbers.append(count)
rookCounts.append(1)
for i in range(1,10):
found = 0
... |
2b715fb624968726756bd282fc46db6f6b1c3543 | golam-saroar/Python_Learning | /SentDex/Intermediate/enumerate.py | 393 | 4.375 | 4 |
'''
The enumerate function returns a tuple containing the count,
and then the actual value from the iterable.
'''
example=['left','right','up','down']
for i,j in enumerate(example):
print(i,j)
#That iterable can be a dict:
example_dict = {'left':'<','right':'>','up':'^','down':'v',}
for i,j in enumerate(example... |
b79e80b080961e07947bf75bc5347a2ee937fcce | zerocod3r/InterviewQuestions | /Tree Data Structure/preorder_traversal.py | 796 | 4.1875 | 4 | # Given a binary tree, return the preorder traversal of its nodes’ values.
# Example :
# Given binary tree
# 1
# \
# 2
# /
# 3
# return [1,2,3].
# Using recursion is not allowed.
# Definition for a binary tree node
# class TreeNode:
# def __init__(self, x):
# self.val = x
# self.left = None... |
f632eeb87e1f8816e115edddd0eb708f1f8c63d9 | wxzoro1/MyPractise | /python/liaoscode/property.py | 1,244 | 3.828125 | 4 | '''s = Student()
s.score = 123 #可以任意修改'''
'''class Student(object):
def get_score(self):
return self.__score
def set_score(self,value):
if not isinstance(value,int):
raise ValueError('Score must be integer!')
if value < 0 or value > 100:
raise ValueError('Score mu... |
150ecd94ec438006efa644f565a7f1cbc82eeb87 | Win-Htet-Aung/kattis-solutions | /basketballoneonone.py | 149 | 3.53125 | 4 | a = 0
b = 0
c = input()
for i in range(0, len(c), 2):
if c[i] == 'A':
a += int(c[i + 1])
else:
b += int(c[i + 1])
print('A' if a > b else 'B')
|
38229782a9766e6417b9753bf79cc531fb51fca1 | n0thing233/n0thing233.github.io | /noodlewhale/Facebook/面试前过的题/116. Populating Next Right Pointers in Each Node.py | 556 | 3.90625 | 4 | # bfs not working because follow up is O(1) space
# 每一层看做linked-list,因为已经establish next了。第一层建立第二层,第二层建立第三层
class Solution:
def connect(self, root: 'Node') -> 'Node':
if not root:
return
node = root
while node.left:
most_left = node.left
while node.next:
... |
e15b9185e9c602cda06553aa7dc9aca671acdf6f | PythonStudy/CorePython | /Exercise/Chapter8/8_4_PrimeNumbers.py | 861 | 4.5 | 4 | #coding=utf-8
"""
Prime Numbers. We presented some code in this chapter to determine a number’s largest factor or if it is prime. Turn this
code into a Boolean function called isprime() such that the input is a single value, and the result returned is True if
the number is prime and False otherwise.
"""
def i... |
cad9fc9f233c051ea7ad14daf0b5259591bce898 | reinimaurer1/catam-julia | /1a/LU with pivot/swapRows.py | 405 | 4.15625 | 4 |
# we write a function that swaps rows u and v of some matrix A
def swapRows(A, u, v):
# we get the size of A
n, m = len(A), len(A[0])
# we initialize B to zero
B = [[0] * m for i in range(n)]
# we copy all entries from A to B but swap rows u and v
for i in range(n):
k = i
if k == u:
k = v
elif ... |
64c7aaf5efd23e449e549389e9f37f8e277fe033 | AKLeee/LeetCode_OJ | /Group_Anagrams#88/GroupAnagrams.py | 436 | 3.59375 | 4 | class Solution(object):
def groupAnagrams(self, strs):
dic = {}
result = []
for item in strs:
sortStr = ''.join(sorted(item))
if sortStr in dic:
dic[sortStr].append(item)
else:
dic.update({sortStr:[item]})
for key, value in dic.iteritems():
if len(value) > 0:
value.sort()
result.a... |
e9270961016e540a8c64adc5451b64a181c81571 | machiscorstia/python | /Base de datos/Query.py | 320 | 3.53125 | 4 | import sqlite3
Conexion = sqlite3.connect("Jugador")
Puntero = Conexion.cursor()
Puntero.execute("SELECT * FROM Jugadores WHERE Puntaje > 10")
Resultado = Puntero.fetchall()
print(Resultado)
for i in Resultado:
print("Nombre:", i[0], " Contraseña:", i[1], " Puntaje:", i[2])
Conexion.commit()
Conexion.close()
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.