blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
6c429c4aca6c176ac2ea7eaa63976b4e342ed00f
Mguer07/script
/game2.0(crazy8s).py
2,524
4.03125
4
import random WORD = ['apple', 'banana', 'cherry', 'watermelon', 'tomato', 'orange', 'jackfruit', 'cantaloupe', 'papaya', 'kumquat', 'Acai'] word = random.choice(WORD) correct = word clue = word[0] + word[(len(word)-1):(len(word))] clue2 = 'fruit' clue3 = 'You really want another clue? Really? Ok fine, its an...
5d6d551116fb24291178d3b9e0b81bc3cc778449
AndrewAct/DataCamp_Python
/Introduction to NLP with Python/2 Simple Topic Identification/01_Building_a_Counter_with_Bag_of_Words.py
1,019
3.671875
4
# # 7/23/2020 # In this exercise, you'll build your first (in this course) bag-of-words counter using a Wikipedia article, which has been pre-loaded as article. Try doing the bag-of-words without looking at the full article text, and guessing what the topic is! If you'd like to peek at the title at the end, we've inclu...
ede9bac2f14b14510b72306e3620977f09d4e3e5
RobertEne1989/python-hackerrank-submissions
/itertools_product_hackerrank.py
772
4.0625
4
''' Task You are given a two lists A and B. Your task is to compute their cartesian product AxB. Example A = [1, 2] B = [3, 4] AxB = [(1, 3), (1, 4), (2, 3), (2, 4)] Note: A and B are sorted lists, and the cartesian product's tuples should be output in sorted order. Input Format The first line cont...
7eb6870a8642d5589a7623d6a195ae541f5130bb
MarthaSamuel/foundation
/order.py
383
4.09375
4
# Author: Dimgba Martha O # @martha_samuel_ # 08 this function compares two numbers and returns them in increasing order def order_numbers(number1, number2): if number1 > number2: return number2, number1 else: return number1, number2 print(order_numbers('cat', 'Cat')) print(order_numbers('Yel...
b037d4755af04b1d03f17e59100399e20bd452d2
SaschMosk/hw
/homework_7.py
1,910
4.0625
4
class Animals: habitat = "land" Lungs = True age = 0 #лет babys = 0 #количество потомков size = 0 #условный размер животного, в дециметрах weight = 0 #вес животного в кг def init_size(self): s = input('Введите размер животного, в дм:') self.size += int(s) return self.size def init_weight(sel...
68d44245ca9d59024cae1e5c1cfd683ed00d03a9
Graham84/PythonBootcamp
/15 - Advanced Python Objects and Data Structures/4 - Advanced Dictionaries.py
1,404
4.8125
5
# Advanced Dictionaries # Unlike some of the other Data Structures we've worked with, # most of the really useful methods available to us in Dictionaries # have already been explored throughout this course. Here we will # touch on just a few more for good measure: d = {'k1': 1, 'k2': 2} # Dictionary Comprehensions # ...
044fd6273c849b7e41672edeb4f68c82dd99511b
iambideniz/Association_Rule_Learning_Recommender_Project
/ARL_Recommender_System.py
7,443
3.734375
4
################## ASSOCIATION RULE LEARNING RECOMMENDER ################## #### Business Problem: recommending products to users at the basket stage. ###### Dataset Story ###### # The Online Retail II dataset includes the sales of a UK-based online store between 01/12/2009 - 09/12/2011. # This company's product cat...
bb72d20ad37c32703e5aa4493dccb01d6958c053
mohanvaraprasad/forloop
/print sum of n natural numbers using for loop.py
71
3.734375
4
n=int(input()) sum=0 for i in range(1,n+1): sum+=i print(sum,end=' ')
9200bf4555d9c5674c557ef1fbebfdd962b247a6
rcmadden/talkpython
/jump_start/number_guess.py
567
4.09375
4
import random print('------------------------------------') print(' GUESS THE NUMBER') print('------------------------------------') the_number = random.randint(0, 100) guess = -1 while guess != the_number: guess = input("Guess a number between 1-100: ") guess = int(guess) if guess == the_number...
60d33e94ec94a2b98254847aee52afae7f9be192
vilisimo/ads
/python/leetcode/easy/ex0101_0200/ex0104.py
1,797
3.96875
4
# Given the root of a binary tree, return its maximum depth. # A binary tree's maximum depth is the number of nodes along the longest path from the root # node down to the farthest leaf node. # Example 1: # Input: root = [3,9,20,null,null,15,7] # Output: 3 # Example 2: # Input: root = [1,null,2] # Output: 2 ...
210e7eff2e29f77085c7c27679da666599b1f275
Saptarshidas131/NPTEL
/Data Structure and Algorithms using Python/is_prime.py
604
4.1875
4
""" Author: AnOnYmOus001100 Date: 28/11/2020 Description: To check if a number n is prime or not """ # find factors till n def factors(n): # list of factors factorlist = [] # iterating till n and if n is divisible by i, add it to factorlist for i in range(1,n+1): if n%i == 0: factorlist = factorlist + [i] ...
16e0d74e0329473a8c78b82517fd1f6618b81ea9
SSDC-SLIET/practice
/Week-02/1. Primitive/Solutions/AmitojSingh (GCS-1930022)/Solution-02.py
310
3.875
4
{ if __name__=='__main__': t = int(input()) for i in range(t): n=int(input()) print(convertFive(n)) # Contributed by: Harshit sidhwa } ''' This is a function problem.You only need to complete the function given below ''' def convertFive(n): a=str(n) a=a.replace('0','5') return a
8aa6445bb92fec708d74394f1b248514d38c77f8
indrajitrdas/Simple-Programs
/MaximumContiguousSubArray.py
582
4
4
# Maximum Subarray Problem: # Find the contiguous subarray of numbers which has the largest sum. # Kadane's Algorithm - Dynamic - O(n) def Max_Sub_Arr(arr): print(arr) max_cur_sum = max_global_sum = arr[0] for i in range(1, len(arr)): max_cur_sum = max(arr[i], max_cur_sum + arr[i]) i...
d511618928ef00033a4fc31485e0527b30a763e5
SurendraKumarAratikatla/MyLenovolapCodes1
/Python/Iron Python/payment.py
124
3.546875
4
f = float(100.000000000000000) print(round(f,5)) print format(f, '.3f') i = "23%" print len(i) print(i[:2]) print(i[2:3])
8ce71065ebb0acab22d0747715b5ce7d6c14da59
dkn22/scratch
/cs/recursion.py
3,164
3.609375
4
import functools def factorial(n): if n <= 0: return 1 return n * factorial(n - 1) def conv_n_to_str(n, base): chars = '0123456789ABCDEF' if n < base: return chars[n] else: return conv_n_to_str(n // base, base) + chars[n % base] def reverse_string(string): if len(s...
4f3401668739980ca1483aea658aaecba8c6a874
LeetCodeSolution/ListNode
/sort.py
655
3.96875
4
def swap(a, b): if not a or not b: return temp = a.value a.value = b.value b.value = temp def sort(head): if not head: return None if not head.next: return head node_loop_i = head while node_loop_i: min = node_loop_i.value node_loo...
9464e6e4af4de5eff6c8146552e02883d53609b0
JacobDrawhorn/Python_Projects
/abstract.py
677
4.40625
4
# import ABC from abc import ABC, abstractmethod # create parent class class AbstractClass(ABC): def __init__(self, value): self.value = value super().__init__() @abstractmethod def eat(self): pass # create child class class Parents(AbstractClass): def eat(self): ...
17e50c35e782d5e9f3adabf3c2213d7fb4f956e0
robobyn/code-challenges
/pythonchallenge/pychallenge3.py
767
4.375
4
# solving python challenge 4 at www.pythonchallenge.com/pc/def/equality.html import re def find_bodyguards(long_string): """Find one small letter surrounded by exactly 3 large letters on each side.""" # regex pattern exactly 3 uppercase 1 lowercase exactly 3 uppercase pattern = re.compile(r"[^A-Z]+[A-Z]{...
41de7fdfe217f9fea1ef64235f95b1e7e78ab8e3
brijeshr19/PYTHON_PROJECT
/JsonToPython.py
657
3.59375
4
import json # Deserialize JSON to Python object (a str, bytes or bytearray instance # containing a JSON document) # Sample JSON Single row #userJSON = '{"first_name": "John", "last_name": "Doe", "age": 30}' # Sample JSON Multiple row userJSON1='[{"id":1,"text":"Brijesh"},{"id":2,"text":"Raj"},{"id":3,"text":"Nav"...
77d943e4aa5ad4a7115dffab9eb0a49ccb32c821
dagandara/HackathonZero
/Katas-Final/TablaMultiplicar.py
228
3.734375
4
tabla = input("Introduce número: ") try: tabla = int(tabla) if(isinstance(tabla, int)): for i in range(11): print(str(tabla) + " x " + str(i) + " = " + str(tabla*i)) except: print("Prigao")
0e778eb1c406e6bd1a83ef82d4b672296c847c95
johnptmcdonald/daily_coding_problem
/002_product_except_index.py
2,513
3.921875
4
#Given an array of integers, return a new array such that each element at index i of the new array is the product of all the numbers in the original array except the one at i. #For example, if our input was [1, 2, 3, 4, 5], the expected output would be [120, 60, 40, 30, 24]. If our input was [3, 2, 1], the expected out...
bc04a9162202c6694edc418fd4ebb582c6c90ba7
iosetek/injector
/sorter.py
789
3.765625
4
def sort(entries): sorted_entries = [] for entry in iter(entries): sorted_entries = __update_sorted_entries(sorted_entries, entry) return sorted_entries def __update_sorted_entries(sorted_entries, entry): for i in range(len(sorted_entries)): for e in iter(sorted_entries[i]): ...
aef8e1e2802c7ec8f83baa3aa3fd0f2bd4a4fdd8
Blangreck/prg105
/8.3_frequent_character.py
757
4.21875
4
def main(): letters = ('A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z') letter = input("Enter a bunch of letters!: ") highest = 0 count = 0 frequent_letter = "" for let in letters: ...
94c363f49a42e0e7668480e1c0e01caf3c43df5f
rockinbinbin/AI-logic
/solver.py
3,779
3.90625
4
#!/usr/bin/python import numpy as np import sys ''' File reading function for sudoku Input: filename Output: a list of 2D numpy matrices representing sudokus ''' def read_sudoku(fname): with open(fname) as f: f_input = [x.strip('\r\n') for x in f.readlines()] sudoku_list = [] for i in xrange(len...
d4e03f0f3f0fcbcd65ace195601d79b23c28cec6
lucyhattersley/6001x
/Project_Euler/501_3.py
309
3.640625
4
def divLen(number): divs = [] for i in range(1,number+1): if number % i == 0: divs.append(i) return len(divs) def findEights(number): eights = 0 for i in range(1, number): if divLen(number) == 8: eights == 1 return eights print findEights(100)
64307e6b7f2f0dcc562c413f651548702de353c2
14Richa/pythonExcercises
/phrases_anagrams.py
258
3.984375
4
def check(str1, str2): if(sorted(str1) == sorted(str2)): print("This string is anagram.") else: print("This string is not an anagram") str1 = "William Shakespeare" str2 = "I am a weakish speller" #s = "" #t = "" #s = s.join(str1) #t = t.join(str2) check(str1, str2)
4456ee5462f081c98dd1541f1a4a35547f5c504b
mondo192/AdvancedSecurity1
/Lab2/vigenere.py
4,707
4.28125
4
#!/usr/bin/python3 import sys def write_data_to_disk(data): workfile = input('\nSave file as: ') with open(workfile, 'w') as f: f.write(data) f.close() def read_data_from_disk(): workfile = input('\nEnter the path to the file for reading: ') with open(workfile) as f: plainte...
7ea618daa1afc74f4152b4ec49cce3b6bb30a77b
Mobile-Robotics-W20-Team-9/UMICH-NCLT-SLAP
/src/dataset/data_manip/pickles/pickleManage.py
1,207
4.0625
4
import pickle # Usage: file to print current pickle files to text file # this allows us to monitor current dictionaries # Example: printPickle("BuildingMappings") # Output: Text file of dictonary keys def printPickle(filename): pickle_in = open(filename + '.pkl',"rb") currDict = pickle.load(pickle_in...
5a561e8feee4798b9f4d8b9428b75884fd5845f9
nptravis/python-studies
/argv.py
357
3.96875
4
import sys ## print out a command line argument # if len(sys.argv) == 2: # print("hello, {}".format(sys.argv[1])) # else: # print("hello world") ## print all command line arguments # for i in range(len(sys.argv)): # print(sys.argv[i]) ## print each character of command line argument one at a time for s in sys.arg...
bbd9930ccb0bafccd7c37e97a5a78f759be880f1
chenyanqa/example_tests_one
/test_23.py
1,293
3.890625
4
#!/usr/bin/env python # -*- coding:utf-8 -*- #打印出如下图案(菱形): ''' * *** ***** ******* ***** *** * ''' ''' #方法1:首先将菱形分成上下两部分,上部分时,先用一个外层循环控制行数,然后分析每行中 空格及星花个数与当前行的关系 然后通过2个内层循环控制列,一个控制空格的输出列,一个控制星花的,注意星花所在列的起始位置一般在空格输出结束的位置。 方法2:通过一个外层循环控制行数,然后分析每行空格与星花的个数关系,此时使用字符串的链接方法,控制先输出空格然后输出星花 ,print((3-i)*' '+(2*i+1)...
034533864febb43db60ab58d7ef5cb16751e7b6d
bakunobu/exercise
/1400_basic_tasks/chap_2/2.7.py
318
3.96875
4
def calc_area(a: float) -> float: A = 6 * a ** 2 return(A) def calc_vol(a: float) -> float: V = a ** 3 return(V) def show_res(a: float) -> None: print('Area of the square\'s sides: %0.2f' % calc_area(a)) print('Volume of the square %0.2f' % calc_vol(a)) show_res(4)
c412ef8980ced1833f8404b1a62968d6337f8f2f
rafaelperazzo/programacao-web
/moodledata/vpl_data/33/usersdata/67/10526/submittedfiles/av1_parte3.py
186
3.640625
4
# -*- coding: utf-8 -*- from __future__ import division #COMECE AQUI ABAIXO n=input("Digite o valor de termos:") i=0 j=1 k=1 soma=0 for l in range(1,n+1,1): if l%2==0:
12203ec0dc830a271d0918e30cfa955b75cfb6e6
ppepos/latece-python
/lab/correction/04-dict-json/evict.py
512
3.6875
4
import json # Generate the list of all Citizens of Rao who require eviction from the # Kingdom of Rao! You can base your decisions on the results of the last # elections in the votes.json file. You must also find how many children # will be left orphaned. with open('votes.json', 'r') as fd: votes = json.load(fd) ...
cf69162865c376a034f85065773845b288628bb9
Leon-C-T/PythonBasics
/evenlyspaced.py
343
3.859375
4
#!/usr/bin/env python3.8 def evenlySpaced(a,b,c): numbers = [a,b,c] numbers = sorted(numbers) if (numbers[1] - numbers[0]) == (numbers[2] - numbers[1]): return True else: return False print(evenlySpaced(2, 4, 6)) print(evenlySpaced(4, 6, 2)) print(evenlySpaced(4, 6, 3)) print(evenlySp...
e9f2f341fdf097bd392e277dcb473429c6198e7c
vdektiarev/sap_python_labs
/lab1/main.py
6,813
3.734375
4
import re def recursive_substring(string, position, length): if position >= len(string) or position < 0: raise ValueError('Wrong position argument!') if position + length > len(string): raise ValueError('Wrong length argument') current_char = string[position] if length <= 1: re...
db1843195730bb1183e26cc40ffacb4de4e2fa84
the-polymath/Python-practicals
/Practical 8/prac_8_1.py
260
3.953125
4
''' Write a Python program to plot following Equation using PyPlot Y= 5*x + 1 ''' import matplotlib.pyplot as plt fig = plt.figure(figsize = (10, 5)) x = [] y = [] for i in range(-50, 50): x.append(i) y.append((5*i) + 1) plt.plot(x, y) plt.show()
705988eb8cc2818b23470ffb52897ef6c88b494f
JeremyYao/LearningPython
/CodingBatPython/Logic-1.py
1,339
3.5625
4
#Jeremy Yao's solution to CodingBat's Python problems def cigar_party(cigars, is_weekend): if not is_weekend: return (cigars >= 40 and cigars <= 60) else: return cigars >= 40 def date_fashion(you, date): result = 1 if (you <= 2 or date <= 2): result = 0 elif (you >= 8 or date >= 8): ...
b66f1fe5d1f0ae199cb38a906fa0dbf6049f93d4
darkeclipz/project-euler
/Eulerlib/pandigital_prime.py
5,077
3.96875
4
import eulerlib import random """ We shall say that an n-digit number is pandigital if it makes use of all the digits 1 to n exactly once. For example, 2143 is a 4-digit pandigital and is also prime. What is the largest n-digit pandigital prime that exists? --------------- The largest n-digit pandigital is when n=9 ...
54354c8ecf440c6da31add2fb1464a295193f6db
amenzl/programming-challenge
/DAG.py
640
3.953125
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Sat Aug 24 07:38:37 2019 @author: anna """ import networkx as nx #networkx creates graphs, functions include Graph(), add_nodes, add_edges G=nx.Graph() class DAG(nodes, edges): def __init__(self): self.nx.Graph() def add_node(nodes):...
f52161e06c76036e88b301854d85ec6c48d70be7
gtyagi777/Problem-Solving---Algorithms-
/PrimeCubes.py
754
3.875
4
# -*- coding: utf-8 -*- """ Created on Sat Nov 10 08:36:02 2018 @author: tyagi""" import math def getprime(z): c= z while c>1: if is_prime(c): return c c -= 1 return 0 def is_prime(m): if m > 3: for i in range(3,m-1): if m%i == 0: ...
20b1e77ae2b6028902f7fa53019eba5572cba462
maliii326/github-test
/added no.py
246
4.15625
4
tuple_item = () total_items = int(input("enter the total number of items:")) for i in range(total_items): user_input = int(input("enter a number:")) tuple_item += (user_input,) print(f"items added to tuple are {tuple_item}")
8d85e9ec2dcc9e50dcc90470afb571313ef18e62
rafaelperazzo/programacao-web
/moodledata/vpl_data/394/usersdata/308/74692/submittedfiles/ex11.py
252
3.5625
4
# -*- coding: utf-8 -*- d1 = int(input('Dia 1: ')) m1 = int(input('Mes 1: ')) a1 = int(input('Ano 1: ')) d2 = int(input('Dia 2: ')) m2 = int(input('Mes 2: ')) a2 = int(input('Ano 2: ')) print('%d/%d/%d' %(d1, m1, a1)) print('%d/%d/%d' %(d2, m2, a2))
33c7f824b49bac9a882c3f18878d82219e9080c4
raulpy271/ChangeNumbersOfBitsPerChannelInImage
/changeNumbersOfBitsPerChannel.py
2,222
3.671875
4
import cv2 class ClassForChangeNumbersOfBitsPerChannel: """class that changes the amount of bits in each RGB channel of your photo""" def __init__ (self, image, newBitsPerChannel): self.image = image self.height = image.shape[0] self.width = image.shape[1] self.defaultDirector...
a3e49cdb8c4d0f2b5a2ed3e4e5489d5459217b4c
mjoniak/adder
/connector.py
664
3.5625
4
from typing import Set from rectangle import Rectangle class Connector(Rectangle): WIDTH = 20 HEIGHT = 20 def __init__(self, x, y, block=None): super().__init__(x, y, self.WIDTH, self.HEIGHT) self.connections: Set['Connector'] = set() self._x, self._y = x, y self.value ...
57fbc9b1933355f1b5dc860e8ee87e719099142e
qiuyuguo/bioinfo_toolbox
/coursework/online_judge_practice/leetcode/7.word_search/word_search.py
1,919
3.953125
4
from sets import Set debug = False visited = [] class Solution: # @param {character[][]} board # @param {string} word # @return {boolean} def exist(self, board, word): if board == None or word == None: return False #create a 2D array to mark if visited for i in range(...
cfe72bd5e3418806df8e2eda81e3fd5d8d86c77b
lverwers/solution-to-coin-flip-problem
/coin flip problem.py
2,628
3.875
4
# coding: utf-8 # In[44]: #note: n controls how many times the simulation will run #1,000,000 was used for testing purposes but be aware #that it will take 5 - 10 minutes to run depending on your #computer. Use smaller n for less computation time, larger n #for greater accuracy. import random hh = 0 ht = 0 tie = ...
e74a68efd76a06a43ac8f8a185be4222d6fa9cb4
Chrisaor/StudyPython
/GeeksforGeeks/Practice/3. Easy/19.MergeTwoSortedArrays.py
265
3.96875
4
def merge_array(arr1, arr2): return ' '.join(map(str, sorted(arr1+arr2,reverse=True))) t = int(input()) for i in range(t): N = input() arr1 = list(map(int, input().split())) arr2 = list(map(int, input().split())) print(merge_array(arr1, arr2))
7cb7f1f15306b5bb246bf054887a88248b549511
Carmenliukang/leetcode
/算法分析和归类/动态规划/斐波那契数列.py
1,058
3.59375
4
#!/usr/bin/env python # -*- coding: utf-8 -*- """ 写一个函数,输入 n ,求斐波那契(Fibonacci)数列的第 n 项(即 F(N))。斐波那契数列的定义如下: F(0) = 0, F(1)= 1 F(N) = F(N - 1) + F(N - 2), 其中 N > 1. 斐波那契数列由 0 和 1 开始,之后的斐波那契数就是由之前的两数相加而得出。 答案需要取模 1e9+7(1000000007),如计算初始结果为:1000000008,请返回 1。 示例 1: 输入:n = 2 输出:1 示例 2: 输入:n = 5 输出:5 提示: 0 <= n <...
d37334491e7e96c789704f9aeb47797ea2552564
AsterWang/leecode
/dp/一维DP/colorful_block.py
852
3.640625
4
class Solution(object): def permuteUnique(self, nums): """ :type nums: List[int] :rtype: List[List[int]] """ result = 0 nums_list = list(nums) self.dfs(nums_list, [], 0, result) return result def dfs(self, nums, path, count, result): i...
db5c118faeb5513a2fa0b3dc15674b3e9b2320ac
sis00337/BCIT-CST-Term-1-Programming-Methods
/06. Eleven Functions/interest.py
1,879
4.0625
4
""" Function 4 - Compound Interest Name : Min Soo (Mike) HWANG Github ID : Delivery_KiKi """ def compound_interest(principal, interest, interest_per_year, number_of_years): """ Calculate compound interest. Decomposition : I did not use decomposition because the formula is an already decomposed tool. Patt...
69620403dbd7de14c460520032f4b77c515cea75
qb-tarushg/analtix
/io/read_file.py
685
3.90625
4
def load(spark, path, file_format='parquet', options=None): """ This method is used for loading/reading files from specified location. :param spark: spark session :param path: Location of the files. :param file_format: Format of file eg. csv, json, parquet :param options: this includes dictionar...
3614f6d911266718adc5fb1d71e944fa0c1246d4
caicaideliulangmao/sqltocsv
/msql2csv.py
4,136
3.71875
4
import sys import pyodbc import pandas.io.sql as psql class SQLExtractor: """ This class defines the basic functions to convert the MS SQL database tables to CSV. """ def __init__(self, server, database, username, password): self.server = server self.database = ...
b47f83afb97e8d34e0c34444942dccafe84e365d
amirkhan1092/hyperskill.org
/Problems/Sum/task.py
115
3.640625
4
# put your python code here n1 = int(input()) n2 = int(input()) n3 = int(input()) print('{}'.format(n1 + n2 + n3))
72afddb910799b3c1d20c365d4dadb9641d1b2da
wangshunzi/itlike-qq-demo
/01-微信+体脂率/01-计算体脂率-2.py
1,640
3.671875
4
# -*- coding: utf-8 -*- """ ------------------------------------------------- Author: Sz WeChat: itlke-sz ------------------------------------------------- """ __author__ = 'Sz' # BMI = 体重(kg) / (身高 * 身高)(米) # 体脂率 = (1.2 * BMI + 0.23 * 年龄 - 5.4 - 10.8*性别(男:1 女:0)) / 100 # 正常成年人的体脂率分别是男性15%~18%和女性25%...
8a1c3513cc54c70113cb48c3ee164e909982d5b9
brainmentorspvtltd/RDE_Python
/ME+CE/loop_1.py
450
3.859375
4
x = 10 ''' start = 0 stop = x - 1 = 9 step = +1 ''' for var in range(x): # indentation - by default 4 spaces print(var, end=' ') print("Loop Exit...") ''' start = 1 stop = x - 1 = 9 step = +1 ''' for var in range(1,x): print(var, end=' ') print("Loop Exit...") ''' start = 2 stop = ...
17a5649e3f6d7f1172aeda4afc56508b846d303c
DeepaShrinidhiPandurangi/Problem_Solving
/Rosalind/Python_Village/5_Reading_and_writing_a_file/5_Read_write.py
1,570
3.953125
4
# Read a file and print its alternate lines import io open_file = open("rosalind1.txt") read_file = open_file.read() print("Full file:") print(read_file) infile = io.StringIO(read_file) # Note , io.StringIO impersonates string data as a file. print("Edited File:") for i,j in enumerate(infile): if i%2 =...
be55dc6fe6d4bcdde559efd60a067e4a12a9c64c
automationhacks/python-ds-algorithms
/data_structures/stack/matching_parenthesis.py
1,090
3.828125
4
from data_structures.stack.stack import Stack # Matching parenthesis problem # https://www.youtube.com/watch?v=w6rusGR9oic&list=PLtbC5OfOR8aqfexTOHSzvdQhfCzp0mZ64&index=3 def is_balanced(expr): stack = Stack() for elem in expr: if elem in '({[<': stack.push(elem) else: ...
6b30fe137e80442c644a056d241a809762ac5392
DanielHenriky/curso-em-video
/exercisio83.py
298
3.96875
4
#Crie um programa onde o uduário digite uma expreção # quauquer que use parênteses. Seu aplicativo deverá analisar # se a expreção passada está com os parênteses abertos e # fechado na ordem correta. expr = str(input('Digite a expreção')) piilha = list() for sinbo in expr:
2f296992c94c3de53a93bbf53e31f3222da3754d
TakLee96/have_fun_with_python
/midterm practice.py
1,378
3.921875
4
from random import randint def game_start(): num_cookies = 10 game_end = False player = 0 print("Game Start! There are {0} cookies.".format(num_cookies)) def take(num): nonlocal num_cookies, player, game_end if game_end: print("Game has ended!") else: if num_cookies < num: print("You cannot take ...
2b351f09984ef2d2fca7468558aee48a67b76fec
surge55/hello-world
/01-PY4E/12-network/12_exercise.py
5,213
3.71875
4
############################################################### ## File Name: 12_exercise.py ## File Type: Python File ## Author: surge55 ## Course: Python 4 Everybody ## Chapter: Chapter 12 - Network Programming ## Excercise: n/a ## Description: Code walkthrough from book ## Other References: n/a ###########...
446291f5d09fe71c45e26dacc867277813d2352e
monika48/LMS
/week1/problem2.py
356
4.125
4
#Assume s is a string of lower case characters. #Write a program that prints the number of times the string 'bob' occurs in s. For example, if s = 'azcbobobegghakl', then your program should print s=input("Enter string:") num= 0 for i in range(1, len(s)-1): if s[i-1:i+2] == 'bob': num+= 1 print('N...
8cc9f03e8ee166caae32436544acc1c129d60536
Esibrian92/kenzie-Mimic
/mimic.py
3,692
3.984375
4
#!/usr/bin/env python # -*- coding: utf-8 -*- # Copyright 2010 Google Inc. # Licensed under the Apache License, Version 2.0 # http://www.apache.org/licenses/LICENSE-2.0 """ Mimic exercise Read in the file specified on the command line. Do a simple split() on whitespace to obtain all the words in the file. Rather tha...
7307a223bc138c17a9b68608af1f18e8b4483166
RizkyAnggita/cryptarithms-solver
/src/cryptarithms.py
6,281
3.78125
4
# Nama : Rizky Anggita S Siregar # NIM : 13519132 # Tanggal : 25 Januari 2021 # Deskripsi : Cryptarithm Solver with Brute Force Algorithm # TUCIL 1 STRATEGI ALGORITMA from timeit import default_timer as timer import os def wordToNum(word, unique_huruf, num_huruf): #Change from word to number which w...
7cc3ccb03ef3d40c0b7689b1f6d7e57dd2c9e6e8
Kavya-N-git/pythonProgram
/MethodOverloading.py
1,798
3.96875
4
#method overloading #python donot support for method overloading because its dynamically typed language and we dont specify any type of data here class Myclass: def getinput(self,name=None,age=None): if name and age != None: print("hello",name) print("you are",age,"years old now\n...
4a9c317e728dc4f2e8b0b457bf50d3f255aecccc
f981113587/Python
/Aula 11/Desafios/043.py
719
4.0625
4
""" Desenvolva uma lógica que leia o peso e a altura de uma pessoa, calcule seu IMC e mostre seu status. Rasgue as minhas cartas E não me procure mais Assim será melhor, meu bem O retrato que eu te dei Se ainda tens, não sei Mas se tiver, devolva-me Devolva-me - Adriana Calcanhot...
a118f8921693115a733d60038261424f3566ab2d
geomartino/coins
/coins/coinssqlexamples.py
6,727
3.5625
4
#!/usr/bin/env python #coding=utf-8 #file: coinssqlexamples.py """ Examples of SQL queries on the COINS database. """ import sqlite3 import locale from optparse import OptionParser def sqlite_examples(sqlite_filename): """ Perform example SQLite queries. Keyword arguments: sqlite_filename -- name o...
c686abe4a1334c9ea04a1ae598aef265363e8895
brandoneng000/LeetCode
/easy/1608.py
549
3.609375
4
from typing import List class Solution: def specialArray(self, nums: List[int]) -> int: nums.sort(reverse=True) index = 0 while index < len(nums) and nums[index] > index: index += 1 return -1 if index < len(nums) and index == nums[index] else index def ma...
13fe6a7f074963aac68af4ef8ec892101d72eb87
BoBOHanLee/algorithm_python
/1_2_2_Recursion.py
443
3.828125
4
import numpy # n! algorithm def n_fumc(num): if num != 0: ans = num*n_fumc(num-1) return ans else: return 1 print('ans1 = %d'%(n_fumc(5))) #Fibonacci Polynomial # Fn = {0 if n==0 ; 1 if n==1 ; Fn-1+Fn-2 if n==2,3,4,5.......} def Fibonacci(num): if num==0: return 0 e...
b19070f2af99309e1c6c3459b2e41d3b8de4633d
blegloannec/CodeProblems
/HackerRank/sherlock_and_geometry.py
1,767
3.515625
4
#!/usr/bin/env python3 def circle_segment_intersect(xc,yc,R,x1,y1,x2,y2): R2 = R*R R21 = (x1-xc)**2+(y1-yc)**2 R22 = (x2-xc)**2+(y2-yc)**2 if R21<R2 and R22<R2: # both ends strictly inside return False if R21<=R2 or R22<=R2: # one end inside, one outside return True # both en...
544d1a6705925494558d592387e6d23548c31442
jinurajan/Datastructures
/LeetCode/top_interview_qns/easy/remove_duplicates_from_array.py
1,714
4
4
""" Given a sorted array nums, remove the duplicates in-place such that each element appear only once and return the new length. Do not allocate extra space for another array, you must do this by modifying the input array in-place with O(1) extra memory. Example 1: Given nums = [1,1,2], Your function should return ...
f2efb23c25bfad9d311b6721d4c8f4a39b7be21a
Mishrasubha/Codeforces-Training-sheet
/codeforces/arm.py
202
3.65625
4
num = str(input()) n = len(num) num = int(num) ornum = num sums = 0 d = 0 while(num!=0): d = num % 10 sums += d**n num = num//10 if sums == ornum: print("YES") else: print("No")
728b17d1e811167833a1a75a16e1646005ac51c0
xiadabing/GIT
/python/TEST/lemon_object/lemon_object_04.py
2,409
4.125
4
class Animal: """ 创建动物 """ def __init__(self,name,age,color): """ :param name: 名字 :param age: 年龄 :param color: 毛色 """ self.name,self.age ,self.color = name, age, color def eat(self): print('{}需要吃东西'.format(self.name)) def dirnk(self): ...
ebdd6a4e8380c4a1024042719a07f5b7f27998c6
obuhaiov-ucode/Python_sprints
/sprint2/t06_generators/cube.py
125
3.515625
4
def cube(n: int) -> int: if isinstance(n, int): while n > 0: yield n * n * n n -= 1
96768bdac99083b8cb722b7a7d56e54d7f7bec20
gschen/where2go-python-test
/1906101031王卓越/以前的代码/求一个正整数的是几位数.py
403
3.59375
4
def ik(k): if k>=10000: print("它是5位数") elif k>=1000 and k<10000: print("它是4位数") elif k>=100 and k<1000: print("它是3位数") elif k>=10 and k<100: print("它是2位数") elif k>=1 and k<10: print("它是1位数") return k k=int(input("请输入一个不大于5位数的整数:")) ik(k) n=list(str(k)) n.r...
bb680157786bb5db937f8f26a29fa85e71435f9e
quangvinh86/Python-HackerRank
/Python_domains/3-Strings-Challenges/Codes/Ex3_12.py
268
4.28125
4
#!/usr/bin/env python3 def capitalize(string): return ' '.join([sub.capitalize() for sub in string.split(" ")]) if __name__ == '__main__': # string = input() string = "1 w 2 r 3g" capitalized_string = capitalize(string) print(capitalized_string)
33cac80bf1791f505ddfc1483badb171dc64d98f
keshavkummari/python-nit-7am
/loops/for.py
403
4.0625
4
count=0 name=input("Enter your Name to Find out number of Vowels in your name: ") #KeyWord VariableExpression MembershipOperator Variable suit #for letter in name : for letter in name: if (letter in ['A','E','I','O','U','a','e','i','o','u']): count=count+1 pr...
b98ee39711bac2a86d6b45af59a432b30b6812b2
Gopalkataria/Prime-Numbers
/prime numbers.py
743
4.21875
4
from math import sqrt import sys def prime(rng): # return a list of prime numbers Primes = [] if rng >= 2: Primes.insert(0, 2) for num in range(3, (rng + 1), 2): # main loop of all odd numbers # main loop till that odd number finding odd factors for fact in range(...
d3121cec82abf021abf0f927be8015b09f8b28e2
tarundev-x/55_PYTHON-lab_experiements
/3(2)forloop.py
130
3.859375
4
list=['A','D','I','T','A'] for i in list: print(i) #output:A #D #I #T #Y #A
dc56060016a071e6afa40f4384e9725b1b55b8f4
Adianek/Bootcamp
/Zadanie11.py
849
4.03125
4
x = int(input("Podaj x: ")) y = int(input("Podaj y: ")) if (x < 0 or y < 0) or (x > 100 or y > 100): print("Gracz jest poza planszą") elif x <= 10 and y <= 10 and x >= 0 and y >= 0: print("Gracz znajduje się w lewej dolnej krawędzi") elif x >= 90 and y >= 90 and x <= 100 and y <= 100: print("Gracz znajduje...
d25fc8020bc412a7a8516bd99654fd2096b29d47
Lumsta01/_Python_Projects
/submission_002-robot-4/world/turtle/world.py
3,017
4.09375
4
import turtle import world.obstacles as obstacles x = 0 y = 0 def set_turtle_enviroment(): """Sets up the turtle enviroment""" windo=turtle.Screen() windo.bgcolor("honeydew") windo.setworldcoordinates(-100, -200, 100, 200) #Draw Border border = turtle.Turtle() border.speed(50) border.pe...
0909497617c98549c037a6b3e53424fadbabfb67
mattgarner/Rosalind
/src/iev.py
1,161
3.796875
4
''' Created on 4 May 2015 @author: matt Given: Six positive integers, each of which does not exceed 20,000. The integers correspond to the number of couples in a population possessing each genotype pairing for a given factor. In order, the six given integers represent the number of couples having the following genoty...
1ae13561ccb6224f8867ed2f47fe96fb13d8edb6
ElektroNeo/100-days-of-code-python
/Day-000/exercise-2.py
589
4.0625
4
# Compute pay function def computepay(hours, rate): try: hour = float(hours) except : hour = -1.0 try: rate = float(rate) except : rate = -1.0 if hour == -1.0 or rate == -1.0: return -1 elif hour > 40: return (40*rate)+((hour-40)*rate*1.5) els...
1a7fc4e1ae0abf7bed743c3960d7b9044321b763
PrashantThirumal/Python
/Basics/ReadingFiles.py
2,615
3.6875
4
''' File I/O ''' #Prizes class class Prize: name = "default" cost = 0.0 #Constructor def __init__(prize, aName, aCost): prize.name = aName if(float(aCost) >= 0): prize.cost = aCost else: print("INVALID PRIZE COST") #Accessors d...
1cf4fd4940dc400f508bd02ca6bacdeacee80dc7
fifa007/Leetcode
/src/perfect_squares.py
683
4.03125
4
#!/usr/bin/env python2.7 ''' Given a positive integer n, find the least number of perfect square numbers (for example, 1, 4, 9, 16, ...) which sum to n. For example, given n = 12, return 3 because 12 = 4 + 4 + 4; given n = 13, return 2 because 13 = 4 + 9. ''' import math class Solution(object): def num_of_squa...
493e653544e8f67db5fac904e4901d9b2699f3d0
JingyanChen/python_study
/sort.py
2,903
4.28125
4
#sort arg #lamada表达式,定义了一个匿名的函数,为他取名为comp,作用是比较x和y的大小 x<y是否为真 #定义了一个函数,函数名为select_sort 参数为可变的,一个或两个,第一个是输入数组,第二个是比较两个数大小的函数指针,默认给出了default值,是一个lambda函数 def select_sort(origin_items,comp=lambda x, y: x < y): """ simple select sort""" items = origin_items[:] #把输入参数赋值给局部变量items for i in range(len(items) - 1): ...
5a4b0f60f2fc6afeba1fc6af0d21bbeaff2d3700
abshir24/In-Class-Algorithms
/day11.py
1,397
3.875
4
# Create a function that accepts a list input and shifts all the values # in the list to the left by 1. Then set the last value in the list equal # to zero this must be done in place. Given: [1,2,3,4,5] => [2,3,4,5,0] def shiftLeft(arr): for i in range(len(arr)-1): arr[i] = arr[i+1] arr[len(arr)...
a8026bdf3889c66292e176efcf98e3867382dac5
AdamZhouSE/pythonHomework
/Code/CodeRecords/2935/60586/243030.py
316
3.609375
4
def exam6(): s=list(input()) l=len(s) num=0 for i in range(0,l): if s[i]== "Q": for j in range(i+1,l): if s[j]=="A": for k in range(j+1,l): if s[k]=="Q": num=num+1 print(str(num)) exam6()
272aff331d55c912b260e7e8a511afebb9afcab1
Kornvalles/Python4sem
/week_9/DateTime/datetime_ex.py
535
3.71875
4
from datetime import date, timedelta, datetime, time today = date.today() today = date(today.year, today.month, today.day) print(type(today)) print(today) next_lecture = today + timedelta(days=7) time_to_next_lecture = abs(next_lecture - today) print(time_to_next_lecture.days) next_lecture = date(2020, 2, 24) + tim...
9a42c8da2c351664ef5028c94204d24f756d5d28
bogdanmagometa/sorting-algorithm-comparison
/experiment.py
6,198
3.8125
4
""" experiment.py This is a module for running the sorting algrithms on different arrays and visualizing the results. """ import random import time from typing import Callable, Dict, List from dataclasses import dataclass from functools import partial import matplotlib.pyplot as plt from array_gen import gen_unsort...
bc7aac8f46750c6e25a804606970cb64e1f287ec
RITESHMOHAPATRA/TIC-TAC-TOE
/Python/pygame1.py
17,544
3.65625
4
import pygame from tictactoe import Board import mini2 from mini2 import Tic #initialization pygame.init() board = Board() tic = Tic() clock = pygame.time.Clock() font = pygame.font.SysFont("comicsansms", 72) #start the game def game_intro(): intro = True #For generating an infinite loop. #run the game wh...
7627b556ec00489874305654021182f7a927c841
Energy-Transition/etg
/etg/util/agentset.py
2,357
4.03125
4
""" A class to mimic Netlogos agentsets iteration behaviour """ import random class AgentSet: """ A class to mimic Netlogo's agentsets random iteration behaviour. Also has some convience methods that making common sequence operations for which order does not matter faster. """ def __init__(self...
3d7209caf1437b02b1f640153ad76b7cdb839fd4
marc9323/Tkinter-Password-Manager
/model.py
1,746
4.25
4
""" Marc D. Holman 11 / 22 / 2019 CIS 2531 - Introduction to Python Programming Term Project - Tkinter Password Manager Application Module model, contains the data model for the application as well as UserTuple and LinkTuple named tuple classes used for holding users and web accounts (links). """ from collections i...
72a9f8b99746802ed3ac38f477029fb4118e7167
J-RAG/DTEC501-Python-Files
/Lab 3-2-2qs1.py
1,799
4.40625
4
# Lab 3-2-2 question 1 # By Julan Ray Avila Gutierrez, jra0108@arastudent.ac.nz RESPONSE_YES = "y" NO_FUNDS = float(0) TOO_COLD_MESSAGE = "It's not warm enough, stay at home." FAREWELL_MESSAGE = "Enjoy your time at the beach." STAY_HOME_MESSAGE = "Ok, enjoy your time at home." NO_CASH_MESSAGE = "Please remember ...
c12ec61b3794b2741ee41f047a7f5dbc34d09ee3
indiependente/nbastaz
/bin/_salaries.py
3,849
3.8125
4
import re import urllib from urllib import urlopen # This method finds the urls for each of the rosters in the NBA using regexes. def find_roster_urls(): # Open the webpage containing links to each roster, # and extract the names of each roster available. f = urllib.urlopen('http://espn.go.com/nba/teams') ...
93c86194268d389f73fa97197976ffa378159d29
tlorine/graph_searh_alg
/graph.py
2,624
3.625
4
import random DEF = 3 START = 1 FINISH = 2 PATH = 4 WALL = 5 class Cell: def __init__(self): self.id = 0 self.x = 0 self.y = 0 self.visited = False self.neighbords = list() self.cell_type = 0 self.rect = None def add_neighbord(self, neigbord): s...
3b5bb6a3fcf367eb67f8cba21edbd5fd1f9438fc
juandreww/1004-DataManipulation2-Learn-1
/1004-DataManipulation2-Learn-1.py
8,623
3.640625
4
import pandas as pd # -- Append -- """ # Buat series of int (s1) dan series of string (s2) s1 = pd.Series([1,2,3,4,5,6]) s2 = pd.Series(["a","b","c","d","e","f"]) # Terapkan method append s2_append_s1 = s2.append(s1) print("Series - append:\n", s2_append_s1) # Buat dataframe df1 dan df2 df1 = pd.DataFrame({'a':[1,2],...
b0a8a3f61903ae3ff393096831a1cc22654b88c0
ahmedzaabal/Python-Demos
/Strings.py
246
4.28125
4
# first_name = "Ahmed" # last_name = "Adel" first_name = input("Please enter your name: ") last_name = input("Please Enter your last name: ") #print(first_name + last_name) print("Hello " + first_name.capitalize() + " " + last_name.capitalize())
0cca7408d69aae4c896ef468f1a689d4dce5223f
dreamCodeMan/The-Handbrake-Distributed-Scheduler
/src/Client/transfer.py
727
3.640625
4
''' Created on 16 May 2011 @author: Thomas Purchas ''' import TarGetFiles def xfer_sockets(destination, service, host, port): ''' This is the basic transfer method that uses sockets to transfer the raw data across the network using sockets. It cheats a little be by using tar files to wrap and compress ...
331cf8f7a97616f5172ed8f0677c501bf16df833
GunnerX/leetcode
/100_相同的树.py
1,675
4.125
4
# 给定两个二叉树,编写一个函数来检验它们是否相同。 # # 如果两个树在结构上相同,并且节点具有相同的值,则认为它们是相同的。 # # 示例 1: # # 输入: 1 1 # / \ / \ # 2 3 2 3 # # [1,2,3], [1,2,3] # # 输出: true # 示例 2: # # 输入: 1 1 # / \ # 2 2 # # [1,2], [1,null,2] #...
bd8309f57a6195d0a624d422558f25b1bdccd726
amkolotov/Algorithms
/homework_07/les_7_task_2.py
1,255
4
4
# -*- coding: utf-8 -*- # отсортируйте по возрастанию методом слияния одномерный вещественный массив заданный случайными числами на промежутке # [0-50). Выведите на экран исходный и отсортированный массивы import random MIN_NUM = 0 MAX_NUM = 50 SIZE = 10 array = [random.random() * 50 for _ in range(SIZE)] print(ar...