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 |
|---|---|---|---|---|---|---|
3804829c4fbc476df069e3b6da3cb07448fb5c5c | MHagarGIS/FieldCalculator-repo | /FormatAddress.py | 1,182 | 3.625 | 4 | # Created by: MHagarGIS
# For: GEOG499
# Title: ArcMap Field Calculator Address Formatter in Python
#
#Converting street type to proper format
def converttype(oldtype): #Define function converttype that accepts argument oldtype
oldtype = oldtype.title() #Use the .title() function to make first letter upper... |
343f2a409f4c5c1919f33ac5587298bc4b773d92 | guzey/guzey.github.io1 | /evolution/evolution.py | 7,153 | 3.796875 | 4 | ### PROBLEM: NEED TO MAKE A TON OF ad hoc ASSUMPTIONS ABOUT e.g. FITNESS ADVANTAGES
# don't think there's a solution tho
# done:
# selection
# meiosis
# nucleotide mutation
# gene duplication
# to do:
# gene --> function map (genes encode body part, right after initial values)
# then there's a neural net... |
d322443df962b9c0c3dbb8528bacfac3eabee165 | BbsonLin/flask-filer | /flask_filer/exceptions.py | 381 | 3.5 | 4 |
class InvalidPathError(ValueError):
"""
Exception raised when a path is not valid.
"""
code = 'invalid-path'
template = 'Path {0.path!r} is not valid.'
def __init__(self, message=None, path=None):
self.path = path
message = self.template.format(self) if message is None else mes... |
c53a33b3173fce4c381c7247e52484a6e7051843 | Basavarajrp/Learning-Python | /dict.py | 6,138 | 4.59375 | 5 | #-------------------Declaring the dict in python and accessing the values using key:------
phonebook={
"Basu":2424,
"Pinki":2244,
"Punter":4422
}
print(phonebook["Pinki"])
print()
#------------------Creating the dict with comprehesion way:--------------------------------
squares = {i:i*i for i in ran... |
9aadfd406f23d5c142029148835f4e1b60a80f70 | aguestuser/flupy | /fluent_python/french_deck.py | 1,618 | 3.671875 | 4 | """French Deck module"""
import collections
from typing import NamedTuple, List, Dict, Iterable, Iterator, cast
Card = NamedTuple('Card', [('rank', str), ('suit', str)])
class FrenchDeck:
ranks: List[str] = [str(n) for n in range(2, 11)] + list('JQKA')
suits: List[str] = 'spades diamonds clubs hearts'.split(... |
bc23256e91744036df92accf23c5dace00f9afe0 | MakavchikDenis/PythonTask_3.2.py | /CollectionClass/ClassInventory.py | 2,619 | 3.859375 | 4 |
class Inventory:
procent=10 #ежегодный процент амортизации
def __init__(self,nameInventory,year,pricePurch):
self.nameInventory=nameInventory
self.year=year
self.pricePurch=pricePurch
self.price=Inventory.funCountingPrice(self)
def funCountingPrice(self):
return se... |
074902903bf0036d263189463cd5728499909984 | CoaleryStudy/PythonStudy | /Defaults/_008.py | 413 | 3.703125 | 4 | i = 1
while i < 11: # While 루프
print("Hello", i)
i += 1
res = 0
while True: # 무한 루프
print("현재 값들의 합 : ", res)
hi = int(input("값을 입력해주세요! : "))
if hi == 0:
break
res += hi
py = "파이썬"
for s in py: # for 루프
print(s)
for col in range(2, 10): # 구구단
for row in range(1, 10):
... |
e150c09ac72e6b10cd0b848e2ae3eef8a277d58a | CoaleryStudy/PythonStudy | /Defaults/_036.py | 136 | 3.90625 | 4 | import string
line = ' ' + input() + ' '
for unit in string.punctuation:
line = line.replace(unit, ' ')
print(line.count(' the ')) |
7017c9cdd9f32fe4364ca6e7ad420a96bd0ea207 | CoaleryStudy/PythonStudy | /Defaults/_009.py | 425 | 3.921875 | 4 | primes = [2, 3, 5, 7, 11]
for p in primes:
print(p)
print("Length :", len(primes))
primes.append(13)
print(primes)
hi = primes.copy()
hi.append(17)
print(hi, primes)
list1 = [1, 2, 3]
list2 = list((4, 5, 6))
print(list1 + list2)
print(list1 * 3)
list1.extend(list2)
print(list1)
list3 = [5, 2, 4, 1, 3]
list4 =... |
972dda604d209f412c2506c5aa9a7748348485cd | Wenbo11/hybrid-cp-rl-solver | /src/problem/portfolio/environment/portfolio.py | 4,769 | 3.5 | 4 | import random
class Portfolio:
def __init__(self, n_item, capacity, weights, means, deviations, skewnesses, kurtosis, moment_factors):
"""
Create an instance of the 4-moment portfolio optimization problem
:param n_item: number of items to add (or not) in the portfolio
:param capaci... |
5391c451c33726ceb1f9b64f9d369f8e1a14815f | 654060747/Reptile_pbs | /pbs-master/app/haicj/test.py | 467 | 3.59375 | 4 | import codecs
# 写 csv
def write_csv(data):
file = "a.csv"
with codecs.open(file,'a',encoding='utf-8') as f:
f.write(data+"\n")
f.close()
string = "(大众 帕萨特 1.8T 手动 舒适版 2005款)"
data = string.split("(")[1].split(")")[0].split(" ")
print("品牌::"+data[0])
print("车系::"+data[1])
cx_all = ""
for x in range(2,len(da... |
41fdc8a89fb3e7ecdcfaec78e5c668fc0e6e4e80 | JoshuaShin/A01056181_1510_assignments | /A1/random_game.py | 2,173 | 4.28125 | 4 | """
random_game.py.
Play a game of rock paper scissors with the computer.
"""
# Joshua Shin
# A01056181
# Jan 25 2019
import doctest
import random
def computer_choice_translator(choice_computer):
"""
Translate computer choice (int between 0 - 2 inclusive) to "rock", "paper", or "scissors".
PARAM choic... |
20236a7f08ab85afc1f6195e470c80b78cf65365 | JoshuaShin/A01056181_1510_assignments | /A5/q02.py | 644 | 3.8125 | 4 | """
q02.py
Calculate greatest common divisor between two numbers.
"""
# Joshua Shin
# A01056181
# April 9th 2019
import doctest
def gcd(a: int, b: int) -> int:
"""
Calculate greatest common divisor.
PRE-CONDITION a must not be 0
PRE-CONDITION b must not be 0
RETURN greatest common divisor be... |
5d14aa9005bb6f82e2309d3343ebbc5488589e35 | JoshuaShin/A01056181_1510_assignments | /A5/q01.py | 1,068 | 4.0625 | 4 | """
q01.py
Calculate the sum of all prime within given upper bound.
"""
# Joshua Shin
# A01056181
# April 15th 2019
import doctest
import math
def sum_of_primes(upperbound: int) -> int:
"""
Calculate the sum of all prime within given upper bound.
PRE-CONDITION upperbound must be larger than 0
RE... |
8de995f926ddb6ff14f587ff069eb391c12118d8 | JoshuaShin/A01056181_1510_assignments | /A1/lotto.py | 716 | 3.8125 | 4 | """
lotto.py.
Return length 6 unique sorted list of integers.
"""
# Joshua Shin
# A01056181
# Jan 25 2019
import random
def number_generator():
"""
Build length 6 unique sorted list of integers.
RETURN length 6 unique sorted integer list
"""
lotto_range = [1, 2, 3, 4, 5, 6, 7, 8, 9,
... |
59830d6c27810a1c223eb12700126bd3edb6c65b | weiyinfu/learnTensorflow | /tensorflow_models/166-mnist-RNN.py | 4,114 | 4.15625 | 4 | """ Recurrent Neural Network.
最终精确度高达: 0.992188
A Recurrent Neural Network (LSTM) implementation example using TensorFlow library.
This example is using the MNIST database of handwritten digits (http://yann.lecun.com/exdb/mnist/)
Links:
[Long Short Term Memory](http://deeplearning.cs.cmu.edu/pdfs/Hochrei... |
8d35ef9ebbce00986a3b8d0a0e21ea752602b0b4 | gochman/advent_of_code_19 | /day10/day10.py | 2,339 | 3.734375 | 4 | import math
class BoardUtilities:
def __init__(self):
with open(r"C:\Yoav's Disk\AdventOfCode\2019\day10\input.txt") as f:
self.raw_content = f.readlines()
self.raw_content = [x.strip() for x in self.raw_content]
self._board = []
for line in self.raw_content:
... |
768ccca94902952995f3b0631707aef4cd45a554 | kory0005/python-lab-9 | /task2.py | 344 | 3.796875 | 4 | import csv
fileName = input('Enter a file name: ')
def readTextFile(name):
fin = open(name, "r")
lc = 1
moveOn = 1
while (moveOn == 1):
for line in fin:
c = line[-1]
# print(line)
print(list(line))
moveOn = 0
lc = lc + 1
fin.close()... |
22899b8f8a909a0ea2abd444750a4a00ea4dcbc9 | gusrochab/data-structure-algorithms | /Data Structures/Blockchain/linked_list.py | 1,691 | 3.96875 | 4 | from node import Node
class Linked_list():
def __init__(self):
self.head = None
def __str__(self):
cur_head = self.head
out_string = ""
while cur_head:
out_string += str(cur_head.value) + " -> "
cur_head = cur_head.next
return out_string
def... |
b5ac4abea44139ef6c10455d5a558046f2d1b2e9 | slowmoh/urban_samples | /python/progress_bar/progress_bar.py | 935 | 3.5625 | 4 | # -*- coding: utf-8 -*-
"""
Created on Tue Dec 20 20:33:09 2016
@author: Ben
Just a simple attempt to get a progress bar
"""
import time
import sys
def progress(curr, end):
sys.stdout.write("\rDoing thing " + str(curr) + " out of " + str(end))
sys.stdout.flush()
sys.stdout.write("\rDoing thing ")
sys... |
e42ebaa9bded8df2b661ea483ac1aa1ab06ef84c | rdnaskelAvoramoK/homework | /home work#2/fizz_buzz.py | 426 | 3.78125 | 4 | print('input fizz number')
fizz = int(input())
print('input buzz number')
buzz = int(input())
print('input last number for calculation')
num = int(input())
list_f_z=""
for i in range(1, num+1):
if not i%fizz and i%buzz:
list_f_z += "F "
elif not i%buzz and i%fizz:
list_f_z += "B "
elif not i... |
57208923bf8ae03a9e6f32aaab9caa47efe1b531 | rdnaskelAvoramoK/homework | /home_work#30/score.py | 3,120 | 3.625 | 4 | class Product:
def __init__(self, name, cost, discount=20.0):
self.name = name
self.cost = cost
self.discount = discount
def discount_off(self):
discount = ((100 - self.discount) / 100)
return discount
def price_off(self):
return self.cost
cl... |
302e6783e89ddf03693dd26f1ebef042e60610a5 | DlyanRutter/play-pig | /pig_game.py | 8,676 | 3.6875 | 4 | from functools import update_wrapper
from collections import defaultdict
import random
import math
def decorator(d):
"Make function d a decorator: d wraps a function fn."
def _d(fn):
return update_wrapper(d(fn), fn)
update_wrapper(_d, d)
return _d
@decorator
def memo(f):
"""Decorator that ... |
0ca8c1dc04f5e98a3d08b588e2a4c5903e7f61da | amit-kr-debug/CP | /Geeks for geeks/Heap/Sorting Elements of an Array by Frequency.py | 2,697 | 4.125 | 4 | """
Given an array A[] of integers, sort the array according to frequency of elements. That is elements that have higher
frequency come first. If frequencies of two elements are same, then smaller number comes first.
Input:
The first line of input contains an integer T denoting the number of test cases. The descriptio... |
b264b3ddb04fef9d689949fae125b00c8b3d6a9d | amit-kr-debug/CP | /Geeks for geeks/Dynamic Programming/Target sum.py | 1,788 | 4 | 4 | """
Count the number of subset with a given difference -- similar
You are given a list of non-negative integers, a1, a2, ..., an, and a target, S. Now you have 2 symbols + and -. For
each integer, you should choose one from + and - as its new symbol.
Find out how many ways to assign symbols to make sum of integers eq... |
25250f8b7d247e2657b1e99ced5bdc0cee48a521 | amit-kr-debug/CP | /Geeks for geeks/array/Missing number in array.py | 1,195 | 3.78125 | 4 | """
Given an array C of size N-1 and given that there are numbers from 1 to N with one element missing, the missing number
is to be found.
Input:
The first line of input contains an integer T denoting the number of test cases. For each test case first line contains
N(size of array). The subsequent line contains N-1 ar... |
b88aa4030ca4dc30cd8c22d41e48ea48d7e162ea | amit-kr-debug/CP | /Geeks for geeks/array/Longest consecutive subsequence.py | 1,151 | 3.9375 | 4 | """
Given an array arr[] of positive integers. Find the length of the longest sub-sequence such that elements in the subsequence are consecutive integers, the consecutive numbers can be in any order.
Input:
The first line of input contains T, number of test cases. First line of line each test case contains a single in... |
aabfac917714563c628ac6b39c2c5b9cf730a99c | amit-kr-debug/CP | /LeetCode/Merge Intervals.py | 1,009 | 4.03125 | 4 | """
56. Merge Intervals
Given an array of intervals where intervals[i] = [starti, endi], merge all overlapping intervals, and return an array of the non-overlapping intervals that cover all the intervals in the input.
Example 1:
Input: intervals = [[1,3],[2,6],[8,10],[15,18]]
Output: [[1,6],[8,10],[15,18]]
Explanat... |
f759b9ed999d0c0f7d984132db84587ef7df0044 | amit-kr-debug/CP | /Geeks for geeks/array/Median In a Row-Wise sorted Matrix.py | 764 | 3.796875 | 4 | """
We are given a row wise sorted matrix of size r*c, we need to find the median of the matrix given. It is assumed that r*c is always odd.
Input:
The first line of input contains an integer T denoting the number of test cases. Each test case contains two integers r and c, where r is the number of rows and c is the n... |
f83e2beb26b7d9a8652d5c6fac6efb6b62248bdd | amit-kr-debug/CP | /CodeChef/june challenge - 2020/The Tom and Jerry Game! - EOEO.py | 2,018 | 3.59375 | 4 | """
As usual, Tom and Jerry are fighting. Tom has strength TS and Jerry has strength JS. You are given TS and your task is
to find the number of possible values of JS such that Jerry wins the following game.
The game consists of one or more turns. In each turn:
If both TS and JS are even, their values get divided by ... |
e2fb43f0392cd69430a3604c6ddcf3b06425b671 | amit-kr-debug/CP | /Geeks for geeks/array/sorting 0 1 2.py | 1,329 | 4.1875 | 4 | """
Given an array of size N containing only 0s, 1s, and 2s; sort the array in ascending order.
Example 1:
Input:
N = 5
arr[]= {0 2 1 2 0}
Output:
0 0 1 2 2
Explanation:
0s 1s and 2s are segregated
into ascending order.
Example 2:
Input:
N = 3
arr[] = {0 1 0}
Output:
0 0 1
Explanation:
0s 1s and 2s are segregated
i... |
eaa50f1a239748e42e38ac0cb9eabe99784c126f | amit-kr-debug/CP | /RobinHood/infytq.py | 750 | 3.609375 | 4 | # cook your dish here
def check(n1):
return n1 == n1[::-1]
def getsum(num):
n1 = int(num)
flag = 1
numgr = 100000000000
numsm = 0
while flag == 1: # for finding palindrome greater than the num
if check(str(n1 + 1)):
flag = 0
numgr = n1 + 1
break
... |
6069283e9388e6d1704f649d14b84e4a288f8d86 | amit-kr-debug/CP | /Cryptography and network security/lab - 2/Vigenere Cipher encrypt.py | 669 | 4.21875 | 4 | def encrypt(plain_text, key):
cipher_text = ""
# Encrypting plain text
for i in range(len(plain_text)):
cipher_text += chr(((ord(plain_text[i]) + ord(key[i]) - 130) % 26) + 65)
return cipher_text
if __name__ == "__main__":
# Taking key as input
key = input("Enter the key:")
# Taki... |
4d24ec86497d6380887a56b5093e4c7da184a4c7 | amit-kr-debug/CP | /Geeks for geeks/Tree/Preorder Traversal.py | 3,072 | 4.21875 | 4 | """
Given a binary tree, find its preorder traversal.
Example 1:
Input:
1
/
4
/ \
4 2
Output: 1 4 4 2
Example 2:
Input:
6
/ \
3 2
\ /
1 2
Output: 6 3 1 2 2
Your Task:
You just have to complete the function preorder() which takes the root node of the tr... |
027c6932e16cc43c2d81d5af1077547b489d2917 | amit-kr-debug/CP | /Geeks for geeks/array/Minimum element in a sorted and rotated array.py | 1,210 | 3.65625 | 4 | """
A sorted array A[ ] with distinct elements is rotated at some unknown point, the task is to find the minimum element in it.
Expected Time Complexity: O(Log n)
Input:
The first line of input contains a single integer T denoting the number of test cases. Then T test cases follow. Each test case consist of two line... |
3d6374a2d3a71afed34cc9d918829dc1f806ae50 | amit-kr-debug/CP | /LeetCode/15. 3Sum.py | 1,370 | 3.59375 | 4 | """
Given an integer array nums, return all the triplets [nums[i], nums[j], nums[k]] such that i != j, i != k, and j != k, and nums[i] + nums[j] + nums[k] == 0.
Notice that the solution set must not contain duplicate triplets.
Example 1:
Input: nums = [-1,0,1,2,-1,-4]
Output: [[-1,-1,2],[-1,0,1]]
Example 2:
Input... |
b8370b96f0b25819243c624e6c91dd0602af9200 | amit-kr-debug/CP | /Geeks for geeks/Dynamic Programming/Coin Change - maximum ways.py | 1,554 | 3.71875 | 4 | """
Given a value N, find the number of ways to make change for N cents, if we have infinite supply of each of
S = { S1, S2, .. , SM } valued coins.
Example 1:
Input:
n = 4 , m = 3
S[] = {1,2,3}
Output: 4
Explanation: Four Possible ways are:
{1,1,1,1},{1,1,2},{2,2},{1,3}.
Example 2:
Input:
n = 10 , m = 4
S[] ={2,5... |
c67c800a679c33ac609d50a2022bc8a31623502c | amit-kr-debug/CP | /RobinHood/advantage round infytq 1.py | 966 | 3.828125 | 4 | def mergeSlide(arr:list):
arr.sort()
print(arr)
countSequence = 0
tempSequence = 0
countRepeat = 0
tempRepeat = 0
flagRepeat = True
flagSequence = True
for i in range(1, len(arr)):
if arr[i-1] + 1 == arr[i]:
if flagRepeat:
tempRepeat = 0
... |
4602c2628ae813e68f997f36b18d270316e42a43 | amit-kr-debug/CP | /hackerrank/Merge the Tools!.py | 1,835 | 4.25 | 4 | """
https://www.hackerrank.com/challenges/merge-the-tools/problem
Consider the following:
A string, , of length where .
An integer, , where is a factor of .
We can split into subsegments where each subsegment, , consists of a contiguous block of characters in . Then, use each to create string such that:
The c... |
024d73d02c3c36dd6d07e1ed80b1b1433fab8e6c | amit-kr-debug/CP | /CodeChef/august long challenge - 2020/Smallest KMP - SKMP.py | 2,824 | 3.875 | 4 | """
Chef has a string S. He also has another string P, called pattern. He wants to find the pattern in S, but that might be impossible. Therefore, he is willing to reorder the characters of S in such a way that P occurs in the resulting string (an anagram of S) as a substring.
Since this problem was too hard for Chef,... |
451bf94129d98c22c93c060d2f5e92d0f2522672 | amit-kr-debug/CP | /Geeks for geeks/Heap/k closest elements.py | 1,743 | 3.875 | 4 | """
Given a sorted array of numbers, value K and an index X in array, find the K closest numbers in position to X in array.
Example: Let array be 11 23 24 75 89, X be 24 and K be 2. Now we have to find K numbers closest to X that is 24. In this
example, 23 and 75 are the closest 2 numbers to 24.
Note: K should be eve... |
38ae00d04139fa2b0054828e80f26cfc02acedd6 | 1OSK/pigga | /дз/2.34.py | 208 | 3.921875 | 4 | V1=float(input("Скорость первого автомобиля "))
V2=float(input("Скорость второго автомобиля "))
S=float(input("Расстояние "))
V=V1+V2
T=S/V
print(T) |
57d8a30f08e8f538c8cfadc23a6674675636e6dd | 1OSK/pigga | /дз23.11.2020/4.py | 242 | 3.953125 | 4 | x = int(input("x"))
y = int(input("y"))
if x == 0 and y == 0:
print("лежит на обеих осях")
elif x > 0 and y > 0:
print("1")
elif x < 0 and y < 0:
print("3")
elif x > 0 and y < 0:
print("4")
else:
print("2") |
182c7263d4e5df5a42764515aaf5854cbacf841e | racterub/yzu_python | /python/static/exercise10/3.py | 943 | 3.625 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
# @Date : 2019-12-12 10:28:51
# @Author : Racter Liu (racterub) (racterub@gmail.com)
# @Link : https://racterub.io
# @License : MIT
import csv
#建立空 list
def listCreate(n):
data = []
for i in range(n):
data.append([0])
return data
#從 2012/01/22... |
94ca9916db1aa81a0d97231c319253e0ff55e198 | racterub/yzu_python | /python/static/exercise4/1.py | 424 | 3.5625 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
# @Date : 2019-10-23 18:49:22
# @Author : Racter Liu (racterub)
# @Mail : racterub@gmail.com
# @Link : https://racterub.io
# @License : MIT
from math import sqrt
for i in range(1, 1000001):
root = int(sqrt(i))
if (root*root == i):
data = i+268
... |
38a1d6273bd31c27b77d7497ddb8e7f1464424fe | racterub/yzu_python | /python/static/exercise4/2.py | 397 | 3.5625 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
# @Date : 2019-10-23 19:10:24
# @Author : Racter Liu (racterub)
# @Mail : racterub@gmail.com
# @Link : https://racterub.io
# @License : MIT
ROW = 10
print("Printing pattern C:")
for i in range(ROW):
print(' '*i, end='')
print('*'*( ROW-i))
print("Print... |
804aae6434be67922291464d7771417abe36f440 | racterub/yzu_python | /python/static/exercise2/1.py | 581 | 3.578125 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
# @Date : 2019-10-13 12:15:14
# @Author : Racterub (Racter Liu) (racterub@gmail.com)
# @Link : https://racterub.io
# @License : MIT
x = int(input('x: ')) #測資: 1
y = int(input('y: ')) #測資: 2
z = int(input('z: ')) #測資: 3
_avg = (x+y+z)/3
_min = x
if y < _min:
... |
d5f87dda4e33427f9383d021d65a87d99d16c9d9 | racterub/yzu_python | /python/static/exercise5/2.py | 805 | 3.546875 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
# @Date : 2019-10-29 19:25:36
# @Author : Racter Liu (racterub)
# @Mail : racterub@gmail.com
# @Link : https://racterub.io
# @License : MIT
'''
IP 用點來分有四個部分,分別是 A class, B class, C class, D class,
A class 和 B class 指定要為 140.138
C class 和 D class 指定要 0 <= number ... |
f7ce9ae1f13ac6aa6012f85961bf778fc5378e1e | yirua/text_reading | /Module_functions.py | 991 | 4.09375 | 4 |
def check_line_length(lines):
check_col_is_7 = True
line_index = 1
for line in lines:
if (len(line) != 7):
check_col_is_7 = False
print "The line with not 7 columns: "
print "line_index {} : {}".format(line_index, line)
#else:
# print "The ... |
234be2c48ef43ab2a3734d31043818fcd846dcc4 | vishnu2914/Gramener-Product-Team | /Product team Solutions.py | 774 | 3.921875 | 4 |
# coding: utf-8
# # 1. Given two lists L1 = ['a', 'b', 'c'], L2 = ['b', 'd'], find common elements, find elements present in L1 and not in L2?
# In[ ]:
# Import numpy
import numpy as np
# In[2]:
L1 = ['a', 'b', 'c']
L2 = ['b', 'd']
# In[3]:
# Common_elements
common_elements = np.intersect1d(L1, L2)
# In... |
49b757c7240082f56b8fdf0bb9ea301103a11633 | Queena-Zhq/leetcode_python | /53.maximum-subarray.py | 1,107 | 3.515625 | 4 | #
# @lc app=leetcode id=53 lang=python3
#
# [53] Maximum Subarray
#
# https://leetcode.com/problems/maximum-subarray/description/
#
# algorithms
# Easy (44.77%)
# Likes: 6927
# Dislikes: 318
# Total Accepted: 904.6K
# Total Submissions: 2M
# Testcase Example: '[-2,1,-3,4,-1,2,1,-5,4]'
#
# Given an integer array ... |
8449a17a67a84ac0f1bf5e6ddca5c9a56e006b2a | Queena-Zhq/leetcode_python | /49.group-anagrams.py | 1,135 | 3.75 | 4 | #
# @lc app=leetcode id=49 lang=python3
#
# [49] Group Anagrams
#
# https://leetcode.com/problems/group-anagrams/description/
#
# algorithms
# Medium (49.87%)
# Likes: 3095
# Dislikes: 166
# Total Accepted: 621.5K
# Total Submissions: 1.1M
# Testcase Example: '["eat","tea","tan","ate","nat","bat"]'
#
# Given an ... |
726fef0f48095d96d4f202b1b9e4e89f1791edd2 | Queena-Zhq/leetcode_python | /844.backspace-string-compare.py | 2,113 | 3.828125 | 4 | #
# @lc app=leetcode id=844 lang=python3
#
# [844] Backspace String Compare
#
# https://leetcode.com/problems/backspace-string-compare/description/
#
# algorithms
# Easy (46.67%)
# Likes: 1449
# Dislikes: 75
# Total Accepted: 189.4K
# Total Submissions: 407.4K
# Testcase Example: '"ab#c"\n"ad#c"'
#
# Given two s... |
297a485dbba01cb14a8849b5c8220f3059a0d0a0 | Queena-Zhq/leetcode_python | /107.binary-tree-level-order-traversal-ii.py | 1,957 | 4.03125 | 4 | #
# @lc app=leetcode id=107 lang=python3
#
# [107] Binary Tree Level Order Traversal II
#
# https://leetcode.com/problems/binary-tree-level-order-traversal-ii/description/
#
# algorithms
# Easy (51.00%)
# Likes: 1380
# Dislikes: 208
# Total Accepted: 324.9K
# Total Submissions: 621.1K
# Testcase Example: '[3,9,2... |
2a07d75a18a765e6a38ecd22fdc30f9d9f4635f6 | Queena-Zhq/leetcode_python | /9.palindrome-number.py | 1,330 | 3.90625 | 4 | #
# @lc app=leetcode id=9 lang=python3
#
# [9] Palindrome Number
#
# https://leetcode.com/problems/palindrome-number/description/
#
# algorithms
# Easy (45.20%)
# Likes: 2059
# Dislikes: 1500
# Total Accepted: 848.7K
# Total Submissions: 1.8M
# Testcase Example: '121'
#
# Determine whether an integer is a palind... |
c6122c5c43a436364386c0085839c4f2c8c59d39 | rishav7037/intro-to-data-science-with-python | /assignment-03/question-13.py | 365 | 3.53125 | 4 | def answer_thirteen():
Top15 = answer_one()
Top15['PopEst'] = Top15['Energy Supply'] / Top15['Energy Supply per Capita']
Top15 = Top15['PopEst']
for i in range(len(Top15)):
country = Top15.keys()[i]
number = "{:,}".format((Top15.iloc[i]))
Top15.replace(Top15.iloc[i], number, inpl... |
e4257bd84246cba390d4635229e711296f7079af | LinkaSofia/Algoritmo-I---Python | /Aulas e Exercícios - 2018/25-04/feira_de_boi.py | 697 | 3.671875 | 4 | ttboi=0 #contador das notas
jovem=1000 #para saber qual boi é mais jovem
pesado=0
soma_geral=0
nome=(input('Informe o nome do boi: '))
while nome!='fim':
peso=float(input('Informe o peso do boi em KG: '))
idade=int(input('Informe a idade do boi em meses: '))
soma_notas=0
for i in range (6):
i=float(input('Informe... |
af6b5de148c6af4715d451e937c50c9a7b4bf253 | LinkaSofia/Algoritmo-I---Python | /Aulas e Exercícios - 2018/Primeira Lista De Exercícios/Exercicio4.py | 283 | 3.734375 | 4 | quant_tec=int(input('Informe a quantidade de pedaços de tecidos: '))
Sobra 1,65 de cada tececido
conta1=(1.65*quant_tec)
conta2=(conta1/1.87)
print('A quantidade de calças feitas é de: ', conta2)
#Cada calça utilizasse 1,87 já com os 15% de percas
#Sobra 1,65 de cada tececido
|
00a2c986bc88cd6e22c71ba2f6d056f9eec22a0e | LinkaSofia/Algoritmo-I---Python | /Aulas e Exercícios - 2018/URI/URI.py | 132 | 3.6875 | 4 | A, B=(input()).split()
A = int(A)
B = int(B)
if A % B == 0 or B % A == 0:
print('Sao Multiplos')
else:
print('Nao sao Multiplos')
|
0e6ecd5400cd38b2cc38691df4b0c982c4a6390f | LinkaSofia/Algoritmo-I---Python | /Aulas e Exercícios - 2018/Primeira Aula/meuprog3.py | 326 | 3.796875 | 4 | print('Meu terceiro programa em Python')
prc_prod=float(input('Informe o preço do produto: '))
jur=float(input('Infome o juro: '))
num_par=int(input('Informe o número de parcelas: '))
pr_jur=1+(jur/100)
vlr_juro=(pr_jur*prc_prod)
valor_parcela=(vlr_juro / num_par)
print('O valor das parcelas será de R$: ', valor_parcel... |
47e1601014dd3ff75fc1a4920611bb9bca075203 | LinkaSofia/Algoritmo-I---Python | /Aulas e Exercícios - 2018/22-04/fatorial.py | 66 | 3.546875 | 4 | n=int(input(""))
f=1
for i in range (0,n) :
f=f*(n-i)
print(f)
|
b293d21020614905d98f43851727a490918287e5 | LinkaSofia/Algoritmo-I---Python | /Aulas e Exercícios - 2018/Primeira Lista De Exercícios/Exercicio6.py | 280 | 3.765625 | 4 | Com_base=float(input('Informe o comprimento da base: '))
Com_aresta1=float(input('Informe o comprimento da aresta da direita: '))
Com_aresta2=float(input('Informe o comprimento da aresta da esquerda: '))
soma=(Com_base+Com_aresta1+Com_aresta2)
print('O perímetro é de: ', soma)
|
df11bc1e05545abc15b0e5c0f2bcbf74a4cc842e | pmartel/Sudoku | /BoxTest.py | 118 | 3.828125 | 4 | """ test how to get row.col from box"""
for b in range(9):
print('b',b)
print('row',(b//3)*3)
print('col',(b*3)%9)
|
3f7db7b6136a51178cd4f8203881b29e3b99760b | vishmango117/CP1404-Practicals | /Week 4/repeated_strings.py | 365 | 3.953125 | 4 |
cache_string = []
repeated_string = []
while True:
user_input = input("Enter String:")
if(user_input == ""):
break
if(user_input in cache_string):
repeated_string.append(user_input)
else:
cache_string.append(user_input)
if(not(repeated_string)):
print("No repeated strin... |
b5c45c728fffa1f3d96aa4460dabc5a5abd54b02 | andersraberg/HackerRankPython | /src/lists.py | 592 | 3.875 | 4 | if __name__ == '__main__':
N = int(input())
the_list = []
for i in range(N):
op = input().strip().split(" ")
if op[0] == "insert":
the_list.insert(int(op[1]), int(op[2]))
elif op[0] == "print":
print(the_list)
elif op[0] == "remove":
the_li... |
a1ac31f633ac496bd5f68f57a974de23930f9308 | guoyunfei0603/lemon11 | /class_3/14/review_if.py | 1,429 | 4.03125 | 4 | # -*- coding: utf-8 -*-
# @Time : 2020/3/27 16:41
# @Author : guoyunfei.0603
# @File : review_if.py
# 输入一个数字,判断能否整除2和3
# num = int(input("请输入一个数字:"))
# if num%2==0:
# if num%3==0:
# print("该数能整除2和3")
# else:
# print("能整除2但不能整除3")
# else:
# if num%3==0:
# print("能整除3但不能整除2")
... |
874702335cc16c1e60f0aa6653ee7bd145a0234c | guoyunfei0603/lemon11 | /class_3/23/class_except.py | 886 | 3.578125 | 4 | # -*- coding: utf-8 -*-
# @Time : 2020/3/23 23:45
# @Author : guoyunfei.0603
# @File : class_except.py
# 异常处理
# 第一种: try...except
# try:
# f = open('test_01.txt','a',encoding='utf-8')
# f.read('我们都一样')
# except Exception as e:
# print('****错误****',e)
# 第二种: try...except...finally
try:
f = op... |
a9ec757138eafbfde183925e66fd14cf1d1020a4 | mickeystone/Bitmsg | /base58.py | 1,228 | 3.90625 | 4 | """ base58 encoding / decoding functions """
alphabet = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz'
base_count = len(alphabet)
def encode(num):
""" Returns num in a base58-encoded string """
encode = ''
if (num < 0):
return ''
while (num >= base_... |
2b54892f2bf83098b34d4279bc5942c05cb7db1c | redreceipt/advent-2020 | /day9/solve.py | 969 | 3.609375 | 4 | def get_numbers(lines):
return [int(line.strip()) for line in lines]
def one(preamble_length):
for i, number in enumerate(numbers):
found = False
if i < preamble_length:
continue
for first_number in numbers[i - preamble_length:i]:
for second_number in numbers[i ... |
3080de8f78481c3c7560e662702f7715fcbc9174 | IrmaGC/Mision-05 | /Menu.py | 6,417 | 3.546875 | 4 | # encoding: UTF-8
# Autor: Irma Gómez Carmona
# Menú que permite elegir entre 7 opciones, 4 son dibujos
import math
import random
import pygame # Librería de pygame
# Dimensiones de la pantalla
ANCHO = 800
ALTO = 800
# Colores
BLANCO = (255, 255, 255) # R,G,B en el rango [0,255], 0 ausencia de color... |
f39b5bf8985d27b972d10dcc06671303c0ac4ed8 | rc2030/gitdemo | /gitdemon.py | 215 | 3.59375 | 4 | import sys
if len(sys.argv) < 3:
print('You must give two command line arguments.')
exit(1)
else
print('You have provided', len(sys.argv) - 1, 'command line arguments.')
print('They are: ',sys.argv[1:])
|
1af1fe79704106a2026f6783cf80d5cbbb17268c | rajathans/cp | /CodeChef/fctrl.py | 124 | 3.5625 | 4 | a = raw_input()
for da in range(int(a)):
f = int(raw_input())
i = 5
r = 0
while (f//i > 0):
r += f//i
i*=5
print r |
7b742399e68f9591dcb0154b50b187c58d6d4ce9 | canhetingsky/LeetCode | /Python3/73.set-matrix-zeroes.py | 929 | 3.625 | 4 | #
# @lc app=leetcode id=73 lang=python3
#
# [73] Set Matrix Zeroes
#
# @lc code=start
class Solution:
def setZeroes(self, matrix: List[List[int]]) -> None:
"""
Do not return anything, modify matrix in-place instead.
"""
row, column = [], []
for i in range(len(matrix)):
... |
e7e707856d241e685c50db43d830624019d30aad | canhetingsky/LeetCode | /Python3/102.binary-tree-level-order-traversal.py | 1,001 | 3.828125 | 4 | #
# @lc app=leetcode id=102 lang=python3
#
# [102] Binary Tree Level Order Traversal
#
# @lc code=start
# Definition for a binary tree node.
# class TreeNode:
# def __init__(self, x):
# self.val = x
# self.left = None
# self.right = None
class Solution:
def levelOrder(self, root: Tree... |
b4487e2f505fe30ec91776daf3c26c18f2067947 | Northwestern-CS348/assignment-3-part-2-uninformed-solvers-brndnwrd | /student_code_uninformed_solvers.py | 5,775 | 3.515625 | 4 |
from solver import *
class SolverDFS(UninformedSolver):
def __init__(self, gameMaster, victoryCondition):
super().__init__(gameMaster, victoryCondition)
def solveOneStep(self):
"""
Go to the next state that has not been explored. If a
game state leads to more than one unexplor... |
b912587a5ad3c58fc59cc09aaef76d2d2a215044 | hakbailey/advent-of-code-2019 | /day_3_part_1.py | 2,165 | 3.859375 | 4 | START = (0, 0)
with open("day_3_input.txt", "r") as f:
input = f.read().split('\n')
wire_1_path = input[0].split(',')
wire_2_path = input[1].split(',')
def all_coords_traveled(start_coords, wire_path):
all_coords = [start_coords]
for i, path in enumerate(wire_path):
new_coords = get_path_... |
efa3c5294a1274ba4c2133c34b6aaa32fb3ad590 | ayatullah-ayat/py4e_assigns_quizzes | /chapter-10_assignment-10.2.py | 921 | 4.125 | 4 | # 10.2 Write a program to read through the mbox-short.txt and figure out the distribution by hour of the day for each of the messages. You can pull the hour out from the 'From ' line by finding the time and then splitting the string a second time using a colon.
# From stephen.marquard@uct.ac.za Sat Jan 5 09:14:16 2008... |
05dff35a6018954c4184e233d82b226bb4389e21 | smrigney/Python-Challenge- | /pybank/main.py | 3,686 | 3.84375 | 4 | # total number of months in data set (column 0)
# the net total amount of profit/losses over the entire period (column 1)
# calculate the changes in profit/losses over the entire period, then find average
# the greatest increase in profits (date and amount) over the entire period
# the greatest decrease in profits (dat... |
585e5e7603ccccfd95ed6a557fd8b54b07c7334d | prisings/python | /bin/1기초문법.py | 474 | 3.796875 | 4 | print('test') # 파이썬에서 주석은 # 그리고 컨트롤 쉬프트 / 는 자바와 같아 그냥 사용가능 (물론 표시되는 문자는 다름)
""" 아
야
어
여 """
n = 10
if n % 2 == 0:
print("짝")
else:
print("홀")
""" 파이썬의 경우 들여쓰기에 매우 민감하다 하나라도 틀리면 error? """
print("plus를 안해도 이어지나?","이게 말이되나?", "유용한 기능")
name = input("이룸 : ")
print("eroom : ", name) |
207e582862dc710a2a6b5901346070a1d300feac | 8787ooo/Python200818 | /guessonetime.py | 274 | 3.84375 | 4 | import random
n = random.randint(1,10)
a = input("num:")
if a == "1" or a =="2"or a =="3" or a =="4"or a =="5" or a =="6"or a == "7" or a == "8"or a =="9" or a == "10":
if n == a:
print("yes")
else:
print('no')
else:
print('error')
|
01ebc37bf5000576214cbf71140dba070dbb4f2a | sdtimothy8/Coding | /Python_projects/small_useful_tools/excel_process/split.py | 214 | 3.546875 | 4 | #!/usr/bin/env python
#coding: utf-8
import os
testfile = 'test.txt'
f = open(testfile, 'r+')
row_list = []
for row in f:
row_list.append(row.split())
print row_list
a = "love"
b = "jiale"
print join(a,b)
|
a804aaae0bee17aafdb0376dad0449156a84b4af | LeonardoArcanjo/Praticas-Python | /parking.py | 2,569 | 3.984375 | 4 | """
Tarifa do estacionamento:
1a a 2a hora: R$ 1.00 cada
3a e 4a hora: RS 1.40 cada
5a hora e seguintes horas: R$ 2.00 cada
O numero de horas a pagar é sempre inteiro e arrendondado por excesso. Quem estacionar por 61 min, pagará por 2 horas,
que é o mesmo que alguém pagaria se tivesse permanecido por 120... |
3d76c24a7f88f83bbda0bb40f5c426709fd48288 | rexlinster/PYLN | /1.py | 352 | 3.734375 | 4 | import sys
print("中文")
str1 = "this is srring"
print(str1.isalpha())
print(max(str1))
while 1 :
user = input("輸入你的姓名:")
pwd = input("passwd:")
if user == "badman" and pwd == "123" :
print("login success")
break
else :
print("login fail")
continue
print(sys.getdefaultenco... |
ab52124ad89b97b019dbe3f64132a1a83edeb1fe | alexleversen/AdventOfCode | /2020/03-1/main.py | 397 | 3.65625 | 4 | file = open('input.txt', 'r')
lines = file.readlines()
treeCount = 0
index = 0
rightSlope = 3
for line in lines:
lineList = list(line)
if(line[index] == '#'):
treeCount += 1
lineList[index] = 'X'
else:
lineList[index] = 'O'
print(''.join(lineList))
index += rightSlope
i... |
246130cc6d8d3b7c3fee372774aa2f93018f4e35 | alexleversen/AdventOfCode | /2020/08-2/main.py | 1,119 | 3.625 | 4 | import re
file = open('input.txt', 'r')
lines = list(file.readlines())
def testTermination(swapLine):
if(lines[swapLine][0:3] == 'acc'):
return False
instructionIndex = 0
instructionsVisited = []
acc = 0
while(True):
if(instructionIndex == len(lines)):
return acc
... |
4b012637f522fe239ec5897f144b476da96ae2c6 | natlin/Learning | /morestring.py | 149 | 3.875 | 4 | name="john"
print "Hello %s!" % name
age=25
print "Hello %s, you are %d years old" %(name, age)
list2=[1,2,3]
print 'this is a list: %s' % list2
|
1df5a6d22eaec8d8e15451b13c296c0eff843916 | SenyaSumkin/python_train | /checkio/github/expand_intervals.py | 1,009 | 3.90625 | 4 | from typing import Iterable
def expand_intervals1(items: Iterable) -> Iterable:
answer = []
for pair in items:
addition_number = pair[0]
if pair[0] == pair[1]:
answer.append(addition_number)
else:
for i in range(pair[1]-pair[0]+1):
answer.append... |
f1cd7c740d556ceede291f2b725d1a15b20b4864 | alter4321/Goodline_test_app_dev | /task_3_gl.py | 1,021 | 4 | 4 | quantity = int(input('Количество элементов массива'))
numbers = [int(i) for i in input('Введите значения через пробел').split(' ')]
# Проверка соответсвия указанного и фактического количества элементов массива
if quantity != len(numbers):
print('Указанное количество элементов не соответсвует фактическому')
e... |
2836445a3619bd8f3a5554d962f079cc0de9cd9a | sooty1/Javascript | /main.py | 1,240 | 4.1875 | 4 |
names = ['Jenny', 'Alexus', 'Sam', 'Grace']
dogs_names = ['Elphonse', 'Dr. Doggy DDS', 'Carter', 'Ralph']
names_and_dogs_names = zip(names, dogs_names)
print(list(names_and_dogs_names))
# class PlayerCharacter:
# #class object attribute not dynamic
# membership = True
# def __init__(self, name="anonymou... |
18e0d40be585f1280c75fe50400a2493ce047262 | kkkyan/leetcode | /problem-string-easy/125.验证回文串.py | 1,223 | 3.84375 | 4 | #
# @lc app=leetcode.cn id=125 lang=python3
#
# [125] 验证回文串
#
# https://leetcode-cn.com/problems/valid-palindrome/description/
#
# algorithms
# Easy (40.77%)
# Likes: 106
# Dislikes: 0
# Total Accepted: 49.7K
# Total Submissions: 121.6K
# Testcase Example: '"A man, a plan, a canal: Panama"'
#
# 给定一个字符串,验证它是否是回文串... |
c0bedffaf20af532c719397c0c67b3111472e682 | kkkyan/leetcode | /problem-math-easy/9.回文数.py | 1,928 | 3.953125 | 4 | #
# @lc app=leetcode.cn id=9 lang=python3
#
# [9] 回文数
#
# https://leetcode-cn.com/problems/palindrome-number/description/
#
# algorithms
# Easy (56.52%)
# Likes: 704
# Dislikes: 0
# Total Accepted: 150.3K
# Total Submissions: 265.9K
# Testcase Example: '121'
#
# 判断一个整数是否是回文数。回文数是指正序(从左向右)和倒序(从右向左)读都是一样的整数。
#
# ... |
f7f585f584f0a6b4ccdb708608640d9ba154673c | matherique/trabalhos-edd | /lista_2/test.py | 2,095 | 4.15625 | 4 | #!/usr/bin/env python3
import unittest
from Fraction import *
class TestFractionClass(unittest.TestCase):
def testNumeradorCorreto(self):
""" Numerador correto """
n, d = 1, 2
fr = Fraction(n, d)
self.assertEqual(fr.num, n)
def testDenominadorCorreto(self):
""" Denominador correto """
... |
a61cb09d4db306db4f1f273b43632f340a55cb2d | matherique/trabalhos-edd | /lista_2/Fraction.py | 2,185 | 3.609375 | 4 | #!/usr/bin/env python3
class Fraction:
__slots__ = ['__num', '__den']
def __init__(self, num, den):
self.__den = den
self.__num = num
@property
def num(self):
return self.__num
@property
def den(self):
return self.__den
def __str__(self):
return f"{self.num} / {self.den}"
# mdc ... |
67f2f60471945c0b4b0d87a3273b55429bc2f276 | alxfed/hadamard | /hadamard_sylvester.py | 392 | 3.546875 | 4 | # -*- coding: utf-8 -*-
"""...
"""
import numpy as np
def hadamard(n): # n is the order of Sylvester construction, not the dimension of the matrix as the idiots did it.
H = np.array([[1]], dtype=int)
for i in range(0, n):
H = np.block([[H, H], [H, -H]])
return H
def main():
print(hadamard(2))... |
babcf24c8692cdad95ce95911bb52958f0852f07 | jhocepSan/LlavesTkReg | /uri1008.py | 127 | 3.53125 | 4 | # -*- coding: utf-8 -*-
a=int(input())
b+float(raw_input())
c=float(raw_input())
print "NUMBER = "+a
print "SALARY = U$ "+(b*c) |
4836460fdc68c01eaf60d760a1851fae4debfd49 | TessieMeng/python-practise | /advobj.py | 2,521 | 3.59375 | 4 | class Student(object): #a empty class
pass
s = Student()
s.name = 'lwd'
## 给一个对象绑定一个方法
def set_age(self, age):
self.age = age
from types import MethodType
s.set_age = MethodType(set_age, s) #attach set_age fun to instance set_age.
## 给某一个对象绑定方法后,其他同类对象不具备此方法
s2 = Student()
s2.set_age(25) #it is inval... |
575156aae3b6f2350d617421a1260d323df3ae16 | TessieMeng/python-practise | /advanced.py | 4,751 | 3.640625 | 4 | # 高阶函数
def abs_add(x, y, abs):
return abs(x) + abs(y)
# 映射方法
def f(x):
return x**2
r = map(f, [1,2,3,4,5,6,7,8,9])
list(r)
list(map(str, [1,2,3,4,5]))
# reduce方法
from functools import reduce
def fn(x, y):
return x*10 + y
reduce(fn, [1,2,3,4,5])
# map和reduce组合用法
def str2int(str):
def chr2num(chr)... |
5b2267600ac663d2493599080b5bf482511015d3 | nehaDeshp/Python | /Tests/setImitation.py | 623 | 4.25 | 4 | '''
In this exercise, you will create a program that reads words from the user until the
user enters a blank line. After the user enters a blank line your program should display
each word entered by the user exactly once. The words should be displayed in
the same order that they were entered. For example, if the user e... |
a15d13da749137921a636eb4acf2d56a4681131a | nehaDeshp/Python | /Tests/Assignment1.py | 559 | 4.28125 | 4 | '''
Write a program that reads integers from the user and stores them in a list. Your
program should continue reading values until the user enters 0. Then it should display
all of the values entered by the user (except for the 0) in order from smallest to largest,
with one value appearing on each line. Use either the s... |
e5fe9fcfda6f7a9806e45d010088812dd02b030f | Blakeinstein/Python-dev | /sudoku/sudoku.py | 1,839 | 3.640625 | 4 | class Sudoku:
def __init__(self, arr=[[0 for i in range(9)] for j in range(9)]):
self.arr = arr
self.node = [0, 0]
def find(self):
for i in range(0, 9):
for j in range(0, 9):
if self.arr[i][j] == 0:
self.node[0] = i
self... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.