blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
e9a690c16c9f41e44017d6ca7f2548fca0ad6d28
mohitsaroha03/The-Py-Algorithms
/src/3.1Array/print-unique-rows.py
593
4.28125
4
# Link: https://www.geeksforgeeks.org/print-unique-rows/ # Python3 code to print unique row in a # given binary matrix def printArray(matrix): rowCount = len(matrix) if rowCount == 0: return columnCount = len(matrix[0]) if columnCount == 0: return row_output_format = " ".join(["%s"] * columnCount) ...
true
d6c9c1d5056f3a3fde6dea01d26bbbd54303def7
mohitsaroha03/The-Py-Algorithms
/src/3.1Array/Printing Matrix Chain Multiplication.py
1,762
4.5625
5
# Link: https://www.geeksforgeeks.org/printing-brackets-matrix-chain-multiplication-problem/ # https://www.geeksforgeeks.org/printing-matrix-chain-multiplication-a-space-optimized-solution/ # A space optimized python3 program to # print optimal parenthesization in # matrix chain multiplication. def printParenthesis...
true
951ae31865210a9c0368fd418686c81971f2558b
mohitsaroha03/The-Py-Algorithms
/src/3.1Array/pair-swapping-which-makes-sum-of-two-arrays-same.py
1,013
4.3125
4
# Link: https://www.geeksforgeeks.org/find-a-pair-swapping-which-makes-sum-of-two-arrays-same/ # Python code for optimized implementation #Returns sum of elements in list def getSum(X): sum=0 for i in X: sum+=i return sum # Finds value of # a - b = (sumA - sumB) / 2 def getTarget(A,B): # Calculations of...
true
9feeb6d379f053bf516b8321f434bb79d26a0ed6
mohitsaroha03/The-Py-Algorithms
/src/5.2Graphs/path-of-more-than-k-length-from-a-source.py
2,423
4.375
4
# Link: https://www.geeksforgeeks.org/find-if-there-is-a-path-of-more-than-k-length-from-a-source/ # IsDone: 0 # Program to find if there is a simple path with # weight more than k # This class represents a dipathted graph using # adjacency list representation class Graph: # Allocates memory for adjacency list ...
true
3eb71a832fee864137d166f1dd11486ffddb2c66
mohitsaroha03/The-Py-Algorithms
/src/5.2Graphs/UnweightedShortestPathWithBFS.py
725
4.21875
4
# Link: https://www.codespeedy.com/python-program-to-find-shortest-path-in-an-unweighted-graph/ # IsDone: 0 def bfs(graph, S, D): queue = [(S, [S])] while queue: (vertex, path) = queue.pop(0) for next in graph[vertex] - set(path): if next == D: yield path + [next] ...
true
fbc5f704faae1755fbc764868fdce40548478b1d
mohitsaroha03/The-Py-Algorithms
/src/zDynamicprogramming/find-water-in-a-glass.py
1,656
4.4375
4
# Link: https://www.geeksforgeeks.org/find-water-in-a-glass/ # Program to find the amount # of water in j-th glass of # i-th row # Returns the amount of water # in jth glass of ith row def findWater(i, j, X): # A row number i has maximum # i columns. So input column # number must be less than i if (j > i): pr...
true
b98fa8cd45e568c6b75868432d9fcd27c5c648ae
mohitsaroha03/The-Py-Algorithms
/src/02Recursionandbacktracking/permutations-of-a-given-string.py
735
4.28125
4
# Link: https://www.geeksforgeeks.org/write-a-c-program-to-print-all-permutations-of-a-given-string/ # IsDone: 1 # Python program to print all permutations with # duplicates allowed def toString(List): return ''.join(List) # Function to print permutations of string # This function takes three parameters: # 1....
true
57d1f7d07a1da34dac935ef8c4d63ac7f20f8c2d
mohitsaroha03/The-Py-Algorithms
/src/3.1Array/subarray-form-mountain-not.py
1,519
4.5625
5
# Link: https://www.geeksforgeeks.org/find-whether-subarray-form-mountain-not/ # Python 3 program to check whether a subarray is in # mountain form or not # Utility method to construct left and right array def preprocess(arr, N, left, right): # initialize first left index as that index only left[0] = 0 lastInc...
true
edfc8906931222ca08025deafff0519fac8d0bd7
mohitsaroha03/The-Py-Algorithms
/src/3.1Array/largest rectangle of 1’s with swapping.py
1,779
4.3125
4
# Link: https://www.geeksforgeeks.org/find-the-largest-rectangle-of-1s-with-swapping-of-columns-allowed/ # Python 3 program to find the largest # rectangle of 1's with swapping # of columns allowed. # TODO: pending R = 3 C = 5 # Returns area of the largest # rectangle of 1's def maxArea(mat): # An auxiliary a...
true
92ad4efcb9cfdb1ab7d261dfb83912b4d1439c88
mohitsaroha03/The-Py-Algorithms
/src/5.2Graphs/find-whether-path-two-cells-matrix.py
2,356
4.28125
4
# Link: https://www.geeksforgeeks.org/find-whether-path-two-cells-matrix/ # IsDone: 0 # Node of a Singly Linked List # Python3 program to find path between two # cell in matrix from collections import defaultdict class Graph: def __init__(self): self.graph = defaultdict(list) # add edge to graph def addEd...
true
97c0eb8980cb8209f70cdf04417ee8f6872dbd94
mohitsaroha03/The-Py-Algorithms
/src/5.1Trees/IsBST2.py
1,323
4.375
4
# Link: https://www.geeksforgeeks.org/a-program-to-check-if-a-binary-tree-is-bst-or-not/ # IsDone: 1 class Node: # constructor to create new node def __init__(self, val): self.data = val self.left = None self.right = None # global variable prev - to keep track # of previous node during Inorder # traversa...
true
7059826d66377beac0d37ebc89f730f9df827f47
mohitsaroha03/The-Py-Algorithms
/src/5.1Trees/PathsFinder print all paths.py
902
4.46875
4
# Link: https://www.geeksforgeeks.org/given-a-binary-tree-print-all-root-to-leaf-paths/ # IsDone: 0 # Python3 program to print all of its # root-to-leaf paths for a tree class Node: # A binary tree node has data, # pointer to left child and a # pointer to right child def __init__(self, data): self.data =...
true
bd4a48f712fbbf309d81955ca6fa88551b42f955
dglauber1/radix_visualizer
/radix_visualizer.py
1,778
4.34375
4
def print_buckets(buckets, ordered_place): """print_buckets: array, int -> Purpose: prints the contents of a 2D array representing the buckets of a radix sort algorithm Consumes: buckets - an array of int arrays, where the xth int array contains all integers with the digit x at ordered_place ...
true
b7a876f1d244f9d30b7dc61810f42769265225c3
itadmin01/GoalSeek_Python
/ExampleScript.py
1,315
4.25
4
## ExampleScript running GoalSeek (Excel) # prepared by Hakan İbrahim Tol, PhD ## Required Python Library: NumPy from WhatIfAnalysis import GoalSeek ## EXAMPLE 1 # Finding the x value, its square results in goal = 10 # (i) Define the formula that needs to reach the (goal) result def fun(x): re...
true
8ea7550e998006d5c906b4d6fccd3c308349304a
ajaymovva/mission-rnd-python-course
/PythonCourse/finaltest_problem3.py
2,483
4.40625
4
__author__ = 'Kalyan' max_marks = 25 problem_notes = ''' For this problem you have to implement a staircase jumble as described below. 1. You have n stairs numbered 1 to n. You are given some text to jumble. 2. You repeatedly climb down and up the stairs and on each step k you add/append starting k chars from t...
true
436919d0eba0ddf4ce4328804cb4017394b0ab27
YusraKhalid/String-Manipulation
/String minipulation.py
2,287
4.25
4
import YKStringProcessor def main(): string = input("Enter replace string: ") finding = input("What do you want to find: ") replace = input("What do you want to replace: ") replaceWith = input("what do you want to replace it with: ") flag = True while flag == True: try: inde...
true
94e2eb23f3127602c81aeb3d6b11d5cd40795846
michalwojewoda/python
/Exercises/01_Character Input.py
1,023
4.125
4
# Create a program that asks the user to enter their name and their age. Print out a message addressed to them that tells them the year that they will turn 100 years old. name = input("Please, state your name: ") age = input("Please, state your age: ") age = int(age) year = str((2020 - age)+100) print(name + " you wil...
true
91389b6966a6dc12a08400e02f79cd49afd05db7
michalwojewoda/python
/Exercises/W3Resource/6.py
341
4.34375
4
# Write a Python program which accepts a sequence of comma-separated numbers from user and generate a list and a tuple with those numbers. values = input("Input some comma separated numbers: ") list = values.split(",") tuple = tuple(list) print("This is the list: ", list) print("This is the tuple: ", tuple) #finished #...
true
fb9378ae6c2620d2b72fb7483fb654c46ef13c00
mohitkhatri611/python-Revision-and-cp
/python programs and projects/python all topics/Generators and iterators.py
1,223
4.46875
4
def generator_functions(): for i in range(5): yield i * 20 #generator is a function normal function expect that it contains yield expression. #yield is a keyword in Python that is used to return from a function without destroying the states of its local # variable and when the function is calle...
true
26d1082fce2c13c5e33c42da020c5e9adfc3d2e0
mohitkhatri611/python-Revision-and-cp
/python programs and projects/Programs/enum and compression.py
388
4.375
4
"""finding Index of Non-Zero elements in Python list using enum and list comprehension""" def prog(): test_list = [6, 7, 0, 1, 0, 2, 0, 12] print("original list: ",test_list) #index of non- zero elements in python list #using list comprehension and enumeration. res = [idx for idx,val in enume...
true
241e4410b89a58f5fdabbcda2a3207554043ae49
mohitkhatri611/python-Revision-and-cp
/python programs and projects/Python Data Structures Programs/linked list programs/Linked List Set 1 Introduction.py
1,539
4.375
4
#https://www.geeksforgeeks.org/linked-list-set-1-introduction/ class Node: def __init__(self,data): self.data=data self.next=None class LinkedList: def __init__(self): self.head=None def push(self,data): newNode=Node(data) newNode.next=self.head self.hea...
true
605cc2177cd64ce2b3aca0a11072824567114e44
mohitkhatri611/python-Revision-and-cp
/python programs and projects/Python Data Structures Programs/tree based programs/level order traversl.py
2,349
4.21875
4
"""2ways first second is taking O(n^2) and firstone is using queue is taking o(n)""" class Node: def __init__(self,data): self.data= data self.left=None self.right=None """this will take O(n)""" class level1: def printLevelOrder(self,root): if root is None: ...
true
4aafc75e31aa1adb6dd76e02abb9bdb80e5b3767
siddhusalvi/basic-python
/8_histogram.py
638
4.21875
4
""" 8. Write a Python program to create a histogram from a given list of integers. """ def print_histogram(numbers): flag = True count = 0 for x in numbers: if flag: maximum = x flag = False elif maximum < x: maximum = x count += 1 output...
true
cf61818df83ddadbdf01553fe328329ecf722f08
siddhusalvi/basic-python
/7_value_in_group.py
598
4.21875
4
""" 7. Write a Python program to check whether a specified value is contained in a group of values. Test Data : 3 -> [1, 5, 8, 3] : True -1 -> [1, 5, 8, 3] : False """ def is_in_group(numbers, elem): for i in numbers: if elem == i: return True return False data = [] size = int(input("E...
true
ab2f60ac081dedde2e75b064a17706ff9dca692b
ravi4all/PythonWE_AugMorning
/Backup/IfElse/01-IfElseSyntax.py
235
4.3125
4
# Compund Assignment -> = userMsg = input("Enter your message : ") # Comparison Operator -> ==, >, <, >=, <= # Logical Operators -> AND, OR, NOT if userMsg == "hello": print("Hello") else: print("I don't understand")
true
19b95cd3027752774bd922eeb9269354ef505836
AdamC66/python_fundamentals2
/ex4.py
445
4.15625
4
#Define a function that accepts a string as an argument # and returns False if the word is less than 8 characters long # (or True otherwise). def len_check(string): if len(string)>=8: return(True) else: return(False) print(len_check("apple")) print(len_check("orange")) print(len_check("adam...
true
d24283dc03f5f2846246d86822ef39709e569b84
Pushkar-chintaluri/projecteuler
/largestprimefactor.py
1,098
4.15625
4
import math import pdb def is_prime(num): """ Helper function that checks if a number is prime or not""" for n in range(2,int(math.sqrt(num))+1): if num%n == 0: return False return True def largest_prime_factor(num): """A Dynamic Programming Solution -- Close to O(N) solution""" ...
true
f30598c56ab09af3541976a7f7be687a0b93717a
approximata/edx_mit_6.00.2x
/unit3/noReplacementSimulation.py
1,030
4.125
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Tue Dec 6 15:30:33 2016 @author: matekovacsbodor """ def noReplacementSimulation(numTrials): ''' Runs numTrials trials of a Monte Carlo simulation of drawing 3 balls out of a bucket containing 3 red and 3 green balls. Balls are not replace...
true
2af621899d369f05a783776c094451045ad779ef
ahmedvuqarsoy/Cryptography-with-Python
/Decryption Caesar Cipher with Bruteforce.py
1,255
4.25
4
#Cracking Caesar Cipher using Bruteforce by Hajiahmad Ahmadzada import time def bruteforce(encrypted_message): encrypted_message.upper() #There is 26 letter and we check each combination #in normal Caesar Cipher for key in range(1,27): decrypted_message = "" #We decrypt message betwe...
true
f3206910885a7865f46247fc5998eb1a9dc8313b
IAmJustSomeRandomGuy/Hello-World
/project6-for loops.py
1,734
4.125
4
from typing import List speed = True for a in "Minecraft": print(a) names = ["Karen", "Josh", "Marry"] for name in names: print(name) for index in range(10): print(index) *hi, bye = range(12, 16) for hello in hi: print(hello) print() print(bye) for name in range(len(names)): print(n...
true
1b9f6b73458c09a9a5445c5a035b0e5cba233a93
asmitamahamuni/python_programs
/string_reverse.py
382
4.375
4
# Reverse the given string # 1. Reversing a string - Recursive def reverse(input): print(input) if len(input) <= 1: return input return reverse(input[1:]) + input[0] s = 'reverse' print(reverse(s)) # 2. Reversing a string - Iterative def reverse(input): return ''.join([input[i] for i in ran...
true
5ab1d4b0d1ec2231ab596d61b2bc033b43947eb3
jwcha/exercism-python
/leap/leap.py
600
4.4375
4
#!/usr/bin/env python3 # function to compute if a given year is a leap year or not. # A leap year is defined as: # A year which is divisible by four, # except if divisible by 100, # unless divisible by 400. def is_leap_year(year): # a one-liner solution return year % 4 == 0 and (year % 100 != 0 or year ...
true
423fd5804aabce808b46d64cfe83366c641627cf
BraeWebb/adventofcode2017
/day1/day1.py
1,169
4.15625
4
import sys def sum_matching(line, index_func=lambda i: i + 1): """ Computes the sum of matching pairs in a circular list. A matching pair is when a number equals the number found at index_func(i) in the list, where i is the numbers index and index_func is the provided function. By default this is ...
true
98f300d7811ec19ff4e815ef2da3dc41736bbf59
knittingarch/Zelle-Practice
/Exercises/5-4.py
253
4.125
4
''' A program that makes acronyms out of user-provided phrases. by Sarah Dawson ''' def main(): acronym = "" phrase = raw_input("Please enter your phrase: ") phrase = phrase.split(" ") for s in phrase: acronym += s[0].upper() print acronym main()
true
28069ad17663f9fc7949345f51c1866c9948eed6
evaristrust/Courses-Learning
/CreateDB/TestDB/contacts.py
998
4.28125
4
import sqlite3 db = sqlite3.connect('contacts.sqlite') db.execute("CREATE TABLE IF NOT EXISTS contacts(NAME TEXT, PHONE INT, EMAIL TEXT)") db.execute("INSERT INTO contacts(NAME, PHONE, EMAIL) VALUES('Big Man', 087894, 'big@gmail.com')") db.execute("INSERT INTO contacts VALUES('Tiny Man', 085343, 'tiny@gmail.com')") d...
true
11b2638a0a7ed50f2ca30eccb989113a1eea3ae4
evaristrust/Courses-Learning
/myexercises/exercise1.py
925
4.21875
4
# We are here going to work on the addition and multiplication # Generate two digit integers and do their multiplication # If their product is greater 1000, generate their sum , else generate their product import random num1 = random.randrange(10,100) num2 = random.randrange(10,100) product = num1 * num2 sum = num1 +...
true
6e3be7a0cd52a9218b1a29d0885794091e899dc2
evaristrust/Courses-Learning
/SecondProgram/pytbasics/CHALLENGES/Edabit/largest_numbers.py
863
4.40625
4
#print the largest numbers in a list... n numbers lst = [20, 42, 21, 34, 23, 70] lst.sort() print(lst[-3:]) # print three largest numbers # or my_list = [20, 42, 21, 34, 23, 70, 24] lst = sorted(my_list) print(lst[-3:]) def largest_numbers(n, lst): lst = [20, 42, 21, 34, 23, 70, 24,45] my_list = sorted(lst)...
true
a720339b1e5f7b8d4f99790f75bcc9ff265d40e1
evaristrust/Courses-Learning
/SecondProgram/pytbasics/CHALLENGES/Edabit/Title string.py
879
4.375
4
# Check if a string txt is a title text or not. # A title text is one which has all the words in # the text start with an upper case letter. def my_text(text): if text == text.title(): print("The text is title") else: print("The text is not title") my_text("World Health Organization") my_text("...
true
ae655fe0d0f0af55f777970f9d78beef11452b99
evaristrust/Courses-Learning
/SecondProgram/pytbasics/challenge_dict_join.py
2,147
4.3125
4
# Modify the program in the join file so that # so that the exits is a dictionary rather than a list # with the keys being the numbers of the locations and the values # being dictionaries holding the exits (as they do at present). # No change should be needed to the actual code # # once that is working, create a nothe...
true
84f271a644134c6c3d8818c9cc95e6861ed3fc1b
evaristrust/Courses-Learning
/SecondProgram/pytbasics/CHALLENGES/Edabit/prime.py
668
4.15625
4
# print the prime number from 0 and 100 # # start = 0 # end = 100 # for num in range(start, end): # if num == int(num): # nbers need to be positive! # for x in range(2, num): # if num % x == 0: # break # else: # print(num, end= " ") my_number = int(input("Ent...
true
ee7e75e0ae58f7cad82cdccabf8098739d7f87ff
evaristrust/Courses-Learning
/SecondProgram/intro_list_range_tuples/challenge3.py
1,599
4.375
4
# Given the tuple below that represents the Imelda May album # "More Maythem", Write a code to print the album details, followed by a # listing of all the tracks in the album. # Indent the tracks by a single tab stop when printing them # remember that you can pass more than one item to the print function # separated wi...
true
e3f22f939b1ea3bf144c9eb0cf9f2069e72e4a60
lambdaJasonYang/DesignPatterns
/DependencyInversion.py
2,113
4.21875
4
class ConcreteWheel: def turn(self): print("Using Wheel") return "Using Wheel" ## Car ---DEPENDS---> ConcreteWheel class Car: def __init__(self, ObjectThisDependsOn): self.Wheel = ObjectThisDependsOn self.turning = True def getState(self): if self.turning == True: ...
true
b1c1656f44ee332458a08db1b5123d2379834291
delphinevendryes/coding-practice
/left_view_binary_tree.py
2,493
4.3125
4
''' Given a Binary Tree, print Left view of it. Left view of a Binary Tree is set of nodes visible when tree is visited from Left side. ''' class Node(): def __init__(self, val, left=None, right=None): self.value = val self.left = left self.right = right def insertLeft(self, val): ...
true
51ccceadf4a071b2d1bc4faa2c84ab3053d14347
jamesdeepak/dsp
/python/q8_parsing.py
1,213
4.375
4
# The football.csv file contains the results from the English Premier League. # The columns labeled ‘Goals’ and ‘Goals Allowed’ contain the total number of # goals scored for and against each team in that season (so Arsenal scored 79 goals # against opponents, and had 36 goals scored against them). Write a program t...
true
06714b34733bb48d3ba92d38470c89bc13b40224
anamarquezz/Data-Structures-and-Algorithms-The-Complete-Masterclass
/BigONotation/01 Why we Need O Notations/NotBigO/question1_forLoop.py
456
4.125
4
''' Write a program to calculete sum of n natural numbers. For example, we will take n as 100 -> Using For Loop -> Using While Loop ''' import time time.time() timestamp1 = time.time() ###python Program to find Sum of N natural Numbers ### number = 100 total = 0 for value in range(1, number + 1): ...
true
d8bbbc389e98c4c1bbd6524388726e8593b51cc1
bjoesa/minitools
/link_checker.py
1,415
4.125
4
#!/usr/bin/python3 """Check a Website (URL) for broken links. This little helper program was made to check website and link status on a given Website. Typical usage example: Simply execute the whole code. You'll be asked to provide an URL. Website and link status will be printed. """ fr...
true
c99f5031e44ad629b01e55ee62b1dbfd16b53e16
devam6316015/all-assignments
/assign 17 twinker GUI.py
1,992
4.40625
4
# print("Q1. Write a python program using tkinter interface to write Hello World and a exit button that closes the interface.") # import tkinter # from tkinter import * # import sys # def exit(): # print("Hello World") # sys.exit() # root=Tk() # b=Button(root,text="EXIT",width=20 ,command=exit) # b.pack() # root.mai...
true
178e21e0dc3e6f48565301bd039ec2ee1ea09829
TheAnand/Data_Structure
/Linkedlist basic operations.py
1,580
4.21875
4
class node : # creating a node class def __init__(self,data) : self.data = data self.next = None class linkedList : # creating a linkedlist class def __init__(self) : self.start = None # for view of the linked list def viewList(self) : # if node is empty then execute the if scope if self.start is None :...
true
c181fb04234b575f8539abf1647be1543ddb3021
isaacrael/python
/Code Cademy/average_numbers_dict_challenge_exercise_practice.py
868
4.375
4
"""Written By: Gil Rael The following python program demonstrates the use of a function called average that takes a list of numbers as input and then prints out the average of the numbers. Algorithm: Step 1: Create list of numbers called lst = [80,90] Step 2: total_values equals the length of the list ...
true
d647f46125b4bed90bf42ec5f46442a8d0672afd
isaacrael/python
/Code Cademy/for_loop_list.py
267
4.21875
4
"""Written By: Gil Rael The following python program demonstrates the use of the for loop with a list""" # Initialize Variables # Define Functions my_list = [1,9,3,8,5,7] for number in my_list: new_num = number * 2 # Your code here print new_num
true
1b1136eccad94ad29b159d7f64c01f171821dd0d
isaacrael/python
/Code Cademy/grocery_store_loop_determine_inventory_value.py
1,543
4.28125
4
"""Written By: Gil Rael The following python program demonstrates the use of a function to calculate the value of inventory in a grocery store and print the result""" """Algorithm: Step 1: Create grocery_store_inventory_value function - Done Step 2: Pass dictionaries prices, stock - Done Step 3: Print...
true
af3a71e7e14e40fdda72d8ac9c3bb8933327e83f
rajivnagesh/pythonforeverybodycoursera
/assignment7.1.py
322
4.5625
5
# Write a program that prompts for a file name, then opens that file and reads through the file,and print the contents of the file in upper case. #Use the file words.txt to produce the output below. fname=input('Enter file name:') fhand=open(fname) for ab in fhand: bc=ab.rstrip() print(bc.upper()) ...
true
653bb16ca399e7bb704b9a8ad1f13fefa22d1caf
Nyarko/Intro_To_Python
/RadiusSurfAreaVolume.py
262
4.21875
4
import math radius = int(input("Input the radius: ")) def surface(): ans = radius**2 *math.pi * 4 return ans def volume(): vol = radius**3 *math.pi*4/3 return vol print ("The surface area is: ", surface()) print ("The volume is: ", volume())
true
e7e3f7d9a762c66b6e99bb6a593c04c848622f1e
draftybastard/DraftyJunk
/pre_function_exc.py
874
4.28125
4
# Function has a single string parameter that it checks s is a single word starting with "pre" # # Check if word starts with "pre" # Check if word .isalpha() # if all checks pass: return True # if any checks fail: return False # Test # get input using the directions: *enter a word that starts with "pre": * # ca...
true
80f0837dcc9768d491dab8129ea8a40c1b38cf55
atashi/LLL
/algorithm/Reverse-Integer.py
922
4.28125
4
# Given a 32-bit signed integer, reverse digits of an integer. # # Example 1: # # Input: 123 # Output: 321 # # Example 2: # # Input: -123 # Output: -321 # # Example 3: # # Input: 120 # Output: 21 # # Note: # Assume we are dealing with an environment which could only store integers within the 32-bit signed integer range...
true
4c8a2419bcfc76d92cc2be4485abc68a270fdb19
atashi/LLL
/algorithm/Reverse-Linked-List.py
1,829
4.34375
4
# Reverse a singly linked list. # Example: # Input: 1->2->3->4->5->NULL # Output: 5->4->3->2->1->NULL # Follow up: # A linked list can be reversed either iteratively or recursively. Could you implement both? # Definition for singly-linked list. class ListNode: def __init__(self, x): self.val = x ...
true
0bd7ce5e366a0578aa88aee81c908b443db28d76
AllenHongjun/cs61a
/lab/61a-su20-mt-solution/q6/q6.py
2,749
4.15625
4
email = 'example_key' def copycat(lst1, lst2): """ Write a function `copycat` that takes in two lists. `lst1` is a list of strings `lst2` is a list of integers It returns a new list where every element from `lst1` is copied the number of times as the corresponding element in `lst2`. If...
true
f4c071400f9be450a8601f90082849c6e21dc1f2
cs50Mu/wonderland
/cs61a/cs61a2014/www-inst.eecs.berkeley.edu/~cs61a/su14/lecture/exceptions.py
331
4.3125
4
## Commented out so that the entire file doesn't error # ValueError('Andrew made a ValueError') ## Break the program by raising the actual error # raise ValueError('Andrew made a ValueError') while True: try: x = int(input('Type in an Integer: ')) print(x+10) except ValueError: print('Not a valid int...
true
c94b3229da293b56f9a8ba689105e77078dedbe7
pavankat/python-fun
/python-review-quiz.py
2,167
4.25
4
# 1. # make a variable called a, set it to 2 # make a variable called b, set it to 3 # add the variables together a = 2 b = 3 print(a+b) c = a+b print(c) # 2. # write a conditional statement that prints out hello if b is greater than a # 3. # add an else to the previous conditional statement so that it prin...
true
a4f336d0e32f811e30239a26cde94d5f7884674a
TheCaptainFalcon/DC_Week1
/tip_calc2.py
949
4.25
4
#Conversion of input into float as base bill_amount = float(input("What is your total bill amount?")) #str() not required - but helps with organization service_level = str(input("Level of service? ('good', 'fair', 'bad') ")) if service_level == "good": #bill_amount input is converted to float -> tip_amount = floa...
true
17c4e5bf0d0a02585bfd4c50f30142954e439138
vijaicv/deeplearning-resources
/self_start/Learn_Numpy/Numpy_Basics/Creating_Arrays.py
1,065
4.21875
4
import numpy as np # 1-d array a=np.array([2,4,6,8]) #creates an array with given list print(a) a=np.arange(2,10,2) #similar to range() 2 to 9 in steps of 2 print(a) a=np.linspace(2,8,4) #creates an array with 4 elements equally spaced between 2 and 8 print(a) #now lets try 2-d arrays print("\n\n 2-d array\n us...
true
29f894ae29d361069dcb3999d6c02fec42ffe81a
vinhpham95/python-testing
/BasicEditor.py
1,287
4.21875
4
# Vinh Pham # 10/11/16 # Lab 7 - Basic Editor # Reads each line from word.txt and copy to temp.txt unless asked to change the line. # Open appopriate files to use. words_file = open("words.txt","r") temp_file = open("temp.txt","w") line_counter = 0 # To count each line; organization purposes. # Read each line seperat...
true
083a971122bc3c0231b5f2014ebc7bb94f3bee6f
vinhpham95/python-testing
/StringFun.py
1,403
4.4375
4
#Vinh Pham # 9/27/16 # Lab 5 # Exercise 1:Given the string "Monty Python": # (a) Write an expression to print the first character. # (b) Write an expression to print the last character. # (c) Write an expression inculding len to print the last character. # (d) Write an expression that prints "Monty". # Exercise 2: Giv...
true
d1734064123a7d1cd0b4a4c9100743b2ca94ca69
StrawHatAaron/python3_fun
/python_collections/sillycase.py
681
4.3125
4
#Aaron Miller #Feb 17 2017 #python 3.6.0 #this program will make the first half of a string lower case and the second half upper caase #by using the made sillycase method def sillycase(fun_stuff): half_uppercase = fun_stuff[len(fun_stuff)//2:].upper() half_lowercase = fun_stuff[:len(fun_stuff)//2].lower() return ...
true
fc89d543eb0e4339334edef14dae4b597f802bf0
Prakashchater/Leetcode-array-easy-questions
/LongestSubarray.py
1,443
4.1875
4
# Python3 implementation to find the # longest subarray consisting of # only two values with difference K # Function to return the length # of the longest sub-array def longestSubarray(arr, n, k): Max = 1 # Initialize set s = set() for i in range(n - 1): # Store 1st element of # sub-...
true
c9f386c320f571798a0f4637bcfa0004dadffced
muhzulfik/python-dasar
/set.py
658
4.21875
4
fruits = {'banana', 'grape', 'pinapple'} print(type(fruits)) print(fruits) # Access Items for x in fruits: print(x) # Add Items fruits.add('apple') print(fruits) fruits.update(['sawo','rasberry']) print(fruits) # Get The Length print(len(fruits)) # Remove Item fruits.remove("banana") print(fruits) fruits.discar...
true
ffd27b28d2f3ad9f5cdf347fc9aaf3ef346582fb
paulfranco/code
/python/adjacent_elements_product.py
587
4.25
4
# Given an array of integers, find the pair of adjacent elements that has the largest product and return that product. # Example # For inputArray = [3, 6, -2, -5, 7, 3], the output should be # adjacentElementsProduct(inputArray) = 21. # 7 and 3 produce the largest product. def adjacentElementsProduct(inputArray): pr...
true
9d324dc3cdb0f98519bc5a5620836a200d46aae0
paulfranco/code
/python/hexadecimal_output.py
226
4.15625
4
user_input = raw_input("Enter a hex number") output = 0 for power, hex_digit in enumerate(reversed(user_input)): print("{} * 16 ** {}".format(hex_digit, power)) output += int(hex_digit, 16) * (16 ** power) print(output)
true
7483b2b593dc962382a7af3c802059202cf12e2e
paulfranco/code
/python/longest_word.py
333
4.25
4
# Create a program that reads some files and returns the longest word in those files import os dirname = input("Enter a dirname: ") def longest_word(filename): return max(open(dirname + '/' + filename).read().split(), key=len) print({dirname + "/" + filename: longest_word(filename) for filename in os.listdi...
true
bb1e67d84dc6c7d98a0b5f379304f41fb474b5bc
paulfranco/code
/python/element-wise_operations.py
809
4.46875
4
# The Python way # Suppose you had a list of numbers, and you wanted to add 5 to every item in the list. Without NumPy, you might do something like this: values = [1,2,3,4,5] for i in range(len(values)): values[i] += 5 # now values holds [6,7,8,9,10] # That makes sense, but it's a lot of code to write and it run...
true
2f41c91d5dd1de35c6dcc4e19a8b5c968efec774
wendyliang714/GWCProjects
/binarysearch.py
1,119
4.25
4
import csv import string # Open the CSV File and read it in. f = open('countries.csv') data = f.read() # Split the data into an array of countries. countries = data.split('\n') length = len(countries) print(countries) # Start your search algorithm here. user_input = input("What country are you searchi...
true
4ed46c72d1b746d0d8f3c93e2c053995baa65f2e
lambdaplus/python
/Algorithm/sort/merge/merge-sort1.py
1,061
4.1875
4
# coding: utf-8 -*- from random import randrange from heapq import merge ''' Help on function merge in module heapq: merge(*iterables, key=None, reverse=False) Merge multiple sorted inputs into a single sorted output. Similar to sorted(itertools.chain(*iterables)) but returns a generator, does not pull t...
true
31c52ba996b1ab82e3e91e76532777bc2ec836fb
iKalyanSundar/Log-Parsing
/modul.py
2,143
4.15625
4
import glob import sys import os.path import pandas as pd #function to get path in which csv files should be scanned def get_file_path_input(): input_path=input("Enter Path where the output file has to be created: ") while (input_path is None) or (input_path == ''): input_path=input("Enter Pat...
true
864a7a46c53c3d87cd09fbce26423aa8c1ccd7e9
jimjshields/pswads
/4_recursion/5_tower_of_hanoi.py
1,716
4.34375
4
# Tower of Hanoi - specs # Three poles # Need to move tower of ascending-size disks from one pole to another # Can only put smaller disks on top of larger disks # Probably makes sense to use three stacks to represent this # Recursively solve this - base case is you have one disk # Case to decrease problem size - move t...
true
c679e5740a3e15de5800071f5603209629ca69ce
narayan-krishna/fall2019cpsc230
/Assignment6/file_complement.py
2,779
4.25
4
#Krishna Narayan #2327205 #narayan@chapman.edu #CPSC 230 section 08 #Assignment 6 import string #import so that we can test the characters of the input #Complement function def complement(sequence): alphabet_one = "ACTG " #alphabet of letters alphabet_two = "TGAC " #complement to that alphabet comp = "" #...
true
490076c3dbe8fb27aae84eb5de54c1b0ce6c2a39
benie-leroy/DI-learning
/Di_execises/pythonProject/Helloword/venv/exercices_w4_day3.py
880
4.21875
4
# exercice 1 : Convert Lists Into Dictionaries ''' keys = ['Ten', 'Twenty', 'Thirty'] values = [10, 20, 30] dic = dict(zip(keys, values)) print(dic) ''' # exercice 2: Cinemax #2 family = {"rick": 43, 'beth': 13, 'morty': 5, 'summer': 8} cost = 0 for x in family: if family[x] < 3: print(x + ' ,your ticket i...
true
f90eddf4ae56e379f8a9c31bc72d5f6fc891b049
rutujar/practice
/Fork Python/Tracks/Module 2 (Control Structures)/python-loops/3_While_loop_in_Python.py
1,276
4.25
4
#While loop in Python """ While loop in Python is same as like in CPP and Java, but, here you have to use ':' to end while statement (used to end any statement). While loop is used to iterate same as for loop, except that in while loop you can customize jump of steps in coupling with variable used to loop, after ever...
true
6d4de5bb8d022bfa2e55e0b0ce65ac32b12fa577
rutujar/practice
/Fork Python/Contest/Module 1/Nearest Power.py
1,560
4.34375
4
Nearest Power #You are given two numbers a and b. When a is raised to some power p, we get a number x. Now, you need to find what is the value of x that is closest to b. # Input Format: The first line of input contains T denoting the number of testcases. T testcases follow. Each testcase contains two lines of in...
true
3248fbc2ea863e003f5ffa355bb9556349fe3a86
rutujar/practice
/Fork Python/Tracks/Module 3 (strings)/python-strings/2_Slicing_in_String_Python.py
1,667
4.34375
4
#Slicing in String - Python """ Here we'll talk about the novel and perhaps tantalizing concept of slicing. Slicing is the process through which you can extract some continuous part of a string. For example: string is "python", let's use slicing in this. Slicing can be done as: a. string[0:2] = py (Slicing till in...
true
66566b1b7b6cb2b76c342763daac5fa4d6d0481d
rutujar/practice
/Fork Python/Tracks/Module 1 (Python Basics)/python-io/6_Taking_input_and_typecasting_Python.py
1,618
4.125
4
#Taking input and typecasting - Python """ You have learned to take string input in python. Now, you'll learn how to take input of int, float, and bool. In Python, we use the input() function and put this function in either int(), float(), or bool() to typecast the input into required data type. Also, integers, fl...
true
0e7fdcb1cfea5a0c336e849b9dbdc50089fd6ef1
rutujar/practice
/Fork Python/Tracks/Module 3 (strings)/python-strings/1_Welcome_aboard_Python.py
923
4.3125
4
#Welcome aboard - Python """ This module talks about Strings in Python. String in Python is immutable (cannot be edited). You have learnt about seperators in Python. Let's start String with first question given below: Given name of a person, the task is to welcome the person by printing the name with "Welcome". If...
true
535bb84156e671b010d9038e29285ee4a6f739fc
Icfeeley/workspace
/Homework/csci362/team5/Commuters_TESTING/scripts/dataTypeParser.py
1,121
4.15625
4
''' parses a string containing data values in python code and determinds the data type of values in the string. ''' def main(): in1 = '[1,2]' in2 = '\'this is a string\'' in3 = '1337' in4 = '10;20' in5 = '[1,2];[2,1]' in6 = '[1,\'2\'];2;4;\'string\'' inputs = [in1,in2,in3, in4, in5, in6] for i in inputs: ...
true
5cd094c4fcfc41b45cd5c9eb755dc5dcdaea81df
picklepouch/workspace
/list_maker2.py
1,247
4.3125
4
import os groceries = [] print("Type help for assistance") def clear_screen(): os.system(cls if os.name == "nt" else clear) def list_items(): clear_screen() for items in groceries: print ("-", items) def remove_item(): list_items() what_remove = input("What would you like to remove? ") ...
true
3da3640a98e9226f656fc55c755a562f1ca4be81
VashonHu/DataStructuresAndAlgorithms
/data_structure/LinkedList.py
1,670
4.15625
4
class ListNode(object): def __init__(self, data, next=None): self.__data = data self.__next = next @property def next(self): return self.__next @property def data(self): return self.__data @next.setter def next(self, next): self.__next = next """ ...
true
60db2d5c2a5db0763170bd4fecf21fb1427b3c3c
thulc567/Padhai_Course_Materials
/FDSW3Asgn1Prob2_Solution-200215-182944.py
2,398
4.25
4
#!/usr/bin/env python # coding: utf-8 # # Assignment 1 Problem 2 # Exercise 2 # # --- # # 1. Write an iterative function to compute the factorial of a natural number # 2. Write a recursive function to compute the factorial of a natural number. # 3. Write a function to compute $\frac{x^n}{n!}$ given a float $...
true
15f0034b53c0619cd7c527d0433294ec17b93c1b
weiyima/python-examples
/chap11_regex/regex.py
1,379
4.21875
4
# Regular Expressions """ Python Regular Expression Quick Guide ^ Matches the beginning of a line $ Matches the end of the line . Matches any character \s Matches whitespace \S Matches any non-whitespace character * Repeats a character zero or more times *? Repeats a cha...
true
ab1f9e2562f47f50d5cf2120195f49964484bd5e
weiyima/python-examples
/chap06_datatypes/list.py
1,182
4.1875
4
#Chapter 8 - List friends = ['Joseph',0.99,'Hello','World'] friends[1] = 'Sally' #list are mutable, list are not #print(friends) #range(int) used to create range/list of size int (e.g. range(4) will be [0,1,2,3]) for i in range(len(friends)): friend = friends[i] print(friend) #list functions friends[3:] #sl...
true
4b40e8821fe98898611ff181eeefa845412ae036
aprebyl1/DSC510Spring2020
/BUNCH_JONATHAN_DSC510/BUNCH_11_1.py
2,817
4.125
4
# File: BUNCH_11_1.py # Name: Jonathan Bunch # Date: 24 May, 2020 # Course: DSC510-T303 Introduction to Programming (2205-1) # Your program must have a welcome message for the user. # Your program must have one class called CashRegister. # Your program will have an instance method called addItem which takes o...
true
ef09a653928272cd0062a73514bbf6623f47d75f
aprebyl1/DSC510Spring2020
/Kuppuswami_DSC510/Fiber_Cable_Quotation.py
1,522
4.15625
4
# Program Name: Quotation for Fiber Cable Installation #Calculate the installation cost of fiber optic cable by multiplying the total cost as the number of feet times $0.87. # Print a receipt for the user including the company name, number of feet of fiber to be installed, the calculated cost, and total cost in a legib...
true
3120783f04c073be7f1eb0ab6c1bb5ef3f6593c9
aprebyl1/DSC510Spring2020
/BUNCH_JONATHAN_DSC510/BUNCH_4_1.py
2,886
4.375
4
# File: BUNCH_4_1.py # Name: Jonathan Bunch # Date: 5 April, 2020 # Course: DSC510-T303 Introduction to Programming (2205-1) # This week we will modify our If Statement program to add a function to do the heavy lifting. # Modify your IF Statement program to add a function. This function will perform the cost cal...
true
aa5509e97d88e5a453029dba3f95513988e34938
aprebyl1/DSC510Spring2020
/SURYAWANSHI_DSC510/week3/assignment3_1.py
2,504
4.53125
5
# File: billingInvoice_assignment2_1.py # Author: Bhushan Suryawanshi # Date:Wednesday, March 25, 2020 # Course: DSC510-T303 Introduction to Programming (2205-1) # Desc: The program will do followings: # Display a welcome message for your user. # Retrieve the company name from the user. # Retrieve the number of feet of...
true
a05756270eef5a4351ac08944d06b1de123199b5
aprebyl1/DSC510Spring2020
/TRAN_DSC510/UserFiberOptics.py
866
4.3125
4
#The purpose of this program is to retrieve company name and number of feet of fiber optic cable to be installed from user, Assignment number 2.1, Hanh Tran username= input('What is your username?\n') print('Welcome' + username) company_name=input('What is your company name?\n') quantity= input('How many feet of fi...
true
af7bb7bb3009a4c6a707db238f389f8f81fb4c18
aprebyl1/DSC510Spring2020
/TRAN_DSC510/Week_6.1_Temperatures.py
1,256
4.5
4
# File: Assignment_6.1 # Name: Hanh Tran # Due Date: 4/19/2020 # Course: DSC510-T303 Introduction to Programming (2205-1) # Desc: This program will do the following: # create a list of temperatures based on user input # determine the number of temperatures # determine the largest temperature and the smallest temperatu...
true
74d09b7aee7f0536acc60e687d64eff287d23e63
santoshmano/pybricks
/recursion/codingbat/powerN.py
372
4.15625
4
""" Given base and n that are both 1 or more, compute recursively (no loops) the value of base to the n power, so powerN(3, 2) is 9 (3 squared). powerN(3, 1) → 3 powerN(3, 2) → 9 powerN(3, 3) → 27 """ def powerN(base, n): if n == 0: return 1 else: return base*powerN(base, n-1) print(powerN(3,...
true
a34e540e2ebe1b343c2d59cf9d5ec1d25c6afc10
Ernestterer/python_work
/lists/places_to_visit.py
625
4.375
4
places = ['jerusalem', 'london', 'newyork', 'singapore', 'dubai'] print(f"The cities I would like to visit are:\n\t\t\t\t\t{places}") print(f"The cities I would like to visit alphabetically:\n\t\t\t\t\t{sorted(places)}") print(f"Here is the original order of the list:\n\t\t\t\t\t{places}") print(f"The cities I would li...
true
6e5bed5488ddda287c784d67090d1d6f785e2c21
mohammad-javed/python-pcap-course
/020-055-lab-list-methods/cipher_decrypt_answer.py
545
4.4375
4
cipher = input('Enter your encrypted message: ') def decrypt(cipher): result = "" # Iterate through the cipher for char in cipher: # Check whether character is alphanumeric if char.isalpha(): if char == 'A': result += 'Z' elif char == 'a': ...
true
0cec6daa3794d985d252d772832795642a7ba42a
mohammad-javed/python-pcap-course
/010-025-lab-math-module/is_triangle_answer.py
374
4.1875
4
import math def is_triangle(a, b, c): if math.hypot(a, b) == c: return True return False print("The program checks if three sides form a right-angled triangle.") inp1 = int(input("Enter first side value: ")) inp2 = int(input("Enter second side value: ")) inp3 = int(input("Enter third side value: "))...
true
afbdc179d558b94dd187d540ba8c7ea27804da51
jacekku/PP3
/Python/04/zadanie08.py
744
4.15625
4
#the exercise wants me to create a transposition for square maticies but the next one wants me to #create one for any size matrix so im going to do it here from random import randint def create_matrix(y_size,x_size,key=0,key_args=[]): return[ [ (key(*key_args) if callable(key) else key) for _ i...
true
58cba3dfbd0f53307a2927d7ad3c93c93b352658
Alexkalbitz/leetcode
/14.py
1,712
4.21875
4
# Write a function to find the longest common prefix string amongst an array of strings. # # If there is no common prefix, return an empty string "". # # Example 1: # # Input: ["flower","flow","flight"] # Output: "fl" # # Example 2: # # Input: ["dog","racecar","car"] # Output: "" # Explanation: There is no common prefi...
true
72737daa1013835d1c191efb2a02c74ab6a5441a
Duelist256/python_basics
/python_basics/strings.py
562
4.25
4
x = "Hello" print(x) a = str("world") print(a) print() print(x[-1]) print(x[0]) print(x[4]) print() print(x[1:3]) print(x[1:]) print(x[:3]) print(x[:10]) print() x = "I'm %d y.o" % 171 print(x) print(str(1)) print(len("12345")) print(sum([1, 2, 3])) print() # Exercise 1. Make a program that displays your favourite a...
true