blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
0b83e723312c427ce98ef2652f38d44296429ca1
councit/python_toy_projects
/notes/section3-notes.py
4,701
4.28125
4
# # Variables: # name = "Taylor" # age = 30 # gender = "male" # # Impliment # print(f'Hi {name}. You are {age} years old!') # # string indexing [start, stop, step] # indexText = 'Hi taylor what beer do you like?' # print(indexText[0::2]) # # Immutability # # You cannont reasign a part or index of a string once ...
02f4ce94c002087b1695c58b0626a3440720cbe3
saierding/leetcode-and-basic-algorithm
/leetcode/二叉搜索树/Validate Binary Search Tree.py
877
3.875
4
# 98. Validate Binary Search Tree class TreeNode: def __init__(self, x): self.val = x self.left = None self.right = None class Solution: # 中序遍历的迭代算法 def isValidBST(self, root): if not root: return True pre = None stack = [] while stac...
1c8ed41e193f023eaf38fee38f67dedcd9b41110
Vijaya-Malini-A/guvi
/Code Kata/no_palin.py
82
3.703125
4
n = int(raw_input()) n = str(n) if n == n[::-1]: print "yes" else: print "no"
3b85489c5e60f5d991af261aa83a77f5e16451a8
subodhss23/python_small_problems
/medium_problems/box_completely_filled.py
482
3.9375
4
''' Create a function that check if the box is completely filled with the asterisk symbol * ''' def completely_filled(lst): for i in lst: if ' ' in i: return False return True print(completely_filled([ "#####", "#***#", "#***#", "#***#", "#####" ])) print(completely_filled(...
b41c8b1ab118b67ad257926743bbcfa6123e8031
Giu514/The-Python-Workbook
/Exercise/1-11.py
291
4.03125
4
#Fuel Efficiency covert from mpg to L/100 KM miles = float(input("Enter the number of miles done: ")) gallons = float(input("Enter the number of gallons consumed: ")) mpg = float(miles/gallons) can = float(235.214583 / mpg) print("{} mpg, equivalent to {:.2f} L/100km".format(mpg, can))
06ff28dcdeeca6f0eec3505513d719373c33b9ab
cloudsecuritylabs/learningpython3
/ch1/askforage2.py
377
4.09375
4
# Get the input and assign the variable in the same line age = input('How old are you?') height = input('How tall are you?') weight = input('what is your weight?') # Print using format print('You are {} years old, {} inches tall and you weight {} lbs'.format(age, height, weight)) # Print using f print(f'You are {age}...
cba693c4fa74b5d45525791b45683fb4ace5e1f4
rmbrntt/6.00.1x
/week 3/PSet3.5_hangman.py
3,546
4.21875
4
__author__ = 'ryan@barnett.io' def getGuessedWord(secretWord, lettersGuessed): ''' secretWord: string, the word the user is guessing lettersGuessed: list, what letters have been guessed so far returns: string, comprised of letters and underscores that represents what letters in secretWord have be...
f16bb3f50fe9d0c01416c89acd74ec8943fbd6b6
EetheridgeIV/LeetCodePy
/9.palindromeInt/solution.py
382
3.984375
4
def isPalindrome(x: int) -> bool: strX = str(x) for i,letter in enumerate(reversed(strX)): if(letter != strX[i]): return False return True def main(): print("Testing 123") print(isPalindrome(123)) print("Testing -123") print(isPalindrome(-123)) p...
87ae648c40bfc46f8576c74e7a7edcb65af7648d
xoiss/python-intf
/intf/__init__.py
5,164
4.03125
4
"""``intf`` provides a simple base class for integers with specified default formatting. Define your own subclasses derived from `BaseIntF` and specify desired formatting right with the class name. Decimal, binary, octal and hexadecimal formats are supported. See `BaseIntF` for more details. Example:: from intf i...
92109dbb30f3430fdf8c5962eee60b5476ad763c
Lesetja2010/Python-Book
/chapter3_endof_chpt_exercises.py
4,008
4.125
4
#! /usr/bin/env python """ Counts the number of occurences of the search_string in the input_file, and prints the lines containing the search_string. command line options: -i conducts a case 'insensitive' search, ie. "text", "Text", "TEXT", etc. will all be counted -m counts multiple occurences of the search string in ...
75606e7e394787afb4f3fb19ebb8abf6027f15f8
fugin213/CPU_python_exercise
/Answer_exercise7.py
471
4.0625
4
while 1==1: x=input("please enter a number: ") x=int(x) tag=0 if (x==1): tag=2 for i in range(x): if (i!=0 & i!=x): if (i!=1): if x%i!=0: continue else: tag=1 if tag==0: ...
d4875118a2ce89c197eed4ce7d71fc66d4dc3e2e
good5229/python-practice
/2577.py
613
3.765625
4
def count_num(num_1, num_2, num_3): if num_1 < 100 or num_2 < 100 or num_3 < 100: print("100 이하의 숫자가 입력되었습니다.") elif num_1 >= 1000 or num_2 >= 1000 or num_3 >= 1000: print("1000 이상의 숫자가 입력되었습니다.") else: result = num_1 * num_2 * num_3 count = [0 for i in range(10)] lis...
0fa51504eed8e748ed1efbf57d5316a5623c5dcf
MiroVatov/Python-SoftUni
/Python Basic 2020/Exam 06 - 06 high jump ver 3.py
645
3.671875
4
height_target = int(input()) letva_height = height_target - 30 jump_counter = 0 fail_counter = 0 while letva_height <= height_target: fail_counter = 0 for i in range(1, 4): jump_height = int(input()) jump_counter += 1 if jump_height > letva_height: letva_height ...
a8b97ba9bb36ccdbc8ef66e725a8f3c0b2df7a57
rafaelperazzo/programacao-web
/moodledata/vpl_data/35/usersdata/101/13444/submittedfiles/dec2bin.py
187
3.828125
4
# -*- coding: utf-8 -*- from __future__ import division p = str(input('Digite um inteiro p: ')) q = str (input('Digite um inteiro q: ')) if p in q: print ('S') else: print ('N')
75bcf40a7e6632fa27b03e872b73a899c8e4164c
Lyppeh/PythonExercises
/Introductory Exercises/ex017.py
256
3.671875
4
from math import hypot cateto1 = float(input('Comprimento do cateto oposto: ')) cateto2 = float(input('Comprimento do cateto adjacente: ')) hipotenusa = hypot(cateto1 , cateto2) print('O comprimento do hipotenusa sera : {:.2f}'.format(hipotenusa))
558a6d962a78370d9750a543593e32c4b498d42e
standrewscollege2018/2020-year-11-classwork-htw0835
/hello world.py
255
3.546875
4
""" I'm so smart and have such a huge veiny brain. I made this all on my own on my very first try. I even figured out how to join strings. Put me in year 13 digi already, Phil. """ #This makes the words show up. print("Hello world!"+" I'm experimenting!")
c82bdefc311827fe5f6d6fad176925a8d6aa6cf8
Jane11111/Leetcode2021
/075_3.py
885
3.796875
4
# -*- coding: utf-8 -*- # @Time : 2021-06-04 14:55 # @Author : zxl # @FileName: 075_3.py class Solution: def sortColors(self, nums ) -> None: """ Do not return anything, modify nums in-place instead. """ arr = [0,0,0] for num in nums: arr[num] += 1 ...
0bd3743cd02529a99339f43ce394c1d0e2039d04
Johnnyprox/APRG_projekt
/enc.py
8,218
3.5625
4
from copy import copy def number_of_matrixes(message): """This functin returns the number of matrixes""" n_o_m = len(message) // 16 + 1 return n_o_m def fill_places(message): """ This function fills all places in the matrix """ reminder = len(message) % 16 if reminder != ...
0a4ee4985d3d15b2b7aa081d6c150d99387fcb81
chavhanpunamchand/PythonPractice
/Strings/areaofcircle.py
342
4.5
4
''' 4. Write a Python program which accepts the radius of a circle from the user and compute the area. Go to the editor Sample Output : r = 1.1 Area = 3.8013271108436504 ''' radius=float(input("Enter the radius of circle :")) pie_value=3.141592653589793238 area_of_circle=pie_value* radius**2 print("The area of circle...
b8a9e3ce715273f69de5e20673c0e5678b48fd23
tiagomenegaz/othello-s
/initialiseBoard.py
450
4.03125
4
## 2nd Assignment #Question 1 #def initialiseBoard(n): #initialiseBoard(n) returns the initial board for an Othello game of size n. def initialiseBoard(n): zeros = [0]*n for i in range(0,n): zeros[i]=[0]*n pos2 = int(len(zeros)/2) #Position 4 pos = int(pos2-1) #From example -> Positi...
570d2801e21e3eb5b8875b228326fb0c3561618b
i-aditya-kaushik/geeksforgeeks_DSA
/Matrix/Codes/transpose.py
1,296
4.4375
4
""" Transpose of Matrix Write a program to find transpose of a square matrix mat[][] of size N*N. Transpose of a matrix is obtained by changing rows to columns and columns to rows. Input: The first line of input contains an integer T, denoting the number of testcases. Then T test cases follow. Each test case contains ...
ef0232d07109e64dec7df7522cac7a761e6b3c73
8563a236e65cede7b14220e65c70ad5718144a3/introduction-python-programming-solutions
/Chapter04/0004_demonstrate_function_scope.py
587
4.09375
4
''' Program 4.3 Demonstrate Using the Same Variable Name in Calling Function and Function Definition arguments passed by the calling program and the parameters used to receive the values in the function definition may have the same variable names exist in different scopes however and thus independen...
b5af0e48da34b1bf1f3430ac7de86994aa43a93a
RaviAnthony/Python-practice-
/dict.py
1,091
3.75
4
states = {'Telangana':'TS','Andhra':'A','Tamilnadu':'TN','Delhi':'D'} cities ={ 'hyderabad':'hyd','vijayawada':'vz', 'Madras':'M', 'Nizam':'NZ'} cities['TS'] = 'Secundrabad' cities['A'] = ' warangal' print '-' *10 print "TS State has:", cities['TS'] print " A State has :", cities['A'] print '-'*10 print " Telangan...
bbe81caca211f9d5be3cf3fe9652b902888b8d73
nuljon/Python-Course-Files
/BasicCoding_Drills/statements.py
231
4.15625
4
# Define variables x = 1 # start an if statement if x == 10: print 'x = 10' # if x does not equal 10, but equals 9 elif x == 9: print 'x = 9' # if not 10 or 9 then ... else: print 'x does not equal 9 or 10'
45160f2d5b3685bc401cbd2b8171760d7de58baa
joshuazd/equations
/root.py
925
3.625
4
class Infix(object): def __init__(self, function): self.function = function def __ror__(self, other): return Infix(lambda x, self=self, other=other: self.function(other, x)) def __or__(self, other): return self.function(other) def __rlshift__(self, other): return Infix(la...
55f876d47509ac024b845c08ffa091aef743e39c
ivanpedro/pythondevelop
/cesaro/cesaro/cesaro.py
411
3.75
4
#cesaro from turtle import * from math import * from random import * import random, string def piramide (size, level): if level == 0: for i in range (3): forward(size) left (120) else: coord =[(0,0),(size/2,0),(size/4,(size/2) + sin(60))] for x,y in coord: penup() goto(x,y) pendown() pira...
be5749f5d497c3f57d03ca62c4f4db88920e312b
bandeirafelipe3/Programa-oWeb2017
/Exercicio_2/lista2questao8.py
303
4
4
def quociente(x,y): return x/y def resto(x,y): return x % y def main(): n1 = float(input("Primeiro numero = ")) n2 = float(input("Segundo numero = ")) n3 = int(input("Digite um numero = ")) print("Quociente = ", quociente(n1,n2)) print("Resto = ", resto(n1,n2)) print("Numero = ", n3) main()
bfbb129a89e1e64a3d13f6b2db508eae496a9cba
marcardioid/DailyProgrammer
/solutions/234_Intermediate/solution.py
528
3.65625
4
with open("enable1.txt") as file: dictionary = set(file.read().splitlines()) def spellcheck(word): fault = None for n in range(len(word) + 1): if not any(x.startswith(word[:n]) for x in dictionary): fault = "{}<{}".format(word[:n], word[n:]) break return fault if fault e...
48f15737f477a6fc827065e871f7a7af8e950a0a
johnnymango/IS211_Assignment3
/IS211_Assignment3.py
2,965
3.546875
4
#!/usr/bin/env python # -*- coding: utf-8 -*- # Imported Modules import argparse import urllib2 import csv import re # Sets up the argparse to accept the url argument when the py file is executed. parser = argparse.ArgumentParser() parser.add_argument("--url", type=str, required=True) args = parser.parse_args() url =...
c3fb87e6d81da09ef88e319b5d1f009850582bf9
VivekRajyaguru/Python-Learning
/Dictionary.py
302
3.796875
4
items = ["abc","xyz","pqri",123,456] def separateList(items): str_item = [] num_item = [] for i in items: if isinstance(i,str): str_item.append(i) elif isinstance(i,int) or isinstance(i, float): num_item.append(i) else: pass return str_item,num_item print(separateList(items))
aad9121a97178e282e9b1fefb682ba1dc3a5302b
keerthanachinna/set51
/fibonacci.py
178
4.28125
4
def fibonacci(n): if(n<=1): else: return(fibonacci(n-1)+fibonacci(n-2)) n=int(input("enter the number of terms:") print("fibonacci series:") for i in range(n) print fibonacci(i)
779524046011497965c0fe624d573eeebb493185
kimmobrunfeldt/analyze_passwords
/anapass/logger.py
762
3.515625
4
#!/usr/bin/python # -*- coding: UTF-8 -*- # """ Simple logger module. """ import time import sys __all__ = ['Logger'] class Logger(object): """Logs everything with timestamp""" def __init__(self, start_time): self.start_time = start_time def log(self, line, end_line=True): ...
db7bab9f9403c466b0dc4e1cd98e31d4b7f59d4e
N0nki/MyAlgorithms
/search.py
1,753
3.578125
4
# coding: utf-8 """ サーチアルゴリズム * リニアサーチ * バイナリサーチ """ from __future__ import division import sys def liner_search(collection, elm): """リニアサーチ""" for e in collection: if e == elm: return True return False def binary_search(collection, elm): """バイナリサーチ""" try: _abort_sor...
4f9663149cb628b6f98d1a2c5b928ba5aaecb302
jessefilho/sentimentanalysis
/ressources/scripts/trimngram.py
389
3.5625
4
#!/usr/bin/env python # This script aims at removing useless words from a sentiment classification corpus. import sys import re from nltk.util import ngrams if len(sys.argv) != 2: sys.exit() for line in sys.stdin: words = line.strip().split() tokens = [token for token in words if token != ""] output...
316277fdb2fa21a4b40568e8fd49068fd79def96
abinezer/HackerRank-Problem-Solving
/prep/TwoStrings.py
565
3.734375
4
#!/bin/python3 import math import os import random import re import sys # Complete the twoStrings function below. def twoStrings(s1, s2): s_one = {} for i in s1: s_one[i] = 1 for i in s2: if i in s_one: return 1 return 0 if __name__ == '__main__': q = int(input()) ...
28ca5a4b9b2a44c63e1518a4e9726b727e7d3f67
lvonbank/IT210-Python
/Ch.06/R6_1abcdefg.py
1,005
3.96875
4
# Levi VonBank # Produces a list of [1,2,3,...10] listA = [] for i in range(1,11): listA.append(i) # Produces a list of [2,4,6,...20] listB = [] for i in range(0,22,2): listB.append(i) # Produces a list of [1,4,9,...100] listC = [] for i in range(1,11): listC.append(i*i) # Produces a list of [0,...0] li...
3917c95b6f17f70e6f5e2fb068ff43fe1a815ada
fangpings/Leetcode
/202 Happy Number/untitled.py
596
3.546875
4
class Solution(object): def isHappy(self, n): """ :type n: int :rtype: bool """ if n == 0: return False if n == 1: return True square = 0 log = set() log.add(n) s = str(n) while square not in log: ...
a03120be7bb444bebb09753bb8289f05eea18ccf
ayanza/Cisco
/practica3.py
323
3.875
4
#Variables print ("VARIABLES") a = 5 print (a) print (type(a)) a = "cinco" print (a) print (type(a)) nombre = u"Ángela" #anteponiendo la u a la cadena codifica a unicode y evita los errores de tildes print (nombre) #las mayus/minus son diferentes año ="2016" print (año) #Constantes: no hay formato de definición
cbde88933f594c7040854ca18508b0faa72dcdac
YiyingW/rosalind_yw
/permutation.py
301
3.703125
4
import itertools def permutation(number): alist=[i for i in range(1, number+1)] return list(itertools.permutations(alist)) def main(): print (len(permutation(7))) for item in permutation(7): result = '' for n in item: result+=str(n)+' ' print (result) if __name__=="__main__": main()
1d21796fdfdce15e3cd74dc914c805e9eb379833
gurramdeepika/python_programming
/PycharmProjects/no1/9_Day/debugger_ex2.py
553
3.59375
4
import pdb def for_jump(count): print("entered in to the function") lis = [1,2,3,4,5,6] print("reaching to the for loop") for var in lis: print("enter in to the loop") count += 1 print(var) print(count) pdb.run("for_jump(2)") # from forloop to outside but cannot jump ...
818a5ef63d0689df1c1e114b75ec3fbe317b3827
Sarthak-source/repos
/college/college.py
3,608
3.625
4
import numpy as np # linear algebra import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv) import matplotlib.pyplot as plt #Data Visualization import seaborn as sns #Python library for Vidualization # Input data files are available in the "../input/" directory. # For example, running this (by...
9763163f9e92a778aaecbbe86bfa8fa771fb16a2
AmitD26/Hashing-1
/isomorphic_strings.py
488
3.734375
4
#Time complexity: O(length) #Space complexity: O(1) class Solution: def isIsomorphic(self, s: str, t: str) -> bool: h1 = {} h2 = {} for i in range(0, len(s)): if s[i] in h1 and t[i] != h1[s[i]]: return False h1[s[i]] = t[i] ...
0b2f3dfcd5f187b88692f6c8c8497ddb945603c9
rppy/course
/for_list_enumerate.py
417
4.40625
4
# iterating through a list by items for item in ['apple', 'banana', 'pear']: print(item) print() # iterating through a list by index fruits = ['apple', 'banana', 'pear'] for index in range(len(fruits)): print(f'{index}. fruit is {fruits[index]}') print() # enumerate to get item and index fruits = ['apple', ...
2b57e6e307b79fab811eb4a4e17fe8151fbe44c7
daks001/py102
/4/Lab4_Act1.py
1,017
3.75
4
# By submitting this assignment, all team members agree to the following: # “Aggies do not lie, cheat, or steal, or tolerate those who do” # “I have not given or received any unauthorized aid on this assignment” # # Names: DAKSHIKA SRIVASTAVA # MAHIRAH SAMAH # MICHAEL MARTIN # JA...
f392cba59873a41837e74c9f77e2e9fdf0fc5c5c
ivklisurova/SoftUni_Python_Advanced
/Comprehension/matrix_modification.py
692
3.546875
4
n = int(input()) matrix = [list(map(int, input().split(' '))) for x in range(n)] while True: args = input().split() command = args[0] if command == 'END': break row = int(args[1]) col = int(args[2]) value = int(args[3]) if command == 'Add': if 0 <= row <= len(matrix) - 1 an...
75380903ea4ded4cd9489fe891fc772ea46d26dc
sofiathefirst/AIcode
/07python3Learn/mislice.py
507
3.515625
4
def cnt(n): while 1: yield n n+=1 c = cnt(0) ''' c[10:20] Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: 'generator' object is not subscriptable ''' import itertools for x in itertools.islice(c,10,20): print('fisrt \n',x) for x in itertools.islice(...
628baf482f95ae5fead2b066eebc90c99cff7b65
kimjieun6307/itwill
/itwill/Python_1/chap05_Function/lecture/step01_func_basic.py
2,411
3.78125
4
''' 함수(Function) - 중복 코드 제거 - 재사용 가능 - 특정 기능 1개 정의 - 유형) 사용자 정의 함수, 라이브러리 함수 ''' # 1. 사용자 정의 함수 ''' 형식) def 함수명(매개변수) : 실행문1 실행문2 return 값1, 값2, ... ''' # 1) 인수가 없는 함수 def userFunc1(): print('인수가 없는 함수') print('userFunc1') userFunc1() # 인수가 없는 함수 userFunc1 # 2) 인수가 있는 함수 def userFunc2(x,y): ...
a8e46d2bad9c6fb71eea3b20d7cad4cab34d7c0d
Erick-Fernandes-dev/Python
/exercicios/importante/aula.py
961
4
4
continuar = True while continuar: op = input("DDigite o operador: ") n1 = int(input("Digite um valor: ")) n2 = int(input("Digite um outro valor: ")) if op == '+': print(n1+n2) resposta = str.upper(input("Deseja continuar, digite (s) para 'sim' e (n) para 'não': ")) if resposta...
fdb55709f3cdcc22ac38f5e5ec221c281b573c3f
abhishekthukaram/Flask-repo
/number-comparison,py.py
222
3.78125
4
def numbercompare(n): newlist = set(n) if len(newlist)== len(n): print "The numbers are unique" else: print "the number is repeated" numbercompare([1,2,3,4,5]) numbercompare([1,1,2,2,3,4,5])
64167acb2a8510d3d661f489d941e6b9615e6e83
dhruv395/Python_tutorial
/Networking/fileclient.py
375
3.75
4
## create a file client that will send the name of the file it want and display the contents of file. import socket #importing a socket module s=socket.socket() #create a object s.connect(('localhost',8080)) # connect to server fileName=input("enter a file name:") s.send(fileName.encode()) ...
fd8354ac13d0cf97db21e37aa3b438fbcc034900
hsaad1/Week-1---In-your-Interface
/main.py
614
3.71875
4
class Teams: def __init__(self, members): self.__myTeam = members def __len__(self): return len(self.__myTeam) # Question 1 def __contains__(self, item): return item in self.__myTeam # Question 2 def __iter__(self): yield from self.__myTeam ...
d1dab7b2bf0aa39872ffbaaa1deb3b2d612dec17
SANDHIYA11/myproject
/Max.py
149
4.21875
4
Lst=[] Num=int(input("Enter how many numbers:")) for i in range(Num): Number=int(input("Enter the number:")) Lst.append(Number) print(max(Lst))
1ab37fbe1a8d710bb197d0e6d93efc8a6fd6987d
Argen-Aman/chapter2task21
/task21.py
263
4.3125
4
str1 = input('Type (enter) string:\n') str1 = str1.split() start = 0 def max_word (str1): global start for i in str1: if len(i) > start: start = len(i) x = i print('The longest word is: ' + str(x)) max_word (str1)
24f61b33265ba599eec451071c0955a9d1fea527
danoliveiradev/PythonExercicios
/ex018.py
296
4.0625
4
from math import radians, sin, cos, tan angulo = float(input('Digite um ângulo em graus: ')) seno = sin(radians(angulo)) coss = cos(radians(angulo)) tang = tan(radians(angulo)) print('Para o ângulo {}º: \nseno = {:.3f} \ncosseno = {:.3f} \ntangente = {:.3f}'.format(angulo, seno, coss, tang))
5e584ef0c3da081fc39213aaa61c59ecec086059
xhlubuntu/leetcode_python
/leetcode_2.py
1,303
3.71875
4
#2 ac # Definition for singly-linked list. class ListNode(object): def __init__(self, x): self.val = x self.next = None class Solution(object): def addTwoNumbers(self, l1, l2): """ :type l1: ListNode :type l2: ListNode :rtype: ListNode "...
bf6295356ade384bdf53215237f7efeb3c1cbf84
rraj29/Sorting_Algorithms
/bucket_sort.py
1,896
4.03125
4
# Here, we create buckets and distribute the elements in the buckets # sort the elements within the buckets # then, simply merge the buckets # Number of buckets = round(sqrt(total no. of elements)) # Appropriate bucket for any element(value) = ceil(Value * No. of Buckets/Max Value in the array) # ceil= ceiling functi...
25fab71d1e6668a97c4ceb4ccd9cd1be45a44d48
astroidis/gml
/gisclass.py
3,489
3.515625
4
from math import radians, sin, cos, acos class _Node: def __init__(self, nodeid, latitude, longitude): self.id = nodeid self.lat = latitude self.lon = longitude def __str__(self): return f"Node {self.id} ({self.lat} {self.lon})" class _Edge: def __init__(self, source, ta...
4c5bb0bfa4bf1272f9a4a50fc3d351e9f27fe93c
r259c280/CS101
/6.22 (LAB).py
3,172
3.96875
4
# Type all other functions here #shorten_space() function. def shorten_space(usrStr): split = usrStr.split() return ( " ".join(split) ) #replace_punctuation() function. def replace_punctuation(usrStr): return usrStr.count("!"), usrStr.count(";"), usrStr.replace("!",".").replace(";",",") #fix_capitil...
1b8269debf9b69dc1618f2605520ff580fc374c8
durandal42/projects
/hearthstone/arena.py
984
3.5
4
import random import collections def new_challenger(): return (0,0) def finished(player): return player[0] >= 12 or player[1] >= 3 def play_round(pop): pop.sort() for i in range(0, len(pop), 2): pop[i], pop[i+1] = play_game(pop[i], pop[i+1]) def play_game(p1, p2): if random.choice([True, False]): ...
c6ec6d4b05892d2b0a4e86a6321162c2e6fc660a
YaqoobAslam/Python3
/Chapter01/fahrenheit_to_celsius.py
201
3.953125
4
def fahrenheit_to_celsius(temp): newTemp = 5*(temp-32)/9 print("The Fahrenheit temperature",temp,"is equivalent to",newTemp,end='') print(" degrees Celsius") fahrenheit_to_celsius(50.)
47fbc8c8bc19cdec5703aba26e11e440073538fc
rproepp/spykeutils
/spykeutils/progress_indicator.py
1,633
3.59375
4
import functools class CancelException(Exception): """ This is raised when a user cancels a progress process. It is used by :class:`ProgressIndicator` and its descendants. """ pass def ignores_cancel(function): """ Decorator for functions that should ignore a raised :class:`CancelException` a...
ce80b79b3d6c15b24c5624275137c3633ce47a76
AdrianMartinezCodes/PythonScripts
/E4.py
165
3.984375
4
num = int(input("Please enter a number to divide: ")) diviser_list = [] for i in range(1,num): if num%i == 0: diviser_list.append(i) print(diviser_list)
f0b2d9453dd5669e2c619106bfddecf4139e4c57
Dorcy-ndg3/LeetCode
/Git/存在重复元素.py
394
3.5625
4
class Solution(object): def containsDuplicate(self, nums): """ :type nums: List[int] :rtype: bool """ if len(nums) <= 1: return False nums.sort() for index in range(0,len(nums)-1): if nums[index] == nums[index +1]:#or nums[index] == num...
04386bd05e5fb66dc719cfbb0e5a3d9dac344619
FCnski/Python-Exercises
/Pssw_strenght.py
4,453
4.09375
4
import re def menu(): print("1. Verify the strenght of your password.") print("2. Exit.") while True: try: escolha = int(input("Sua opção:")) if escolha == 1: # se a escolha for == 1, ele executará a função de verificação / If you choose 1, the program will execute ...
baeea74e07eed30466705e51a165c1850e2d83bf
MrHamdulay/csc3-capstone
/examples/data/Assignment_2/wchgil001/question3.py
252
4.09375
4
import math i=math.sqrt(2) pi = 2 n = 0 while n != 1: n = 2/i i = math.sqrt(2+i) pi = pi * n print('Approximation of pi:',round(pi,3)) r=eval(input('Enter the radius:\n')) area=(pi*r**2) print('Area:',round(area,3))
0d7b41a253d00394163244e0a42489950767e24d
vipulchakravarthy/6023_CSPP1
/cspp1-assignments/m4/p1/vowels_counter.py
742
4.09375
4
''' #Assume s is a string of lower case characters. #Write a program that counts up the number of vowels contained in the string s. #Valid vowels are: 'a', 'e', 'i', 'o', and 'u'. For example, if s = 'azcbobobegghakl', #your program should print: #Number of vowels: 5 ''' def main(): ''' #Write a program that co...
93c8e5ff846157cf1280465405cbc53619f7e8b2
manimaran89/python_script
/chn.py
226
3.921875
4
from copy import deepcopy a=range(6) b=deepcopy(a) b.reverse() def f1(m): for i in range(6): yield m[i] def f2(m): for i in range(6): yield m[i] f=f1(a) g=f2(b) for i in range(3): print g.next() print f.next()
bd640fb19496f0d385f1c8add3f519cd5ca0e1ee
khurath-8/SDP-python
/assignment1_simplecaculator_58_khurath.py
763
4.1875
4
a=float(input("enter a number : ")) b=float(input("enter another number :")) c=input("enter operation(add,subract,multiply,divide,reminder,exponent,floordivision):") ## ADDITION if(c=="add"): res_add=a+b print(res_add) ## SUBRACTION elif(c=="subract"): res_sub=a-b print(res_sub) ...
fc46ba674a97201f5857cb9b2d2767450c926593
enchainingrealm/UbcDssgBccdc-Pipeline
/util/preprocessor.py
4,088
3.75
4
import json import re def preprocess(df, organisms=False): """ Preprocesses the data in the given DataFrame. Preprocesses result_full_descriptions: - Converts all result_full_descriptions to lowercase - Removes all characters that are not letters, numbers, spaces, or pipes - Replaces...
5ee176d3e95f55f49a8ed6187ba5e5d8f36a1bb2
kjco/bioinformatics-algorithms
/ba4b-peptide-encoding/peptide_encoding_v2.py
3,769
4.09375
4
# Programming solution for: # Find Substrings of a Genome Encoding a Given Amino Acid String # http://rosalind.info/problems/ba4b/ # # There are three different ways to divide a DNA string into codons for # translation, one starting at each of the first three starting positions of # the string. These differen...
415e63acc4bba306511adb334db0aa714b12b928
aston-github/CS101
/F19-Assign2-Turtles/TurtleShapes.py
1,339
3.90625
4
''' TurtleShapes.py @author: ASTON YONG ''' import turtle, BoundingBox import random def drawOneShape(turt, size): ''' Draws a square with the side length of size input ''' for i in range(4): turt.forward(size) turt.right(90) def drawOneIceCrea...
83f017e7653fd447a3aefce1cf1ec899f58fe41b
everbird/leetcode-py
/2015/SubstringWithConcatenationOfAllWords_v0.py
946
3.59375
4
#!/usr/bin/env python # encoding: utf-8 class Solution: # @param {string} s # @param {string[]} words # @return {integer[]} def findSubstring(self, s, words): if len(words) == 1: word = words[0] lenw = len(word) r = [] for i, c in enumerate(s[:-l...
e8eaaca8886645f7ba424f70beef5eacfa627c26
sajjad065/assignment2
/Datatype/qsn22.py
475
3.78125
4
total=int(input("How many string do you want to input in list ")) lis=[] list_dub=[] count=0 for i in range(total): str1=input("Enter strings ") lis.append(str1) list_dub.append(lis[0]) for i in lis: for j in list_dub: if(i==j): count=count+1 if(count>=1): count=0 e...
470b761926fd82fdae8db4c160aa2f6b4105290e
gtxmobile/leetcode
/14.最长公共前缀.py
379
3.53125
4
# coding:utf-8 class Solution14(object): def longestCommonPrefix(self, strs): """ :type strs: List[str] :rtype: str """ if not strs: return "" strs.sort() first = strs[0] last = strs[-1] i = 0 while i < len(first) and first[...
a30ae354b55b8c2335dca72a9d54905e626a5ad9
saddagarla/shunsvineyard
/my-python-coding-style-and-principles/my_package/my_data_structure/my_tree.py
6,128
4.15625
4
# Copyright © 2018 by Shun Huang. All rights reserved. # Licensed under MIT License. # See LICENSE in the project root for license information. """A binary tree example to demonstrate different tree traversal, including in-order, pre-order, post-order, and level-order. """ import enum # Enum to define traversal types...
954d271d1621447ca25d38ff6be15a3b12a31763
1chaechae1/Ant-Man
/1주차/sequential_search.py
382
3.6875
4
import sys # 순차 탐색 구현 def sequential_search(n, target, array): for i in range(n): if array[i] == target: return i+1 # 인덱스가 아닌 '몇'번째 데이터인지 변환 array = [i for i in range(10, 30, 2)] n = len(array) target = 14 res = sequential_search(n, target, array) print(f"{target} 데이터는 array의 {res}번째에 존재!")
831cf73714cfc7f4edd615bc539c47f135395944
dhrubach/python-code-recipes
/simple_array/h_buy_sell_stock_twice.py
1,070
3.609375
4
########################################################################### # LeetCode Problem Number : 123 # Difficulty Level : Hard # URL : https://leetcode.com/problems/best-time-to-buy-and-sell-stock-iii/ ########################################################################## from typing import List class BuyS...
60da758c2a44ed111ff8833bb19e5ecfeb945c5f
limapedro2002/PEOO_Python
/Lista_06/Manuele-Myllene/Questão_03/Pessoa_3.py
1,155
3.9375
4
from Endereco import Endereco #Crie um diagrama de classes que represente uma classe Pessoa com os atributos privados identificador, #nome e CPF, e uma classe Endereço com os atributos número da casa, rua, cidade, estado e pais. Nesse caso #uma pessoa deve “agregar” um ou vários endereços. Implemente métodos...
a867ee7a0b82913ce8ef0c013cfff62402acb99a
arrancapr/Clases
/Python1ArrancaPr/Samples/firstfunction.py
469
3.640625
4
def firstFunction(throwError): if throwError: raise ValueError("showing the error functionality") else: print("function works yeah") def addHello(name): print("Welcome to the class: " + name) studentList = ["Davin", "Sarah", "Louie", "Aaron"] for var in studentList: addHello(var) d...
ed795239f4cfbe780864d1584de2dda8e3e60ffe
maha03/AnitaBorg-Python-Summer2020
/Week 7 Coding Challenges/Functions/squareroot.py
502
4.375
4
#Script: squareroot.py #Author: Mahalakshmi Subramanian #Anita Borg - Python Certification Course #DESCRIPTION: A Python program to find the square root of a number and return the integral part only '''Sample Input : 10 Sample Output : 3 ''' import math def squareroot(n): squareroot=math.sqrt(n) answer=int(s...
c1ec323b5e7ecfb52fb8b57d910a1ba8b32d90cd
RodrigoVillalba/Tp-estadistica
/main.py
1,616
3.578125
4
# Tp de estadistica import random import math #1. Utilizando únicamente la función random de su lenguaje (la función que genera un número aleatorio uniforme entre 0 y 1), def calcularAleatorio(): numAleatorio = random.random() return numAleatorio #implemente una función que genere un número distribuido Bernoul...
ac03cf401fa185d6e81a164a9ddc0ccbd3ae4bfb
MohamedAly8/Learning_OpenCV
/Project6.py
999
3.515625
4
import cv2 import numpy as np img = cv2.imread('chessboard.png') #Convert image to grayscale gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY) #Runs Shi-Tomasi Corner Detection Algorithm args: (src image, max num of corners, quality 0 to 1, minimum euclidean distance between corners delta x^2 + delta y^2 = r^2 ) corners...
2a942cad205a3631e1b5d58b75337f666b29cd35
gitpbg/learnmatplotlib
/bar.py
378
3.640625
4
import numpy as np import matplotlib.pyplot as plt import sys #histogram and barchart x = np.arange(1, 10, 2) print(x) y = 10*np.random.rand(5) x2 = np.arange(0, 10, 2) y2 = 10*np.random.rand(5) plt.bar(x, y, label='bars1', color='blue') plt.bar(x2, y2, label='bars2', color='purple') plt.xlabel('x') plt.ylabel('y') ...
9ddacb8801d5d0ee53c2b1cb21b56b9ebc5c1400
hongminpark/prgrms-algorithms
/stack_queue/lv2_프린터_queue.py
645
3.65625
4
# https://programmers.co.kr/learn/courses/30/lessons/42587 from queue import Queue def solution(priorities, location): q = Queue() count = 0 for i in range(1, len(priorities)): q.put(i) max_idx = 0 q.put(max_idx) while True: now = q.get() if q.qsize() == 0: ...
891f371f0fc3238669506a64f9018cd2e1ec14d4
cameronkabati/pythonexample
/python.py
189
4.25
4
#prints the output hello world print ('Hello world') #Using strings and the input function using print name =input('Please enter your name: ') print('hello', name, 'nice to meet you')
41818fafa3ba81b1c661072fc03f6b82dffa0284
sejunova/algorithm-study
/cracking_coding_interview/array_and_string/string_compression.py
678
3.609375
4
def string_compression(string): cur_char, char_count = string[0], 1 compression_list = [] for i in range(len(string)): if len(compression_list) > len(string): return string if i + 1 == len(string): compression_list.append(cur_char) compression_list.append(...
2fc25e360354d6bd3d522b0dcd44523227f578fe
vic-ux/py_work
/parrot.py
699
4.1875
4
prompt = "\nTell me something, and I will repeat it back to you:" prompt += "\nEnter 'quit' to end the program. " message = "" while message != 'quit' : message = input(prompt) if message != 'quit': print(message) prompt = "\nTell me something, and I will repeat it back to you:" prompt += "\nEnter 'quit' to ...
9fc18140e2ec19aa065d66a917216b83a9407873
kamaljahangir/adhocpywinter2018
/adhoc/input.py
209
3.9375
4
#!/usr/bin/python import time n1=raw_input("enter a number : ") # delay of 2 second time.sleep(2) n2=raw_input("enter a number : ") # typecast to int print "sum of given numbers ",int(n1)+int(n2)
5c15b534468b82cc781f80a1dfa70614f4a31755
AgastyaTeja/HackerRank
/ModifiedKaprekarNumbers.py
801
3.53125
4
#!/bin/python3 import math import os import random import re import sys # Complete the kaprekarNumbers function below. def kaprekarNumbers(p, q): output="" for i in range(p,q+1): n = i**2 temp=str(n) if len(str(n))%2==0: d=len(str(n))//2 else: d=(len(str...
946fd6d911f39890360b6b8d1f64a1aa646db4b6
AthosFB/Exercicios-Python
/ExercícioDoCurso/091.py
597
3.515625
4
import random import time from operator import itemgetter jogo = {"jogador1": random.randint(1, 6), "jogador2": random.randint(1, 6), "jogador3": random.randint(1, 6), "jogador4": random.randint(1, 6)} ranking = {} print("Valore Sorteados: ") for k, n in jogo.items(): print(f"{k} recebe \033...
43ca6390c9b115ccbc3fed873bcc0215b3bad5ae
MrHamdulay/csc3-capstone
/examples/data/Assignment_3/vrmnic005/question2.py
243
4.1875
4
def print_triangle(height): for row in range(height): print(" " * (height - row - 1) + "*" * (2*row + 1)) if __name__ == "__main__": height = int(input("Enter the height of the triangle:\n")) print_triangle(height)
ce68db4f2c2b74900948df93b42c13dbfea481c5
Kvazimado/Kvazi
/Калькулятор 2.py
223
4.0625
4
a = float (input("NUM 1 \n")) b = float (input("NUM 2 \n")) w = float (input("NUM 3 \n")) c = input("RAW \n") r = 0 if c=="+": r=a+b+w elif c=="-": r=a-b-w elif c=="*": r=a*b*w elif c=="/": r=a/b/w print (r)
b66024ce1f63908c281187cacaf37c478e2940e7
navneetspartaglobal/Data21Notes
/reptile.py
457
3.640625
4
from animal import Animal class Reptile(Animal): def __init__(self): super().__init__() self.cold_blooded = True def use_venom(self): print("if i have venom i am going to use it") def moving(self): print("moving but as a snake") def __repr__(self): return f"...
c94ba5cb9058f4199101ed5205fe8bb87f0b15a1
ivanovkalin/myprojects
/softUni/tayloring_workshop.py
657
3.5
4
usd_exchange_rate = 1.85 number_of_rectangle_tables = int(input()) length_of_rectangle_tables_in_m = float(input()) width_of_rectangle_tables_in_m = float(input()) total_size_of_table_covers = number_of_rectangle_tables * (length_of_rectangle_tables_in_m + 2 * 0.30) * (width_of_rectangle_tables_in_m + 2 * 0.30) tot...
100461bfaca0972089f14a34c5d800473630ac5a
TheEnzoLobo/flvs
/2-06.py
304
4.09375
4
amount = int(input("How many products you like? ")) total = float(0.00) for side in range(amount): product = str(input("Product: ")) price = float(input("Price: $")) print(product + " $" + str(price)) total = total + price print("Your total is " + " $" + str(total))
865b17bc1d2a6e8ebbdba35e7c53a2b73af6b1c3
mzakjang2/WORKSHOP2
/string/string_format.py
221
3.8125
4
age = 22 txt = "My name is BM, and I am {}" result = txt.format(age) print("result:", result) # result: My name is BB, and I am 21 # เอาage มาใส่ในtxt โดยใช้ฟังก์ชันformat
e36bb1f0024cb25690a4b4174613bd206beefba1
aaron-maritz/ctci_solutions
/chapter_1/q_5.py
1,828
4.09375
4
# Aaron Maritz # Question 1.5 # One Away -> Three types of edits that can be performed on strings # Insert char, Remove char, Replace char, Given two strings determine if they are one edit (or zero) away # example -> pale, pale -> true, ple, pale -> true, pale, bake -> false # Thoughts -> first check le...
1b40053ed8bccfa314868eed929ad575488c0eb6
Ezeaobinna/Python-Basics-Algorithms-Data-Structures-Object-Oriented-Programming-Job-Interview-Questions
/Algorithms/Sorting and Searching/sorting/bubble sort/bubble-sort-recursive.py
323
3.8125
4
alist: list = [54, 26, 93, 17, 77, 31, 44, 55, 20] def bubbleSort(alist, n: int): if n < 2: return for i in range(n): if alist[i] > alist[i + 1]: alist[i], alist[i + 1] = alist[i + 1], alist[i] bubbleSort(alist, n - 1) print(alist) bubbleSort(alist, len(alist) - 1) print(alis...
54ee32626f4f5f51bcb2e31ce9a122226f76efde
KickItAndCode/Algorithms
/DynamicProgramming/BurstBalloons.py
3,041
3.59375
4
# 312. Burst Balloons # Given n balloons, indexed from 0 to n-1. Each balloon is painted with a number on it represented by array nums. You are asked to burst all the balloons. If the you burst balloon i you will get nums[left] * nums[i] * nums[right] coins. Here left and right are adjacent indices of i. After the burs...
54ce9a84cf1a8096251243faee80961af1ec3a3d
veyu0/Python
/les_8/les_8_task_4.py
1,397
3.890625
4
class Office_equipment: def __init__(self, name, model): self.name = name self.model = model def __str__(self): return f'Name - {self.name}, model - {self.model}' class Printer(Office_equipment): def __init__(self, name, model, amount): super().__init__(name, mo...