blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
6dae0009db5c974725c375f8b4e427a2fbe0e2a5
duderman/geek_brains
/python/1/1.py
209
3.796875
4
a = "" b = 1 str_input = input("SUP?: ") print("str_input is: ", str_input) try: int_input = int(input("SUP(int)?: ")) except ValueError: print("Not a number") else: print("int_input is :", int_input)
897b853b0b3b93fba2309d87f994f3c722ad029d
ekateryna-rodina/problem-solving
/pow.py
545
4.25
4
# This problem was asked by Google. # Implement integer exponentiation. That is, implement the pow(x, y) function, where x and y are integers and returns x^y. # Do this faster than the naive method of repeated multiplication. # For example, pow(2, 10) should return 1024. def pow(number, power): if power == 1: ...
a5abda2fc996ee6bdb50cb905d7d435bd6516335
rajlath/rkl_codes
/LeetCodeContests/others/forest1.py
1,144
3.875
4
''' Examples: Input: answers = [1, 1, 2] Output: 5 Explanation: The two rabbits that answered "1" could both be the same color, say red. The rabbit than answered "2" can't be red or the answers would be inconsistent. Say the rabbit that answered "2" was blue. Then there should be 2 other blue rabbits in the forest that...
004d76fee20f60d48d0f03601ade498bc2d9c73d
mehdislymnv/PragmatechFoundationProject
/HackerRank/python-arithmetic-operators.py
161
3.53125
4
a=int(input()) b=int(input()) t=a+b c=a-b v=a*b print(t) print(c ) print(v ) """ https://www.hackerrank.com/challenges/python-arithmetic-operators/problem """
65cdb4eb3a39bead0049fa93465fe1033cdfcb3d
schatfield/Convert-Student-Object-to-a-String
/convert.py
3,854
4.1875
4
# Use the __str__ and __repr__ magic methods on your class to specify what an object's string representation should be. It's just like the toString() method in JavaScript. # If you print a Student object. The output would look something like below. # mike = Student() # mike.first_name = "Mike" # mike.last_name = "Ell...
9556d69914a7503fa2573289827d7da0a8a6c2d3
MashuAjmera/Algorithms
/lcs.py
879
3.625
4
# Problem: Longest Common Subsequence # Author: Mashu Ajmera # Algorithm: Dynamic Programming # Leetcode: https://leetcode.com/problems/longest-common-subsequence/submissions/ # GFG: https://www.geeksforgeeks.org/longest-common-subsequence-dp-4/ class Solution: def longestCommonSubsequence(self,a,b): la=le...
8c4202185d9cd80693b4aa5e516e3a3f9858deeb
chavp/MyPython
/ThinkPython/string.py
309
3.78125
4
fruit = 'banana' print(len(fruit)) index = 0 while index < len(fruit): letter = fruit[index] print(letter) index = index + 1 # slice print(fruit[:3]) print(fruit[3:]) import string import random rans = [random.random() for x in range(10)] print(rans) t = [x for x in range(10)] print(random.choice(t))
7747f18cbd2cca9675e8e5cd4e88d66e42f6e4d5
QIAOZHIBAO0104/My-Leetcode-Records
/1800. Maximum Ascending Subarray Sum.py
837
4.03125
4
''' https://leetcode.com/problems/maximum-ascending-subarray-sum/ Given an array of positive integers nums, return the maximum possible sum of an ascending subarray in nums. A subarray is defined as a contiguous sequence of numbers in an array. A subarray [numsl, numsl+1, ..., numsr-1, numsr] is ascending if for all i ...
9f68a1d5e77682aa4b7247f8c0cca60ecf620244
BAFurtado/Python4ABMIpea2020
/classes/class_da_turma.py
1,479
4.4375
4
""" Exemplo de uma class construída coletivamente """ class Aluno: def __init__(self, name): self.name = name self.disciplinas = list() self.email = '' class Turma: def __init__(self, name='Python4ABMIpea'): self.name = name self.students = list() def add_student...
60e26bdfb2f94f1f0df94c7a85ac9c1c81d7cdc4
zubuxx/University_programming
/List_1/Vector.py
6,301
4.28125
4
# -*- coding: utf-8 -*- u"""Klasa przechowująca wektor j""" import random import math class Vector(): """ Class used to represent Vector ... Attributes ---------- size : int size of vector(default 3) numbers : list vector respresented as...
993aad02c5ac7639ff0a135699968e150a9c02cc
Gramosa/Importacao_teste
/plano_cartesiano/point.py
2,426
4.0625
4
from .functions import * def check_value(value): """ Check if a value is numeric """ try: value / 2 except: raise Exception('The value need be numeric') class Point():#Just a 2D point, A(x, y) """ This class simulates 2D points, type A(x, y) There are ...
e3daa24bfd640e01fb7401bd949968cedd4a9b9a
johnromanishin/Python
/Old Python Programs/ps54.py
1,302
4.0625
4
# Problem set 2 # Name: John Romanishin # Collabortors: R Tharu # Time: 6:00 # Enumerate possible answers starting at 1 McNugget # For each possible answer n, # Check if there exists x, y, and z such that 6x+9y+20z = n # (this can be done by looking at all feasible combinations of x, y, and z) # If not, n...
d1f28bd8346d9591ef93265ad9b03b73ddf3b3b9
pvinod480/msit
/set6.py
3,861
3.671875
4
class Players: def __init__(self): self.players ={} try: fobj = open("players.txt","r") for line in fobj: fields = line.split() name = fields[0] players = fields[1:] for player in players: s...
09245803e096e4b461a699f99f3b4a2a4b667ab7
dylanlee101/leetcode
/code_week21_914_920/sum_of_leaves.py
896
4
4
''' 计算给定二叉树的所有左叶子之和。 示例: 3 / \ 9 20 / \ 15 7 在这个二叉树中,有两个左叶子,分别是 9 和 15,所以返回 24 来源:力扣(LeetCode) 链接:https://leetcode-cn.com/problems/sum-of-left-leaves ''' # Definition for a binary tree node. # class TreeNode: # def __init__(self, x): # self.val = x # self.left = None # ...
5cd79ad9eac30ead789f5bbbd9205ba3169a53c9
ngzhian/codeinsert
/grablines.py
995
3.890625
4
import sys def grab(filename, start, end=None): """Returns a lines `start` to `end` of a file Line numbers are 1-based and end is inclusive If end is None, return just one line """ start = int(start) end = start if end is None else int(end) with open(filename) as f: lines = [] ...
72105d7e79a9a77595ef64127ca9253d82598ee3
liuqun5050/myScript
/计算1到100的偶数和.py
133
3.609375
4
# 计算1到100之间偶数之间的和 i = 2 result = 0 while i <= 100: result += i i += 2 print("总和为:%d" %result)
dadc119f98306971563a56e5ea3ca7479b65f31b
AntoineAugusti/katas
/prologin/2014/15_balloons.py
715
3.625
4
# http://www.prologin.org/training/challenge/demi2014/balloons from sys import stdin data = [int(x) for x in stdin.readline().split()] nbBalloons = data[0] nbCustomers = data[1] # Get data for balloons balloons = [] for i in range(nbBalloons): balloons.append([int(x) for x in stdin.readline().split()]) # Get data f...
36b2fdd3b6b7ac296aa304cbef1518cff18eef43
Jschnore/hort503
/assignment2/ex8.py
383
3.546875
4
formatter = "{} {} {} {}" print(formatter.format(1, 2, 3, 4)) print(formatter.format("one", "two", "three", "four")) print(formatter.format(True, False, False, True)) print(formatter.format(formatter, formatter, formatter, formatter)) print(formatter.format( "I got something", "to type cuz", ...
7b3f65b63548856ae574fba472666ba580c44e35
ztony123/codeHouse
/yl_python_code/python_code/A_Python 总文件/继承/一个小题目.py
410
3.953125
4
class Parent(object): x = 1 class Son1(Parent): pass class Son2(Parent): pass print(Parent.x, Son1.x, Son2.x) # Son1.x Son2.x 是去找父类的参数 Son1.x = 2 print(Parent.x, Son1.x, Son2.x) # Son1.x = 2 是给Son1添加了一个参数 Son2.x 是去找父类的参数 Parent.x = 3 print(Parent.x, Son1.x, Son2.x) # x 先会去找本身是否有这个参数 没有再去父类里面找
a5d7de3a132d7119ee8682384c55f22ad4f90792
lxconfig/UbuntuCode_bak
/algorithm/leetcode/backtracking/07-组合总和Ⅱ.py
2,215
3.703125
4
""" 给定一个数组 candidates 和一个目标数 target ,找出 candidates 中所有可以使数字和为 target 的组合。 candidates 中的每个数字在每个组合中只能使用一次。 """ from typing import List class Solution: def combinationSum2(self, candidates: List[int], target: int) -> List[List[int]]: """减法思维 """ size, res, path = len(ca...
373a729fb9666bb0cf8d2afadf2ab146a96dfc9c
brauliotegui/SPICED
/Week_08/poker_player.py
1,058
3.75
4
class Player: ''' The class Player is a blueprint for a poker player. Parameter ------- name: Name of the player stack_size: Amount of chips the player currently has ''' buy_in = 1000 limit = 100 def __init__(self, name, maximum_bet): self.name = name self.__m...
c026eff9cb3d493306e82edd56770341818ae9fb
Isko00/ICT
/task1/24.py
329
4.09375
4
import math seconds = 0 print("Enter number of days: ") seconds += int(input()) * 24 * 60 * 60 print("Enter number of hours: ") seconds += int(input()) * 60 * 60 print("Enter number of minutes: ") seconds += int(input()) * 60 print("Enter number of seconds: ") seconds += int(input()) print("Time: " + str(seconds) + " ...
3a7f57dabaf19c9e58aac77c99dff694d2ebd673
zby981207/PythonDemon
/Chapter2/2-3.py
193
3.8125
4
char = input("Your customized character: ") print(char, char, '', sep=char) print(char, sep='') print(char, char, '', sep=char) print(char, ' ', char, sep='') print(char, char, '', sep=char)
f4de0c91b3e7224e3dd634c8362ddae6b55a6f02
yoongyoonge/python_100Q
/code/2. data_graph/026.py
395
3.5625
4
import pandas as pd import matplotlib.pyplot as plt # 예제 025에서 저장한 CSV 파일을 불러와서 데이터프레임으로 변환 df = pd.read_csv('./code/data/bok_statistics_CD_2.csv', header=0, index_col=0) print(df.head()) print('\n') # 막대 그래프 그리기 df.plot(kind='bar') plt.show() df['CD_rate'].plot(kind='bar') plt.show() df['change'].plot(kind='bar')...
e4ce29954355e352818c31f9605e7a25fa648a2f
dianedef/P3-Aidez-MacGyver
/models/player.py
2,233
4.03125
4
"""This module defines classes and functions related to the hero in the game.""" from copy import copy from models.position import Position class Player: """This class represents the player's sprite on the screen.""" def __init__(self, pseudo, bag, position, jeu): """This function initialize a play...
86e8e74f7ac8460e1753a480fa853012ffb21915
cyxy7757/PythonDemo
/FirstPython.py
2,684
4.09375
4
# msg = 'Hello world python' # print(msg) s = set([1,2,3,4,4,5]) print(s) # 定义一个求绝对值的函数,当入参错误时,给出提示。 # def my_abs(x): # if not isinstance(x,(int, float)): # raise TypeError("类型错啦,只能整数或者浮点数"") # if x >= 0: # return x # else: # return -x # print(my_abs(-5)) # print(my_abs('a')) # 默...
ddcbf35e6d58d77a53a04f2245c30be101785d59
Brandsma/LangTechFinal
/Question_Classifier.py
2,030
3.515625
4
# Find the Root # Look at Dependencies of Root # Find {'nsubj', 'dobj', 'prep', 'attr', 'ccomp'} (Question words can also be attributes) # With those dependencies find the subject and object # What's type of the question #Does root have a nsubj: # NO: # list/show/print/ hwatadffaheve # YES: # iS 'is' the ro...
99aa7a3e58453f93a35c4376425077865e66652c
paolobarto/Sudoku_Solver
/square.py
1,910
3.6875
4
import numpy as np from board import Board from squareVal import findSquareVal,possibleValue import importlib class Square(Board): def __init__(self,x,y): self.x=x self.y=y super().__init__() self.value=self.array[x][y] #This will be used to grab...
8975625122e93a50b8cd5280db961055c4ed5967
Armindo123/prog1
/avaliacao/avaliacao2/avaliacao2ex2.py
812
4.3125
4
#ordenar 3 valores do maior para o menor valor1 = float(input("Valor 1: ")) valor2 = float(input("Valor 2: ")) valor3 = float(input("Valor 3: ")) if valor1 == valor2 or valor1 == valor3 or valor2 == valor3: print("Introduza valores diferentes") elif valor1 > valor2 and valor2 > valor3: print("{} > {} > {}".f...
cb1f4faf899e13a265df0ccf58fb50356cfb68c2
Cat9Yuko/python-
/Python14字符串格式化.py
695
3.96875
4
#coding:utf-8 #字符串连接 str1='good' str2='bye' print str1+str2 #字符串和字符串变量连接 print 'vert'+str1 print str1+'and'+str2 #字符串和数字连接 #不能直接把字符串和数字直接相加 #用str()把数字转换成字符串 print 'My age is'+str(18) #或 num =18 print 'My age is '+str(num) #%对字符串进行格式化 #输出时,%d会被%后面的值替换 #%d只能替换整数,格式化小数用%f,想保留两位小数在f前加条件:%.2f #%s...
79ce1e0713b2f86a92c57db171d4ca7f19e3cb9f
frankShih/TimeSeriesVectorization
/vectorization/rdp.py
2,913
3.75
4
# -*- coding: utf-8 -*- """ The Ramer-Douglas-Peucker algorithm roughly ported from the pseudo-code provided by http://en.wikipedia.org/wiki/Ramer-Douglas-Peucker_algorithm """ from math import sqrt def distance(a, b): return sqrt((a[0] - b[0]) ** 2 + (a[1] - b[1]) ** 2) def point_line_distance(point, start, e...
5742096d50a153f525f4cc12a2e6bd2e38f360e6
SKosztolanyi/Python-exercises
/48_Reading a text file and averageing the converted number.py
611
4.03125
4
# Use the file name mbox-short.txt as the file name # In this assignment I work with another .txt file and I want to extract a number as a float from every line that starts with: # Then I calculate the average of all the numbers I gained. # I only print the final value fname = raw_input("Enter file name: ") fh = open(...
1da643ba961aed5094988005c912387da6f29e4f
kktn/DeepLearning
/chap3/activation_function.py
1,477
3.578125
4
import numpy as np import matplotlib.pylab as plt def step_function(x): return np.array(x > 0, dtype=np.int) def sigmoid(x): return 1 / (1 + np.exp(-x)) def relu(x): return np.maximum(0, x) def identity_function(x): return x def neuron(): # initial layer -> first layer X = np.array([1.0, 0....
a15fe0a35fec9be762616a6b42ec42750294a144
Fedalto/n-puzzle
/solver.py
4,324
3.640625
4
#!/usr/bin/env python # -*- coding: utf-8 -*- import tabuleiro, sys from heuristica import cebola,manhattan from nodo import Nodo, movimento class Solver (object): def __init__(self, n=3, tabini=None,heuristica=cebola): self.heuristica = heuristica(n) self.lista_pesos = [] self.n = n ...
4dd2f4c4ca8c46552db11f3120834f348c342278
lanjar17/Python-Project
/Chapter 5/Latihan 1/Latihan 1_2.py
613
3.875
4
# program hitung syarat kelulusan # input nilai BahasaIndonesia = int(input('Nilai Bahasa Indonesia :')) Matematika = int(input('Nilai Matematika :')) IPA = int(input('Nilai IPA :')) if(BahasaIndonesia < 0 or BahasaIndonesia > 100): print('Maaf input ada yang tidak valid') elif(Matematika < 0 or Matematika > 100)...
bc625f7de2e191283a64b02eb9c26f6013cb0ebc
ayoubabounakif/edX-Python
/count_input_character.py
156
3.734375
4
def count_char(string, char): count = 0 for x in string.lower(): if x == char.lower(): count = count + 1 return count
a21234ea6a5b6d77ff6fff28fb7b9fe7defe50f9
grbalmeida/hello-python
/useful-modules/csv/main.py
1,468
3.84375
4
import csv import sys argv = sys.argv def print_customers(): with open('./customers.csv', 'r') as file: data = csv.reader(file) next(data) for customer in data: name, lastname, email, phone = customer print(f'Name: {name}') print(f'Lastname: {lastname}') print(f'Email: {email}...
941fb86b32b13a5da17f970859e0fde3d9a3ebee
Khachatur86/FredBaptisteUdemy
/checkio/long_repeat.py
616
3.640625
4
def long_repeat(line): count = 1 max_count = 0 for index in range(len(line) - 1): if line[index] == line[index + 1]: count += 1 if count > max_count: max_count = count if line[index] != line[index + 1]: count = 1 return max_count if __name__ ...
ff1a3175751aa93dce84c249bfb1f077cf13f822
supragya1107/monopoly
/monopoly_game.py
26,252
3.765625
4
"""Ever played MONOPOLY? This is a short code written for the game. Game asks for the number of players in the beginning. You should choose more than one player. MADE BY-SUPRAGYA UPADHYAY :) """ ############################################################################### class Player: money=15....
94393011973525b51044bde6d694bb925a81e49b
shukad333/leet-python
/dynamicprogramming/MaxSumCombinationFromTwoArrays.py
1,120
3.890625
4
""" Given two arrays arr1[] and arr2[] each of size N. The task is to choose some elements from both the arrays such that no two elements have the same index and no two consecutive numbers can be selected from a single array. Find the maximum sum possible of above-chosen numbers. Examples: Input : arr1[] = {9, 3, 5,...
1c7181d7d8c7a89e6e37a4f650894048ddd64047
evgenylahav/exercism_python
/matrix/testing.py
225
3.53125
4
class A: def __init__(self, number): self.n = number a = A(1) b = A(1) print(id(a) == id(b)) # False L1 = [1, 2, 3] L2 = [1, 2, 3] print(id(L1) == id(L2)) # False c = 1 d = 1 print(id(c) == id(d)) # True
b5bb25579949bdbb1d9ed352c5726d01e54c3238
Burnin9Bear/PythonCode
/20181214Day1/counter.py
494
3.765625
4
num1 = int(input("请输入第一个数字")) num2 = int(input("请输入第二个数字")) num3 = int(input("请输入第三个数字")) sum = num1 + num2 +num3 if sum >100000: print("您输入的三个数的和忒大了") elif sum >10000: print("您输入的三个数的和挺大") elif sum >1000: print("您输入的三个数的和有点大") elif sum >100: print("您输入的三个数的和不算大") elif sum <=100: print("您输入的三个...
1656931eabcdb86412f5bd5f991ded6ed622cff0
boppanaravisastry/Examples-of-python-programs
/feet-inches.py
268
4.4375
4
#Unit conversion #Convert units from feet to inches. feet = float(input('# of feet?')) print (feet, "feet is:\t", feet*12.0, "inches") #Convert units from inches to feet. inches = float(input('# of inches?')) print (inches, "inches is:\t", inches/12.0, "feet")
34a2318b42d5f2bb3425644cf4b116e50511f90f
itsanshulverma/du-cs-undergrad-course
/Semester3/PythonSEC/Practicals/_04/ques_4.py
298
4.21875
4
# Input num = int(input("Enter a number greater than or equal to 10: ")) if num >= 10: #Check if num satisfies condtn. _set = set() #Create empty set while num != 0: _set.add(num%10) num = int(num/10) print("Set: ", _set) else: print("Oops! Number is less than 10")
c161866326941efac9f2424ca5a3127a7b531e44
gmg0829/pythonLearninng
/basic/listDemo.py
1,060
3.828125
4
hello = (1, 2, 3) li = [1, "2", [3, 'a'], (1, 3), hello] li.append("pytaya") li.insert(0,'balabala') li.pop() li.pop(0) li.remove('2') #访问元素 print(li[3],li[-2]) #切片访问 #格式: list_name[begin:end:step]begin 表示起始位置(默认为0),end 表示结束位置(默认为最后一个元素),step 表示步长(默认为1) print(li[0:2],li[:2]) print(li[0:3:2]) #嵌套访问 print(li[-2][1]) #删除元...
8472fb6598e09c17f02ccad8059b64f916de565f
ganhan999/ForLeetcode
/中等55. 跳跃游戏.py
1,703
4.28125
4
""" 给定一个非负整数数组,你最初位于数组的第一个位置。 数组中的每个元素代表你在该位置可以跳跃的最大长度。 判断你是否能够到达最后一个位置。 示例1: 输入: [2,3,1,1,4] 输出: true 解释: 我们可以先跳 1 步,从位置 0 到达 位置 1, 然后再从位置 1 跳 3 步到达最后一个位置。 示例2: 输入: [3,2,1,0,4] 输出: false 解释: 无论怎样,你总会到达索引为 3 的位置。但该位置的最大跳跃长度是 0 , 所以你永远不可能到达最后一个位置。 """ """ 如果某一个作为 起跳点 的格子可以跳跃的距离是 3,那么表示后面 3 个格子都可以作为 起跳点。 可以对每一个能...
67924b9236d42dc2dbc21e6d5297a9255ff93f90
tmurray19/BSc-Archives
/Python/Past Assignments/CS211/gaussian.py
5,436
4.21875
4
#student I.D: 15315901 """A class for Gaussian integers A Gaussing integer is a complex number of the form a+bi where a and b are integers""" """write the code for the class Gaussian which models Gaussian integers. Your code should have: 1. A constructor so that we can create objects of the class Gaussian as follows...
8c0377b70b902e6e61351869a4378b4c2c50a3a7
TheKillerAboy/programming-olympiad
/Python_Solutions/CodeForces/#579/Remove_the_Substring_(easy_version).py
636
3.546875
4
def get_all_lefts(word,substring): if len(substring) == 0: yield ((len(word),word),) else: if substring[0] not in word: yield (-1,) else: for i in range(len(word)): if word[i] == substring[0]: for sub_sequance in get_all_lefts(w...
12860fa37b1ec617847a69f89b332f65d5ebad8e
sylvain-01/Python_Games
/rock_paper_scissors/rock_paper_scissors.py
3,610
4.15625
4
import tkinter from tkinter import * from random import randint # initialize window where game will be played root = tkinter.Tk() root.geometry("1500x300") root.title("Rock, Paper, Scissors") root.config(bg="white smoke") # Define top label name label_top = tkinter.Label(root, text="Rock, Paper, Scissors Game: selec...
1d2caa0d9d87f80e40b3c5644c0854e94886e0c0
mathvolcano/leetcode
/1268_suggestedProducts.py
2,352
3.609375
4
""" 1268. Search Suggestions System https://leetcode.com/problems/search-suggestions-system/ """ class Solution: def suggestedProducts(self, products: List[str], searchWord: str) -> List[List[str]]: # Binary search # [1] Sort the products lexicographically # [2] For each prefix of searchWo...
a5c6cbd1ffd539881de0dfd87a5b254b0a7ab5ee
alexnsadler/Fundamentals-of-Computing-Specialization
/AT/AT Part 2/Project 3/week_3_app.py
6,209
3.984375
4
"""Project 3 application (student written).""" import random import timeit import alg_cluster import alg_project3_solution as des import matplotlib.pyplot as plt def gen_random_clusters(num_clusters): """Return a list of randomly generated points in the corners of a square. Input: num_clusters is the number...
724c807d4567215be0de9f657b28dbbcc476848c
duvu/my-filter5
/testpandas.py
885
3.78125
4
import pandas as pd df = pd.DataFrame({'Age': [20, 21, 22, 24, 32, 38, 39], 'Color': ['Blue', 'Green', 'Red', 'White', 'Gray', 'Black', 'Red'], 'Food': ['Steak', 'Lamb', 'Mango', 'Apple', 'Cheese', 'Melon', 'Beans'], ...
0aac905b298bd04987437fc02a5f1fcd9621000d
afs2015/SmallPythonProjects
/FunPythonProjects/FizzBuzzSolution.py
317
4.09375
4
#!/usr/bin/python # Author: Andrew Selzer # Purpose: Sample FizzBuzz solution. Counts from 1-100 and prints Fizz if number is divisible by 3, Buzz if number is divisible by 5 for num in range(1,101): msg = '' if num % 3 == 0: msg += 'Fizz' if num % 5 == 0: msg += 'Buzz' print (msg or n...
5d19e5be06bde6d6e4ae9badb4e38e3a9af7472e
EtoKazuki/python_calendar
/calendar.py
6,426
3.671875
4
# -*- coding: utf-8 -*- import datetime import sqlite3 # 今日の日付データを代入 today = datetime.date.today() # 空のリストを作成 day = [] month = [] year = [] # 今日の年、月、日、を代入 today_year = int(today.year) today_month = int(today.month) today_day = int(today.day) # DBに接続する conn = sqlite3.connect("zemi.db") cur = conn.cursor() # 5年分のリスト...
695b26becb587b0975df0b088e81f00c63340a0c
luckybooooy/test
/biji.py
6,793
3.9375
4
(代码换行,实际不换行) # total='appalPrice'\ # +'bananaPrice'\ # +'pearPrice' # print(total) # # appalPrice=1; bananaPrice=2; pearPrice=3 # a=(appalPrice+bananaPrice+pearPrice) # print(a) # # import keyword # print(keyword.iskeyword('admin')) # # print(keyword.kwlist) # # x = 4 # y = x # print(x,id(x)) # print(y,id(y...
a27f1eac3eb43cadc43e7227c019015ddcad55d8
MrHamdulay/csc3-capstone
/examples/data/Assignment_8/prkgyu001/question2.py
345
4.125
4
def counting(p): if len(p) == 1: return 0 elif len(p) == 2: if p[0] == p[1]: return 1 else: return 0 elif p[0] == p[1]: return 1 + counting(p[2:]) else: return counting(p[1:]) string = input("Enter a message:\n") print("Number of pairs: "...
9bf79b5c13b467d4086e084d51bb842f225be03a
TarasKravchuk/human_calc
/main.py
1,847
3.546875
4
import inflect p = inflect.engine() action_list = ["*", "+", "/", "-"] action_dict = {"+": "plus", "*": "multiplication", "/": "division", "-": "minus"} def calc (validator_result): arg1 = validator_result[0] action = validator_result[1] arg2 = validator_result[...
771ad6545112a09cdd4507ac1340479ddc721871
alisatsar/itstep
/Python/Lessons/string/str.split.py
259
3.671875
4
a = "Ivan Aleksandrovich Petrov" print(a.split()[-1]) #[-1] означает вывести последнее слово #Petrov print(a.split("a" [-1])) #[-1] означает максимальное количество разбиений #['Iv', 'n Aleks', 'ndrovich Petrov']
92195f98dbcaaba97329f6f622faaa6203dc6d22
visw2290/Scripts-Practice
/Scripts-Sublime/emailvalid.py
548
3.734375
4
class EmaVer: email_list=[] def ema(self,email): self.email = email if '@' in self.email: if self.email not in EmaVer.email_list: EmaVer.email_list.append(email) else: return 'Email ID already exists' else: return 'Enter a valid email address' em1 = EmaVer() print(em1.ema('visw@gmail.com')) pr...
9513f780d3a55860d0c78b71b667081e9cae859c
camwebby/ANN-Builder
/ANNClassFinal.py
5,169
4.0625
4
import numpy as np from matplotlib import pyplot as plt ###test data#### trainFeatures1 = np.array( [[0,0,1], [0,1,1], [1,0,1], [1,1,1], [0,0,0]] ) trainLabels1 =...
9ec405356ba0c2a4915dc884845653af0aa73f72
Prakharpatni/Functions
/To Find Numbers Divisible by Another Number.py
173
3.546875
4
value=25 list= [25,65,15,75,62,84,100,150,163] def check(num): for i in list: if(i%value==0): print(i) else: print("")
b6e46a4799656a48c31fcb0357f8a387f007a628
wenxinjie/leetcode
/backtracking/python/leetcode39_Combination_Sum.py
1,154
3.546875
4
# Given a set of candidate numbers (candidates) (without duplicates) and a target number (target), find all unique combinations in candidates where the candidate numbers sums to target. # The same repeated number may be chosen from candidates unlimited number of times. # Note: # All numbers (including target) will b...
9a7ec6941bc2d0467bd0e58a630afca31e39f779
imcmurray/digitalSignageDev
/add_new_slide.py
3,943
3.5
4
""" Shows basic usage of the Slides API. Prints the number of slides and elments in a presentation. """ from __future__ import print_function from apiclient.discovery import build from httplib2 import Http from oauth2client import file, client, tools # Setup the Slides API IMG_FILE = 'leaves-fallen-leaves-HD-Wallpaper...
e2d4b02cee90684f7980cbdbd4a1910ac92a772f
YYKyeko/Basic-Python-Codes-For-Beginners
/rockpaper31.py
1,020
4.125
4
print("*****rock*****") print("*****paper*****") print("*****scissors*****") from random import randint player = input("write your choice player: ").lower() rand_num = randint(0, 2) if rand_num == 0: computer = "rock" elif rand_num == 1: computer = "paper" else: computer = "scissors" print(f"Computer pla...
1b60ebc3f76147477c08162922b14686947d8d48
Inflearn-everyday/study
/dahyun/gcd and lcm.py
128
3.609375
4
from math import gcd a,b = map(int, input().split()) def lcm(a,b): return a*b // gcd(a,b) print(gcd(a,b)) print(lcm(a,b))
2734d34005255811f134cea5035f874775ba7c1f
krrish94/learn_tensorflow
/lstm_repetition_detection increased_freq.py
8,245
3.6875
4
# Tutorial from: https://jasdeep06.github.io/posts/Understanding-LSTM-in-Tensorflow-MNIST/ import numpy as np import tensorflow as tf from tensorflow.contrib import rnn # Seed RNG rng_seed = 12345 np.random.seed(rng_seed) tf.set_random_seed(rng_seed) # Declare constants # LSTM is unrolled through 10 time steps se...
810a047c69fa09415cc784b40f2de82009a7acc2
Simeontues/Test
/main_consult.py
186
3.515625
4
from calculate import calculate days = int(input("How many days did you worked: ")) salary = 0 bonus = 0 full = 0 salary = days*200 bonus = calculate(days) full = salary + bonus
926b1528a810324638c190fe92577528e5858d06
harshjohar/CS50_intro
/ProblemSet6/mario/less/mario.py
611
4.1875
4
while True: n = int(input("Height: ")) if n >= 1 and n <= 8: break for i in range(n): print(" " * (n- i - 1), end = "") print("#" * (i + 1)) #two things not working #Run your program as python mario.py and wait for a prompt for input. Type in foo and press enter. Your program should reject ...
d8c006020a59928e2e46d810798f2c5435764073
njdevengine/python-the-hardway
/nuts.py
275
3.515625
4
def nuts(): print "What are your favorite nuts?" print "Third favorite nut?" C = raw_input("> ") print "Second favorite nut?" B = raw_input ("> ") print "What is your ultimate nut?" A = raw_input("> ") print "So your favorite nuts are: %r, %r, %r" %(A, B, C) nuts()
2ba8908397d5453276717d624b481c7b7a0faed6
pdelro/IS211_Assignment6
/conversions_refactored.py
1,874
4.25
4
def convert(fromUnit, toUnit, value): """ Convert """ if fromUnit == toUnit: return value elif fromUnit == "C" and toUnit == "K": # do Celsius to Kelvin value = value + 273.15 return value elif fromUnit == "C" and toUnit == "F": # do Celsius to Fahrenheit...
1a964f608285f1822d8a94412338f22bb8a7a7d2
klamb95/flask_homework
/solution/tests/calculator_test.py
544
3.625
4
import unittest from modules.calculator import * class TestCalculator(unittest.TestCase): def test_add_3_and_2_returns_5(self): result = add(2,3) self.assertEqual(5, result) def test_subtract_2_from_3_returns_1(self): result = subtract(3,2) self.assertEqual(1, result) d...
075fe0d96f70ca6f24a7f03a9c7a2bac51cfb2bc
RomanAdriel/AlgoUnoDemo
/RomanD/ejercicios_rpl/estructuras_basicas/ej_5_triangulos.py
1,275
4.3125
4
"""Escribir un programa que solicite el ingreso del valor de los 3 lados de un triángulo. Luego, debe imprimir por pantalla si el triángulo es equilátero (3 lados iguales), escaleno (3 lados distintos) o isósceles (2 lados iguales). Ejemplos: Ingrese la longitud del primer lado del triangulo: 10 Ingrese la lo...
777eb1e60defc984e10cc82432df4331a516e029
Da1anna/Data-Structed-and-Algorithm_python
/基础知识/贪心算法/经典例题.py
4,989
3.71875
4
''' 1.[分数背包问题] 可以用贪心求最优解 有一个背包,背包容量是M=150。有7个物品,物品可以分割成任意大小。 要求尽可能让装入背包中的物品总价值最大,但不能超过总容量。 物品 A B C D E F G 重量 35 30 60 50 40 10 25 价值 10 40 30 50 35 40 30 ''' class goods(): def __init__(self,id,weight,value): self.id = id self.w = weight self.v = value def __str__(self): ...
2d19baa307d5e388879d800005b387dbe33bc3a1
chimnanishankar4/Logic-Building
/Day-7/3.py
534
4.5
4
''' 3.Define a class named Shape and its subclass Square. The Square class has an init function which takes a length as argument. Both classes have a area function which can print the area of the shape where Shape's area is 0 by default. ''' class Shape: def __init__(self): pass def area(self): ...
6c2819c58815c0f59d038678ba69b534e618b8b3
twood1/LeetCode
/Medium/MinSquares.py
1,263
3.609375
4
# Given a positive integer n, find the least number of perfect square numbers (for example, 1, 4, 9, 16, ...) # which sum to n. # Input: n = 12 # Output: 3 # Explanation: 12 = 4 + 4 + 4. import math class Solution(object): def numSquares(self, n): if n == 0: return 0 # edge case, exit...
79685422b90ada7beae46f96dc4fa550d05fed2f
longjiazhen/learn-python-the-hard-way
/ex3.py
605
4.125
4
#coding:utf-8 print "I will now count my chikens:" print "Hens",25+30/6 #30 print "Roosters",100-25*3%4 #100-75%4=100-3=97 print "Now I will count the eggs:" print 3+2+1-5+4%2-1/4+6 #1+0+0+6=7 print "Is it true that 3+2<5-7?" print 3+2<5-7 #False print "What is 3+2?",3+2 #5 print "What is 5-7?",5-7 #-2 print "Oh,th...
9f90a33051d8fefceb44e2b385131d37e33edf59
Oleksandr015/NIX_edu_solutions
/task_6/sixth_task.py
849
3.671875
4
'''Дан список из словарей: list_ = [ {'name': 'Alex', 'age': 25}, {'name': 'Oleg', 'age': 23}, {'name': 'Anna', 'age': 32}, {'name': 'Igor', 'age': 50}, {'name': 'Anton', 'age': 17}, ] Отфильтруйте его так, чтобы в нём остались только люди, имена которых начинаются с буквы "А", и возраст между 18 и ...
03dd980579e284402dd3e6ba61a743466d98a8f6
rajeshberwal/dsalib
/dsalib/Array/search.py
523
4.28125
4
def search(arr: list, elem: object) -> int or None: """Uses Linear Search for searching the given element. It will returns index for given element if element is present in the list. Args: arr (list): list of elements elem (object): element that we want to search Returns: int or...
08e9c46a6df3483f5aafae545761e8ea60af5443
Vasiliy1982/repo24122020
/praktika_urok5_2.py
254
4.03125
4
# практическое задание 2 число = int(input("Введите число:")) число_крат7 = число % 7 if число_крат7 > 0: print(число, "не кратно 7") print(число, "кратно 7")
3b54a3a3f215a76b2d159b88791d52519a50349d
dragonsarebest/Portfolio
/Code/3October2020.py
1,192
3.640625
4
class Solution: def isValid(self, s): openBraces = {'(' : 0, '[' : 0, '{' : 0} closedBraces = {')' : 0, ']' : 0, '}' : 0} stack = [] for i in range(0, len(s)): brace = s[i] if(brace in openBraces.keys()): openBraces[brace] += 1 ...
a535b027889670afb1febbbd036ed2c8ca44bf16
iamanx17/dslearn
/linkedlist/printati.py
234
3.625
4
from linkedlist import takeinput, printdata def printati(head,i): count=0 while count<i: head=head.next count+=1 return head.data head=takeinput() printdata(head) i=int(input()) print(printati(head, i))
ec5420107350ed227750c052240564cfe91c20fb
petitepirate/interviewQuestions
/q0109.py
835
4.125
4
# This problem was asked by Cisco. # Given an unsigned 8-bit integer, swap its even and odd bits. The 1st and 2nd bit should be swapped, # the 3rd and 4th bit should be swapped, and so on. # For example, 10101010 should be 01010101. 11100010 should be 11010001. # Bonus: Can you do this in one line? #_____...
9207750aa057675633d9c18fb7b1ea8ad5c3f007
CGodiksen/ritmo-discord
/ritmo.py
9,609
3.859375
4
"""A simple discord bot named Ritmo. Ritmo is a music bot that has expanded functionality through spotify integration. The discord bot is implemented using a class based design with the "discord.Client" superclass from the "discord" python package. """ import json import discord import os import youtube from song_que...
229e12c93432d1c66259be470b52ccc25d55aa13
RedPandaDev/Problemsolving-in-python
/week_7/tasks.py
1,708
3.65625
4
######### 1 ######### # def counting(i): # print(i) # i -= 1 # if i == 0: return # counting(i) def counting(i): print(i) i *=2 if i > 1024: return counting(i) ######## 3 ######### def printList(a): while len(a) > 0: print(a.pop(0)) #### Doesn't print twice as 'pop' removes the items from the list ###...
0d4199f051426d2ce7dce78d222e5e668a34146b
cahilld/stream2
/day2/hello.py
384
3.765625
4
def addition(x,y): return(x+y) print (addition("hello ","world")) def size(z): if z>10: return("BIG") else: return("small") print(size(12)) def aresame(a,b): return(a==b) print(aresame(5,5)) def shape(o,p): if o>p: return ("Bigger") if o<p: return ("Smaller") ...
742b833db84d32bbdab561391c60299c8c4abd8e
marioDonaire/GPS
/main.py
699
3.9375
4
#!/usr/bin/python3 from Problema import Problema from Solucionador import Solucionador def main(): switch = {0:"Anchura", 1:"Costo uniforme", 2:"Profundidad simple", 3:"Profundidad iterativa", 4:"Profundidad acotada",5:"Voraz",6:"A*"} json = input("Inserte el nombre del json: ") problema = Problema(str(f"j...
bc7495af31fcab4d4570f142256db81f85b562dc
tragicmj/python
/basics/guessNumber.py
178
3.90625
4
chances = 3 while chances != 0: chances -= 1 x = int(input("Guess Number: ")) if(x == 9): print("You Won!") break else: print("Sorry You Failed")
3a81b3e088b0c749eb40ec065ea7cf97409a46d4
HazelIP/pands-problem-sheet
/plottask.py
854
4
4
# The program displays a plot of the functions, # f(x)=x, g(x)=x2 and h(x)=x3 in the range [0, 4] on the one set of axes. # author: Ka Ling Ip import numpy as np import matplotlib.pyplot as plt f = np.array ([0,1,2,3,4]) #f(x) in range [0,4] g = f * f #g(x) = f squared h = f * f * f # h(x) = f cubed # create a plo...
4525a8c47f22e40b601035a67a71be9d569c46f3
naveenkommineni/Week3
/Flipcoin.py
373
3.546875
4
#Flip coin prob lst=['H','T'] import random heads=0 tails=0 for i in range(22): n=random.choice(lst) if n=='H': heads+=1 else: tails+=1 print('Number of heads:',heads) print('Number of tails:',tails) poh=(heads/i)*100 pot=(tails/i)*100 print('probability percentage of heads:',...
d902168c25d9690ebf8f71463c39c4b55f73b0a1
DivyanshMangla/Games
/Frosthack/Main.py
1,134
3.90625
4
while(True): print("Welcome to the Main Menu") print("Please type the code of the game that you want to play") print("Tic Tac Toe: code = 1") print("Guessing Game: code = 2") print("IPL Quiz: code = 3") print("To Exit the Game code = 4") n=int(input()) if(n==...
4910bee05a89799c324016e3a382f79622a3e7ab
RizkiAsmoro/python
/Arithmetic.py
1,163
3.84375
4
''' Basic Arithmetic base on input ''' val_a = float(input ('Input value for a =')) val_b = float(input ('Input value for b =')) val_c = float(input ('Input value for c =')) # addition add_result = val_a + val_b print (val_a,"+",val_b,"=",add_result) # subtraction subtract_result = val_a - val_b print (val_a,"-",val_...
04458ea403b678e03cf12496bfe87565549dd4f3
AnXnA05/python_practic
/0816_cal_area_n_perimeter.py
159
3.71875
4
r = float(input('请输入圆形对半径 = ')) pi = 3.1415926 area = pi*r*r perimeter = pi*r*2 print(f'圆形的周长是{perimeter:.2f},面积是{area:.2f}')
a478365a6230f550e731faebe1810a8246c57f87
broadinstitute/catch
/catch/utils/dynamic_load.py
1,298
3.921875
4
"""Functions for dynamically loading modules and functions. """ import importlib import os __author__ = 'Hayden Metsky <hayden@mit.edu>' def load_module_from_path(path): """Load Python module in the given path. Args: path: path to .py file Returns: Python module (before returning, this...
dce5e5778fe60d42eae643428e7691284ac93186
wileyzhao/Algorithms-Specialization
/course1_codes/selection_sort.py
565
3.703125
4
import random ''' selection sort:' n*n - n O(n*n) 12 41 4 7 99 45 34 6 31 8 90 54 4 41 12 7 ''' def main(): for i in range(20): x = random.randint(1,100) print(x, end=' ') print() arrStr = input('Please input a list of numbers:') arr = arrStr.split(' ') arr = list(map(int,arr)) arrR = selection_sort(arr) ...
05a4cb563cbd2989458b3e81d9729a4d4c827480
liazylee/python
/my_py_notes_万物皆对象/面向对象(万物皆对象)/深拷贝与浅拷贝/copy_deepcopy_可变对象.py
588
3.765625
4
# coding = utf-8 ''' @author = super_fazai @File : copy_deepcopy_可变对象.py @Time : 2017/8/3 20:32 @connect : superonesfazai@gmail.com ''' # 对可变对象的拷贝 from copy import copy,deepcopy a = [1,2,3] b = a c = copy(b) d = deepcopy(a) a.append(4) print(id(a) == id(b)) # ---> True print(id(a) == id(c)) # ---> False...
fa8fd86b85a8476cb05a1bd9b8936436ac43c3e3
q798010412/untitled2
/6.22/判断环链.py
472
3.953125
4
class Node: def __init__(self,data): self.data=data self.next=None def is_circle(head): pre=head cur=head while cur and cur.next: pre=pre.next cur=cur.next.next if pre==cur: return True return False if __name__ == '__main__': h=Node(0) a=N...
4efc011e4f332adc51537757db6f0775249422c2
mariaperezdeayalas/Shark-Attacks-Pandas-Project-
/SRC/cleaning_functions.py
1,524
3.6875
4
# First I create a dictionary indicating which moment of the day represent each hour # horarios = {'Night': ['00', '01', '02', '03', '04', '05', '20', '21', '22', '23'], 'Morning': ['06', '07', '08', '09', '10', '11'], 'Afternoon': ['12', '13', '14', '15', '16'], 'Evening': ['17', '18', '19']} # Then I create the fu...
c9d69e5a3da06416b4bc94dc274c2d8b53995ead
iota-cohort-dc/Daniel-Perez
/Python/Python_Fun/string&list.py
89
3.859375
4
str= "if monkeys like bananas, then i must be a monkey" print string&list.find("monkey")
7e51c52c6e5630dae99ebfc82526721c00f6248b
BlakeBeyond/python-onsite
/week_02/09_functions/03_dog.py
613
4.21875
4
''' Write a program with the following three functions: - bark - this function should not take in any arguments and should print the string "bark bark" - eat - takes in parameters food_item and amount and prints out "The dog ate <amount> of <food_item> - sleep - calls the python sleep method to sleep the p...
7ebe0d95378b5ced041aec74033f033a87e83946
JFluo2011/leetcode
/leetcode/strings/003_longest_substring_without_repeating_characters.py
1,474
3.515625
4
class Solution: def length_of_longest_substring(self, s): """ :type s: str :rtype: int """ # return self.o_2n(s) return self.o_n(s) def o_2n(self, s): # worst case: O(2n) i, j, length = 0, 0, 0 seen = set() while j < len(s): ...