blob_id
stringlengths
40
40
repo_name
stringlengths
5
127
path
stringlengths
2
523
length_bytes
int64
22
3.06M
score
float64
3.5
5.34
int_score
int64
4
5
text
stringlengths
22
3.06M
332331940cffd1abdfee2feaa32b87d60ab9bb7a
arentij/ft2db
/string_work/class_enh.py
218
3.53125
4
n = int(input()) a = {} for i in range(n): s = input().split(":") a[s[0]] = s[1].split() print(a) m = int(input()) for j in range(m): if j in a.keys(): print("Yes") else: print("No")
eb83ac26936667b0a56fba6a858e0d171063438a
arentij/ft2db
/string_work/safe_sum.py
212
3.90625
4
def sum(a, b): if type(a) == type(b) == int: if a > 0 and b > 0: return int(a) + int(b) else: raise ValueError else: raise TypeError print(sum(-1.1, 2.1))
2d48e3f944582a248b6622f04d8de3518e33b8b4
jramonsanchez/OSCrud
/CrudOS.py
3,836
3.984375
4
from tkinter import * import tkinter as tk import sqlite3 conn = sqlite3.connect('mibase.db') print("Connection successfully done.") # We create the form win = Tk() win.geometry("800x800") #We create tha menu menubar= Menu(win) def addEmploye(): addE = Tk() entry1 = tk.Entry(addE) entry2 = tk.Entry(addE...
c1c0a2a5dc1e226638dca0a9bf4601a4478be4ba
troybrowncoding/P0-Movie-Trailer
/media.py
456
3.6875
4
# movie class and contructor class Movie: """ These keep movie titles, posters, and trailers together.""" def __init__(self, title, poster_image_url, trailer_youtube_url): """Creates a movie with title, poster, and trailer info all as strings. Be sure to include complete URL's. ...
d9c79dfacb1d3321075798870219037453153de3
rianferrer/Python-Prelims
/prelims.py
2,063
3.890625
4
#FERRER, MARION CARYL R. #3ITD #ELEC2C PRELIMS LAB import sys def login(): attempts = 0 while True: userName = input("Username: ") password = input("Password: ") attempts += 1 #Successful Login if userName == 'IT ELE2C' and password == 'P83Lim_3xAm': pr...
dbc771f72561ebcac1619be969449e2c812854ca
pjohnst5/478
/plots/backprop3.py
530
3.65625
4
import matplotlib.pyplot as plt from matplotlib.pyplot import figure import numpy as np import pandas as pd learningRates = [0.005, 0.025, 0.05, 0.075, 0.085, 0.1, 0.125, 0.15, 0.175, 0.2] totalEpochs = [572, 145 ,63, 86, 68 ,85, 39, 43, 35, 31] df=pd.DataFrame({'x': learningRates, 'y1': totalEpochs}) plt.title("Ep...
7353ae10d5b9fa0c219ab3737d85f144c4f7a300
enkhbateddie/hackerRank
/Find string.py
401
3.671875
4
#ABCDCDC #CDC def count_substring(string, sub_string): b = [i for i in range(0, len(string)) if sub_string == string[i:i+len(sub_string)]] return len(b) count_substring("ABCDCDC", "CDC") ''' count = 0 for i in range(0, len(string)): if sub_string == string[i:i+len(sub_str...
11f7f93b4690191cd336a3884aa99ca24b5cdd8d
phoebeweimh/xiao-g
/归并排序.py
1,225
4.4375
4
#!/usr/bin/env python # !coding:utf-8 # 归并排序(英语:Merge sort,或mergesort),是创建在归并操作上的一种有效的排序算法。该算法是采用分治法(Divide and Conquer)的一个非常典型的应用。 #分治法: # 分割:递归地把当前序列平均分割成两半。 # 集成:在保持元素顺序的同时将上一步得到的子序列集成到一起(归并)。 import random def SortByMerge(arr,size): if size <= 1: return arr i = int(size/2) left = SortB...
b1b4e9ef6ba7fea39eb3366aea0bcffcf8d36f9a
phoebeweimh/xiao-g
/斐波那契数列.py
640
4
4
#!/usr/bin/env python # !coding:utf-8 # 斐波那契数列指:第0项是0,第1项是第一个1。从第三项开始,每一项都等于前两项之和。 import random num = random.randint(0, 20) print('斐波拉契数列位数为:', num) def fab(num): a, b = 0, 1 fablist = [] if num <= 0: print('生成的数不对') elif num == 1: fablist.append(a) return fablist else: ...
bd623037f30fd9cafc62281b393d2983714eed3a
meet1504/Advance-College-Management_System
/College_Std_info_BackEnd.py
2,604
3.671875
4
import sqlite3 def connect(): conn = sqlite3.connect("College_student.db") cur = conn.cursor() cur.execute("CREATE TABLE IF NOT EXISTS student (id INTEGER PRIMARY KEY, name text, father_name text, mother_name text, \ address text, mobileno integer,email_address text, d...
d22a954c0a50eb89bd5c24f37cf69a53462e1d0c
dinabseiso/HW01
/HW01_ex02_03.py
1,588
4.1875
4
# HW01_ex02_03 # NOTE: You do not run this script. # # # Practice using the Python interpreter as a calculator: # 1. The volume of a sphere with radius r is 4/3 pi r^3. # What is the volume of a sphere with radius 5? (Hint: 392.7 is wrong!) # volume: 523.3 r = 5 pi = 3.14 volume = (4 * pi * r**3) / 3 print(volume) ...
ab510abcf925e780b8ec8b0867419f3a59ebeb16
Padma-Dhar/Python_assignments
/black_jack/black_jack.py
3,343
3.671875
4
# from art import logo # import random # class blackjack_player: # def __init__(self): # self.blackjack_cards_drawn = [] # self.end_game_parameter=0 # self.lost=0 # self.sum_of_card_value=0 # self.card_value={"J":10,"Q":10,"K":10,"A":11} # for i in range(1,11): # ...
0fae3d7773010b94f87746497e6d49f0fcf9c628
vicamu/countries
/opp/gba.py
1,034
3.6875
4
from pokemons import * import random print("POKEMON".center(50, "-")) print("Oak: Select your first pokemon...") [print(f"{i+1}. {pokemon.name}") for i, pokemon in enumerate(pokemons)] user = int(input("Choose: ")) - 1 pokemon_a = pokemons[user] pokemons.remove(pokemon_a) pokemon_d = random.choice(pokemons) print(f"Yo...
e0e5192c482da843c87386924d7fd19e55036b24
GothAck/Civicboom-hActivate
/hActivate/hactivate/lib/misc.py
950
3.515625
4
import math R = 6371 def distance(lon1,lat1,lon2,lat2): lat1 = math.radians(lat1) lon1 = math.radians(lon1) lat2 = math.radians(lat2) lon2 = math.radians(lon2) dlat = lat2 - lat1 dlon = lon2 - lon1 a = math.sin(dlat/2) * math.sin(dlat/2) +\ math.cos(lat1) * math.co...
3f16e1d17f3ad9e41dd2032e9be9fa54f26c5002
0x326/academic-code-portfolio
/2016-2021 Miami University/CSE 283 Computer Networking/Project 1 - Socket-based HTTP Server/http_server.py
3,704
3.625
4
# Name: John Meyer # Date: 2017/10/16 # Assignment: Project 1 """ A simple socket-based HTTP server. """ import argparse import logging import re import socket import webbrowser from pathlib import Path if __name__ == '__main__': logging.basicConfig(level=logging.DEBUG) logger = logging.getLogger('server') ...
6a6448402f96f1c2be967b44f90312abfb08d18f
jimsaw/DS2017-G3
/restaurant.py
946
4
4
class Restaurant: __nombre = "" __pago = "" __staff = {"asistentes":[], "administradores":[]} def __init__(self, nombre, pago): self.__nombre = nombre self.__pago = pago def __str__(self): return "Nombre: " + self.__nombre + "\n" + "Tipo de pago: " + str(self.__pago) ...
a8e490253018054776b6992b4bab1d5d6696bc4f
MakeMeSenpai/data_structures
/bases/bases.py
3,990
4.0625
4
import string # Hint: Use these string constants to encode/decode hexadecimal digits and more # string.digits is '0123456789' # string.hexdigits is '0123456789abcdefABCDEF' # string.ascii_lowercase is 'abcdefghijklmnopqrstuvwxyz' # string.ascii_uppercase is 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' # string.ascii_letters is ascii_l...
337f4e1d5ae2aaf4768b0b5a2e12093881cf1232
fortiema/udemy_lazyprog
/adv_nlp/bilstm_mnist.py
1,701
3.765625
4
""" bilstm_mnist Example application of RNN networks to image classification problems. """ import os import keras.backend as K from keras.layers import Bidirectional, Concatenate, Dense, GlobalMaxPooling1D, Input, Lambda, LSTM from keras.models import Model import numpy as np import pandas as pd import matplotlib.py...
4e08538ac7e84443288690b8389a8764fc3bf3e3
jlsicajan/code_examples
/daily_coding/binary_tree.py
1,137
3.84375
4
from collections import deque class Node: def __init__(self, val, left=None, right=None): self.val = val self.left = left self.right = right node = Node('root', Node('left', Node('left.left', Node('right'))), Node('right', Node('right.left'), Node('right.right'))) def printTree(root): ...
51f524faf8a4093bb3ff5b2c8e954b63b57b3e82
spsree4u/MySolvings
/arrays/next_number.py
427
3.59375
4
def add_one(arr): size = len(arr) result = [0] * size carry = 1 for i in range(size-1, -1, -1): value = arr[i] + carry if value == 10: result[i] = 0 carry = 1 else: result[i] = value carry = 0 if carry: result = [0] * ...
90c2bc439a5ac5acbb48ef5450aa2e7bc6748d8a
spsree4u/MySolvings
/arrays/lucky_floor.py
1,308
3.921875
4
""" For a given number of floors, find the top floor number (lucky floor) in a building in such a way that there shouldn't be floor number contains 4 or 13 (ex: [1,2,3,5,..,10,11,12,15,16,...23,25,...39,50,..,103,..112,115,..]) ex: 14 floor building Normal floors will be : [1,2,3,4,5,6,7,8,9,10,11,12,13,14], top_floor ...
f1cff7d66240d8077fa2878aadb8ce46cedcb314
spsree4u/MySolvings
/maths/two_eggs.py
1,092
4
4
""" You are given two eggs, and access to a 100-storey building. Both eggs are identical. The aim is to find out the highest floor from which an egg will not break when dropped out of a window from that floor. If an egg is dropped and does not break, it is undamaged and can be dropped again. However, once an egg is b...
b3c9b758ea0b683aa4762a1e8e30bfffb2074a00
spsree4u/MySolvings
/trees_and_graphs/mirror_binary_tree.py
877
4.21875
4
""" Find mirror tree of a binary tree """ class Node: def __init__(self, data): self.data = data self.left = self.right = None def mirror(root): if not root: return mirror(root.left) mirror(root.right) temp = root.left root.left = root.right root.right = temp ...
34880aab243a184a4c4b7e0356b8dc4a969daca2
spsree4u/MySolvings
/numerical/common_algos.py
864
3.71875
4
import math def binary(num): bin_result = [] while num > 0: bin_result.append(num % 2) num //= 2 bin_result.reverse() return bin_result # print(binary(742)) def is_prime(n): for i in range(2, n): for j in range(1, int(math.sqrt(n)) + 1): if i * j == n: ...
f29923bcb48d0f6fd0ea61207249f57ca0a69c6a
spsree4u/MySolvings
/trees_and_graphs/post_order_from_pre_and_in.py
1,526
4.21875
4
# To get post order traversal of a binary tree from given # pre and in-order traversals # Recursive function which traverse through pre-order values based # on the in-order index values for root, left and right sub-trees # Explanation in https://www.youtube.com/watch?v=wGmJatvjANY&t=301s def print_post_order(start, ...
965e5afce19c0ab3dcaf484bdafa554dd4d51e4d
spsree4u/MySolvings
/trees_and_graphs/super_balanced_binary_tree.py
2,240
4.125
4
""" Write a function to see if a binary tree is "super-balanced". A tree is "super-balanced" if the difference between the depths of any two leaf nodes is no greater than one. Complexity O(n) time and O(n) space. """ class Node: def __init__(self, data): self.data = data self.left = None ...
a6848a7fe69287d440cf077f5bbe09ed0007f9c7
spsree4u/MySolvings
/dynamic_programming/reg_ex_matching.py
2,614
3.9375
4
""" Given an input string s and a pattern p, implement regular expression matching with support for '.' and '*' where: '.' Matches any single character.​​​​ '*' Matches zero or more of the preceding element. The matching should cover the entire input string (not partial). isMatch("aa","a") → 0 isMatch("aa","aa") → 1 ...
41585952c5d56267b51f423a944753fb0dd0a29f
spsree4u/MySolvings
/trees_and_graphs/graph_learn.py
3,336
4.46875
4
# Basic representations of a Graph """ Uses: Graphs are used to represent networks. The networks may include paths in a city or telephone network or circuit network. Graphs are also used in social networks like linkedIn, Facebook. For example, in Facebook, each person is represented with a vertex(or node). Each node i...
3e92fa31734cdd480a102553fda5134de7aed2ba
aryansamuel/Python_programs
/jumble.py
819
4.375
4
# Aryan Samuel # arsamuel@ucsc.edu # prgramming assignment 6 # The following program asks the user for a jumbled word, # then unjumbles and prints it. # Note: The unjumbled word should be in the dictionary that is read by the prog. def main(file): file = open(file,'r') word_list = file.read().split() ...
973894beeb1f3fad7d76418c883124079f859754
HenryDLC/health_food
/post_info.py
3,111
3.78125
4
class info(): def __init__(self): self.A = "A 休息,坐卧为主 比如:不能自理的老年人或残疾人等\n" self.B = "B 静态生活/工作方式 比如:办公室职员或坐着工作的职业从业\n" self.C = "C 坐姿生活方式为主,偶尔活动 比如:学生/司机/装配工人等\n" self.D = "D 站/走为主的生活方式 比如:家庭主妇/销售人员/服务员/接待员\n" self.E = "E 重体力生活或工作方式 比如:建筑工人/农民/旷工/运动员或运动爱好者\n" def index(se...
65724008628712d0e089ab53b96229f29de56a06
Hanthebot/EulerProject
/P10-19/P12.py
1,020
3.65625
4
import time import math #revised on 2022/07/24 22:53 def fo2(a): return "{0:.2f}".format(a) def inTime(t): return f"{int(t / 3600)}:{int(t % 3600 / 60)}:{fo2(t % 60)}s" def evenDivide(n): if n % 2: return int(n / 2) else: return int((n - 1) / 2) def getFactors(n): fac = [num for...
79e95ae4f5a9da5ff22c93758e3f4f489259f027
windrunner0/studypython
/code/chapter01/test06.py
547
3.953125
4
#!usr/bin/python3 def printinfo(name, age = 35): print("名字:" , name) print("年龄:", age) return; printinfo("郑鹏", 26); print() printinfo(name="二狗"); print() printinfo(age=900,name="涛涛"); def info(arg1, *vartuple): print("输出:") print(arg1); for var in vartuple: print(var); return; i...
61635c6fda67caed27e9f03b01ba0f13b8995b56
windrunner0/studypython
/code/chapter01/test03.py
3,648
4.3125
4
#!/usr/bin/python3 tuple = ( 'abcd', 786 , 2.23, 'demo', 70.2 ) tinytuple = (123, 'demo') print (tuple) # 输出完整元组 print (tuple[0]) # 输出元组的第一个元素 print (tuple[1:3]) # 输出从第二个元素开始到第三个元素 print (tuple[2:]) # 输出从第三个元素开始的所有元素 print (tinytuple * 2) # 输出两次元组 print (tuple + tinytuple)...
1043ddfe80a37fe711878996665e4ed0c7a51df5
sergei-doroshenko/filerename-git
/filerename/tests/test_dict.py
669
3.796875
4
def test_1(): # Define a dictionary code websters_dict = {'person': 'a human being', 'marathon': 'a running race that is about 26 miles', 'resist': 'to remain strong against the force', 'run': 'to move with haste; act quickly'} print(websters_dict...
36590e123904f3973f7b382b4ad5a9f5d489265e
Laikiru/RPS-Game
/Rock Paper Scissors.py
3,221
4.40625
4
# Rock Paper Scissors Game // 07/19/2021 - 10/07/2021 # by Laika!! # Input options Rock, Paper, Scissors # Bot chooses from random selection- Rock Paper Scissors # Compare; win or lose ############################### def end_game(): # Function to end game if the player wants to. print("Would you like to ...
4f9176215fab73e0c560c04efd23a53974226349
johnbickmore/cairo_utils
/cairo_utils/dcel/Line.py
5,590
3.921875
4
""" Line: Representation of a 2d line """ from math import sqrt from numbers import Number import logging as root_logger import numpy as np from ..math import intersect, get_distance import IPython logging = root_logger.getLogger(__name__) CENTRE = np.array([[0.5, 0.5]]) class Line: """ A line as a start positio...
78be8ddb17792267e2324a240af3180706bd3033
johnbickmore/cairo_utils
/cairo_utils/dcel/voronoi/Events.py
2,609
3.515625
4
""" Events: The data representations of points and circles in the voronoi calculation """ import IPython import numpy as np from enum import Enum CIRCLE_EVENTS = Enum("Circle Event Sides", "LEFT RIGHT") class VEvent: offset = 0 """ The Base Class of Events """ def __init__(self,site_location,i=-...
126dfda6ffab1ea5cc154a8ee0ff91815877fd4a
douglasinkote/modelagemFenomenosFisicos
/Revisao_Prova_S1/q9.py
388
3.828125
4
def minimo(v): # criterio de parada # existir apenas 1 valor na lista if (len(v) == 1): return v[0] # calcular o menor restante da lista min_rest = minimo(v[1:]) # verificando se a cabeca eh o menor valor if (v[0] < min_rest): return v[0] # o menor valor veio do restante ...
021b86289b6a9c1f7d3fda9ec2a5cbb988908846
mmubash3/Projects
/Projects/Python/Volume Calculator/main.py
5,052
4.25
4
#must import the functions in order to use them in the code from volume import cubevol from volume import pyramidvol from volume import ellipsoidvol from summarize1 import summarize print("Volume Calculator") test_case_number= int(input('Please enter the number of tests: ')) for i in range(1, test_case_num...
4a9c4d6de4ee29280100bd18bc2c8f6d6a5d528f
AugmentedMode/STOP-Touching-Your-Face-Website
/functions.py
1,072
3.890625
4
import os import sqlite3 def get_database_connection(): ''' Creates a connection between selected database ''' sqlite_file = 'site.db' file_exists = os.path.isfile(sqlite_file) conn = sqlite3.connect(sqlite_file) if not file_exists: create_sqlite_tables(conn) if os.stat(sq...
dc958ad3b6e1066123ab4e926dfe329a7952ce14
HighWarlordRage/Add_Surname
/add_surname.py
237
3.796875
4
#Title: Project-6b def add_surname(first_name): last_name = [name+' Kardashian' for name in first_name if name[0]=='K'] return last_name first_name = ["Kiki", "Krystal", "Pavel", "Annie", "Koala"] #print(add_surname(first_name))
b240ca85a1127a3442e331e4dea3a75311ac3e36
ephantuskaranja/password_locker
/control.py
4,725
3.8125
4
import secrets import string import getpass import pyperclip class Userdata: ''' Class that generates new instances of userdata class ''' def create_user(self): ''' function that creates new users ''' print("Please enter Username and password to register\nusername:") ...
8be0ea55ef2b9b7665668126cccdb48feb6829f7
rosedu/robocheck
/utils/download.py
1,202
3.90625
4
import urllib2 import os import sys """ Downloads the file from the url into the specified folder, renaming it 'fileNae """ def downloadFile(folderPath, fileName, url): try: u = urllib2.urlopen(url) f = open(os.path.join(folderPath, fileName), 'wb') meta = u.info() fileSize = int...
406733242122511a89c977f794127742e495f54b
Shobhits7/Programming-Basics
/DSA/DSA-python/Maths/PerfectSquare.py
583
3.953125
4
# Check if a number is perfect square using binary search. def perfect_square(n: int) -> bool: try: left = 0 right = n while left <= right: mid = (left + right) // 2 if mid ** 2 == n: return True elif mid ** 2 > n: right = ...
551b45106596ac37c8664302ab313a7832302c09
Shobhits7/Programming-Basics
/Python/commonElementsInaList.py
284
4.03125
4
#read two lists a and b ,write a function that returns a list that contains only the elements that are common to both the lists. a=[] b=[] newlist=[] for i in a: if i in b: if i in newlist: continue newlist.append(i) print(newlist)
203e35f62d3a64a25c87b1f88f8ba9b7ad33c112
Shobhits7/Programming-Basics
/Python/factorial.py
411
4.34375
4
print("Note that facotrial are of only +ve integers including zero\n") #function of facorial def factorial_of(number): mul=1 for i in range(1,num+1): mul=mul*i return mul #take input of the number num=int(input("Enter the number you want the fatcorial of:")) #executing the function if num<0 ...
e98f42af716c60f62e9929ed5fa9660b3a1d678a
Shobhits7/Programming-Basics
/Python/palindrome.py
364
4.46875
4
# First we take an input which is assigned to the variable "text" # Then we use the python string slice method to reverse the string # When both the strings are compared and an appropriate output is made text=input("Enter the string to be checked: ") palindrom_text= text[::-1] if text==palindrom_text: print("Pal...
90312277b3c47497dd06cb81d2b82c82494becc0
Shobhits7/Programming-Basics
/Python/Utility/Phone Number Details/PhoneNumberDetailsUsingPython.py
381
3.578125
4
import phonenumbers as ph from phonenumbers import carrier from phonenumbers import geocoder from phonenumbers import timezone number = input("Enter Phone Number: ") number = ph.parse(number) print("Time Zone: ",timezone.time_zones_for_number(number)) print("Carrier Name: ",carrier.name_for_number(number, "en")) prin...
369a2dd3d06e212bd40d376b1c5e9a0a3eef3536
Shobhits7/Programming-Basics
/Python/Projects/Steganography Project/decrypt_steganography.py
576
3.734375
4
# Import necessary libraries from PIL import Image import stepic # Open the image from which the secret message is to be extracted: # image = Image.open("C:\\Users\\Nitin Kumar\\OneDrive\\Documents\\encrypted.png") img = input("Enter your picture with which you want to decrypt your message:\n") image = Image.open...
db38de29fb9325cc6e909397601f59f64dd1936c
Shobhits7/Programming-Basics
/Python/Pattern Programs/Arrow_Pattern.py
815
4.09375
4
# Print the following pattern for the given number of rows. Assume N is always odd. # Pattern for N = 7 # Note : There is space after every star. # * # * * # * * * # * * * * # * * * # * * # * # Input format : # Integer N (Total no. of rows) # Output format : # Pattern in N lines n = int(input()) i = 1 m =...
1b2ec70312c8bf5d022cf2832fb3dfbf93c0d0f2
Shobhits7/Programming-Basics
/Python/fibonacci_series.py
1,110
4.40625
4
# given a variable n (user input), the program # prints fibinacci series upto n-numbers def fibonacci(n): """A simple function to print fibonacci sequence of n-numbers""" # check if n is correct # we can only allow n >=1 and n as an integer number try: n = int(n) except ValueError: ...
2e6e4d14e2d3f6fdf064b906a4a15c6690c2a556
hansolpp/final_exam
/finalexam02.py
750
4.0625
4
import math class Point: def __init__(self, x = 0, y = 0): self.__x_location = x self.__y_location = y def get_x_location(self,): return self.__x_location def get_y_location(self,): return self.__y_location def point_to_point_distance(self, point_2): x = (se...
205aa8dc602736f7c9ca50c099c2cb1361e41249
cognivore/icfpc2004-tbd
/data/py/bouncing.py
657
3.734375
4
def turn_around(): turn_left() turn_left() turn_left() def random_turn(): if flip(2): if flip(2): turn_left() else: turn_right() else: if flip(2): turn_left() turn_left() else: turn_right() turn...
29fcc83bd78491dcc0c723375064469faf93acc9
Abhishek264/DSpgms
/temperature.py
130
3.78125
4
f=float(input()) c=((f-32)*(5/9)) print('the temperature is converted fahrenheit',f,"to celsius",c) #l=[1,2,'hello',5,'hi','c']
9ed3b79f77421bb2747a2398de114373a88c3654
AlexShadrin/Python_dz_2
/task_2_3.py
658
3.515625
4
my_list = ['в', '5', 'часов', '17', 'минут', 'температура', 'воздуха', 'была', '+5', 'градусов'] idx = 0 while idx < len(my_list): if my_list[idx].isdigit(): my_list.insert(idx, '"') my_list[idx + 1] = f'{int(my_list[idx + 1]):02}' my_list.insert(idx + 2, '"') idx += 2 el...
757bac55b3c7ccf29ac7220c91745196ccb48a0a
Jeromecloud/python3
/oop.py
1,200
3.828125
4
class Cat: """这是一个猫类""" def __init__(self,new_name): print("Jerry is coming") #self.attribute = 属性的初始值 self.name = new_name def eat(self): print("%s Eat Fish" % self.name) def __del__(self): print("Jerry is over") def __str__(self): return "Litt...
33badff2fce81aba67c872bc07b2e8e8644df597
AnthonyDiTomo/hw-2
/problem2.py
851
3.875
4
angry = 1 bored = 1 hungry = 1 tired = 0 #If T-Rex is angry, hungry, and bored he will eat the Triceratops. if angry and bored and hungry: print("T-Rex will eat Triceratops") #Otherwise if T-Rex is tired and hungry, he will eat the Iguanadon. elif tired and hungry: print("T-Rex will eat Iguanadon") #O...
33daada7246de7d731138c2b607d08b56dbc41da
alexskates/recurrent_model_metrics
/similarity.py
2,056
3.53125
4
import numpy as np def dice_binary(seq1, seq2, invalid_value=1.): """ The Sorenson-Dice coefficient is a statistic used for comparing the similarity of two samples. This function takes two binary (one-hot) sequences. Invalid_value is used where both sequences are all zero. Defaults to 1.0 as if th...
62d48e83bb8a3fd738856c05b9718ee5ea03b34a
PiKaChu-R/code-learn
/program/SwordOffer/KthNode.py
1,541
3.515625
4
#!/usr/bin/env python # -*- coding: utf-8 -*- ''' @File : KthNode.py @Time : 2019/09/16 16:24:13 @Author : R. @Version : 1.0 @Contact : 827710637@qq.com @Desc : None ''' ''' 给定一颗二叉搜索树,请找出其中的第k大的结点。例如, 5 / \ 3 7 /\ /\ 2 4 6 8 中...
7b39d72d15c98bafbc198d42367364c3f9202190
PiKaChu-R/code-learn
/program/Fluent-Python/ArithmeticProgression.py
599
3.796875
4
#!/usr/bin/env python # -*- coding: utf-8 -*- # 等差数列生成器 # 第一版 class ArithmeticProgression1: def __init__(self, begin, step, end=None): self.begin = begin self.step = step self.end = end # None ->无穷数列 def __iter__(self): # 先做加法,根据结果强制类型转换begin result = type(self.begin +...
5f3c47796c3626db42b1bc1573a7586785547f6d
PiKaChu-R/code-learn
/program/SwordOffer/rectCover.py
557
3.703125
4
#!/usr/bin/env python # -*- coding: utf-8 -*- ''' @File : rectCover.py @Time : 2019/09/09 10:12:21 @Author : R. @Version : 1.0 @Contact : 827710637@qq.com @Desc : None ''' ''' 我们可以用2*1的小矩形横着或者竖着去覆盖更大的矩形。 请问用n个2*1的小矩形无重叠地覆盖一个2*n的大矩形,总共有多少种方法? ''' # here put the i...
62f349212dd1aa95b8ca0a62faa09169e5e36ec3
PiKaChu-R/code-learn
/program/Fluent-Python/FrenchDeck.py
932
3.671875
4
Python 3.6.6 (v3.6.6:4cf1f54eb7, Jun 27 2018, 03:37:03) [MSC v.1900 64 bit (AMD64)] on win32 Type "copyright", "credits" or "license()" for more information. >>> import collections >>> Card = collections.namedtuple('Card',['rank','suit']) >>> class FrenchDeck: ranks = [str(n) for n in range(2,11)] +list('JQK') suits ...
805c7d5252dac29490a176a026676463215f3902
PiKaChu-R/code-learn
/program/SwordOffer/GetMedian.py
4,285
3.578125
4
#!/usr/bin/env python # -*- coding: utf-8 -*- ''' @File : GetMedian.py @Time : 2019/09/16 16:34:19 @Author : R. @Version : 1.0 @Contact : 827710637@qq.com @Desc : None ''' ''' 如何得到一个数据流中的中位数?如果从数据流中读出奇数个数值,那么中位数就是所有数值排序之后位于中间的数值。 如果从数据流中读出偶数个数值,那么中位数就是所有数值排序之后中间两个...
beb07d6c5b4fa3be44b84ed1338b339c42255b38
PiKaChu-R/code-learn
/program/SwordOffer/LeftRotateString.py
1,536
4.03125
4
#!/usr/bin/env python # -*- coding: utf-8 -*- ''' @File : LeftRotateString.py @Time : 2019/09/09 16:59:08 @Author : R. @Version : 1.0 @Contact : 827710637@qq.com @Desc : None ''' ''' 汇编语言中有一种移位指令叫做循环左移(ROL),现在有个简单的任务, 就是用字符串模拟这个指令的运算结果。 对于一个给定的字符序列S,请你把其循环左移K位...
a752118a32d20db370d49fd67dae1b66ba36fc25
PiKaChu-R/code-learn
/program/SwordOffer/isNumeric.py
1,611
3.71875
4
#!/usr/bin/env python # -*- coding: utf-8 -*- ''' @File : isNumeric.py @Time : 2019/09/15 15:54:47 @Author : R. @Version : 1.0 @Contact : 827710637@qq.com @Desc : None ''' ''' 请实现一个函数用来判断字符串是否表示数值(包括整数和小数)。 例如,字符串"+100","5e2","-123","3.1416"和"-1E-16"都表示数值。 但是"...
fec1246e9e886ae142c9c6df5d16a2b2612a9104
PiKaChu-R/code-learn
/program/SwordOffer/IsContinuous.py
891
3.53125
4
#!/usr/bin/env python # -*- coding: utf-8 -*- ''' @File : IsContinuous.py @Time : 2019/09/09 17:12:10 @Author : R. @Version : 1.0 @Contact : 827710637@qq.com @Desc : None ''' ''' ''' # here put the import lib def IsContinuous(nums): if not nums: return False...
b39574300d08c24051ee8ba679de22f15b52eb3e
PiKaChu-R/code-learn
/program/SwordOffer/NumberOf1Between1AndN_Solution.py
895
3.71875
4
#!/usr/bin/env python # -*- coding: utf-8 -*- ''' @File : NumberOf1Between1AndN_Solution.py @Time : 2019/09/09 15:31:17 @Author : R. @Version : 1.0 @Contact : 827710637@qq.com @Desc : None ''' ''' 求出1~13的整数中1出现的次数,并算出100~1300的整数中1出现的次数? 1~13中包含1的数字有1、10、11、12、13因此...
45d3167fc5fbdd151f276973d5fa7ca9b2b3459f
rodionova-lyubov/project_euler
/009.py
626
3.984375
4
'''Особая тройка Пифагора Тройка Пифагора - три натуральных числа a < b < c, для которых выполняется равенство a**2 + b**2 = c**2 Например, 3**2 + 4**2 = 9 + 16 = 25 = 5**2. Существует только одна тройка Пифагора, для которой a + b + c = 1000. Найдите произведение abc.''' for a in range(1, 1000): for b in range...
714d3a2aaba9c204a70a26a3ec2fe99df88d57dd
ProfeSantiago/Python
/6) Archivos/CSVPandas/PandasCVS.py
810
3.5625
4
#------------------------------------------------------- # Para este ejercicio hay que correr estos comandos desde el Terminal o Consola: # # pip install --upgrade pip # pip install pandas #------------------------------------------------------- import pandas def leeCSVPandas(archivoCSV): datosLeidos = p...
b935748d365ac7336a3334c3a50f902e44d14a59
PracaJacaa/Farmers-Invaiders
/phygame.py
4,483
3.5
4
#import of Modules import pygame import random import math #initialize all imported pygame modules pygame.init() #Display screen = pygame.display.set_mode((800, 600)) #CAPTION pygame.display.set_caption("Sprzedaj Futro") #ICON icon = pygame.image.load('leather.png') pygame.display.set_icon(icon) ...
b349a41b204f19829fb2dff369d8638829a281ae
Robin-P/zappy
/Modules/AI/Python/inventory.py
1,614
3.765625
4
# coding: utf-8 """ Inventory class """ class Inventory: """ Inventory class Returns: Inventory """ def __init__(self): self.bag = { 'linemate': 0, 'deraumere': 0, 'sibur': 0, 'mendiane':0, 'phiras': 0, 'thyst...
5450f0a1c479521d15bd8b91171bb72686cb14b6
marcelcosme/URI
/PYTHON/2670(accepted).py
332
3.59375
4
primeiro = int(input()) segundo = int(input()) terceiro = int(input()) minutos = [] #se o primeiro andar total_1= segundo*2+terceiro*4 minutos.append(total_1) #se o segundo andar total_2 = primeiro*2+terceiro*2 minutos.append(total_2) #se o terceiro andar total_3 = primeiro*4+segundo*2 minutos.append(total_3) print(m...
64dcb4c686bc489d9f4c157416f5dcc7b85581ab
marcelcosme/URI
/PYTHON/1192(accepted).py
234
3.640625
4
for i in range(int(input())): x = str(input()) l = x[1].upper() if x[0] == x[2]: print(int(x[0]) * int(x[2])) elif x[1] == l: print(int(x[2]) - int(x[0])) else: print(int(x[0]) + int(x[2]))
920e99be554e231d3b064828c3c35970c261211c
marcelcosme/URI
/PYTHON/2463(KADANE)(accepted).py
551
3.515625
4
def kadane(lista, tamanho): max_real = 0 soma = 0 max_ate_agora = 0 for i in range(tamanho): soma += lista[i] if soma > max_ate_agora: max_ate_agora = soma if soma < 0: if max_ate_agora > max_real: max_real = max_ate_agora soma ...
6099f56f132e1ac2008aa8cc2004ae12059793e8
marcelcosme/URI
/PYTHON/1520(error).py
767
3.703125
4
while True: try: quantidade = int(input()) lista = [] for j in range(quantidade): x, y = map(int, input().split()) for i in range(x, y + 1): lista.append(i) lista.sort() quero = int(input()) contador = 0 if quero in list...
856389859c831b97b9aefce51097f00f0aa8f865
marcelcosme/URI
/PYTHON/1515(wrong).py
622
3.53125
4
cases = int(input()) while cases != 0: name = [] year = [] day = [] auxiliar = [] for i in range(cases): x = input().split() name.append(x[0]) year.append(int(x[1])) day.append(int(x[2])) x = year.count(min(year)) if x > 1: for k in range(x): ...
e7b5580acb9b32851fb81667be36ea32af43613b
marcelcosme/URI
/PYTHON/2492(accepted).py
497
3.84375
4
def invertivel(numero): entrada = [] saida = [] for i in range(numero): n_entrada, separador, n_saida = str(input()).partition(' -> ') entrada.append(n_entrada) saida.append(n_saida) if len(set(entrada)) != len(entrada): print('Not a function.') elif len(set(saida)) !...
431c7b591bc3e6d33140d71f3832cfde1115079a
marcelcosme/URI
/PYTHON/2682(accepted).py
237
3.84375
4
numero = 0 erro = False while True: try: x = int(input()) if x > numero and erro == False: numero = x elif x < numero: erro = True except EOFError: break print(numero + 1)
cef6660c4b676f544e2e54e9213f183e63766aea
marcelcosme/URI
/PYTHON/1078(accepted).py
94
3.515625
4
x= int(input()) for i in range(1,11): prod = i*x print('%i x %i = %i' %(i, x, prod))
68b93254a9e64f986f6c2c2594ac5c6715bfd496
marcelcosme/URI
/PYTHON/1180(accepted).py
586
3.71875
4
'''tamanho = int(input()) vetor = list(map(int, input().split())) menor = min(vetor) print('Menor valor:', menor ) index = vetor.index(menor) print('Posicao:', index)''' # usando artifícios de python # caso nao tivessemos o artificio de min tamanho = int(input()) vetor = list(map(int, input().split())) def menor...
acb868ba6041bfa257761f7f255378d492fec09e
marcelcosme/URI
/PYTHON/2375(accepted).py
257
3.625
4
diametro = int(input()) dados = list(map(int,input().split())) def cabe(diamentro,dados): for i in dados: if i<diamentro: return False return True boleana = cabe(diametro,dados) if boleana: print('S') else: print('N')
a0a2b764406603ae3af20f9b5deb01abc562867b
marcelcosme/URI
/PYTHON/2478(error).py
504
3.53125
4
pessoas = int(input()) lista_presentes = [] lista_pessoas = [] for i in range(pessoas): x = list(map(str, input().split())) lista_pessoas.append(x[0]) lista_presentes.append(x[1:]) while True: try: pessoa, presente = map(str, input().split()) index = lista_pessoas.index(pessoa) ...
c796d5cbbd0773a35c4a72a4c6ecdcbba0e2358d
marcelcosme/URI
/PYTHON/1728(accepted).py
613
3.78125
4
def trocando(algarismo): novo = algarismo[-1] for i in range(len(algarismo) - 2, -1, -1): primeiro = algarismo[i] novo += primeiro return novo def algorismos(palavra): primeiro, separador, resultado = palavra.partition('=') resultado = int(trocando(resultado)) soma_1, sinal, so...
6c38d350cabd52f98394f70703e6f3b0874c773d
sergey-igoshin/Igoshin_Sergey_dz_5
/task_5_1.py
599
3.8125
4
""" DZ 5_1. Написать генератор нечётных чисел от 1 до n (включительно), используя ключевое слово yield, например: odd_to_15 = odd_nums(15) next(odd_to_15) 1 next(odd_to_15) 3 ... next(odd_to_15) 15 next(odd_to_15) ...StopIteration... """ def odd_nums(x): for num in range(1, x + 1, 2): yie...
537bfed643c059426bc9303f369efb0e1a9cc687
MS642/python_practice
/objects/objects.py
1,445
4.28125
4
class Line: """ Problem 1 Fill in the Line class methods to accept coordinates as a pair of tuples and return the slope and distance of the line. # EXAMPLE OUTPUT coordinate1 = (3, 2) coordinate2 = (8, 10) li = Line(coordinate1, coordinate2) li.distance() ...
70fcf059ad0f15f7895c750052fbafcb04fa9874
MS642/python_practice
/methods/methods.py
8,087
4.28125
4
""" Practice questions and solution added to the functions with asserts to verify """ def lesser_of_two_evens(a, b): """ # LESSER OF TWO EVENS: Write a function that returns the lesser of two given numbers if both numbers are even, # but returns the greater if one or both numbers are odd :param a...
fc82134e9cfe0c385b1958df723280a0ef7bd4cf
nablet/projecteuler-my_solutions
/Problem022.py
1,145
3.90625
4
# Names scores # Problem 22 # Using names.txt (right click and 'Save Link/Target As...'), a 46K text file containing over five-thousand first names, # begin by sorting it into alphabetical order. Then working out the alphabetical value for each name, multiply this value # by its alphabetical position in the list...
895b02f1e95643463fa6cccb9ebc611019fb0e1a
nablet/projecteuler-my_solutions
/Problem067.py
1,431
3.734375
4
# Maximum path sum II # Problem 67 # By starting at the top of the triangle below and moving to adjacent numbers on the row below, # the maximum total from top to bottom is 23. # 3 # 7 4 # 2 4 6 # 8 5 9 3 # That is, 3 + 7 + 4 + 9 = 23. # Find the maximum total from top to bottom in triangle.txt (right ...
517e2e4858fee9e68bc2e3c27601e12f986eec1c
nablet/projecteuler-my_solutions
/Problem015.py
559
3.59375
4
# Lattice paths # Problem 15 # Starting in the top left corner of a 2×2 grid, and only being able to move to the right and down, there are exactly 6 routes to the bottom right corner. # How many such routes are there through a 20×20 grid? import time s = time.time() def factorial(num): value = 1 for ...
c0e20ddb74fa49544832aff6006d15b958e97f62
Zhumatai-prog/Chapter-2-Task-14
/task14.py
130
3.96875
4
numbers = input("Enter a list of numbers: ") number = list(numbers) for i in number: if i % 2 == 0: print (i) else: continue
22202840ae1c77f10c7e1f301ec5c0262b92e4e3
lucasflosi/Assignment2
/nimm.py
2,011
4.40625
4
""" File: nimm.py ------------------------- Nimm is a 2 player game where a player can remove either 1 or 2 stones. The player who removes the last stone loses the game! """ STONES_IN_GAME = 20 #starting quantity for stones def main(): stones_left = STONES_IN_GAME player_turn = 1 while stones_left > 0: ...
7608a5bf24eb46ea37f06a3f7ff7031e59fb22a9
KIM1890/py_game
/lession_1/draw_shape.py
1,370
3.515625
4
import pygame import sys # khoi tao game pygame.init() # thiet lap man hinh cho game screen = pygame.display.set_mode((500, 500)) # fill background screen.fill((255, 255, 255)) # tao caption cho screen pygame.display.set_caption('drawing shape') # create icon pygame.display.set_icon(pygame.image.load('img_game.png...
562d6e508ea71c5ec1ffd66920e9487f50d1f07a
Yonimdo/Python-Intro
/ListComprehension/41/41a.py
356
3.6875
4
def funny(s): lst = s.split() lst = [x[::-1].lower().title() for x in lst] # === YOUR CODE HERE! === # ======================= return " ".join(lst) result = funny("Foo bar") print(result) assert result == "Oof Rab" result = funny("The quick brown fox") print(result) assert result == "...
42f330afbe767e5190cc95419153fb771a81af0a
Yonimdo/Python-Intro
/Files/35/ex_35_old.py
623
3.5
4
def parse_commands(filename): x, y = 0, 0 # --- WRITE YOUR CODE HERE --- # infile = open(filename,"r"); for line in infile: split = line.split(' ') if split[0] == "North": y += int(split[1]) elif split[0] == "South": y -= int(split[1]) ...
54e5dd333292fa93e1fd6a748f5dbaf1e6fe896c
Yonimdo/Python-Intro
/Dictionaries/39/39a.py
1,792
3.5625
4
def paint(width, height, commands): canvas = [[" " for x in range(width)] for y in range(height)] for command in commands: ''' for c in commands: x0, y0 = c['start'] dx, dy = c['size'] for x in xrange(dx): for y in xrange(dy): canvas[...
933a8337302cb41821a2aa3db07e5c68076cbd2d
lebgit/RSOI
/functions.py
322
3.53125
4
from collections import Counter def prime_num(s): if not s.isdigit(): return False c = int(s) res = True for i in range(2,c): if c % i == 0: res = False break return res def square(s): if not s.isdigit(): return False c=int(s) return c**...
28ad057133887c127f21baa0c3de6158ce8a1bac
DanielCortild/Projectile-Motion
/main.py
4,358
4.25
4
""" PyGame Simulation of Projectile Motion ~ Daniel Cortild, 29 July 2021 """ # Libraries from math import sqrt, atan, pi, cos, sin import pygame # Constants WIDTH = 1200 HEIGHT = 500 RADIUS = 10 BLACK = (0, 0, 0) GRAY = (64, 64, 64) WHITE = (255, 255, 255) START_X = WIDTH / 2 START_Y = HEIGHT - RADIUS - 1 # Ball...
e4b9457b5249f20a6289a38c6b2a721c87f86704
beyhad/ass
/stackprob.py
487
3.828125
4
class Stack: def __init__(self): self._data = [] def push(self,x): self._data.append(x) def pop(self): if(self.is_empty()): print("stack is empty") else: return self._data.pop() def is_empty(self): return len(self._data) == 0 if __name__ == '__main__': s = Stack() List = [2,4,6,8,10,12...
57b5c0051c2b911ea48fb9a3e792c8eaa39f04c8
ashendrickson/dfval
/dfval/dfclean/dfclean.py
595
3.78125
4
import pandas as pd def na_clean(df, qty_n): """converts NaN values to 0 Parameters: df (pandas dataframe): a pandas dataframe qty_n (list): list of field names in the dataframe that should have NaN values replaced with 0 Returns: df (pandas dataframe): a pandas dataframe that i...
75e1bb64b879352671bc78710c6a9b0543f3332e
MoosHU1/Formatieve_opdracht2
/Formatieve_opdracht2a.py
945
3.59375
4
''' Bron 1: https://www.w3schools.com/python/python_mongodb_find.asp ''' import pymongo client = pymongo.MongoClient("mongodb://localhost:27017/") database = client["huwebshop"] def opdracht_1(): colom_product = database["products"] results = colom_product.find() for result in results: print(r...