blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string |
|---|---|---|---|---|---|---|
0028980f2fa91ad863e92acbad0ce859a8ceb12a | soldevenus/final | /p2.py | 238 | 3.640625 | 4 | L=[9,-1,10,0,-2]
x=19
def positive_sum(L):
for n in L:
if n==x:
print
L=[-1,2,14,0,0,1]
print"sum L:", positive_sum(L)
M=[1,1,2,8,1]
print "sum M:", positive_sum(M)
N=[-1,-2,-3]
print"sum N:",positive_sum(N)
|
160309cc7730af6b89098162e34faf3d111e0e78 | HarshCasper/Rotten-Scripts | /Python/Scrap_Latest_Torrents/scrap_latest_torrents.py | 1,924 | 3.828125 | 4 | """
This script downloads the torrents in our Torrent client from the
website https://rarbg.to/ from an entered label.
"""
import subprocess
import os
import sys
import rarbgapi
def main():
"""
Principal function
"""
count = 0
# Label to search
label = input("Enter a label: ")
# Search ... |
01584fc2cb9fab9f05bdc87783f8c89957c22da3 | alissa-huskey/gh-pages-cli | /ghp/types.py | 2,247 | 3.75 | 4 | """types module -- define some basic types"""
from datetime import datetime
__all__ = [
"Date",
"Missing",
"Sha",
]
class Date(datetime):
"""Class for date strings"""
"""The format used by datetime.strptime() to parse date strings."""
INPUT_FORMAT: str = "%Y-%m-%dT%H:%M:%SZ"
def __new... |
6c3d211e1ad7a966858b16195ff53ff372227020 | BenVigos/Computer_Science_2020-2021 | /UNIT-1/Electronics Hardware store/library.py | 1,895 | 3.734375 | 4 | #This program encrypts the store data
def encryptor(items, prices, inventory):
msg = ["","","","","","",""]
encr_msg = ["","","","","","",""]
key = [int(ord(char)/10) for char in "p4ssw0rd"]
encr_lines= open("encrypted store data.txt", "w")
#Puts the elements in the format "item,price,inventory"
... |
a46fc90b56f328e36dde04922437d1a119d4c9be | GiveMeTheReason/algorithms | /bfs.py | 1,009 | 3.9375 | 4 | from collections import deque
def pers_is(pers):
if pers[-1] == "e":
return True
else:
return False
def bfs(name):
'''
Example from "Grokking Algorithms"
Breadth First Search
'''
queue = deque()
for item in graph.get(name):
queue.append(item)
... |
e944cf63efad90f1c2c7c5e086d799c13060d0cd | sepidehaghvami/Quera-Sulotins | /jaame 2 araye.py | 298 | 3.578125 | 4 | arr1 = []
arr2 = []
arr3 = []
n = int(input())
while len(arr1) <= n:
arr1 = [int(x) for x in input().split()]
break
while len(arr2) <= n:
arr2 = [int(x) for x in input().split()]
break
for i in range(n):
arr3.append(arr1[i] + arr2[i])
print(' '.join(map(str, arr3))) |
980b22c2eb1c5265e1374e01b8d03facf8d5884d | adwitiyapaul/HackerRank-30-days-of-code | /3_Conditional_Statements/Solution.py | 834 | 4.34375 | 4 | #Task
#Given an integer, n, perform the following conditional actions:
#If n is odd, print Weird
#If n is even and in the inclusive range of 2 to 5, print Not Weird
#If n is even and in the inclusive range of 6 to 20, print Weird
#If n is even and greater than 20, print Not Weird
#Complete the stub code provided in yo... |
145a7d8c50d06b35d0fbd68bc57fa8bcd686abac | skillup-ai/tettei-engineer | /chapter14/Q2_ans.py | 1,225 | 3.5 | 4 | import numpy as np
class RNN:
def __init__(self, Wx, Wh, h0):
"""
Wx : 入力xにかかる重み(1,隠れ層のノード数)
Wh : 1時刻前のhにかかる重み(隠れ層のノード数, 隠れ層のノード数)
h0 : 隠れ層の初期値(1,隠れ層のノード数)
"""
# パラメータのリスト
self.params = [Wx, Wh]
# 隠れ層の初期値を設定
self.h_prev = h0
def forward... |
22c3be1462da8032b9b237985a0c64969780f01d | djoshuac/competitive-programming | /hackerrank/Project_Euler/36-Double_Base_Palindromes/solution.py | 522 | 3.90625 | 4 | def is_palindrome(s):
for i in range(len(s) // 2):
if s[i] != s[-1 - i]:
return False;
return True;
def to_base(n, base):
num = []
while n > 0:
num.append(str(n % base))
n //= base
return "".join(reversed(num))
def double_base_palindrome_sum(n, base):
return... |
0f01cf13752c63fa643d9f1d4088f91da485740c | mateusrmoreira/Curso-EM-Video | /desafios/desafio06.py | 657 | 4.25 | 4 | ''' 14/03/2020 by jan Mesu
Crie um programa que peça um número
e mostre seu dobro, seu triplo e sua raíz quadrada
'''
from cores import cores
numero = int(input('Escreva um número: '))
dobro = numero * 2
triplo = numero * 3
print(
f"""{cores['verde']} O número digitado foi {numero} {cores['limpar'... |
f0a342051445084d0337bfaaf93b507a60df0f6a | Stafeev/Conference-App | /interview.py | 363 | 3.625 | 4 | def fruits(file):
for fruit in file:
name=fruit["name"]
num_baskets=0
num_fruit=0
for item in fruit["baskets"]:
num_baskets+=1
num_fruit+=item
print name,num_baskets,num_fruit
file=[
{ "name" : "apples",
"baskets" : [10,20,30]
},
{ "name" : "bananas",... |
66e478e968461ff292f9266ad4c18b7e584fc0a2 | marlenaJakubowska/codecademy_py | /dict_challenge/frequency_count.py | 475 | 4.25 | 4 | # Write a function named frequency_dictionary that takes a list of elements named words as a parameter.
# The function should return a dictionary containing the frequency of each element in words.
def frequency_dictionary(words):
freqs = {}
for word in words:
if word not in freqs:
freqs[wo... |
f7ff0650298d1ee6698ee7f079f6f074059bcd90 | rhythm-patel/Betweenness_Centrality | /SBC.py | 11,077 | 3.75 | 4 | #!/usr/bin/env python3
# Rhythmkumar Patel
# rhyhtmkumar18083@iiitd.ac.in
# 2018083
import re
import itertools
ROLLNUM_REGEX = "201[0-9]{4}"
class Graph(object):
name = "Rhythmkumar Patel"
email = "rhythmkumar18083@iiitd.ac.in"
roll_num = "2018083"
def __init__(self, vertices, edges):
"""
... |
df5cd30b3f09c5e5aa1b670b82f5e87cc0bc4c0b | Aasthaengg/IBMdataset | /Python_codes/p03698/s419484452.py | 155 | 3.5 | 4 | S = list(input())
S.sort()
ans = True
for i in range(len(S)-1):
if S[i] == S[i + 1]:
ans = False
break
if ans:
print("yes")
else:
print("no") |
cae1343ff21693ad84a6869117ae48ec51c6ac70 | LauroCRibeiro/SQLite3-With-Python-Tutorial- | /database_connect.py | 227 | 4 | 4 | #Done by Lauro Ribeiro (12/02/2021)
# Tuturial 1- Connect to database in python
#Create SQLite Connection
import sqlite3
#Create a connector- connect to database
conn = sqlite3.connect('customer.db')
print("Opening database...") |
c93a132a1c20fd57651fa606fff8cbb3817e1dbb | manish-iitg/printing-portal | /pdf.py | 733 | 3.5 | 4 | # pip install PyPDF2
import os
from PyPDF2 import pdfFileMerger, pdfFileReader, pdfFileWriter
# code to merge multiple pdf files into one
source_dir = os.getcwd()
merger = pdfFileMerger()
for item in os.listdir(source_dir):
if item.endswith('pdf'):
merger.append(item)
merger.write('complete.pdf')
merge... |
067f2e2040cba8c585f17378b5ae67bdd167210a | shardaishwak/pyvine | /app.py | 855 | 3.75 | 4 | from pprint import pprint
from Hashon import Encoder
from Game import Game
question = input("What do you want to do: ")
list_of_hashes = []
if question == "hash":
code = input("Code: ")
hasher = Encoder(code, list_of_hashes)
hasher.encode()
elif question == "list of hashes":
if list_of_hashes:
pprint(list_o... |
10d69dee0d8328be1fbf9303d397b3c434c2a848 | Anandkumarasamy/Python | /demo_string3.py | 283 | 4.375 | 4 | #10.Write a Python program to change a given string to a new string where the first and last chars have been exchanged.
def exchange_char(string1):
result=string1[(len(string1)-1)]+string1[1:(len(string1)-1)]+string1[0]
return result
print(exchange_char('anandkumarasamy'))
|
339ce0e4cdad4d27f05a3a8b9bb39c25a46b9cd8 | denny-Madhav/PYTHON-BASIC-PROJECTS | /PingPong/paddle.py | 481 | 3.671875 | 4 | from turtle import Turtle, Screen
class Paddle(Turtle):
def __init__(self, postion):
super().__init__()
self.shape("square")
self.color("red")
self.penup()
self.goto(postion)
self.shapesize(stretch_wid=5, stretch_len=1)
def Up(self):
ny = sel... |
11fd58cb93623e1d9193d88d019afc003140f4b0 | MayWorldPeace/QTP | /Python基础课件/代码/第六天的代码/02-文件的相关操作.py | 814 | 3.53125 | 4 | import os
# 1. 文件重命名
#
# os模块中的rename()可以完成对文件的重命名操作
#
# rename(需要修改的文件名, 新的文件名)
# os.rename("hm.txt", "hmhm.txt")
# 2. 删除文件
#
# os模块中的remove()可以完成对文件的删除操作
#
# remove(待删除的文件名)
# os.remove("hm[复件].txt")
# 3. 创建文件夹
# os.mkdir("黑马")
# 4. 获取当前目录
# ret = os.getcwd()
# 获取的是绝对路径(可以看到盘符)
# print(ret)
# 5. 改变默认目录
# ../ 上... |
6ee2ee2c4c50d29c9a6d14799d281785453f64b8 | juni-lee/KOOC_2018_Fall_IE481 | /01 Lecture/Week 2/W02_04_PolymorphismandAbstractClass_03.py | 1,160 | 3.859375 | 4 | """
Abstract class, or Abstract Base Class in Python
A class with an abstract method
What is the abstract method?
Method with signature, but with no implementation
Why use it then?
I want to have a window here, but I don't know how it will look like, but you should have a window here!... |
29d250750b316fdf65e1fcd43c8a43e0ab0341dd | sanjay000111/cyberassignment | /cyberassignment3/Q3.py | 225 | 3.890625 | 4 | def reversed_words(sentence):
list_of_words = sentence.split()
list_of_words.reverse()
reversed_line = " ".join(list_of_words)
print(reversed_line)
reversed_words("I am home")
reversed_words("We are ready") |
e66449ccba44d250d8af203b7fe27c2352f10ca4 | C-CCM-TC1028-111-2113/homework-4-JennyAleContreras | /assignments/28Fibonacci/src/exercise.py | 396 | 3.90625 | 4 | from math import sqrt
def fib(index):
while True:
if index < 2:
return index
else:
u = ((1+sqrt(5))/2)
j = ((u**index-(1-u)**index)/sqrt(5))
return round(j)
def main():
#escribe tu código abajo de esta línea
index=int(input("Enter the index: ... |
d1a2bc4e0793188664a9e6a9f69ae4021c528a56 | asharifisadr/Image-Processing | /HW0_9733044/Q3/HM0-Q3.py | 740 | 3.5625 | 4 | #!/usr/bin/env python
# coding: utf-8
# In[23]:
import numpy as np
from matplotlib import pyplot as plt
def mapping(arr):
arr=(((arr-arr.min())/(arr.max()-arr.min()))*255) # mapping operation
arr = arr.astype('uint8') # changing data type to int
return arr
rnd = np.random.uniform(-3.2, 9.3, size=(50, ... |
71845286d42e6aefc0f190b9705fd76e6fca95e0 | pauladepinho/clube-de-programacao | /2019-10-08/areaDoRetangulo.py | 223 | 3.84375 | 4 | # Calcula a área de um retângulo
base = float (input ('Qual é a base do retângulo? '))
altura = float (input ('E qual é a altura? '))
area = int (base * altura)
print ('A área do retângulo é ' + str (area) + '.') |
55fb6560cdf2570eae0dcda153e2578fd906c1a3 | a-soliman/python-bible | /sec-07/tuples.py | 198 | 3.71875 | 4 | our_tuble = (1,2,3,'a','b','c')
print(our_tuble[0:3])
a = [1,2,3]
b = tuple(a)
print(b)
#assining variables using tuples and lists
c,d,e = (3,4,5)
print(e)
f,g,h = [100, 200, 300]
print(g) |
36d30e205ab644b5d5770cf8fc4f75801b101277 | layshidani/learning-python | /lista-de-exercicios/Curso_IntroCiênciadaCompPythonParte 1_Coursera/SEMANA_4/S4OP1-primo.py | 348 | 3.734375 | 4 | # coding: utf-8
print('-' * 40)
print('Somador de número inteiro'.center(40, '-'))
print('-' * 40)
n = int(input('\nDigite um número inteiro: '))
i = 0
if n == 0 or n == 1:
print('não primo')
else:
for divisor in range(2, n):
if (n % divisor) == 0 and (n != divisor):
i += 1
if i != 0:
print('não primo')
... |
2b0eefbf6badc335d5b675529ab10cc38d7b9306 | psnakhwa/Python-Exercises | /Python Coding Exercises/stack.py | 1,766 | 4.03125 | 4 | from sys import maxsize
#Implementation of stack using arrays
class Stack():
def __init__(self):
self.items = []
def isEmpty(self):
return (self.items == [])
def push(self,item):
self.items.append(item)
def pop(self):
if self.isEmpty():
prin... |
4118bc8cda3b86b84b0316662f4d2ad06106674f | Monamello/introducao-programacao-python-exercicios | /capitulo_6/exercicio6-3.py | 303 | 3.890625 | 4 | # Faça um programa que percorra duas listas e
# gere uma terceira sem elementos repetidos
lista_1 = [1, 2, 3]
lista_2 = ["a", "b", "c", 1, 2,]
tam = len(lista_1)
x = 0
while x < tam:
pos = lista_1[x]
if not pos in lista_2:
lista_2.append(pos)
x+=1
listao = lista_2
print(listao) |
b582dbd0682c2578e97072021dd0fc960e606f24 | caryt/utensils | /money/tests.py | 1,239 | 3.96875 | 4 | """Test Money
=============
"""
from unittest import TestCase
from money import Dollars, Cents
dollars = Dollars(1.0)
cents=Cents(1)
class TestDollars(TestCase):
"""Test a :class:`.Dollars`.
"""
def test_test(self):
"""Test."""
self.assertEqual(5*dollars, Dollars(5.0))
self.assert... |
9e61ba4eb7055514a93625d8cbbd548d37060be7 | EswarSai/Python | /user41_x9iV2U9tnmSq1cc.py | 2,859 | 4.1875 | 4 | # template for "Guess the number" mini-project
# input will come from buttons and an input field
# all output for the game will be printed in the console
import simplegui
import random
import math
no_of_chances_used = 0
secret_number = 0
range = 100 # default range is [0,100)
# helper function to start and restart t... |
38cf18b3112a10cbfd8df05f86491dc2eedda4ff | vbukovska/SoftUni | /Python_advanced/Ex2_tuples_and_sets/unique_usernames.py | 360 | 3.53125 | 4 | def input_lines_to_list(count):
lines = []
for _ in range(count):
line = input()
lines.append(line)
return lines
def custom_print(lines):
for line in lines:
print(line)
count_input_lines = int(input())
input_lines = input_lines_to_list(count_input_lines)
unique_users = set(... |
ad523a6c0a6b84f43e62050999ac6ca60f8bf092 | emdemor/cov19 | /cov19/country.py | 3,426 | 3.53125 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Description
----------
The country object contains information and actions
related the countries that are important to understand
the Covid dissemination
Informations
----------
Author: Eduardo M. de Morais
Maintainer:
Email: emdemor415@gmail.com
... |
5eef86a5181166e27738d52e92fc479f4477c57e | WoodsChoi/algorithm | /view/offer-33.py | 1,785 | 4.03125 | 4 | # 二叉搜索树的后序遍历序列
# medium
'''
输入一个整数数组,判断该数组是不是某二叉搜索树的后序遍历结果。如果是则返回 true,否则返回 false。假设输入的数组的任意两个数字都互不相同。
参考以下这颗二叉搜索树:
5
/ \
2 6
/ \
1 3
示例 1:
输入: [1,6,3,2,5]
输出: false
示例 2:
输入: [1,3,2,6,5]
输出: true
来源:力扣(LeetCode)
链接:https://leetcode-cn.com/problems/er-cha-sou-suo-shu-de-hou-xu-bian-li-xu-lie-... |
d0992bb5fc916b4c9b3054d420c2c445e2af2a62 | KBiz65/Project-Euler-100 | /Problem_23_Non-abundantsums.py | 2,107 | 3.96875 | 4 | #A perfect number is a number for which the sum of its proper divisors is
#exactly equal to the number. For example, the sum of the proper divisors of 28
#would be 1 + 2 + 4 + 7 + 14 = 28, which means that 28 is a perfect number.
#A number n is called deficient if the sum of its proper divisors is less than
#n and it i... |
d8f0073486012aea69f0f8484d6206158e35132e | Aasthaengg/IBMdataset | /Python_codes/p03424/s325437058.py | 164 | 3.53125 | 4 | n = int(input())
s = list(map(str, input().split()))
import collections
s = collections.Counter(s)
if len(s.keys()) == 3:
print("Three")
else:
print("Four") |
14de3b808f02c42eb798fc722b96fce69b82aed9 | Yazurai/ELTE-IK-19-20 | /PY/Week 2/HUFtoEUR.py | 314 | 3.78125 | 4 | n = 0.0
inputSuccess = False
while not inputSuccess:
inputSuccess = True
try:
n = int(input("Please enter n:"))
except ValueError:
inputSuccess = False
print('Please enter a valid number!')
for n in range(1, n, 1):
print(str(n) + "HUF is " + str(n * 0.00299728261) + "EUR.") |
7e58b244a5d9137bd52b330fc6ef4664b27a9fd6 | MuskaanVerma/Python-Assessment-2018 | /PythonAssignmentFolder/Question1/ques1.py | 1,318 | 4.21875 | 4 | #!/usr/bin/env python
import re
import string
import sys
import logging
#Used to load configuration from file and level is set to INFO(which will act like Print statement
#likewise we can also debug, create a warning, display errors
logging.basicConfig(filename='test1.log',level=logging.INFO)
#validate function is val... |
fbc16d69321f07833c80dc80ae551398a9c21147 | Swapnil7711/Python-Programming-Challenges | /Easy/10 Time Conversion.py | 777 | 3.84375 | 4 | '''
Given a time in -hour AM/PM format, convert it to military (24-hour) time.
----------------------------------------------------------------------------
Sample Input
07:05:45PM
Sample Output
19:05:45
'''
#!/bin/python3
import sys
import datetime
time = input().strip()
arr = time.split(':')
if('PM' in time):
... |
6f157a9959ce5ad11a3384ed58dccc9c7a3992b3 | livetoworldlife/class2-module-assigment-week05 | /1.randomly_picks.py | 1,979 | 4.25 | 4 | """
Write a program which randomly picks an integer from 1 to 100.
Your program should prompt the user for guesses – if the user guesses incorrectly,
it should print whether the guess is too high or too low. If the user guesses correctly,
the program should print how much time the user spend to guess the right answer... |
e2189465711555d5ca59e10ec086318b7a5dd760 | bigeyesung/Leetcode | /590. N-ary Tree Postorder Traversal.py | 1,060 | 3.703125 | 4 | """
# Definition for a Node.
class Node:
def __init__(self, val=None, children=None):
self.val = val
self.children = children
"""
class Solution:
def postorder(self, root: 'Node') -> List[int]:
#T:O(n)
#S:O(h):tree height
# def dfs(root, arr):
# if not root:
... |
7f9f99011c5bc2a138579e3ba7e264e5c037dc30 | challeger/leetCode | /每日一题/2020_09_17_冗余连接I.py | 2,237 | 3.5625 | 4 | """
day: 2020-09-17
url: https://leetcode-cn.com/problems/redundant-connection/
题目名: 冗余连接
在本题中,树指的是一个连通且无环的无向图.
输出一个图,该图由一个有着N个节点(节点值不重复)的树及一条附加的边构成.附加的边的
两个顶点包含在1到N中间,这条附加的边不属于树中已存在的边.
结果图是一个以 边 组成的二维数组,每一条 边 的元素都是一堆[u, v],满足u < v,表示连接顶点
u和v的无向图的边.
返回一条可以删去的边,使得结果图是一个有着N个节点的树,如果有多个答案,则返回二维数组中最后出现
的边,答案边[u, v]应满足相同的格... |
e11b621c3011dd8ac6309521f7cd53b74e0dcc28 | Gyczero/Leetcode_practice | /矩阵旋转/leetcode_48_顺时针旋转.py | 762 | 3.875 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time : 2019/10/16 6:40 下午
# @Author : Frankie
# @File : leetcode_48_顺时针旋转.py
from typing import List
class Solution:
def rotate(self, matrix: List[List[int]]) -> None:
"""
Do not return anything, modify matrix in-place instead.
观察矩阵
... |
038aa10fe714b85babcb2bc2822aa9263b8bb393 | Hou-J/LeetCode | /003_LongestSubstringWithoutRepeatingCharacters.py | 940 | 3.796875 | 4 | # https://leetcode.com/problems/longest-substring-without-repeating-characters/description/
#
# Given a string, find the length of the longest substring without repeating characters.
#
# Examples:
#
# Given "abcabcbb", the answer is "abc", which the length is 3.
#
# Given "bbbbb", the answer is "b", with the length... |
6c5fed074b3432ea4e5e98001cc12ea0d48b5432 | Srikar-ai/Graph-Traversals | /DFS_of_graph.py | 345 | 3.875 | 4 | visited=set()
def DFS(visited,graph,node):
if node not in visited:
print(node)
visited.add(node)
for neighbour in graph[node]:
DFS(visited,graph,neighbour)
graph={
'A' : ['B','C'],
'B' : ['D', 'E'],
'C' : ['F'],
'D' : [],
'E' : ['F'],
'F' : []
}
DFS(... |
e2f8bbf4f2b173c739d4a58b41f3f2b7d1a10a65 | oyugirachel/PythonGames | /welcomMat.py | 200 | 3.53125 | 4 | f,d=list(map(int,input().split()))
for i in range(1,f,2):
a=".|." * i
print(a.center(d,"-"))
a="Welcome"
print(a.center(d,"-"))
for i in range(f - 2,0,-2):
a=".|." * i
print(a.center(d, "-"))
|
d4ea151b0823630bcf663948cba26b055e5a308f | walteregli1/miscellanies | /10zze.py | 960 | 4.0625 | 4 | # look for a number 10 digits all digits are
# used 0,1,2,3,4,5,6,7,8,9
# and in each position the number, counting from the start (left)
# is a multiple of the digit at the position.
# 10 Zahl
# python recursive script WE 22.March 2020
##########################################
z=['1','2','3','4','5','6','7','8','... |
bc34046e9b308055f45c05e7458ad0eb9d19e055 | chun337163833/word-poker | /words_analysis/tile_gen.py | 1,385 | 4.0625 | 4 | """
Uses the strings we generated to prepare a list of tiles that can be dealt to users
"""
import itertools
with open("dict") as f:
strings = f.readlines()
f.close()
f = open("tiles", "w")
for s in strings:
tile_row = []
s = s.strip()
# Extract the 5 community tiles
comm = list(s[0:5])
tile_row.extend(co... |
57479abdb042ee10cafc90636634caa11dead116 | kuleana/ay250_pyseminar | /homework1/homework1b.py | 1,290 | 3.6875 | 4 | # homework1b.py - creates imitation plot of given data
# homework 1b AY 250
# Feb 4, 2012
# Katherine de Kleer
# import packages
import numpy as np
from pylab import *
# read in the data from file
kw={'skiprows':1}
nytemps = np.loadtxt('ny_temps.txt',**kw) #MJD, max temp
google = np.loadtxt('google_data.txt',**kw) #M... |
b1a2cd0497ccdf62d318949251699bb45e223c56 | dlichacz/python-samples | /Blackjack.py | 5,315 | 3.796875 | 4 | from random import shuffle
suits = ['H', 'D', 'S', 'C']
# Create dictionary of the values of each rank. Issue of Ace being 11 will be dealt with later.
values = {'A':1, '2':2, '3':3, '4':4, '5':5, '6':6, '7':7, '8':8, '9':9, '10':10, 'J':10, 'Q':10, 'K':10}
class Player(object):
def __init__(self, name, ban... |
ec19e81273024f7782e09ae7e9ee019a4e01e1fe | staho/PSI_GCP04_zima_2017-2018_Kamil_Stachowicz | /PSI_1/perceptron.py | 1,985 | 3.71875 | 4 | #!/usr/bin/python
import random
class Perceptron:
def __init__(self, lr):
self.weights = [0,0,0]
self.weights[0] = random.uniform(-1,1)
self.weights[1] = random.uniform(-1,1)
self.weights[2] = random.uniform(-1,1)
self.wrong = 0
self.x = 0
self.y = 0
... |
1cd12a737f03f65f48758ce8e9741e7feb4dd0fa | robertawatson/py_beginner | /FVCalc.py | 688 | 4.0625 | 4 | # Simple Future Value Calculator
# This compounds at a fixed periodic rate and assumes there are no payments/coupons.
def calc(PV, r, n):
FV = PV*((1+r)**n)
return FV
def main():
print("This is a simple future value calculator.")
PresVal = float(input("Please enter a present value: "))
rate = flo... |
62b099d0841587cbb70d55a12822a61c6488d925 | KevinBoxuGao/CCC | /2019/junior/j1.py | 270 | 3.875 | 4 | team_one = []
team_two = []
for i in range(3,0,-1):
team_one.append(int(input())*i)
for i in range(3,0,-1):
team_two.append(int(input())*i)
if sum(team_one) > sum(team_two):
print("A")
elif sum(team_one) == sum(team_two):
print("T")
else:
print("B") |
35611e278035c8df0f1768a4d601fcb8d5d284e1 | bgoonz/UsefulResourceRepo2.0 | /GIT-USERS/TOM-Lambda/CSEU4-Algorithms-GP/complexity.py | 644 | 3.71875 | 4 | # Runtime of a iterative function
<<<<<<< HEAD
def some_func(n): # O(n)
if n == 1:
return
i = 0
while i <= n: # O(n) * O(1) + 1 (O(1) * O(n)) => O(n) + 1 => O(n)
=======
def some_func(n): # O(n)
if n == 1:
return
i = 0
while i <= n: # O(n) * O(1) + 1 (O(1) * O(n)) => O(n) + 1 =... |
69c5bb33fbd00b0c727ef982f2b4eb87d732dc03 | 00009115/CSF.Seminars | /Week 7/Task 1/main.py | 812 | 3.609375 | 4 | class Student:
def __init__(self, id, marks):
self.id = id
self.marks = marks
def calculator(self):
total_mark = 0
for mark in self.marks:
total_mark += mark
return total_mark / len(self.marks)
def display(self):
print("Average mark is:", self.c... |
b4f345385c05fe0771eec118ae5cc6d6dfdb8df1 | zhangshv123/superjump | /interview/google/face/word_square.py | 1,561 | 3.75 | 4 | """
Word Square definition, 0<=k<n(width/length), row k and column k are idenitcal
eg: row 1: ABCD and column 1:ABCD are the same
"""
from copy import deepcopy
def word_square(strs, k):
"""
:type strs: List[str], k: int
:rtype: List[List[str]]
"""
strs_filtered = [s for s in strs if len(s) <= k]
... |
96430e89a05f31add691486f4e5562b52777fbb9 | shailesh05/algorithm-functional_program | /insertionsort_for_string.py | 401 | 4 | 4 | def string_insert():
size = int(input("enter the size"))
list1=[]
for i in range(size):
val=input("enter the word")
list1.append(val)
for i in range(1,len(list1)):
temp=list1[i]
j=i-1
while (j>=0) and (temp<=list1[j]):
list1[j+1]=list1[j]
... |
2c53439fca170dc7d24a510fe7c6b0d8ce354e06 | kre-men/Microsoft-DEV236x- | /Module 3 Conditionals/Practice/Part3__Comparison Operators and If Comparison(Examples and Task 1-2).py | 852 | 4.375 | 4 | # [ ] review and run code to see if 3 greater than 5
3 > 5
# [ ] review and run code to see if 3 less than or equal to 5
3 <= 5
# [ ] review and run code
# assign x equal to 3
x = 3
# test if x is equal to
x == 9
# [ ] review and run code
x = 3
print("x not equal 9 is", x != 9)
print("x equal 3 is", x == 3)
print()
... |
4b4572e96d1017be6d10d9951abb1b57542a47cb | Yobretaw/AlgorithmProblems | /EPI/Python/Searching/12_2_search_sorted_array_for_first_elment_greater_than_k.py | 1,114 | 3.8125 | 4 | import sys
import os
import math
import imp
import random
import functools
"""
Design an efficient algorithm that takes a sorted array and a key, and finds
the index of the first occurence of an element greater than that key.
"""
def find_first_occurence_greater_than_key(arr, k):
n = len(arr)
if n < 2:... |
593d12b454482caed55ece41c814f7089437c173 | ai-mosaic/course | /appendix_i/solutions/10.py | 230 | 3.78125 | 4 | with open("three_columns.csv","r") as f:
numbers = [ [float(y) for y in x.split(",") ] \
for x in f.read().split("\n") if len(x)>0 ]
i = 2
j = 1
print( sum(numbers[i]) )
print( sum([x[j] for x in numbers]) )
|
515bf6a994991d97e381504b9c603c9eb0915a27 | liambloom/Python | /yesno.py | 237 | 3.78125 | 4 | import re
def yn(question):
res = input(question + "? ")
if re.search("yes", res, re.IGNORECASE): return True
elif re.search("no", res, re.IGNORECASE): return False
else: return yn('Please answer with "yes" or "no". ' + question) |
9718066d59cdbd0df8e277d5256fd4d7bb10d90c | JasmanPall/Python-Projects | /Swap variables.py | 290 | 4.25 | 4 | # This program swaps values of variables.
a=0
b=1
a=int(input("Enter a: "))
print(" Value of a is: ",a)
b=int(input("Enter b: "))
print(" Value of b is: ",b)
# Swap variable without temp variable
a,b=b,a
print(" \n Now Value of a is:",a)
print(" and Now Value of b is:",b) |
7cb3ec6edd7ec3fd103997aab88f407ef0057d7a | satheesh22g/Image-Filtering-Using-Python | /image_filter.py | 4,691 | 3.671875 | 4 | import cv2
import numpy as np
class Cartoonizer:
"""Cartoonizer effect
A class that applies a cartoon effect to an image.
The class uses a bilateral filter and adaptive thresholding to create
a cartoon effect.
"""
def __init__(self):
pass
def render(self, im... |
8c6e9afce7ccd7a4d7efffcf8734e8bef806918d | jerryz123/gym-driving | /gym_driving/assets/rectangle.py | 3,658 | 3.75 | 4 | import numpy as np
class Rectangle(object):
"""
Baseline rectangle class.
"""
def __init__(self, x, y, width=50, length=25, angle=0.0):
"""
Initializes rectangle object.
Args:
x: float, starting x position.
y: float, starting y position.
angl... |
2729edf75025c5a911bd1c81ddd20020f1a5badb | bruckhaus/challenges | /python_challenges/project_euler/p023_non_abundant_sums.py | 2,843 | 4.03125 | 4 | from collections import defaultdict
class NonAbundantSums:
# Non-abundant sums
# Problem 23
# A perfect number is a number for which the sum of its proper divisors is exactly equal to the number.
# For example, the sum of the proper divisors of 28 would be 1 + 2 + 4 + 7 + 14 = 28,
# which means th... |
d26150cc679bee29122699b44052c8e608f1cf2d | cjmking2010/python_study | /Crossin/lesson72.py | 543 | 3.78125 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
# Filename: lesson72.py
# Author: peter.chen
lst_1 = [1,2,3,4,5,6]
lst_2 = []
for item in lst_1:
lst_2.append(item * 2)
print lst_2
lst_1 = [1,2,3,4,5,6]
lst_2 = [i * 2 for i in lst_1]
print lst_2
lst_1 = (1,2,3,4,5,6)
lst_2 = map(lambda x: x * 2,lst_1)
print lst_2
... |
f25509ead0a6dec819920afc4521dd601e95498a | Gelivabilities/Data-mining | /Matplotlib/图表基本元素.py | 1,111 | 3.5625 | 4 | import numpy as np
import pandas as pd
import matplotlib.pyplot as plt#注意目前的导包都是小写的
df=pd.DataFrame(np.random.rand(10,2),columns=['A','B'])#2列dataframe
f=plt.figure(figsize=(10,10))
fig=df.plot(figsize=(6,4))#对dataframe df的一个Figure
print(fig,type(fig),'\n')
print(f,type(f))
plt.title('myname')
#x,y轴标签
plt.xlabel('x'... |
99ee1e6a102b8d93bcabca1599881d33e99089ac | ridhim-art/practice_list2.py | /functions/default_parameters.py | 457 | 3.65625 | 4 | def remove_punc(sentence,punctuation='!@#$%^&*()_+`:"[]'):
for item in punctuation:
if item in sentence:
sentence = sentence.replace(item,'')
print(sentence)
msg = "hi there, )*(!@#*where is th*)(&!@)#e secre!@#)(!*@#)t for the:!@ treasure"
remove_punc(msg,'()*!@#*&:')
remove_punc(msg)
def... |
a6e62c4e768ced97cd2871d9b1f506208f3e8323 | idealgupta/pyhon-basic | /input outpur.py | 190 | 3.90625 | 4 | print('adarsh')
a={'c':18 , 'b':20}
print("value of a is",a['c'], "value of b is ",a['b'])
print("my name is {0}, class{1}" .format("adarsh","10"))
num=input("kuch dal be ")
print(num) |
0f65c5b224de4891f929f4e037c6886ae27c3f98 | MaiconRenildo/Python | /Python 2.7/Códigos/Provas/P2/Questao1.py | 432 | 3.921875 | 4 | string=raw_input('Informe a string que sera verificada: ')
metade=len(string)//2
ultimo=len(string)-1
i=0
palindromo=True
stringb=''
f=0
j=3
while f<j:
stringb=stringb+string[f]
while i<=metade:
if string[i]!=string[ultimo-i]:
palindromo=False
i=metade+1
else:
... |
41f9217ea5da57558604c234aaa0c5cc9db194e9 | codingiscool121/Data-Sampling--C110-Project | /hw.py | 1,022 | 3.546875 | 4 | import statistics as st
import pandas as pd
import plotly.figure_factory as pf
import plotly.graph_objects as go
import random as rand
data = pd.read_csv("medium_data.csv")
readtime = data["reading_time"].tolist()
populationmean = st.mean(readtime)
populationsd = st.stdev(readtime)
print("The population mean... |
3a56d406c752da4ce2516c5deeeeba016e4ad2b2 | mvsparks/School | /Scripting/lab5/exr1.py | 239 | 3.765625 | 4 | #!/usr/bin/python
#what's missing on the first line?
from math import sqrt #or import math as m
x = input('please enter a number: ')
print 'Square root is: ', sqrt(x) #if you give math another alias use m.sqrt(x)
|
5ac27d9a1f1939dc0a36627cf40c21884738036a | jz33/LeetCodeSolutions | /238 Product of Array Except Self.py | 740 | 3.5 | 4 | '''
238. Product of Array Except Self
https://leetcode.com/problems/product-of-array-except-self/submissions/
Given an array nums of n integers where n > 1,
return an array output such that output[i] is equal to the product of all the elements of nums except nums[i].
Example:
Input: [1,2,3,4]
Output: [24,12,8,6]
No... |
c739ef65990521567300ef9e31fa649042f3b9f5 | pganjhu/Python-Practice-Progms | /prog50.py | 1,039 | 3.96875 | 4 | # -*- coding: utf-8 -*-
"""
Created on Tue Aug 25 18:05:58 2020
@author: Pawan
"""
'''ou are given a string .
Your task is to verify that is a floating point number.
In this task, a valid float number must satisfy all of the following requirements:
Number can start with +, - or . symbol.
For example:
✔
... |
e2a6fd73ddb9c80d32833d5fc168e19023a279ff | KatyaKalache/holbertonschool-higher_level_programming | /0x06-python-test_driven_development/tests/6-max_integer_test.py | 853 | 3.90625 | 4 | #!/usr/bin/python3
"""Unittest for max_integer([..])
"""
import unittest
max_integer = __import__('6-max_integer').max_integer
class TestMaxInteger(unittest.TestCase):
def test_int_negative(self):
self.assertEqual(max_integer([-2, -1, -3]), -1)
def test_floats(self):
self.assertEqual(max_inte... |
2aae92812631b850bb24eb2cf4f805d5462cfe27 | kzrs55/learnpython | /niukeTest/test2/test1.py | 295 | 3.796875 | 4 | # -*- coding: utf-8 -*-
import sys
def f(n):
while True:
if n % 2 == 1:
return n
n = n / 2
if __name__ == "__main__":
# 读取第一行的n
n = int(sys.stdin.readline().strip())
sum = 0
for i in range(n):
sum += f(i + 1)
print sum
|
760b05fc245b6d4820ccb865abfb33718f498361 | murbook/Python | /basic/type.py | 747 | 4.125 | 4 | #type関数を使って変数の型を確認する
myvar = 1234
print(type(myvar))
mystr = "Hello"
print(type(mystr))
mylist = [1,2,3,4]
mydict = {"one":1, "two":2, "three":3}
print(type(mylist))
print(type(mydict))
def myfunc():
return(0)
print(type(myfunc))
print()
#isinstance関数を使って変数が指定した型であるか確認する
myvar = 1234
print(isinstance(myvar, int... |
934825dee9e3b61542a0a13684846e12a310be51 | JosephLevinthal/Research-projects | /5 - Notebooks e Data/1 - Análises numéricas/Arquivos David/Atualizados/logDicas-master/data/2019-1/225/users/4001/codes/1756_2390.py | 163 | 3.546875 | 4 | from numpy import*
p = array(eval(input("Presentes: ")))
f = array(eval(input("Faltantes: ")))
i = 0
r = 1
while (p[i] != max(p)):
i = i + 1
r = r + 1
print(r) |
be14276b9ece880dc0886f69565188c479905d65 | chikkuthomas/python | /advanced python/object oriented programming/Regular expression/regular2.py | 405 | 3.6875 | 4 | # this considers only strings ,not numbers
import re
n='56kg'
x='\d*\w*'
match=re.fullmatch(x,n)
if match is not None:
print("valid")
else:
print("invalid")
# # OTHER WAY #
# n='56kg'
# x='\[0-9]{2}[a-z]{2}' # checking whether digits from (0-9)and also 2 alphabets from a-z is also satisfied
# match=re.fullma... |
2216ca69d7953c80f81f5de6c0c93e4599cf4c77 | JackieBinBin/zzh1988 | /fin290_hw3/fin290_hw3_02.py | 1,435 | 4.09375 | 4 | # Write python code that reads the text document and counts the unique words
# and stores the words and counts into a dictionary
word_count = {} # 定义字典变量
with open('C:\\Users\\Gary\\Desktop\\zzh\\dracula.txt') as f:
for word in f.read().split():#读文件并过滤掉空格
if word not in word_count:
word_count[... |
5d51427733e5739c24aaf8e7e2955fba20a82994 | wellingtonlope/python-curso-em-video | /desafios/desafio023.py | 535 | 4.09375 | 4 | # -*- coding: utf-8 -*-
numero = input('Digite um número: ')
if(len(numero) == 4):
print('unidade: {}'.format(numero[3]))
print('dezena: {}'.format(numero[2]))
print('centena: {}'.format(numero[1]))
print('milhar: {}'.format(numero[0]))
elif(len(numero) == 3):
print('unidade: {}'.format(numero[2]))
print('dezen... |
6718508e4fcbce2631688235287e6146a9b4ef30 | correl/euler | /python/e042.py | 1,518 | 4.0625 | 4 | # -*- coding: utf-8 -*-
"""How many triangle words does the list of common English words contain?
The nth term of the sequence of triangle numbers is given by, tn = ½n(n+1); so the first ten triangle numbers are:
1, 3, 6, 10, 15, 21, 28, 36, 45, 55, ...
By converting each letter in a word to a number correspondin... |
c0e68545128c1cce0d4abeb2611780697fa4f298 | griffithcwood/Image-Processing | /GUI.py | 2,570 | 3.765625 | 4 | import functions as f
import sys
__name__ = "Griff Wood"
__version__ = "2.5"
"""The GUI section of the Image Recognition Project. It's fairly rudimentary but it works """
def showMenu():
'''shows the main menu in terminal and functions as a GUI'''
while(True):
print("0: Explanation \n " +
"1:... |
382d843f9f766cf99a4a77c341ecea1106f161c7 | MatthewHardcastle/Image-Car-Detection | /main.py | 1,674 | 4.125 | 4 | import cv2
#opencv documentation
#https://docs.opencv.org/2.4/modules/objdetect/doc/cascade_classification.html?highlight=detectmultiscale
img = "car.jpg" #Declaring the img to the one located in your python file
Car_Classifier = "cars.xml" #Car classifier xml file-this xml will check our image and check it again... |
8253e5dca597dea8a24a5f639d7f5b9e7d12c915 | swkim0128/Algorithm | /python/src/main/algorithms/programmers/stackqueue/testKit03.py | 1,033 | 3.71875 | 4 | """
문제 - 기능 개발
배포되어야 하는 순서대로 작업의 진도가 적힌 정수 배열 progresses와 각 작업의 개발 속도가 적힌 정수 배열 speeds가 주어질 때
각 배포마다 몇 개의 기능이 배포되는지를 return 하도록 solution 함수를 완성
"""
def solution(progresses, speeds):
# 종료 조건 : progresses 들이 모두 100%가 될 때까지
# n 일차 마다 각 progresses는 작업율을 각 speeds만큼 증가
# 작업률이 100% 이면 pop, count 증가
cou... |
dad54af95ab85803b6cce9c30b9746b798006fdb | lihaibo3653/python-d-class-1 | /test3.py | 105 | 3.5 | 4 |
if False:
print("true")
else:
print("false")
#这是一行注释
'string'
"string"
'string' |
bd5dabf0df95025ac7b1142ebbf02186edbc1cbf | oojo12/ml-algorithms | /rdfn.py | 3,195 | 3.84375 | 4 | """ Implementation of radial basis neural network. It is programmed to have 3
layers and a sigmoid activation function with batch gradient descent"""
import numpy as np
import pandas as pd
from math import log,floor
__author__ = "Femi"
__version__ = "1"
__status__ = "starting"
class rbf():
def __init__(self,x_tr... |
e138698a537dc83c54b9c868d48ea300e49ec39e | FAHM7380/group6-Falahati | /Final Project/report functions.py | 16,270 | 4.21875 | 4 | # for acquiring a balance for specific units and specified time period please type balance(root_in) in python console
# for obtaining a csv file including a transaction history between a specific time period transaction_history(root_in, root_out) in python console
# for acquiring a percent share from total expenses t... |
186333574e82f115175e57614cb974c88fa566c0 | yamato1992/at_coder | /abc/abc071/b.py | 144 | 3.578125 | 4 | import string
s = set(list(input()))
ans = 'None'
for c in string.ascii_lowercase:
if not c in s:
ans = c
break
print(ans)
|
6d607486528cf6027895c5c1fe5c7c7491328b9f | Vika-Zil2020/python | /permutations.py | 2,094 | 3.546875 | 4 | <<<<<<< HEAD
# my_list = []
# for a in range(0,10):
# for b in range(0,10):
# for c in range(0,10):
# num =str(a)+str(b)+str(c)
# if num not in my_list and int(num)<1000:
# my_list.append(num)
# print(my_list)
# a = 0
# b = 0
# c = 0
# for l in range (a,10):
# for j in range(b,10):
# for f in range(c,1... |
468be8025e3d93030d587a7a00bff56f66abaa20 | dmitri-dev/Algorithms | /math.py | 2,818 | 4.25 | 4 | import math
from functools import lru_cache
# Fibonacci
def fibonacci(n):
sequence = [0, 1, 1]
for i in range(3, n + 1):
sequence.append(sequence[i - 1] + sequence[i - 2])
return sequence[n]
def fibonacci_2(n, memo):
if n in memo:
return memo[n]
if n <= 2:
... |
3d563e6fa352342d141e5ad75dc63706a17cb038 | Anh-KNguyen/Advance-Python | /iter-rec-enumerate.py | 786 | 3.84375 | 4 | from typing import *
def iterativeEnumerate(items: List[str]) -> List[Tuple[int, str]]:
out = []
count = 0
for item in items:
tup = (count, item)
out += [tup]
count += 1
return out
def recursiveEnumerate(items: List[str]) -> List[Tuple[int, str]]:
def helper(count: int, ls... |
7004144e3d3a9b2e98b99ebc39561887320d5e5b | abhaykr201/data_analysis_challenge | /Question5.py | 732 | 3.546875 | 4 | import matplotlib.pyplot as plt
import pandas as pd
import numpy as np
import csv
import ast
df=pd.read_csv("data.csv")
df1990 = df[ df['Year']==1990 ]
df2 = df1990[['Neonatal mortality rate (per 1000 live births)','Country']]
df2.reset_index(inplace=True)
df2['average'] = pd.DataFrame(df2['Neonatal mort... |
0857c58b516502eac9db0a774d545290a19a394f | VitaliiFisenko95/python_lk | /lk13/HW.py | 2,420 | 3.671875 | 4 | """
Создать класс воина, создать 2 или больше объектов воина с соответствующими воину атрибутами. Реализовать методы,
которые позволять добавить здоровья, сменить оружие. Реализовать возможность драки 2х воинов с потерей здоровья,
приобретения опыта.
Следует учесть:
- у воина может быть броня
- здоровье не может быть... |
a53807dd4a28665b190ce7f046fb3f6d365d377a | gulsher7/Python_Programs | /functions/workingfunc.py | 164 | 3.984375 | 4 | num1 = int(input("enter number"))
num2 = int(input("enter number"))
num3 = int(input("enter number"))
def add(x,y,z):
print(x + y + z)
add(num1, num2, num3)
|
6014bac9c3af149be7cd1b1524fe839dea0f5752 | AdamantLife/AL_Text | /AL_Text/texttable.py | 21,911 | 3.578125 | 4 | """
A Module for Outputting Monospaced Text Tables
Usage:
TextTable.printtable(options) : print()'s a Monospaced Text Table
TextTable.gettable(options): As above, but returns the string instead of print()ing it
TextTable(options) : Initializes a new TextTable Object. Allo... |
2cc42055d20ad5d4c5fb5b7c5445c9b974acadc5 | sakira/UdemyReinforcementLearning | /policy_iteration.py | 3,162 | 3.6875 | 4 | # -*- coding: utf-8 -*-
"""
Created on Tue Dec 24 11:52:44 2019
@author: sakirahas
Step 1: Randomly Initialize V(s) and policy pi(s)
Step 2: V(s) = iterative_policy_evaluation(pi) to find the current value of V[s]
Step 3: policy improvement
We have a flag
policy_changed = False
we loop through all the states
for s i... |
3030543397fc9c85a54cc67570188debc299521e | DharaTandel/Python | /Task_Three/T3_9.py | 125 | 3.6875 | 4 | n=int(input("Enter the value of n: "))
d={}
for i in range(1,n+1):
d[i]=i*i
i+=1
print(d)
|
d463fae779e01ee12a4cfb7237b58bfeebb67e50 | Nihooo/Python | /Python_Basic/19.Class_other/3.Combine.py | 1,605 | 4 | 4 | # 组合 大类包含小类,类与类之间没有共同点,但有关联
'''
class Hand:
pass
class Foot:
pass
class Trunk:
pass
class Head:
pass
class Person:
def __init__(self, id_num, name):
self.id_num = id_num
self.name = name
self.hand = Hand()
self.foot = Foot()
self.trunk = Trunk()
... |
65978b0775e58b017313d80b097ce6594179dcc2 | zouy50/Algorithm | /数据结构/树/baseTree.py | 2,250 | 3.875 | 4 |
class Node:
"""
树的结点类
"""
def __init__(self, parent, data, children: list = None):
"""
:param parent: 父结点
:param data: 结点数据
:param children: 子结点列表
"""
self.parent = parent
self.data = data
if children is None:
self.children =... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.