blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string |
|---|---|---|---|---|---|---|
7f84a02124f4b669371f0350c6230e5d2edcf990 | vtsartas/ejpython | /ejpy/ejElenaPY/22_hoja-V-7_tres_cifras_reves.py | 1,376 | 4.25 | 4 | # Ejercicio 22 (hoja V, 7) - Pedir un número de tres cifras y si lo es invertir el orden de estas
# Pedimos por pantalla el número a verificar
num = int(input("Introduce un número de tres cifras (100 a 999): "))
# Si el número está entre 100 y 999 tendrá 3 cifras y lo pondremos al revés
if num>99 and num<1000:
... |
561840249f9c3f68014899343e950f371eb3a974 | YOGESH-TECH/python-basic-problems | /monday.py | 399 | 3.796875 | 4 | year=int(input("enter the year here: "))
ref_year=1900
diff=year-ref_year
lyear=diff//4
nyear=diff-lyear
td=((nyear*365)+(lyear*366))
day=td%7
if day==0:
print("monday")
elif day==1:
print("tuesday")
elif day==2:
print("wednessday")
elif day==3:
print("thrusday")
elif day==4:
print("friday")
elif ... |
f4497baa33da90534488a1ecc26a0cc6f3bd4972 | TorpidCoder/Python | /W3School/List/10.py | 160 | 4 | 4 | list = ['sail','nikki','vimal','manju','rajkumar','killer']
n = int(input("Enter the number : "))
for vals in list:
if(len(vals)>n):
print(vals)
|
bb0a90d66dac3ee34710779782512ac4ac3f6fc7 | Billshimmer/blogs | /algorithm_problem/spiral_matrix_ii.py | 890 | 3.515625 | 4 | #!/usr/bin/python
# -*- coding: latin-1 -*-
# leetcode 59
class Solution(object):
def spiralMatrix(self, n):
if n == 0:
return []
if n == 1:
return [[1]]
self.Array = [ [ 0 for __ in range(n)] for __ in range(n) ]
self.Array[0][0] = 1
self.r... |
5d49162b0935047a90c7c84fc29949ecb5631e1b | arthurDz/algorithm-studies | /leetcode/number_of_connected_components_in_an_undirected_graph.py | 1,126 | 3.96875 | 4 | # Given n nodes labeled from 0 to n - 1 and a list of undirected edges (each edge is a pair of nodes), write a function to find the number of connected components in an undirected graph.
# Example 1:
# Input: n = 5 and edges = [[0, 1], [1, 2], [3, 4]]
# 0 3
# | |
# 1 --- 2 4
# O... |
7bf05a23763155cf74e1b6e521bd602fd7400cf2 | ericdegan/Curso-em-Video | /ex044.py | 759 | 3.84375 | 4 | valor = float(input('Qual o valor a pagar R$:'))
pag = input('Você pode pagar em [1] Dinheiro ou [2] Cartão qual você prefere? ').upper()
if pag == ('1'):
print('Em dinheiro você ganha 10% de desconto vai ficar R$:{:.2f}'.format(valor - (valor/100) * 10))
elif pag == ('2'):
cart = input('Voce quer pagar ... |
5ed0c019d962c97d5684afded731c0775f56765a | ChrisXi/Hadoop-Learning | /Streaming version/mapper.py | 1,674 | 3.609375 | 4 | #!/usr/bin/env python
import sys
# input comes from STDIN (standard input)
for line in sys.stdin:
# remove leading and trailing whitespace
line = line.strip()
# split the line into words
words = line.split()
# increase counters
#print len(words)
i0 = 0
for i1 in range(i0+1,len(words)-1... |
05cfc0d2d57b3e4e5fe16a281eec7faf33970abf | gopalkrishna12/json2xml | /src/cli.py | 620 | 3.515625 | 4 | import sys
import argparse
from src.json2xml import Json2xml
def main(argv=None):
parser = argparse.ArgumentParser(description='Utility to convert json to valid xml.')
parser.add_argument('--url', dest='url', action='store')
parser.add_argument('--file', dest='file', action='store')
args = parser.pars... |
8d5f817d8cbc9b7849713b74ee4ed343df2a39ad | Janepoor/Python-Practice- | /first non-repeat char.py | 303 | 3.625 | 4 | ### first non-repeat char
def firstchar(inputstring):
hash={}
for i in inputstring:
if i not in hash:
hash[i]=1
else:
hash[i]+=1
for i in inputstring:
if hash[i]==1:
return i
return ('##')
print (firstchar("hhelloworld")) |
cc32e2ce1a8dc494bc420357f674f48c04bfa2d8 | green-fox-academy/FulmenMinis | /week-02/day-01/seconds_in_a_day.py | 387 | 4.125 | 4 | current_hours = 14
current_minutes = 34
current_seconds = 42
# Write a program that prints the remaining seconds (as an integer) from a
# day if the current time is represented bt the variables
remaining_hours = 24-current_hours
remaining_minutes = 60-current_minutes
remaining_seconds = 60-current_seconds
print(remai... |
5c294a50fecad04d67394d388be16fd588585012 | TheSmurfs/pypractice | /week4/员工信息表程序/main.py | 6,730 | 3.84375 | 4 | #!/usr/bin/env python
#-*- coding:utf-8 -*-
# author:FCQ
# datetime:2018/7/11 19:24
# software: PyCharm
#!/usr/bin/env python
# -*- coding:utf-8 -*-
# Author: Colin Yao
"""python 员工信息表操作"""
import sys
import os
def select1():
'''
查看文件函数
:return:
'''
with open('peopledb', 'r', encoding='utf-8') as... |
7c6bbe6c69ec15bf7bd2a9efbed8753d4e030a70 | kazukazu7/p-semi | /question3.py | 871 | 3.59375 | 4 | import random
from collections import Counter
import statistics as st
sum = 0
list = []
for i in range(1000):
i = random.randint(1, 6)
sum = sum + i
list.append(i)
list.sort()
# N=1000
N = len(list)
print("合計は" + str(sum))
def average(): # 平均値を求める
ave = sum / N
print("平均は" + str(ave))
def m... |
00f58c5501e33b39ec61c8436ea2effeb1d88168 | IANHUANGGG/Gomoku-AI | /Five-In-a-Row/src/board.py | 1,754 | 3.71875 | 4 | from src.piece import Piece
import src.util
import src.constant as cons
import copy
class Board:
def __init__(self):
self.board = [[Piece.EMPTY for col in range(cons.NORMAL_B_HEIGHT)] for row in range(cons.NORMAL_B_WIDTH)]
self.height = cons.NORMAL_B_HEIGHT
self.width = cons.NORMAL_B_WIDTH
... |
efcd6c2fd9d302466f1353cce80d55c718e5c5ba | lj1064201288/Python-Notebook | /飞机蛇的练习题/Restaurant.py | 892 | 3.640625 | 4 | class Restaurant():
def __init__(self, name, cuisine):
self.restaurant_name = name
self.cuisine_type = cuisine
self.number_serced = 0
def describe_restaurant(self):
print("这个餐馆的名字是:", self.restaurant_name)
print("这个餐馆是一个" + self.cuisine_type + "餐馆.")
def open_rest... |
73666546940d16f5977cd377088779ce92141134 | superhman/DSC510Spring2020 | /Gunasekaran_DS510/Gunasekaran_DS510_Final_Project.py | 11,905 | 4.09375 | 4 | # File : Gunasekaran_DS510_FinalProject.py
# Name : Ragunath Gunasekaran
# Date : 05/30/2020
# Course : DSC-510 - Introduction to Programming
# Assignment :
# Created a header for this Program.
# Created new API - # api_key = "09d020dd8193c479bf9e062588c60cfa"
# Created a Python Application which ... |
64afa25a0ab78e0a536883dccd63398da8206f27 | ANKerD/competitive-programming-constests | /uri/upsolving/2175/code.py | 194 | 3.734375 | 4 | a,b,c = map(float, raw_input().split())
if a == b or b == c or a == c:
print 'Empate'
elif a == min(a,b,c):
print 'Otavio'
elif b == min(a,b,c):
print 'Bruno'
else:
print 'Ian'
|
85d07d593a26735e39441af937d47294d9026f3d | nuekodory/AtCoder | /Other/SoundHound2018/F.py | 162 | 3.71875 | 4 | input_line = input().split()
a = int(input_line[0])
b = int(input_line[1])
if a + b == 15:
print("+")
elif a * b == 15:
print("*")
else:
print("x")
|
8207e1092bab6cae13ed8d63d8c437d11c1af78a | theravikumar/dataStructure | /queue_List.py | 618 | 3.9375 | 4 | class queue:
def __init__(self):
self.List = []
def enqueue(self,value):
self.List.append(value)
def dequeue(self):
del self.List[0]
def peek(self):
print(self.List[0])
def isEmpty(self):
if len(self.List)==0:
print("the queue is empty")... |
f1cdfe661a81438835dd02ef9ab2485e4f61be20 | Viditagarwal7479/Assignments-2021 | /Week1/run.py | 679 | 4.03125 | 4 | ## This is the most simplest assignment where in you are asked to solve
## the folowing problems, you may use the internet
'''
Problem - 0
Print the odd values in the given array
'''
arr = [5,99,36,54,88]
## Code Here
i=0
count=0
while(i<5)
if(arr[0]%2!=0)
count+=1
i+=1
print(count)
'''
Problem - 1
Print all ... |
8b631e49768fc802011b27d5e1cd610ac1c065ef | jonnytrade/Learning_Python | /Other task/String.py | 67 | 3.78125 | 4 | word = "Hello World"
print(word)
print(word[::-1])
a=10
b=5
print(a>b)
|
aadaf9fbd54b68f249c2a96d2e3ac2793299f9e5 | kiminh/implementation_of_papers | /CF_recommender_system/BPR/accuracy.py | 306 | 3.578125 | 4 | # accuracy.py
import numpy as np
# dataset that will be given to accuracy calculating functions must have [ [~~~~~, real_value, predicted_value] * number_of_data ] form
def RMSE(dataset):
return np.sqrt(np.mean([float((true_value - prediction)**2) for (_, _, true_value, prediction) in dataset]))
|
3d78f8ba2acdf2e2f479a5ca1b1544c04e5eb784 | katonamac/CSES-7960 | /day1.py | 1,275 | 4.28125 | 4 | # Day 1 of Python course
num = 7
num_float = 7.0
l = [2,3,4,5,6]
item = 3
print(item == 3)
#note that when you aren't in the console you have to use the
#print function to get an output
myStr = "This is my string!"
print(myStr)
print(myStr[0],myStr[9],myStr[-1])
myStr = myStr + "biatch"
#An equi... |
ad628fa230030458d2c3d6bb75b8290949350a62 | VishalGupta2597/batch89 | /notepadwithobj.py | 1,328 | 3.609375 | 4 | from tkinter import *
from tkinter import filedialog
class text_editor:
def open_file(self):
f = filedialog.askopenfile(initialdir="c://", title="Select file",
filetypes=(("text file", "*.txt"), ("all files", "*.*")))
def save_file(self):
pass
def save_a... |
683dd7dba56426f22cfaca860c2f2c83fb6bce90 | Kylar42/wvup | /Project Euler/euler20.py | 229 | 3.9375 | 4 |
def factorial(n):
if n == 0:
return 1
else:
recurse = factorial(n-1)
result = n * recurse
return result
bignum = factorial(100)
cursum=0
while(bignum > 0):
cursum += bignum%10
bignum /= 10
print cursum
|
4d3bd7ea4e348e49585af33e6b2be8761af364db | mrinmoybasak/PythonTutorial | /tut9.py | 349 | 3.6875 | 4 | # grocery = ["harpic" , "loliop" , "shop","egg", "rice"]
# print(grocery[4])
#
numbers = [2,7,9,11,5,3]
# numbers.remove(9)
# numbers.pop()
numbers.sort()
# print(numbers)
# numbers.reverse()
# print(numbers)
# print (numbers[1:5:2])
# numbers = []
# numbers.append(7)
# numbers.append(71)
# numbers.append(79)
# numbers... |
3483ad49dedbcf7aec805141967ac529a9c8adf9 | niranjan-nagaraju/Development | /python/leetcode/binary_tree_max_width/binary_tree_max_width_efficient.py | 4,806 | 4.125 | 4 | '''
https://leetcode.com/problems/maximum-width-of-binary-tree/
Given a binary tree, write a function to get the maximum width of the given tree. The width of a tree is the maximum width among all levels. The binary tree has the same structure as a full binary tree, but some nodes are null.
The width of one level is ... |
cb47206e2f407ad15549c3b1ddbfba07d13a3f82 | jing1988a/python_fb | /好咧,最后还是要搞google/hard/MinimumCosttoHireKWorkers857.py | 4,809 | 3.640625 | 4 | # There are N workers. The i-th worker has a quality[i] and a minimum wage expectation wage[i].
#
# Now we want to hire exactly K workers to form a paid group. When hiring a group of K workers, we must pay them according to the following rules:
#
# Every worker in the paid group should be paid in the ratio of their q... |
af06056b6ddf07de7ab9146fa5b25e8fff6feecd | landron/Project-Euler | /Python/easy/problem_66_continued_fraction.py | 4,231 | 3.984375 | 4 | """
Square roots as continued fractions
https://projecteuler.net/problem=64
Detect cycles is not possible:
2 = 1; 2
41 = 6; 2, 2, 12
55 = 7; 2, 2, 2, 14
"All irrational square roots of integers have a special form for the
period; a symmetrical string, like the empty str... |
83aa24e98b7587d4206fa4d983c18cecd1872d58 | compilepeace/DS_AND_ALGORITHMS | /DS_with_python/trees/04_traversal.py | 1,209 | 3.890625 | 4 |
class BTNode:
def __init__(self, data):
self.data = data
self.left = None
self.right = None
def BTInput():
n = int(input())
if n == -1:
return None
new_node = BTNode(n)
new_node.left = BTInput()
new_node.right = BTInput()
return new_node
def BTPrint(root):
if root == None:
return
print(f"{... |
80603d73c5a815e2cb1a02acdeeaeece897bd9d3 | bauassr/Session19_assignment2 | /Session19.2.py | 2,140 | 3.671875 | 4 | import numpy as np
import pandas as pd
Group1=np.array([51, 45, 33, 45, 67])
Group2= np.array([23, 43, 23, 43, 45])
Group3=np.array([ 56, 76, 74, 87, 56])
print("Group of mean",Group1.mean())
print("Group2 mean",Group2.mean())
print("Group3 mean",Group3.mean())
def getdf(value):
Group = pd.DataFra... |
1c7c9e9a66c782512ada137f492a507c1d22955f | onikun94/algo_python | /src/abc049_c.py | 412 | 3.671875 | 4 | s = input()
data = ["erase", "eraser","dream", "dreamer"]
count = 0
count1 = 0
while 1:
for frag in data:
count += 1
print("count =",count)
if s.endswith(frag):
count1 += 1
s = s[:-len(frag)]
print(s)
print("count1 =",count1)
break
... |
aaf600f5de07756d75e519a6ea6d92f8d8d74c46 | Andru-filit/andina | /Clase #5/15.py | 74 | 3.734375 | 4 | x= int (input (3))
y= int (input (2))
x= x % y
x= x % y
y= y % x
print(y) |
408c2e3ee9a830a29a3cc3bf7113e38cbd22c171 | brigitteunger/katas | /test_min_insertions.py | 2,416 | 3.953125 | 4 | import unittest
from typing import List
class Solution:
def minInsertions(self, s: str) -> int:
if s == "" or s is None:
return 0
nums = 0
expected = 0
index = -1
max_index_s = len(s) - 1
while index < max_index_s:
index += 1
if ... |
288cbc3622d1979e5708693709997faa4291392d | unclebae/Python3-tutorial | /07.string/isalphaTest.py | 135 | 3.921875 | 4 | str = "this"; # No space & digit in this string
print (str.isalpha())
str = "this is string example....wow!!!"
print (str.isalpha())
|
02886f4c99ac5332d13896773de1d3094a08e2cf | cardstdani/arrays-python | /QuickSort.py | 371 | 3.921875 | 4 | a = [41, 14, 6, 23, 19, 2, 11, 8, 30]
def quickSort(n):
if len(n) < 2:
return n
pivot = n.pop()
rightList = []
leftList = []
for item in n:
if item > pivot:
rightList.append(item)
else:
leftList.append(item)
return quickSort(leftList) + [pivot]... |
48a64cfccf5470b12c6fe7693077fa3a1d783963 | HourGu/python-ex | /iteration.py | 847 | 3.953125 | 4 | # -*- coding: cp936 -*-
#����iteration
## for```in```
>>> d={'a':1,'b':2,'c':3}
##
>>> for key in d:
print key
a
c
b
##
>>> for value in d.itervalues():
print value
1
3
2
##
>>> for value in d:
print value
a
c
b
##
>>> for key,value in d.iteritems():
print key,value
a 1
c 3
b 2
>>>
##
>>> for... |
f5abafce6c509dad03963192228120aca6b53a94 | Sanford137/Python-Tetris | /tetris_9_classes.py | 1,798 | 4.125 | 4 | # Tetris Classes
'''This program contains the classes for Tetris.'''
import pygame
import random
# Colors
BLACK = (0, 0, 0)
GREY = (125, 125, 125)
WHITE = (255, 255, 255)
GREEN = (0, 255, 0)
YELLOW = (0, 150, 150)
RED = (255, 0, 0)
ORANGE = (255, 100, 100)
LIGHT_BLUE = (0, 0, 150)
BLUE = (0, 0, 255)
PURPLE = (200, 0... |
a3936646d5f48dab0d8ba5adb3485d1e30c4575d | anubeig/python-material | /MyTraining_latest/MyTraining/Pandas/ImpFunctions.py | 1,209 | 3.53125 | 4 | import pandas as pn
dict1 = {'Names':['Nazeer','Malika','Anu','Parru','Arshiya','Seema','Amir','Asma','Mateen','Ashiq'],
'Age':[55,48,30,29,25,22,7,3,1,1],
'food':['Chicken','Fish','Chicken','Mutton','Ice','Ice','Fish','Mutton','ceralac','cerelac'],
'weight':[70,55,71,45,44,43,15,9,7,4]}
df =... |
c5f6adce6c12cc8c17865f8956cc31ad976f75d4 | anila-a/CEN-206-Data-Structures | /lab03/ex14.py | 799 | 4.125 | 4 | '''
Program: ex14.py
Author: Anila Hoxha
Last date modified: 03/13/2020
Write a short Python program that takes two arrays a and b of length n storing int values, and
returns the dot product of a and b. That is, it returns an array c of length n such that c[i] =
a[i] · b[i], for i = 0, . . . ,n−1.
'''
def d... |
3939624cb13024d6b430cfffcdda79b6d3188352 | ucsb-cs8-f18/cs8-f18-lecture-code | /lec13/termination_trace.py | 233 | 3.5 | 4 | n = 3
while n > 0:
if n % 5 == 0:
n = -99
print n
n = n + 1
-----
n = 3
3 > 0? yes
print 3
n = 4
4 > 0? yes
print 4
n = 5
5 > 0? yes
n remainder 5 is 0!
n = -99
print -99
n = -98
-98 > 0? no
|
b1fbffa3718f22ffb73b60333caaf54fddd8666b | NARENSTAR/python | /day14/sub function.py | 140 | 3.890625 | 4 | def sub(a,b):
c=a-b;
print("subtraction",c)
return
a=int(input("enter the number1:"))
b=int(input("enter the number 2:"))
sub(a,b) |
584b7f3ee70d92b9d529bcbe46bfe29f396972e1 | ShaoxiongYuan/PycharmProjects | /1. Python语言核心编程/1. Python核心/Day04/exercise05.py | 256 | 3.859375 | 4 | str_input = input("请输入一个字符串:")
for i in str_input:
print(ord(i))
while True:
str_input = input("请输入编码值:")
if str_input == "":
break
else:
message = chr(int(str_input))
print(message)
|
d41e1b0b4b55b36ec18c9dd8da68a094eb7da4cc | AnkitaYadav1999/Python-Programs | /Arithmatic Operations.py | 576 | 4 | 4 | Python 3.9.2 (tags/v3.9.2:1a79785, Feb 19 2021, 13:44:55) [MSC v.1928 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license()" for more information.
>>> print("Arithmatic Operations")
Arithmatic Operations
>>> print("Addition")
Addition
>>> a = 10
>>> b = 20
>>> c = a + b
>>> print(c)
30
>>> print("S... |
1201238b1dc00b2cf65cac64434a5fa9e28451a9 | inlee12/Python | /quiz4_part4.py | 135 | 3.75 | 4 | def non_even(x):
tot =0
for k in x:
if k%2 != 0:
tot += k
return tot
x=[2,4,6,7,9]
print(non_even(x))
|
ac155f66844f153f9533fc6564ff772561e32795 | Tr4shL0rd/mathScripts | /funktioner/findFunktionsVærdien_X_Plus.py | 382 | 3.8125 | 4 | #https://www.matematikfessor.dk/lessons/funktionsvaerdi-for-lineaert-udtryk-2-1198?id=21391446
try:
def main():
while True:
print("f(x) = a*x+b")
x = int(input("x = "))
a = int(input("a = "))
b = int(input("b = "))
print(a*x+b)
print()
main()
except KeyboardInterrupt:
print("CTRL-C\r\tGood-Bye")... |
54dae5293a39d78856ef91e37b70ddd19600a68b | c344081/learning_algorithm | /02/99.py | 1,345 | 3.734375 | 4 | '''
Recover Binary Search Tree
Two elements of a binary search tree (BST) are swapped by mistake.
Recover the tree without changing its structure.
Note:
A solution using O(n) space is pretty straight forward. Could you devise a constant space solution?
'''
# Definition for a binary tree node.
class TreeNode(object)... |
03e8b7d1821f055f9f3a68f7cdb0a2e985507f01 | Flerken101/Python-Crash-Course | /Chapter 9/restaurant.py | 1,343 | 3.921875 | 4 | class Restaruant():
"""一次模拟餐馆的简单尝试"""
def __init__(self, restaurant_name, cuisine_type):
"""初始化描述餐馆的属性"""
self.restaurant_name = restaurant_name
self.cuisine_type = cuisine_type
self.number_served = 0
def describe_restaurant(self):
"""简单描述餐馆的名字及主营菜品"""
... |
604a626652c1f6f94a2b3156d56f84efa06bac0a | sbhusal123/Python-Data-Structures | /Data Structures/Tuples/immutable_property.py | 241 | 3.84375 | 4 | x = (1,2,3)
# del(x[0]) # TypeError: 'tuple' object doesn't support item deletion
# x[1] = 8 # TypeError: 'tuple' object does not support item assignment
# y = ([1,2,3],4,5)
# del(y[0][1])
# print(y)
a = (1,2,3)
b = (4,5,6)
print(a+b)
|
5ead77bf50795522e4f862c40fae3d897fb1efad | PiotrusWatson/evogame | /species.py | 413 | 3.5 | 4 | """A class for each species in the game which contains the base population, speed, size, and power and possible mutations"""
from mutants import Mutants
from biome import Biome
class Species:
def __init__(self, name):
self.name = name
self.population = 100
self.mutants = []
self.biomes = []
def toString(s... |
5b56868c3ef6062d012d17ba2674960cdd4a56cc | EveryDayIsAPractice/Leetcode-python3 | /242_Valid_Anagram-0.py | 859 | 3.53125 | 4 | class Solution:
def isAnagram(self, s, t):
"""
:type s: str
:type t: str
:rtype: bool
"""
if s is None:
if t is None:
return True
else:
return False
elif t is None:
return False
memory... |
90741111dca4f139ebf5be3f55af61df8b488a03 | akhilmn18/CollegeStuff | /AI/Python/DFS_Example.py | 506 | 3.90625 | 4 | GRAPH = {
'S': ['A', 'B', 'C'],
'A': ['D'],
'B': ['E'],
'C': ['F'],
'D': ['G'],
'E': [],
'F': [],
'G': []
}
# Recursive DFS
def dfs(node):
if node not in VISITED: # Check for Visited Node
print(node)
VISITED.add(node) ... |
af61ee159105da4298dde129c2520c31e0f9c248 | Jetpuffed/CS-1.1-Intro-to-Programming | /spaceman/spaceman.py | 4,366 | 4.375 | 4 | import random
def load_word():
'''
A function that reads a text file of words and randomly selects one to use as the secret word
from the list.
Returns:
string: The secret word to be used in the spaceman guessing game
'''
f = open('words.txt', 'r')
words_list = f.readlines()... |
8afc5f1cba8232870d20d12c09b3455d9362c611 | mengqhui/mnist_LeNet | /tensorflow_model.py | 9,253 | 3.515625 | 4 | import tensorflow as tf
from tensorflow.examples.tutorials.mnist import input_data
import utility
def weight_variable(shape):
initial = tf.truncated_normal(shape, stddev=0.1)
return tf.Variable(initial)
def bias_variable(shape,init_value=0.1):
initial = tf.constant(init_value , shape=shape)
return ... |
d7a81689fa56e29cabbb21da07c471ff7e615a70 | ericosur/ericosur-snippet | /python3/omc/ser1357.py | 318 | 3.59375 | 4 | #!/usr/bin/python3
# coding: utf-8
'''
1+3+5+7...
'''
def main():
''' main '''
limit = 400
t = 0
k = 1
repeat = 1000
for i in range(repeat):
#print(k)
t += k
k += 2
print(i, t)
if t >= limit:
break
if __name__ == '__main__':
main()
|
ddd9d480a859f453e2e2dd52a4dbb8c0fc61cb21 | cuban1edziela/pisscord | /Flask_Backend_API/api/db.py | 1,138 | 3.796875 | 4 | import sqlite3
class Database:
def __init__(self, db):
self.conn = sqlite3.connect(db)
self.cur = self.conn.cursor()
self.cur.execute("CREATE TABLE IF NOT EXISTS contacts (id INTEGER PRIMARY KEY, name text, surname text, n text, e text)")
self.conn.commit()
def fetch... |
650bdece75a5d5a90a951c42948b91a1363dc06c | robertompfm/morais-parking-python | /MoraisParkingPython/model/area_estacionamento.py | 1,417 | 3.875 | 4 | class AreaEstacionamento():
# CONSTRUCTOR
def __init__(self, nome, tipo, capacidade, especial=True, ocupacao=0):
self.nome = nome
self.capacidade = capacidade if capacidade > 0 else 1
self.tipo = tipo
self.especial = especial
self.ocupacao = ocupacao
# GETTERS AND S... |
159db7ca66fb6267fec7680d3562e9e4b9b70c0e | here0009/LeetCode | /Python/294_FlipGameII.py | 1,244 | 3.765625 | 4 | """
You are playing the following Flip Game with your friend: Given a string that contains only these two characters: + and -, you and your friend take turns to flip two consecutive "++" into "--". The game ends when a person can no longer make a move and therefore the other person will be the winner.
Write a function... |
328e67619c06ffea93a93a323e4ebf963caeba92 | rafaelperazzo/programacao-web | /moodledata/vpl_data/303/usersdata/287/77772/submittedfiles/testes.py | 401 | 3.796875 | 4 | # -*- coding: utf-8 -*-
#COMECE AQUI
salarioh=float(input('quanto vc ganha por hora?: '))
salariob=salarioh*30
ir=salariob-(salariob*0.11)
inss=salariob-(salariob*0.08)
sindicato=salariob-(salariob*0.05)
salariol=salariob-ir-inss-sindicato
print(salariob)
print('-ir(11%):(ir)R$')
print('-inss(8%):'+inss+'R$'... |
7a158ab33100ad8ab78bf04b8d38388935892737 | Imafikus/orbital-paradox | /check_types.py | 2,098 | 4.28125 | 4 | import datetime
def check_positive_int(value):
"""
Checks if provided value is positive integer.
Returns True or False
"""
check = True
try:
int(value)
except ValueError:
check = False
return check
if int(value) < 0:
check = False
return check
... |
4c54aeead1be8f44715fb19166b44115c2665197 | antweer/learningcode | /intro2python/multiplication_table.py | 118 | 3.90625 | 4 | for num in range(1,11):
for num1 in range(1,11):
num2 = num*num1
print("{} x {} = {}".format(num, num1, num2))
|
296d7b690884a0569ea666f4fc4ced1ef37a05da | khryss/PLP | /exercises/e7_tree_iterator.py | 317 | 3.625 | 4 | '''Tree iterator in pre-order'''
def tree_iter(tree):
# tree format: ('a', ('b', None, None), None)
if tree:
name, child_left, child_right = tree
yield name
for left in tree_iter(child_left):
yield left
for right in tree_iter(child_right):
yield right
|
9139b798084f54b81567e8e9ddd850fb0dcf3072 | jarkynashyrova/pythoProject | /lists.py | 5,905 | 4.53125 | 5 | # lists (Array) a list a collection of items in a particular order. you can make
# list that includes the letters, digits from 0-9 or names
# the pop() method removes the element
#append() add items to the list
#operations: create, access, add element, remove element, copy
#num = lists()# create an empty list
#evens = ... |
bd19efc46d7d3bed2a822ed4a543313f4df43918 | Md-ASIFUR-RAHMAN/Data-preprocessing | /pandas02.py | 17,721 | 3.515625 | 4 | #!/usr/bin/env python
# coding: utf-8
# In[24]:
import pandas as pd
df = pd.read_csv('annual-buisness-csv.csv')
df.head(50)
df['year']
# In[10]:
get_ipython().run_line_magic('matplotlib', 'inline')
df.plot.scatter(x='hp',y='mpg')
# In[11]:
get_ipython().run_line_magic('matplotlib', 'inline')
df.plot.scatter(... |
5afd5f2c7d902962f9898981a8a640ea04d016bf | zyb8023/py_study | /zip_f/zip_demo.py | 1,318 | 3.734375 | 4 | import os;
import zipfile;
def create_zip(path):
"""创建一个压缩文件"""
# 创建一个zip文件对象
print(os.path.basename(path))
zip_file = zipfile.ZipFile(os.path.basename(path) + ".zip", "w")
# 将文件写入zip文件中,即将文件压缩
# os.walk 遍历目标文件夹,获取每一个文件和文件夹
print('开始压缩文件……')
for root, dirs, files in os.walk(path, topdo... |
8acd4a653443970dd861207c6fccc196579b4a05 | bisoisk/An-Introduction-to-Interactive-Programming-in-Python-Part_1 | /Practical Exercises/Ex1_LogicAndConditionals1.py | 6,643 | 4.375 | 4 |
# Ex1 for logic and conditionals
###################################################
# 1. Write a Python function is_even that takes as input the parameter number (an integer) and returns True if number is even
# and False if number is odd. Hint: Apply the remainder operator to n (i.e., number % 2) and compare to zer... |
974b7ff3e203cb6725351ecf117e2832075b30e0 | dingyaguang117/ProjectEuler | /util/Prime.py | 1,675 | 3.6875 | 4 | import math
def PrimeList(N = None,limit = None):
'''
return first N primes or primes <= limit
'''
if N ==None and limit ==None:
raise Exception('need either N or limit')
ans = [2,3]
i = 5
dt = 2
while True:
if N != None and len(ans) >= N : break
if limit != None and ans[-1] >= limit: break
f = True... |
7d7c3d808a9736e8a724d4e28aac1e9717cb25ad | Ranjith8796/Python-programs | /Task-1 (sum_of_the _employees).py | 1,141 | 3.828125 | 4 | import pandas as pd
# function for returning the sum of the Employees of all Department where the Country is India
def sum_of_emp():
object_2=['India']
r_df2 = df2.loc[df2['COUNTRY'].isin(object_2)]
object_1=r_df2['CODE'].tolist()
r_df1 = df1.loc[df1['COMPANY_CODE'].isin(object_1)]
allemp=r_df1['TO... |
5c2e566a0a4b1a9905b9a3d099a94d557750281b | RickWazowski98/csv_viewer | /src/tools.py | 282 | 3.546875 | 4 | import csv
import pandas as pd
def read_csv_header(path):
pass
def read_csv_data(path):
with open(path, "r") as file:
df = pd.read_csv(file, usecols=[0,1,2,3,4,5,6], delimiter=",")
list_of_rows = [list(row) for row in df.values]
return list_of_rows
|
adbbe1127e59c28fbf25ff628d7cf12c2424d286 | sarae17/2019-T-111-PROG | /exams/stoduprof/sales.py | 1,297 | 4.09375 | 4 | def open_file():
'''
Prompts the user for a file name.
Returns the corresponding file stream or None if file not found
'''
try:
file_name = input("Enter file name: ")
file_stream = open(file_name)
return file_stream
except FileNotFoundError:
return None
def read_... |
f03e7476418f393bd23a9526d1bce54b4827d735 | lingzhengZHANG/Junior-Year | /Introduction to Machine Learning/Logistic Regression.py | 4,512 | 3.53125 | 4 | from numpy import *
'''
filename='hw3_train.dat' #文件目录
def loadDataSet(): #读取数据(这里只有两个特征)
dataMat = []
labelMat = []
fr = open(filename)
for line in fr.readlines():
lineArr = line.strip().split()
dataMat.append([1.0, float(lineArr[0]), float(lineArr[1])]) #前面的1,表示方程的常量。比如两个特征X1,X2,... |
92c514d2639d25de402bfa65ad6c8e02068ef3e1 | Thamarai-Selvam/Exthand-test | /Test_app.py | 1,938 | 3.578125 | 4 | from tkinter import *
from PIL import Image,ImageTk
import time
#root window
welcomewin = Tk()
welcomewin.title("Welcome to Exthand")
welcomewin.configure(background='#3C3C3C')
logo = Image.open("D:\Exthand\Title.png")
logocard = ImageTk.PhotoImage(logo)
logolabel = Label(image=logocard)
logolabel.image = lo... |
86c2c2a8756cbf616714fa23289f626292438a37 | dssk2001/Rock-Paper-Scissors | /RPS.py | 1,740 | 3.75 | 4 | import random
import tkinter as tk
window = tk.Tk()
window.geometry("300x300")
window.title("Rock Scissor Paper")
ui=""
ci=""
usc = 0
csc = 0
def rcc():
return random.choice(['Rock','Paper','Scissor'])
def choice_to_number(choice):
rps={'Scissor':0,'Paper':1,'Rock':2}
return rps[cho... |
24f9f681421781ac884004d35e8c4f815b0b533a | mkseth4774/ine-guide-to-network-programmability-python-course-files | /TSHOOT/TSHOOT#2/good.higher.py | 247 | 4.15625 | 4 | ##
##
number1 = int(input("Please enter your first number: "))
number2 = int(input("Please enter your first number: "))
if number1 > number2:
HIGHEST = number1
else:
HIGHEST = number2
print("The higher of the two numbers was ", HIGHEST)
|
c347c6cdb59c5b3f395bc0dc902d31866c1b4ff5 | DavidWrightOS/Intro-Python-II | /src/adv.py | 4,059 | 3.5 | 4 | from room import Room
from player import Player
from item import Item
# Declare all the rooms
room = {
'outside': Room("Outside Cave Entrance",
"North of you, the cave mount beckons."),
'foyer': Room("Foyer", """Dim light filters in from the south. Dusty
passages run north and east."... |
0ba23f7e46e494909fcda0dd9767250703dcf91f | eltnas/ExerciciosPythonBrasil | /04 - ExerciciosListas/04.py | 342 | 3.578125 | 4 | vetor = []
vogal = ['A','E','I','O','U']
contVogal = 0
contConsoante = 0
for i in range(10):
palavra = str(input("Escreva: ").upper())
vetor.append(palavra)
if palavra in vogal:
contVogal = contVogal + 1
else:
contConsoante = contConsoante + 1
print("São {} consoantes!".fo... |
367a2db5539d2304773d484d9219a887ed49eb61 | yeazin/python-test-tutorial-folder | /list manipulation.py | 335 | 3.875 | 4 | #list manipulation
x=[5,544,54543,5421,85,32,424,4]
#x.append(55555)
#x.insert(2,555)
#remove element
##x.remove(85)
#remove element for specify
##x.remove(x[2])
#for count a data from the list type
##print(x.count(85))
#for finding of place of a value type
#print(x.index(anything))
## for sort of the list type
x.so... |
306fdc4dde5e8f0aa01567f0ad7df135cb96d6be | AmenehForouz/leetcode-1 | /python/problem-1290.py | 1,653 | 3.765625 | 4 | """
Problem 1290 - Convert Binary Number in a Linked List to Integer
Given head which is a reference node to a singly-linked list. The value of
each node in the linked list is either 0 or 1. The linked list holds the
binary representation of a number.
Return the decimal value of the number in the linked list.
"""
... |
cc0b4aaa92b7a22892b4f2711ee355a8b0e1109a | astamminger/zotero-bibtize | /tests/bibkey_formatter/test_formatters/test_author_formatters.py | 7,679 | 3.53125 | 4 | """
Test suite for BibKey formatting sequences.
Tests the generation of key contents based on the author entry
"""
from zotero_bibtize.bibkey_formatter import KeyFormatter
#
# Test lower author formatting
#
def test_no_author_lower():
key_formatter = KeyFormatter({})
key_format = '[author:lower]'
assert ... |
5056723c07701b29b5ba8f4555be10a52bb7b640 | krstoilo/SoftUni-Fundamentals | /Python-Fundamentals/Exams/shopping_list.py | 842 | 4 | 4 | shopping_list = input().split("!")
command = input()
while command != "Go Shopping!":
if "Urgent" in command:
command = command.split()
if command[1] not in shopping_list:
shopping_list.insert(0, command[1])
elif "Unnecessary" in command:
command = command.split()
i... |
737044d300685f6c1d111fc3a17acb15ba82d2ee | contactsohail07/Huffman-Coding | /huff.py | 1,279 | 3.875 | 4 | inp_string=raw_input("enter the string ")
def frequency():
global inp_string
freq={}
for char in inp_string:
freq[char]=freq.get(char,0)+1
return freq
inp_freq=frequency()
def sort(dict):
inp_list=[]
for char in dict:
inp_list.append((dict[char],char))
inp_list.sort() ... |
449f78675dd6e62d724c708546de2627f9b0b5a3 | sheetal101/loop | /average.py | 227 | 3.8125 | 4 | i=1
count=0
sum=0
while i<=4:
A=int(input("enter a weight: "))
sum=sum+A
count=count+1
i=i+1
print(sum)
print(sum/count)
average=sum/count
if average%5==0:
print("divisible")
else:
print("not divisible") |
97296de5e01d888f2acb09cc888d53a7ea188ba4 | qmnguyenw/python_py4e | /geeksforgeeks/python/python_all/147_1.py | 4,304 | 4.46875 | 4 | Python program for word guessing game
Python is a powerful multi-purpose programming language used by multiple giant
companies. It has simple and easy to use syntax making it perfect language for
someone trying to learn computer programming for first time. It is a high-
level programming language, and its cor... |
0b8578558ca24d1999db75c3ded6adc42eff4cbe | 981377660LMT/algorithm-study | /11_动态规划/dp分类/区间dp/dfs/回文/1278. 分割回文串 III-枚举分割点.py | 1,353 | 3.625 | 4 | from functools import lru_cache
# 首先,你可以将 s 中的部分字符修改为其他的小写英文字母。
# 接着,你需要把 s 分割成 k 个非空且不相交的子串,并且每个子串都是回文串。
# 请返回以这种方式分割字符串所需修改的最少字符数。
# 1 <= k <= s.length <= 100
# 总结:
# 枚举分割点+记忆化dfs
class Solution:
def palindromePartition(self, s: str, k: int) -> int:
@lru_cache(None)
def cal(lef... |
bb381455e2bcf75bd8679ed5413a17c6a70247f4 | fgardete/pdsnd_github | /Bikeshare_GiadaSartori_3.py | 7,557 | 4.375 | 4 | import time
import pandas as pd
import numpy as np
CITY_DATA = { 'chicago': 'chicago.csv',
'new york city': 'new_york_city.csv',
'washington': 'washington.csv' }
def get_filters():
"""
Asks user to specify a city, month, and day to analyze.
Returns:
(str) city - name ... |
2b12f948d52ff866884b143da3d682c3d1286135 | bfaure/Encryption | /algo/shift.py | 2,421 | 3.78125 | 4 |
import sys
# 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
letters_upper = ["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"]
letters_lower = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o"... |
44f27dbb637a603c0bd93a78a8b4ee2398d70d2b | greenfox-velox/timikurucz | /week-03/day-4/cw02.py | 654 | 3.875 | 4 | # Check to see if a string has the same amount of 'x's and 'o's. The method must return a boolean and be case insensitive. The string can contains any char.
def XO(s):
num_o = 0
num_x = 0
o_letters = ('o', 'O')
x_letters = ('x', 'X')
for char in s:
if char in o_letters:
num_o +=... |
af47b5effb408dc49f78bde3ee4f0226342d8506 | daniel-reich/ubiquitous-fiesta | /sDvjdcBrbHoXKvDsZ_19.py | 343 | 3.59375 | 4 |
def anagram(name, words):
l = []
for i in range(len(name)):
if name[i] != ' ':
l.append(name[i].lower())
for i in range(len(words)):
for j in range(len(words[i])):
if words[i][j].lower() in l:
l.remove(words[i][j])
else:
return False
if len(l) == 0:
return True
e... |
88213522cfb133b24a460b44ed6f6010898e0057 | christinapanto/project | /New folder/dmelt/python/packages/npfinder/classes.py | 4,792 | 3.859375 | 4 | class Point:
"""
Point object class
Attributes:
point_number = number of given point
x -> point x coordinate
y -> point y coordinate
x_err_low -> low error in x
x_err_high -> high error in x
y_err_low -> low error in y
y_err_high -> high error in... |
f23e4bd10c978746b9a0ffdac838c88ab4489478 | Cyberghost999/Basic-Python-Programmes | /extractNumbersFromList.py | 121 | 3.59375 | 4 | str = "Hello 12345 World"
l =[]
for i in str:
if i.isdigit():
l.append(i)
else:
continue
print(l) |
aa3b63cde85b7be7fc44906fffe567e0d8367446 | weichuntsai0217/work-note | /programming-interviews/epi-in-python/ch05/06_6_BUYANDSELLASTOCKONCE.py | 652 | 3.921875 | 4 | from __future__ import print_function
def get_max_profit(x):
"""
Time complexity is O(n) where n is the length of x
"""
max_profit = 0
min_price = float('inf')
for p in x:
max_profit = max(max_profit, p - min_price)
min_price = min(min_price, p)
return max_profit
def get_input(case=0):
if c... |
0f23fd0ec2fa18e21f5183498e6b72c6cc60b8c7 | manuelmj/Dise-o_Microelectronico_Digitial | /taller/ejercicio6.py | 897 | 4.125 | 4 |
def media(Numeros:list)->float:
sumaNumeros=sum(Numeros)
cantidadNumeros=len(Numeros)
return(sumaNumeros/cantidadNumeros)
def desviacionEstadar(Numeros:list)->float:
cantidadNumeros=len(Numeros)
sumatoria=0
x=media(Numeros)
for numero in Numeros:
sumatoria+=((numer... |
56f77016d3ecbb8eae86168037e2a74999d963a5 | nghiemphan93/machineLearning | /2019-03-14_Genetic Algorithm/Population.py | 4,206 | 3.515625 | 4 | import random
from DNA import DNA
from typing import List
class Population:
def __init__(self, target: str, mutationRate: float, populationSize: int):
self.DNAList = []
self.matingPool = []
self.target = target
self.generations = 0
self.mutationRate = mutationRate
self.isFi... |
0783d25b0675030de78e18229e5719a821951a6a | ShinW0330/ps_study | /05_Graph_Search/Level3/5567.py | 1,014 | 3.640625 | 4 | # 결혼식
# https://www.acmicpc.net/problem/5567
# 힌트
# 1. BFS를 이용하여 깊이 2까지의 모든 노드의 개수를 파악한다.
import sys
from collections import deque
def bfs(s):
q = deque()
q.append(s)
check[s] = True
depth = 0
ans = 0
while len(q) != 0:
q_size = len(q)
if depth == 2:
return ans
... |
394dcfa3fb98be7ead1a337a3eb2f732eaca920f | bpapillon/adventofcode2020 | /02/01.py | 691 | 4 | 4 | import re
def parse_line(line):
pattern = r'([0-9]+)\-([0-9]+) ([a-z])\: ([a-z]+)$'
match = re.match(pattern, line)
min_occurrences = int(match.group(1))
max_occurrences = int(match.group(2))
char = match.group(3)
password = match.group(4)
return (password, char, min_occurrences, max_occur... |
b3712dcaab606d5cf6b974e4d1803fd865173ced | alexsks65536/Python-base | /lesson01/lesson1-3.py | 573 | 3.890625 | 4 | def procent_write(procent):
s = procent[-1]
if s == '1' and procent != '11':
text = 'процент'
return text
elif procent == '11' or procent == '12' or procent == '13' or procent == '14':
text = 'процентов'
return text
elif s == '2' or s == '3' or s == '4':
text = 'п... |
cbfff23b392e048b2f9d085405903790c752911e | Hanchen-Yao/opencv-test | /python/roi_demo.py | 1,510 | 3.5 | 4 | # ROI与泛洪填充:换掉图片区域的某个部分
# 作者:hanchen
# 时间:2020年5月10日
import cv2 as cv
import numpy as np
import matplotlib.pyplot as plt
def fill_color_demo(image):
copyImg = image.copy()
h, w = image.shape[:2]
mask = np.zeros([h + 2, w + 2], np.uint8)
# 参数:原图,mask图,起始点,起始点值减去该值作为最低值,起始点值加上该值作为最高值,彩色图模式
cv.floodFi... |
feb184b75e3c57ac1433881c6bc74e797e89f52b | thatsokay/advent-of-code | /2018/05/part2.py | 316 | 3.59375 | 4 | from string import ascii_lowercase
from part1 import react
if __name__ == '__main__':
with open('input.txt') as f:
polymer = f.read().strip()
results = (
len(react(polymer.replace(letter, '').replace(letter.upper(), '')))
for letter in ascii_lowercase
)
print(min(results))
|
6fd43374f0bc36dffb2839f570bbd73c9bc5a808 | endy-see/AlgorithmPython | /ZuoShen/0-MinArrSum.py | 600 | 3.5 | 4 | """
计算数组的小和
题目:数组的小和定义如下:
例如,数组s=[1,3,5,2,4,6],在s[0]的左边小于或等于s[0]的数的和为0,在s[1]的左边小于或等于s[1]的数的和为1,
在s[2]的左边小于或等于s[2]的数的和为1+3=4,在s[3]的左边小于等于s[3]的数的和为1,在s[4]的左边小于或等于s[4]
的和为1+3+2=6,在s[5]的左边小于或等于s[5]的数的和为1+3+5+2+4=15,所以s的小和为0+1+4+1+6+15=27.
给定一个数组s,实现函数返回s的小和
思路:归并排序,在归并的时候对右边的每个数,如果
""" |
08fa36e86ec240d83526c43a5b90fc89475fe9b6 | thanikaReddy/fbNewsAnalysis | /regression/multivariate.py | 9,635 | 3.703125 | 4 | """ Fits a multivariate linear regression model to all features, to predict mins_to_100_comment
Fits a multivariate linear regression model multiple times - the number of times is defined by NUMITER.
Each iteration,
* One feature is added to the model at a time and the change in R2 and RMSE is noted for each featur... |
798aad37b7e6d7d6c3cdb0eeeb042a274b6c8924 | jorgezafra94/Python_to_the_top | /Python_intro/lists_tup_set_dic.py | 5,456 | 4.5625 | 5 | # lists tuples sets dictionaries
print('****************************** LIST *************************************')
print('---------------- slicing ---------------------')
a = [1,2,3,4,5,6,7,8]
print(a)
print(a[:])
print(a[1: 4])
print(a[3:])
print(a[:5])
print(a[-2])
print(a[-5: 5])
print('--------------------ADD---... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.