blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string |
|---|---|---|---|---|---|---|
b076e337190d36e2b0ac80b8a1b58e852d550199 | dojo-parana/dojo-parana | /teclado_celular/teclado.py | 1,655 | 3.828125 | 4 | #!/usr/bin/env python
# -*- coding=utf-8 -*-
import unittest
def testa_leitura(texto):
print(texto)
return 'Babaca'
def ler_frase(ler=input):
'''
>>> teste = 'a'
>>> print(teste)
a
>>> print(ler_frase(testa_leitura))
Escrever a frase:
Babaca
'''
recebe_frase = ler('Escrev... |
ce887af0b3196c306e5fdde8753f735aaa31f085 | bqmoreland/EASwift | /algs2e_python/Chapter 09/python/nonrecursive_hilbert.py | 4,419 | 3.90625 | 4 | import tkinter as tk
import math
def hilbert(canvas, color, depth, current_x, current_y, dx, dy):
""" Draw the Hilbert curve."""
# Make stacks to store information before recursion.
sections = []
depths = []
dxs = []
dys = []
# Determines which section of code to execute next.... |
c78bab559d5b6bb1d09d9cac060af40943ccb91b | dennis2030/leetcodeStudyGroup | /google-code-jam-2016/counting-sheep/john.py | 515 | 3.59375 | 4 | #!/usr/bin/python3
import re
def solve(N):
if N == 0:
return 'INSOMNIA'
digits = set()
number = N
while True:
for digit in str(number):
digits.add(digit)
if len(digits) == 10:
break
number += N
return number
def main():
T = int(input(... |
30bf6ac2b39240b7068ed6ee2dfd0be247529954 | iabrmv/egeBot | /decline.py | 638 | 3.75 | 4 | ### Здесь будет функция, которая склоняет слово word в соответствии с числительным number
### decline(21, 'балл') _____ 21 балл
### decline(32, 'балл') ______ 32 балла
### decline(65, 'балл') ______ 65 баллов
def decline(number, word):
if number in range(10, 20):
return(str(number) + ' ' + word + 'ов')
... |
8fb6f641c03a32a0991ac9b5095951380a17796b | BZhong7/merge_user_ids | /merge_user_ids.py | 2,191 | 3.890625 | 4 | # Brandon Zhong - Merge User IDs
# Main function that calls all other functions in order to merge the two lists together
# If there are no objects in existing_users, just merge new user objects within the list
# Otherwise merge the lists together, then merge objects together within the new list if needed
def merge_u... |
318ba90a3a5e8f2c30ce79c338640689e5e9636e | keis/omx | /omx/target.py | 1,710 | 3.515625 | 4 |
class Target(object):
'''Holds the data passed to a factory as 'name'
In general 'data' will be a list of objects created from other templates,
but may be string when mapped to a attribute or text()
During load the scratch property may hold the TemplateData that will be the next item.
'''
# ... |
b63df5bbe45cc3b373ac6e0f324ab5cdd7ee877f | adamcfro/code-abbey-solutions | /sum_in_loop.py | 207 | 4.1875 | 4 | def sum_in_loop(*args):
'''This function takes in any amount of numbers and sums them together.'''
total = 0
for num in args:
total += num
return total
print(sum_in_loop(1, 2, 3, 4)) |
8f544aff7ed8ebee1c1bdedae641b1434feed08f | DBJoran/Shinyhunter | /cropper.py | 3,208 | 3.671875 | 4 | import math
import cv2
"""
This function will crop a screenshot to your preferred area. The preferred area is decided by the mode that you use.
The following modes can be used:
- chat, the box where you will see 'Got away safely!' etc. This is the box you see when in battle.
- health, the box where your POKéMONS hea... |
bbdc17539e0d2464664afadd15bcbaa5395bc216 | Michael07220823/Tools | /Encrypt/encrypt & decrypt.py | 2,481 | 3.8125 | 4 | def encrypt_key_generate(num_key = int()):
from cryptography.fernet import Fernet
if num_key != int():
print("\n[INFO] Random generate key:")
for i in range(1, num_key + 1):
key = Fernet.generate_key().decode('utf-8')
print(str(i) + '. ' + key)
else:
key = Fe... |
3386c7f5c73252eace92a72cc8eb6565eff0016d | bij51247/atcoder-study | /atcoder_a/vanising_pitch.py | 247 | 3.515625 | 4 | V,T,S,D = map(int,input().split())
t_distance = V*T
s_distance = V*S
if D < t_distance:
print('Yes')
elif D >= t_distance and D <= s_distance:
print('No')
else:
print('Yes')
#模範回答
# print('Yes' if (D < V*T or D > V* S) else 'No') |
9c7d3c6ed9a94323f2c988a1c69ca20eead78fc9 | KzZe-Sama/Python_Assignment | /Data Types/Qn18.py | 227 | 4.0625 | 4 | # DATA
# Largest Number Finder
items=[300,500,600,800,900,1000,100,1500]
largestNum=0
for item in items:
# Control Statement
if largestNum<item:
largestNum=item
print(f"{largestNum} is the largest of them all.") |
62dddd58a9531078b5e2c089db5711c8019d84a9 | jpcornwell/advent-of-code | /4-2018/08-Day/py/2-part.py | 751 | 3.765625 | 4 | #!/usr/bin/env python3
with open('../input.txt') as f:
content = f.read()
def parse_node():
global nums
global index
node_value = 0
child_values = []
recurse_count = nums[index]
meta_count = nums[index + 1]
index += 2
for _ in range(recurse_count):
child_values.append(parse... |
2c06c1872f9ad80742a1bd2bd6416f952a0d435a | scriptk1tty/messinround | /piglatin.py | 173 | 3.828125 | 4 | def piglatin():
words = str(input("Ranslate-ay:")).split()
for word in words:
print(word[1:] + word[0] + "ay", end = " ")
print()
piglatin()
|
4b51736a9ee15c174165f0c8ae38e123c7fdaa84 | Binohow/Python-Crash-Course | /how5.py | 971 | 4.03125 | 4 | """ if语句 """
# %%
cars = ['audi', 'bmw', 'subaru', 'toyota']
for car in cars:
if car == 'bmw':
print(car.upper())
else:
print(car)
# %%
banned_users = ['andrew', 'carolina', 'david']
user = 'marie'
# %%
x = True
y = False
# %%
age = input("Enter your age:")
age = int(age)
if(age >= 18):
prin... |
7d2fd6fb711717aa826a5cf04bfb109049f60e22 | CrumbleZ/project-euler | /0065.py | 639 | 3.671875 | 4 | """
Problem:
Find the sum of digits in the numerator of the 100th convergent of the
continued fraction for e.
Performance time: ~0.0012s
"""
from fractions import Fraction
from timer import timer
from utils import sum_of_digits
timer.start()
a = [int(n / 3 * 2) if n % 3 == 0 else 1 for n in range(1, 101)... |
64b08b193b695d2346ccc9d3b035dce8b434b7b1 | chojiwon1727/lab_python | /lec03_function/function10.py | 1,029 | 4.125 | 4 | """
파이썬에서 함수는 1급 객체(first-class object)라고 부름
- 함수를 변수에 저장할 수 있음
- 매개변수(parameter)에 함수를 전달할 수 있음
- 함수가 다른 함수를 리턴할 수 있음
- 함수 내부에서 다른 함수를 정의할 수 있음
"""
def twice(x):
return 2*x
result = twice(100) # 함수 호출 -> 함수의 리턴값 저장
print(result) # 함수의 리턴값을 출력
double = twice # 함수를 변수에 저장
print(double)
result = double(11)
pri... |
18bd26033f05be57286bd0a52d130aa27d292cbc | Kaushik8511/Competitive-Programming | /Trees/LeftViewOfTree.py | 708 | 3.796875 | 4 | class Node:
def __init__(self,key=None,left=None,right=None):
self.key = key
self.left = left
self.right = right
def printleft(root,level,d):
if root is None:
return
if level not in d:
d[level]=root.key
... |
f0a1a6fa6b1510cff7b6f213a19791b730ec9a78 | danielefornaro/BitcoinBlockchainTechnology | /scripts/EC-7_10_F263_G3_4_N280.py | 1,838 | 3.515625 | 4 | #!/usr/bin/python3
# elliptic curve y^2 = x^3 + a * x + b
a = -7; b = 10
assert 4*a*a*a+27*b*b !=0, "zero discriminant"
# over prime finite field
prime = 263;
def checkPoint(P):
assert P[0] is None or (P[0]*P[0]*P[0]+a*P[0]+b) % prime == (P[1]*P[1]) % prime
# a given generator specifies the group order
G = (3, ... |
ef471c2f97cc7bf0b5ee77f04d4951fdb9e2ff51 | anandpandav786/My-Code-In-Python | /mapInLambda.py | 145 | 3.828125 | 4 | #Program to print square of nos between 1 to 10
list1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
list2 = list(map(lambda x: x*x, list1))
print(list2) |
1499cd81884c086c5ae33e8965f80411103c2e05 | notesofdabbler/reticulate_IndyUseR_sep2020 | /norvig_words.py | 2,439 | 3.640625 | 4 | #
# Function from Peter Norvig's notebook on How to do things with words
# https://github.com/norvig/pytudes/blob/master/ipynb/How%20to%20Do%20Things%20with%20Words.ipynb
#
# Made a few tweaks to enable calling from R through reticulate. Note those with comments starting with ***
#
import re
import math
import rando... |
f7042e84bea0d1e3cfc6f107c8206ea695940d19 | drforse/snake | /game/types/snake.py | 3,492 | 3.546875 | 4 | import turtle
from ..exceptions import *
import gc
import typing
class Snake:
def __init__(self, game, x: int = 0, y: int = 0, visible: bool = True, speed: int = 0, **kwargs):
"""
the Snake
:param x: x-coord of where the snake should appear
:param y: y-coord of where the snake shou... |
1c8e28b8d42be1a14ab4587d79105b9cb56775e1 | LewPort/game-of-shite | /20x20.py | 1,704 | 3.75 | 4 | #!/usr/bin/env python3
import random
import time
env = {}
def resetenv(env):
for y in range(0, 21):
for x in range(0, 21):
env[x, y] = ' '
def printenv(env):
for x in range(0, 21):
for y in range(0, 21):
print('|' + str(env[x, y]), end='')
print('|')
print... |
31e0563c5272ded32555e3b49c8389e91852e018 | AllenKll/getting-started-with-python | /week6/4.6.py | 948 | 4.375 | 4 | # 4.6 Write a program to prompt the user for hours and rate per hour using
# raw_input to compute gross pay. Award time-and-a-half for the hourly rate for
# all hours worked above 40 hours. Put the logic to do the computation of
# time-and-a-half in a function called computepay() and use the function to do
# the co... |
aa8b38dc414b0a1cf6a58310e2bdbc420f3db511 | Kimovac/proving-probability | /monty_hall.py | 835 | 3.609375 | 4 | import sys
import random
def monty_hall_probability(iterations, switch):
prize_count = 0
for i in range(iterations):
doors = [0, 0, 0]
doors[random.randint(0, 2)] = 1
pick = random.randint(0, 2)
if(switch):
doors.pop(pick)
doors.pop(doors.index(0))
pick = 0
if(doors[pick]):
prize_count += ... |
9e28762f149c9af80e5201b95dc9ec87259d3445 | Vith-MCB/Phyton---Curso-em-Video | /Cursoemvideo/Exercícios UFV/Lista 4/exer05 - ABC.py | 115 | 3.75 | 4 | a = int(input('Termo antecessor: '))
c = int(input('Termo sucessor: '))
b = (a+c)/2
print('Termo B: {}'.format(b))
|
0e691cc20678a85142bed5804c2cf3e091b20fe1 | michael-zero/estudo_pytista_kkk | /files.py | 752 | 3.5625 | 4 | ipsum_file = open('files/ipsum.txt')
#list
# ipsum_file.seek(0)
# lines = ipsum_file.readlines()
# print(lines)
#read lines
# for linha in ipsum_file:
# print(linha.rstrip())
# another way
# ipsum_file.seek(0)
# file_text = ipsum_file.read(10)
# print(file_text)
# print(len(file_text))
# ipsum_file.close()
#... |
6c0038a8b19317a0a766a4987aa4bd6fd6f7f648 | l593067749/learn-python | /www/number1/MethodTypeTest.py | 706 | 3.640625 | 4 | # -*- coding: UTF-8 -*-
'给实例或类绑定方法'
from types import MethodType
class MethodTypeTest(object):
__slots__ = ('setName','name','age') # 用tuple定义允许绑定的属性(方法)名称
pass
def setName(self,name):
self.name=name
methodTypeTest=MethodTypeTest()
methodTypeTest.setName=MethodType(setName,methodTypeTest,MethodTypeTest)#... |
e1dd63ca5b33fc5d75e0baf643cae08909861f98 | RishavMz/Programming_During_Leisure | /tictactoe.py | 7,506 | 4 | 4 | # Author : RishavMz
# A simple tic tac toe game
# Two options
# 1. Human vs Computer
# 2. Human vs Human
import random
player = 0
computer = 0
player1 = 0
player2 = 0
# This function checks if any player has won
def check(li):
for i in range(3):
if(li[i] == li[i+3] and li[i] == li[i+6]):
... |
53eb7d669ee68d4394cdf1bb8bd9cafcb1016c9c | mcfee-618/FluentAlgorithm | /01linkedlist/src/reorder.py | 1,557 | 3.796875 | 4 | class ListNode:
def __init__(self, val=0, next=None):
self.val = val
self.next = next
class Solution:
def reorderList(self, head: ListNode) -> ListNode:
"""
Do not return anything, modify head in-place instead.
"""
if head is None or head.next is None:
... |
044f6e42c2b3ac9e0ec9fdacb76c276f7b515be8 | benbauer14/turtle_race | /main.py | 1,956 | 4.03125 | 4 | from turtle import Turtle, Screen
import random
ben = Turtle("turtle")
june = Turtle("turtle")
max = Turtle("turtle")
ray = Turtle("turtle")
erica = Turtle("turtle")
ben.color("purple")
june.color("blue")
max.color("green")
ray.color("orange")
erica.color("red")
screen = Screen()
screen.setup(500, 400)
user_bet = sc... |
90108068eac2d62c6ac977c785c32fdcad0b7184 | OscarPerezGonzalez/python_examples | /Ejercicio 1/ejercicio1.py | 616 | 4.0625 | 4 | def isInt():
while True:
num = input('Escribe un numero entero entre 1 y 10: ')
try:
num = int(num)
if num < 1 or num > 10:
print('Valor fuera de rango: escribe un valor entre 1 y 10')
else:
return num
except ValueError:
... |
1d0e68fcc0b26e65a8f34c2e3bbce278d4525073 | wooseokoh/python | /python20/상속연습/상속정리문제1.py | 1,070 | 3.875 | 4 | class Person():
name = ''
age = 0
def work(self):
print('일하다')
def talk(self):
print('대화하다')
def __init__(self, name, age):
self.name = name
self.age = age
class Man(Person):
job = ''
car = ''
def event(... |
67d7e82571d243255b3e34b118814abff0479a49 | ECNU-1X/text-script | /FileEncoding/utf8Files.py | 2,796 | 3.6875 | 4 | """Function Declaratios.
Modify text file's encoding to utf-8. General for Chinese text files.
Common coding standard:
GB18030
GB2312
"""
__author__ = "Liu Kun"
__version__ = 0.1
import os
import queue
import time
import threading
import argparse
parser = argparse.ArgumentParser()
parser.add_argument("-d", ... |
a0ce558ce14be704c3b305bad1dcedfe10c71fd7 | lil-mars/pythonProblems | /LearningPython/OOP/oop/practicing.py | 878 | 3.578125 | 4 | class Player:
# Class object attributes
membership = True
def __init__(self, name='Anonymus', age=0):
if Player.membership:
self.name = name # Attributes
self.age = age
def shout(self):
print(f'my name is {self.name}')
def run(self, hello):
print(f... |
7a9daf393daf773d4212d8f5494a05eecf8917fb | Daniel-Choiniere/hackerRank_python | /print_function.py | 151 | 3.71875 | 4 | # Without using any string methods, try to print the following:\
# 123.....n, all on one line
n = 3
for i in range(1, n + 1):
print(i, end="")
|
8e0c1b46c67cda6872aaf47464c1b252c81d43c3 | brandonjyan/AlgorithmicToolbox | /week4_divide_and_conquer/3_improving_quicksort/sorting.py | 1,136 | 3.9375 | 4 | # python3
from random import randint
def partition3(array, left, right):
x = array[left]
j = k = left
for i in range(left + 1, right + 1):
if array[i] == x:
j += 1
array[i], array[j] = array[j], array[i]
elif array[i] < x:
j += 1
k += 1
... |
332906744ddb6b4568756b87e566e8699ef6055f | Koushika-BL/python | /combine 2 dict &add common values.py | 122 | 3.796875 | 4 | from collections import Counter
dict1={'a':12,'b':4}
dict2={'h':7,'b':5}
dict3=Counter(dict1)+Counter(dict2)
print(dict3)
|
6f9f0ea4c1ffb354d02c24b6bc218738aa3301bd | Hessupatteri/interest-py | /danielG.py | 1,119 | 3.9375 | 4 | # Orginal code written by Markus Sköld
# Welcome message.
print("Welcome, i can help you to calculate your rate and total money")
# Get user to tell us the amount of savings each year. Create variable and input.
yearlysavings = int(input("Tell me how much you will save each year by printing it in the terminal? "))
#... |
6b5ae2c245c132384756c884de7f36a76dc21904 | shankar7791/MI-10-DevOps | /Personel/Vinayak/Python/7 April/school.py | 1,270 | 3.546875 | 4 | class Student:
def __init__(self,name,rollno,m1,m2):
self.name=name
self.rollno=rollno
self.m1=m1
self.m2=m2
def accept(self,Name,Rollno,marks1,marks2):
ob=Student(Name,Rollno,marks1,marks2)
ls.append(ob)
def display(self,ob):
print("Name : ", ob.nam... |
56cdc8d38dca12e455e4fe94cbed378e4ecf2dd4 | ravulaprasad/python-tutorial | /lamda fucntion.py | 83 | 3.65625 | 4 | f=lambda x:'even' if x%2==0 else 'odd'
#calling block
k=f(int(input()))
print(k) |
4e49df3cdc2cb824b52c886a59430399a07aef99 | Hugens25/Coding-Challenges | /pairs_equal_10.py | 2,055 | 3.8125 | 4 | # Objective of this solution is to find pairs of integers in a list that
# equal 10. Bonus is to solve problem in linear time.
import random
# this list will store random values for our function
random_list = []
# seed the list with random values from 1 to 9
for i in range(10):
random_list.append(random.randint(... |
fa8b4b4cd29e62e1c5fb0d40e6e64f612416cb3f | sssurvey/Python-Intern-Assignment-2-Response | /task_2_sol/Answer.py | 3,462 | 3.671875 | 4 | # Haomin Shi
# 05/25/2018
# Response to the assignment 2, task 2
import mysql.connector
from intercom.client import Client
# intercom = https://github.com/intercom/python-intercom
import requests
from requests.auth import HTTPBasicAuth
"""
MySQL table overview
DROP TABLE IF EXISTS `user`;
CREATE TABLE `user` (
`id... |
0d2c3e8c94d0669633ab4e938014fc5018a221d1 | weekenlee/leetcode-c | /leetcodePython/leetcodePython/nqueues.py | 678 | 3.5625 | 4 | def solveNQueens(n):
"""
:type n :int
:rtype: List[List[str]]
"""
def isqueens(depth, j):
for i in range(depth):
if board[i] == j or abs(depth - i) == abs(board[i] - j):
return False
return True
def dfs(depth, row):
if depth == n:
... |
f0655fcd741e2b53a7ad429275ff18627d7e557e | dishasahu/dishaPythonAssignments | /exercise_ii_a/add_one.py | 333 | 3.75 | 4 | # -*- coding: utf-8 -*-
"""
Created on Tue Feb 12 15:41:01 2019
@author: abc
"""
num=int(input("enter the number"))
a=int(num%10+1)
rev=rev*10+a
num=num/10
b=int(num%10+1)
rev=rev*10+a
num=num/10
c=int(num%10+1)
rev=rev*10+a
num=num/10
d=int(num%10+1)
rev=rev*10+a
num=num/10
e=int(num%10+1)
rev=rev*10+a
num=num/1... |
e37c6971ec0f7b422b20fa1f420566e8479b128c | gott51010/goForIt | /code/preprocessing.py | 5,223 | 3.6875 | 4 | """数据预处理
"""
# 数据预处理 把不准确或不适用于模型记录的数据纠正或删除掉
from sklearn.preprocessing import MinMaxScaler
from sklearn.preprocessing import StandardScaler
import numpy as np
import pandas as pd
# 无量纲化,也称为数据的规范化,消除量纲影响后再进行接下来的分析。
# 在梯度和矩阵为核心的算法中 无量纲化可以加快求解速度
# 有一个特例是决策树和树的集成算法里 不需要无量纲化 决策树可以处理任意数据
# 线性的无量纲化包括去中心化处理 和缩放处理等
# 中心化处理 让... |
9eb50043172011e1aed70b52430d3aaa89d06d86 | Beck-Haywood/CS-1.2-Intro-Data-Structures | /sentence_generator.py | 1,880 | 3.625 | 4 | from dictogram import Dictogram
from histogram import read_word_file, make_histogram, random_word_frequency
from sample import sample_word
import random
import sys
def markov(words):
"""
"""
couple = []
#Creates a list of every couple in the corpus
for index in range(len(words)-1):
couple.ap... |
3fab9fa9d25b58f9a83c22bcb88ac4a8bac8cc37 | yxun/notebook | /python/leetcode/045_jump_game_ii.py | 1,362 | 3.765625 | 4 | #%%
"""
- Jump Game II
- https://leetcode.com/problems/jump-game-ii/
- Hard
Given an array of non-negative integers, you are initially positioned at the first index of the array.
Each element in the array represents your maximum jump length at that position.
Your goal is to reach the last index in the minimum number... |
77a17de6f9b09a6994f3831dc057e34e04ce1359 | joshuazd/rubiks | /rubiks.py | 5,724 | 3.8125 | 4 | def print_color(color):
if color[0] == ' ':
return [' ', ' ', ' ']
return ['\033[' + {
'R': '91',
'O': '33',
'Y': '93',
'G': '92',
'B': '94',
'W': '97'
}[i] + 'm' + i + '\033[0m' for i in color]
class Rubiks_Side():
... |
ae069690e3a3b18681dfec838cb3955649ec8f39 | Talol-efron/CodingBat | /example/sum3.py | 128 | 3.875 | 4 | def sum3(nums):
result = 0
for num in nums:
result = result + nums[num]
return result
print(sum3([1,2,3])) |
728575f79cb514ffce06d6a531f6eafc5e747547 | homerooliveira/Show-Me-The-Data-Structures | /problem2.py | 857 | 4.1875 | 4 | import os
from typing import List
import pprint
def find_files(suffix: str, path: str) -> List[str]:
"""
Find all files beneath path with file name suffix.
Note that a path may contain further subdirectories
and those subdirectories may also contain further subdirectories.
There are no limit to ... |
04fa4f4562dbe638953fcd84146c985f6441a5b3 | tainenko/Leetcode2019 | /leetcode/editor/en/[266]Palindrome Permutation.py | 964 | 3.734375 | 4 | # Given a string s, return true if a permutation of the string could form a
# palindrome.
#
#
# Example 1:
#
#
# Input: s = "code"
# Output: false
#
#
# Example 2:
#
#
# Input: s = "aab"
# Output: true
#
#
# Example 3:
#
#
# Input: s = "carerac"
# Output: true
#
#
#
# Constraints:
#
# ... |
88382b0d3865a23dd70b896583f5ab9c67be641b | charlesdebarros/CodeWars | /CodeWars_Python/string_repeat_python.py | 350 | 3.9375 | 4 | #!/usr/bin/env python
# Write a function called repeat_str which repeats the given
# string src exactly count times.
#
# repeat_str(3, "foo"); // "foofoofoo"
# repeat_str(1, "bar spam"); // "bar spam"
def repeat_str(repeat, string):
return string * repeat
print(repeat_str(4, 'a'))
print(repeat_str(3, 'hello ')... |
18b1be2e56456948b7460c0b175ff59039e41fb0 | zhang4ever/target_offer | /DeleteNodeInList.py | 2,379 | 3.953125 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
# @File : DeleteNodeInList.py
# @Time : 2018-04-01 22:28
# @Author : zhang bo
# @Note : 删除链表节点
"""
import time
class ListNode:
def __init__(self, val):
self.val = val
self.next = None
def __del__(self):
self.val = None
... |
f266c60279e870114caa5e58c5361469872371b0 | harbenml/advent-of-code-2020 | /puzzles/puzzle16.py | 5,092 | 3.703125 | 4 | from typing import List
from typing import Dict
from typing import Tuple
def get_data(filename: str) -> List:
with open(filename) as f:
data = f.read().split("\n\n")
data = [el.split("\n") for el in data]
return data
def parse_rules(rules: List) -> Dict[str, List[int]]:
y: Dict[str, List[int... |
14ec4dcb3c137bb8539cf5d36f9cbea704e5b7c7 | krnets/codewars-practice | /7kyu/Sum of Cubes/index.py | 487 | 4.09375 | 4 | # 7kyu - Sum of Cubes
""" Write a function that takes a positive integer n, sums all the cubed values from 1 to n, and returns that sum.
Assume that the input n will always be a positive integer.
sum_cubes(2)
> 9
# sum of the cubes of 1 and 2 is 1 + 8 """
def sum_cubes(n):
return sum(x ** 3 for x in range(n +... |
0d39e638cf65631f8e69cd1677dfc2af042526b7 | TheMoonlsEmpty/test | /类/类练习3.0.py | 573 | 4.03125 | 4 | # 设计 二维坐标 Point 类,使其可hash,并能判断2个坐标实例是否相等,实现2个坐标加减运算,以及判断2个坐标实例的大小
class Point:
def __init__(self, x, y):
self.x = x
self.y = y
def __str__(self):
return '{},{}'.format(self.x, self.y)
def __eq__(self, other):
return (self.x == other.x) and (self.y == other.y)
def __iad... |
a997fff1c38f70cf1435d3a1b33dbb3e821ae3f1 | vrtineu/learning-python | /variaveis_compostas/listas/ex088.py | 845 | 3.921875 | 4 | # Faça um programa que ajude um jogador da MEGA SENA a criar palpites. O programa vai perguntar quantos jogos serão gerados e vai sortear 6 números entre 1 e 60 para cada jogo, cadastrando tudo em uma lista composta.
from time import sleep
from random import randint
print(f'{"-"*30}\n{"Gerador de jogadas - Mega ... |
7acf90ba06b7105e91ccf725c2325242419136cc | alvxyz/PythonClass | /Struktur Data (Pak Bowo)/AlvianTeddyCahyaPutra_Jobsheet1_List/AlvianTeddyCahyaPutra_Jobsheet1_Soal3.py | 2,297 | 3.625 | 4 | # # cara primitif
# data = list(input("Masukan kata yang ingin dipecah: ").lower())
#
# nilai_vokal_a = 0
# nilai_vokal_i = 0
# nilai_vokal_u = 0
# nilai_vokal_e = 0
# nilai_vokal_o = 0
# nilai_non = 0
#
# for element in data:
# if element == "a" :
# nilai_vokal_a += 1
# elif element == "i" :
# ... |
6cc05a326cbd9b964bbc1f457c601e7ec362f216 | Hnomer/python_test_tasks | /task1/task1.py | 1,237 | 3.5 | 4 | import sys
import math
import functools
def OpenFile(path):
try:
with open(path, "r") as file:
return file.readlines()
except:
return ""
def Percentile(N, percent, key=lambda x:x):
if not N:
return None
k = (len(N)-1) * percent
f = math.floor(k)
c = math.c... |
dcbe4ad37e408a96f13a7c2553adc0c08b86828c | Eroica-cpp/LeetCode | /199-Binary-Tree-Right-Side-View/solution01.py | 1,558 | 4.25 | 4 | #!/usr/bin/python
# ==============================================================================
# Author: Tao Li (taoli@ucsd.edu)
# Date: Jun 11, 2015
# Question: 199-Binary-Tree-Right-Side-View
# Link: https://leetcode.com/problems/binary-tree-right-side-view/
# ===========================================... |
e194bfb274ff4f9e74cb10c467835e271db2a598 | elisio-ricardo/ExerciciosPythonCursoEmVideo | /CursoEmVideo/curso em video/ex96.py | 236 | 3.578125 | 4 | def area(larg, comp):
a = larg * comp
print(f'A area de um terreno {larg} x {comp} é de {a} m².')
print('Controle de Terrenos')
print('-' * 40)
l = float(input('Largura(m): '))
c = float(input('Comprimento(m): '))
area(l, c) |
0f5285b825487e9e017e723a5c702325d1ff48dc | 93fk/exercism | /python/pangram/pangram.py | 345 | 3.75 | 4 | def is_pangram(sentence):
sentence_lower = sentence.lower()
alphabet_string = 'abcdefghijklmnopqrstuvwxyz'
count = 0
alphabet_len = len(alphabet_string)
for letter in alphabet_string:
if letter in sentence_lower:
count += 1
if count == alphabet_len:
return True
el... |
2acb3527ac73fa2648a3d0f1053cc45458ae8539 | Mahbubul-Hasan/Python | /print/index.py | 572 | 4.03125 | 4 | print("Hello Python")
print(25)
print(30 * 10)
print("50 + 10 = ", 50 + 10)
print("Hello", "", "Word")
print("{0} - {1} = {2}".format(50, 10, 50 - 10))
num1 = 3.14387548253492
num2 = 73.852735912372
print('{0:.3f} + {1:.3f} = {2:.3f}'.format(num1, num2, (num1 + num2)))
print(f'{num1:.3f} + {num2:.3f} = {(num2 + ... |
fa01f1baa3c845f0ed933d456fa094e001714ae5 | RUPESH1439/Operating-System-Algorithms-In-Python | /fcfs/index.py | 1,116 | 3.65625 | 4 | class Process:
def __init__(self,name,arrival,burst):
self.name = name
self.arrival_time = arrival
self.burst_time = burst
def get_arrival_time(self):
return self.arrival_time
def get_burst_time(self):
return self.burst_time
def get_name(self):
return self.name
def set_starting(self,time):
self.start... |
dd1ba47633010926f56d9c2a23123fea4e17a02f | poojashahuraj/CTCI | /practice/practice/ArraysAndStrings/sub_array-with_sum_zero.py | 1,022 | 4.09375 | 4 | """
How to find if there is a sub array with sum equal to zero
There is whole set of array related questions which are based upon sub-array or only selective elements of array e.g.
from some range, this is one of such problem. Here you are given an array of positive and negative numbers,
find if there is a sub-array wi... |
71135bb910fcdd61709ea62ca9edbab161050228 | afcarl/miscPython | /FileIO.py | 931 | 4.46875 | 4 | import os #used later in the program..
#basic file IO
#writing to a file
test = open("test.txt","w")
test.write("testing...\n")
test.close()
#reading from a file
test = open("test.txt","r")
print test.read()
test.close()
#Note - if you open file with "w" for write it will create the file if it does not already exist... |
8ca6c8513459fd89b4ab86f0c57360aead38c408 | sai-byui/articles-and-resources | /Python/tutorials/OOP_Intro/Lesson1_Classes.py | 367 | 3.78125 | 4 | # Just a really simple one, acts more or less like a C++ struct - only has
# member variables. This allows you to put two (or more) related pieces of
# information into the same container.
class Rectangle:
def __init__(self, length, width):
self.length = length
self.width = width
rect1 = Rectangl... |
15317e98318e6360c51f860a7e315bb1524ff77a | zhukuixi/exercises | /ml/mywork/task4.py | 969 | 3.65625 | 4 | """
Task 4:
In this task we present a real life dataset in the form of a supervised classification problem.
This dataset contains 50 observations and one target variable.
What we are trying to predict here is that given these 50 metrics how likely is a user to click on a coupon.
Your task is the following:
Perform ... |
005d70912fa74cb0ea12437934fd5706e1e9149e | ayushiagarwal99/leetcode-lintcode | /leetcode/breadth_first_search/207.course_schedule/207.CourseSchedule_yhwhu.py | 2,173 | 3.671875 | 4 | # Source : https://leetcode.com/problems/course-schedule/
# Author : yhwhu
# Date : 2020-07-31
#####################################################################################################
#
# There are a total of numCourses courses you have to take, labeled from 0 to numCourses-1.
#
# Some courses may hav... |
d9fb018afcfaa417fa50d80a550c8b5fd74624ed | MichalHalucha/checkio.org | /checkio.org(Conversion-into-camelcase).py | 567 | 3.6875 | 4 | def to_camel_case(name):
x = name.split("_")
y = ""
for item in x:
item = item.title()
y = y + item
print(y)
return y
if __name__ == '__main__':
#These "asserts" using only for self-checking and not necessary for auto-testing
assert to_camel_case("my_function_name") == "My... |
a4817c26e37504a4dac3e2355dc57d744317f54a | nirvana9/py | /test/student.py | 486 | 3.8125 | 4 | #!/usr/bin/env python
# coding=utf-8
class Student(object):
def __init__(self, name, score):
self.name=name
self.score=score
def print_score(self):
print '%s: %s' %(self.name,self.score)
if __name__=='__main__':
bart = Student('Bart Simpson',59)
Lisa = Student('Lisa Simpson',87... |
15eb3f918a3f2fdcb0bfb833c0a378e8cc61ec9c | IshitaSharma3101/Python | /chapter_07/ques5.py | 98 | 3.921875 | 4 | n = int(input("Enter a number : "))
sum = 0
i=1
while i<=n:
sum += i
i+=1
print(sum) |
359485c221f14d8bc5affeaef1ce1f5af6ea6d3c | shubhamfursule/Temperature-Dictionary | /Temperature_dictionary.py | 565 | 3.859375 | 4 | week=['Sunday','Monday','Tuesday','Wednesday','Thrusday','Friday','Saturday']
a=[]
b=[]
temperature_dict={}
for w in week:
if w=='Sunday' or w=='Saturday':
temp=float(input(f"Please Enter temperature for {w}: "))
a.append(temp)
else:
b.append(float(input(f"Please Enter temperatu... |
9926b5f2c579efb28d3d5481310ffda059f92616 | DEVARUN98/pythonprog | /filtermapreduce/fil2.py | 1,240 | 3.53125 | 4 | employees=[
{"e_id":1000,"e_name":"ram","salary":25000,"department":"testing","exp":1},
{"e_id":1001,"e_name":"ravi","salary":22000,"department":"ba","exp":1},
{"e_id":1002,"e_name":"raj","salary":20000,"department":"mrkt","exp":1},
{"e_id":1003,"e_name":"nikil","salary":26000,"department":"developer","... |
a8955a7d7f84107a0d6ef3c3be353865f53fd2ed | rosittaj/PETS | /main.py | 2,359 | 4.3125 | 4 | species_list = {'dog': 'dog', 'cat': 'cat', 'horse': 'horse', 'hamster': 'hamster'}
animal = {'Dog': [], 'Cat': []}
class Pet():
def __init__(self, species, name=''):
if species not in species_list:
print("\nspecies not in the species_list")
species_list[species] = name
... |
5cb8997b7010e128224fda7d3fb08d18f3cd53bd | ryaoi/battleship | /battleship.py | 2,301 | 3.875 | 4 | from random import randint
class bcolors:
HEADER = '\033[95m'
OKBLUE = '\033[94m'
OKGREEN = '\033[92m'
WARNING = '\033[93m'
FAIL = '\033[91m'
ENDC = '\033[0m'
BOLD = '\033[1m'
UNDERLINE = '\033[4m'
board1 = []
board2 = []
for x in range(5):
board1.append(["O"] * 5)
board2.appe... |
a9d59d990b645e825a12b98abfc5d10469bacd0f | itsaimejia/metodos_numericos | /trapecio.py | 1,358 | 3.703125 | 4 | import numpy as np
from math import *
from sympy import *
import sys, getopt, argparse
def funcion(x):
return sin(3.1416*x)
def solucion(datos):
a=float(eval(datos[0]))
b=float(eval(datos[1]))
n=int(datos[2])
h = (b-a)/n
x = a
suma = funcion(x)
for i in range(0,n-1,1):
x+= h
suma+=2*funcion(x)
sum... |
e64e0aff6385ff5953656ae47d4e462e33206dff | kuzja111/Intro_to_CS | /ex5_matrix/wordsearch.py | 13,739 | 3.953125 | 4 | import sys
import os.path
WORD_FILE_ERROR = 'unable to find words list'
MATRIX_FILE_ERROR = 'unable to find matrix file'
DIRECTION_ERROR = 'invalid direction'
LENGTH_ERROR = 'Invalid number of arguments'
def word_file_locator(args):
"""
locates the word file
:param args: all arguments from ... |
8fb8790e8915849941e79fa89c35148cdef3a39c | hussainMansoor876/Python-Work | /untitled/file 4.py | 226 | 3.5625 | 4 | bicycles=['trek','cannonadle','redline','specialized']
print(bicycles)
print(sorted(bicycles))
bicycles.sort()
print(bicycles)
bicycles.sort(reverse=True)
print(bicycles)
bicycles.reverse()
print(bicycles)
print(len(bicycles)) |
0a5f6f73b2b6f7e22775c1a49b80c9ce0d6e44b4 | NicHagen/project_euler | /problem16.py | 202 | 4.09375 | 4 | """
2**15 = 32768 and the sum of its digits is 3 + 2 + 7 + 6 + 8 = 26.
What is the sum of the digits of the number 2**1000?
"""
num = 2**1000
sum = 0
for i in str(num):
sum += int(i)
print(sum)
|
e1d921715435c24875c291e233f31b23ffa7a039 | carlagouws/house-price-study | /GraphPlotter.py | 1,173 | 3.59375 | 4 | import csv
from datetime import datetime
from datetime import timedelta
import matplotlib.pyplot as plt
import numpy as np
# Converts a date string into date format
def convert_date(date_string):
string_format = '%d/%m/%Y'
datetime_object = datetime.strptime(date_string, string_format)
return datetime_obje... |
3b7b9b0394332678f9fc0ed7fa42372121361b3d | aidynkyzy/akerke | /9task3.py | 147 | 3.703125 | 4 | for s in range(int(input())):
s = input()
a = s.count("A")
b = s.count("D")
if a > b:
print("Anton")
else:
print("Danik") |
75f4bcac11a26b92f7ed6e35af0dc918522f3df0 | btlorch/license-plates | /src/ops.py | 2,596 | 3.875 | 4 | import tensorflow as tf
def conv2d(x, W):
"""
Returns a 2D convolutional layer with full stride.
"""
return tf.nn.conv2d(x, W, strides=[1, 1, 1, 1], padding="SAME")
def max_pool_2x2(x):
"""
Max-pooling over 2x2 blocks
"""
return tf.nn.max_pool(x, ksize=[1, 2, 2, 1], strides=[1, 2, 2,... |
71e625f2f9ed1d2133d62b1a5b6250ef8b0a2bfb | ksayee/programming_assignments | /python/CodingExercises/LeetCode1002.py | 1,300 | 3.96875 | 4 | '''
1002. Find Common Characters
Easy
Given an array A of strings made only from lowercase letters,
return a list of all characters that show up in all strings within the list (including duplicates).
For example, if a character occurs 3 times in all strings but not 4 times, you need to include that character three time... |
ce896304621ca91e120c7eeccdc18cdd79ecba1b | haohsun/TQC-Python | /PYD201.py | 127 | 3.96875 | 4 | # TODO
n = eval(input())
if n % 2 == 0 :
print(n, "is an even number.")
else:
print(n, "is not an even number.") |
89be9747fd60ed15b137bd6092e537d5d299cfed | srihariprasad-r/workable-code | /Practice problems/foundation/recursion/printkeypadcombinations.py | 500 | 3.515625 | 4 | def printkeypadcombinations(str,ans):
if len(str) == 0:
print(ans)
return
ch = str[0]
rest = str[1:]
chr_from_dict = dict[int(ch)]
for i in range(len(chr_from_dict)):
printkeypadcombinations(rest, ans + chr_from_dict[i])
dict = {
1 : 'abc',
2 : 'd... |
4eddfe9891408730e8015adf72a1a7c92cffe2c4 | IIKovalenko/Python_Study | /BasicSyntax.py | 5,974 | 3.5625 | 4 | import keyword
#******************************基础语法的练习***********************************
#字面字符串的级联
str = "this""is""String\n";
#r可以显示自然字符串
str0 = "this""is"r"String\n";
print(str);
print(str0);
#python中的变量不需要声明类型,他没有类型
#6个标准的数据类型Numbers数字 String字符串,List列表,Tuple元组,Sets集合 Dictionaries
#字典
#----------------------------... |
acc8afc0601bd0ddc9c28d05573cdf2ce5c52b68 | Reikonz/PythonLearning | /Basic Tutorial/loops.py | 1,027 | 3.953125 | 4 | #********for loops
primes = [2,3,5,7]
for prime in primes:
print(prime)
#prints out 0,1,2,3,4
for x in range(5):
print(x)
#prints out 3,4,5
for x in range(3,6):
print(x)
#prints out 3,5,7
for x in range(3,8,2):
print(x)
#********while loops
count = 0
while count < 5:
print(co... |
f07bc32b0df0fdf55921f0f4d226bb8f70770f74 | Swetha7Venkataraman/Project98 | /swapFiles.py | 370 | 3.671875 | 4 | def swapFiles():
file1=input("Enter the name of first file:")
file2=input("Enter the name of second file:")
with open (file1,'r') as a:
data_a=a.read()
with open (file2,'r') as b:
data_b=b.read()
with open (file1,'w') as a:
a.write(data_b)
with open (file2,'w') a... |
110272f4b553764c605f8b8f67b9621bd64f857e | IliaVakhitov/drafts | /Solved/pascaltriangle.py | 647 | 3.6875 | 4 | # Pascal's Triangle
from typing import List
class Solution:
def run(self):
res = self.generate(15)
for row in res:
print(row)
def generate(self, numRows: int) -> List[List[int]]:
res = []
res.append([1])
res.append([1,1])
for i in range(2... |
90c05b719fb809350fedb8a4dbd5f4438a14c05b | yongge666/advancePython | /Thread_sync.py | 689 | 3.75 | 4 | # coding:utf8
# 线程同步
# lock在同一个线程(函数)里面只能有一个acquire 和 release
# Rlock在同一个线程(函数)里面要有相同数目的acquire和release
from threading import Thread,Lock,RLock
total = 0
lock = RLock()
def add():
global total
global lock
for i in range(100000):
lock.acquire()
total += 1
lock.release()
def desc():
... |
f614139af6205b7be8cb81b3be0f06dfee624c78 | edu-athensoft/stem1401python_student | /sj200917_python2m6/day02_200924/dict_10_values.py | 438 | 3.734375 | 4 | """
dictionary values()
dict.values()
"""
daysdict = {
'MON': 'Monday',
'TUE': 'Tuesday',
'WED': 'Wednesday',
'THU': 'Thursday',
'FRI': 'Friday',
'SAT': 'Saturday',
'SUN': 'Sunday',
'OTH': 'Sunday'
}
print(daysdict.values())
print(type(daysdict.values()))
# list()
allvalues = list(d... |
79deeca4a8d61fb28e393629a37f87bc6a2df904 | MarcerCyoon/ParticleSimulator | /animation.py | 3,883 | 3.703125 | 4 | import numpy as np
import matplotlib.pyplot as plt
import matplotlib.animation as animation
import random
class Simulation:
def __init__(self, numParticles, velocities, positions, masses, coeff=3):
self.numParticles = numParticles
self.velocities = np.zeros((numParticles, 2))
self.positions = ... |
60607dbf0edf31106cb02863be60147b1fa8832d | 1deterministic/Simple-Logical-Expression-Analyzer | /demo.py | 2,431 | 3.640625 | 4 | '''
Demo run for testing and, well, demonstration purposes
'''
# you can drop the slea folder on a python project and import it using
from slea import slea
# demo run
if __name__ == "__main__":
# some string to be evaluated
string = "!(a & ( b | !c ) & d)"
# values associated with the operands
oper... |
35c53d5514a376937c7fe6513005946eedc7a3d0 | VineetKhatwal/Python | /DataStructure/LinkedList/ModularNodeFromEnd.py | 1,327 | 3.9375 | 4 | class Node:
def __init__(self, data):
self.data = data
self.next = None
class LinkedList:
def __init__(self):
self.head = None
def printLinkedList(self, ll):
curr = self.head
while(curr):
print(curr.data, end=" ")
curr = curr.next
def i... |
70e0dd346831193f38347db8ce4b1e5320d3f638 | benjisidi/advent-of-code | /day1/fuelPart2.py | 402 | 3.609375 | 4 | import math
def getFuel(mass, totalFuel=0):
requiredFuel = math.floor(mass/3) - 2
if requiredFuel <= 0:
return totalFuel
else:
return getFuel(requiredFuel, totalFuel + requiredFuel)
return math.floor(mass/3) - 2
if __name__ == '__main__':
with open("./fuelInput.txt", "r") as f:
... |
fa7e92513ccb480eda7771281fb38b64d25a7347 | zmwangx/Project-Euler | /157/solution.py | 670 | 3.859375 | 4 | #!/usr/bin/env python3
import sympy
N = 9
def search():
count = 0
for v1 in range(N + 1):
for v2 in range(N + 1):
for n in range(max(v1, v2, 1), N + 1):
remaining = (2 ** (n - v1)) * (5 ** (n - v2))
a0 = 2 ** v1
b0 = 5 ** v2
... |
a521b1d9a959401706622576f4a495e1037d72bb | NPencheva/Python_Advanced_Preparation | /03_multidimensional_lists/2021.02_multidimensional_lists_exercises/03_Maximum Sum.py | 1,583 | 3.84375 | 4 | from sys import maxsize
number_of_rows, number_of_columns = [int(x) for x in input().split()]
matrix = []
for row_index in range(number_of_rows):
row = [int(y) for y in input().split()]
matrix.append(row)
max_3x3_square_sum = -maxsize
starting_row = 0
starting_column = 0
for row_index in range(number_of_ro... |
69963734df6fbbdf1f87cc11842567779e78d8b7 | ish-joshi/python-book-code | /book-code-python/getting-started/variables/accept-as-many-params.py | 1,033 | 4.53125 | 5 |
def do_math(operation, *nums):
"""By adding the * in front of nums, any number of arguements can be accepted
This is really useful, as they are converted to a tuple;
do_math('multiply', 1,2,3,4,5) -> Operation=multiply, Nums=(1, 2, 3, 4, 5)
"""
print(f"Operation {operation}, Nums {nums}")
i... |
2223db44b12523fc24deb0572ad33bf2d7b794a5 | soufuru/Python_textbook_summary | /chapter2/chapter2-4~.py | 687 | 3.875 | 4 | # chapter2-4 ~
#############################
####---ユーザーからの入力---####
#############################
# 時給計算プログラム
# 時給の入力
usr = input("時給はいくらですか")
jikyu = int(usr)
# 時間の入力
usr = input("何時間働きましたか")
jikan = int(usr)
#計算
kyuryo = jikyu * jikan
#結果を表示
fmt = """
時給{0}円で{1}時間働いたので
給料は、{2}円です。
"""
desc = fmt.format(jikyu,... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.