blob_id stringlengths 40 40 | repo_name stringlengths 5 119 | path stringlengths 2 424 | length_bytes int64 36 888k | score float64 3.5 5.22 | int_score int64 4 5 | text stringlengths 27 888k |
|---|---|---|---|---|---|---|
619d472babe28a2b1b577f5b2edcd1787319015b | Dan-Freda/python-challenge | /PyBank/main.py | 2,911 | 3.828125 | 4 | # Py Me Up, Charlie (PyBank)
# Import Modules/Dependencies
import os
import csv
# Initialize the variables
total_months = 0
net_total_amount = 0
monthy_change = []
month_count = []
greatest_increase = 0
greatest_increase_month = 0
greatest_decrease = 0
greatest_decrease_month = 0
# Set path to csv file
budgetdata_cs... |
6d801c0c47cc82cfc27305b341cf93fd98c23d99 | sagarsharma6/Python | /Assignment7.py | 549 | 4.125 | 4 |
#Ques 1
d={'1':'abc','2':'def','3':'ghi','4':'jkl'}
for key in d:
print(key,d[key])
#Ques 2
dic={}
dic2={}
for i in range(3):
name=input("Enter name of student: ")
print("Student",name,":")
for marks in range(3):
s=input("Enter subject: ")
m=int(input("Enter marks: "))
dic2[... |
1d74bf7c4a91ece932509e867a361e83985ff548 | trunghieu11/PythonAlgorithm | /Contest/Codeforces/Codeforces Round #313 (Div. 1)/B.py | 527 | 3.59375 | 4 | __author__ = 'trunghieu11'
def check(first, second):
if first == second:
return True
if len(first) % 2 == 1:
return False
half = len(first) / 2
return (check(first[:half], second[half:]) and check(first[half:], second[:half])) or (check(first[:half], second[:half]) and check(first[half... |
0b6f31cd241f134ffc6830374d42d1b7286722dc | sathishmtech01/pyspark_learning | /scripts/spark/dataframe/spark_df_schema_specify.py | 1,269 | 3.671875 | 4 | # Import data types
from pyspark.sql.types import *
from pyspark.sql import Row,SparkSession
import os
os.environ['SPARK_HOME'] = "/home/csk/sparkscala/spark-2.4.0-bin-hadoop2.6/"
spark = SparkSession \
.builder \
.appName("Python Spark SQL basic example") \
.config("spark.some.config.option", "some-value")... |
ec014aec05eecb32dc63928acb64d7f5b0b3db38 | ohmygodlin/snippet | /leetcode/00547friend_circles.py | 1,222 | 3.703125 | 4 | M = [[1,1,0],
[1,1,0],
[0,0,1]]
class UnionFind:
parent = {}
size = {}
cnt = 0
def findCircleNum(self, M):
"""
:type M: List[List[int]]
:rtype: int
"""
self.cnt = len(M)
for i in range(self.cnt):
self.parent[i] = i
self.size[i] =... |
03f8ad9e173fc903bbb81effcf65747cbb0b320a | santiagbv/AlgorithmicToolbox | /Week3-Greedy-algorithms/largest_number.py | 277 | 3.59375 | 4 | #Maximum Salary
import functools
def compare(elem1, elem2):
if elem1 + elem2 > elem2 + elem1:
return -1
else:
return 1
n = int(input())
A = input().split(' ')
A.sort(key=functools.cmp_to_key(compare))
ans = ''
for i in A:
ans = ans + i
print(ans) |
c439f7645b94d7b2f44396c2fb54348da04bf6e4 | IrynaDemianenko/Python_Intro_Iryne | /max_in_row.py | 1,062 | 3.90625 | 4 | def max_in_row(table):
max_element = 0
for row in table:
if table[row]>=table[row+1]:
max_element += table[row]
return max_element
"""
Дан двумерный массив(список списков, таблица) размером n x m.
Каждая строка состоит из m элементов, всего n строк.
Верните списо... |
3bcb0bec3709cbf1b37e6de063fdcb017c7e88cc | michaellu4527/python_step_49 | /Step49.py | 170 | 3.546875 | 4 | import bubblesort
list1 = [67, 45, 2, 13, 1, 998]
list2 = [89, 23, 33, 45, 10, 12, 45, 45, 45]
print (bubblesort.bubbleSort(list1))
print (bubblesort.bubbleSort(list2)) |
2df4ae6515a7ae1224ecfb588cb32612f0e2dab3 | miggleliu/leetcode_my_work | /037_sudoku_solver.py | 2,008 | 3.78125 | 4 | class Solution(object):
def solveSudoku(self, board):
"""
:type board: List[List[str]]
:rtype: None Do not return anything, modify board in-place instead.
"""
# return a list containing all the possible valid digits for a grid
def valid_digits(row, col):
... |
39c14a596ee9aa10a3f4cc00bc17ba7a609cfee3 | saetar/pyEuler | /not_done/euler_160.py | 977 | 3.640625 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
# Jesse Rubin
"""
Factorial trailing digits
Problem 160
For any N, let subset_sums(N) be the last five digits before the trailing zeroes in N!.
For example,
9! = 362880 so subset_sums(9)=36288
10! = 3628800 so subset_sums(10)=36288
20! = 2432902008176640000 so subset_sums(... |
c6e5680eee86da2157f13f51de66166c365ec1f9 | meimeilu/python | /152-ex.py | 427 | 3.71875 | 4 | def print_line(char,times):
print(char * times)
def print_lines():
"""打印单行分隔线
:param char 打印的字符参数
:param times 打印出来的次数
"""
row = 0
while row <= 5:
print_line("+",50)
row += 1
# print_lines()
def print_liness(char , times):
row = 0
while row <= 5:
... |
8f9bd84f165ff4400179ed0cc7b607e3af32c4e1 | huangjiadidi/dfdc_deepfake_challenge | /training/pipelines/random_walk.py | 1,778 | 3.875 | 4 | import numpy as np
import random
part_id = []
# for i in range(9):
# part_id.append(i)
"""
define part id:
top-left = 0 - top-right = 1
\ /
left-eye = 2 - right-eye = 3
\ /
| nose = 4 |
... |
75c3458878138203396dd9cf02665d7e4b85f2b0 | Ritvik19/CodeBook | /data/Algorithms/Memoization.py | 1,051 | 3.953125 | 4 | import time
class Memoize:
def __init__(self, f):
self.f = f
self.memo = {}
def __call__(self, *args):
if not args in self.memo:
self.memo[args] = self.f(*args)
return self.memo[args]
def factorial(k):
if k < 2:
return 1
return k * fact... |
261ce8f630820632021e5bbc8c1e9df01fd5a70c | TheMaksoo/Computer-Engineering-and-Science | /Exercise_1.py | 437 | 4.15625 | 4 |
# list of employees
employees = ("Max","Naru","Smol","Ginger","Devil","Bitz","Bear","Ruka","Khael","LRavellie")
# Prints list of employees
print(employees)
print("--------------")
# sorts employees alphabetical
Sortedemployees = sorted(employees)
# Prints employee list in alphabetical order
print(Sortedemployees)
p... |
75878c5d76b2f6fa4e59ab98daf21701249faaa0 | Jongyeop92/BoardGameAI | /Othelo/OtheloBoard.py | 4,639 | 3.609375 | 4 | # -*- coding: utf8 -*-
import sys
sys.path.append("../Board")
from Board import *
BLACK = 'B'
WHITE = 'W'
class OtheloBoard(Board):
def __init__(self, width, height, FIRST=BLACK, SECOND=WHITE):
Board.__init__(self, width, height, FIRST, SECOND)
self.blackCount = 2
self.whiteCount = 2... |
6ad58d93a43c7a44d57b2064eed887b8ace8afca | c4rl0sFr3it4s/Python_Basico_Avancado | /script_python/randint_input_usuario_condicao_composta_028.py | 538 | 4.03125 | 4 | '''randomize um valor inteiro entre (0, 5) entre com o valor do usuário
e mostre se o valor randomizado for igual ao do usuário, VENCEU, ou PREDEU'''
from random import randint
from time import sleep
computador = randint(0, 5)
print('{:-^40}'.format('JOGO DA ADIVINHAÇÃO'))
usuario = int(input('Digite um número de [0, ... |
6cc148c48488f10c692fb8583fa676d7b9ad2293 | minhazalam/py | /py dict fun and files/programs/var_scope.py | 744 | 4.03125 | 4 | # About : In this program we will se the scope resolution of variable
# * global variable
# * local variable
# Define square funcions
def square(num) :
sq = num * num
return sq
# Add sum of square fxn
def sum_of_square(fn, sn, tn) :
x = square(fn) # called square function
y = square(sn) # called squar... |
39e95e01e176fcc0b3552d50c9c7d11c51eeead7 | qeedquan/challenges | /dailyprogrammer/164-easy-assemble-this-scheme-into-python.py | 1,686 | 3.9375 | 4 | #!/usr/bin/env python
"""
Description
You have just been hired by the company 'Super-Corp 5000' and they require you to be up to speed on a new programming language you haven't yet tried.
It is your task to familiarise yourself with this language following this criteria:
The language must be one you've shown intere... |
d4560415ae445bf0776d75b1a774f36e6526160a | Ronaldlicy/Python-Exercises | /PythonExercise38.py | 1,165 | 4.1875 | 4 | # There are two players, Alice and Bob, each with a 3-by-3 grid. A referee tells Alice to fill out one particular row in the grid (say the second row) by putting either a 1 or a 0 in each box, such that the sum of the numbers in that row is odd. The referee tells Bob to fill out one column in the grid (say the first co... |
337583c1e1a1bbb1e8f5296a9141b7f4082255cb | SergeKrstic/show-case | /HorizonCore/Graph/GraphNodeNav.py | 1,565 | 3.609375 | 4 | from HorizonCore.Graph.GraphNode import GraphNode
class GraphNodeNav(GraphNode):
"""
Graph node for use in creating a navigation graph. This node contains
the position of the node and a pointer to a BaseGameEntity... useful
if you want your nodes to represent health packs, gold mines and the like
... |
7bb96f989316b89c9f263a38c342ec562484b756 | bhagavantu/PlacementManagement | /source/placement.py | 4,329 | 4.125 | 4 | IT_companies={"Accenture":6.7, "Mindtree":7, "Apple":8.5, "Infosis":8}
core_companies={"Bosch":7.2, "Texas Instruments":8, "Siemens":8.5, "Schnieder":7.8}
companies={"Accenture":6.7, "Mindtree":7, "Apple":8.5, "Infosis":8, "Bosch":7.2, "Texas Instruments":8, "Siemens":8.5, "Schnieder":7.8}
class PlacementManagement:... |
0d9978191ae42332c7b098542a87d436dc7c359b | chengke07/MyPython | /wintest1.py | 1,080 | 3.5625 | 4 |
import tkinter as tk
# 创建窗体
window = tk.Tk()
def call():
global window
window.destroy()
def main():
global window
# 设置主窗体大小
winWidth = 600
winHeight = 400
# 获取屏幕分辨率
screenWidth = window.winfo_screenwidth()
screenHeight = window.winfo_screenheight()
# 计算主窗口在屏幕上的坐标
x = i... |
65768c24f811faa8f754cbf8860f6f77632b2f5a | Tirhas-source/PyPoll | /main.py | 2,301 | 3.765625 | 4 | import os
import csv
election_data = os.path.join("election_data.csv")
election_output = 'election_output.txt'
# A list to capture the names of candidates
total_votes = 0
candidates_name = []
each_vote = []
percent_vote = []
with open(election_data, newline = "") as csvfile:
csvreader = csv.reader(csvfile)
... |
38f89c6b5bdaa173c9395d41f23d557493461d21 | Nexuist/Cellular-Conquest | /src/BaseClasses.py | 3,835 | 3.6875 | 4 | import pygame, math
class Coordinates:
def __init__(self, x, y):
self.x = x
self.y = y
def __str__(self):
return "(%s, %s)" % (self.x, self.y)
def __eq__(self, other): # Called by python to test equality
return True if (self.x == other.x and self.y == other.y) else False
... |
7073b92e05a67956bd79839908e4b82a6a021ffc | perhansson/rasp-pi | /flash-led.py | 899 | 3.765625 | 4 | import RPi.GPIO as GPIO
import time
import string
GPIO.setmode(GPIO.BCM)
led_green = 18
led_red = 22
GPIO.setup(led_green,GPIO.OUT)
GPIO.setup(led_red,GPIO.OUT)
while(True):
print("Tell me how many times to blink:")
s = input("How many times to blink the green LED? ")
print(s)
n_green_blink = int(s)... |
999beb6ab7e774b62a16801e2248bf48bddb91ce | zoeechengg/text-mining | /analyze_data.py | 2,136 | 3.921875 | 4 | import string
import nltk
from nltk.sentiment.vader import SentimentIntensityAnalyzer
def process_file(filename, skip_header):
"""Makes a histogram that contains the words from a file.
filename: string
skip_header: boolean, whether to skip the Gutenberg header
returns: map from each word to the numbe... |
6a4491aeab30266fee782daa94c1032193ee5316 | narendraparigi1987/python | /exercises/Exceptions_1.py | 159 | 3.6875 | 4 | try:
a = int(input("Tell me one number: "))
b = int(input("Tell me another number: "))
print("a/b = ", a/b)
except:
print("Bug in user input.") |
f52f4b028644a7d7dee9e12ced267ecc54b64bb4 | chrisbubernak/ProjectEulerChallenges | /63_PowerfulDigitCounts.py | 416 | 3.65625 | 4 | # The 5-digit number, 16807=7^5, is also a fifth power. Similarly, the 9-digit number, 134217728=8^9, is a ninth power.
# How many n-digit positive integers exist which are also an nth power?
def solve(n):
finds = 0
for i in range(1, n):
for j in range(1, n):
power = i ** j
if len(str(power)) == j... |
4609b5a3c01b544bcf14a9cdc89da77f3f19b369 | clivejan/python_fundamental | /exercises/ex_6_6_polling.py | 314 | 3.828125 | 4 | favourite_languages = {
'jen': 'python',
'sarah': 'c',
'edward': 'ruby',
'phli': 'python',
}
names = ['clive', 'sarah', 'david']
for name in names:
if name in favourite_languages.keys():
print(f"{name.title()}, thank you to response the poll.")
else:
print(f"Hi {name.title()}, please take the poll.")
|
e11ed34881624105d4e7bb09a33fb0763e6e2ebd | ValerieNayak/CodingInterview | /sorting_searching/quick_sort.py | 1,028 | 3.921875 | 4 | # Valerie Nayak
# 7/29/2020
# Quick Sort
# not complete yet
def quicksort(arr, left, right):
print(arr)
print('left', left)
print('right', right)
if left < right:
arr, mid = partition(arr, left, right)
print('mid', mid)
arr = quicksort(arr, left, mid-1)
arr = quicksort(... |
1b29c2e0c533a76d456fb52e297deda7a18d159f | yogi-katewa/Core-Python-Training | /Exercises/Deepak/Class and Object/p1.py | 413 | 3.984375 | 4 | class Basic(object):
#initialize the variables
def __init__():
print("Constructor Called...")
#get Data From User
def get_String(self, arg):
self.arg = arg
#Print the variable of Class
def print_String(self):
return self.arg.upper()
obj = Basic(word)
#takes inp... |
92eebf7e1791929540026f1430f34eb5a580b9c5 | yangxiyucs/leetcode_cn | /leetcode/07. reverse Int.py | 408 | 3.53125 | 4 | #反转int 数字
class Solution(object):
def reverse(self, x):
"""
:type x: int
:rtype: int
"""
#pop operation:
y, rev =abs(x), 0
boundary = 2**31-1 if x > 0 else 2**31
while y != 0:
rev = rev * 10 + y%10
if rev > boundary:
... |
075df3b0d465c7d0f5c5637275a198d59529d260 | kirkwood-cis-121-17/exercises | /chapter-8/ex_8_2.py | 1,179 | 3.875 | 4 | # Programming Exercise 8-2
#
# Program to total all the digits in a sequence of digits.
# This program prompts a user for a sequence of digits as a single string,
# calls a function to iterates through the characters and total their values,
# then displays the total.
# Define the main function
# Defi... |
6c7d546c1d6ebe45cc0d2f1a19b3275f5a72cbb7 | FridayAlgorithm/JW_study | /Baekjoon/queue/2164.py | 458 | 3.75 | 4 | from collections import deque
N = int(input())
deque = deque([i for i in range(1, N + 1)])
while(not (len(deque) == 1)):
deque.popleft()
move = deque.popleft()
deque.append(move)
print(deque[0])
#디큐 정의 확인
#popleft() pop()을 하되 왼쪽부터 값을 뺀다.
#버리고 맨앞의 숫자를 뒤로 옮기기만 잘해주면 되는 문제
#디큐안쓰면 카드배열 생성하고 하는데서 시간초과오류 오... |
cc28e5de2953b0d64a4baff64d7a89af3e54e443 | ChangxingJiang/LeetCode | /1001-1100/1019/1019_Python_1.py | 715 | 3.703125 | 4 | from typing import List
from toolkit import ListNode
class Solution:
def nextLargerNodes(self, head: ListNode) -> List[int]:
stack = []
ans = []
idx = 0
while head:
ans.append(0)
while stack and head.val > stack[-1][0]:
ans[stack.pop()[1]] =... |
05597db6bc9e7dc82fe26219ff91be14a23cfc2b | mridul0509/Cyber-security | /Assignment3/5.py | 150 | 3.8125 | 4 | list=[1,1,2,3,3]
b=0
for x in list:
if ((list[x]==3)and(list[x+1]==3)):
print("True")
b=1
break
if(b!=1):
print("False")
|
8eac576e1e83dceb1266dc5e22b98d6c34dcc158 | leoelm/interview_training | /9.11.py | 823 | 3.9375 | 4 | from BinaryTree import BinaryTree
t = BinaryTree(val = 1)
t.left = BinaryTree(val = 2, parent = t)
t.right = BinaryTree(val = 2, parent = t)
t.left.right = BinaryTree(val = 3, parent=t.left)
t.left.left = BinaryTree(val = 4, parent=t.left)
t.right.left = BinaryTree(val = 3, parent=t.right)
t.right.right = BinaryTree(v... |
d4347e903e22532799055bb307576f7a776efffe | LukeBreezy/Python3_Curso_Em_Video | /Aula 14/ex057.py | 394 | 4.03125 | 4 | sexo = ''
while 'M' != sexo != 'F': # Enquanto a pessoa não digitar uma opção válida, o laço não para
if sexo != '':
print('{} não é uma opção válida, digite M para masculino ou F para feminino.\n'.format(sexo))
sexo = input('Qual é o seu sexo? [M/F]: ').upper()
if sexo == 'M':
print('Vo... |
bb1e22c7d5ddccdb909b0a667732b86c918ae581 | haidragon/Python | /Python基础编程/Python-08/文件/文件定位读写.py | 512 | 3.5625 | 4 | f = open("D:/Personal/Desktop/test.txt",'rb')
#读取3个字节
f.read(3)
print(f.tell())
#在读取3个字节的基础上再读取2个字节
f.read(2)
print(f.tell())
#将读取位置重新定位到开头第二个字节
f.seek(2,0)
print(f.tell())
#从第三个字节开始读取3个字节
temp = f.read(3)
print(temp)
print(f.tell())
#将读取位置重新定位到结尾前第三个字节
f.seek(-3,2)
print(f.tell())
#从第三个字节开始读取3个字节
temp = f.read()
pr... |
79725b7bfb5864695b91e20ac2524f0f0730ccf6 | slimgol/searchEngine | /ranker.py | 4,627 | 4 | 4 | '''
This program is made for Python3.
Description: Rank a list of URLS; Return the ranked list of urls.
Approach:
(Note that this progam needs to be modified; this approach is nowhere where optimal.)
Accept a list of strings (These strings will have already been normalized).
Accept a raw input search term.
Normaliz... |
7d10a63c410d07bbd6571fb51759309fa3d6bd4e | shubhdashambhavi/learn-python | /org/shubhi/general/arithmeticOperator.py | 172 | 3.84375 | 4 | a=10
b=5
print('Addition:', a+b)
print('Substraction: ', a-b)
print('Multiplication:', a*b)
print('Division: ', a/b)
print('Remainder: ', a%b)
print('Exponential:', a ** b) |
e6b664797a0cea9558e609e0e6a7a4771fa98258 | uditrana/crossyRoadGame-539-hw2 | /exercises.py | 4,217 | 3.671875 | 4 | '''
solutions.py
##############################################
hw2: CS1 Content Game
##############################################
Collaborators:
Eugene Luo: eyluo
Omar Shafie: oshafie
Udit Ranasaria: uar
Preston Vander Vos: pvanderv
##############################################
This CS1 content... |
76fe88f42fe99e96c36c21fd977c5f2985095e0c | CTEC-121-Spring-2020/mod7-lab2-Ilya-panasev | /Mod7Lab2.py | 2,011 | 3.578125 | 4 | """
CTEC 121
Ilya Panasevich
Module 7 Lab 2
Class demos
"""
""" IPO template
Input(s): list/description
Process: description of what function does
Output: return value and description
"""
from math import *
def main():
# string formatting
'''
x = 1
y = 2
z = 3
print("x: {0}, y: {1}, z: {2... |
1ffbea03a8213a5bddf5d21440faee1807d6a668 | shoshin-programmer/former_work | /company_to_mail_templating_only_designation.py | 1,183 | 3.5 | 4 | import pandas as pd
from mailmerge import MailMerge
def main():
csv_filename = input('Enter csv filename: ')
template_filename = input('Enter template filename: ')
output_folder = input ('Enter output folder name: ')
positions_needed = input('Enter Positions separated by comma (format important)... |
0dc626d36e1412a173c31bb7e5027812319c96f9 | ksreddy1980/test | /General/counter.py | 261 | 3.546875 | 4 | class Counter :
value = 0
def set(self,value):
self.value = value
def up(self):
self.value = self.value + 1
def down(self):
self.value = self.value - 1
count = Counter()
set,up,down = count.up, count.up,count.down
|
38fe3e0d10f01852e7d0c360472eba4222c0c4f8 | CarlZhong2014/Python | /exercise/Thread/InstanceThread2.py | 1,293 | 3.734375 | 4 | #coding=utf-8
#创建线程方法之二:创建线程实例,传入一个可调用的类对象(ThreadFunc)。
import time
import threading
class ThreadFunc(object): #创建一个ThreadFunc类
def __init__(self, func, args, name=''): #通过构造器将传入的函数等设置为类属性。
self.name = name
self.func = func
self.args = args
def __call__(self): #调用函数。
self.func(*self.args)
loops ... |
0f3c0d1dda4715a4c6a5c84bc11aa5de2cea48de | rodrigofurlaneti/python | /string2.py | 2,219 | 4.5625 | 5 | #1/use/bin/python3
def main():
s = 'ola String'
print("Upper => Todas letras da variaver fica em caixa alta")
print(s.upper())
print("Capitalize => Somente o primeiro caracter fica em letra caixa alta ")
print(s.capitalize())
print("Format => Inseri no texto a posição do dado, aonde tiver {} ou... |
916a9e73c8c0dfdf5ccbe91ab3c8d5e5dafea2af | entirelymagic/Link_Academy | /Python_Net_Programming/pnp-ex02/tickets/authentication_service.py | 360 | 3.875 | 4 | import json
def authenticate(user, password):
"""Authentication method, given a username and a password, will check in the current list for a match"""
with open("users.json") as file:
users = json.loads(file.read())
for u in users:
if u["username"] == user and u["password"] == password:
... |
7b39d820f64dda30094979846f99f4ff507e59c9 | UWPCE-PythonCert-ClassRepos/SP_Online_PY210 | /students/csimmons/lesson03/strformat_lab.py | 3,299 | 4.1875 | 4 | #!/usr/bin/env python3
# Craig Simmons
# Python 210
# strformat_lab: String Formatting Exercises
# Created 11/22/2020 - csimmons
# Task 1
# Transform ( 2, 123.4567, 10000, 12345.67) to 'file_002 : 123.46, 1.00e+04, 1.23e+04'
print('\nTask One Excercise: Use str.format()')
tuple1 = ( 2, 123.4567, 10000, 12345.67)
pri... |
33aa1648db18aa82328502155f9b22625b4613c8 | Elbrus1703/git | /введение в програмирование/rap.py | 470 | 3.75 | 4 | # -*- coding : utf-8 -*-
print u"здравствуйте! это магазин У Ашота"
print u" t1 яблоко == 25 сом "
t1 == 25 = int(raw_input(">"))
print u" t2 ручка == 10 сом "
t2 == 10 = int(raw_input(">"))
print u" t3 наушники == 100 сом "
t3 == 100 = int(raw_input(">"))
print u"выберите кол-во товара"
sum==u"к... |
1b297db09ad05a710a09be4fedbb7db07b1de81b | blaxson/myneuralnetwork | /network.py | 6,335 | 3.875 | 4 | import random
import numpy as np
# from graphics import *
""" class that is used for actual neural network functionality, some repr"""
class NeuralNetwork(object):
""" The list 'sizes' contains the num of neurons in the respective layers of
the neural network. If the list is [24, 16, 10], then it woul... |
a784d64505144902dbd5334572604905f7d98df4 | staals19/PythonProjects | /binarysort.py | 666 | 3.640625 | 4 | mylist = [1,2,3,4,5,6,7,8,9,10]
num = int(input("what number?"))
def findMiddle(list):
middle = float(len(list))/2
if middle % 2 != 0:
return list[int(middle + .5)]
else:
return list[int(middle)]
run = True
while run == True:
if int(len(mylist)) == 1:
if mylist == [num]:
... |
dcad90f8042195d0f5cc99d933236e3b7b843399 | Praneethrk/python_assignment | /Assn_3/member/member.py | 1,602 | 4.25 | 4 | '''
1. Make a class called Member. Create two attributes - first_name and last_name, and then create 5 more attributes that are typically stored in a Member profile, such as email, gender, contact_number, etc. Make a method called show_info() that prints a summary of the member’s information. Make another method called... |
07319f2c7d232c17aacb78757da27da615304817 | vanshdhiman86/TicTacToe | /tictactoe.py | 2,937 | 4 | 4 | board = [" " for x in range(10)]
def insert_letter(letter, pos):
board[pos] = letter
def spaceisfree(pos):
return board[pos] == " "
def printBoard(board):
print(" | | ")
print(" " + board[1] + " | " + board[2] + " | " + board[3] )
print(" | | ")
print("------------")
print(" | | ... |
edadc0bdcd41d33ad99398a13f42a6bd449bc3a1 | prachinamdeo/Basic-Programs | /prime_no.py | 180 | 3.84375 | 4 | def prime(n):
c=0
for i in range(1,n+1):
if n % i == 0:
c=c+1
if c == 2:
return True
else:
return False
n=int(input("Enter no. "))
res = prime(n)
print(res) |
4c0b86f556b1bf21c848f542d970f2365db3d192 | PIYUSH-KP/Training_with_Acadview | /assignment15_regex/regex.py | 2,546 | 3.5625 | 4 | import re
# Q.1- Extract the user id, domain name and suffix from the following email addresses.
# emails = "zuck26@facebook.com" "page33@google.com"
# "jeff42@amazon.com"
# desired_output = [('zuck26', 'facebook', 'com'), ('page33', 'google', 'com'), ('jeff42', 'amazon', 'com')]
print('__'*50,'\nSOLUTION 1\n','__'*50... |
f4b746facd710897b5a24c2739f5d530da7a34e1 | scheidguy/ProjectE | /prob70.py | 1,783 | 3.859375 | 4 | # -*- coding: utf-8 -*-
"""
Created on Wed Sep 23 20:23:56 2020
@author: schei
"""
def calc_primes(below_num):
primes = [2] # first prime (and only even prime)
for num in range(3, below_num, 2): # skip even numbers
if (num+1) % 1000000 == 0: # prog report for big prime calculations
pri... |
aa9c0bc669d88d62e18c95312cb0d04fea558840 | aaryalanchaster/PythonPrograms | /TURTLE/pattern4.py | 723 | 3.921875 | 4 |
from turtle import Turtle, Screen
MIN_COLOR = 5
MAX_COLOR = 255
COUNT = 150
ANGLE = 5
STARTING_LENGTH =
LENGTH_INCREMENT = 2
N = 6
def draw_polygon(turtle, size):
angle = 360 / N
for _ in range(N):
turtle.forward(size)
turtle.left(angle)
screen = Screen()
screen.co... |
a36b25bef1ab986d41bf7bdb83b5fb1b2519a37d | NallamilliRageswari/Python | /Happy_Number_Recursion.py | 428 | 4.125 | 4 | #Happy number - when sum of number is equal to 1 or 7 .
#program for happy number with recursion.
n=int(input("Enter a number : "))
sum1=0
def Happy(n):
sum1=0
if(n==1 or n==7):
return ("Happy number")
elif(n<10):
return("Not a Happy Number")
else:
while(n>0):
... |
bf27525f8294bcc1d2e74ed5688a88d0ceea520f | kobewangSky/LeetCode | /384. Shuffle an Array.py | 825 | 3.578125 | 4 | import random
class Solution:
def __init__(self, nums):
self.ori = nums
def reset(self):
return self.ori
"""
Resets the array to its original configuration and return it.
"""
def shuffle(self):
ramdom_times = random.randrange(0, len(self.ori))
chac... |
2ec5da81a4f3a1d864056cd28cfe3da7b038db38 | dusjh/Python | /DemoRandom.py | 598 | 3.84375 | 4 | # DemoRandom.py
# 임의의 숫자 만들기
import random
# 0.0 ~ 1.0 사이의 값
print(random.random())
print(random.random())
# 2.0 ~ 5.0 사이의 값
print(random.uniform(2.0, 5.0))
# 임의의 정수 만들기
print([random.randrange(20) for i in range(10)])
print([random.randrange(20) for i in range(10)])
# 유일한 값이 생성
print(random.sample(range(20),10))
p... |
b2a293e3a4b70d46473c03a43ded1996257eee03 | kononeddiesto/Skillbox-work | /Module27/02_slowdown/main.py | 587 | 3.515625 | 4 | import time
from typing import Callable
def decorator(func: Callable) -> Callable:
"""
Декоратор, ожидание в 2 секунды
:param func:
:return:
"""
def wrapped() -> None:
start = time.time()
time.sleep(2)
result = func()
end = time.time()
timing = round(en... |
0ce725d322499a7fb81f409cb3b2c40c9e34fb3e | aanchal1234/Assignment1 | /assignment7.py | 1,679 | 4.0625 | 4 | # Write a function"perfect"() that determines if parameter number is a perfect number.use this function in a program determines and print all the perfect numbers between 1 and 1000.
p = []
def perfect():
for x in range(1, 1000):
li = []
sum = 0
for y in range(1, x):
if (x % y == ... |
098816a9a74846cc3dde4d7c5537cf98907eb8ed | AKDavis96/Data22python | /Classes/Class.py | 544 | 3.703125 | 4 | class Dog:
animal_kind = "Dolphin" # class variable
def bark(self): # method (a function in a class)
return "woof"
# print(Dog().animal_kind)
# print(Dog().bark()) with brackets you have instantiated it
# print(Dog())
# print(Dog.bark) prints memory location
Myles = Dog()
Osc... |
1a1d7f1acc562a40541c0d2babbbfa4b0ad33349 | Cosdaman/BSYS2065-Lab | /Lab7/LAB7Q9-8.py | 511 | 4.125 | 4 | # Write a function that removes all occurrences of a given letter from a string.
def removeletter(stringthing,letterthing):
x = int(len(stringthing))
newstring = ""
for i in range(x):
if letterthing != stringthing[i]:
newstring = newstring + stringthing[i]
else:
pas... |
b070e6d6cb3bc52234d2638b13e4c40ac3fee566 | ryanjmack/MITx-6.00.1x | /week2/exercises/guess_my_number.py | 1,103 | 4.4375 | 4 | """
Created on Wed Jun 7 09:36:06 2017
@author: ryanjmack
In this problem, you'll create a program that guesses a secret number!
The program works as follows: you (the user) thinks of an integer between 0 (inclusive)
and 100 (not inclusive). The computer makes guesses, and you give it input - is its guess\
too high... |
1a87aee981ea8ac587d87db4247cb54f3d92109d | TogrulAga/Numeric-Matrix-Processor | /Topics/Custom generators/Fibonacci sequence/main.py | 272 | 4 | 4 | def fibonacci(n):
previous = 0
before_previous = 0
for i in range(n):
next_element = previous + before_previous
yield next_element
before_previous = previous if i != 1 else 0
previous = next_element if next_element != 0 else 1
|
81639399eb83541e3c4e653d0a11c5d8455d1600 | julesdesplenter/1NMCT2-LaboBasicProgramming-julesdesplenter | /week4_lijsten/week1_intro/oefening9.py | 269 | 3.59375 | 4 |
# a = int(input("geef mij een nummer "))
#
# uitkomst = ((a * 10) + a) + ((a*100)+(a*10)+a) + a
#
# print("{0}".format(uitkomst))
a = int(input("geef mij een nummer "))
nummer = str(a)
n1 = nummer + nummer
n2 = nummer + nummer + nummer
print(a + int(n1) + int(n2))
|
7b83d4397930fa6873a82b8311d294f9e490d369 | sylviadoce/HCS_Chess_Lab_08 | /SylviaCopyButton.py | 2,748 | 4 | 4 | # HCS Lab 04
# Name: Sahil Agrawal
#
# This module creates the Button class.
from graphics import *
class Button:
"""A button is a labeled rectangle in a window. It is activated or deactivated with the activate()
and deactivate() methods. The clicked(p) method returns true if the button is active and p is in... |
91562f36b088a9ad356222414b95860e12eb0329 | lbuchli/telan | /interpreter.py | 9,561 | 3.5625 | 4 | #!/usr/bin/env python3
import lexer
import parser
###############################################################################
# Command Representation #
###############################################################################
def print_err(position, me... |
6a1c9e49189c4a742fbf7120b2e3ecd400cd1635 | jeremiedecock/snippets | /science/physics_python/kinematics/finite_difference_method.py | 710 | 3.578125 | 4 | # -*- coding: utf-8 -*-
# Copyright (c) 2010 Jérémie DECOCK (http://www.jdhp.org)
from common.state import State
name = 'Finite difference method'
class Kinematics:
def __init__(self):
pass
def compute_new_state(self, state, acceleration, delta_time):
"Compute the forward kinematics with f... |
3fd1e061e643125303aec25b7b681a8590457d5c | lanners-marshall/Graphs | /projects/graph/src/no_bokeh/adventure/item.py | 676 | 3.578125 | 4 | class Item:
def __init__(self, name, description):
self.name = name
self.description = description
def on_drop(self):
print(f'player has dropped {self.name}')
def __str__(self):
return str(f"{self.name}")
class Treasure(Item):
def __init__(self, name, description, score_amount):
super().__i... |
becf1767f745bade0404dd299210dbd74c34cb71 | ksm0207/Python_study | /Hello.py | 1,283 | 4 | 4 | def plus(x, y):
return x + y
def minus(x, y):
return x - y
def mul(x, y):
return x * y
def div(x, y):
return x / y
saved_value = 0
while 1:
select_number = int(input("숫자 입력 "))
saved_value = plus(saved_value, select_number)
print("저장된 값 = ", saved_value)
... |
6ccbbb304a2c90e6583861b687b1c497e4f5f154 | dodonmountain/algorithm | /2019_late/adv/playground/카드2.py | 187 | 3.578125 | 4 | from collections import deque
N = int(input())
cards = deque(range(1, N+1))
while True:
a = cards.popleft()
if not cards:
break
cards.append(cards.popleft())
print(a) |
01c3fa214321a7487ef4e1f3e83e2214f8382193 | TobiahRex/python-learn | /tutorial_lists/main.py | 808 | 4.09375 | 4 |
def main():
l = [1,2,3,4]
l.append('toby')
print(f'l: {l}', '\n')
l.clear()
print('clear(): ', l, '\n')
target = ['im the target']
l = target.copy()
print(f"""
target = ['im the target']
l = target.copy()
l: {l}
""")
l.extend([1, 2, 3])
print('l.extend([1, 2, 3]): ', l, '\n')
l = [3,2,6,... |
24d88d4945ebdb0f13d04cac9ffa13f8ba51ed69 | rajanmanojyadav/Tathastu_Week_of_code | /Day1/Program4.py | 504 | 4.25 | 4 | #Take 2 inputs, CostPrice,SellingPrice of a product for user and return following:
#1.profit from sell
#2.what should be the selling price if we increased th profit by 5%
costprice=int(input("Enter the cost price of the product: "))
sellingprice=int(input("Enter the sell price of the product: "))
profit=sellingprice ... |
44b30f1b165021bf6730c4e80a126e12163dfb5f | Scorch116/DeckofCards | /Deck.py | 464 | 4.375 | 4 | Importing modules tools
#random - used to select random in the data
# itertools , used to work with iterable in data sets
import random , itertools
#First the deck is made
deck = list(itertools.product(range(1,14),['Heart','Diamond','Club','Spade']))
#Use the random.shuffle to reorganise the order of item in deck
ra... |
1cd9eba7b0b78c0f3d029c4e262210b02c007be9 | donnell74/CSC-450-Scheduler | /gui/flow.py | 1,810 | 3.75 | 4 | def main():
subject = raw_input("Which type of constraint? [instructor / course] ").lower() #button
while (1):
if subject in ["instructor", "course"]:
break
else:
subject = raw_input("Invalid input. [instructor / course] ").lower()
if subject == "instructor":
... |
b17fef7e7e5a7cf94f58820426558aee5cbdfa6a | kaumnen/codewars | /[7 kyu] Find the capitals.py | 90 | 3.859375 | 4 | def capitals(word):
return sorted([x for x in range(len(word)) if word[x].isupper()])
|
adfc2ab73d65a3b8c2113d55d52f60497d42c2e4 | HOTKWIN/Algorithm-diagram | /快速排序.py | 1,657 | 3.578125 | 4 | #分而治之,D&C
class parctice(object):
def sum_DC(self,arr):
if len(arr) == 0:
return 0
elif len(arr) == 1:
return arr[0]
else:
tmp = arr.pop(0)
return tmp+self.sum_DC(arr)
def numOfList_DC(self,arr):
if len(arr) == 0:
retu... |
fb6a7d8ff81309dcfaa28f701b23c112154a12ef | Icetalon21/Python_Projects | /random_list/list.py | 429 | 3.96875 | 4 | import random
tenRandom = random.sample(range(0, 100), 10)
print ("Every element: ", tenRandom)
print ("Even Index: ", tenRandom[0::2])
myList = list()
for i in tenRandom:
if i % 2 == 0:
myList.append(i)
print("Every even: ", myList)
reverseList = list(reversed(tenRandom)) #non-destructive
print("Reverse... |
fc3960c0b69cc3adfb64e71ae760fc9088a12464 | saurabhkmr707/Word_Game | /test.py | 1,399 | 3.625 | 4 | import tkinter as tk
class Example():
def __init__(self):
self.root = tk.Tk()
# self.table = tk.Frame(self.root)
# self.table.pack(fill="both", expand=True)
self.entry_vals = [[0 for i in range(4)] for i in range(10)]
self.rows = []
for row in range(10):
... |
5b043ebf41b031775ca7d4279580f6d189c2d112 | treuille/multiplication-battleship | /streamlit_app.py | 5,479 | 3.84375 | 4 | import streamlit as st
import random
from typing import Set, Tuple
from streamlit.session_state import SessionState
Point = Tuple[int, int]
Points = Set[Point]
# What I'm trying to do here is have the state reset if either the board
# size of number of ships changed. In order to do so, I've added this
# initialized f... |
64237b744bfd8c3b27af56f759db5d8e4123059c | dashayudabao/practise_jianzhioffer | /jianzhi_offer/day1_二维数组中的查找.py | 1,191 | 3.703125 | 4 | # Author: Baozi
#-*- codeing:utf-8 -*-
"""题目描述
在一个二维数组中(每个一维数组的长度相同),每一行都按照从左到右递增的顺序排序,每一列都按照从上到下递增的顺序排序。
请完成一个函数,输入这样的一个二维数组和一个整数,判断数组中是否含有该整数
"""
import random
array = [[1,2,8,9],[2,4,9,12],[4,7,10,13],[6,8,11,15]]
target = random.randint(1,20)
# target = 14
print("array :",array)
print("target :",target)
# 二维行列式的行
r... |
4babd09df7470dfde4b4993f095cc78bdb04e66a | MthwBrwn/owasp_research_demo | /build_db.sh | 500 | 3.5625 | 4 | #!/usr/bin/python3
import sqlite3
db = "./students.db"
conn = sqlite3.connect(db)
c = conn.cursor()
cmd = "CREATE TABLE students (Name TEXT, Last TEXT)"
c.execute(cmd)
conn.commit()
data = [
("Robert", "Tables"), ("Toby", "Huang"), ("Hannah", "Sindorf"),
("Daniel", "Frey"), ("Ray", "Ruazol"), ("Roger", "Huba"),... |
d4f2c07738e084c013018d62b6ca173364530420 | mindovermiles262/projecteuler | /001.py | 514 | 4.15625 | 4 | """"
Project Euler Problem 1
@author: mindovermiles262
@date: 2018.01.18
Problem:
If we list all the natural numbers below 10 that are multiples of 3 or 5, we
get 3, 5, 6 and 9. The sum of these multiples is 23.
Find the sum of all the multiples of 3 or 5 below 1000.
"""
def multiple35(max):
to... |
de5046c3c097aa3d4113f44fb92654c9c4a67e9a | tzhou2018/LeetCode | /doubleHand/345reverseVowels.py | 1,813 | 3.59375 | 4 | '''
@Time : 2020/3/15 16:19
@FileName: 345reverseVowels.py
@Author : Solarzhou
@Email : t-zhou@foxmail.com
'''
"""
使用双指针,一个指针从头向尾遍历,一个指针从尾到头遍历,当两个指针都遍历到元音字符时,交换这两个元音字符。
为了快速判断一个字符是不是元音字符,我们将全部元音字符添加到集合 HashSet 中,从而以 O(1) 的时间复杂度进行该操作。
时间复杂度为 O(N):只需要遍历所有元素一次
空间复杂度 O(1):只需要使用两个额外变量
"""
class Solution(object):
... |
80034cd7c74a44311efc584a0f8a384bbb62f148 | jmctsm/Python_03_Deep_Dive_Part_04_OOP | /Section_06_Single_Inheritance/05 - Delegating to Parent.py | 6,133 | 3.75 | 4 | def line_break():
x = 0
print("\n\n")
while x < 20:
print("*", end="")
x += 1
print("\n\n")
line_break()
class Person:
def work(self):
return 'Person works...'
class Student(Person):
def work(self):
result = super().work()
return f'Student works... and ... |
916cb5435053cac29dc738bdf6d10e6e58a67afc | nithesh712/python-programs | /med.py | 3,331 | 4.15625 | 4 | num = float(input('Enter a Number: '))
if(num > 0):
print('Even Number it is', num)
elif(num == 0):
print('Its a Zero')
else:
print('Negative number it is', num)
num = float(input('Enter a Number: '))
if(num % 2 == 0 and num != 0):
print(f'It is Even number {num}')
elif(num == 0):
print('It is Zero... |
66d5f7f6a18cf06d1a47e04d45359831116a8145 | fanxiao168/pythonStudy | /AIDStudy/01-PythonBase/day18/exercise02.py | 1,379 | 3.53125 | 4 | '''
1.获取可迭代对象中长度最大的元素(列表)
([1,1],[2,2,2,2],[3,3])
2.在技能列表中,获取所有技能的名称与持续时间与攻击力
3.在技能列表中,获取攻击力最小的技能
4.对技能列表根据持续时间进行降序排列
要求:使用两种方式实现ListHelper.py
内置高阶函数
'''
from common.list_helper import ListHelper
class Skill:
def __init__(self, id, name=None, atk=None, duration=Non... |
15aaf2930cbef513453dc6238ff3b6ba93baa307 | alecs396/Jumper-Game | /Jumper.py | 2,930 | 4.0625 | 4 | class Jumper:
"""A jumper is a person who jumps from aircraft. The responsibility of Jumper is to keep track of their parachute."""
def __init__(self):
self.chute = []
self.chute.append(r" ___ ")
self.chute.append(r" /___\ ")
self.chute.append(r" \ / ")
self.... |
e2bee9cec8148f2ee0c65aac3d56cda32707f403 | igorpsf/Stanford-cs57 | /2 Lecture.py | 1,893 | 3.9375 | 4 | from pip._vendor.distlib.compat import raw_input
# a = [0,1,2,3,4]
# a[0]=8
# print(a[0]) # 8
# print(a[0:2]) # [8, 1]
# print(a[:2]) # [8, 1]
# print(a[2:4]) # [2, 3]
print(list(range(4))) # [0, 1, 2, 3]
print(list(range(4,8))) # [4, 5, 6, 7]
print(list(range(1,13,2))) # [1, 3, 5, 7, 9, 11]
#... |
611a2f811b6dac9c70ed5de7834362b397b5c9ea | codeartisanacademy/caapygame | /platformer/jumping/player.py | 1,433 | 3.703125 | 4 | import pygame
RED = (255, 0, 0)
SCREEN_WIDTH = 800
SCREEN_HEIGHT = 600
class Player(pygame.sprite.Sprite):
def __init__(self):
""" Constructor function """
# Call the parent's constructor
super().__init__()
# Create an image of the block, and fill it with a color.
# Thi... |
d736b315ca0e391f07046128196c94ea79ff3fb5 | quisitor/CMIT-135-40D_WEEK-3 | /voting_test.py | 926 | 4.40625 | 4 | """
:Student: Craig Smith
:Week-3: Conditional Logic Programs
:Module: voting_test
:Course: CMIT-135-40D (Champlain College)
:Professor: Steve Giles
Purpose
-------
This module takes in a potential voter's age and determines if they are 18 or
older and able to legally vote.
Constraints
-----------
1. Prompt the user... |
ab5d362fdf8ba636277b2414e30499ea6a64c949 | ajinkyavn1/hacking-Scripts | /PortScanenr.py | 292 | 3.546875 | 4 | # !/user/bin/python
import socket
sock=socket.socket(socket.AF_INET,socket.SOCK_STREAM)
host='192.168.1.100'
port=135
def Scanner(port):
if sock.connect_ex((host,port)):
print("port %d is closed{port} ")
else:
print("Port %d is Open {port}")
Scanner(port) |
3c0efadd1ffb7dc5b856376b90abf790ef0d942f | Wim4rk/BTH-oopython | /kmom01/lab1/classes.py | 1,994 | 3.71875 | 4 | #!/usr/bin/env python3
# -*- coding: UTF-8 -*-
"""
Contains classes for lab1
"""
# from datetime import datetime
# import time
class Cat():
"""
Lab1
"""
_lives_left = 9
nr_of_paws = 4
def __init__(self):
""" Awaken the c-c-cat... """
self.eye_color = ''
self.name = '... |
4528ccc368d986e51c2d5c20460be8255b450881 | dona126/Python-Programming | /Basics/loop.py | 199 | 3.84375 | 4 | #for loop
myList=[1,2,3,"meera"]
for x in myList:
print(x)
#while loop
i=0
while(i<4):
print(myList[i])
i=i+1
#break : exit from the loop
#continue : flow goes to beginning of loop
|
0a134dec034fa6f40e2039826911ce134292f8bf | xynicole/Python-Course-Work | /W12/ex7frameDemo.py | 1,862 | 4.3125 | 4 | import tkinter
'''
Creates labels in two different frames
'''
class MyGUI:
def __init__(self):
# Create main window
self.__main_window = tkinter.Tk()
# Create two frames, for top and bottom of window
self.__top_frame = tkinter.Frame(self.__main_window)
self.__bottom_frame = tkinter.F... |
567cbcc2a5bc59fabf57e326e30e02c9055c2b2b | hamza-yusuff/Python_prac | /Inter advanced threading python stuff/metaclasses.py | 935 | 3.65625 | 4 |
#using __new__
class players(object):
_number=0
def __new__(cls, *args,**kwargs):
instance=object.__new__(players)
if cls._number==2:
return None
else:
cls._number+=1
return instance
def __init__(self,fname,lname,score):
self.fn... |
2b504c510c635a472121bba4a6636ec64d96c80b | Ramaraj2020/100 | /Kadane's Algorithm/max-product-subarray.py | 709 | 3.671875 | 4 | def maxProductSubArray(arr, N):
globalMax = 1
localMax = 1
start = end = 0
localStart = localEnd = 0
for i in range(len(arr)):
if arr[i] > 0:
localMax *= arr[i]
if localMax > globalMax:
globalMax = localMax
start = localStart
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.