blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string |
|---|---|---|---|---|---|---|
b1d4baff4a56fc3334e77380540c9184d41a0aad | cstmdzx/12DownLoader | /win/main.py | 7,894 | 3.546875 | 4 | # coding=gbk
import os, urllib, urllib2, urlparse, HTMLParser
#ع
#´ԣhttp://www.cnpythoner.com/post/pythonurldown.html
def url2name(url):
return os.path.basename(urlparse.urlsplit(url)[2])
def reporthook(count,block_size,total_size):
print '\x0D','أ'+'%d MB' % int(count*block_size/(1024.0*1024.0... |
81ecba7c363729ac7b56b9d0373b820ab035ca47 | NDresevic/nonek | /examples/compiled_files/e02_compiled.py | 188 | 3.546875 | 4 |
### nonek ###
import random
import math
n = int(input())
sum = 0
while (n > 0):
sum = (sum + (n % 10))
n = (n // 10)
if (sum > 10):
print('veci')
if (sum <= 10):
print('manji') |
df44e7d9144979f40d0927ec913347ab80b47aa2 | aaronw4/Sprint-Challenge--Algorithms | /recursive_count_th/count_th.py | 813 | 4.0625 | 4 | '''
Your function should take in a single parameter (a string `word`)
Your function should return a count of how many occurences of ***"th"*** occur within `word`. Case matters.
Your function must utilize recursion. It cannot contain any loops.
'''
def count_th(word):
# LC_word = word.lower()
letters = list(wor... |
86ca864c11cc4a107a486665f28040435876ef9e | ramonvaleriano/python- | /Livros/Introdução à Programação - 500 Algoritmos resolvidos/Capitulo 2/Exercicios 2a/Algoritmo63_Lea36.py | 407 | 3.734375 | 4 | # Program: Algoritmo63_Lea36.py
# Author: Ramon R. Valeriano
# Description:
# Developed: 15/03/2020 - 18:50
# Updated:
valor_class = float(input("Enter with the value of the hour class: "))
quantity = int(input("Quantity of the class: "))
discount = float(input("Enter with the discount INSS: "))
value_quantity = valo... |
45e11c76a85cfb821763a4c72af887379b5ffd2c | mango0713/Python | /20191217-total.py | 188 | 3.90625 | 4 | import random
total = int(input("total :"))
sum = 0
for x in range (total) :
if random.randint (1, 6) == 2 :
sum = sum + 1
print (sum/total)
|
2b94db61766d5cd6dec69347bda69aa5bee77790 | wookiekim/CodingPractice | /Algorithm/암기.py | 483 | 4 | 4 | class Node:
def __init__(self, data=None):
self.data = data
self.next = None
class LinkedList:
def __init__(self):
self.head = None
def add_node(self, data):
new_node = Node(data)
new_node.next = self.head
self.head = new_node
linked_list = LinkedList()
lin... |
d32ecdcbaf9de7fc26a4393a72eaa95ff85afeb7 | anubhav-tandon/Haar-Cascade | /3.draw_on_img.py | 662 | 3.625 | 4 | # In this file we will draw some shapes and put some text on the image file.
import cv2
import numpy as np
img = cv2.imread('t1.png',cv2.IMREAD_COLOR)
cv2.line(img,(0,0), (800,800), (0,255,0), 15) ##bgr green
cv2.rectangle(img,(0,0), (250,150), (0,0,255), 5)
cv2.circle(img,(100,63), 55, (255,0,0), -1)
p... |
248e4edbb2baad9352cb27338bd1a5a5b70ffa6d | mosesxie/CS1114 | /HW #9/hw9.py | 2,059 | 3.71875 | 4 | def max_abs_val(lst):
absolutevaluelist = []
for element in lst:
if element < 0:
absolutevaluelist.append(element * -1)
else:
absolutevaluelist.append(element)
maxValue = max(absolutevaluelist)
return maxValue
def main_q1():
... |
d6f9d4842916d09ea5521196abe719ad9a45247f | ZipCodeCore/PythonFundamentals.Exercises.Solutions | /part11/test_shapes.py | 540 | 3.640625 | 4 | import unittest
import shapes
class RectangleTest(unittest.TestCase):
def test_area(self):
rect = shapes.Rectangle(2, 4)
expected = 8
actual = rect.area()
self.assertEqual(expected, actual)
def test_perimeter(self):
rect = shapes.Rectangle(2, 4)
expected = 12
... |
956eae83d7e5d53a2b2508dff2b088ddf3dccdf6 | queiker/Ekonomia | /Ekonomia.py | 4,674 | 3.859375 | 4 | debug_code = True
#
def procent_skladany_roczny():
print("\n" * 30)
print("""Procent składany z kapitalizacją roczną
""")
kapital_poczatkowy = float(input("Podaj kapitał początkowy : "))
oprocentowanie_roczne = float(input("Podaj liczbę oznaczającą oprocentowanie roczne : "))
ile_lat ... |
2d6e3f3044b1c790c3ae682f781df1f1275c7625 | FefAzvdo/Python-Training | /Aulas/009.py | 2,678 | 4.25 | 4 | # Manipulação de strings
frase = "Curso em Vídeo Python"
# Fatiamento
# Posição 0 e posição 9
print(frase[0], frase[9])
# Fatia da posição 9 até a posição 13
print(frase[9:14])
# Fatia da posição 15 até a posição 20
print(frase[15:21])
# Fatia da posição 0 até a posição 20 pulando de 2 em 2
print(frase[0:21:2])
... |
481bf58ac3e718e8090e8883e54cda0c8b5ab3e8 | Learning-and-Intelligent-Systems/stacking | /old/stability.py | 7,199 | 3.578125 | 4 | """
Copyright 2020 Massachusetts Insititute of Technology
Izzy Brand
"""
from block_utils import *
from filter_utils import *
import numpy as np
from copy import copy
from itertools import permutations, combinations_with_replacement
# TODO(izzy): right now I'm assuming sequential vertical contacts. This get's a
# lo... |
8d80668bf3d2af9d38dc8663a4a131c84aa3c959 | ElijahWxu/Python_for_Physics | /f2c_file_read.py | 652 | 3.5625 | 4 | ###Problem 4.3 ####
import os
cwd = os.getcwd()
print (cwd)
tempfile=["Temperature Data","-----","Fahrenheit degree:67.2"]
print (tempfile)
with open("temp.txt", "w") as f: # open a file to save the score
f.write('\n'.join(str(temp) for temp in tempfile))
f.close()
#open and read the file
f = ... |
f48ef5924b04d82217e3f36558979fda649878af | ar90n/lab | /contest/project_euler/problem_25/problem_25.py | 451 | 3.71875 | 4 | #!/usr/bin/env python
# -*- cofing:utf-8 -*-
import math
def fibo( n ):
golden_ratio = ( 1 + math.sqrt( 5 ) ) / 2
return int( math.floor( math.pow( golden_ratio , n ) / math.sqrt( 5 ) + 0.5 ) )
def digits( n ):
return len( str( n ) )
def main():
val0 = fibo( 1100 )
val1 = fibo( 1101 )
index = 1101
while( digi... |
14b2d7e61443e610060969420bcbebbea634150e | collintheestump/DeckDeals- | /Deals.py | 998 | 3.578125 | 4 | class dealOut(object):
deal = {}
restOfDeck = []
def deal(numPlayers,numCards):
from random import randint
suits=['S','H','D','C']
ranks=['A','2','3','4','5','6','7','8','9','10','J','Q','K']
deck=[]
players={}
# Build the Deck of Cards
for s in suits:
for r in ranks:
... |
0586f32e8077e34ba50179e6f13edf916903c324 | Vahid-Esmaeelzadeh/CTCI-Python | /educative/18 Palindromic Subsequences/03 Count of Palindromic Substrings.py | 359 | 3.875 | 4 | '''
Count of Palindromic Substrings
'''
def count_PS(st):
return helper(st, 0)
def helper(st, index):
if index == len(st) - 1:
return 1
count = helper(st, index + 1)
if st[index] == st[-1]:
count += 1
return count + 1
print(count_PS("abdbca"))
print(count_PS("cddpd"))
print(c... |
2959b8f0a99931e1e1385718c10017ba9bc27bf7 | EthanDF/museURL.py | /museURL.py | 846 | 3.53125 | 4 | import csv
from bs4 import BeautifulSoup
import requests
#Bib to URL List
museURLs = 'C:\\Users\\fenichele\\Desktop\\museURLs.csv'
def checkURL(url):
"""to check the URL of a muse journal"""
museURL = url
result = []
response = requests.get(url, verify=True)
s = response.status_code
retur... |
6585aaa503a9f66fd0221897ba9068b7a070a642 | Kevin9436/JianZhiOffer | /algorithm-quick-sort.py | 1,028 | 3.71875 | 4 | def quick_sort(nums):
if len(nums) == 0:
return nums
else:
quick_sort_partition(nums, 0, len(nums)-1)
return nums
def quick_sort_partition(nums, start, end):
if start >= end:
return
pivot = nums[start]
left = start
right = end
while left < right:
whi... |
492709530229e0b1e019f1a8b1485398fb6db8d8 | Mschikay/leetcode | /962. Maximum Width Ramp.py | 2,443 | 3.640625 | 4 | # Use two array to solve this problem. min_arr[i] is the minimum of the first i + 1 elements of A, max_arr[j] is the maximum of the last len(A) - j elements of A.
#
# The idea of this solution is: Suppose (i, j) is the answer, then A[i] must be the smallest element among the first i + 1 elements of A and A[j] must be t... |
8eb3e916b69842618c831fb2286d02b39725c3a6 | alexcampos09/Cracking-the-Code-Interview | /1.3.py | 178 | 3.53125 | 4 | def URLify(s):
return (s.lower().strip().replace(' ', '%'))
s1 = "Mr John Smith "
s2 = "Mr John Smith"
s3 = "Cats and Dogs"
print(URLify(s1))
print(URLify(s2))
print(URLify(s3))
|
dc97ce9cd29ecb9501126300edeaa63f0466cd3d | KFurudate/Atcoder_SHOJIN | /Atcoder/20200106_過去問精選10問/3_ABC_081_B_Shift_Only/ABC_072_B_OddStringABC_072_B_OddString.py | 78 | 3.5 | 4 | s = input()
n = len(s)
S = ''
for i in range(0, n, 2):
S += s[i]
print(S) |
5a9ae2cd4faa6ce6fda58c8ff95a442d4bcc95ee | mbergert/RedesNeuronales | /Perceptron/Perceptron.py | 1,541 | 3.609375 | 4 | from random import random, uniform
class Perceptron:
def __init__(self, *, pesos=None, b=None, num=None):
self.pesos = []
if num == None:
self.pesos = pesos
self.b = b
else:
for i in range(0, num ):
self.pesos.append(uniform(-2, 2))
... |
9acc333740120c855af81a6c1da926281ff60075 | Amarjeet28/Python-Code-Clinic | /mergeCSV.py | 1,033 | 4.09375 | 4 | """Merge "n"" csv files into one, they may have different number and order of columns"""
""" Key Learnings:
1. If For loop and some assignment is needed then think of:
self.dataSet = [pd.read_csv(eachPath) for eachPath in path]
2. Concat function in pandas library requires first element as List o... |
efd2947608249a852293b6f5da4b8bdea000403e | taogangshow/python_Code | /第1章 python基础/Python基础06-面向对象1/10-烤地瓜.py | 1,546 | 3.609375 | 4 | class SweetPotato:
def __init__(self):
self.cookedLevel = 0
self.cookString = "生的"
self.condiments = []
def __str__(self):
msg = "地瓜状态:"+self.cookString+"\n"+"烘烤等级:"+str(self.cookedLevel)+"\n"+"添加的佐料有:无"
if len(self.condiments)>0:
msg = "地瓜状态:"+self.cookString... |
a140fb9c7401095706b7cb0511c6e9c596c3f171 | LukaFenir/LidlParser | /tests/test_parsed_receipt.py | 3,565 | 3.65625 | 4 | import unittest
from typing import List
from parsed_receipt import ParsedReceipt
class TestParsedReceipt(unittest.TestCase):
def test_init(self):
print('Testing: ParsedReceipt object creation')
def test_parse_receipt_with_no_items(self):
# Given
items: List[str] = []
total: ... |
512928e95fa6a63d36a2f5b7ff991f1c79aff638 | caahnuns/URI | /Iniciante/1154_idades.py | 215 | 3.734375 | 4 | executar = 1
total = 0
cont = 0
while(executar == 1):
idade = int(input())
if(idade < 0):
executar = 0
else:
total += idade
cont += 1
print("{:.2f}".format(total/cont)) |
2406880c1b2663565c04906603592168005641ed | HarrisonScarfone/python-course | /first_oop_example/main.py | 440 | 3.671875 | 4 | import make_random_stuff
school = make_random_stuff.make_school(2, 3, 1, 3)
print(f'This is {school.name}!')
print(f'These are the teachers and the students in their class!\n\n')
for school_class in school.school_classes:
print(f'The class of {school_class.class_name} has {len(school_class.student_list)} studen... |
8eeef548617364ddde27863d2b6cb4d112a3f8ff | aker4m/c_algorithm | /python3/ch01/dbl_digits.py | 291 | 3.953125 | 4 | def int_input(string):
return int(input(string))
if __name__ == '__main__':
print("2자리 정수를 입력하세요.")
no = int_input("수는 : ")
while no < 10 or no > 99:
no = int_input("수는 : ")
print("변수 no 값은 {}이 되었습니다.".format(no))
|
b84207c6ada4d1e786883f5ee86f98162f390b07 | chenchenqianqian/Student-Info | /student_info project/student_info.py | 4,865 | 3.96875 | 4 | #写一个函数input_student()得到学生的姓名,年龄,年龄
# 输入一些学生信息;按照年龄从大到小排列,并输出
# 按照成绩从高到低排序后,并输出
#第一步,读取学生信息,形成字典后存入列表L中
from student import Student
def input_student():
L = []
while True:
name = input('请输入学生姓名:')
if not name:
break
age = int(input('请输入学生年龄:'))
score = in... |
f22798808103d6d76e81cf48cbe58da39c053555 | EugeneBad/Andela_BootCamp | /DAY_2_PROBLEM_OOP_MODEL/program.py | 1,684 | 3.71875 | 4 | class Disease:
def __init__(self, prevalence, survival_rate):
self.prevalence = prevalence # Percentage of people who have the disease
self.survival_rate = survival_rate # How many people can survive the disease
# Method that returns the number of infected people given an area's population
... |
a080570819a4482e2b94e400cb4c09966ca5af98 | gokeep-org/AlgorithmCase | /src/base/linked_for_arr.py | 2,497 | 3.984375 | 4 | class LinkedList:
element = None
next = None
def add(self, num):
temp = self
while True:
if temp.next is None:
temp.next = LinkedList()
temp.element = num
break
else:
temp = temp.next
pass
d... |
c1200e5fb1c98dcc6787e257886a7472d25d8760 | haoliweimiao/PythonTools | /base/dict.py | 793 | 4.125 | 4 | #!/usr/bin/python
# coding=utf-8
dict = {}
dict['one'] = "This is one"
dict[2] = "This is two"
tinydict = {'name': 'name_1', 'code': 6734, 'dept': 'sales'}
# 输出键为'one' 的值
print(dict['one'])
# 输出键为 2 的值
print(dict[2])
# 输出完整的字典
print(tinydict)
# 输出所有键
print(tinydict.keys())
# 输出所有值
print(tinydict.values())
a = {
... |
6cc8ce3561dd64c2862b9491cf44443168b988e6 | Vilchynskyi/ITEA_Python_Basics | /lesson_3/homework6.py | 1,626 | 4.15625 | 4 | import re
from phone_book import (find_contact_by_name,
find_contact_by_phone,
count_same_numbers,
delete_contact
)
if __name__ == '__main__':
contact_book = {}
print('1 - Add to contact book'
'\n2 - Find... |
b5815130f7614241c528c2518c42d0b938f90ac1 | LongJH/LeetCode | /all_problems/38. 报数_E.py | 1,994 | 3.765625 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
# Author: 'longjh' time: 2018/12/14
"""
38. 报数
"""
"""
题目:
报数序列是一个整数序列,按照其中的整数的顺序进行报数,得到下一个数。其前五项如下:
1. 1
2. 11
3. 21
4. 1211
5. 111221
1 被读作 "one 1" ("一个一") , 即 11。
11 被读作 "two 1s" ("两个一"), 即 21。
21 被读作 "one 2", "one 1" ("一个二" , "一个一") , 即 1211。
... |
a99a30ddaf90db333e98cc506f3ceb00e888a2b1 | Jardel-dev/exercicios1 | /ex050.py | 300 | 3.765625 | 4 | #leia seis numeros inteiros e mostre a soma de apenas aqueles que forem pares
soma = 0
cont = 0
for c in range(1, 7):
num = int(input(f'digite 0 {c}º valor: '))
if num % 2 == 0:
soma = soma + num
cont = cont + 1
print(f'foi informado {cont} numeros e a soma deles é {soma}') |
843664d7bc5a86480af3eb59c7b24d3c3783f0b2 | xiaotuzixuedaima/PythonProgramDucat | /PythonPrograms/python_program/file_replace_is_to_was.py | 595 | 4.0625 | 4 | # file replace is to was in any file ..???
f = open("C:\\Users\\Saurabh\\Desktop\\file_handle\\filereplace.txt","r")
a=f.read()
print(a)
b = input("enter the world: ")
c = input("enter the world replace :")
a=a.replace(b,c)
print(a)
# new file ...??
f = open("C:\\Users\\Saurabh\\Desktop\\file_handle\\filereplace... |
6cf6d573eb24f136e9207d9b5c687e6e0c4f496f | Jay07/Workshop4 | /convertTemp.py | 271 | 4.03125 | 4 | def convertFahrenheit(tempCelsius):
tempFahrenheit = (tempCelsius * 1.8) + 32
return tempFahrenheit
tempCelsius = float(input("Enter temperature in Celsius: "))
tempFahrenheit = convertFahrenheit(tempCelsius)
print("Temperature in Fahrenheit:", tempFahrenheit) |
45ef9bdfac39a94e0250abe63a812b97d8d5ecd6 | chrismedrela/2019-04-24-pytdd | /bowling/bowling_game_test.py | 1,167 | 3.53125 | 4 | from bowling_game import BowlingGame
import unittest
class BowlingGameTests(unittest.TestCase):
def setUp(self):
self.game = BowlingGame()
def roll_many_times(self, rolls, pins):
for i in range(rolls):
self.game.roll(pins)
def assert_score_is(self, expected):
self.ass... |
f180916af608781beecc94f98beed2134bac54d1 | noorul90/Python_Learnings | /TupleTest.py | 334 | 4.25 | 4 | #list is mutable but tuple is not mutable means once you create the tuple you can't change value in tuples
numsTuple = (12,15,14,52,44) #12,15,14,52,44
nums = 14,52,55,25
print(type(nums), nums)
print(numsTuple)
print(numsTuple[1])
#immutable nature
#numsTuple[1]=15 #gives error beacause we can't change the value
#pr... |
03d7c2a8aba133493f40995cf178dd548a538098 | JackSanders1998/CIS-407-Project | /match.py | 1,671 | 3.640625 | 4 | from datetime import datetime
from users import *
import sys
questions = 1
artist_genre = ""
year = 0
month = 0
day = 0
while questions == 1:
artist_date = input("When do you want to perform?\n")
year = int(artist_date.split(',')[0])
month = int(artist_date.split(',')[1])
day = int(artist_date.split('... |
a5ba809eb5db179bb5eb8e8861f1a754b9b0ed8c | Witziger/Walkthru-Python | /Walkthru_07/ex_07_02.py | 416 | 3.59375 | 4 | # Use the file name mbox-short.txt as the file name
fname = input("Enter file name: ")
fh = open(fname)
count = 0
x = 0
for line in fh:
if not line.startswith("X-DSPAM-Confidence:") : continue
count = count + 1
data = float(line[20:])
x = x + data
avg = x/count
print('Average spam confidence: ', avg)
... |
4782c618685e33d84a23d26ce7a1b3e264098bfa | taehyeng/taehyeong | /tests/fizzbizz_test.py | 684 | 3.671875 | 4 |
# -*- coding: utf-8 -*-
import unittest
import fizzbizz
class FizzBizz(unittest.TestCase):
def setUp(self):
print '\n'
print "�ҵ带 �����մϴ�."
def tearDown(self):
print '\n'
print "�ҵ带 ��� �����մϴ�."
def test_fizzbizz(self):
self.assertEqual(fizzbizz.fizzbizzf(... |
ef5d4d60cdb1a2355e7a63729cd1d4e11486c032 | Fatou1993/elements-of-programming-interviews-python | /greedy_algorithms_and_invariants/optimum_task_assignment.py | 492 | 3.859375 | 4 | from collections import namedtuple
def optimum_task_assignment(tasks_duration):
PairedTasks = namedtuple('PairedTasks', ('task1', 'task2'))
res = []
start, end = 0, len(tasks_duration) - 1
tasks_duration.sort()
while start < end :
res.append(PairedTasks(tasks_duration[start], tasks_duration... |
972f6454bf1c5d4e3893b1157dd0e6fbd4cad13e | GabrielEstevam/icpc_contest_training | /uri/uri_python/ad_hoc/p1441.py | 215 | 3.625 | 4 | N = int(input())
while N != 0:
lista = [N]
while N > 1:
if N % 2 == 0:
N /= 2
else:
N = N*3 + 1
lista.append(N)
print(int(max(lista)))
N = int(input()) |
c3e202d8c1c0160194f5e4e0ab8ebc5faeed20ea | christensonb/Seaborn | /seaborn/repr_wrapper/dictlist.py | 1,985 | 4.40625 | 4 | # this is untested
class DictList(list):
"""
This object acts as a list and a dict by assuming an int index is for a list
and any other index is for the dict
"""
def __init__(self, columns, values):
"""
:param columns: list of str of the column names
:param values: ... |
f829007366fa747c1ed8580984ae13b3ce86a80f | sahilshah5/Computational-Chemistry | /2D Ising Lattice/ILtimetrial.py | 566 | 3.6875 | 4 | import time
import IsingLattice as il
#use a relatively big lattice of 25x25 so that we get more accurate timing data
n_rows = 25
n_cols = 25
lattice = il.IsingLattice(n_rows, n_cols)
#record the time at which we start running
start_time = time.clock()
#do 2000 monte carlo steps
for i in range(2000):
lattice.mont... |
d370bbb0e74e94830fc1bd6c7117d83175ee1987 | layroyc/Python02 | /测试/test.py | 314 | 3.671875 | 4 | #25.自定义模块(模块中含有变量、函数、类),然后使用该模块(两种方法),并使用模块中的内容
a = 100
def add(x,y):
return x+y
class Car:
def __init__(self,skill,color):
self.skill = skill
self.color = color
print(self.skill,self.color)
|
2380a19f33e2dadf588a3f0f71ffc40904550459 | MAPLE-Robot-Subgoaling/IPT | /data/HW3/hw3_326.py | 723 | 4.15625 | 4 | def main():
theTemp = float(input("Please enter the temperature: "))
theMetric = input("Please enter 'C' for Celsius, or 'K' for Kelvin: ")
if theMetric == "C":
if theTemp < 0:
print("At this temperature, water is a (frozen) solid.")
elif theTemp >= 100:
print("At thi... |
7a7f8ecb0af896d70a37fb5338548a04f4f9673d | adjippp/Ujian_Kategori_Bilangan | /Ujian_Kategori_Bilangan.py | 1,325 | 3.671875 | 4 | import math
def kategori(angka):
jawaban=[]
if(math.isnan(angka)):
return "Input bukan angka"
else:
if (isinstance(angka,int)):
jawaban.append('Bulat')
if (angka>=0):
jawaban.append('Cacah')
if (angka < 0):
jawaban.append('Negatif')
... |
94e7c649d370b33515a8c9b6e8fb9a3017bde8f5 | Dino-Dan/PassManager | /PassManager.py | 5,466 | 4.1875 | 4 | import os
class PassManager():
'''(None) -> None
This is a class that will manage passwords by storing them in a text
file. They will be in a format that follows this:
WEBSITE:[USERNAME, PASSWORD]
This will also be able to read the passwords within the text file and
output them if the ... |
a08821970d6acf2bbdaa3231f7d24a9ec63525e1 | zhangwenjunpython/----------- | /天文大作业/tensorflows_demo.py | 3,032 | 3.53125 | 4 | #网络老哥的关于手写体的demo,具体地址如下https://blog.csdn.net/qq_34258054/article/details/80394669
#写的非常好,主要的程序是借鉴他的。
import tensorflow as tf
from tensorflow.examples.tutorials.mnist import input_data
mnist = input_data.read_data_sets(r'G:\tmp\data',one_hot=True)
xs = tf.placeholder(tf.float32,[None,28*28])#原始的输入为28*28像素大小
ys = t... |
18923c87220f6d97032b73914f29f02fc3bdea4b | learnerofmuses/slotMachine | /152Spr13/feb13p1.py | 402 | 3.78125 | 4 | ROW = 5
COL = 4
def main():
scores = [[0,0,0,0], [1,1,1,1], [2,2,2,2], [3,3,3,3], [4,4,4,4]]
print(scores)
for i in range(ROW):
for j in range(COL):
scores[i][j] = i+j
print("after assigning values")
print(scores)
print("printing something - explain here what in printing")
for i in range(ROW):
if(i%... |
bcc36616460acc9a9a6462e31bc354114c4d081f | Alba126/Laba20 | /zad5.py | 2,114 | 3.515625 | 4 | from tkinter import *
import math
class Game:
def __init__(self, width=1000, height=1000):
self.vx = 1
self.vy = 1
self.t = 0
self.dt = 1
self.i = 0
self.height = height
self.width = width
self.c = Canvas(root, width=self.width, height=self.height, b... |
a2942146045fac31162ec42bd7c4a13a434083d2 | jmstrouse/Joshua_Challenge | /Coding/CustomComplex.py | 1,717 | 4.3125 | 4 | """
A custom type for complex numbers.
Written for: https://www.hackerrank.com/challenges/
class-1-dealing-with-complex-numbers/problem
Uses Python 3.8.0
"""
from math import sqrt
class Complex(object):
"""A custom, hand-written complex number type."""
def __init__(self, real, imag):
"""Sets in... |
46784a3b0580be89079041292055f0759e64ac6b | angel-becerra/trabajo10-Becerra_Chancafe | /app12.py | 2,176 | 3.5625 | 4 | import libreria
def funcion_arroz_con_pato():
print("garcias por preferir el arroz con pato")
print("disfrute su comida")
def funcion_cabrito():
print("gracias por preferir el plato cabrito")
print("disfrute su comida")
def funcion_aji_de_gallina():
print("gracias pór preferir aji de gallina")
... |
5bc2a30e01e704a59235b92e1f2cce3e6eb9f686 | GreenMarch/datasciencecoursera | /algo/hash_table/find-words-that-can-be-formed-by-characters.py | 1,407 | 3.8125 | 4 | class Solution(object):
def countCharacters(self, words, chars):
"""
:type words: List[str]
:type chars: str
:rtype: int
"""
from collections import Counter
ch_ctr = Counter(chars)
good = 0
for word in words:
w_ctr = Counte... |
868c1834ffafa8cde9279ec446a00ccc70e20247 | lucaslb767/pythonWorkOut | /pythonCrashCourse/chapter5/requested_items.py | 609 | 3.859375 | 4 | requested_items =['calabresa', 'milho' ]
if requested_items:
for requested in requested_items:
print('Adding '+ requested +'.')
print('\n finished making your pizza')
else:
print('are you sure you want a plain pizza ?')
##using multiple lists
avaiable_toppings = ['calabresa', 'queijo', 'pepperon... |
7cea3369c9f40f3b9ec8a3f4af5af0eb1f91ce07 | edumarrom/dados | /jugador.py | 1,358 | 3.640625 | 4 | from random import choice
class Jugador:
def __init__(self, nombre, saldo = 1000.0):
self.__set_nombre(nombre)
self.__set_saldo(saldo)
def __str__(self):
return f'| {self.nombre()} | Monedero: {self.saldo()} ¥ |'
def nombre(self):
return self.__nombre
def saldo(self):... |
3d67007fa139a907e1881d66d2199e75a5695291 | bacizone/python | /ch10-fibonacchi.py | 183 | 3.9375 | 4 | def fibonacchi(n):
if n == 0:
return 0
elif n == 1:
return 1
else:
return fibonacchi(n-1) + fibonacchi(n-2)
result = fibonacchi(35)
print(result)
|
d0b9b5743143ec2e05b02d15f43b9c6fdee01901 | NakalanziJacklyn/Assignment-1 | /question4.py | 141 | 3.75 | 4 | word_list=['really', 'tomorrowismonday', 'django','Kampabits','python','react']
Longest_word= max(word_list,key=len)
print len(Longest_word)
|
e72dc7dccd2ce65a1091e3a90271d60482372773 | Jonathan-Welham/CapstoneSP21 | /backend/mailer.py | 2,679 | 3.671875 | 4 | import os
import imghdr
import smtplib
from email.message import EmailMessage
"""
NOTE: In order to send an email using a Python script
the sender must enable the use of less secure apps.
If the sender uses the 'gmail' mail sever they can do
so here: https://myaccount.google.com/lesssecureapps
"""
class Mai... |
820770a282ffd6d18596f05e308ff87bad839e1c | Osama-Yousef/data-structures-and-algorithms-python | /data_structures_and_algorithms/challenges/graph/graph.py | 1,918 | 4.28125 | 4 | class Node:
"""
Instance of a node object
"""
def __init__(self, value):
self.value = value
class Graph:
"""
the Common (graph ) data structure.
"""
def __init__(self):
self._adjacency_list = {}
def add_node(self, value):
"""adds a node to the g... |
424c0783105ebe68332211f012cbc00e321e70ed | asymmetry/leetcode | /0068_text_justification/solution_1.py | 1,536 | 3.625 | 4 | #!/usr/bin/env python3
class Solution:
def fullJustify(self, words, maxWidth):
"""
:type words: List[str]
:type maxWidth: int
:rtype: List[str]
"""
result = []
row = [words[0]]
row_length = len(words[0])
for word in words[1:]:
i... |
7a0e71daf15942ddb64bfa25c69d5cf37354369a | MarkMoretto/project-euler | /incomplete/problem_725.py | 1,782 | 3.875 | 4 |
"""
Purpose: Project Euler exercises
Date created: 2020-09-13
Problen Number: 725
Name: Digit sum numbers
URL: https://projecteuler.net/problem=725
Contributor(s):
Mark M.
Description:
A number where one digit is the sum of the other digits is called a digit sum numbe
or DS-number for short. For example... |
d2a55df3d1029736530a7822e1711cbc01ee1953 | JonathanGamaS/hackerrank-questions | /python/text_alignment.py | 679 | 4.1875 | 4 | """
You are given a partial code that is used for generating the HackerRank Logo of variable thickness.
Your task is to replace the blank (______) with rjust, ljust or center.
"""
def text_alignment():
t = int(input())
c = 'H'
for i in range(t):
print((c*i).rjust(t-1)+c+(c*i).ljust(t-1))
fo... |
b7be33b152e705ab91f6d0cec82f581bc5c983fe | gutaors/DataCamp | /personal-master/DataCamp/training/Big_Data_Fundamentals_PySpark.py | 7,776 | 4.09375 | 4 | # Apache Spark is written in Scala
# Pyspark APIs are similar to Pandas and scikit-learn
# Understanding SparkContext
# A SparkContext represents the entry point to Spark functionality. It's like a key to your car. PySpark automatically creates a SparkContext for you in the PySpark shell (so you don't have to create ... |
a365bf9206e5d832a54b75d807cbe9cddaeb9d86 | SamB2653/ml_course | /ml_course/prerequisites/tensors.py | 10,367 | 4.21875 | 4 | import tensorflow as tf
import numpy as np
'''
Following an Introduction to Tensors but with some minor changes and additions.
Source: https://www.tensorflow.org/guide/tensor
'''
# Create a scalar (rank-0) tensor. A scalar has no axes and is a single value. This will be an int32 tensor by default
rank_0_tensor = tf.... |
9a41679a204b9e0fb3265bb75c58493b85c5d450 | Default-UNIT/Analise-Algoritmo | /Exercicios 02.02/Python/Ex001.py | 289 | 3.5 | 4 | vetor = []
somarPar = 0
somarImpar = 0
cont = 0
for i in range(1, 8):
num = int(input(f'Digite o {i}º número: '))
vetor.append(num)
for j in vetor:
if cont % 2 == 0:
somarPar += j
else:
somarImpar += j
cont += 1
print(f'{somarPar}-{somarImpar}')
|
8b69c22357ef25ddca9167989f2337674fe78784 | sweenejp/learning-and-practice | /practicepythondotorg/exercise_14.py | 692 | 4.1875 | 4 | # Write a program (function!) that takes a list and returns a new list that contains all the
# elements of the first list minus all the duplicates.
#
# Extras:
#
# Write two different functions to do this - one using a loop and constructing a list,
# and another using sets. Go back and do Exercise 5 using sets, and wri... |
3a637cd191090ef1b2d1351b7cc3662e7e3fa2df | caioalexandred/python_inicio | /ex013.py | 295 | 3.65625 | 4 | dado1 = input('digite algo ')
print('esse conteúdo é alfabético?', dado1.isalpha())
print('esse dado é numérico?', dado1.isnumeric())
print('tem espaço nos caracteres?', dado1.isspace())
print('tem decimais?', dado1.isdecimal())
print('É totalmente maiúscula?', dado1.isupper())
|
d2501421eed685bbad3c7084ebb49616b596dad4 | AayushAnimalFriends/codingclass2-Journal | /papas challenge.py | 495 | 3.734375 | 4 | binaryx = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
print(binaryx)
def twobinary(binary):
binary[len(binary)-1]=1
print(binary)
binary[len(binary)-1]=0
binary[len(binary)-2]=1
print(binary)
binary[len(binary)-1]=1
print(binary)
return
def threebinary(binarythree):
print('.',binarythree)
i ... |
4661dcbec923362150b2119caa55daaecdb225fd | KevinJianLin/UoG-BINF6410-Bio-Programming | /Lecture/temp.py | 583 | 3.6875 | 4 | from random import randint
a = randint(0,20) #get a random number
cards = ['7D','2S','10H','3S','AC']
print(cards[0]+ " "+ cards[3])
cards.append("5H") #changes cards
print(cards)
print(cards)
print("Cardsare "+" ".join(cards))
dna = ['A','T','C']
nonsense = cards + dna
print(nonsense)
print (dna[-1])
pr... |
dc74ee3fbdfb6754a9376efc9d8ced6e5e3cd834 | ArmaoThaoSwExp/CrackingTheCodingInterview | /chapter19/chapter19_1.py | 594 | 4.15625 | 4 | """
Author: Armao Thao
Description:
Chapter 19: cracking the coding interview
"""
##############################################################################
# Cracking the coding exercise Chapter 19.1
# Write a function to swap a number in place without temporary variables.
#######################... |
2ba0477f3bbcc76250dc37135d1dc22da73105f9 | ASAD5401/PYTHON-CODE | /to check duplicate words in list.py | 287 | 3.5625 | 4 | import os
f=open("d:\\asad.txt","r")
q=f.read()
f.close()
w=q.split()
print(w)
o=len(w)
c=0
for i in w:
for j in w:
if i.lower() == j.lower():
c+=1
if(c>o):
print("duplicate words are present")
else:
print("duplicate words are not present") |
e808fc75161700ab86fd6b8b47bda705e6477aa4 | Flannelz/sudoku-slayer | /printer.py | 956 | 3.875 | 4 | # File: printer.py
# Author: Alice Hanigan
# Date: 04/11/2020
#
import value
import constraint
def sudoku_printer(value_grid):
# Prints a ValueGrid object to the command line
for i in range(value_grid.get_length()-1):
line = ""
divider = ""
for j in range(value_grid.... |
70e4743307bd0065eedd9e69934fc26c33b4e623 | LixingZHANG96/Algorithm_Package_Lix | /Classical Algorithms/Mathematics/Matrix_Calculation/Strassens_Method_for_Matrix_Multiplication/strassens_method.py | 1,713 | 3.515625 | 4 | import numpy as np
def strassens_method(A, B):
"""The main function for recursive square matrix multiplication."""
A = np.array(A)
B = np.array(B)
n = A.shape[0]
if n == 1:
C = A * B
else:
A11, A12, A21, A22 = matrix_partition(A)
B11, B12, B21, B22 = matrix_partition(B)... |
c34bb567f19003c3af4d3a2c1c56291d5adfd50a | Tobdu399/p3wordformatter | /build/lib/formatword_pkg/__init__.py | 538 | 3.96875 | 4 | def format_word(word):
formatted_word = []
completed_word = ""
for letter in word:
formatted_word.append(letter)
formatted_word[0] = formatted_word[0].upper()
completed_word += formatted_word[0] # Add the capitalized letter
for i in range(1, len(formatted_word)):
f... |
e90db08f25eae6963856da6ed5e4bcfd8c146eb0 | amitgit2020/NPTEL-Python-DSA-2020 | /Week-3/Assignment.py | 3,394 | 4 | 4 | '''
1) Write a function contracting(l) that takes as input a list of integer l and returns True if the absolute difference between each adjacent pair of elements strictly decreases.
Here are some examples of how your function should work.
>>> contracting([9,2,7,3,1])
True
>>> contracting([-2,3,7,2,-1])
Fals... |
ada8d4295a93b18c5c45ada1b6d6967abf43416c | lcodesignx/pythontools | /tools/get_forecast.py | 1,096 | 3.546875 | 4 | #!/usr/bin/env python
import requests, json, argparse
def get_forecast(city):
'''Function to get weather forcast for a city'''
message = f'Weather forcast for {city}'
api_key = '74466c79d2480d1529e8ea066fe19b33'
base_url = 'http://api.weatherstack.com/current?'
complete_url = base_url + 'access_ke... |
dca310e7acd3975b6bb07c7fbd33517309c8940d | NathanDunfield/montesinos | /bdry_run.py | 3,858 | 3.640625 | 4 | # This program computes the boundary slopes of a Montesinos
# or two-bridge knot.
#
# You will need a Python interperator (version 1.5 or newer) to run
# these programs. These are free and availible for virtually every
# platform from the Python home page <http://www.python.org>. If you're
# using UNIX, you can see if... |
86171ef258d4128812031ed3d65d6b92b8c348bd | AnupamKP/py-coding | /string/compare_version.py | 967 | 4.25 | 4 | '''
Compare two version numbers version1 and version2.
If version1 > version2 return 1,
If version1 < version2 return -1,
otherwise return 0.
You may assume that the version strings are non-empty and contain only digits and the . character.
The . character does not represent a decimal point and is used to separate nu... |
573e6bed1a742381e11c8d9b76cb6251e58f3b9a | jorendorff/advent-of-code | /ad2019/dec04/part1.py | 1,623 | 4.03125 | 4 | """Day 4: Secure Container
You arrive at the Venus fuel depot only to discover it's protected by a
password. The Elves had written the password on a sticky note, but someone
threw it out.
However, they do remember a few key facts about the password:
* It is a six-digit number.
* The value is within the range giv... |
281e7b1cd34b4e2504cf9d1eb89b3ea5dcce1760 | jasondzy/Python | /Python/basic/furniture/furniture_test.py | 902 | 3.75 | 4 |
class room():
def __init__(self,area,addr,info):
self.area = area
self.addr = addr
self.info = info
self.useful = self.area
def __str__(self):
msg = "romm:size is :%d area useful is:%d addr is:%s info is:%s "%(self.area,self.useful,self.addr,self.in... |
3f72aaa5e49acb04adf60ea7be9dac29d79faaff | AdamZhouSE/pythonHomework | /Code/CodeRecords/2952/48102/252669.py | 617 | 3.515625 | 4 | def search(string: str) -> list:
res = []
now = ''
for i in string:
if i.islower():
now += i
elif i == 'B':
now = now[0:len(now)-1]
elif i == 'P':
res.append(now)
return res
def find():
s = input()
ans = search(s)
n = int(input())... |
ecf7c405e3240ce4943d1331c412819389bb3016 | sytrack/coding-for-office-workers | /week-01-python/07-functions.py | 1,029 | 3.875 | 4 | # 함수 functions
# 입력값 parameters, 반환값 return
def hello_friends(name):
print("Hi, {}".format(name))
name1 = "sunyoung"
name2 = "dayoung"
name3 = "doyoung"
name4 = "hara"
name5 = "sunyoung"
name6 = "dayoung"
name7 = "doyoung"
name8 = "hara"
# print("Hello, {}".format(name1))
# print("Hello, {}".format(name2))
# prin... |
d990cc68925c4830db1202db65e3d58534e9fe4d | canattofilipe/python3 | /comprehensions/comprehension_v2.py | 286 | 3.59375 | 4 | #!/usr/bin/python3
# Versão "normal/classica"
dobros_pares = []
for i in range(10):
if (i % 2 == 0):
dobros_pares.append(i*2)
print(dobros_pares)
# [ empressão for item in list if condicional ]
dobros_pares = [i*2 for i in range(10) if i % 2 == 0]
print(dobros_pares)
|
3d20e657e5bc8333207645b72821d8abe22b74b0 | xiaojkql/Algorithm-Data-Structure | /Basic Data Structure/Sort and Search/Search/indexOfMin.py | 505 | 3.921875 | 4 | # -*- coding: utf-8 -*-
'''
Author: Qin Yuan
E-mail: xiaojkql@163.com
Time: 2019-01-22 15:42:29
'''
def indexOfMin(ls):
"""搜索列表中最小元素的index,
如果列表为空返回-1,否则返回index"""
if not ls:
return -1
minIndex = 0
for i in range(1, len(ls)):
if ls[minIndex] > ls[i]:
minIndex = i
re... |
0c86ede2449727dc789e099b3af0c8f7607716dc | GustavoGuke/py | /capitulo_10/exercicio_pg266.py | 1,317 | 3.875 | 4 | # Exercicio 10.3
# abrir um arquivo e escrever nele
'''
nome = input('digite seu nome: ')
filename = 'arquivosTxt/exercicio_pg266.txt'
# escrever no arquivo
with open(filename, 'w') as f:
f.write(nome)
# abrir o arquivo apenas leitura
with open(filename) as f:
line = f.readlines()
for i in line:
if nom... |
80701b1698f06e4cecb7f6aee093fdeba2be9635 | Empythy/Algorithms-and-data-structures | /105. 从前序与中序遍历序列构造二叉树.py | 1,407 | 3.828125 | 4 | # -*- coding: utf-8 -*-#
"""
Created on 2020/7/10 9:04
@Project:
@Author: liuliang
@Email: 1258644178@qq.com
@Description:
@version: V1
"""
# Definition for a binary tree node.
from typing import List
class TreeNode:
def __init__(self, x):
self.val = x
self.left = None
self.right =... |
4fa4ecfcd23d131e9c274789e965df8bc26c5eb2 | DeepakJha01/cyberalgo | /extended_euclid.py | 962 | 3.90625 | 4 |
from pandas import *
def display(matrix):
print('\n')
df = pandas.DataFrame(matrix)
print(df.to_string(index=False, header=False))
print("\nEXTENDED EUCLID'S ALGORITHM")
print("Calculating MMI(a mod m) and GCD(a,m) ...\n")
a = int(input("Enter a : "))
m = int(input("Enter m : "))
A1,A2... |
0b6af68a1dfc21a5ff95de6743de4159a72d08c6 | ecrossett/Machine_Learning | /helper_code/softmax.py | 233 | 3.671875 | 4 | def softmax(x):
'''Calculates the softmax for each row of the input x'''
x_exp = np.exp(x)
# sum each row of x_exp
x_sum = np.sum(x_exp, axis = 1, keepdims = True)
# compute
s = x_exp / x_sum
return s |
cee8665f445d96b378cb438feb9b5588a23e0ecb | NithyaKrishnan08/Python_Practice | /10_print_digit_pattern.py | 354 | 4.21875 | 4 | # To print digit patterns
# For a given integer print the number of *'s that are equivalent to each digit in the integer.
def pattern(UserNumber):
numbers = list(UserNumber)
for number in numbers:
number = int(number)
print("|", end='')
print(number * '*')
userNo = input('Ent... |
40833cdc8f04523a45c86f68ef85056ba4c78bb2 | AnishHemmady/Guitar-Python | /algorithm.py | 2,718 | 3.609375 | 4 | '''
Developing different algorithms for the main file.
Copyright@BMRSoftwareGroup USA 2017
'''
#Here we make use of strategy pattern since its family of algorithms.
import pdb
class Skipper(object):
def algorithm(self,inp,user_inpt):
return "Not Implemented"
class Major(Skipper):
def seek_solver(self,inp_arry... |
c41f60da89db0cb0eaa425407a4472d979929ec1 | CarlosAmorim94/Python | /Exercícios Python/ex059_Criando um menu de opções.py | 1,479 | 4.375 | 4 | """
EXERCÍCIO 059: Criando um Menu de Opções
Crie um programa que leia dois valores e mostre um menu como o abaixo na tela:
[ 1 ] Somar
[ 2 ] Multiplicar
[ 3 ] Maior
[ 4 ] Novos Números
[ 5 ] Sair do Programa
Seu programa deverá realizar a operação solicitada em cada caso.
"""
n1 = int(input('Digite o primeiro número:... |
489a32815d959becab405e73e3340ed5e033d899 | roshray/LSTM.FibonacciSeries | /FZBZ.py | 305 | 3.953125 | 4 |
def FizzBuzz(x):
sequence =[]
for i in range(1,x+1):
if i%3 and i% 5 ==0:
sequence.append("FizzBuzz")
elif i%3 ==0:
sequence.append("FIZZ")
elif i%5 ==0:
sequence.append("Buzz")
else:
sequence.append(str(i))
return sequence
def main():
print('\n'.join(FizzBuzz(25)))
main() |
fe79650f39034a61e4f14835b87dc7a2db79bb33 | Walker088/leetcode | /python/String/022_GenerateParentheses.py | 2,805 | 3.953125 | 4 | """
Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses.
## Example 1:
Input: n = 3
Output: ["((()))","(()())","(())()","()(())","()()()"]
## Example 2:
Input: n = 1
Output: ["()"]
-------------------------------------------------------------------------------------... |
0b7d9d444984f66fb23244885dad155ea88b3b5c | katur/rc-warmups | /i01_intersperse.py | 458 | 4 | 4 | '''Write a function that takes a list of lists and intersperses their elements.
E.g.
intersperse([[1, 2, 3], [4, 5, 6], [7, 8, 9]]) => [1, 4, 7, 2, 5, 8, 3, 6, 9]
'''
def get_element(l):
index = 0
while index < len(l[0]):
for sublist in l:
yield sublist[index]
index += 1
def int... |
b73c685b2906fa5108a6310236ff6be4c3436758 | tobkre/NNfromScratch | /nnfs.py | 6,354 | 3.5 | 4 | # -*- coding: utf-8 -*-
"""
Created on Thu Apr 5 08:25:01 2018
@author: kretz01
"""
"""Build a MLP with one hidden layer, one input layer (two values) and a single
neuron in the ooutput layer, to predict the outcome of the &-Function"""
import numpy as np
from Layer_Classes import Layer, HiddenLayer, OutputLayer
... |
818c376051eacb10078db111340d81cbec92c65d | pnimit/py | /Libraries/daysofweekday.py | 434 | 4.125 | 4 | # Prints out a day of every month's first FRIDAY in 2018
import calendar
# Loop for each month
for month in range(1,13):
# First friday must be somwhere in first two weeks
c = calendar.monthcalendar(2018, month)
w1 = c[0]
w2 = c[1]
# calendar month starts from sunday
if w1[calendar.FRIDAY] != 0:
day = w1[ca... |
5f64bab78ce79506069abc0f510c768d0ed396db | pengyuhou/git_test1 | /leetcode/441. 排列硬币.py | 295 | 3.59375 | 4 | class Solution:
def arrangeCoins(self, n: int) -> int:
cur = 1
count = 0
while True:
count += cur
if count > n:
return cur-1
cur += 1
if __name__ == "__main__":
n = 0
print(Solution().arrangeCoins(n))
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.