blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string |
|---|---|---|---|---|---|---|
44594dd1eb91304113d432342b7213fa27a078e8 | anouard24/problem-solving | /kattis/lastfactorialdigit.py | 133 | 3.515625 | 4 | f = [1, 1, 2, 6, 4]
for _ in range(int(input())):
n = int(input())
if n <= 4:
print(f[n])
else:
print(0)
|
db48d8ac2cca76dc8209e391180aadb7c82d75e6 | anouard24/problem-solving | /codeforces/gyms_2018/word.py | 250 | 3.765625 | 4 | # problem name: Word
# date: 10/11/2018
ins = str(input())
up = 0
low = 0
for i, s in enumerate(ins):
if s.isupper():
up += 1
else:
low += 1
if up > low:
ins = ins.upper()
else:
ins = ins.lower()
print(ins)
|
5b7e1b3b75edc1d0616c1f152539945a49b704ad | skimberk/neuralnets | /nn-simple-2-layer.py | 1,117 | 3.703125 | 4 | import numpy as np
# Hyperbolic tan function
def tanh(x):
output = np.tanh(x)
return output
# Derivative of hyperbolic tan given output of tanh
def tanh_output_to_derivative(output):
return 1 - np.power(output, 2)
# Inputs
X = np.array([
[0, 0],
[0, 1],
[1, 0],
[1, 1]
... |
8c263df6d8c2c7073ce2b3d6cce387baaa9f123e | dilshan2015338/NewsArticleClassiication | /utils/utils.py | 4,105 | 3.59375 | 4 | import os
import io
def read_files(dir):
"""
Read all the files in a given directory and return a list of file paths.
Args:
dir: path to file directory
Returns:
list of file paths
"""
print('[INFO] Reading data...')
f = []
for roots, dirs, files in os.walk... |
ba724c035279c0410ce83842d9f68fe2b4d5388a | Demonslyr/ProjectEuler | /Problem3/prob3.py | 919 | 3.640625 | 4 | #! python2
import math
'''
The prime factors of 13195 are 5, 7, 13 and 29.
What is the largest prime factor of the number 600851475143 ?
'''
class Memoize:
def __init__(self, fn):
self.fn = fn
self.memo = {}
def __call__(self, *args):
if args not in self.memo:
self.memo[arg... |
afafcf48c733b3308f8b8cd5f5c33e96edd5e6e3 | RoshchynaA/Python | /step2_6.py | 900 | 3.796875 | 4 | product = []
count = 1
instruction = ''
while instruction != 'stop':
title = input('Название товара: ')
cost = input('Стоимость товара: ')
quantity = input('Количество товара: ')
unit = input('Единица измерения товара: ')
product.append(
(count, {'title': title, 'cost': cost, 'qua... |
2c02449e04af1dee001e3c74770337668e2408c0 | RoshchynaA/Python | /step_1.py | 245 | 3.890625 | 4 | a = 9
print((a // 3) ** 3)
b = a % 9
print(b)
c = a + a*b
print(c + 1)
print(a != b)
print(c > a)
mood = input("Hi! Are you happy today?")
int(input("How many time did you smile this morning?"))
print("You can do more! :)")
|
ade2f05881457b73b0d03a71a792a6c4757605c3 | RoshchynaA/Python | /step3_2.py | 662 | 3.921875 | 4 | def func_str():
str = ('Меня зовут ' + name + ' ' + surname + ', ' + year + ' года рождения. Проживаю в городе ' + town + '. Связаться со мной можно по емейлу ' + email + ' или по телефону ' + phone)
return str
name = input('Введите имя: ')
surname = input('Введите фамилию: ')
year = input('Введите год р... |
226dee30ee13d6e2cf56f4202b931c05ed38b9e5 | BastryginaE/Codelabs | /Lab2oop.py | 494 | 4.09375 | 4 | class Squareroot:
def __init__(self, a):
self.a=a
def count(self):
Xn=1
A=1
while A > 0:
x=1/2*(Xn+self.a/Xn)
if x != Xn:
Xn=x
else:
break
return x
a=float(input('Insert a positive number:'))... |
e21a1dfcd48c7db6a83ddae286a94e9c0fe451fe | KunitakeYuto/AtCoder | /ABC/ABC141/B.py | 324 | 3.71875 | 4 | S=input()
i=0
while i<len(S):
if (i+1)%2==0:
if S[i]=="L" or S[i]=="U" or S[i]=="D":
pass
else:
print("No")
quit()
else:
if S[i]=="R" or S[i]=="U" or S[i]=="D":
pass
else:
print("No")
quit()
i+=1
print("Y... |
59f7c0fd8bfb1642b1dbaad90dd4bdf4ec07b3d5 | KunitakeYuto/AtCoder | /ABC/ABC132/A.py | 221 | 3.921875 | 4 | S=input()
if S[0]==S[1] and S[2]==S[3] and S[0]!=S[2]:
print("Yes")
elif S[0]==S[2] and S[1]==S[3] and S[0]!=S[1]:
print("Yes")
elif S[0]==S[3] and S[1]==S[2] and S[0]!=S[1]:
print("Yes")
else:
print("No") |
597a7c4a617a3af9d9d62ef1c2fc0757ccbc9440 | berkcangumusisik/CS50 | /Hafta 6/pset6/readability.py | 600 | 3.671875 | 4 | from cs50 import get_string
text = get_string("Text: ")
n_words = n_sent = n_let = i = 0
length = len(text)
while i < length:
if text[i].isalpha():
n_let += 1
if (i == 0 and text[i] != " ") or (i != length and text[i] == " " and text[i + 1] != " "):
n_words += 1
if text[i] == "." or text[... |
ac52d7e50df7ad344488609e05baa94b73748ac8 | berkcangumusisik/CS50 | /Hafta 6/scores2.py | 153 | 3.71875 | 4 | scores = []
for i in range(3):
scores.append(int(input("Bir not giriniz:")))
ortalama = str(sum(scores) / len(scores))
print(f"Ortalama {ortalama}") |
9afabb7bd2df66bcf41d041daeb9cb2a05eefc8f | mihailthebuilder/react-ts-flask-backend | /base_convert.py | 829 | 4.0625 | 4 | # great base converter: https://www.dcode.fr/base-n-convert
def bc(base, num):
upper_bound = 1
upper_power = 0
num_decreasing = num
rebased_num = ""
# find the highest power for the base that's smaller than the number
while upper_bound * base < num:
upper_bound *= base
upper_p... |
7972ad4855633ae9f47b91cbf2ee1f9d6869aba8 | akjha013/Python-Rep | /test10.py | 366 | 4.09375 | 4 | # lists in python
# new items placed at the end of the list
# order is maintained and duplicates are allowed
animals = ['Bird','Cat','Dog','Elephant','Fish']
print(animals[:])
print(animals[:-2])
print(animals[-2:])
myNums = [10,22,45,4,-6,44,25]
print(myNums[:])
max = myNums[0]
for item in myNums:
if item > max:... |
abef0d7433c31333a7d4b63cd0971a7746d90115 | akjha013/Python-Rep | /main.py | 417 | 4.03125 | 4 | # STRING IN PYTHON
# car="myCar"
# car2="myCar"
# print(car==car2)
# res = input('what is your name? ')
# col = input('what is your favourite color?')
# print(res+ ' likes '+col)
# weight_p = input('Weight in Pounds')
# res = float(weight_p) * 0.453592
# print('Weight in kg is ' + res + ' kg')
# print(res)
myStr = "l... |
5bfdd1868bf406e035e47c1813da13b973ba58d4 | akjha013/Python-Rep | /test20.py | 268 | 3.90625 | 4 | # CONSTRUCTOR IN PYTHON
class Person:
def __init__(self, name):
self.name = name
def talk(self):
print(f'hi I am {self.name}')
prsn = Person('wacko9')
# print(f'person name is {prsn.name}')
prsn.talk()
prsn2 = Person('Jim Halpert')
prsn2.talk()
|
6b11fa1dd37dd341e1e3fe88f088e5d138f15ab1 | danielma0826/BMI | /BMI.py | 163 | 3.65625 | 4 |
height=eval(input('請輸入身高(cm)='))
weight=eval(input('請輸入體重(KG)='))
bmi=weight/((height/100)**2)
bmi = int(bmi)
print('此人的BMI=', bmi)
|
9992d9773b8333ca4d5d3a9365537e11c6c7cb2e | vehernan/Google-IT-Automation | /INTRO2PYTHON/coursera.py | 11,230 | 4 | 4 | def greeting(name, department):
print("Welcome, " + name)
greeting("Blake", "It support")
Welcome, Blake
def area_traingle(base, height):
return base*height/2
area_a = area_triangle(5,4)
area_b = area_triangle(7,3)
sum = area_a + area_b
print("The sum of ... |
d554cd8e86f8c5c1ed30daa44669ff48386ca962 | RozanMagdy/Graduation-Project | /Machine Learning/lesson02-Miniflow/Gradient_descent.py | 840 | 3.8125 | 4 | from sympy import *
import numpy as np
import random
def gradient_descent_update(x, gradx, learning_rate):
"""
Performs a gradient descent update.
"""
x = x - learning_rate * gradx
# Return the new value for x
return x
def f(x):
"""
Quadratic function.
It's easy to see the ... |
b143836ecc440a6d3714e35a992b277f6c71624a | Girum-Haile/PythonStudy | /OOP-Inheritance.py | 2,370 | 4.3125 | 4 | # Inheritance is the capability of one class to derive or inherit the properties from some another class.
# single-inheritance
class Person:
def __init__(self, name):
self.name = name
def getname(self):
return self.name
def isemployeer(self):
return False
class Emp(Person): # ... |
f519ad595c7f7a8a1cae710aedb28eb3810a74a3 | Girum-Haile/PythonStudy | /HelloWorld.py | 357 | 4.1875 | 4 | # this program prints out "hello World" on the console
# string values must be inside quotes
print("hello_world")
# number values doesn't require quotes
print(12)
# type() is used to identify the type of the value
# this program prints out "str" which is string
print(type("hello world"))
# this program prints out "int"... |
10fca713afef3452fe5ba377ea9a96d54113174b | danijar/jumper | /src/component/character.py | 1,210 | 3.515625 | 4 | import pygame, time
class Character(object):
def __init__(self):
self.speed = 3.0
self.health = 3
self.attack_time = 1.0
self.attack_range = 55.0
self.last_attack = None
self.hit_time = 1.2
self.last_hit = None
def attack(self, target, amount=1):
"""Attack another character taking attack cooldown a... |
8e3f4b8aebad97dbe136a1bdb8cb988117930604 | dmahugh/local-repo-search | /repo_filter.py | 2,005 | 3.8125 | 4 | """
Filters a CSV file to eliminate rows that meet these two criteria:
- repo is in the googleapis org on Github
- repo is not included in repos.json at this URL:
https://raw.githubusercontent.com/googleapis/sloth/master/repos.json
The header row of the input file and all rows not meeting the above criteria are
wri... |
861515e477a5d77328543366fc78bd0b5372333a | prakhub/pi3 | /analysis/surface.py | 9,337 | 3.546875 | 4 | #!/usr/bin/env python
# coding: utf-8
""" Provides a class to generate a 3D model from beam data """
__author__ = 'Andreas Gsponer'
__license__ = 'MIT'
import numpy as np
from scipy.interpolate import CubicSpline
class CubicFit():
""" Stores a 3D parameterization of the beam along the MBL.
All paramet... |
c51fb51b43af6f40144e0af16fde9c399e71f82b | aduanfei123456/algorithm | /dfs/count_islands.py | 945 | 3.90625 | 4 | """
Given a 2d grid map of '1's (land) and '0's (water),
count the number of islands.
An island is surrounded by water and is formed by
connecting adjacent lands horizontally or vertically.
You may assume all four edges of the grid are all surrounded by water.
Example 1:
11110
11010
11000
00000
Answer: 1
Example 2:
110... |
21f765b9247bc8e2f0195f243fac5a46d10aabea | aduanfei123456/algorithm | /dp/combination_sum.py | 1,272 | 3.96875 | 4 | """
Given an integer array with all positive numbers and no duplicates,
find the number of possible combinations that
add up to a positive integer target.
Example:
nums = [1, 2, 3]
target = 4
The possible combination ways are:
(1, 1, 1, 1)
(1, 1, 2)
(1, 2, 1)
(1, 3)
(2, 1, 1)
(2, 2)
(3, 1)
Note that different sequences... |
60760510aa80d92a482d1c8b909437602e6f870e | aduanfei123456/algorithm | /array/rotate_array.py | 380 | 4.4375 | 4 | """
Rotate an array of n elements to the right by k steps.
For example, with n = 7 and k = 3,
the array [1,2,3,4,5,6,7] is rotated to [5,6,7,1,2,3,4].
Note:
Try to come up as many solutions as you can,
there are at least 3 different ways to solve this problem.
"""
def rotate(nums,k):
nums=nums[-k:]+nums[0:len(nums)... |
cae37ba2460a5923ad691bd2ddd1a51fd59197b7 | lemakkamel/lecture0 | /hocine.py | 424 | 3.96875 | 4 | text=str(raw_input("Enter text : "))
def count_letter(text):
counter = 0
index = 0
box = 2
length = len(text) - 1
while index < length:
check = text[index:index + box]
if check[0] not in " ,." and check[1] == " ":
counter += 1
elif (index == (length - 1)) and (" ... |
67460c9bf919e0200eb08f37d180ce52f6404d79 | c-14795/coding_problems_solved | /ds/insertion_sort.py | 1,296 | 4.40625 | 4 | """
Insertion sort code
values: list of integers
"""
def insertion_sort(values):
# iterate over the values from 1st index to n-1 index
# we are assuming that the 0th element is already sorted.
for unsorted_index in range(1, len(values)):
# take the first value in the unsorted portion and assign it... |
aab6addcb602d4f059131438536a4eb0491d293c | yiyinghsieh/python-algorithms-data-structures | /cw_remove_duplicate_words.py | 1,382 | 3.71875 | 4 | """Codewars: Remove duplicate words
7 kyu
URL: https://www.codewars.com/kata/5b39e3772ae7545f650000fc/train/python
Your task is to remove all duplicate words from a string, leaving only
single (first) words entries.
Example:
Input:
'alpha beta beta gamma gamma gamma delta alpha beta beta gamma gamma gamma
delta'
O... |
bc225482907f9857aec2e99e8a8274ef25cd097a | yiyinghsieh/python-algorithms-data-structures | /cw_consonant_value.py | 2,249 | 3.65625 | 4 | """Codewars: Consonant value
6 kyu
URL:https://www.codewars.com/kata/59c633e7dcc4053512000073/train/python
Given a lowercase string that has alphabetic characters only and no
spaces, return the highest value of consonant substrings. Consonants are
any letters of the alphabet except "aeiou".
We shall assign the foll... |
176f7a87b0fa6efab4c0cd0c463ff59e207fbc5c | yiyinghsieh/python-algorithms-data-structures | /cw_backwards_read_primes.py | 2,554 | 4.25 | 4 | """Codewars: Backwards Read Primes
6 kyu
URL:https://www.codewars.com/kata/5539fecef69c483c5a000015/train/python
Backwards Read Primes are primes that when read backwards in base 10
(from right to left) are a different prime. (This rules out primes which
are palindromes.)
Examples:
13 17 31 37 71 73 are Backwards... |
99767a7fe8ddf1099a7808f01ff95845d8d13d2b | yiyinghsieh/python-algorithms-data-structures | /cw_watermelon.py | 2,132 | 4.09375 | 4 | """Codewars: Watermelon
8 kyu
URL: https://www.codewars.com/kata/55192f4ecd82ff826900089e/train/python
It's too hot, and they can't even…
One hot summer day Pete and his friend Billy decided to buy watermelons.
They chose the biggest crate. They rushed home, dying of thirst, and decided to
divide their loot, howeve... |
1cfe7b70e7f526e68676d84e16ca206e52a49b1f | yiyinghsieh/python-algorithms-data-structures | /cw_persistent_bugger.py | 2,075 | 3.78125 | 4 | """Codewars: Persistent Bugger
6 kyu
URL: https://www.codewars.com/kata/55bf01e5a717a0d57e0000ec/train/python
Write a function, persistence, that takes in a positive parameter num
and returns its multiplicative persistence, which is the number of
times you must multiply the digits in num until you reach a single
d... |
d81eb8b255ca378929a6dfa3059e7674c76c1f8e | yiyinghsieh/python-algorithms-data-structures | /cw_expressions_matter.py | 2,663 | 4.40625 | 4 | """Codewars: Expressions Matter
8 kyu
URL: https://www.codewars.com/kata/expressions-matter/train/python
Given three integers a ,b ,c, return the largest number obtained after inserting
the following operators and brackets: +, *, ().
Consider an Example :
With the numbers are 1, 2 and 3 , here are some ways of plac... |
c9fbf27adaf6998a70df5cb4ee1df980e6caaa94 | yiyinghsieh/python-algorithms-data-structures | /cw_century_from_year.py | 718 | 4.0625 | 4 | """Codewars: Codewars: Century From Year
8 kyu
URL: https://www.codewars.com/kata/century-from-year/train/python
The first century spans from the year 1 up to and including the year 100,
The second - from the year 101 up to and including the year 200, etc.
Task :
Given a year, return the century it is in.
centuryF... |
115ac57e959ae555091917f7ed57efd9dc7951e7 | yiyinghsieh/python-algorithms-data-structures | /cw_count_the_divisors_of_a_number.py | 2,666 | 4.03125 | 4 | """Codewars: Codewars: Count the divisors of a number
7 kyu
URL: https://www.codewars.com/kata/542c0f198e077084c0000c2e
Count the number of divisors of a positive integer n.
Random tests go up to n = 500000.
Examples
divisors(4) = 3 # 1, 2, 4
divisors(5) = 2 # 1, 5
divisors(12) = 6 # 1, 2, 3, 4, 6, 12
divisors(... |
6636fbffe4c2caab845db3a59485558f5b020f2e | yiyinghsieh/python-algorithms-data-structures | /cw_number_of_occurrences.py | 1,021 | 4 | 4 | """Codewars: Number Of Occurrences
7 kyu
URL: https:https://www.codewars.com/kata/52829c5fe08baf7edc00122b/train/python
Write a functionthat returns the number of occurrences of an element
in an array.
Examples
sample = [0, 1, 2, 2, 3]
number_of_occurrences(0, sample) == 1
number_of_occurrences(4, sample) == 0
numb... |
c6962bf185dffd8751820759a96f10cf75d10e1a | senwen616/Algorithm | /递归/344.反转字符串.py | 1,023 | 4.03125 | 4 | #!/usr/bin/python
# -* - coding: UTF-8 -* -
class Solution0(object): # 一行
def reverseString(self, s):
"""
:type s: List[str]
:rtype: None Do not return anything, modify s in-place instead.
"""
for i in range(len(s) - 1, 0, -1): s.insert(i, s.pop(0))
class Solution1(object):... |
8228ee0d9c444ad1a8e381119f8dc9059065d4a6 | senwen616/Algorithm | /回文数/回文.py | 720 | 3.578125 | 4 | #!/usr/bin/python
# -* - coding: UTF-8 -* -
class Solution(object):
def isP(self, s):
l = 0
r = len(s) - 1
while l < r:
if s[l] != s[r]:
return False
else:
l += 1
r -= 1
return True
def validPalindrome(sel... |
70a09b19293e5710d5e67148313f7c23eea1323d | senwen616/Algorithm | /动态规划/887_扔鸡蛋.py | 1,634 | 3.5 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
@author: swp
@file: 887_扔鸡蛋.py
@time: 2020/12/4
@version:
"""
"""
你将获得 K 个鸡蛋,并可以使用一栋从 1 到 N 共有 N 层楼的建筑。
每个蛋的功能都是一样的,如果一个蛋碎了,你就不能再把它掉下去。
你知道存在楼层 F ,满足 0 <= F <= N 任何从高于 F 的楼层落下的鸡蛋都会碎,从 F 楼层或比它低的楼层落下的鸡蛋都不会破。
每次移动,你可以取一个鸡蛋(如果你有完整的鸡蛋)并把它从任一楼层 X 扔下(满足 1 <= X <= N)。
... |
205dfae9893743038eee9084122a4f5b31ad92f0 | jasonj2333/mypong2021 | /pong4.py | 2,267 | 3.546875 | 4 | TITLE = "Pong 2021"
WIDTH = 700
HEIGHT = 500
start_game = False
game_over = False
player1 = Actor('player', (10, HEIGHT / 2))
player2 = Actor('player', (WIDTH - 10, HEIGHT / 2))
ball = Actor('ball', (WIDTH / 2, HEIGHT / 2))
ball_x = 5
ball_y = 5
player1_score = 0
player2_score = 0
def draw():
screen.clear()
... |
c436f45e0cad88e5d7d88831bd336e9a3c5370b7 | graja22/hello-world | /power.py | 185 | 3.90625 | 4 | num1=int(input())
num2=int(input())
if num1 & num2 is int:
num3=num1**num2
print(num3)
else:
num3=int(num1)
num4=int(num2)
num5=num3**num4
print(num5)
|
f067dff1619aa5d8e45ba202a83b53fe70ee1bac | graja22/hello-world | /nmultiple.py | 64 | 3.546875 | 4 | d=int(input())
for i in range(1,5+1):
print(i*d,end=" ")
|
7771176d0348e81fa09c9e91e7f3e2fffd016c1d | graja22/hello-world | /fibbet.py | 150 | 3.6875 | 4 | a= int(input())
n1 = 1
n2 = 1
print(n1, n2, end=" ")
for i in range(2,a):
next = n1 + n2
print(next, end=" ")
n1 = n2
n2 = next
|
907db3c9e08790054df66535264d2813d35c1b57 | yeohkc1995/Pathfinding | /GPS_Converter.py | 460 | 4.09375 | 4 | print "This is a program to convert GPS coordinates to the relavent occupancy grid position: \n\n"
xcoord = float(input("Orignal x-coordinates: "))
ycoord = float(input("Orignal y-coordinates: "))
print "\n\n"
minX = float(input("Minimum X: "))
minY = float(input("Minimum Y: "))
scale = float(input("Scale: "))
prin... |
4119c0abd7c7e33dd30ee03a04f84a5c9b2dbed1 | Ibar-052/InfoGath | /InfoGaht.py | 2,852 | 3.53125 | 4 | #python3
import os, sys
os.system("clear")
print("""
╔══╗╔═╦╗╔══╗╔═╗╔══╗╔╗╔╗╔══╗╔══╗
╚║║╝║║║║║═╦╝║║║║╔═╣║╚╝║║╔╗║╚╗╔╝
╔║║╗║║║║║╔╝─║║║║╚╗║║╔╗║║╠╣║─║║─
╚══╝╚╩═╝╚╝──╚═╝╚══╝╚╝╚╝╚╝╚╝─╚╝─
""")
nama = input("masukkan nama pengguna : ")
#keluar
def keluar():
mmk = input("lanjut [y/t] --> ")
if mmk == 't' or mmk == 'T':... |
bcbcb7a1054e52864d09be447157e9d97d2fa5cf | tokfrans03/WiimmfiSpy | /player.py | 631 | 3.609375 | 4 |
class player:
def __init__(self, fc, vp, combo, name, time):
self.name = name
self.vp = vp
self.combo = combo
self.fc = fc
self.time = time
def dict(self):
return {
"name": self.name,
"vp": self.vp,
"combo": self.comb... |
ba028ea6eb39646857c139f689c672e7cdc437a2 | LIM-EUNBI/Python | /day20210612.py | 834 | 3.921875 | 4 | # a = [1, 2, 3, 4]
# print(a)
# for문
# for i in range(10):
# print(i)
# for i in range(0, 13, 2):
# print(i)
# for i in range(13, 0, -2):
# print(i)
# for i in range(0, 101, 3):
# print(i)
# 100까지의 합 구하기
# sum = 0
# for i in range(11):
# sum += i
# print(sum)
# a = list(range(21))
# ... |
e31bdaf70f106d0b54229794c243cf086f235de9 | LIM-EUNBI/Python | /main.py | 206 | 3.703125 | 4 | import menu as m
menu = m.Menu()
name = input("메뉴 : ")
while(name != ''):
price = input("가격 : ")
menu.addMenu(name, price)
name = input("메뉴 : ")
menu.printList()
menu.saveList() |
3ea7fce8f1efd9a7f6ca23b1993cd45b92dffeed | JHolderguru/OPP | /pats_file.py | 784 | 3.515625 | 4 | class Cat:
def __init__(self, name):
self.name = name.title()
self.legs = 4
self.fur = True
self.independence = True
self.agility = True
self.family = "Feline"
def purr(self):
return self.name + ": Prrrrrrrrrrrrrprrrrrrrrrrr"
def nap(self):
... |
39d32585850667f96ec730331cf5147be80b08f6 | JHolderguru/OPP | /fast_life.py | 550 | 3.984375 | 4 | from cat_class import *
#Initialize the class
cat_instance = Cat()
print(cat_instance)
# To assign an enemy
fight = cat_instance.fight(' fox')
print(fight)
# To assign the food
food = cat_instance.food(' juicy mice')
print(food)
# To print the Color
print(cat_instance.colour())
#Print the instance
print(cat_insta... |
8737b1a0260afdab887b1348ba1efbbd4842b0a9 | blubits/tsuro | /game.py | 2,353 | 3.84375 | 4 | from board import Board
"""
A wrapper for the Tsuro game.
:Author: Maded Batara III
:Version: v1.0
"""
class Game:
"""
The Game class wraps around all the classes in the Tsuro module.
"""
def __init__(self, num_players, deck, rows, cols):
"""
Creates a new Game.
Args:... |
19aab366c77fb6729b3a29f62fe6da33d4477c7a | sleepyfoxen/aoc20 | /day3.py | 789 | 3.640625 | 4 | from functools import reduce
from operator import mul
from typing import NewType
Pair = NewType('Pair', (int, int))
def product(l): return reduce(mul, l, 1)
with open('inputs/day3', 'r') as f:
input_ = f.read().strip().splitlines()
# input_ = '''..##.......
# #...#...#..
# .#....#..#.
# ..#.#...#.#
# .#...##..#.
... |
e5700359ac920ee623805202ca23cbcb90faac73 | kuzn137/2020-Air-Pollution-Dashboard | /wrangling_scripts/wrangle_data.py | 4,911 | 3.640625 | 4 | import pandas as pd
import plotly.graph_objs as go
# Use this file to read in your data and prepare the plotly visualizations. The path to the data files are in
# `data/file_name.csv`
file_name = 'data//waqi-covid19-airqualitydata-2020.csv'
particles = ['pm25', 'pm10', 'no2', 'o3', 'so2']
df = pd.read_csv(file_name, s... |
b384c8aac3606f463a51b9b1b3cdf01f525e8c30 | didw/ml_finance | /mlfinlab/mlfinlab/data_structures/run_data_structures.py | 12,866 | 3.59375 | 4 | """
Advances in Financial Machine Learning, Marcos Lopez de Prado
Chapter 2: Financial Data Structures
This module contains the functions to help users create structured financial data from raw unstructured data,
in the form of tick, volume, and dollar run bars.
These bars are used throughout the text book (Advances ... |
5727919ac43c2dd6314f0c12656ce3649e28b9f4 | jessicarowell/Helpers | /undo_make_directories.py | 1,637 | 3.84375 | 4 | import os, shutil, argparse
def getDirs(key):
listDirs = next(os.walk('.'))[1]
dirNames = []
for d in listDirs:
if key in d:
dirNames.append(d)
return(dirNames)
def moveFilesUp(dirList):
for d in dirList:
for f in os.listdir(d):
if os.path.isfile(os.path.join(d, f)):
try:
shutil... |
3582a4d32065ec2feab6ad1df3e61cffdd52953d | nvovk/python | /OOP/1 - Figures/figures.py | 816 | 3.796875 | 4 | class Circle:
def __init__(self, rad):
self.rad = rad
self.centre = [0, 0]
def resize(self, rad):
self.rad += rad
def move(self, osx, osy):
self.centre[0] += osx
self.centre[1] += osy
class Rectangle:
def __init__(self, width, height):
self.width = w... |
c412a049d155f71bb11eb03ebb8af00e4b43e0cd | Bgumel/Automate-The-Boring-Stuff | /Practice-Projects/Ch 03 - Collatz Sequence | 1,914 | 4.8125 | 5 | #! python3
# collatz_sequence.py - Performs the Collatz Sequence on any number
# Introductory message
print('In order to experience the collatz sequence type in any positive number.')
# collatz function - has one if/else statement depending on if the number is even or odd
# the % is remainder. If the number entered ... |
56e8a06ca328c21b06c4b84debbf09116c442617 | Bgumel/Automate-The-Boring-Stuff | /Practice-Projects/Ch 07 - Strong Password Detection | 3,833 | 4.46875 | 4 | #! python3
# strong_password_detection.py
"""
Write a function that uses regular expressions to make sure the password
string it is passed is strong. A strong password is defined as one that
is at least eight characters long, contains both uppercase and lowercase
characters, and has at least one digit. You may need to ... |
ed498dc5b8745975128185c03fa9fafb6c0eb5d1 | Bgumel/Automate-The-Boring-Stuff | /ExtraPrograms/Zip | 615 | 4.375 | 4 | #! python3
# A program designed to quickly zip a file
import os
import zipfile
while True:
zip_file = input('What file would you like to zip?\n')
wd = input('Where would you like to zip ' + zip_file + ' to?\n')
while True:
try:
os.chdir(wd)
break
except:
print('Cannot find directory.\nPlease enter ... |
98bfc1b65991581b77696d05d3b18f6ad22e004f | jtplace1/School_Projects | /Python/Rainfall/Rainfall.py | 1,052 | 4.125 | 4 | # Program Name: Rainfall.py
# Course: IT1113/Section w01
# Student Name: Jabari Smith
# Assignment Number: Lab 6 Due Date: 11/22/20
# Purpose: This program takes in the user input of rainfall for 12 months
# and finds the average, total, highest and lowest varibles from the info
months = ['January', 'Feb... |
4dce774dc0a01c8031f83764d2fb5601fc6aef3f | jtplace1/School_Projects | /Python/Test_Grade_Average/Test_Grade_Average.py | 1,390 | 4.25 | 4 | # Program Name: Test_Grade_Average.py
# Course: IT1113/Section w01
# Student Name: Jabari Smith
# Assignment Number: Lab 2 Due Date: 10/18/20
# Purpose: This program takes in the user input for the name of 12 students and their 8 test grades,
# then displays the average and letter grade.
def calc_average(a1,a... |
98a15b6c5c859cbc3b3db0b0437832450d8b890c | marcusvinysilva/blue_mod1 | /aula17/aula17_codelab_Q03.py | 671 | 4.0625 | 4 | # Crie uma classe que modele uma pessoa:
# a) Atributos: nome, idade, peso e altura.
# b) Métodos: envelhecer, engordar, emagrecer, crescer.
# Por padrão, a cada ano que a pessoa envelhece, sendo a idade dela menor que 21 anos, ela deve crescer 0,5 cm
class pessoa():
def __init__(self, nome, idade, peso, altura):
... |
e0f5c502b609746c98417228223c52820e726154 | marcusvinysilva/blue_mod1 | /aula04/aula04_codelab_Q03_caixa-eletronico.py | 1,209 | 3.9375 | 4 | # Caixa eletrônico
# Faça um Programa para um caixa eletrônico. O programa deverá perguntar ao usuário a valor do saque e depois informar quantas notas de cada valor serão fornecidas.
# As notas disponíveis serão as de 1, 5, 10, 50 e 100 reais.
# O valor mínimo é de 10 reais e o máximo de 600 reais. O programa não deve... |
2e4e0e579ee5b67a80953fb8a028c83e045317e9 | marcusvinysilva/blue_mod1 | /aula07/aula07_codelab_for_Q04.py | 493 | 4.125 | 4 | ### 04 - Desenvolva um programa que leia seis números inteiros e mostre a soma apenas daqueles que forem pares. Se o valor digitado for ímpar, desconsidere-o. Mostre também quantos valores pares foram digitados. ###
soma = 0
num_par = 0
for i in range(1, 7):
numero = int(input(f'Digite o {i}º número: '))
if (nu... |
798c63c7f8b5f399944c555da5b42540347b62ee | marcusvinysilva/blue_mod1 | /aula09/aula09_codelab_Q02.py | 1,009 | 4.09375 | 4 | #02 - Crie um programa que vai ler vários números e colocar em uma lista. Depois disso, crie duas listas extras que vão conter apenas os valores pares e os valores ímpares digitados, respectivamente. Ao final, mostre o conteúdo das três listas geradas.
lista = []
lista_par = []
lista_impar = []
while True:
num = ... |
a0ffa31fd11a89fbf62cb3261d27e9c02e5ae1e2 | marcusvinysilva/blue_mod1 | /aula06/aula06_exercicios_for_Q04.py | 428 | 4.15625 | 4 | # 04 - Desenvolva um código em que o usuário vai entrar vários números e no final vai apresentar a soma deles (o usuário vai dizer quantos números serão informados antes de começar)
quantidade_valores = int(input('Quantos valores serão usados na soma? '))
soma = 0
for i in range(1, quantidade_valores+1):
valor = i... |
cb65b3676e7a94d6ef26066f09ff4e67a93bee3b | sitio-couto/python | /test11.py | 686 | 3.640625 | 4 | import time
import functools
# class logstr(object):
#
# def __init__(self, f):
# self.log = ""
# self.f = f
#
# def __call__(self, *args):
# ret = self.f(*args)
# self.log += time.asctime(time.localtime())
# self.log += " entrada: " + str(args) + " saida: " + str(ret) +... |
83961304e4ac5c8e621da3df57fc1bcf62dbdf7f | annkon22/txt_to_speech | /split.py | 897 | 3.515625 | 4 |
def spl_inp(us_input):
us_input = us_input.upper()
us_split = []
cons = 'BCDFGHJKLMPQRSTVWXYZ'
vow = 'AEIOU'
cur = 0
nxt = 1
while cur <= len(us_input) - 2:
if us_input[cur] in cons and us_input[nxt] in vow:
syl = ''+ us_input[cur] + us_input[nxt] +... |
cc41ce3a64427a5bb1f97d4c00243d3b034096c0 | rithvikdemon/python-assignments1 | /assignment_11.py | 975 | 3.796875 | 4 | #Question 1
import time
import datetime
import threading
def threadd():
time.sleep(5)
print("Inside the function after 5 seconds")
threadd()
#Question 2
import time
import datetime
import threading
def numbers():
i=1
for x in range(10):
print(i)
i+=1
ti... |
0ccface1c70ef5c3f25ea630796319796719c2a0 | rithvikdemon/python-assignments1 | /assignmnet_4.py | 1,134 | 3.890625 | 4 | #Question1
tup1= (1,2,3,'x','y','z')
print(tup1)
print(len(tup1))
#Question2
tup2= (1,2,3)
tup3= ('x','y','z')
print('Max element in tupel 1 is=', (max(tup2)))
print('Min element in tupel 1 is=', (min(tup2)))
print('Max element in tupel 2 is=', (max(tup3)))
print('Min element in tupel 2 is=', (min(tup3)... |
388c7d4394b15cdfc3ee7b3d689eae07a3fd95d8 | Chruffman/Personal-Projects | /BMR.py | 1,589 | 4.40625 | 4 | # BMR Calculator
# by Chris Huffman 2017
def BMR(weight, height, age, gender):
if gender == 'f':
yourBMR = 655 + f_weight + f_height - f_age
return yourBMR
if gender == 'm':
yourBMR = 66 + m_weight + m_height - m_age
return yourBMR
print ("Please enter your n... |
73becbd59bbae9980d974a093debcca34dfa76c8 | wying523/YingWang_InsightData | /src/median_unique.py | 1,412 | 3.796875 | 4 | #InsightData Challenge
#Author: Ying Wang
#This code calculates the median for the unique word as the tweet comes in
import sys
import re
import numpy
InputFile = sys.argv[1]
OutputFile = sys.argv[2]
ListofNum = []
def main():
library = re.compile(r"\S+", re.IGNORECASE)
#empty the output file
open(O... |
9298fc2ea20ef9ecb402b59cc07201e0195d3c70 | vipin-t/py-samples | /hello1.py | 515 | 3.8125 | 4 | #print (" Hello world")
# name = 'Charlie'
# print (name)
a = 'hello world'
b = "Introduction to Python Programming Coding using VS Code"
# val = b.split('o')
# print (val)
# print ( a.upper() )
print ( a[::-1])
print (b.count('i'))
# print('{0:>20} | {1:>20}'.format('Fruit', 'Quantity'))
# print('{0... |
13d3d57d8383e1eed8dcb27f4764c4b58be937d4 | bamundagaaloyzius/pythonstart | /arithmetic.py | 169 | 3.828125 | 4 | x=10.3
y=4
#addition
z=x+y
print("z is " + str(z))
#multiplication
w =x*y
print("w is " + str(w ))
#subtraction
print(y-x)
#modulo
print(y%x)
#division
print(x/y) |
b15ffac67b355e26fa60966d75e6a5ed611f19e8 | TiernanBurke/python_3_solutions | /5.14.7.py | 1,057 | 4.03125 | 4 | #-------------------------------------------------------------------------------
# Name: module1
# Purpose:
#
# Author: Tiernan
#
# Created: 28/08/2020
# Copyright: (c) Tiernan 2020
# Licence: <your licence>
#-------------------------------------------------------------------------------
... |
4f8aef0e9d6b644e1bea78f9de419aa27907d002 | syedamir2321/ALGORITHMS | /KNAPSACK.py | 579 | 4.0625 | 4 | def knapsack(maximum,weight,value,n):
if n==0 or maximum==0:
return 0
if weight[n-1]>maximum:
return knapsack(maximum,weight,value,n-1)
else:
return max(knapsack(maximum,weight,value,n-1),value[n-1]+knapsack(maximum-weight[n-1],weight,value,n-1))
maximum = int(input("Enter t... |
aa930ba20051fe2ecbfd5fa4563ecf1773cb0010 | syedamir2321/ALGORITHMS | /SORTING_TECHNIQUES/SELECTION_SORT.py | 710 | 3.859375 | 4 | import matplotlib.pyplot as plt
import time
import random
size = []
timess = []
def selection_sort(array,arr_len):
for i in range(arr_len-1):
min_index = i
for j in range(i+1,arr_len):
if array[j]<array[min_index]:
min_index = j
array[i],array[min_i... |
06e5396f540d7d4147a580be7b69121734745e5b | martrik/HPCodeWarsSamples | /2015 All/prob02.py3 | 134 | 3.5625 | 4 | import sys
mile = 1.609
miles = float(sys.stdin.readline())
print(str(miles)+" miles are "+str(round(miles*mile, 2))+" kilometers") |
38f9c2912577ef4dad0bee722e8cb4a8367b8108 | martrik/HPCodeWarsSamples | /2013 All/prob09.py | 256 | 3.609375 | 4 | import sys
for linen in sys.stdin:
line = linen.strip().upper()
if int(line) == -1:
break
count = 0
for i in range(int(line)+1):
for j in str(i):
if j == "1":
count += 1
print(str(count)) |
f2543726c84abb985251069d0b07117f68473140 | martrik/HPCodeWarsSamples | /2014 Gabriel/prob_04.py | 803 | 3.625 | 4 | real_number = int(input())
numbers = []
names = []
def find_closer():
diferences = []
closers = []
global numbers
global real_number
for i in numbers:
diference = real_number - i
if diference < 0:
diferences.append(-diference)
else:
diferences.append(... |
55344f030c3b0c6f7196d2a6fbd901ca92db6eef | UpTownCat/LeetCode | /LeetCode_206.py | 1,023 | 3.6875 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
# @File : LeetCode_206.py
# @Author: UpTownCat
# @Date : 2017/10/2
class ListNode(object):
def __init__(self, v):
self.val = v
self.next = None
class Solution(object):
def reverseList(self, head):
if not head or not head.next:
... |
31502efa6b0b87ea868da1e433b0a140c599159f | MaiconJunge/Curso-Python | /Fundamentos/operadoresdeatribuição.py | 395 | 3.8125 | 4 | # Atribuição
a = 3
a = a + 7
print(a)
# Acrescentando valor - Atribuição Aditiva
a += 5
print(a)
# Atribuição Diminutiva
a -= 3
print(a)
# Atribuição Multiplicativa
a *= 2
print(a)
# Atribuição Divisiva
a /= 4
print(a)
# Atribuição Modular
a %= 4
print(a)
# Atruibuição Exponencial
a **... |
ba8d7bc08932c62c770432b3f548e5d14f0db37f | saadmgit/python-practice-tasks | /task4.py | 858 | 4.21875 | 4 |
# TASK 4: code for making input string UPPERCSASE using class & methods
class SaadCls:
def __init__(self): # init function initializing input string variable
self.input_str = ""
def get_string(self): # Method for taking input from user
self.inpu... |
2376d0244bde37b4f0020b6194c24ef9f6cf2b8e | BensonIsabel/cpsmi-python | /lab-1.py | 112 | 4.03125 | 4 | print("Enter some string>> ")
strng = str(input())
for x in range(len(strng)):
print(strng[-(x+1)], end="")
|
8f5c8cd756d79269c0cff6d8aa046000338c1e1d | jaimecabrera911/PythonBasico | /02 Operadores y expresiones/OperadoresLogicos.py | 800 | 4.03125 | 4 | # Encontramos 3 operadores especiales para realizar operaciones lógicas. Normalmente se utilizan para agrupar, excluir y negar expresiones.
# Puede ayudar echar un vistazo a esta explicación sobre las tablas de la verdad:
# Not
# And
# Or
# Operadores lógicos
#
print("Not (Negación lógica)")
print(not True)
print(not F... |
41150aa1af0ca550171c2a830a0093dc587c07f5 | jaimecabrera911/PythonBasico | /02 Operadores y expresiones/ExpresionesAnidadas.py | 112 | 3.53125 | 4 | a = 10
b = 5
print(a * b - 2 ** b >= 20 and not (a % b) != 0)
print(a * b - 2 ** b <= 20 and not (a % b) != 0)
|
86eb0590960784b536a11a1bad2c691cc45061ac | prasen7/python-examples | /turtlestyle.py | 333 | 3.703125 | 4 | # turtle design
import turtle
turtle.pensize(2)
turtle.bgcolor('skyblue')
turtle.speed(0)
c=['red','brown','blue','white','yellow','orange','black','green','red','green']
for i in range(6):
for colour in c:
turtle.color(colour)
turtle.circle(100)
turtle.left(10)
turtle.hidetur... |
514c5e377175054b391c185b52dafb00f70a1778 | prasen7/python-examples | /strindex.py | 135 | 4.1875 | 4 | # program to generate index of string
s= input('enter string: ')
l=len(s)
print(*s, sep="|")
print('='*(l*2-1))
print(*range(l))
|
d8310b50b1a22468f24a0d9c55d210c76d618afe | prasen7/python-examples | /list unique .py | 2,433 | 4.375 | 4 | # removing duplicate from list
# using collections.OrderedDict.fromkeys()
from collections import OrderedDict
# initializing list
test_list = [1, 5, 3, 6, 3, 5, 6, 1]
print ("The original list is : " + str(test_list))
# using collections.OrderedDict.fromkeys()
# to remove duplicated
# from l... |
8e12e4af4621bd5f57afbb150eac929918890a7c | prasen7/python-examples | /LeapYear.py | 714 | 4 | 4 | year = int(input("Enter a year: "))
a="Leap year"
b="Common year"
if year<1582:
print("Not within the Gregorian calendar period")
exit()
if year%4!=0:
print(b)
elif year%100!=0:
print(a)
elif year%400!=0:
print(b)
else:
print(a)
# leap year function
def isYearLeap(year):
... |
e1b96497d318884d577fc311cf5630772a43103b | prasen7/python-examples | /avg_string.py | 356 | 4.15625 | 4 | # takes a string as input and figures out the average length of all words and returns the no. representing the same.
# Remove all punctuations and round up to nearest whole no.
import math
n = input("input a string: ")
s= n.split()
l=0
for i in s:
l+=len(i)
a = math.ceil(l/len(s))
print(s)
print("average ... |
e98e0e3921552deae800354b3e05c4fc72a7633c | half-potato/cortex | /src/draw_network.py | 650 | 3.515625 | 4 | import networkx as nx
import matplotlib.pyplot as plt
import numpy as np
def draw_network(net):
G = nx.DiGraph()
for i in range(net.size):
for j in range(net.size):
w = net.weights[i, j]
G.add_edge(i+1, j+1, weight=w)
val_map = {}
for i, v in enumerate(net.neurons):
... |
6f3df8f1d883c3f948c573fe9eeca46a0146986c | jbrdge/Recipes | /Python/Pandas/commonPandasETL.py | 2,238 | 3.8125 | 4 | import pandas as pd
#Common Pandas ETL Methods
#------------------------Loading Data-----------------------------#
filepath=''
#read a csv/txt file
df = pd.read_csv(filepath,header=0)
#read a xlsx file
df = pd.read_excel(filepath, header=None)
#read a .npy or .npz file
numpy_data = np.load(filename, allow_pickle=... |
cc6d84e977520bb7afab249b3233270489e31123 | AndrewOS95/Retinopathy | /src/gui.py | 2,442 | 3.59375 | 4 | #import the 'tkinter' module
import tkinter
from tkinter import *
from tkinter import ttk
from tkinter.filedialog import askopenfilename
globalImPath = ""
mainBackground = "#fafafa"
imBackground = "#ffffff"
#create a new window
window = tkinter.Tk()
#set the window background
window.configure(background=mainBackgrou... |
6f1c07a2f61c0c0f9814f5f6be2c0196eb16045d | angepocalypse/Card_Game | /player.py | 410 | 3.6875 | 4 | from Deck import Deck
class Player:
'''Player class'''
def __init__(self, player_name, user_id):
self.name = player_name
self.id = user_id
self.decks = []
self.decks.append(Deck(player_name, "{}'s Deck".format(player_name)))
def new_deck(self, deck_name):
'''Adds a... |
95a9047b91dafad0946fb8be656e61b780930a1b | JiaRui10/JiaRui_Note | /Python_Note.py | 5,179 | 4.21875 | 4 | # 让Python程序变成一个可执行脚本
#!/usr/bin/env python
# 装饰器
# 作用:对一个函数、方法或者类进行加工。提高了程序的可重复利用性,并增加了程序的可读性。
# ----------------------------->
def decorator(F):
def new_F(a, b):
print('input', a, b) # 添加一个打印输入功能
return F(a, b)
return new_F
@decorator
def square_sum(a, b):
return ... |
a4ef2bd1db01d7340b511e3e0813125c5e9f9eab | LeozinLL/Curso-Em-Video | /FOR/ex05.py | 244 | 3.734375 | 4 | soma = 0
cont = 0
for x in range(1, 7):
num = int(input('Digite o {} valor: '.format(x)))
if num % 2 == 0:
cont += 1
soma += num
print()
print('Você informou {} número(s) PARES e a soma deles foi: {}'.format(cont, soma))
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.