blob_id
stringlengths
40
40
repo_name
stringlengths
5
127
path
stringlengths
2
523
length_bytes
int64
22
545k
score
float64
3.5
5.34
int_score
int64
4
5
text
stringlengths
22
545k
aae2e917718f00dd7013f98cec646a5bbf120446
Seoyoung2/Algorithm_Study
/Baekjoon/BFS - New/연결 요소의 개수.py
660
3.609375
4
# https://www.acmicpc.net/problem/11724 # BFS/DFS를 쓰는 방법도 있지만 Union-Find(합집합 찾기)를 사용함 from sys import stdin n, m = map(int, stdin.readline().split()) parent = {i: i for i in range(1, n+1)} def getParent(n): if n == parent[n]: return n parent[n] = getParent(parent[n]) return parent[n...
c982836cd5b734492e06ec4714b30114a5c6e836
Seoyoung2/Algorithm_Study
/Programmers/Level2/JadenCase 문자열 만들기.py
580
3.78125
4
# https://programmers.co.kr/learn/courses/30/lessons/12951 def solution(s): answer = [s[0].upper()] for i in range(1, len(s)): if s[i] == " ": answer.append(" ") elif s[i] != " " and s[i-1] == " ": answer.append(s[i].upper()) else: answer....
e90e795b8bc63d83b65a4dd3c48620a2025c59c3
Pongsakorn0/BasicPython
/ifcondition.py
238
3.796875
4
age = 15 if(age == 18): print("Allow to Access") else: print("you 15") user = input("user = ") pwd = input("password =") if(user == "admin" and pwd == "1234"): print("Login Success") else: print("Login Fail !!!")
4f3b25f63b7ebcc6b3aa02571b3517df061d9222
gabedebem/pyhton_do_zero
/m_3_mais_velho_split.py
621
3.953125
4
#Digitar o nome e a idade separadamente na mesma linha: usar o comando input.split. # As variaveis ficam separadas por virgula, assim como ficarao os valores delas, como strings. pessoa_1 , idade_1 = input("Digite separadamente o primeiro nome e a idade:\n").split() #transformar um dos valores em numoro inteiro idade_...
3e715f3790091f80ca9d14da25e6c2b1990f1256
codebuff/snippets
/trees/node.py
1,404
3.609375
4
class Node: def __init__(self, key, value, parent=None): self.key = key self.value = value self.left_child = None self.right_child = None self.parent = parent self.height = None self.depth = None def get_key(self): return self.key def get_val...
390af2b1fe1d9adf10a4b2559e738d8261da1b3c
Tejashwini132/Mile_to_Km_Converter
/main.py
668
4
4
from tkinter import * window = Tk() window.title("Mile To Km Converter") window.config(padx=20, pady=20) def convert(): miles = float(input.get()) km = round(miles * 1.609) display_label.config(text=f"{km}") # Entry input = Entry(width=7) input.grid(column=1, row=0) # Labels mile_label = Label(text="Mi...
52cbbdbf63054a00a6c7d1d6156fd52233cb6f00
tdkseraph/algorithm
/array/findItemsPutInKnapsack.py
1,622
3.6875
4
# 0-1 Knapsack problem # In 0-1 Knapsack problem, we are given a set of items, each with a weight # and a value and we need to determine the number of each item to include in # a collection so that the total weight is less than or equal to a given limit # and the total value is as large as possible. # Input: # value = ...
db8c1097c994e96b8121c0438798d62e8af2bc2b
tdkseraph/algorithm
/array/findDuplicateInRangeK.py
1,138
3.890625
4
# Find duplicates within given range k in an array. # Given an array and a positive number k, check whether the array contains any duplicate # elements within range k. If k is more than size of the array, the solution should check # for duplicates in the complete array. # A[] = { 5, 6, 8, 2, 4, 6, 9 } k = 4 # Output: D...
070ffec6384b2773afbef03f7d00098f875d2698
tdkseraph/algorithm
/array/findLongestSequenceSameSumInTwoArray.py
971
3.6875
4
# Length of longest continuous sequence with same sum in given binary arrays # For example, consider below binary arrays X[] and Y[] # X: {0, 0, 1, 1, 1, 1} # Y: {0, 1, 1, 0, 1, 0} # The length of longest continuous sequence with same sum is 5 as # X[0, 4]: {0, 0, 1, 1, 1} (sum = 3) # Y[0, 4]: {0, 1, 1, 0,...
fddb5d0d7a9d286defc1ae9eff3b09a731daadde
tdkseraph/algorithm
/array/findMaximumSubarrayKadane.py
1,790
4
4
# Maximum Subarray Problem (Kadane’s algorithm) # Given an array of integers, find contiguous subarray within it which has the largest sum. # Input: {-2, 1, -3, 4, -1, 2, 1, -5, 4} # Output: Subarray with the largest sum is {4, -1, 2, 1} with sum 6. from typing import List def findSubarrayWithLargestNonNegativeSum(...
582b86e3bf2723c51605d534ff797b3c29b40c1d
meinertsen/interviews
/subset_pair_sum.py
680
3.8125
4
# Subset pair sum question: https://www.youtube.com/watch?v=XKu_SEDAykw # python solution for unsorted numbers using a list comprehension with if else a = [1, 2, 3, 9] b = [1, 2, 4, 4, 9, 6] # extended from youtube example to illustrate unsorted sequence s = 8 # Are the numbers sorted: no # integers, negatives: assu...
c42dd0dbe5719c4681a18994f4b5913d5a6e2059
AlissonSantana/curso_python
/aula21/ex021.py
2,713
3.953125
4
help() help(print) print(input.__doc__) DocString def contador(i, f, p): """ -> Faz uma contagem e mostra na tela :param i: Início da contagem :param f: Fim da contagem :param p: Passo da contagem :return: Sem Retorno! Função criada por Alisson """ c = i while c <= f: p...
993167c14798e9532e57e0c53d12de747aa6707b
AlissonSantana/curso_python
/aula19/ex019.py
2,491
3.859375
4
from random import randint from operator import itemgetter pessoas = {'nome': 'Gustavo', 'sexo': 'M', 'idade': 22} pessoas['nome'] = 'Jose' pessoas['peso'] = '90.5' print(f'Seu nome é {pessoas["nome"]} e sua idade é {pessoas["idade"]}') print(pessoas.keys()) print(pessoas.values()) print(pessoas.items()) for k in pess...
ee9dbf27452e333751107ab4dc0a1dbb893c944c
Archanaaarya/function
/kbc_in_function.py
1,984
3.84375
4
question_list=["what is the full form of KBC in programming?", "which company is the best for software engeneers ?", "Which course is taught in navgurukul?"] option_list=[["1.kon banega cat", "2.kon banega carodpati", "3.kon banega coder ", "4.kon banega chor"],["1.twitter", "2.insta", "3.facebook", "4.google"],["1.Sof...
80c9e475ca243a6187fd47ea4eaae18e6f4a1d29
Archanaaarya/function
/sum_of_the_eliments_by_function.py
266
3.5625
4
# Q2. Aapko sum function ka use krke di hue list ke element ka sum print krvana hai. Input numbers = [1, 2, 3, 4, 5] print(sum(numbers)) # or numbers = [1, 2, 3, 4, 5] i = 0 sum = 0 while i<len(numbers): sum = numbers[i]+sum i = i+1 print(sum)
0ce90406f9667eaa460919f4131eecd9808c6c3c
Archanaaarya/function
/arbitarary_argument.py
188
3.640625
4
# Python Arbitrary Argument def icecream(*flavours): for flavour in flavours: print("i love "+flavour) icecream("chocolate", "butterscotch","vanilla","strawberry","stroberry")
6b3089bd9bf7cba6335aecea8daddc82a12b9dc3
nju-luke/Test
/prime.py
564
3.53125
4
# -*- coding: utf-8 -*- # @Time : 10/16/16 10:53 # @Author : Luke # @Software: PyCharm import numpy as np class Prime(): def __init__(self): self.W = 0 self.train() def is_prime(self,n): k = int(np.sqrt(n)) for i in range(2,k+1): if n%i == 0: re...
a1bdf0091a6bf3baa06c7398df19af4152bde843
jannisveerkamp/advent-of-code-2018
/15/day_15.py
994
3.6875
4
GOBLIN = "G" ELF = "E" FLOOR = "." WALL = "#" class Unit: def __init__(self, row, column, is_elf): self.row = row self.column = column self.is_elf = is_elf self.hp = 200 self.attack_power = 3 def __lt__(self, other): if self.row == other.row: return...
13fc2a538f52c689f5af6fc29d94595cea356ce0
jannisveerkamp/advent-of-code-2018
/06/coordinates.py
3,459
3.75
4
EMPTY = "." MULTI = "x" UNSAFE = "o" def size_safe_area(coordinates, max_sum_distance): coordinates = parse_coordinates(coordinates) x_max, y_max = get_array_size(coordinates) area = [[EMPTY for _ in range(x_max)] for _ in range(y_max)] for y in range(y_max): for x in range(x_max): ...
66224e29cfb2ed7e77c59b1aabf002ff3221136d
jannisveerkamp/advent-of-code-2018
/2017-01/captcha.py
429
3.71875
4
# First assignment from 2017 to see if everything is set up correctly :-) def calculate_captcha_sum(digits, step=1): digit_sum = 0 for i in range(0, len(digits)): if digits[i % len(digits)] == digits[(i + step) % len(digits)]: digit_sum += int(digits[i % len(digits)]) return digit_sum ...
d827d939a605a4851d3882169aa85574b260b69a
Rajanayaki/Linked-List
/Remove duplicates with buffer.py
962
3.734375
4
class node: def __init__(self,data): self.data=data self.next=None class linkedlist: def __init__(self): self.head=None def push(self,data): newnode=node(data) if self.head is None: self.head=newnode else: temp=self.head while(temp.next!=None): temp=temp.next...
d74fcbcb016f784ef857903ec0b4bbd8ef428050
ShreyaRawal97/Show-me-the-datastructures
/problem_2.py
1,090
3.59375
4
""" File Recursion """ import os def find_files(suffix, path): paths = list() contents = os.listdir(path) for file in contents: #path = os.path.join(dir, file) if os.path.isfile(os.path.join(path, file)): if file.endswith(suffix): paths.append(os.path.join(path...
225ce0b4870a426998f644e534eed3c2e058a8b5
aenygma/exercism.io
/python/high-scores/high_scores.py
598
3.640625
4
class HighScores(object): def __init__(self, scores): self.scores = scores def latest(self): """ get the latest score """ if len(self.scores) != 0: return self.scores[-1] return def personal_best(self): """ get personal best """ ...
2cbf4dc968670a72820580e8516342aa5390080f
aenygma/exercism.io
/python/book-store/book_store.py
2,076
3.609375
4
class Chunk(object): """ given a list of items, chunk them in unique groups """ def __init__(self, tlist): self.tlist = tlist.copy() @property def counts(self): """ return a tally of counts""" ret = [] for i in set(self.tlist): ret.append((i, self....
8c56ffe12aa6a5ab669d9a7dd592ccc9fe9c306c
ezekielp/algorithms-practice
/palindrome_number.py
659
3.5
4
class Solution: def isPalindrome(self, x: int) -> bool: if x < 0 or (x % 10 == 0 and x != 0): return False digits = [] dummy_x = x while dummy_x > 0: digit = 0 while dummy_x % 10 != 0: dummy_x -= 1 digit += ...
19b00f3cace5617652435d104b04dc24b68513ea
ezekielp/algorithms-practice
/integer_break.py
1,227
4.25
4
""" Given a positive integer n, break it into the sum of at least two positive integers and maximize the product of those integers. Return the maximum product you can get. Example 1: Input: 2 Output: 1 Explanation: 2 = 1 + 1, 1 × 1 = 1. Example 2: Input: 10 Output: 36 Explanation: 10 = 3 + 3 + 4, 3 × 3 × 4 = 36. Not...
a2aabd815109e519d6eff5a73b31bba6e058689a
Bigphilosophy/ChatRoom
/main.py
1,980
3.640625
4
# !/usr/bin/python3 # -*- coding: utf-8 -*- import os class Person(): def __init__(self, name, word_file_path): self.name = name self.word_file_path = word_file_path def __repr__(self): return self.name def say(self, words): message = "[{}]:{}".format(self.name, words) ...
4d692beb2cc98e342477298f4ffcb0bd4cda8e3c
Daniel-Ems/bank_of_nerds
/bank_information.py
13,680
4.4375
4
#!/bin/usr/env python3 import os import time import sys class Account: """ The account class contains the methods of depositing or """ """ withdrawing. It stores a float and a product label """ def __init__(self, product): self.balance = 0.00 self.product = product # withdraw and dep...
a2b3384b5e04e99f794c2a4dfd836cdca902fb05
rathoddilip/InheritanceUsingPython
/single_inheritance.py
268
3.640625
4
class Father: fatherName = "" def father(self): return self.fatherName class Son(Father): def parents(self): print("Father name :", self.fatherName) if __name__ == '__main__': s1 = Son() s1.fatherName = "RAM" s1.parents()
1dbb444b466d87af04383d9b5271ddf06abcda1e
Rand-RB/S-M-Path-3
/smile detection.py
627
3.546875
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Mon Jun 29 11:47:16 2020 @author: ranood """ #smile detection with open cv import cv2 #xml file "the trained model" smaile_trained_model=cv2.CascadeClassifier("haarcascade_smile.xml") #read the image img=cv2.imread("aaa.jpg") #change the input to gray gray=...
389e77d4e21f112b30f415e21064026f6161aa9a
vaishu29/Python-Assignment
/Day3/LandThePlane.py
159
3.75
4
altitude=1500; if altitude<1000: print("land the plane"); elif altitude<5000: print("come down to 1000ft"); else: print("Go round and try later");
96fcaeefcfbbe21eca76765564a09f41c8b8f934
mingz2013/py.calc
/src/parser/parser.py
5,859
3.609375
4
# -*- coding:utf-8 -*- """ 语法分析,生成抽象语法树 """ __date__ = "14/12/2017" __author__ = "zhaojm" from ast import ast from scanner.scanner import Scanner from token import token class Parser(object): def __init__(self, filename, src): self.file = token.File(filename) self.scanner = Scanner(self.file...
679b8b24eda016b5e320624a0ead00bfdf12903b
dple/Strings-in-Python
/pangram.py
706
4.15625
4
""" A pangram is a string that contains every letter of the alphabet. Given a sentence determine whether it is a pangram in the English alphabet. Return either pangram or not pangram as appropriate. For example: Input: We promptly judged antique ivory buckles for the next prize Output: pangram """ def pangrams(s): ...
a8028c387cd7614526d1621c9ac1761441383cad
venkatarahul189/Python-deep-learning
/ICP2/icp2(2).py
173
3.71875
4
set = 0 a = int(input('num:')) while a != 0: if (a % 2) == 0: a = a/2 set = set + 1 else: a = a - 1 set = set + 1 print(set)
1ff2b6f79a5a00f7357ecc07ee5d5a83b8f819a9
venkatarahul189/Python-deep-learning
/ICP5/source code/ICP5(3).py
1,113
3.640625
4
import pandas as pd import numpy as np import matplotlib.pyplot as plt #import the data dframe = pd.read_csv('data.csv') convert = {"City Group": {"Big Cities": 0, "Other": 1}, "Type" : {"FC" : 0, "IL" : 1, "DT" : 2}} data = dframe.replace(convert) #check the data types data.revenue.describe() y = np.log(d...
f7ba397788aa0ee66582f5dd3a834de31062b0d8
jstocks/minesweeper
/minesweeper_input.py
2,695
3.9375
4
""" TCSS504 Jeffrey Stockman NetID: stockmaj Group Assignment #1 - individual solution minesweeper input file creates single or multiple minesweeper boards based on row, column, and mine probability; writes all [R C] and minefield to a file 'minesweeper_input.txt' to be read and solved by 'minesweeper_output.py' ""...
b00e72688105d28cf73b30c290f3ecb58376f675
salil-khanna/GameBot
/gamebot.py
16,640
3.625
4
# Libraries to make the bot work import os import discord import random import asyncio from discord.ext import commands import json import urllib.request TOKEN = ... #Replace token with your own bot's token if you want to reproduce bot results, the token connects the python file to the bot BOT_PREFIX = ("?", "!") ...
4851223f62521a36f53145677c1ab41dabd75ef3
Wyinne/algorithm020
/Week1/合并两个有序链表.py
836
3.90625
4
class Node(object): def __init__(self,elem): self.elem=elem self.next=None class Soultion: def AddTwoList(self,l1,l2): if not l1: return l2 elif not l2: return l1 elif l1.elem<l2.elem: l1.next=self.AddTwoList(l1.next,l2) ret...
31c86f9b3b49aca2002fa01058ca4763312c3046
Gaurav1921/Python3
/Basics of Python.py
1,703
4.375
4
""" to install any module first go in command prompt and write 'pip install flask' and then come here and write modules are built in codes which makes our work more easier and pip is package manager which pulls modules """ import flask """ to print something the syntax for it is """ print("Hello World") """ us...
96e7bc37fdcb4714a78f13fb1657e9c6dd8426b5
DerekMazino/Uri-Online-Judge
/Principiante/1044.py
196
3.5625
4
cadena=input().split(' ') n1=int(cadena[0]) n2=int(cadena[1]) if n1>n2: a=n1%n2 elif n2>n1: a=n2%n1 else: a=0 if a==0: print('Sao Multiplos') else: print('Nao sao Multiplos')
b31dc8ea91f4e5adc22e2b3de652a1edb5c60e6f
DerekMazino/Uri-Online-Judge
/Principiante/1007.py
107
3.578125
4
a=int(input()) b=int(input()) c=int(input()) d=int(input()) dif=(a*b)-(c*d) print("DIFERENCA = %d" %dif)
9b9c89bb8f1c966590d30eb3b12863a3eb31f018
DerekMazino/Uri-Online-Judge
/Principiante/1038.py
205
3.515625
4
entrada=input().split() x=int(entrada[0]) y=int(entrada[1]) if x==1: v=y*4.00 if x==2: v=y*4.50 if x==3: v=y*5.00 if x==4: v=y*2.00 if x==5: v=y*1.50 print('Total: R$ {:.2F}'.format(v))
39a1e65b76dee0ea2ffeeea9c46ce8ff2363b684
oalbe/exercism
/python/prime-factors/prime_factors.py
309
3.734375
4
def prime_factors(num): factors = [] i = 2 while (i <= num): if 0 == (num % i): factors.append(i) # NOTE: This hides an implicit cast to int num = num // i i = 1 i += 1 return factors
b074993b366204f71819d66f837170eed9bd6123
oalbe/exercism
/python/sublist/sublist.py
1,312
3.828125
4
def check_helper(ref_list, test_list): if not ref_list: return True # TODO: Should I add a check to first verify that each element of the ref_list # is present in the test_list? Seems to only add overhead. status = False i = 0 j = 0 while i < len(test_list): if j...
f6504f62bf0227b7878785c276b7b4a3f670e0fd
oalbe/exercism
/python/robot-simulator/robot_simulator.py
1,024
3.53125
4
NORTH, EAST, SOUTH, WEST = range(4) class Robot: directions = [NORTH, EAST, SOUTH, WEST] def __init__(self, direction=NORTH, x=0, y=0): self.x = x self.y = y self.bearing = direction @property def coordinates(self): return (self.x, self.y) de...
80585d0100afb9f342ce5e6e50c07a5a61866226
oalbe/exercism
/python/luhn/luhn.py
1,180
3.625
4
class Luhn: def __init__(self, num): self._number = str(num) def addends(self): digits = self._number addends_arr = [] num_len = len(digits) for i in range(num_len - 1, -1, -1): if (0 == (num_len - i) % 2): doubled_num = in...
a0feac15044710bb837321f9918d323b6e267267
richard-to/CS-Evolutionary-Computing
/pa2/pa2.py
3,108
3.609375
4
#!/usr/bin/env python """ Main program for PA2 This program uses evolutionary strategies algorithm to maximize the following function: f(x1, x2) = 21.5 + x1 * sin(4 * pi * x1) + x2 * sin(20 * pi * x2) """ import random import es """ Logging Settings Currently only one logging setting is available. Specify Non...
d36ebbfe999c6bbf6d52760732243ba0fde29d72
kh-mo/isolationForest
/reference.py
5,460
3.5625
4
''' https://machinelearningmastery.com/implement-decision-tree-algorithm-scratch-python/ 참조 ''' import os import urllib.request import pandas as pd def download_data(name): ''' name : download 가능한 데이터 셋 이름 ''' urls = {"BanknoteAuthentication" : "http://archive.ics.uci.edu/ml/machine-le...
d1ee3c94491b93693cd9bd09f65e7e4d31ad4511
Enin/codingTest
/amazon/6_determine_if_a_binary_tree_is_a_binary_search_tree.py
2,728
4.28125
4
### # Given a Binary Tree, figure out whether it’s a Binary Sort Tree. # In a binary search tree, each node’s key value is smaller than the key value of all nodes in the right subtree, # and is greater than the key values of all nodes in the left subtree. # Below is an example of a binary tree that is a valid BST. impo...
7508a1741a08754cac0eb8640c53c6424d07799a
Enin/codingTest
/amazon/10_find_Kth_permutation.py
1,388
3.796875
4
# Given a set of ‘n’ elements, find their Kth permutation. # Consider the following set of elements: import itertools def factor(n): if n == 0 or n == 1: return 1 return n * factor(n - 1) def find_kth_permutation_use_itertools(v, k): if not v: return result = [] for i in list(iter...
31cda8337ae5d3aac34cea9da7ccdcd4c04bc4be
Enin/codingTest
/basic_code.py
2,410
3.78125
4
# from random import * # 랜덤 함수 사용 라이브러리 # # print(int(random() * 10) + 1) # 1에서 부터 10사이의 랜덤 int 1개를 출력 # print(randint(1, 45)) # 1~45 사이의 랜덤 int 1개를 출력 # # name = "lee" # print(name[2]) # 문자열은 리스트처럼 n번째 문자를 가져올 수 있음. # # print("Lol".lower()) # 소문자로 변경 # print("Lol".upper()) # 소문자로 변경 # x = "lol" # print(x.replace...
3a4aa5f103c622810f4b6d69774b31c76ccf8371
Enin/codingTest
/amazon/13_clone_a_directed_graph.py
3,760
3.828125
4
# Given the root node of a directed graph, # clone this graph by creating its deep copy so that # the cloned graph has the same vertices and edges as the original graph. # # Let’s look at the below graphs as an example. # If the input graph is G=(V,E) where V is set of vertices and E is set of edges, # then the output ...
74af819f062dc0dff568fbbfdd2767be07f4f603
Enin/codingTest
/amazon/7_string_segmentation.py
907
4.375
4
# You are given a dictionary of words and a large input string. # You have to find out whether the input string can be completely segmented into the words of a given dictionary. # The following two examples elaborate on the problem further. import collections # recursion과 memoization을 사용 given_dict = ['apple', 'apple'...
038c8411815183d4b7d8496a3c17a084b942b8c9
Dekart97/Python-Projects
/Linear Regression/Linear_Regression.py
2,169
3.84375
4
# Author: Dekart Kosa # Description: This is a linear regression model that predicts the final grade(G3) for students based on mid-term grades, G1, # G2, study-time, failures, absences. The data is taken from https://archive.ics.uci.edu/ml/datasets/Student+Performance import pandas as pd import numpy as np import skl...
7b80ac4b0a5070981ddb6dc475cd725a6f2144c7
jferreira1/TPMC-Build-10-Real-World-Applications
/Exercises/Section 24/account/acc.py
1,207
3.75
4
class Account: def __init__(self, filepath): self.filepath = filepath with open(filepath, 'r') as file: self.balance = int(file.read()) def withdraw(self, amount): self.balance = self.balance - amount def deposit(self, amount): self.balance = self.balance +...
f20624f6d8b11ee6d3fe79f50b599d74c657d1ab
yhoo0007/string-algos
/solutions/q3/modified_kmp.py
4,965
3.515625
4
# Ho Yi Ping # This file contains all the code for question 3 (Modified KMP). Run the # file from commnad line via: python modified_kmp.py <text_file> <pattern_file> This program will # write its output to a file named 'output_kmp.txt' in the same directory as the script. import sys ALPHABET = [chr(i) for i in rang...
506c1e4ee1304102b7ba5f0a267fb9f5a3d586b1
MichaelPay/michael_learns_python
/Python Projects/Python Basics/Logics/For and While Loops.py
736
3.875
4
# -*- coding: utf-8 -*- """ Created on Tue Jul 18 20:28:17 2017 @author: Monic """ listing = 'Hello, How are you today? I am so cool! Nice to meet you, son!' my_list = listing.split() for word in my_list: print(word) for letter in 'abcdefghijklmnopqrstuvwxyz': print(letter.upper()) #create a ...
c347eb330580a122ef900460dbb694e136f7e94c
MichaelPay/michael_learns_python
/Python Projects/OOP Python/NumString Magic Methods.py
846
3.953125
4
# -*- coding: utf-8 -*- """ Created on Thu Jul 27 13:53:18 2017 @author: Monic """ # numstring.py # a class that holds a float or int as a string # but allows us to turn it back into an int whenever we want to class NumString: def __init__(self, value): self.value = str(value) def __str__...
0febc19e5fdac3e7a10a0055ffb5893c4dca0323
MichaelPay/michael_learns_python
/Python Projects/datetime/challenge 1.py
283
3.5
4
# -*- coding: utf-8 -*- """ Created on Tue Aug 1 19:50:31 2017 @author: Monic """ import datetime import random now = datetime.datetime.now() two = datetime.datetime.now() print(now) print(two.replace(hour=14)) time = random.randint(1, 19999) print(time)
b642da7e57504a1574613560cd89f6de4a7b8c83
MichaelPay/michael_learns_python
/Python Projects/Python Basics/Strings.py
186
3.5
4
status_message = "Hey {}, you're so cool. But today is {}, and it's cool" import time print(status_message.format(input("Put in your name here please: "), time.strftime("%m/%d/%Y")))
41e86d61e4cb637eef5e896616a9cb144aec1167
MichaelPay/michael_learns_python
/Python Projects/OOP Python/new dunder method.py
1,040
3.828125
4
# -*- coding: utf-8 -*- """ Created on Thu Jul 27 14:38:20 2017 @author: Monic """ # __new__ is used to modify immutable data types class rStr(str): def __new__(*args, **kwargs): self = str.__new__(*args, **kwargs) self = self[::-1] return self # creating subclass for ...
1b9c902c69bd1bebd1ada9cc0e52275cd27224f7
chiragkalal/python_practice_programs
/final_king_names.py
2,574
3.890625
4
import re def int_to_roman(int_num): int_roman = { 1: "I", 4: "IV", 5: "V", 9: "IX", 10: "X", 40: "XL", 50: "L", 90: "XC", 100: "C", 400: "CD", 500: "D", 900: "CM", 1000: "M" } if(int_num in int_roman): return int_roman[int_num] for i in [1000, 100, 10, 1]: for j ...
a8e6503aaf9f93ede083adc7390e0dc9fda11bc1
tonyhong272/codingPractice
/LongestCommonPrefix/1st.py
510
3.65625
4
class Solution(object): def longestCommonPrefix(self, strs): """ :type strs: List[str] :rtype: str """ preStr = '' if not strs: return preStr for i, char in enumerate(strs[0]): for string in (strs): if len(string) -1 < i...
43b22a6d7caeac6b35f50a3749c573236035b36f
tonyhong272/codingPractice
/reverseInteger/1.py
508
3.515625
4
# -*- coding: utf-8 -*- """ Created on Mon Mar 21 15:34:44 2016 @author: xhong """ class Solution(object): def reverse(self, x): """ :type x: int :rtype: int """ if x==0: return 0 str_x = str(abs(x)) sign = x/abs(x) str_x = str_x[::-1] ...
d3302d00ebca7dd0ff302f38cd78d1b87ccb5c1f
AdishiSood/Jumbled_Words_Game
/Jumbled_words_Game.py
2,419
4.46875
4
#To use the random library, you need to import it. At the top of your program: import random def choose(): words=["program","computer","python","code","science","data","game"] pick=random.choice(words) #The choice() method returns a list with the randomly selected element from the specified sequence. ...
9ecdd1c23dce712618b75e1aa7457d6f26ed889f
matias1022/Ejercicio-8
/claseConjunto.py
2,114
3.546875
4
class Conjunto: __lista=[] def __init__(self): self.__lista = [] def agregaNumero(self,numero): if type(numero) == int: if numero not in self.__lista: self.__lista.append(numero) def getLongitudConjunto(self): return len(self.__lista) def get...
253b28a9e66c5f6bde777ca82b4d7fd37856d0d5
GonzaloGmv/terminar-el-juego
/juego.py
2,520
3.890625
4
def pedir_numero(MIN,MAX): while True: respuesta = input("Escriba un numero entre " + str(MIN) + " y " + str(MAX) + ": ") try: respuesta = int(respuesta) except: pass else: if MIN <= respuesta <= MAX: break return respuesta def...
3b0d09e57ae39e265785c3c49ecf108074b1d018
GbadeAina/python
/hello.py
180
4.125
4
name = input("What's your name? ") age = int(input("Age? ")) if age < 10: print("Hi, little " + name + "!") else: print("Hello " + name + "!") print("How are you?")
267fbb724c821c9b8e588d15851ee94e7e85c3ac
BlankRiser/Learning-python
/findingLanes/lines.py
1,666
3.765625
4
# https://www.youtube.com/watch?v=eLTLtUVuuy4 # importing openCV, numpy import cv2 import numpy as np import matplotlib.pyplot as plt # getting the image file usig imread(srcImage) image = cv2.imread('test_image.jpg') # imshow('nameOfWindow',src_image_Object) : shows the image, but closes instantly cv2.imshow('resul...
553ef3e7e23cc44785fcc0ea1865852827e17d43
zhuzhumi/basePractice
/base/6-12/generater.py
462
3.59375
4
#coding:utf-8 g = (x * x for x in range(1,10)) print type(g); a = [] for i in g: a.append(i) print a print '\n----------斐波拉契数列------------\n' def func(max): n,a,b = 0,0,1 while n < max: print b a,b = b,a+b n = n + 1 print func(6) print '\n----------------------\n' def func(max): ...
eb37f2f862469d372da8c0a61eff437d310cbcad
DongMinHong/computer
/ex03/ex03.py
1,213
3.9375
4
#-*-coding:cp949 print "I will now count my chickens:" print "Hens", 25 + 30 / 6 , "dong min" # , 갪 ½Ű ٸ ½Ű # #-*-coding:cp949 ̴ּ print "Roosters", 100 - 25 * 3 % 4 print "Now I will count the eggs:" print 3 + 2 + 1 - 5 + 4 % 2 - 1 / 4 + 6 print 1 / 4 #ó ׳ Ǽ / ָ Ҽ ʴ´ # Ҷ "" ʰ ׳ 길 ־ش print "Is it true ...
9c86c2abe1a808153185215b16d58210da7af7d1
Dmdv/CS373
/coconuts.py
283
3.53125
4
#!/usr/bin/env python def cocos(x): for i in range(5): x = (x*5.0/4.0)+1 print (x) if int(x) != x: return False return x i = 1 while True: result = cocos((i*5)+1) if result: print (result) print (i) break i += 1
602d8fc92d71be221a3e0082e681cd4bf43729f8
MichaelAndri/Homework
/Chapter 5 - control structures/10 - Print even up to.py
139
4.1875
4
def print_even_upto(): for number in range(n): if (number%2) == 0: print(number) n = int(input("Enter number: ")) print_upto()
4b192abd36c49cc85782d868427501a617390c44
ljwon0312/academy_python
/day_1/009.py
246
3.78125
4
def greet(n): return '\nHello, Bioinformatics'*n while True: enter = input('enter the function : ') if enter == 'nope': break elif enter == 'greet': n = input('enter the number : ') print(greet(int(n)))
9393aeafd20dc95893ad4aa1b24a6cdfec5dffee
ljwon0312/academy_python
/week_1_class/basic_loop_0.py
252
3.984375
4
n = '' while True: a = input('Enter a number : ') try: int(a) n += a+' ' except: if a == 'done': print(n) break else: print('Please enter a number') continue
4e364c490dbbc6e102468a757d5a0ddad960bf98
ljwon0312/academy_python
/week_1_class/basic_string_2.py
131
3.953125
4
string = input('Enter the string : ').upper() character = input('Enter the character : ').upper() print(string.count(character))
0868734287f3560b176daac0e4cc4d69f2c5c1b6
ljwon0312/academy_python
/day_1/012.py
130
3.8125
4
def fact(n): t=1 while n>0: t*=n n-=1 return t ii = int(input('enter a number : ')) print(fact(ii))
87ea652c2a9d355662fea1da16ad8e9bb3b8e4b7
ljwon0312/academy_python
/day_1/005.py
171
4.0625
4
num1=21 if num1%3==0 and num1%7==0: print('num1은 3과 7의 배수') elif num1%7==0: print('num1은 7의 배수') elif num%3==0: print('num1은 3의 배수')
71adad2d321dbfdd3a189114c09bb8440317a4f3
ljwon0312/academy_python
/day_1/010.py
192
3.734375
4
def mySum(a,b): return int(a)+int(b) while True: ch = input('enter a pair of number : ') try: print(mySum(ch.split(',')[0], ch.split(',')[1])) except: break
f3cbe0c0e1d8b7848bdc2d184ebef31ddeef8ff7
ljwon0312/academy_python
/week_1_class/basic_string_1.py
115
3.96875
4
string = input('Enter the string : ') character = input('Enter the character : ') print(string.count(character))
b0e4478ce8923befde74762649b3f12e6a02d3fa
ljwon0312/academy_python
/week_1_class/basic_list_1.py
81
3.65625
4
string = input('enter the string : ') sl = string.split() sl.sort() print(sl)
0342319476500cd20e47fc7eab0ce518fdcaa02a
uhdang/codeforce
/141A_Amusing_Joke_cpp/main.py
244
3.5625
4
# print("YES" if sorted(list(input()) + list(input())) == sorted(list(input())) else "NO") # s,i=sorted,input;print('YNEOS'[s(i()+i())!=s(i())::2]) # s, i = sorted, input # foo = 'YNEOS' # print('YNEOS'[True::2]) # print('YNEOS'[False::2])
37425fe3f12e51ee7c5335d6f38b384c5fc4b7d7
launis/areadata
/pfa_fit.py
1,092
3.53125
4
def pfa_fit(X, n_features, n_components): """ Principal feature analysis exploits the structure of the principal components of a set of features to choose the principal features args: X: scaled dataframe n_features: demanded set of features returns: list of selected f...
bc1923f362aab1b596318441b89347075e04e956
launis/areadata
/supportfunctions.py
920
3.9375
4
def add_zeros(element): """This changes the format of postcodes to string with the needed zeros Args: element: individual row from apply codes Returns: parameter postcode value with zeros """ #postinumeroihin etunollat jos on ollut integer elem...
dda9ec732dae50a799100b0f9e741bba70e81513
alfyes/kata01_agiles
/Estadisticas.py
697
3.5
4
class Estadisticas: def calcular(self, cadena): if cadena == "": return [0, None, None, None] elif "," in cadena: numeros = cadena.split(",") minimo = int(numeros[0]) maximo = int(numeros[0]) promedio = 0 for num in numeros: ...
785e8acc51e804363ffe2cd222748b5b5f13ad01
FahidLatheef/Algorithmic-Toolbox
/Week 2/2.6-fibonacci_sum_last_digit.py
361
3.625
4
def fibonacci_sum_ll(n): fib_lis = dict() for i in range(n+1): if (i <= 1): fib_lis[i] = i else: fib_lis[i] = fib_lis[i-2] + fib_lis[i-1] return fib_lis sum_ld = [] for i in range(60):#60 reps found d = fibonacci_sum_ll(i) sum_ld.append(sum(d.values())%10) n...
58e5c687708fa2abcc01823d1971aa25c3489e64
FahidLatheef/Algorithmic-Toolbox
/Week 2/2.8-fibonacci_sum_squares.py
407
3.859375
4
def fibonacci_sum(n): fib_lis = [] for i in range(n+1): if (i <= 1): fib_lis.append(i) else: fib_lis.append(fib_lis[i-2] + fib_lis[i-1]) return fib_lis sum_ld = [] for i in range(30): #By trial and error found 30 reps sum_ld.append(sum(i**2 for i in fibonacci_sum...
42e4b07ec490d33ecd010cb26ace594049692ef9
M-Pepper/CyOOC-Python
/error_handling.py
840
3.953125
4
#!/usr/bin/env python3 import random '''print('begin') try: with open('dne.txt', 'r') as whatever: pass print(1/0) except ZeroDivisionError as ZeroErr: print(ZeroErr) print('you tried to divide by zero you goof') except FileNotFoundError as FileErr: print(FileErr) print('you tried to o...
39c12880e8ca7d956e3fef4c78ee3fa37576213c
M-Pepper/CyOOC-Python
/adhoc-activities/logic/check.py
1,166
3.640625
4
#!/usr/bin/env python3 import itertools import unittest import random import platform import deliverable as student version = platform.python_version().split('.') if int(version[0]) < 3 or int(version[1]) < 6: def choices(population,k=1): return [random.choice(population) for _ in range(k)] random.cho...
7c5914946a491aab81d6bde27150d0d6a2aab143
M-Pepper/CyOOC-Python
/adhoc-activities/logic/deliverable.py
440
3.828125
4
#!/usr/bin/env python3 # Validate the given 5 digit product code (as a string) according to the following rules (return True if it's valid, otherwise False): # The codes use the digits 0, 1, 2, 3, and 4, and no others. # Each digit occurs exactly once in any code. # The second digit has a value exactly twice that of t...
a17cf7b84d59a9ae8c1d5c157355d431fecb832d
M-Pepper/CyOOC-Python
/objects_class.py
1,457
3.9375
4
#!/usr/bin/env python3 import random '''class MyClass: class_attribute = 5 var = MyClass() print(var.class_attribute) var.class_attribute = 10 var2 = MyClass() print(var2.class_attribute)''' '''class Employee: def whatever(): #Method definition pass def __init__(self,last,first): #Special Metho...
2923de5e2d0597b3365d453d570adab84da62814
Set4now/python_scripts
/file/backup.py
578
3.828125
4
import os import sys source_file=raw_input("Enter the path of the file: ") target_file=raw_input("Enter the backup filename with absolute path: ") if source_file == "" or target_file == "": print sys.argv[0] if sys.argv[2] == "abc" or sys.argv[3] == "xyz": print "Please enter the file names in user promt or on co...
5a4cb374a31417aae54a0afbbfa0f260b564387f
Set4now/python_scripts
/excercise/ex13.py
207
3.53125
4
a = [1, 2, 3, 4] print 'length ' + '---> ' + str(len(a)) print 'range is ' + str(range(len(a))) sum = 0 mul = 1 for i in a: sum += i mul = mul * i print sum print mul a.sort(reverse=True) print a[0]
473a33cdf1e3d0b3ec1e427a7fe20142559d9aab
Set4now/python_scripts
/class/inheritence.py
713
3.6875
4
class Employee: def __init__(self, first, last, pay): self.first = first self.last = last self.pay = pay self.email = first + '.' + last + '@example.com' def fullname(self): return '{0} {1}'.format(self.first, self.last) # creating instances emp_1 = Employee('suman', 'deb', 1000000) emp_2...
8f5a9bfdffca3ef69be2e280f3ae486035b677cb
Set4now/python_scripts
/excercise/dic/ex1.py
716
4.0625
4
#def sorting(dicts): # sorted(dicts.values()) # return dicts #print sorting({"first" : 1, "second" : 2, "fourth" : 4, "third" : 3}) dict = {"first" : 1, "second" : 2, "fourth" : 4, "third" : 3} sorted_inc = sorted(dict.values()) print sorted_inc sorted_rev = sorted(dict.values(), reverse=True) print sorted_rev...
a559e1c8888ba0b35368684da3d4a1425f12ea42
Set4now/python_scripts
/excercise/dic/ex2.py
87
3.703125
4
def dict(num): d = {} for i in range(num): d[i] = i*i return d print dict(5)
829c3d99738a516029ce6afad9fb0059af7731c1
Lucush/my-first-blog
/hello.py
413
3.796875
4
mena = [] def pozdrav(): meno = input('Ako sa volas? ') mena.append(meno) print('Ahoj,', meno) if meno == 'Lucia': print('To si ty,', meno) else: print('Teba nepoznam!') dalsi = True while dalsi: pozdrav() odpoved = input('Este raz?') if odpoved.lower() in ['ano','hej','yes']: dalsi = True else: ...
a59a7582cdaf49889f219f79d050579f4075fd3e
orange-404/securitytestdemo
/cmdb/practice1.py
1,348
3.734375
4
#-*-coding:utf-8-*- from cmdb import commons class Student: classroom = '101' address = 'beijing' def __init__(self, name, age): self.name = name self.age = age def print_age(self): print('%s: %s' % (self.name, self.age)) class Ground(Student): def __init__(self, name, age...
c8a92111a0771eea9ed777ad5303a4f86d013fef
Ruochen-Wang/leetcode_prac
/062_uniquePaths.py
411
3.671875
4
dp_dict = {} def uniquePaths(m: int, n: int) -> int: if m == 1 or n == 1: return 1 if (m,n) in dp_dict: return dp_dict[(m,n)] elif (n,m) in dp_dict: return dp_dict[(n,m)] else: temp = uniquePaths(m,n-1) + uniquePaths(m-1,n) dp_dict[(m,n)] = temp dp_dict[...
3e62658cf22ed31c94fc687b665a8974171a2193
Ruochen-Wang/leetcode_prac
/014_longestCommonPrefix.py
651
3.9375
4
from typing import List def longestCommonPrefix(strs: List[str]) -> str: if len(strs) == 0: return "" elif len(strs) == 1: return strs[0] elif len(strs) == 2: shorter = len(strs[0]) if (len(strs[0]) < len(strs[1])) else len(strs[1]) i = 0 while i < shorter and strs[0...