blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
21b13df050bb393416e65d2671f6d7928fb34f6a
ErickMwazonga/sifu
/math/reverse_integer.py
738
4.21875
4
''' 7. Reverse Integer Link: https://leetcode.com/problems/reverse-integer/ Given a signed 32-bit integer x, return x with its digits reversed. If reversing x causes the value to go outside the signed 32-bit integer range [-231, 231 - 1], then return 0. Assume the environment does not allow you to store 64-bit integer...
true
229e22715ff921f6dde25bdc8aa8b034832e3abb
ErickMwazonga/sifu
/hashmaps/jewels_and_stones.py
849
4.125
4
''' 771. Jewels and Stones Link: https://leetcode.com/problems/jewels-and-stones/ You're given strings J representing the types of stones that are jewels, and S representing the stones you have. Each character in S is a type of stone you have. You want to know how many of the stones you have are also jewels. The let...
true
a160d41841365f6bc5537b472fb9f94df459bbee
ErickMwazonga/sifu
/binary_search/sqrt/sqrt.py
1,343
4.15625
4
''' 69. Sqrt(x) Link: https://leetcode.com/problems/sqrtx/ Given a non-negative integer x, compute and return the square root of x. Since the return type is an integer, the decimal digits are truncated and only the integer part of the result is returned. Write a function that takes a non-negative integer and returns ...
true
22a28928de9b7cd4513c0aed9dddcbded63314b1
ErickMwazonga/sifu
/recursion/learning/count_occurrences.py
692
4.25
4
''' Given an array of integers arr and an integer num, create a recursive function that returns the number of occurrences of num in arr Example input -> [4, 2, 7, 4, 4, 1, 2], num -> 4 output = 3 ''' def countOccurrences(arr: list[int], num: int, i: int = 0): if i == len(arr): return 0 if arr[i] == ...
true
458be929b5f24b02589aa291010b2f4b7ba882de
ErickMwazonga/sifu
/graphs/shortest_path.py
1,563
4.125
4
''' shortest path https://structy.net/problems/shortest-path Write a function, shortestPath, that takes in an array of edges for an undirected graph and two nodes (nodeA, nodeB). The function should return the length of the shortest path between A and B. Consider the length as the number of edges in the path, not the ...
true
6e64d56410b082881f0a2316e8011f1691333f80
davidhansonc/Python_ZTM
/random_game.py
946
4.15625
4
''' * File Name : random_game.py * Language : Python * Creation Date : 05-01-2021 * Last Modified : Wed Jan 6 22:46:12 2021 * Created By : David Hanson ''' from random import randint def run_guess(guess, answer): try: if 1 <= int(guess) <= 10: if int(guess) == int(answer): ...
true
6fa0434dd00c0c40d6c22d5c8dbb8732f0e208d0
mohit266/Python-course-Edugrad
/Edugrad_1.py
458
4.125
4
""" QUESTION 1: Swap the case of the string that comes as an input and return the string while making sure that the first letter of the string stays Uppercase. Example - Input - "PyThON" Output - "PYtHon" """ def main(i): result = "" for ch in range(len(i)): if ch == 0: result += i[ch].upp...
true
c2f4904730f474b18290c7fc549086c1666d5cbc
chiragnarang3003/assignment6
/assign6.py
2,982
4.375
4
''' #Question1:->Create a function to calculate the area of a sphere by taking radius from user. ''' def area_sphere(num): '''Calculate the area of the sphere using Fuctions''' pi=3.14 temp=4*pi*num*num return temp radius=int(input("Enter radius of the sphere : ")) output=area_sphere(radius) print("The ...
true
e34cde867262e8ae91ddb55f5d5d2898e7d7eec7
SebastianN8/calculate_pi
/calculate_pi.py
1,312
4.34375
4
# # calculate_pi.py # # Created by: Sebastian N # Created on: April 19 # # This program calculates pi according to iterations # # This is where math.floor comes from import math # Function that contains the loop in order to get the result of a gregory leibniz series def calculate_pi(iterations_passed_in): # Variable...
true
f525f2bc24bb8d015a687a475ae0e136f2b28983
ritesh2905/StringPractice
/05FindingSubstring.py
205
4.125
4
# Substring in a string str1 = 'the quick brown fox jumps over the lazy dog' str2 = input('Enter a substring : ') if str2 in str1: print('Sunsting is present') else: print('Substring not found')
true
2683b4888e1654b57783905aacbf7d79f21d145c
Priyankasgowda/90dayschallenge
/p50.py
1,834
4.375
4
# Activity Selection Problem | Greedy Algo-1 # Greedy is an algorithmic paradigm that builds up a solution piece by piece, always choosing the next piece that offers the most obvious and immediate benefit. Greedy algorithms are used for optimization problems. An optimization problem can be solved using Greedy if the pr...
true
4c7d779f8dfcabda3e19ec33136ef11687926ea0
Priyankasgowda/90dayschallenge
/p38.py
1,548
4.25
4
# Maximum Length Chain of Pairs | DP-20 # You are given n pairs of numbers. In every pair, the first number is always smaller than the second number. A pair (c, d) can follow another pair (a, b) if b < c. Chain of pairs can be formed in this fashion. Find the longest chain which can be formed from a given set of pairs....
true
081e9ab63f45f82814274dd037af5a9ca22599ee
JoachimIsaac/Interview-Preparation
/arrays_and_strings/reordering_words_in_a_sentence.py
2,806
4.3125
4
""" Problem 3: Reverse the ordering of words in a sentence. For example: Input: "The weather is amazing today!" Output: "today! amazing is weather The" UMPIRE: Understand: --> can we get an empty string? yes --> can we get a single letter ? yes --> so we need to reverse the entire sentence but keep the words in t...
true
9ede3d57572351010d154f023ef131ca957316e8
JoachimIsaac/Interview-Preparation
/LinkedLists/86.PartitionList.py
1,986
4.125
4
# Definition for singly-linked list. # class ListNode: # def __init__(self, val=0, next=None): # self.val = val # self.next = next """ UMPIRE: --> we are getting a singlely linked list --> the calue x is asusumed to always be there --> what if we get an empty linked list (just return it ) same w...
true
6db5b0a035b58bd2cf1e2ec243591726cf5beced
prajjwolmondal/Rock-Paper-Scissors
/rps.py
2,148
4.46875
4
# This is a rock paper scissors game in Python #Goal #Ask the player if they pick rock paper or scissors #Have the computer chose its move #Compare the choices and decide who wins #Print the results #Subgoals #Let the player play again #Keep a record of the score e.g. (Player: 3 / Computer: 6) import random def use...
true
4339bebc75fb603808739f5289ece703c2bbeaaf
ram4ibm/codeworks
/challenge3/dict_of_dict_value.py
1,310
4.25
4
#!/usr/bin/env python # Incomplete : 40 min # VARIABLES #input_nested_var = dict(input("Enter the Nested input object: ")) #input_nested_key = input("Enter the Nested input key: ") #input_nested_var = {"a": {"b": {"c": "d"}}} input_nested_var = {"a": {"b": {"c": {"d": "e"}}}} #input_nested_var = {"a": {"b"...
true
2476666d622309d940c03489242121a701127610
KolluriMounish/Python-problem-Solving
/problem_1.py
893
4.4375
4
#TODO: Given an array containing unsorted positive or negative integers with repeated # values, you must arrange the array in such a way that all non-zeroes should be on the left- # hand side of an array, and all zeroes should be on the right side of the array. Order of non- # zero elements does not matter. You are ...
true
bc25e8e24dccca506cbce23efa340fa6470f2b68
Malbshri/malbshri
/lesson 59.py
880
4.1875
4
import re #Replace all white-space charactor with the digit "9": str = "The rsin in Spain" x = re.sub("\s", "9", str) print(x) import re #Replace the first two occurrence of white-space charactor with the digit 9" str = "The rain in Spain" x = re.sub("\s", "9", str, 2) print(x) import re #The search() function retu...
true
9857a478ff0a80d9962a333bb2afe8f294694d0e
CleverOscar/python-udemy
/exercise/conditional.py
893
4.25
4
## -*- coding: utf-8 -*- #x = 5 #y = 6 # #print('x =',x,'y =', y) #print('X is less than Y:', x<y) #print('X is greater than Y:',x>y) # #var_1 = 7 #var_2 = 7 # #print('Var_1:', var_1, 'Var_2:', var_2) #print(var_1 < var_2) #print(var_1 > var_2) #print(var_1 == var_2) #print(var_1 <= var_2) #print(var_1 >= var_2) #print...
true
3bd04acf2d465c96e2914be6ade4d9283c7b72ec
cyndichin/DSANano
/Data Structures/Recursion/Deep Reverse.py
1,749
4.71875
5
#!/usr/bin/env python # coding: utf-8 # ## Problem Statement # # Define a procedure, `deep_reverse`, that takes as input a list, and returns a new list that is the deep reverse of the input list. # This means it reverses all the elements in the list, and if any of those elements are lists themselves, reverses all t...
true
abebd06788fd47dbab9773fc1f64e100de2476e2
ATLS1300/pc04-generative-section12-kaily-fox
/PC04_GenArt.py
2,262
4.125
4
""" Created on Thu Sep 15 11:39:56 2020 PC04 start code @author: Kaily Fox ********* HEY, READ THIS FIRST ********** My image is of a star and a moon in the night sky. I decided to do this because the sky is one of my favorite parts of nature. Its' beauty is so simplistic yet breath taking. The natural phenomenas t...
true
1202fa13f40bb0f3d5138213af0ce12798beb6d0
alexdemarsh/gocode
/blogmodel.py
2,498
4.5
4
''' Blog Model Create a class to interface with sqlite3. This type of object is typically called a Model. The table in sqlite3 will have two columns: post_name and post_text Discuss with your neighbour on how to solve this challenge. To connect Python to SQL, reference the following: http://www.pythoncentral.io/...
true
3c07f4c0549d6d02ca7ca975b83af3943f3dd12b
STMcNamara/cs50-Problems
/pset6/vigenere/vigenere.py
1,462
4.1875
4
import sys from cs50 import get_string # Define a main function to allow returns def main(): # Return 1 if incorrect number of arguments provided if len(sys.argv) != 2: print("Please provide one command line argument only") sys.exit(1) # Return 1 if the key is not letters ony key = s...
true
2d499a16ab2c0af88d8fe1dc1bb1f755cc1fe0b3
awsaavedra/coding-practice
/python/practice/2ndEditionLearningPythonTheHardWay/ex32.py
492
4.125
4
# creating non-empty arrays the_count = [1, 2, 3, 4, 5] fruits = ["Apples", "Oranges", "Tangerines", "Pears"] change = [1, "two", 3, "four"] for number in the_count: print "This number %d " % number for fruit in fruits: print "This fruit: %s" % fruit for i in change: print "I got %r" %i elements = [] for i i...
true
1f838acbcd6fc68280d7425dab45414467815a0e
awsaavedra/coding-practice
/python/practice/2ndEditionLearningPythonTheHardWay/ex15.py
423
4.15625
4
filename = raw_input("Please give me the filename you would like to open:") txt = open(filename) print "Here's your file %r:" % filename print txt.read() print "I'll also ask you to type it again:" file_again = raw_input("> ") txt_again = open(file_again) print txt_again.read() txt.close() #How do I use this .c...
true
cf27a6755dde266d83965d3bf01f2c9e8ef238cc
nalisharathod01/Python-Practice
/Python Programming/Integers.py
833
4.28125
4
#intergers integerNumber = 1 intNum = 2 floatNumbers = 1.0 secondFloat = -229.0 print(integerNumber) print(intNum) print(floatNumbers) #find types of the strings string = "hello" print(type(string)) print(type(secondFloat)) #only multiplication can be done with integers and string #integers operations #with divisio...
true
c0a2c9e9293a663314aca23381c1499ff53947ae
nalisharathod01/Python-Practice
/Python Programming/ifStatements.py
1,007
4.21875
4
#if condition: #doApproritateThing #elif differentCondition: #else of #doMoreStuff #elif condition3: # morestuff #else: #doBaseCase/FallBack number = 6 if number == 7: print ("this number is 7") elif type(number) == type(7): print("same Type") elif number ==6: ...
true
14fdb7bfed2aaeb14425d81d9c5273d2e08ce3d3
adriaanbd/data-structures-and-algorithms
/Python/data-structures/linked-lists/is_circular.py
1,185
4.28125
4
from singly_linked_list import LinkedList def is_circular(linked_list: LinkedList) -> bool: """ Determine wether the Linked List is circular or not Args: linked_list(obj): Linked List to be checked Returns: bool: Return True if the linked list is circular, return False otherwise """...
true
6e3b2f1686fd54223fe0474b6e250c6d2cd642b1
brandonkwleong/coding-practice
/sorting/quick-sort.py
2,701
4.3125
4
#/opt/bin/python """ QUICK SORT This script implements the quicksort algorithm. Quicksort requires the 'partition' method, which is described below. (Merge sort requires the 'merge' method). Time Complexity: O(n * log(n)) Worst case: O(n^2), depending on how the pivots are chosen Note that in the gene...
true
6308212919ba70665bb36456607cbaf77b90e49a
aah/project-euler
/python/e002.py
1,410
4.125
4
#!/usr/bin/env python3 """Even Fibonacci Numbers Project Euler, Problem 2 http://projecteuler.net/problem=2 Each new term in the Fibonacci sequence is generated by adding the previous two terms. By starting with 1 and 2, the first 10 terms will be: 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ... By considering the terms in t...
true
cd8c6c803c3d603ae3fd5363308bf6a85a8a9701
isrt09/Python_Problem_Solving_Exercises
/Python with 70+ Problems/Dictionary.py
1,394
4.125
4
# Dictionary Part 1(Do this exercise in computer) # Do the following 1.Create a dictionary which consist of Item(keys) and Quantity(values) of items in the shop. Items Quantity soap 10 bread 5 shampoo 8 2.Create another dictionary which c...
true
b4d5f1f31f567a1b5b6fa573c9af39767425ab80
willmartell/pyexercises
/100ex_28.py
228
4.125
4
"""define a function that can accept two strings as input and concatenate them and then print it in the console""" string1 = "hello" string2 = "world" def concat_str(s1,s2): return s1+s2 print concat_str(string1,string2)
true
e1149ba3d4f87b3c3969341602823a13b1ac0b93
Rajno1/PythonBasics
/variables/MultipleValuesToVariable.py
543
4.28125
4
""" Python allows you to assign many values to multiple variables we can assign one value to multiple variables if you have a collection of values in a list, Python allows you to extract the values to variables- this called unpacking """ # assigning many values to multiple variables x,y,z="Raju",2,True print(x+" is",ty...
true
9ff4aee52115a0b8582c751ef58607da41b9b404
DipendraDLS/Python_Basic
/18. Working_with_text_file/reading_and_writing.py
455
4.125
4
# # Example 1 : reading from one file and writing to another file with open("file1.txt") as f: content = f.read() with open("file2.txt", 'w') as f: f.write(content) # # Example 2 : Reading from old file and writing to the new file and finally deleting the old file import os oldname = "file1.txt" newname = "...
true
c6d31b991fdbf9b991517d72bda2055cd39d96c2
DipendraDLS/Python_Basic
/05. List/accessing_list.py
307
4.3125
4
# Accessing value of list a = [1, 2, 4, 56, 6] # Example 1: # Access using index using a[0], a[1], a[2] print(a[2]) # Assigning Values ( i.e change the value of list using) a[0] = 10 print(a) a_list = [1,2,3] a_list[1] = 4 print(a) #list repeatation list4 = [1, 2] list5 = list4 * 3 print(list5)
true
012797ebeff24d2a2453e2296cfc0d239b8e057c
DipendraDLS/Python_Basic
/13. Lambda_Function/lambda_function_with_map.py
785
4.40625
4
# The map() function in Python takes in a function and a list. # The function is called with all the items in the list and a new list is returned which contains items returned by that function for each item. # Example 1 : program to double each item in the list using map() function. my_list = [1, 5, 4, 6, 8, 11, 3, 1...
true
a74d594c5cc9d009acad884b4dc313b08acead88
DipendraDLS/Python_Basic
/05. List/list_creation.py
770
4.375
4
# In python, list size can always be dynamic (i.e list ko size badna or ghatna sakcha).. no need to be worry of creating dynamic size like in C & C++ # lists are mutable (meaning that, values or items in the list can be changed or updated) # Syntax 1 : for Creating empty list in python first_list = [] print('Type of f...
true
13abef90c48da1dadfb1e1556edb9abfa3309a77
Datbois1/Dat_bois1
/Number 3.py
217
4.1875
4
Number=input("Enter Number") Number=int(Number) if Number > 10: print(str(Number)+" is greater than 10") elif Number < 10: print(str(Number)+" is less than 10") else: print(str(Number)+" is equal to ten")
true
3c99e735729ff6283b0aec80b4ae3bd47e41fa5f
SACHSTech/ics2o-livehack1-practice-laaurenmm
/windchill.py
717
4.1875
4
""" Name: windchill.py Purpose: This program allows the user to input a the degree in celsius and windspeed to calculate the Author: Mak.L Created: 08/02/2021 """ print ("******Windchill******") print("") #User will input temperature and wind speed temp_c = float(input("Enter the temperature in cel...
true
ad8927ec17caa8739aeb326c8965aa7641faf4d0
renatronic/data_structures_and_algorithms
/finders.py
2,101
4.25
4
from node import Node from linked_list import LinkedList ''' The grace of the both solutions is that both have O(n) time complexity, and O(1) space complexity. We always use two variables to represent two pointers no matter what size the linked list is). ''' # returns the nth to last element def nth_last_node(linke...
true
00b44f0765a7ae38024e85efdcd9d17982f2ca33
Ezeaobinna/algorithms-1
/Pending/dijkstra.py
1,042
4.15625
4
#!/usr/bin/python # Date: 2018-01-27 # # Description: # Dijkstra's algo can be used to find shortest path from a source to destination # in a graph. Graph can have cycles but negative edges are not allowed to use # dijkstra algo. # # Implementation: # - Initialze graph such that distance to source is set to 0 and othe...
true
1248e8d20a1cc116f046311c10e44a443572a871
mikemontone/Python
/make_album2.py
747
4.15625
4
#!/opt/bb/bin/python3.6 def make_album(artist_name,album_title, tracks=''): """ Builds a dictionary describing a music album. """ album = { 'artist' : artist_name , 'album' : album_title} if tracks: album['tracks'] = tracks return album #album1 = make_album('beach boys','pet sounds', tracks=14) #alb...
true
c3246f6b7419d2eef546fe82ae3809fda7201175
mikemontone/Python
/Chapter08/sandwich_order.py
655
4.125
4
toppings = [] #prompt = "\nPlease tell me what toppings you want on your sandwich: " #prompt += "\n (Enter 'quit' when you are finished adding toppings.) " #while True: # topping = input(prompt) # if topping == 'quit': # break # else: # print("Adding " + topping + " to your sandiwch.") def make_sa...
true
e113cbc67495858f87609e4751af24b7c93f4540
sandeep2823/projects
/Python/derek banas learning/05_Functions/05_calculate_area.py
824
4.15625
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Thu Aug 9 23:26:25 2018 @author: sandeepsingh """ import math def get_area(shape): shape = shape.lower() if shape == "circle": circle_area() elif shape == "rectangle": rectangle_area() else: ...
true
d893029766441bdfbf03370f60c8a7ed227dc9e7
sandeep2823/projects
/Python/derek banas learning/01_simple_code/02_convert_miles_to_kilometers.py
396
4.28125
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Thu Aug 2 22:33:09 2018 @author: sandeepsingh """ # Problem : Receive miles and convert to kilometera miles = input("Please enter the miles : ") # Convert miles to kilometer and store into kilometer kilometer = int(miles) * 1.60934 # Print the kilomet...
true
67c8802e4e5e7d7df8f240bd10165d10b6d26b77
CAM603/Python-JavaScript-CS-Masterclass
/Challenges/bst_max_depth.py
1,207
4.125
4
# Given a binary tree, find its maximum depth. The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node. class TreeNode(object): def __init__(self, val=0, left=None, right=None): self.val = val self.left = left self.right = right d...
true
a877f7d37cac84d65a89bcd2a700785fa30ccdda
RephenSoss/ToDoList
/todolist.py
777
4.25
4
def show_help(): print ('What should we pick up at the store?') print (""" Enter "DONE" to stop adding items. Enter "HELP" to stop adding items. Enter "SHOW" to stop adding items. """) show_help() def add_to_list(new_item): shop_list.append(new_item) print("Added {}. List now had {} items.".format(new_item,...
true
3eddd6fc6998c0d7bd0bfdd125693754a11bb7af
rehanhkhan/Assignment2
/Exercise_4-10.py
914
4.75
5
'''*********************************************************************************************** 4-10. Slices: Using one of the programs you wrote in this chapter, add several lines to the end of the program that do the following: • Print the message, The first three items in the list are:. Then use a slice to prin...
true
60dbf192f402385cdefb861e0b548aa5d65000d0
chendddong/Jiuzhang-Ladder
/5. Kth Largest Element.py
1,310
4.25
4
''' Find K-th largest element in an array. You can swap elements in the array Example Example 1: Input: n = 1, nums = [1,3,4,2] Output: 4 Example 2: Input: n = 3, nums = [9,3,2,4,8] Output: 4 Challenge O(n) time, O(1) extra memory. ''' # TAG:[Quick Sort, Quick Select, Two Pointers] class Solution: """ @par...
true
b4dd714c784a2ddc28a06849e7d2bd089d8bf6c3
JayneJacobs/PythonHomeGrown
/decisionsComparison/defProceduresBasic (1).py
1,367
4.125
4
# Define a procedure, is_friend, that takes # a string as its input, and returns a # Boolean indicating if the input string # is the name of a friend. Assume # I am friends with everyone whose name # starts with either 'D' or 'N', but no one # else. You do not need to check for # lower case 'd' or 'n' def isDNfriend(pe...
true
0ae82e92caf97c01068f029c06cb12f3cf4453b6
cs-fullstack-2019-spring/python-review-loops-cw-cgarciapieto
/pythonreviewclasswork.py
1,119
4.21875
4
def main(): # exercise1 # Python program that prints all the numbers from 0 to 6 except 3 and 6. # with an expected output of 1245 # def exercise1(): # number = 0 # # # for number in range(6): # number = number + 1 # # if number == 3: # # continue # continue here # # elif number =...
true
045d40c58121721a843693ed35bb54a4600588b4
Jlobblet/px277
/Week 2/Excercises/second_col_second_row.py
217
4.3125
4
"""Consider the 2D array ((1, 2), (3, 4)). Extract and print the second column values, then print the second row values.""" import numpy as np array = np.array(((1, 2), (3, 4))) print(array[:, 1]) print(array[1, :])
true
1cd060f2e6d05ec6e84fd6d41b456d9d7d0e9f64
Jlobblet/px277
/Week 2/Assessment/04.py
525
4.21875
4
"""Write a function called "increasing(data)" that prints True if the input array is increasing or False otherwise. Hint: np.diff() returns the difference between consecutive elements of a sequence. """ import numpy as np def increasing(data): """Take an array and return whether the array is strictly increasing o...
true
89680b2abb72179539bb70b06c3393ae7ac7ae25
agnirudrasil/12-practical
/src/question_14/main.py
1,368
4.21875
4
""" Write a python program to create CSV file and store empno,name,salary in it. Take empno from the user and display the corresponding name, salary from the file. Display an appropriate message if the empno is not found. """ import csv def create_csv(): with open("employee.csv", "w", newline='') as f: cw...
true
65a3e5322a7bcfc2c45d4a2bc2fedf6dd52d8c93
erdembozdg/coding
/python/python-interview/algorithms/sorting/insertion_sort.py
461
4.28125
4
def insertion_sort(arr): # For every index in array for i in range(1,len(arr)): # Set current values and position currentvalue = arr[i] position = i while position>0 and arr[position-1]>currentvalue: arr[position]=arr[position-1] ...
true
5aab761eaaf04322966c6c74c0fcad037477c9bc
uzairaj/Python_Programming
/Python_Tips_Tricks.py
807
4.21875
4
#Create a single string from all the elements in list a = ["My", "name", "is", "Uzair"] print(" ".join(a)) #Return Multiple Values From Functions def x(): return 1, 2, 3, 4 a, b, c, d = x() print(a, b, c, d) #Find The Most Frequent Value In A List test = [1, 2, 3, 4, 2, 2, 3, 1, 4, 4, 4] p...
true
14bca08dd4cd2d68fa62269829ba76f92db83d29
george-marcus/route-planner
/student_code.py
2,436
4.25
4
import math from queue import PriorityQueue # Used Concepts found on this link # https://www.geeksforgeeks.org/a-search-algorithm/ def shortest_path(map_grid, start_node, goal): initial_distance = 0 road_cost = {start_node: initial_distance} came_from = {start_node: None} # we use a priority queue...
true
bf967bb5919d2c0d1e4698b1439c213ed2ef7d89
Nasir1004/-practical_python-with-daheer
/if statement.py
202
4.125
4
name = input('enter your name') if name is ("sharu"): print("sharu you are a good freind") elif name is ("abbas"): print('you are one of the best ') else: print('you are very lucky to be my freind')
true
a9b70899b6b89662582efd58b8f1c6f7ab38b60b
Libraryman85/learn_python
/beal_katas/2_1_18.py
1,322
4.25
4
# strings can be in single or double quotes # str = 'test' # str2 = "test" # string interpolation {} # bool # boolean is true/false # bool = True # bool_false = False # int # int = 1 # int = -1 # floats are decimals # float = 1.0 # float_negative = -1.0 # casting # output = '1' + 1 # to convert string to int # i...
true
662df803670dd10231be1ef40c2dccbacddb9ecc
mediassumani/TechInterviewPrep
/InterviewPrepKit/Trees/height_balanced_tree.py
1,209
4.15625
4
''' 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. ''' def getDepth(self, node): left_depth = 0 right_depth = 0 ...
true
b7c13aca4e20c253e1e792d690226138292172ee
Fusilladin/ListOverlap
/ListOverlap.py
956
4.1875
4
# LIST OVERLAP a = [1, 2, 3, 5, 8, 13, 15, 21, 27, 28, 29, 30, 34, 44, 55, 89] b = [1, 2, 3, 4, 5, 6, 7, 9, 10, 11, 12, 13, 15, 27, 43, 44, 45] c = [] d = [] for elem in a: if (elem in a) and (elem in b): c.append(elem) continue elif (elem in a): d.append(elem) else:...
true
1021858fc455addb151eee1cf4a11aedcbc787a5
claggierk/video_rental
/Customer.py
2,075
4.25
4
phone_number_length = 12 dob_length = 3 class Customer(object): """ a Customer to a DVD rental facility """ def __init__(self, f_name, l_name, phone, dob, email): """constructor; initialize first and last names, phone #, date of birth, and email""" self.first_name = f_name self....
true
89ce032171309536dae16bc55a3c49fae721c86a
sanjeevseera/Hackerrank-challenges
/strings/Love-Letter_Mystery.py
1,121
4.125
4
""" James found a love letter that his friend Harry has written to his girlfriend. James is a prankster, so he decides to meddle with the letter. He changes all the words in the letter into palindromes. To do this, he follows two rules: He can only reduce the value of a letter by , i.e. he can change d to c, but he c...
true
29a744f875d73c04464a5d5b4c357fe1d3bb28d0
sanjeevseera/Hackerrank-challenges
/30DaysOfCode-challenges/Day17_More_Exceptions.py
1,039
4.3125
4
""" Yesterday's challenge taught you to manage exceptional situations by using try and catch blocks. In today's challenge, you're going to practice throwing and propagating an exception. Check out the Tutorial tab for learning materials and an instructional video! Task Write a Calculator class with a single method:...
true
a28639b300eed5497da619b9e89bc4da7c9f9bbb
nitish24n/Topgear-Python-L1-set1
/15th.py
693
4.40625
4
"""Create a list of 5 names and check given name exist in the List.         a) Use membership operator (IN) to check the presence of an element.         b) Perform above task without using membership operator.         c) Print the elements of the list in reverse direction.""" names = ["hari","krishna","pawan","karan",...
true
b6c7db962cd190f5e9e5515e6c9a1b188cce376f
nitish24n/Topgear-Python-L1-set1
/18th.py
630
4.3125
4
""" Using loop structures print numbers from 1 to 100.  and using the same loop print numbers from 100 to 1 (reverse printing) a) By using For loop b) By using while loop c) Let mystring ="Hello world" print each character of mystring in to separate line using appropriate loop """ #for-loop 1 to 100 for i in range(1,...
true
786bc7bddf5415c7c40c964bba2e8295d1066252
nitish24n/Topgear-Python-L1-set1
/13th.py
810
4.125
4
"""Write a program to find the biggest of 4 numbers.    a) Read 4 numbers from user using Input statement.    b) extend the above program to find the biggest of 5 numbers. (PS: Use IF and IF & Else, If and ELIf, and Nested IF)""" first,second,third,forth = input().split() first,second,third,forth = int(first),int(seco...
true
661af70ac0304040e409c3c122327ffb9d84d648
CHINASH29/hello-world
/duplicate.py
261
4.125
4
# Checking Duplicates in list my_list = ['a', 'a', 'b', 'c', 'd', 'd', 'e', 'e', 'e'] dupes = [] for values in my_list: if my_list.count(values) > 1: if values not in dupes: dupes.append(values) print('Duplicate values are :-', dupes)
true
3335a9c63f02bdc696f318a8c8b81ce966be3bc9
code-of-the-future/Python-Beginner-Tutorials-YouTube-
/Python_Types_and_Logical_Operators.py
626
4.21875
4
# Python Types # Basic types in python! print(type("Hello, world!")) print(type(13)) print(type(4.72)) print(type(True)) # Moving to integers print(4.72, int(4.72)) # Python rounds down! print(4.05, int(4.05)) # Rounding up! print(4.72, int(4.72), int(round(4.72))) # Moving strings to integers print("12345", int("...
true
effe3f32bbd6abd042f25a407bf32226630ab2e7
EECS388-F19/lab-jcosens
/students.py
274
4.125
4
students = ["Daniel", "Kanu", "Olivia"] students.sort() print(students) first_name = students[0] first_name = first_name[:-1] print(first_name) length = 0 longest = ""; for x in students: if len(x) > length: longest = x; length = len(x) print(longest)
true
9b143c613b4a16b0d7653cc766dfa9d0376e46c3
aarreza/hyperskill
/CoffeeMachine/coffee_machine_v1.py
1,043
4.40625
4
#!/usr/bin/env python3 # Amount of water, milk, and coffee beans required for a cup of coffee WATER, MILK, COFFEE = (200, 50, 15) # Enter the available amount of water, milk, and coffee beans water_check = int(input("Write how many ml of water the coffee machine has: ")) milk_check = int(input("Write how many ml of mi...
true
bc16f961006f820799356fb52d92594137ccf9e9
limingwu8/ML
/NLP/demo02.py
440
4.15625
4
# test stopwords # filter words which included in stopwords from nltk.corpus import stopwords from nltk.tokenize import word_tokenize example_sentence = "This is an example showing off stop word filtration." stop_words = set(stopwords.words("english")) print(stop_words) words = word_tokenize(example_sentence) filtere...
true
426474b3f01c3ca40d212b7fcb4148908bde31bb
thegreedychoice/TheMathofIntelligence
/Gradient Descent - Linear Regression/gradient_descent.py
2,621
4.15625
4
import numpy as np import csv import matplotlib.pyplot as plt """ The dataset represents distance cycled vs calories burned. We'll create the line of best fit (linear regression) via gradient descent to predict the mapping. """ #Get Dataset def get_data(file_name): """ This method gets the data points from the csv...
true
155c460efdfd78af00513dbb1234b069dbbe93fe
Tomology/python-algorithms-and-data-structures
/Algorithms/sorting_algorithms/quicksort.py
1,181
4.1875
4
""" QUICK SORT Time Complexity Best Case O(n log n) Worst Case O(n^2) Space Complexity O(log n) """ def quickSort(arr, left=0, right=None): if right == None: right = len(arr) - 1 if left < right: pivotIndex = pivot(arr, left, right) # left quickSort(arr, left, ...
true
282b920f62219c096f5e4123f3222efb1d3f9e08
iApotoxin/Python-Programming
/14_whileLoop1.py
353
4.125
4
countNum1 = 0 while (countNum1 < 10): print ('The countNum1 is:', countNum1) countNum1 = countNum1 + 1 #------------------------------------------------- countNum2 = 0 while countNum2 < 10: print(countNum2, "True: countNum2 is less than 10") countNum2 = countNum2 + 1 else: print(countN...
true
1c64a0a40c89fc22509439b01afc5aa37751789f
shreeya917/sem
/python_mine/shreeeya/PycharmProjects/-python_assignment_dec15/unpack.py
246
4.15625
4
# Q5. Code a Function that simply returns ("Hello", 45, 23.3)and call this function and unpack the returned values and print it. def f(): return ["Hello", 45, 23.3] result = list(f()) print(result) #x,y,z=unpack()
true
c9f958bdf9318e66ae10596c08c2ea5210020d32
shreeya917/sem
/python_assignment_dec22/alphabetically_sort.py
363
4.34375
4
#Write a program that accepts a comma separated sequence of words as input # and prints the words in a comma-separated sequence after sorting them alphabetically. sequence=str(input("Enter the sequence of word: ")) words=sequence.split(',') print("The unsorted input is: \n",sequence) words.sort() print("The sor...
true
e0b130df14c6948bd4cbf1ae47b9337caf343090
raprocks/hackerrank-practice
/Python/leapcheck.py
497
4.21875
4
def is_leap(year): """TODO: Docstring for is_leap. :year: TODO :returns: TODO The year can be evenly divided by 4, is a leap year, unless: The year can be evenly divided by 100, it is NOT a leap year, unless: The year is also evenly divisible by 400. Then it is a leap year. """ leap = False yea...
true
6a522630136ef49df119a198addee80a7a4cd193
raprocks/hackerrank-practice
/FAANG/GreetMe.py
395
4.15625
4
name = input() # take only input as this is string time = int(input()) # take input and convert it to integer if time >= 0 and time <= 11: # simple if else statements based on problem statement print("Good Morning " + name + " sir.") elif time >= 12 and time <= 15: print("Good Afternoon " + name + " sir.") el...
true
21d46ef79e63a6d3ac7de06bb5d1a88b9434518c
PrhldK/NLTKTraining
/exercises/module2_2b_stopwords_NLTK.py
766
4.3125
4
# Module 2: Text Analysis with NLTK # Stop Words with NLTK # Author: Dr. Alfred from nltk.tokenize import word_tokenize from nltk.corpus import stopwords # print(stopwords.words('english')[0:500:25]) stop_words = set(stopwords.words("english")) text = """ Dostoevsky was the son of a doctor. His parents were very h...
true
9fbb5c647713f726f2435ccfaff604c43a50d325
Kamayo-Spencer/Assignments
/W1_A1_Q2_Spencer.py
1,046
4.4375
4
# Question. # In plain English and with the Given-required-algorithm table, write a guessing game # where the user should guess a secret number. After every guess, the problem tells the user whether their number # was too large or small. In the end, the number of tries needed should be printed # Given ifomation # Use...
true
de920ee9aea6686050e08e9abb6d620f954d57fb
skitoo/mysql-workbench-exporter
/mworkbenchexporter/utils.py
513
4.21875
4
def camel_case(input_string): return "".join([word.capitalize() for word in input_string.split('_')]) def lower_camel_case(input_string): first = True result = "" for word in input_string.split('_'): if first: first = False result += word.lower() else: ...
true
1c511220f1083194e354e2d9f73199d63d812128
Julzmbugua/bootcamp
/students.py
1,212
4.1875
4
student = { 'name': 'An Other', 'langs': ['Python', 'JavaScript', 'PHP'], 'age': 23 } student2 = { 'name': 'No Name', 'langs': ['Python', 'Java', 'PHP'], 'age': 24 } # Task 1: # Create a function add_student that takes a student dictionary as a parameter, # and adds the student in a list of st...
true
da086a88365d28d2b8172689780b0ffaf6fa17fc
agus2207/Cursos
/Python for Everybody/Extracting_Data.py
916
4.15625
4
#n this assignment you will write a Python program somewhat similar to https://py4e.com/code3/geoxml.py. #The program will prompt for a URL, read the XML data from that URL using urllib and then parse and #extract the comment counts from the XML data, compute the sum of the numbers in the file and enter the sum. ...
true
1af6b418d30b50f291803394b0d53006d349af09
thelmuth/cs110-spring-2020
/Class22/turtle_drawing.py
958
4.375
4
import turtle def main(): michelangelo = turtle.Turtle() turtle_drawing(michelangelo) def turtle_drawing(t): """ Write a function that takes a turtle, and then asks the user what direction the turtle should move using the WASD keyboard keys. The turtle should move up 30 pixels if the user enter...
true
d45d46386733cf5e97f8ac555f82e66e5111fde3
thelmuth/cs110-spring-2020
/Class04/year.py
533
4.375
4
""" Author: Class Description: This program calculates the year and number of days past Jan. 1 given some number of days. """ DAYS_IN_YEAR = 365 START_YEAR = 2020 def main(): days = int(input("Enter the number of days that have passed since Jan. 1 2020: ")) years = days // DAYS_IN_YEAR curre...
true
32d18a1cba9d4bbcd9d95e2281e5a834e678a7c2
thelmuth/cs110-spring-2020
/Class25/cards.py
2,288
4.21875
4
""" File: cards.py Author: Darren Strash + Class! Make playing card class for blackjack. """ import random #Rank RANKS = ["A", 2, 3, 4, 5, 6, 7, 8, 9, 10, "J", "Q", "K"] #Suit SUITS = ["D", "C", "S", "H"] class PlayingCard: """Represents a single playing card from a standard deck.""" def __init__(self, rank...
true
252b50d29c748b3ca9d95c359a43bed3c7c5fe3b
thelmuth/cs110-spring-2020
/Class16/grids.py
1,653
4.28125
4
def main(): # Create a grid of a map for a robot in a park map = [["grass", "puddle", "mud"], ["tree", "grass", "grass"], ["bush", "robot", "tree"], ["bush", "mud", "grass"]] # print(map) # print(map[2]) # print(map[2][3]) print_grid(map) ...
true
9dca3985fd5ee606d8b6fd1c8b53bd2fcf17f1f1
rand0musername/psiml2017-homework
/2 Basic file ops/basic_file_ops.py
733
4.1875
4
import re import os # regex that matches valid text files FILE_PATTERN = re.compile(r"^PSIML_(\d{3}).txt$") def count_files(root): """Return the number of files under root that satisfy the condition.""" num_files = 0 for dirpath, _, files in os.walk(root): for file in files: fmatch = F...
true
da1721a0670435a000e319adf776fd5770b4af08
sidherun/lpthw
/ex_15a.py
950
4.25
4
# This line imports argument variable module from the sys library from sys import argv # This line identifies the arguments required when the script runs script, filename = argv # This line initiates a variable, 'txt' and assigns the open function on the file we created 'ex15_samples.txt', which means the contents of...
true
bc19e0f1be946edcdc032719be76c1c888519555
simonlc/Project-Euler-in-Python
/euler_0007
699
4.25
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 10 001st prime number? """ #http://www.daniweb.com/software-development/python/code/216880/check-if-a-number-is-a-prime-number-python def isprime(n): "Check if integer n is a p...
true
b064a9e9915c6a1b13993bf688dba5c09cd76e3c
richardmoonw/CRS_Bioinformatics
/Week_01/exercise04.py
985
4.25
4
# The careful bioinformatician should check if there are other short regions in the genome # exhibiting multiple occurrences of a n-mer and its complement. After all, maybe therse strings # occur as repeats throughout the entire genome, rather than just in the ori region. The goal is # to create a program to find all ...
true
4229331e91ef430e66bc1b0638e942680a54edf0
EswarAleti/Chegg
/Python/Curve_GPA/GPA.py
1,156
4.28125
4
#importing random to generate random numbers import random #declare a list called GPA GPA=[] #These indexes denotes the random number between startFrom to endAt i.e 0 to 40 startFrom=0 endAt=40 #This function generate GPA list using random() def generateRandomGPA(): #For 20 students for i in range(20): ...
true
68dd02c6e73c8461c7af2eb5c8ed9875f5b33ff9
AishaRiley/calculate-volume
/volumepyramid.py
404
4.125
4
##Write program to calculate volume of pyramid ##Have user give the base and the height of the pyramid def main(): print("Volume:",pyramidVolume(5, 9)) print("Expected: 300") print("Volume:",pyramidVolume(9, 10)) print("Expected: 0") def pyramidVolume(baseLength, height): baseArea = base...
true
a6691db3611b04de1322f6ecf30b87a6fc83d708
Yobretaw/AlgorithmProblems
/Py_leetcode/007_reverseInteger.py
1,122
4.1875
4
import sys import math """ Reverse digits of an integer. Example1: x = 123, return 321 Example2: x = -123, return -321 - If the integer's last digit is 0, what should the output be? ie, cases such as 10, 100. - Did you notice that the reversed integer might overflow? Assume the input is a 32...
true
1373f3fbe475186d04a6f9ebdf7e001b1a3eb2ab
Yobretaw/AlgorithmProblems
/Py_leetcode/162_findPeakElement.py
1,039
4.25
4
import sys import math """ A peak element is an element that is greater than its neighbors. Given an input array where num[i] != num[i+1], find a peak element and return its index. The array may contain multiple peaks, in that case return the index to any one of the peaks is fine. You may imagine th...
true
9df0e169aa2b24b89699b821127ab38962e87f98
Yobretaw/AlgorithmProblems
/EPI/Python/BinaryTree/10_1_testIfBalanced.py
1,575
4.15625
4
import sys import os import math import imp Node = imp.load_source('Node', '../BST/BST.py').Node bst_print = imp.load_source('Node', '../BST/BST.py').bst_print """ ============================================================================================ A binary tree is said to be balanced if for each node...
true
8462a52099b7ff85c921367ea3b26449da940299
Yobretaw/AlgorithmProblems
/EPI/Python/Array/6_13_permuteElementsOfArray.py
1,386
4.3125
4
import sys import os import re import math import random """ ============================================================================================ A permutation of an array A can be specified by an array P, where P[i] represents the location of the element at i in the permutation. A permutation can ...
true
b75f5219b092e837b2f4dfd19691c35c73b21f75
Yobretaw/AlgorithmProblems
/Py_leetcode/224_basic_calculator.py
1,805
4.34375
4
import re """ Implement a basic calculator to evaluate a simple expression string. The expression string may contain open ( and closing parentheses ), the plus + or minus sign -, non-negative integers and empty spaces. You may assume that the given expression is always valid. Some examples: ...
true
0119a76668ae12ebb589380e105137148adbc4cf
Yobretaw/AlgorithmProblems
/EPI/Python/Strings/7_4_reverseAllWordsInSentence.py
748
4.15625
4
import sys import os import re import math """ ============================================================================================ Implement a function for reversing the words in a string s. Assume s is stored in a array of characters ===========================================================...
true