blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
fc14e17399d9efa8927bba5b3449dfe2a4bd33cc
qursaan/stepik_python_beginners
/working_files/copy_even_lines.py
435
3.734375
4
# Given: A file containing at most 1000 lines. # # Return: A file containing all the even-numbered lines from the original file. Assume 1-based numbering of lines. Please copy the content of output file into the text field below. def cp_even_line(filename, newfile): f = open(filename,'r') w = open(newfile, 'w+...
00521c5f79dda415c2f3986446d83036f73f6f0a
hassyGo/NLP100knock2015
/iwai/set1/exp7.py
332
3.5
4
# !/usr/bin/python # coding:UTF-8 # 1-(7) import sys argv = sys.argv argc = len(argv) if (argc != 4): print "Error!" x = int(argv[1]) y = str(argv[2]) z = int(argv[3]) #text = "" 一行でprintすることも可能 print x, print u"時の", print y, print u"は", print z #print argv #pythonでも%d, %s, %.1fも使える
3b5f247787542d15ee17f1f1b7a10c16c31a0235
klmsathish/DataStructures
/Selection_sort.py
746
4
4
A = [] x=int(input("enter the size of array:")) for i in range(x): b=int(input("Enter the number:")) A.append(b) # Traverse through all array elements for i in range(0,len(A)): smallest=min(A[i:]) min_indx=A.index(smallest) A[i],A[min_indx]=A[min_indx],A[i] print("sorted array:") print...
aea9ee62008bd0e0287abe2e2266f2c505356c4e
Yanushanus/coloc
/38.py
837
3.671875
4
''' Дані про направлення вітру (північний, південний, східний, західний) і силі вітру за декаду листопада зберігаються в масиві. Визначити, скільки днів дув південний вітер з силою, що перевищує 8 м / с. ''' data = {'North': [4, 3, 0, 6, 10, 13, 18, 9, 7, 12], 'South': [13, 12, 3, 4, 6, 2, 6, 9, 11, 8], ...
896ac190a3286c238f34c44328b542045be1c7c9
MasterPK/VUT_FIT
/1BITL/ISJ/isj_proj05_xkrehl04.py
8,166
4.125
4
#!/usr/bin/env python3 import collections def add(self,other): """Soucet dvou polynomů, v pripade potreby rozsiruje""" len1=len(self) len2=len(other) if len1<len2: for i in range(0,len2-len1): self.append(0) len1=len2 if len2<len1: for i in range(0,len1-len2): ...
15c9874af73ee224909854beb93c6a00ab2a0f15
magicalsoup/CCC-Junior-Prep
/Lesson8 Algorithms/Problem 1/Solutions/Solution.py
340
3.9375
4
# python 2 code import math def isPrime(n): if n == 2: return True; if n <= 1: return False; for i in range(2, int(math.sqrt(n)) + 1): if n % i == 0: return False return True n = int(raw_input()) while True: if isPrime(n): print n ...
ecbd22d7bbf2bbe867966831ace0b43973f93b56
DigitalDood01/Python-Programming
/files.py
427
3.90625
4
#THIS PROGRAM IS ABOUT FILES #Reading a file fileref = open("learn_file.txt", "r") for l in fileref: print(l.strip()) fileref.close() #Writing a file filewrite = open("write_file.txt", 'w') for i in range(15): sq = i*i print(sq) filewrite.write(str(sq) + '\n') #filewrite.write("\n") ...
9ac109cc18476920fae7b6f6715da5167a81fc9a
omushpapa/minor-python-tests
/String reverse/reverse.py
327
4.46875
4
# Define a function reverse() # that computes the reversal of a string. # For example, reverse("I am testing") # should return the string "gnitset ma I". def reverse(string): return string[::-1] def main(): word = raw_input("Enter string: ") print reverse(word) if __name__ == "__main__": ...
51ed9f84a42450950c268a769f4b2617c0339e8e
shin99921/Python-
/소프트웨어기초코/coding_chapter5.py
3,270
3.71875
4
# 3.정수를 입력받아 변수num에 대입한 후, 변수 num의 값이 100보다 적을경우 숫자를 출력해보자. print("3","-"*50) a = int(input("input: ")) if a < 100: print(a) print() # 4.정수를 입력받아 변수 num에 대입한 후, 변수 num의 값이 100 보다 적을경우 숫자를 출력해보자. print("4","-"*50) a = int(input("input: ")) if (a % 2 == 0): print("짝수") print() # 5.정수를 입력받아 변수 num 에 ...
8be3b49cc0b47f739031ec04abed6a9d624a4e13
dengdengkai/Python_practise
/3/3-8.py
668
3.796875
4
#!/usr/bin/python # coding: UTF-8 """ 题目:有5个人坐在一起,问第五个人多少岁?他说比第4个人大2岁。问第4个人岁数,他说比第3个人大2岁。问第三个人,又说比第2人大两岁。问第2个人,说比第一个人大两岁。最后问第一个人,他说是10岁。请问第五个人多大? 程序分析:利用递归的方法,递归分为回推和递推两个阶段。要想知道第五个人岁数,需知道第四人的岁数,依次类推,推到第一人(10岁),再往回推。 """ def fact(age,n): if n == 1: return age else: return fact(age+2,n-1)...
7d41d559516fdd466a85d6ac5d2423d970ffce26
sheelabhadra/LeetCode-Python
/976_Largest_Perimeter_Triangle.py
874
4.03125
4
""" Given an array A of positive lengths, return the largest perimeter of a triangle with non-zero area, formed from 3 of these lengths. If it is impossible to form any triangle of non-zero area, return 0. """ """SOLUTION: Sort the list of side lengths in descending order. The first triplet for which the condition ...
3dc4b7d09b78fa6b430d0ca004bca2b7ccd867b1
pratyusa98/Streamlit
/example3.py
593
3.734375
4
import streamlit as st # Text/Title st.title('How to receive user input and process them with streamlit?') # Receiving User Text Input firstname = st.text_input("Enter Your Firstname","Type Here..") # Text Area message = st.text_area("Enter Your message","Type Here..") # Date Input import datetime toda...
90b338f0b4ae4eb0d99a006796fe22cafc71552b
BenjaminUJun/slick
/pox/ext/slick/placement/Placement.py
1,365
3.78125
4
""" Placement base class """ class Placement(): def __init__ (self, network_model): self.network_model = network_model def get_placement (self, flowspace_desc, elements_to_install): """ Inputs: - flowspace_desc: flowspace against which we are installing the elem...
999b9ee47064d0210e98a45a2cf029cca5f0d6f1
Software05/Github
/Modulo-if/app4.py
380
4.09375
4
# lee tres números numero1 = int(input("Ingresa el primer número:")) numero2 = int(input("Ingresa el segundo número:")) numero3 = int(input("Ingresa el tercer número:")) # verifica cuál de los números es el mayor # y pásalo a la variable de mayor número numeroMayor = max(numero1,numero2,numero3) # imprimir el result...
8284372447121c9019b0e9e89baa50e80a925e08
JosefJoubert/AI
/Prac7/practice.py
237
3.5
4
# -*- coding: utf-8 -*- """ Created on Tue May 31 11:27:18 2016 @author: kameelperd64 """ x = [1,2,3] y = [2,3,4] w = [0.8,0.7] z = [] for i in range(3): z.append(x[i]*w[0] + w[1]) dw1 = 0 for i in range(3):
4a7ee24a80c2d785bb1ca8b14ce651cf94b6c8b5
Bocca1970/primary-admin
/Python 44.py
601
3.90625
4
# --------------- Python 44 --------------- # ----- Izracunavanje kvadratnog korena --- # Funkcija koren pronalazi delioca argumenta koji stepenovan eksponentom daje argument osnova = int(input("Unesi vrednost osnove x: ")) kvKoren = 2 stepen = (osnova**(1/float(kvKoren))) def kvadratniKoren(osnova, kvKoren): i...
3d00b54f1000402801c39045311e05c0a709b05a
PiggerZZM/leetcode-exercises
/LeetCode268/268.py
431
3.703125
4
# -*- coding: utf-8 -*- #project:LeetCode191 #author: Administrator #contact: 1506032039@qq.com #software: PyCharm #file: 268.py #time: 2019/2/27 13:44 class Solution: def missingNumber(self, nums): sum = 0 for i in range(0,len(nums)): sum += nums[i] return (len(nums)+1)*len(nums...
f7d53ca8e19a0d6584149460c8ae122848683cc3
nik-hil/Questions
/problems/next-greater-element.py
427
3.984375
4
# https://www.geeksforgeeks.org/next-greater-element/ def next_element(arr): s = [] for i in range(len(arr)): while s and s[-1].get("value") < arr[i]: t = s.pop(-1) arr[t.get("ind")] = arr[i] s.append({"ind":i, "value":arr[i]}) while s: t = s.pop(-1)...
d7da93f645e2e20da767cc0b7e38dd6c6c7b65a8
Zirmaxer/Python_learning
/Bitroot/Test8.1.py
964
3.75
4
''' Напишіть Python-функцію inspector, яка визначає корисну інформацію в переданому їй об'єкті функції та створює читабельний рядок з цією інформацією в такому форматі: Func name: {func_name} Func docs: {func_doc_string} Num of local variables: {num_of_local_variables} Name of local variables: {local_variable_names} '...
bf231e39dd0ad3ff2fe8e4492a9b70e06de3a205
mrmuli/bootcamp_9_ke
/toy_problems/prime_numbers.py
487
4.1875
4
""" Prime Numbers """ """ prime checks whether a number is prime and returns either true or false """ """ prime_list appends all primes in a list and returns the list """ def prime(x): if x < 2: return False else: for i in range(2,x): if x % i == 0: return False return True # print prime(100) def ...
645a95f78c24621554c4e393a6586ac57a0108c3
Cynzgao/8-puzzle
/PuzzleState.py
3,657
3.796875
4
from __future__ import division from __future__ import print_function import sys import math import time #import queue as Q from heapq import heappush, heappop import resource ## The Class that Represents the Puzzle class PuzzleState(object): """ The PuzzleState stores a board configuration and implemen...
f5564296db14fa03c57f7ea68ebe03927d303b55
michmeng/Bioinformatics-Algorithms
/Finding Genomic Breakpoints/chromosome_to_cycle.py
727
3.6875
4
def chromosome_to_cycle(chromosome): nodes = [0] * (2 * len(chromosome)) for i in range(0, len(chromosome)): curr = chromosome[i] if curr > 0: nodes[(2*i)] = (2*curr)-1 nodes[2*i+1] = 2*curr else: nodes[(2*i)] = (-2)*curr nodes[2...
0151ae29b2c4ebf04a991284a9e0ec91ff61f95d
WuLC/LeetCode
/Algorithm/Python/592. Fraction Addition and Subtraction.py
1,673
3.6875
4
# -*- coding: utf-8 -*- # @Author: LC # @Date: 2017-06-17 10:26:14 # @Last modified by: LC # @Last Modified time: 2017-06-17 10:50:32 # @Email: liangchaowu5@gmail.com # 1. seperate all numerators and denominators and store them seperately in a list # 2. find lcm(lowest common multiple) for all denominators # 3. ...
50370a3d9da71ba3d02876be18fcc778340cae55
Momin-C/LeetCode
/14 Longest Common Prefix.py
350
3.546875
4
#PROBLEM 14 #SOURCE: https://leetcode.com/problems/longest-common-prefix/ strs = ["dog","dogaracecar","dcarss","dogman"] def longestCommonPrefix(strs): if len(strs)==0: return "" strs.sort() i = 0 while (strs[0][i] == strs[-1][i]) and (i < len(strs[0])): i += 1 return strs[0][:i] pri...
5a90dc9e157c5d7a25f3230a709d42d997c5df2c
mmodzel3/Pokemon-task
/app/app.py
1,747
3.734375
4
from app.exceptions import InvalidInputException from app.pokemons import PokemonType def parse_input_to_attacking_pokemons(lines): attacking_pokemons = [] for line in lines: pokemons = line.split("->") if len(pokemons) != 2: raise InvalidInputException("Invalid input ...
274a97238c6e570b9bb2888df9c61eb14488862b
zhouyuhangnju/freshLeetcode
/Convert Sorted Array to Binary Search Tree.py
731
3.84375
4
# Definition for a binary tree node. class TreeNode(object): def __init__(self, x): self.val = x self.left = None self.right = None def sortedArrayToBST(nums): """ :type nums: List[int] :rtype: TreeNode """ if len(nums) <= 0: return None mid = len(nums) /...
62754b533522b2914750759e8b23c651498847da
satemochi/saaaaah
/geometric_misc/matrix_multiply/mohapatra1.py
1,608
3.609375
4
from itertools import product import numpy as np def mohapatra(a, b): """ Matrix multiplication for nxn-matrix of positive integers Inspired by https://github.com/ShrohanMohapatra/matrix_multiply_quadratic and reference: S. Mohapatra, (2018). "A new quadratic-t...
2f203aec8b8aa4e4413be3cb41ea594ea738db41
ncutixavier/Learn-Python
/AddMatrices.py
397
3.59375
4
first_matrix = [ [1,2,3], [3,4,5], [4,4,4] ] second_matrix = [ [1,1,1], [2,2,2], [3,3,3] ] result = [ [a,b,c], [d,e,f], [g,h,i] ] print(first_matrix+second_matrix) # print(first_matrix[0][0]+second_matrix[0][0]) # for row in first_matrix: # for col in row: # print (...
877b8a6a2011f833da641671100542f84b197a24
andrewlee224/chess-composition
/chesscomposition/piececomposer.py
6,510
3.5
4
import logging import time from collections import deque import pieces as pcs import chessboard as csb class PieceComposer(object): """Compute all compositions of non-threatening pieces positions. Given the chessboard dimensions and and iterable of desired piece types computes all possible compositions ...
d02fed2dc18034f219caac93b25f6a3603e47f68
brandonio/typoglycemia
/typoglycemia.py
1,491
3.53125
4
import string from itertools import permutations # lowercase letters lst = string.ascii_lowercase # English dictionary named "dict" diccionario = open("dict", "r") alphabetical = [] prev = "a" toadd = [] for word in diccionario: curr = word.lower() curr = curr[:len(curr) - 1] if curr[0] == prev[0]: toadd.app...
4e09f527b1e64f49c381b3e16394776f21f6df2b
zachariahsharma/learning-python
/numbers/4.py
513
3.59375
4
cars=100 space_in_a_car=4.0 drivers=30 passengers=90 cars_not_driven=cars-drivers cars_driven=drivers carpool_capasity=cars_not_driven*space_in_a_car avrege_people_in_car=passengers/cars_driven print("there are",cars,"cars avalible") print("there are only",drivers,"drivers avalible") print("there will be",cars_not_driv...
305a381a07dcbe2ecb6f009f77c9db0625f427ea
MuhammadShahzeb1/2.-Python-Beginners-programs-Part2
/15.Writing and Appending in a file/append.py
638
4.21875
4
#we will discuss appending a file #f=open("append.py","a") #it will append in a file like whatever we will write it will just add in exisiting file #if we do not use append operation than it wil just simply delete previous data update it with new one #now we can write our new program in ...
ce0c9d4f32df9f4d152cd6cc5bc98c81294e70dc
pombredanne/Rusthon
/regtests/str/compare.py
177
3.609375
4
"""compare""" from runtime import * def main(): a = 'XYZ' b = 'XYZ' assert( a == b ) x = False if 'a' < 'b': x = True assert( x==True ) assert( 'a' < 'b' ) main()
ea7056ff6267a549928a497d8419ba28ae48457d
jroehl/misc.scrape_topsy
/scrape_topsy.py
11,538
3.5
4
#!/usr/bin/env python3 """ Script for scraping topsy website. Functions: - Navigate to topsy URL passed as parameter - Grab tweet details (TweetID, TweetText (including Hashtags, Links etc.), TweetTimestamp, InReplyTo ID) - Open www.gettwitterid.com at the end of the run to obtain twitter id - Save the details in stan...
28221a160719bbd175bd824650bc0e81915dfe5b
ladlod/my_leetcode
/dp/leetcode300.py
1,854
3.71875
4
# !/usr/bin/python # -*-coding: utf-8 -*- # 给你一个整数数组 nums ,找到其中最长严格递增子序列的长度。 # 子序列是由数组派生而来的序列,删除(或不删除)数组中的元素而不改变其余元素的顺序。例如,[3,6,2,7] 是数组 [0,3,1,6,2,2,7] 的子序列。 # 来源:力扣(LeetCode) # 链接:https://leetcode-cn.com/problems/longest-increasing-subsequence # 著作权归领扣网络所有。商业转载请联系官方授权,非商业转载请注明出处。 # 动态规划做法 # 思路:dp:dp[j] = max(nums[...
7006eb791f1fa285d4fcb6437cc0e6adbbf6f9e2
Jack-Kingdom/ACM
/LeetCode/500-Keyboard-Row.py
592
3.515625
4
class Solution(object): def findWords(self, words): """ :type words: List[str] :rtype: List[str] """ fst = 'qwertyuiopQWERTYUIOP' snd = 'asdfghjklASDFGHJKL' trd = 'zxcvbnmZXCVBNM' result =[] for word in words: count = 0 ...
effe3f90a4038601b87adbfbc7e2309474cd3a3b
ballantines1982/Uppdrag-2-Pension
/pensionen.py
1,367
3.859375
4
program_run = True print("--------------------------------------") print("Välkommen till denna pensionsimulator") print("--------------------------------------") while program_run: #While loopen iterarar koden så länge program_run är lika med True. try: #Använder try här för att testa om det genereras fe...
bcdfc2f9eccd33c58c6234fcb59fd65aa0b173a8
tmu-nlp/100knock2016
/kent/chapter02/knock17.py
290
3.703125
4
#!/usr/bin/python #_*_coding:utf-8_*_ def main(): fin = open("col1.txt") col1_list = list() for line in sorted(fin): col1_list.append(line.strip()) for col in set(col1_list): print col print len(set(col1_list)) if __name__ == "__main__": main()
92439aa6d8a4d7d6234a366dc3c8e51640748c8a
hahaliu/LeetCode-Python3
/643.maximum-average-subarray-i.py
799
3.65625
4
# ex2tron's blog: # http://ex2tron.wang # 我的代码:超出时间限制 # class Solution: # def findMaxAverage(self, nums, k): # """ # :type nums: List[int] # :type k: int # :rtype: float # """ # ret = float('-inf') # for i in range(len(nums)-k+1): # ret = max(r...
8d4697c1af197d366139bd509fefca2b73268bef
abhisek08/Python-Basics-Part-1-
/checking multiple values.py
176
3.953125
4
''' Write a Python program to check whether multiple variables have the same value ''' a=20 b=a c=b d=20 print(a is 20) print(b is a) print(c is b) print(d is 20) print(d is a)
dd075fd0b4e9a1bf817c65d76bf788afcc778205
ConnyBlog/CodeDriver
/LearnRecord/Python/Code/someCode/recursiveFunc.py
1,278
4.1875
4
# 递归函数 # 递归函数需要防止函数溢出。函数的调用是通过栈这种数据结构实现的,进入一个函数,栈就会加一层栈帧,当函数返回,栈就会减一层帧; # 由于栈的大小不是无限的,所以调用次数过多就会出现栈溢出; # 解决栈溢出:尾递归优化,循环是特殊的尾递归函数; # #计算阶乘 # def fact(n): # print('n=',n) # if n == 1: # return 1 # return n * fact(n-1) # 尾递归优化 # 函数返回的时候,调用自身本身,并且return不能包含表达式,这样编译器可以把尾递归做优化,无论递归本身调用多少次都只占用1个帧; def...
94e0a8ff1d31df1283dbc84a5bd25a4c4350f31b
MrHamdulay/csc3-capstone
/examples/data/Assignment_7/knmkri002/push.py
2,533
4
4
def push_left(grid): """merge grid values left""" count = [] for i in range(5): for row in range(4): for col in range(3): if grid[row][col] == 0: grid[row][col] = grid[row][col + 1] grid[row][col +1] = 0 el...
c93970e5e4f557b2e03837b4a984446b09706e19
ndbellew/KompyuterM3chakrs
/LearningPython/ShinKattisProblems/Skocimis.py
156
3.53125
4
line = input().split() x, y, z = int(line[0]), int(line[1]), int(line[2]) dif1 = y-x dif2 = z-y if dif1 > dif2: print(dif1-1) else: print(dif2-1)
7cc27554243dbf38e97b905a1cf8b7d83d7fbbe3
NASA-AMMOS/MMGIS
/private/api/great_circle_calculator/compass.py
14,531
3.71875
4
# -*- coding: utf-8 -*- # This collection of classes just let me call something like compass.east to get 90 degrees. from collections import namedtuple class CompassSimple: """ A class to use one of the 32 compass points inplace of degrees. This was made so I could just call compass.east to get 90 degrees. ...
4baf79fc2316003a4782514003b14ffd726b46a5
jacobhurt/Methodologies-Class
/Python/carconsignment.py
1,606
3.9375
4
class vehicle: def__init__(self, manu, esize, price): self.setmanu self.setesize self.owner.name self.setprice self.getmanu self.getsize self.getowner class truck(vehicle): def__init__(self, load, tow): self.setload self.settow sel...
24ddd1f7012c43ac6aaff8753d10260afdb993c8
manasap29/Python-
/pandas.py
32,847
3.875
4
%reset -f #%% # ============================================================================= # Data Structures # ============================================================================= # 3 datatypes availabe,Series,DataFrame & Panel # Series : 1 dimension,homogenious,data-mutable,size-immutable # DataFram...
f27cfd0d57134ded4a4f4092cd01bb4249ef76f2
karolinanikolova/SoftUni-Software-Engineering
/2-Python-Fundamentals (Jan 2021)/Course-Exercises-and-Exams/00-Exam-Prep/01_Mid_Exam_Prep/03-Programming-Fundamentals-Mid-Exam-Retake/03-Moving-Target.py
1,940
3.9375
4
# 8. * Moving Target # You are at the shooting gallery again and you need a program that helps you keep track of moving targets. # On the first line, you will receive a sequence of targets with their integer values, split by a single space. # Then, you will start receiving commands for manipulating the targets, until t...
eb965edc2daa2c13b98de3fa17a5e2e22bf11533
alu-rwa-dsa/week-2--create-multiple-unit-tests-jules
/.github/q4.py
278
3.75
4
lA = [20, 5, 2, 9, 3]#list one lB = [20, 2, 9, 3]#list two def CLists(lsA, lsB): for number in lsA: if number not in lsB: return number if __name__ == "__main__": print(CLists(lA, lB)) # Space Complexity - O(1) # Time Complexity - O(A * B)
6d275e023be5e5aeba50f6ab48a1fb63d59bcdbe
sangeethadhanasekar/new_python
/listcirculating.py
379
4
4
choice=int(input("how many elements do you want in a list")) list1=[] for i in range(choice): inp=input("enter the elements in the list") list1.append(inp) print("the given list is",list1) print("enter index 'n' ranges from 0 to",len(list1)-1) n=int(input()) revlist=list1[n:]+list1[:n] print("...
c21cf6e673e2c7c7d0e438e29fc076f7d662942a
AndrianovaVarvara/algorithms_and_data_structures
/TASK/Хирьянов 15 лекция контрольная работа/A_больше меньше.py
194
3.921875
4
a = int(input()) x = input() b = int(input()) if x == '>': if a > b: print('YES') else: print('NO') else: if a < b: print('YES') else: print('NO')
16b2d757605c6deec6f4d7777321d56afd8b607a
Bayesd/exercise0_python
/string-length/string_length.py
301
3.96875
4
def get_length(name): length_of_str = len(name) return length_of_str length = get_length("Guido van Rossum") print(length) # The correct answer here should be `16` # Gain some extra score by answering who "Guido van Rossum" is ;) """ Guido van Rossum är den första personen som printade "Hello World" med py...
26db68a72b039f2468608dd305006bc37fcafd11
xie616/Data-Mining-HandBook
/配套教程/Python入门与Python爬虫/Week-03/Example-0301/近体诗格律分析(面对过程).py
10,007
3.53125
4
""" 1. 诗句数量、诗句字数是否符合绝句或律诗的要求(不考虑排律、六言的情况) 2. 诗文是否押平声韵(暂不考虑首句押韵情况),诗文的韵脚是否符合平水韵部 3. 诗句是否为拗句(是否存在孤平或拗救的情况) 4. 诗文的平仄是否符合对黏的要求 《首春》 李世民 寒随穷律变,春逐鸟声开。 平平平仄仄 平仄仄平平(十灰) —— 仄仄脚正格 平平脚正格 初风飘带柳,晚雪间花梅。 平平平仄仄 仄仄中平平(十灰) —— 【失黏】仄仄脚正格 平平脚正格 碧林青旧竹,绿沼翠新苔。 仄平平仄仄 仄仄仄平平(十灰) —— 【失黏】仄仄脚正格 平平脚正格 芝田初雁去,绮树巧莺来。 平平平仄中 仄中中平平(十灰) —— 【失黏】仄仄脚正格 平平脚正格...
602ac189b9b406231c927dbc6fa23b0842dc4808
jagadeesh1414/assign4_note.py
/assign4_prog2_rev.py
211
4.28125
4
def reverse(string): string = "".join(reversed(string)) return string s = "Gitam" print("The original string is : ",end="") print(s) print("The reversed string is : ",end="") print(reverse(s))
32e169f5d705e4a38d258535b3bcd77567c61e3f
aongenae/leetcode
/src/util/datastructures/string_binary_tree.py
2,567
3.578125
4
#!/usr/bin/env python3 ################################################################################ # # Filename: string_binary_tree.py # # Author: Arnaud Ongenae # ################################################################################ from .binary_tree import BinaryTree def re...
f3073607e2af90f68c995241424599c7d36939fd
Rushi21-kesh/30DayOfPython
/Day-23/day-23_tejas.py
150
3.5
4
n = [1, 54, 32, 12] def cyclical(n): n.insert(0, 0) n.insert(0, 0) n[0] = n.pop() n[1] = n.pop() return n print(cyclical(n))
ca29825f5be357d56639a0b38924c717cbf86b80
kaspesi/cse326_program_1
/problem4.py
2,345
3.796875
4
# ------------------------------------------------------------------------- ''' Problem 4: compute sigmoid(Z), the loss function, and the gradient. This is the vectorized version that handle multiple training examples X. 20/100 points ''' import numpy as np # linear algebra from scipy.sparse import diags ...
51ca4ff0505ecb1c97983ea5d22e28eb86d82a93
vanstek/daily-kata
/Shorter Path.py
953
3.984375
4
#Shorter Path #Level: 6 kyu ''' You are given a list of directions in the form of a list: goal = ["N", "S", "E", "W"] Pretend that each direction counts for 1 step in that particular direction. Your task is to create a function called directions, that will return a reduced list that will get you to the same point.The o...
804d857cff5fb34b75d50f60f4fd795d1a86d28d
dadafros/Harvard-CS50-Course
/pset6/readability/readability.py
523
3.875
4
from cs50 import get_string text = get_string("Text: ") numLetters = 0 numWords = 1 numSetences = 0 for i in range(len(text)): if text[i].isalpha(): numLetters = numLetters + 1 elif text[i] == " ": numWords = numWords + 1 elif text[i] in (".", "!", "?"): numSetences = numSetences +...
ef9ac98b22f81b4a9c2ef7c58f3f576fc324347b
etownbetty/LeetCode
/singleNumber.py
606
3.59375
4
#Given an array of integers, every element appears twice except for one. Find that single one. class Solution: def singleNumber(self, nums): """ :type nums: List[int] :rtype: int """ #put the nums in a dict, then iterate through dict to find which one has a value ==1 ...
c1c5fe35a8eb742f7cff83b103ef708c210209e2
CJ8664/leetcode
/57-insert-interval/57-insert-interval.py
884
3.5625
4
class Solution: def insert(self, intervals: List[List[int]], newInterval: List[int]) -> List[List[int]]: result = [] for i, interval in enumerate(intervals): # new interval ends before start of interval if newInterval[1] < interval[0]: result.append(newInterva...
a0e243a830e5b91d7f4081784700dee2ed58289b
Victoria-DR/codecademy
/computer-science/veneer/script.py
2,340
3.578125
4
import datetime class Art: def __init__(self, artist, title, year, medium, owner): self.artist = artist self.title = title self.year = year self.medium = medium self.owner = owner def __repr__(self): return f"{self.artist}. \"{self.title}\". {self.year}, {self.medium}. {self.owner.name}, {...
cb7c629e39dd24482e1dfdccb6b15969e2acc9f6
alblaszczyk/python
/simplepythonexercises/simply_the_best.py
436
3.546875
4
x = [5,6,3,124,46,67,4567,2,345] def simply_the_best(x): max_value = x[0] for i in x: if max_value < i: max_value = i return max_value print simply_the_best(x) # max_value = x[0 #for i in x: #if i in x: #if x[i] > x[i+1]: #max_value = x[i]...
4a289659623379aa758c05a87c04f2e55758615e
arnabs542/DataStructures_Algorithms
/stacks/Min_Stack.py
2,017
3.921875
4
''' Min Stack Design a stack that supports push, pop, top, and retrieving the minimum element in constant time. push(x) -- Push element x onto stack. pop() -- Removes the element on top of the stack. top() -- Get the top element. getMin() -- Retrieve the minimum element in the stack. NOTE: All the operations have to ...
a79bccfeec3014b95dedaa39c3d2258e07a101b0
NuomiPanda/CodeBlock
/sort_demo.py
6,595
4
4
#! -*-encoding:utf-8 -*- """ 1. 交换排序 冒泡排序(Bubble Sort) 快速排序(Quick Sort) 2. 插入排序 简单插入排序(Insert Sort) 希尔排序(Shell Sort) 3.选择排序 简单选择排序(Select Sort) 堆排序(Heap Sort) 4. 归并排序 二路归并排序(Two-way Merge Sort) 5. 线性时间非比较类排序 计数排序(Counting Sort) 桶排序(Bucket Sort) 基数排序(Radix ...
6a2613977ce9d1ad67b60cb7d40c3120a11e1d61
DanielKolodziej/Python
/Pythonstuff/Week 5/file processing w lists, json, pickling introed.py
1,190
3.59375
4
## Processing Lists to file #a. Writelines method #General syntax -> fileObject.writelines( sequence ) # Open a file fo = open("foo.txt", "w") seq = ["This is 1st line\n", "This is 2nd line"] # Write sequence of lines at the end of the file. fo.writelines( seq ) # Close opend file fo.close() ''' #b. with stateme...
d483a1e4b817743ef6f1501114f2364f572d7a16
brandr/Platformer
/gameimage.py
11,130
3.578125
4
""" The most abstract type of object that can appear in the game. """ from animationset import AnimationSet from spritestripanimator import SpriteStripAnimator from camera import WIN_WIDTH, WIN_HEIGHT import pygame from pygame import Surface, Color, Rect import os import copy BACKGROUND_COLOR = Color("#000000") DEF...
c01178e4947852053899fc0a3be886b2e89ff962
patdriscoll61/Practicals
/Practical01/Practical02/asciiTable.py
71
3.515625
4
for i in range(10, 120, 11): print("{:>6} {:>3}".format(i,chr(i)))
cc38f502cf24fa1fa3bcd0e1a3bfb890cfabcc27
ysachinj99/PythonFile
/Data Structure/Binary Search Tree.py
542
4.125
4
print("Implement Binary Search in an Order List") def binarysearch (alist,item): first = 0 last = len(alist)-1 found = False while first <= last and not found: midpoint=(first+last)//2 if alist[midpoint]==item: found = True else: ...
2690b1e982f03fe8756aedf4d64c16b8aaca8895
AdamZhouSE/pythonHomework
/Code/CodeRecords/2934/60617/296094.py
720
3.8125
4
def Alien_code(): code=input() res=decompression(code) if res=="ABPIKPIKABPIKPIKABPIKPIKABPIKPIKABPIKPIKABPIKPIKABPIKPIKABPIKPIKABPIKPIKABPIKPIKABPIKPIKABPIKPIKABPIKPIKABPIKPIKABPIKPIKABPIKPIKABPIKPIKABPIKPIKABPIKPIKABPIKPIKABPIKPIK" print(code) print(res) def decompression(str): num="1" tem...
bd048f1c4389cbf389ddf7b04773b82fed3b23fc
Windspar/PyGizmo
/example.py
1,598
3.546875
4
import pygame import pygizmo as gizmo class Scene: def __init__(self): # basic pygame setup pygame.display.set_caption('PyGizmo Example') self.rect = pygame.Rect(0, 0, 800, 600) self.surface = pygame.display.set_mode(self.rect.size) self.clock = pygame.time.Clock() ...
27b188ed91243209236c860276cd581ec291e3a0
glyg/glyg-misc
/spacegeo.py
2,511
3.8125
4
#!/usr/bin/python # -*- coding: utf-8 -*- ##Définitions pour les simulations de la cellule ### import scipy as S from math import * class Position(object): ### position dans un espace dimensions def __init__(self, pos=S.zeros(3)): self.pos = pos def move(self, da, db, dc): ...
afce719f615bc0b1f2d99aeca483654484d52c51
hujianli94/Python-code
/9.异常程序调试/自定义异常类2.py
785
3.84375
4
#!/usr/bin/env python # -*- coding:utf8 -*- import datetime as dt class MyException(Exception): """ 自定义异常类 MyError """ def __init__(self, message): super(MyException, self).__init__(message) def read_date_from_file(filename): try: file = open(filename) in_date = file.read...
824c4cad71ef43efdd16be17efd1e622bdba9827
thewchan/python_crash_course
/python_basic/pizza.py
422
4.4375
4
#for loop exercises pizzas = ['cheese', 'peperoni', 'sausage'] for pizza in pizzas: print(pizza) print(f"I like {pizza} pizza.") print("I really like pizzas!") friends_pizzas = pizzas[ : ] pizzas.append('anchovie') friends_pizzas.append('hawaiian') print('\nMy favorite pizzas are:') for pizza in pizzas: pr...
5b9cb28f84573d3eb0212e338b353b65e5948f83
hideomit/samurai_code
/janken.py
2,275
3.609375
4
import random janken_data = ["グー","チョキ","パー"] class Janken: def janken(self): try: kekka = 0 print(kekka) while kekka == 0: myJanken = int(input("あなたは?(0:グー、1:チョキ、2:パー)")) comp = random.randint(0,2) ...
80c7d2412bb3a18f92c9c0bace126fcac9887a00
Clanger72/Lingugem-Programa-o-01
/EstDecisao/1MascFem.py
290
3.703125
4
def genero(sexo): if sexo != 'M' and sexo != 'F': return print('Sexo inválido') if sexo == 'M': return print('Masculino') elif sexo == 'F': return print('Feminino') s = str(input('Para feminino digite F ou M para masculino: ')) genero(s)
461d1c95ff6b84d1bc0cad75053d6c3deeb45a23
WSJI0/BOJ
/1000-9999/1181.py
208
3.609375
4
''' 1181번 단어 정렬 ''' n=int(input()) word=[] for _ in range(n): w=input() wLen=len(w) if not([wLen,w] in word): word.append([wLen,w]) word.sort() for i in word: print(i[1])
6212624a9becbe8865dc85ab2148bff5f3edf535
logankilpatrick/LabFive
/module5exercise/module5exercise.py
4,339
4.4375
4
# Module 5 exercises # 1. Based on Textbook R6.3 # write a loop to copy a list ''' L1 = [1,3,5,7,8,6,4,3,0] L1copy = [] for elem in L1: L1copy.append(elem) L1copy = [ ] for i,elem in enumerate(L1): L1copy[i] = elem # List 5 ways to copy a list, without using a loop L1copy = list(L1) # Easy way to copy...
c29cd9707f4985e903a9afbfeab7741b46ff463a
avenet/hackerrank
/algorithms/warmup/staircase.py
140
3.953125
4
staircase_length = int(input()) for i in range(1, staircase_length + 1): print( ' ' * (staircase_length - i) + ('#' * i) )
269a0d90b57788d2e948525ba0a28f2617cee1bb
fedoseev-sv/Course_GeekBrains_Python
/lesson_1/hw_1_2.py
642
4.375
4
''' №2. Пользователь вводит время в секундах. Переведите время в часы, минуты и секунды и выведите в формате чч:мм:сс. Используйте форматирование строк. ''' print("ЗАДАНИЯ №2:\n") seconds = int(input("Введите колическо секунд: ")) variable_hour = seconds // 3600 variable_minutes = (seconds - variable_hour * 3600) //...
0f82f42c6f3d5930ebf5bca829e1d68d7adf3ad5
ChemaML/Algoritmia
/2.completeAStar.py
5,428
3.59375
4
import math # --------------------------------------------------------------- # COMENTARIOS: # - Un tablero sin obstaculos no representa una situacion real # por lo que para marcar posibles obstaculos que entorpezcan # el camino, utilizaremos 1's en el mapa en lugar de 0's # (modificaciones: # variable: bo...
8feec6824a846b05803a1e7a0db2e36aa3d27c9f
chasel2361/oofem
/TimeSeries.py
865
3.53125
4
class TimeSeries: """ TimeSeries object to control FEM timing. Parameters ---------- init : {initial time, float} interval : {time interval, float} record_in : {input series, list} """ def __init__(self, init, interval, record_in): self.init = init self.interval = i...
e99b6a416f7344b983bd520579732c8a61a345e9
hamk-webdev-intip19x6/petrikuittinen_assignments
/lesson_regular_expressions/floating_point_regular_expression.py
306
3.671875
4
import re re_floating_number = re.compile(r"[-+]?\d*\.?\d+") re_floating_exponent = re.compile(r'[+-]?(\d+(\.\d*)?|\.\d+)([eE][+-]?\d+)?') s = "Here are some floating point numbers: 3.14 123.45678, 0.2:0.0 -5.6 +3.54, 0.0001 10.0 and -2.0" num_strings = re_floating_number.findall(s) print(num_strings)
c26e880dfe068c5ea4b16b1a03f7c9ec288d246c
ChiPT318/PhamThucChi-Fundamental-C4E16
/Session02/Homework/binary.py
167
3.953125
4
print("1 0 "*20) n = int(input("Choose a number:")) for i in range(n): if i % 2 == 0: print("1", end= " ") else: print("0", end= " ") print()
77862f10557d5b034b318fe9806aa725d982bb66
douglas-ee/exercicios_python
/introducao_python/8_strings.py
888
4.40625
4
# -*- coding: utf-8 -*- # AQUI VAMOS APRENDER UM POUCO MAIS SOBRE STRINGS E SEUS COMANDOS DE USO A = "DOUGLAS" B = "DOS" C = "SANTOS" D = "GOMES" string_0 = "Douglas é Um Programador de Primeira!" string_1 = string_0.lower() string_2 = string_0.upper() string_3 = string_0.split() string_4 = string_0.split('o') stri...
8f2568880abf81c0d782cc712d452d12747c22db
houhailun/leetcode
/数组/leetcode245_最短单词距离III.py
896
3.84375
4
#!/usr/bin/env python # -*- coding:utf-8 -*- """ @Time : 2019/7/8 18:01 @Author : Hou hailun @File : leetcode245_最短单词距离III.py """ print(__doc__) """ 给定一组不含重复元素的整数数组 nums,返回该数组所有可能的子集(幂集)。 说明:解集不能包含重复的子集。 示例: 输入: nums = [1,2,3] 输出: [ [3],   [1],   [2],   [1,2,3],   [1,3],   [2,3],   [1,2],   [] ] """ class...
6cab5a541ef4e0d22fd1e43f321fcb818498ec47
GrantStenger/game-playing-ai
/tic-tac-toe/main.py
10,231
3.984375
4
#!/Users/Home/anaconda/bin/python import os import random BLANK = "_" class Game: def __init__(self): self.board = self.makeBoard() self.gameOver = False def makeBoard(self): board = [["1", "2", "3"], ["4", "5", "6"], ["7", "8", "9"]] return board def printBoard(self): for row in range(3): for col...
ec104d76bd1f75a4e72a738caf03f929223beda7
mxu007/daily_coding_problem_practice
/DCP_3_4.py
2,912
4.09375
4
# Given two singly linked lists that intersect at some point, find the intersecting node. # Assume the lists are non-clyclical # Example A = 3 --> 7 --> 8 --> 10 # B = 99 --> 1 --> 8 -->10 # Output: return node with value 8 # Do this is O(m+n) time where m and n are the lengths of the list and constant space class ...
20b853bc90f32089332bbd7649682ae13f9a629d
Nagendracse1/Competitive-Programming
/heap/Nagendra/Binary heap.py
2,411
3.796875
4
class MaxHeap: def __init__(self,max_size): self.max_size = max_size self.heap = [-1]*max_size self.heap_size = 0 def heapify(self,i): left = 2*i+1 right = 2*i+2 #print(self.heap) if left < self.heap_size and self.heap[i] < self.heap[left]: ...
7763049a6ae9c4fab6fcc1fcaa1a8a94ca657cb4
CrunchWillSupreme/Udemy
/Machine_Learning_A-Z/Regression/Simple_Linear_Regression/simple_linear_regression_WH.py
2,301
3.625
4
# Data Preprocessing # Importing the libraries import numpy as np import matplotlib.pyplot as plt import pandas as pd import os os.chdir(r'C:\Users\willh\Udemy\Machine Learning A-Z\P14-Machine-Learning-AZ-Template-Folder\Part 2 - Regression\Section 4 - Simple Linear Regression\Simple_Linear_Regression') # Importing ...
2b812f4edc2af4ba00dfd453ee937f6928cf4a0d
ExpertSeahorse/SimpleCode
/Scramblies.py
697
4
4
from collections import Counter import time def scramble(s1, s2): s1 = list(s1) s2 = list(s2) answer = [] for letter in s2: if letter in s1: answer.append(letter) s1.remove(letter) return answer == s2 def scramblerfaster(s1,s2): starttime= time.time() # Cr...
8b1448f7646ce1e2fd4043c38e96dfe3610fdfb2
AaraSekar/first
/even.py
97
3.9375
4
d=int(input()) if d>0: if d%2==0: print("Even") else: print("Odd") else: print("invalid")
3aba9dae7f62a22500aa06845aee6f3f63acc645
Aliskka/First
/04_data_structures/task_4_7.py
421
3.703125
4
# -*- coding: utf-8 -*- ''' Задание 4.7 Преобразовать MAC-адрес в двоичную строку (без двоеточий). Ограничение: Все задания надо выполнять используя только пройденные темы. ''' MAC = 'AAAA:BBBB:CCCC' MAC = MAC.split(':') print(MAC) print(str(int(MAC[0], 16))+str(int(MAC[1], 16))+str(int(MAC[2], 16)))
c847b94131e337b97c18f20cd9d557d6e00b174e
GabrielAmazonas/TextBreaker
/Models/Line.py
502
3.765625
4
from Block import Block class Line: def __init__(self, raw_string): self.blocks = [] self.raw_string = raw_string self.build_line_blocks() def build_line_blocks(self): """This method is called on the Text constructor. Passing the needed parameters to...
aa454ad43a4afc5c5b37b3db62688dcb5517d71e
ggorla/python
/helloworld/stringMethods.py
186
4
4
course = 'python for beginners' course.replace('P','J') len()#lenth of string general perpose 'Python' in course# this is a boolean to find Python in course print(course.upper())
0424f641fb71e1774f8e95282f1f560b54701e2d
BhagyeshDudhediya/PythonPrograms
/advanced-python/calculator-exercise/menu.py
2,440
4.1875
4
import sys import ops def print_menu(): print ("1. Simple Calc. 2: Scientific Calc. 3. Exit") ans = raw_input("Select Calculator of your choice: ") return ans ans = print_menu() while True: if (ans == '1'): print ("1. Add 2. Subtract 3. Multiply 4. Divide 5. Go Back") opera...
e8851bd675f32a69d1b1c1e6a8c40634acfa803a
CarinaGiovine/ProgramacionPy
/Accenture_code.py
2,162
3.859375
4
# -*- coding: utf-8 -*- """ Created on Fri Sep 17 10:46:50 2021 @author: CarinaG """ '''Haga un programa que lea un número indeterminado de valores, correspondientes a notas, finalizando la entrada de datos cuando se ingresa un valor de -1 (que no debe almacenarse). Después de esta entrada de datos, haga:...
fa26ede0ceaf739d8e735843d99647d5e192a885
Rpratik13/Algorithm_Implementations
/demonHuman.py
2,112
3.5
4
def isSafe(island1, island2): if len(island1) + len(island2) != 6: return False if island1.count('H') != 0 and island1.count('H') < island1.count('D'): return False if island2.count('H') != 0 and island2.count('H') < island2.count('D'): return False return True boat_on_left = [False] moved = [False] last...
f1aa67210fa789d6256b585e31a92411b55afb10
zoubohao/UC_Davis_STA_CS_Coureses
/ECS 32B/HW4/hash_map.py
7,922
3.625
4
from unordered_list import UnorderedList class Entry: def __init__(self, key = None, value = None): ### private attributions ### only change or get by method. self._key = key self._value = value def setKey(self, key): self._key = key def setValue(self,value): ...
4c77d5b5c47d00f271bddd092c8c2860afb1e3ba
PingRen32/LeetCodePersonalSolutions_Algorithms
/Medium/0146_LRU_Cache.py
1,752
3.625
4
# Design a data structure that follows the constraints of a Least Recently Used (LRU) cache. # # Implement the LRUCache class: # # LRUCache(int capacity) Initialize the LRU cache with positive size capacity. # int get(int key) Return the value of the key if the key exists, otherwise return -1. # void put(int key, int v...
c7b43638fc43c70772bafb02abeebdc9fe5b2a8f
Huayra-J/Helping_Hayden_in_His_Assignment
/q1.py
362
3.640625
4
#get file object reference to the file file = open("HIT137cdu.txt","r") #read content of file to string data = file.read() #get number of occurrences of the substring in the string count = data.count("You Make CDU") count2 = data.count("Great. You Make CDU") print('Number of You make CDU are:', count) print('Nu...