blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
41b44b20257c4a5e99ca9af99d7ca7fc7066ed1c
Lesikv/python_tasks
/python_practice/matrix_tranpose.py
654
4.1875
4
#!usr/bin/env python #coding: utf-8 def matrix_transpose(src): """ Given a matrix A, return the transpose of A The transpose of a matrix is the matrix flipped over it's main diagonal, switching the row and column indices of the matrix. """ r, c = len(src), len(src[0]) res = [[None] * r for i i...
true
485fd356a2b3da8cd0db30d1d83714ef64d174f2
anubhavcu/python-sandbox-
/conditionals.py
1,765
4.15625
4
x = 50 y = 50 # if-else: <, >, == # if x > y: # print(f'{x} is greater than {y}') # else: # print(f'{x} is smaller than {y}') if x > y: print(f'{x} is greater than {y}') elif x < y: print(f'{x} is smaller than {y}') else: print("Both numbers are equal") # logical operators - and, or, not x = 5 ...
false
c70cbbe6dd0107e74cd408a899dc6bbe77432829
reenadhawan1/coding-dojo-algorithms
/week1/python-fundamentals/selection_sort.py
1,044
4.15625
4
# Selection Sort x = [23,4,12,1,31,14] def selection_sort(my_list): # find the length of the list len_list = len(my_list) # loop through the values for i in range(len_list): # for each pass of the loop set the index of the minimum value min_index = i # compare the current value...
true
249cbda74673f28d7cc61e8be86cdfef2b855e2a
Bharadwaja92/DataInterviewQuestions
/Questions/Q_090_SpiralMatrix.py
414
4.4375
4
""""""""" Given a matrix with m x n dimensions, print its elements in spiral form. For example: #Given: a = [ [10, 2, 11], [1, 3, 4], [8, 7, 9] ] #Your function should return: 10, 2, 11, 4, 9, 7, 8, 1, 3 """ def print_spiral(nums): # 10, 2, 11, 4, 9, 7, 8, 1, 3 # 4 Indicators -- row start and end, column s...
true
8b2af30e0e3e4fc2cfefbd7c7e9a60edc42538c0
Bharadwaja92/DataInterviewQuestions
/Questions/Q_029_AmericanFootballScoring.py
2,046
4.125
4
""""""""" There are a few ways we can score in American Football: 1 point - After scoring a touchdown, the team can choose to score a field goal 2 points - (1) after scoring touchdown, a team can choose to score a conversion, when the team attempts to score a secondary touchdown or (2) an u...
true
604a4bb01ff02dc0da1ca2ae0ac71e414c5a6afe
Bharadwaja92/DataInterviewQuestions
/Questions/Q_055_CategorizingFoods.py
615
4.25
4
""""""""" You are given the following dataframe and are asked to categorize each food into 1 of 3 categories: meat, fruit, or other. food pounds 0 bacon 4.0 1 STRAWBERRIES 3.5 2 Bacon 7.0 3 STRAWBERRIES 3.0 4 BACON 6.0 5 strawberries 9.0 6 Strawberries 1.0 7 pecans 3.0 Can...
true
015f6e785a2d2b8f5ebe76197c15b8dd335526cc
code4nisha/python8am
/day4.py
1,594
4.375
4
x = 1/2+3//3+4**2 print(x) # name = 'sophia' # print(name) # print(dir(name)) # print(name.capitalize) # course = "we are learning python" # print(course.title()) # print(course.capitalize()) # learn = "Data type" # print(learn) # learn = "python data types" # print(learn.title()) # data =['ram',123,1.5] # print(...
false
58401ce6e6a3876062d2a629d39314432e08b64f
mattling9/Algorithms2
/stack.py
1,685
4.125
4
class Stack(): """a representation of a stack""" def __init__(self, MaxSize): self.MaxSize = MaxSize self.StackPointer = 0 self.List = [] def size(self): StackSize = len(self.List) return StackSize def pop(self): StackSize = self.StackSize() ...
true
31b272d2675be1ecfd20e9b4bae4759f5b533106
iemeka/python
/exercise-lpthw/snake6.py
1,792
4.21875
4
#declared a variable, assigning the string value to it. #embedded in the string is a format character whose value is a number 10 assigned to it x = "There are %d types of people." % 10 #declared a variable assigning to it the string value binary = "binary" #same as above do_not = "don't" # also same as above but with w...
true
ed10b4f7cebef6848b14803ecf76a16b8bc84ca4
iemeka/python
/exercise-lpthw/snake32.py
713
4.40625
4
the_count = [1, 2, 3, 4, 5] fruits = ['apples', 'oranges', 'pears', 'apricots'] change = [1, 'pennies', 2, 'dimes', 3, 'quarters'] # this first kind of for-loop goes through a list for number in the_count: print "This is count %d" % number # same as above for fruit in fruits: print "A fruit of type: %s" % fruit fo...
true
bb1a2972bc806e06fe6302c703c158130318bf07
iemeka/python
/exercise-lpthw/snake20.py
1,128
4.21875
4
from sys import argv script, input_file = argv # a function to read the file held and open in the variable 'current_file' and then passed.. # the variable is passed to this functions's arguement def print_all(f): print f.read() # seek takes us to the begining of the file def rewind(f): f.seek(0) # we print the nume...
true
3d3bb07c0afda8d2c9943a39883cbbee67bfe4b1
icgowtham/Miscellany
/python/sample_programs/tree.py
2,130
4.25
4
"""Tree implementation.""" class Node(object): """Node class.""" def __init__(self, data=None): """Init method.""" self.left = None self.right = None self.data = data # for setting left node def set_left(self, node): """Set left node.""" ...
true
1eb9a54a4c86c72594064717eb0cd65c6376421d
icgowtham/Miscellany
/python/sample_programs/algorithms/quick_sort_v1.py
1,352
4.125
4
# -*- coding: utf-8 -*- """Quick sort implementation in Python.""" def partition(array, begin, end): """Partition function.""" pivot_idx = begin """ arr = [9, 3, 4, 8, 1] pivot = 0 i = 1, begin = 0 3 <= 9 -> swap -> [3, 9, 4, 8, 1] pivot = 1 i = 2, pivot = 1 4 <= 9 -> swap -> [...
false
55b9c9b05bcaa82321000ef230e049cab763a7f9
sovello/palindrome
/palindrome_recursive.py
632
4.28125
4
from re import * def reverseChar(word = '' ): reversed_word = '' for letter in word: if len(word) == 1: reversed_word = reversed_word + word else: reversed_word = reversed_word+word[-1] word = word[:len(word)-1] reverseChar(word) return rev...
false
87661803c954900ef11a81ac450ffaaf76b83167
truas/kccs
/python_overview/python_database/database_03.py
1,482
4.375
4
import sqlite3 ''' The database returns the results of the query in response to the cursor.fetchall call This result is a list with one entry for each record in the result set ''' def make_connection(database_file, query): ''' Common connection function that will fetch data with a given query in a specific D...
true
5217a281d3ba76965d0cb53a38ae90d16e7d7640
truas/kccs
/python_overview/python_oop/abstract_animal_generic.py
2,001
4.25
4
from abc import ABC, abstractmethod #yes this is the name of the actual abstract class ''' From the documentation: "This module provides the infrastructure for defining abstract base classes (ABCs) in Python" ''' class AbstractBaseAnimal(ABC): ''' Here we have two methods that need to be implemented by any clas...
true
f0c289169c7eea7a8d4675450cda1f36b10c3baf
alexeydevederkin/Hackerrank
/src/main/python/min_avg_waiting_time.py
2,648
4.4375
4
#!/bin/python3 ''' Tieu owns a pizza restaurant and he manages it in his own way. While in a normal restaurant, a customer is served by following the first-come, first-served rule, Tieu simply minimizes the average waiting time of his customers. So he gets to decide who is served first, regardless of how sooner or ...
true
6033592ae372bada65743cdb8cad06e78b5546a4
EkataShrestha/Python-Assignment
/Assignment 1.py
2,195
4.125
4
print(" ASSIGNMENT-1 ") "-------------------------------------------------------------------------------" print("Exercise 1:---------------------------------------------------") width = 17 height = 12.0 delimiter = '.' ##1. width/2: print("answer number 1 (width/2) is:", width/2) print( type(width/2) ) ##2. wid...
false
2b82cd1ea8697747b28486a7987f99dceea7775a
mousexjc/basicGrammer
/org/teamsun/mookee/senior/c012_1funcType.py
452
4.53125
5
""" Chapter 12 函数式编程 匿名函数 格式:lambda param_list: expression lambda:关键字 expression * :只能是【表达式】 """ # 正常函数 def add(x, y): return x + y f = lambda x, y: x + y print(f(2, 3)) print("=====================") # 三元表达式 # 其他语言:表达式 ?true结果 : false结果 # Python : true结果 if 表达式 else false结果 x = 1 y = 2 a =...
false
2e86e6d499de5d51f19051728db135aac6b36044
avisek-3524/Python-
/oddeven.py
260
4.1875
4
'''write a program to print all the numbers from m-n thereby classifying them as even or odd''' m=int(input('upper case')) n=int(input('lower case')) for i in range(m,n+1): if(i%2==0): print(str(i)+'--even') else: print(str(i)+'--odd')
true
3d3513f1520a98a06f7047699c4bee78d6e4a00f
carolinesekel/caesar-cipher
/caesar.py
361
4.34375
4
alphabet = "abcdefghijklmnopqrstuvwxyz" #shift by 5 cipher = "fghijklmnopqrstuvwxyzabcde" input_string = input("What would you like to encrypt? ") print("Now encrypting ", input_string, "...") encrypted = "" for letter in input_string: position = alphabet.index(letter) new_char = cipher[position] encrypt...
false
4a4f0e71027d92fa172f78811993aa1d62e2a6c7
JuveVR/Homework_5
/Exercise_2.py
2,650
4.21875
4
#2.1 class RectangularArea: """Class for work with square geometric instances """ def __init__(self, side_a, side_b): """ Defines to parameters of RectangularArea class. Checks parameters type. :param side_a: length of side a :param side_b:length of side a """ sel...
true
0b0e1f3f55ae4faa409b1fefb704b577aebb6c87
saicataram/MyWork
/DL-NLP/Assignments/Assignment4/vowel_count.py
801
4.3125
4
""" ************************************************************************************* Author: SK Date: 30-Apr-2020 Description: Python Assignments for practice; a. Count no of vowels in the provided string. ************************************************************************************* """ def vowel_c...
true
bd557b8cb881b1a6a0832b347c6855289a7c7cef
saicataram/MyWork
/DL-NLP/Assignments/Assignment4/lengthofStringinList.py
528
4.375
4
""" ************************************************************************************* Author: SK Date: 30-Apr-2020 Description: Python Assignments for practice; a. Count length of the string in list provided. ************************************************************************************* """ string = ...
true
d4aa13f6bd5d92ad0445200c91042b1b72f8f4cc
lilianaperezdiaz/cspp10
/unit4/Lperez_rps.py
2,982
4.3125
4
import random #function name: get_p1_move # arguments: none # purpose: present player with options, use input() to get player move # returns: the player's move as either 'r', 'p', or 's' def get_p1_move(): move=input("rock, paper, scissors: ") return move #function name: get_comp_move(): # argum...
true
d717960b2780b50a21f2ce7e1a586d08c2937f38
huhudaya/leetcode-
/LeetCode/212. 单词搜索 II.py
2,593
4.21875
4
''' 给定一个二维网格 board 和一个字典中的单词列表 words,找出所有同时在二维网格和字典中出现的单词。 单词必须按照字母顺序,通过相邻的单元格内的字母构成,其中“相邻”单元格是那些水平相邻或垂直相邻的单元格。 同一个单元格内的字母在一个单词中不允许被重复使用。 示例: 输入: words = ["oath","pea","eat","rain"] and board = [ ['o','a','a','n'], ['e','t','a','e'], ['i','h','k','r'], ['i','f','l','v'] ] 输出: ["eat","oath"] 说明: 你可以假设所有输入都由...
false
287660ee7a1580903b9815b83106e8a5bd6e0c20
5folddesign/100daysofpython
/day_002/day_004/climbing_record_v4.py
2,228
4.15625
4
#python3 #climbing_record.py is a script to record the grades, and perceived rate of exertion during an indoor rock climbing session. # I want this script to record: the number of the climb, wall type, grade of climb, perceived rate of exertion on my body, perceived rate of exertion on my heart, and the date and time...
true
6367b485bbbeb065dc379fa1164072db6bac22e4
risbudveru/machine-learning-deep-learning
/Machine Learning A-Z/Part 2 - Regression/Section 4 - Simple Linear Regression/Simple linear reg Created.py
1,590
4.3125
4
import numpy as np import matplotlib.pyplot as plt import pandas as pd # Importing the dataset #X is matrix of independent variables #Y is matrix of Dependent variables #We predict Y on basis of X dataset = pd.read_csv('Salary_data.csv') X = dataset.iloc[:, :-1].values y = dataset.iloc[:, 1].values # Spli...
true
84c9145c5802f5f1b2c2e70b8e2038b573220bd5
renan09/Assignments
/Python/PythonAssignments/Assign8/fibonacci2.py
489
4.15625
4
# A simple generator for Fibonacci Numbers def fib(limit): # Initialize first two Fibonacci Numbers a, b = 0, 1 # One by one yield next Fibonacci Number while a < limit: yield a #print("a : ",a) a, b = b, a + b #print("a,b :",a," : ",b) # Create a gener...
true
8fa278a0adcf19426d8b40a82aa53992b685341a
itssekhar/Pythonpractice
/oddandeven.py
515
4.125
4
num=int(input("enter a numer:")) res=num%2 if(res>0): print("odd number") else: print("even number") """ Using function""" def Number(n): res=n%2 if res>0: return "odd" else: return "even" Number(2) """Using main function for to find an even and odd number """ def tofin...
false
be1a6beb03d6f54c3f3d42882c84031cd415dc83
shaversj/100-days-of-code-r2
/days/27/longest-lines-py/longest_lines.py
675
4.25
4
def find_longest_lines(file): # Write a program which reads a file and prints to stdout the specified number of the longest lines # that are sorted based on their length in descending order. results = [] num_of_results = 0 with open(file) as f: num_of_results = int(f.readline()) for...
true
f99e68cfa634143883bfce882bc3b399bf1f1fcf
shaversj/100-days-of-code-r2
/days/08/llist-py/llist.py
862
4.21875
4
class Node: def __init__(self, data): self.data = data self.next = None class LinkedList: def __init__(self): self.head = None def add(self, data): new_node = Node(data) node = self.head # Get to the last node previous = None while node is...
true
1b68f58a36594c14385ff3e3faf8569659ba0532
derekcollins84/myProjectEulerSolutions
/problem0001/problem1.py
521
4.34375
4
''' If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23. Find the sum of all the multiples of 3 or 5 below 1000. ''' returnedValues = [] sumOfReturnedValues = 0 for testNum in range(1, 1000): if testNum % 3 == 0 or \ testNum ...
true
59609427d2e62f29bb7388f7bd320cb2cf927da3
Sohom-chatterjee2002/Python-for-Begineers
/Assignment-1-Python Basics/Problem 3.py
423
4.15625
4
# -*- coding: utf-8 -*- """ Created on Wed Dec 2 14:23:03 2020 @author: Sohom Chatterjee_CSE1_T25 """ def append_middle(s1,s2): middleIndex=int(len(s1)/2) print("Original strings are: ",s1,s2) middleThree=s1[:middleIndex]+s2+s1[middleIndex:] print("After appending new string in middle: ",m...
false
8b29ca12d190975f7b957645e9a18b4291e662a1
Sohom-chatterjee2002/Python-for-Begineers
/Assignment 2 -Control statements in Python/Problem 6.py
556
4.15625
4
# -*- coding: utf-8 -*- """ Created on Wed Dec 23 14:25:28 2020 @author: Sohom Chatterjee_CSE1_T25 """ #The set of input is given as ages. then print the status according to rules. def age_status(age): if(age<=1): print("in_born") elif(age>=2 and age<=10): print("child") elif(...
true
fccacd3a4799ab9b23a34b5c60f007afd54f7f73
tejaswisunitha/python
/power.py
348
4.28125
4
def power(a,b): if a==0: return 0 elif b==0: return 1 elif b==1: return a elif b%2 == 0: res_even = power(a,b/2) return res_even*res_even else : b=(b-1)/2 res_odd= power(a,b) return a*res_odd*res_odd ...
false
413524181632130eb94ef936ff18caecd4d47b06
nikhilroxtomar/Fully-Connected-Neural-Network-in-NumPy
/dnn/activation/sigmoid.py
341
4.1875
4
## Sigmoid activation function import numpy as np class Sigmoid: def __init__(self): """ ## This function is used to calculate the sigmoid and the derivative of a sigmoid """ def forward(self, x): return 1.0 / (1.0 + np.exp(-x)) def backward(self, x): ...
true
8e96a6fcac5695f7f0d47e1cf3f6ecef9382cbbf
janvanboesschoten/Python3
/h3_hours_try.py
275
4.125
4
hours = input('Enter the hour\n') try: hours = float(hours) except: hours = input('Error please enter numeric input\n') rate = input('Enter your rate per hour?\n') try: rate = float(rate) except: rate = input('Error please enter numeric input\n')
true
ed98b46454cb7865aadfe06077dff076dfd71a73
mujtaba4631/Python
/FibonacciSeries.py
308
4.5625
5
#Fibonacci Sequence - #Enter a number and have the program generate the Fibonacci sequence to that number or to the Nth number. n = int(input("enter the number till which you wanna generate Fibonacci series ")) a = 0 b = 1 c = a+1 print(a) print(b) for i in range(0,n): c = a+ b print(c) a,b=b,c
true
4c99cd87da23da776fff6f9f56348488be10e8d5
zzb15997937197/django-study
/mysite/polls/python_study/dict_demo.py
1,917
4.28125
4
dict_data = {"age": 23, "name": "张正兵"} # 1. items()方法,返回字典的所有键值对,以列表的形式返回可遍历的元组数组 items = dict_data.items() for i in items: print(i) # 2. key in dict 判断键是否在字典里 if "age" in dict_data: print("age is in dict") else: print("age is not in dict") # 3. 可以直接根据键来拿到对应的值 print(dict_data["age"]) # 4. keys()方法,返回该字典的...
false
2ddc4abc64069852fdd535b49a26f5712463f14a
nathanandersen/SortingAlgorithms
/MergeSort.py
1,122
4.25
4
# A Merge-Sort implementation in Python # (c) 2016 Nathan Andersen import Testing def mergeSort(xs,key=None): """Sorts a list, xs, in O(n*log n) time.""" if key is None: key = lambda x:x if len(xs) < 2: return xs else: # sort the l and r halves mid = len(xs) // 2 ...
true
614d2f3dfc383cf24fd979bb2918bef80fda3450
fancycheung/LeetCodeTrying
/easy_code/Linked_List/876.middleofthelinkedlist.py
1,180
4.15625
4
#!/usr/bin/env python2 # -*- coding: utf-8 -*- """ @author:nali @file: 876.middleofthelinkedlist.py @time: 2018/9/3/上午9:41 @software: PyCharm """ """ Given a non-empty, singly linked list with head node head, return a middle node of linked list. If there are two middle nodes, return the second middle node. Exam...
true
4e2ef817bd967563c72eadc6728f80a74cd661b7
sakuma17/PythonTraining
/0201/dictLesson.py
584
4.1875
4
dict1=dict() #空のdict dict1['apple']='りんご' dict1['orange']='みかん' print(dict1) print(len(dict1)) dict1['banana']='ばなな' del dict1['orange'] print(dict1) print(dict1['apple']) # 指定したキーのバリューを取得 #print(dict1['pine']) #無いのでerror print(dict1.get('pine')) #Noneを返す print(dict1.get('banana')) #ばなな if 'apple' in dict1: pr...
false
4afad10bff966b08e4f0aab782049901a3fb66dc
BalintNagy/GitForPython
/Checkio/01_Elementary/checkio_elementary_11_Even_the_last.py
1,261
4.21875
4
"""\ Even the last You are given an array of integers. You should find the sum of the elements with even indexes (0th, 2nd, 4th...) then multiply this summed number and the final element of the array together. Don't forget that the first element has an index of 0. For an empty array, the r...
true
92067b660f1df00f7d622b49388994c892145033
BalintNagy/GitForPython
/OOP_basics_1/01_Circle.py
572
4.125
4
# Green Fox OOP Basics 1 - 1. feladat # Create a `Circle` class that takes it's radius as cinstructor parameter # It should have a `get_circumference` method that returns it's circumference # It should have a `get_area` method that returns it's area import math class Circle: def __init__(self, radius): ...
true
7852ff2dfef25e356a65c527e94ee88d10c74a0b
BalintNagy/GitForPython
/Checkio/01_Elementary/checkio_elementary_16_Digits_multiplication.py
929
4.40625
4
"""\ Digits Multiplication You are given a positive integer. Your function should calculate the product of the digits excluding any zeroes. For example: The number given is 123405. The result will be 1*2*3*4*5=120 (don't forget to exclude zeroes). Input: A positive integer. Output: The p...
true
d5353aa98262d9de8b540c9ae863bde41ab0cda9
mura-wx/mura-wx
/python/Practice Program/basic program/chekPositifAndNegatif.py
306
4.15625
4
try : number=int(input("Enter Number : ")) if number < 0: print("The entered number is negatif") elif number > 0: print("The entered number is positif") if number == 0: print("number is Zero") except ValueError : print('The input is not a number !')
true
b45e6f6b1e8bb428e0e3fd5b6985687e64812a1c
Alihussain-khan/HangMan-Game-Python
/hangman game.py
2,638
4.1875
4
import random def get_word(): words= [ 'Woodstock', 'Gray', 'Hello', 'Gopher', 'Spikepike', 'green', 'blue', 'Willy', 'Rex', 'yes', 'Roo', 'Littlefoot', 'Baagheera', 'Remy', ...
false
76b5171706f347c58c33eed212798f84c6ebcfd1
zuxinlin/leetcode
/leetcode/350.IntersectionOfTwoArraysII.py
1,434
4.1875
4
#! /usr/bin/env python # coding: utf-8 ''' ''' class Solution(object): ''' Given two arrays, write a function to compute their intersection. Example: Given nums1 = [1, 2, 2, 1], nums2 = [2, 2], return [2, 2]. Note: Each element in the result should appear as many times as it shows in both a...
true
37e1234e8f39adc280dc20a3c39ea86f93143b0e
zuxinlin/leetcode
/leetcode/110.BalancedBinaryTree.py
1,342
4.28125
4
#! /usr/bin/env python # coding: utf-8 ''' Given a binary tree, determine if it is height-balanced. For this problem, a height-balanced binary tree is defined as: a binary tree in which the depth of the two subtrees of every node never differ by more than 1. Example 1: Given the following tree [3,9,20,null,null,15...
true
7a750725399d333e2cd1b46add1b8cc0c02b1522
MadyDixit/ProblemSolver
/Google/Coding/UnivalTree.py
1,039
4.125
4
''' Task 1: Check weather the Given Tree is Unival or Not. Task 2: Count the Number of Unival Tree in the Tree. ''' ''' Task 1: ''' class Tree: def __init__(self,x): self.val = x self.left = None self.right = None def insert(self, data): if self.val: if self.val > da...
true
02d2c723586f0b98c48dde041b20e5ec86809fae
pkray91/laravel
/string/string.py
1,254
4.4375
4
print("Hello python"); print('Hello python'); x = '''hdbvfvhbfvhbf''' y = """mdnfbvnfbvdfnbvfvbfm""" print(y) print(x) a='whO ARE you Man'; print(a); print(a.upper()); print(a.lower()); print(len(a)); print(a[1]); #sub string not including the given position. print(a[4:8]); #The strip() method removes any whitespace f...
true
0ee9e3d684e4a810701066ada2cc0daf04347abf
WebClub-NITK/Hacktoberfest-2k20
/Algorithms/14_disjoint_set/disjoint-set.py
989
4.1875
4
# Python3 program to implement Disjoint Set Data Structure for union and find. class DisjSet: def __init__(self, n): self.rank = [1] * n self.parent = [i for i in range(n)] # Finds set of given item x def find(self, x): if self.parent[x] != x: self.parent[x] = self.find...
false
996520dcd43c24c0391fc8767ee4eb9f8f3d309e
AdityaChavan02/Python-Data-Structures-Coursera
/8.6(User_input_no)/8.6.py
481
4.3125
4
#Rewrite the program that prompts the user for a list of numbers and prints the max and min of the numbers at the end when the user presses done. #Write the program to store the numbers in a list and use Max Min functions to compute the value. List=list() while True: no=input("Enter the no that you so des...
true
0ac525f075a96f8a749ddea35f8e1a59775217c8
ZoranPandovski/al-go-rithms
/sort/selection_sort/python/selection_sort.py
873
4.125
4
#defines functions to swap two list elements def swap(A,i,j): temp = A[i] A[i] = A[j] A[j] = temp #defines functions to print list def printList(A,n): for i in range(0,n): print(A[i],"\t") def selectionSort(A,n): for start in range(0,n-1): min=start #min is the index of the small...
true
6b2ae13e2f7dfa26c15cef55978cf7e70f4bf711
ZoranPandovski/al-go-rithms
/dp/min_cost_path/python/min_cost_path_.py
809
4.21875
4
# A Naive recursive implementation of MCP(Minimum Cost Path) problem R = 3 C = 3 import sys # Returns cost of minimum cost path from (0,0) to (m, n) in mat[R][C] def minCost(cost, m, n): if (n < 0 or m < 0): return sys.maxsize elif (m == 0 and n == 0): return cost[m][n] else: ...
true
1f2547aa08428209cf4d106ad8361033dd411efc
ZoranPandovski/al-go-rithms
/strings/palindrome/python/palindrome2.py
369
4.53125
5
#We check if a string is palindrome or not using slicing #Accept a string input inputString = input("Enter any string:") #Caseless Comparison inputString = inputString.casefold() #check if the string is equal to its reverse if inputString == inputString[::-1]: print("Congrats! You typed in a PALINDROME!!") else: ...
true
fc9287fca6c7b390cbd47ae7f70806b10d6114c3
ZoranPandovski/al-go-rithms
/data_structures/b_tree/Python/check_bst.py
1,131
4.28125
4
""" Check whether the given binary tree is BST(Binary Search Tree) or not """ import binary_search_tree def check_bst(root): if(root.left != None): temp = root.left if temp.val <= root.val: left = check_bst(root.left) else: return False else: ...
true
bf23783e9c07a11cdf0a186ab28da4edc1675b54
ZoranPandovski/al-go-rithms
/sort/Radix Sort/Radix_Sort.py
1,369
4.1875
4
# Python program for implementation of Radix Sort # A function to do counting sort of arr[] according to # the digit represented by exp. def countingSort(arr, exp1): n = len(arr) # The output array elements that will have sorted arr output = [0] * (n) # initialize count array as 0 count = [0] * (10) # Store ...
true
45d1f94946fb66eb792a8dbc8cbdb84c216d381c
ZoranPandovski/al-go-rithms
/math/leapyear_python.py
491
4.25
4
'''Leap year or not''' def leapyear(year): if (year % 4 == 0) and (year % 100 != 0) or (year % 400==0) : #checking for leap year print(year," is a leap year") #input is a leap year else: print(year," is not a leap year") #input is not a leap year year=int(input("Enter the year: ")) while year<=999 or year>=...
true
533b8c91219f7c4a2e51f952f88581edb8446fd5
ZoranPandovski/al-go-rithms
/sort/python/merge_sort.py
1,809
4.25
4
""" This is a pure python implementation of the merge sort algorithm For doctests run following command: python -m doctest -v merge_sort.py or python3 -m doctest -v merge_sort.py For manual testing run: python merge_sort.py """ from __future__ import print_function def merge_sort(collection): """Pure implementa...
true
0fbd0364c4afb58c921db8d3a036916e69b5a2b1
ZoranPandovski/al-go-rithms
/sort/bubble_sort/python/capt-doki_bubble_sort.py
652
4.3125
4
# Python program for implementation of Bubble Sort # TIME COMPLEXITY -- O(N^2) # SPACE COMPLEXITY -- O(1) def bubbleSort(arr): n = len(arr) # Traverse through all array elements for i in range(n): # Last i elements are already in place for j in range(0, n-i-1): # traver...
true
0b275806d4228c967856b0ff6995201b7af57e5e
ZoranPandovski/al-go-rithms
/data_structures/Graphs/graph/Python/closeness_centrality.py
1,585
4.28125
4
""" Problem : Calculate the closeness centrality of the nodes of the given network In general, centrality identifies the most important vertices of the graph. There are various measures for centrality of a node in the network For more details : https://en.wikipedia.org/wiki/Closeness_centrality Formula : let C(x) be ...
true
9b8696686283cf9e7afea3bf7b1ac976c3233a54
ZoranPandovski/al-go-rithms
/dp/EditDistance/Python/EditDistance.py
1,017
4.15625
4
from __future__ import print_function def editDistance(str1, str2, m , n): # If first string is empty, the only option is to # insert all characters of second string into first if m==0: return n # If second string is empty, the only option is to # remove all characters of first string if n==0: return m #...
true
81807e5f75856d4c7d6e44065c9d13e6d750a75d
marciogomesfilho/Codes
/ex72.py
1,079
4.28125
4
#Exercício Python 072: Crie um programa que tenha uma tupla totalmente preenchida com uma contagem por extenso, de zero até vinte. # Seu programa deverá ler um número pelo teclado (entre 0 e 5) e mostrá-lo por extenso. contagem = ('Zero', 'Um', 'Dois', 'Três', 'Quarto', 'Cinco') numero = int(input('Digite um número ...
false
bec4691cc3960e641bfaae05bcd7afdce043ffa7
marciogomesfilho/Codes
/ex31.py
420
4.25
4
#Exercício Python 031: Desenvolva um programa que pergunte a distância de uma viagem em Km. # Calcule o preço da passagem, cobrando R$0,50 por Km para viagens de até 200Km e R$0,45 parta viagens mais longas. dist = float(input('digite quantos kms foi a viagem: ')) if dist <= 200: print ('o valor da viagem foi...
false
fb4fc200462f10023d7f470ebd64aadb799c6519
marciogomesfilho/Codes
/ex79.py
627
4.25
4
#Exercício Python 079: Crie um programa onde o usuário possa digitar vários valores numéricos e # cadastre-os em uma lista. Caso o número já exista lá dentro, ele não será adicionado. # No final, serão exibidos todos os valores únicos digitados, em ordem crescente. numeros = list() while True: n = int(input('D...
false
399c60589ea352d922f22c5392bb3a41594b6167
marciogomesfilho/Codes
/ex89.py
1,679
4.1875
4
""" """Exercício Python 089: Crie um programa que leia nome e duas notas de vários alunos e guarde tudo em uma lista composta. No final, mostre um boletim contendo a média de cada um e permita que o usuário possa mostrar as notas de cada aluno individualmente. """ """ completa = list() temp = list() respost...
false
044b06fda913253faaa6ac13b30308aa18c7aa47
th3n0y0u/C2-Random-Number
/main.py
577
4.4375
4
import random print("Coin Flip") # 1 = heads, 2 = tails coin = random.randint(1,2) if(coin == 1): print("Heads") else: print("Tails") # Excecise: Create a code that mimics a dice roll using random numbers. The code of the print what number is "rolled", letting the user what it is. dice = random.randint(1,6) ...
true
9ee168ff9d35d0968e709211340358f2b3a1b5ac
IleanaChamorro/CursoPython
/Modulo2/Operadores/operadores.py
456
4.15625
4
#Operadores a = 3 b = 2 resultado = a + b print(f'Resultado suma: {resultado}') resta = a - b print(f'Resultado es: {resta}') multiplicacion = a * b print(f'resultado multiplicacion: {multiplicacion}') division = a / b print(f'resultado division: {division}') division = a // b print(f'resultado division(int): {d...
false
a54440ee6d73d158644143c3b43659a5fca377da
IleanaChamorro/CursoPython
/Modulo4/cicloFor.py
389
4.28125
4
#El bucle for se utiliza para recorrer los elementos de un objeto iterable (lista, tupla, conjunto, diccionario, …) y ejecutar un bloque de código. En cada paso de la iteración se tiene en cuenta a un único elemento del objeto iterable, sobre el cuál se pueden aplicar una serie de operaciones. cadena = 'Hola' for let...
false
869a95eb86410b60b95c95c08ab58a93193b55e1
thevarungrovers/Area-of-circle
/Area Of Circle.py
209
4.25
4
r = input("Input the radius of the circle:") # input from user r = float(r) # typecasting a = 3.14159265 * (r**2) # calculating area print(f'The area of circle with radius {r} is {a}') # return area
true
efffd3b52497bf990f8a02ea00af6f8f360f0270
musatoktas/Numerical_Analysis
/Python/Non-Linear Equations Roots/step_decreasing.py
387
4.125
4
x = float(input("Enter X value:")) h = float(input("Enter H value:")) a = float(input("Enter a value:")) eps = float(input("Enter Epsilon value:")) def my_func(k): import math j = math.sin(k) l = 2*pow(k,3) m = l-j-5 return m while (h>eps): y = my_func(x) z = my_func(x+h) if (y*z>0): ...
false
2c969e27e178cb286b98b7e320b5bbdcaee3b8f7
ProximaDas/HW06
/HW06_ex09_04.py
1,579
4.53125
5
#!/usr/bin/env python # HW06_ex09_04.py # (1) # Write a function named uses_only that takes a word and a string of letters, # and that returns True if the word contains only letters in the list. # - write uses_only # (2) # Can you make a sentence using only the letters acefhlo? Other than "Hoe # alfalfa?" # - writ...
true
aa1403aeaa7c51aa6031bd5361a55cb8a796bc78
Marcoakira/Desafios_Python_do_Curso_Guanabara
/Mundo3/Desafio086b.py
423
4.125
4
# Desafio086b criar uma matriz 3*3 e preencher ela com dados. alista = [[0,0,0],[0,0,0],[0,0,0]] for l in range(0,3): for c in range(0,3): alista[l][c] = int(input(f'Insira o numero da posição {l},{c}')) for c in range (0,3): for d in range(0,3): print(f'{alista[c][d]:^5}',end='') print() ...
false
308a96b56534d587575e0be55f037bdcbeb5c06e
subbul/python_book
/lists.py
2,387
4.53125
5
simple_list = [1,2,3] print "Simple List",simple_list hetero_list = [1,"Helo",[100,200,300]]# can containheterogenous values print "Original List",hetero_list print "Type of object hetero_list",type(hetero_list) # type of object, shows its fundamental data type, for e.g., here it is LIST print "Item at index 0 ...
true
1bb058c929eb776f52deab7486bcb65c71148d58
yangxi5501630/pythonProject
/study/study/15_元组.py
1,470
4.1875
4
''' tuple下元组本质就是一个有序集合 格式:元组名 = (元组元素1, 元组元素2, ……, 元组元素n) 特点: 1.与列表类似 2.用() 3.一旦初始化就不能修改,这个和字符串一样 ''' #创建空元组 tuple1 = () print(tuple1) #创建带元素的元组 tuple2 = (1,2,"tarena", True) print(tuple2) #定义只有一个元素的元组,记得后面带分割符, tuple3 = (1,) print(tuple3) print(type(tuple3)) #访问元组成员 tuple4 = (1,2,3,4) index = 0 for member in tuple...
false
6a8aa8ce16427dab54ddc650747a5fcb306b86ba
twilliams9397/eng89_python_oop
/python_functions.py
897
4.375
4
# creating a function # syntax def name_of_function(inputs) is used to declare a function # def greeting(): # print("Welcome on board, enjoy your trip!") # # pass can be used to skip without any errors # # greeting() # function must be called to give output # # def greeting(): # return "Welcome on board, enjoy...
true
013b2ac2244f256970950dc1cc7cdcae25f5371d
stockholm44/python_study_2018
/wikidocs/06-2.py
737
4.15625
4
# 06-2 3의 배수와 5의 배수를 1-1000사이에 더해주는거. 아니다. 그냥 class로 n을 받자. class Times: def __init__(self, n): self.n = n def three_five_times(self): sum = 0 # return sum = sum + i for i in range(1, self.n) if i % 3 ==0 or i % 5 == 0] # how can i make functional sum of for loop. for i i...
false
c5910f1116ccfb97578f5c4d0f3f65023e3be1ad
leocjj/0123
/Machine Learning/0_Copilot/test02.py
342
4.21875
4
def calculate_fibonacci(n): if n == 0: return 0 elif n == 1: return 1 else: return calculate_fibonacci(n-1) + calculate_fibonacci(n-2) def main(): n = int(input("Enter the number of terms: ")) for i in range(n): print(calculate_fibonacci(i), end=" ") if __name__ == ...
false
2b32d798a175be4fbc682ca9b737c5d1231ff989
leocjj/0123
/Python/python_dsa-master/stack/postfix_eval.py
730
4.1875
4
#!/usr/bin/python3 """ Evaluate a postfix string """ from stack import Stack def postfix_eval(string): # Evaluate a postfix string operands = Stack() tokens = string.split() for token in tokens: if token.isdigit(): operands.push(int(token)) else: op2 = operands....
false
27c6ec9e71d1d1cdd87ae03180937f2d798db4b2
leocjj/0123
/Python/python_dsa-master/recursion/int_to_string.py
393
4.125
4
#!/usr/bin/python3 """ Convert an integer to a string """ def int_to_string(n, base): # Convert an integer to a string convert_string = '0123456789ABCDEF' if n < base: return convert_string[n] else: return int_to_string(n // base, base) + convert_string[n % base] if __name__ == '__mai...
true
35eb4eddbc01e1c926e84c1a7d5f5467f4365746
leocjj/0123
/Python/python_dsa-master/recursion/palindrome.py
737
4.21875
4
#!/usr/bin/python3 """ Check if a string is a palindrome """ def remove_white(s): # Remove characters that are not letters new = '' for ch in s: if ord(ch) >= ord('a') and ord(ch) <= ord('z'): new += ch return new def palindrome(s): # Check if a string is a palindrome if ...
false
e81c76e31dd827790d6b98e739763201cfc618ab
tlepage/Academic
/Python/longest_repetition.py
1,121
4.21875
4
__author__ = 'tomlepage' # Define a procedure, longest_repetition, that takes as input a # list, and returns the element in the list that has the most # consecutive repetitions. If there are multiple elements that # have the same number of longest repetitions, the result should # be the one that appears first. If the i...
true
9682bdce76206453617d5b26c2c219becb5d4001
yougov/tortilla
/tortilla/formatters.py
444
4.125
4
# -*- coding: utf-8 -*- def hyphenate(path): """Replaces underscores with hyphens""" return path.replace('_', '-') def mixedcase(path): """Removes underscores and capitalizes the neighbouring character""" words = path.split('_') return words[0] + ''.join(word.title() for word in words[1:]) def...
true
d817d8f491e23137fd24c3184d6e594f1d8381b0
GaneshManal/TestCodes
/python/practice/syncronous_1.py
945
4.15625
4
""" example_1.py Just a short example showing synchronous running of 'tasks' """ from multiprocessing import Queue def task(name, work_queue): if work_queue.empty(): print('Task %s nothing to do', name) else: while not work_queue.empty(): count = work_queue.get() tota...
true
68a9fa74fcc26279e1e184eb9281e458c86b3937
GaneshManal/TestCodes
/python/practice/sqaure_generator.py
510
4.15625
4
# Generator Function for generating square of numbers def square_numbers(nums): for num in nums: yield num*num numbers = range(1, 6) gen_x = square_numbers(numbers) print "Generator Object : ", gen_x print "Generator Mem : ", dir(gen_x) """" 'print '--->', gen_x.next() print '--->', gen_x.next() print ...
false
5a9161c4f8f15e0056fd425a5eee58de16ec45bf
beb777/Python-3
/003.py
417
4.28125
4
#factorial n! = n*(n-1)(n-2)..........*1 number = int(input("Enter a number to find factorial: ")) factorial = 1; if number < 0: print("Factorial does not defined for negative integer"); elif (number == 0): print("The factorial of 0 is 1"); else: while (number > 0): factorial = factorial * number ...
true
1c922b07b6b1f011b91bc75d68ece9b8e2958576
Leah36/Homework
/python-challenge/PyPoll/Resources/PyPoll.py
2,168
4.15625
4
import os import csv #Create CSV file election_data = os.path.join("election_data.csv") #The list to capture the names of candidates candidates = [] #A list to capture the number of votes each candidates receives num_votes = [] #The list to capture the number of votes each candidates gather percent_votes = [] #...
true
faaf4b222a3b9e120d0197c218bcd6e25c3422a4
bwblock/Udacity
/CS101/quiz-median.py
621
4.21875
4
#! /usr/bin/env python # Define a procedure, median, that takes three # numbers as its inputs, and returns the median # of the three numbers. # Make sure your procedure has a return statement. def bigger(a,b): if a > b: return a else: return b def biggest(a,b,c): return bigger(a,bigger(b...
true
a759beda8dd1ef2309a0c200c3442bed4228f455
naotube/Project-Euler
/euler7.py
616
4.21875
4
#! /usr/bin/env python # By listing the first six prime numbers: 2, 3, 5, 7, 11, and 13, # we can see that the 6th prime is 13. # What is the 10001st prime number? primes = [2,3] def is_prime(num): """if num is a prime number, returns True, else returms False""" for i in primes: if num % i == 0: ...
true
cd9902d851dd5f7d4527d6bb80fa8abf13ef59c7
ubaidahmadceh/python_beginner_to_expert
/isdigit_function.py
218
4.25
4
number = input("Enter your number : ") if number.isdigit(): print("this is numeric (0-9)") elif number.isalpha(): print("this is string !!") else: print("This is not numeric , this is symbol or alphabet")
true
95a17e11a79f68563c393524c22b6f45b0365599
rob256/adventofcode2017
/python3/day_2/day_2_part_1.py
977
4.15625
4
from typing import List def checksum_line(numbers_list: iter) -> int: """ Given a list of numbers, return the value of the maximum - minimum values """ min_number = max_number = numbers_list[0] for number in numbers_list[1:]: min_number = min(min_number, number) max_number = max(ma...
true
e6886af2f0373dea4fac1f974cfca7574bca353b
daniel-cretney/PythonProjects
/primality_functions.py
481
4.4375
4
# this file will take a number and report whether it is prime or not def is_primary(): number = int(input("Insert a number.\n")) if number <= 3: return True else: divisor = 2 counter = 0 for i in range(number): if number % divisor == 0: ...
true
48ea70aaf45047d633f7469efd286ddcfb1a4ec3
jamesjakeies/python-api-tesing
/python3.7quick/5polygon.py
347
4.53125
5
# polygon.py # Draw regular polygons from turtle import * def polygon(n, length): """Draw n-sided polygon with given side length.""" for _ in range(n): forward(length) left(360/n) def main(): """Draw polygons with 3-9 sides.""" for n in range(3, 10): polygon(n, 80) ...
true
1f7ed4325ab493a60d95e04fa38d22d30578a966
jamesjakeies/python-api-tesing
/python3.7quick/4face.py
622
4.25
4
# face.py # Draw a face using functions. from turtle import * def circle_at(x, y, r): """Draw circle with center (x, y) radius r.""" penup() goto(x, y - r) pendown() setheading(0) circle(r) def eye(x, y, radius): """Draw an eye centered at (x, y) of given radius.""" circle_at(x, y, ra...
false
29362f4276d7ac83c520b89417bed94d2a771a4f
jamesjakeies/python-api-tesing
/python_crash_tutorial/Ch1/randomwalk.py
352
4.25
4
# randomwalk.py # Draw path of a random walk. from turtle import * from random import randrange def random_move(distance): """Take random step on a grid.""" left(randrange(0, 360, 90)) forward(distance) def main(): speed(0) while abs(xcor()) < 200 and abs(ycor()) < 200: random_move(10...
true
51578c97eb0b4a7478be114fa2eca98b713613ca
WillDutcher/Python_Essential_Training
/Chap05/bitwise.py
674
4.375
4
#!/usr/bin/env python3 # Copyright 2009-2017 BHG http://bw.org/ # Completed Chap05: Lesson 21 - Bitwise operators x = 0x0a y = 0x02 z = x & y # 02x gives two-character string, hexadecimal, with leading zero # 0 = leading zero # 2 = two characters wide # x = hexadecimal display of integer value # 08b gives eight-char...
true
1ce0280f860821796f022583f2b5b96950f587b9
WillDutcher/Python_Essential_Training
/Chap05/boolean.py
670
4.1875
4
#!/usr/bin/env python3 # Copyright 2009-2017 BHG http://bw.org/ # Completed Chap05: Lesson 23 - Comparison operators print("\nand\t\tAnd") print("or\t\tOr") print("not\t\tNot") print("in\t\tValue in set") print("not in\t\tValue not in set") print("is\t\tSame object identity") print("is not\t\tNot same object identity...
true
9be5e6cad8942160830e3d4bcca8c66dcac52370
Avinashgurugubelli/python_data_structures
/linked_lists/singly_linked_list/main.py
2,546
4.46875
4
from linked_list import LinkedList from node import Node # Code execution starts here if __name__ == '__main__': # Start with the empty list linked_list_1 = LinkedList() # region nodes creation first_node, second_node, third_node = Node(), Node(), Node() first_node.data = 5 second_node.data = 1...
true