blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
7650bcd47d6f32188fca7b77d1dbfd7b9202cf37
ankushjassal01/Python-Learning
/B.Input and output files/4.Appending data on files.py
1,022
4.625
5
# append mode # we can write data to a file in append mode ('a') too # with append mode we can write the data to the end of the file . it do not overwrite the data in a file like write # rather then that it write the data and let previous data in the file # append can also create the file if it not present in file dire...
true
e7bf9509a8d0eb7869166293f985fd43215eed53
ankushjassal01/Python-Learning
/C.functions & Methods/10.Parameter types.py
1,525
4.28125
4
# params # keyword or positional params # (var, name=var) # var-positional # (*args) # var-keyword # (**kwargs) # keyword only: that can defined as keyword or *, it must be call with its defined keyword # like if k or p then call it with k or p # positional only :: that can be supplied only by position # VAR-POSITIONA...
true
f0b1a8a8ab982004a96e1019a5439a09a898a3cd
ankushjassal01/Python-Learning
/C.functions & Methods/2.Return & without Return.py
2,209
4.125
4
# %% returns values def years(prompt): while True: temp = input(prompt) if temp.isnumeric() and len(temp) == 4: return int(temp) else: # we can remove else and write code like line 35 print('-----that is not a year.. type again-----') # print('-----that is no...
true
30ca9eafa4f946755018b262d80a9b411f6f0c99
dayananda30/Crack_Interviews
/Datastructure_Algorithms/LinkedList/SingleLinkedList/SinglyLinkedList-1.py
1,823
4.40625
4
#URL : https://www.youtube.com/watch?v=RhCGA4jlPmQ&list=PLzjoZGHG3J8vdUH75YPqmO7lbQl_M-xXo&index=2 # Create Nodes # Create LinkedLists # Add Nodes to LinkedLists # Print Nodes """ Creating Nodes , LinkedLists and adding the Nodes to the Linked at the END. and displaying all the Node's Data """ class Node: def...
true
91dd4b374f49306c4054105aa9ab6c9763b13d9e
dayananda30/Crack_Interviews
/Datastructure_Algorithms/LinkedList/SingleLinkedList/SinglyLinkedList-4.py
1,454
4.15625
4
class Node: def __init__(self,data): self.data = data self.next = None class LinkedList: def __init__(self): self.head = None def insertAtBeginning(self,newNode): if self.head is None: self.head = newNode def insertAtEnd(self,newNode): cur = self....
true
7831daa9c144f7adb41db02a0c55627b9de70d25
dayananda30/Crack_Interviews
/Comprehensive Python Cheatsheet/File_Parser/XML/Parsing-4.py
1,433
4.34375
4
""" Modifying an XML file ElementTree.write() provides a simple way to build XML documents and write them to files. Once created, an Element object may be manipulated by directly changing its fileds(such as Element.text), adding and modifying attributes(Element.set() method) as well as adding new children (eg: Elemen...
true
9199b86100ff14ef01b3502ec8aeb89af8698e47
nishant184/Python-Core-and-advanced
/inputoutput.py
606
4.21875
4
name="nishant" marks=45.5 print("name is ",name,"marks are ",marks) #anothe way is print("Name is %s marks are %d"%(name,marks)) #another way is by placeholders #print("name is {},marks are{}",format(name,marks)) #Input function s=input() print(s) s1=input("Enter your name") print(s1) #Input function considers all the...
true
1af8a51efe1515821b3477723e5323f509f142aa
nishant184/Python-Core-and-advanced
/breakcontinue.py
703
4.21875
4
#Break is used to break the loop if the condition ia true lst=[3,1,2,5,6,2] for i in lst: if i==5: break print(i) #In the above for loop the loop stop executing after the value of is 5 #It will not print the elements after 5 #Continue #To print numbers from 1 to 20 but skip multiples of 3 x=0 while x<2...
true
c0f6550cdbe70d83a3bc1e686e34f55eabc2ceab
nishant184/Python-Core-and-advanced
/dictionary.py
418
4.375
4
#Dicitonary is denoted by curly braces and it has key and values d1={"nishant":22,"sumit":21} print(d1) #Items attribute will display all the elements in a dictionary print(d1.items()) #Keys attribute will display all the keys d2=d1.keys() for i in d2: print(i) #Values attribute will display all the values d3=...
true
fef05b423bd91fb9b790c7473645383ca7810f52
TheLukeRussell/6-1-number-guesser-game
/b.py
1,009
4.15625
4
print("\t\t Think you can outsmart a computer in 2020?") print("\n\t The computer should have the upperhand...") import random numberOfGuesses = 0 name = input('\n What is your name? ') number = input('\n Hello ' + name + '!' + ' What number would you like to select? ') print('\n So ' + name + ',' + ' you chose the ...
true
10304dddaa84a4305a418091fd6d02781d511261
visajkapadia/data-structures-python
/SinglyLinkedList/reverse_iterative.py
695
4.25
4
def reverse_iterative(self): # 0(n) if self.head is None: # if 0 elements return if self.head.next is None: # if single element return if self.head.next.next is None: # if two elements ptr = self.head.next ptr.next = self.head self.head.n...
true
2a3e59272afb26c611047c25d962bbb61f303b74
sshalu12/Turtle-Race
/main.py
1,057
4.15625
4
from turtle import Turtle, Screen import random screen = Screen() screen.setup(width=500, height=400) user_input = screen.textinput(title="Make Your Bet", prompt="Which turtle will win the race?\nColors: red, blue, yellow, green, purple\nEnter a color:") race_start = False turtle_list = [] x = -230 y = -80 color = ["...
true
633938a0de83d96f1da632697b1f6a6399f8ef2f
Chamillion1/Girls-Who-Code-Projects-
/Atom/Pythonfile2.py
254
4.21875
4
number = 3 tries = 0 guess = int(input("Guess a number")) for tries in range (0, 2): if number > guess: guess = int(input("Guess higher")) elif number < guess: guess = int(input("Guess lower")) print ("the correct number is 3")
true
479eb58bf59e1abcefbdc3f47d3b3f9a63d223d4
michaelrizzo2/python_certification
/while_loops.py
226
4.3125
4
#while something is true do something. x=1 while x<=10: x+=1#We need this to prevent an infinite loop. if x==6: continue#This will skip over 6 print(f"The value of x is {x}") else: print("Out of loop")
true
0532b742fe12455ba56408f5d124afa3679c9f3c
michaelrizzo2/python_certification
/Section_04/assignment_02.py
826
4.5
4
# Assignment 2 """ Create a method called pay_extra that accepts 2 parameters: working, and hour. This method will be used to decide whether an employee will receive extra pay or not. If an employee is working during the hrs of 8pm until 8am in the morning, that means they should be paid extra. In that situation t...
true
9b27e80a2a3e2762772a70f03e5046e15ef12485
pcmac77/fs-python-interview
/simple_transposition.py
676
4.5
4
#Simple transposition is a basic and simple cryptography #technique. We make 2 rows and put first a letter in the #Row 1, the second in the Row 2, third in Row 1 and so on #until the end. Then we put the text from Row 2 next to #the Row 1 text and thats it. #Complete the function that recieves a string and encrypt #it...
true
1b1f4aa51520ca3079fc33e023a52cc2f764cb8e
hayleylandsberg/Python-Orientation-Exercises
/lists/planets.py
1,478
4.75
5
# 1. Use append() to add Jupiter and Saturn at the end of the list. # 2. Use the extend() method to add another list of the last two planets in our solar system to the end of the list. # 3. Use insert() to add Earth, and Venus in the correct order. # 4. Use append() again to add Pluto to the end of the list. # 5. Now t...
true
57f49eb14dd0bba22ba4f9ea1f7c6aaab8abe158
hyonschu/learnpython
/gattaca.py
1,212
4.15625
4
""" Given a file in the following format: GATAGGAGTAGTGAGT GTAGTAGAGTATGATAGTGTA GATTAGATGATGATG GATATATAGATATATTAGAT GATAGATAGT GATTAAGATATGATAGTAG GATTAGATAGTAGTAGT GTATAGATAGTAGTAGTGATGA GTAGATGATGATAGTAGTAGT GAAGTAGTGATGAGTAG For every position in the string, find the breakdown (in percentage) for each symbol enc...
true
6cfadff80a9fec98062f721bb5c285278d7e2758
Neelavdeep/Incubyte
/Incubyte_Assignment.py
1,437
4.1875
4
import pandas as pd import sqlite3 def create_connection(db_file): """ create a database connection to the SQLite database specified by db_file :param db_file: database file :return: Connection object or None """ conn = None try: conn = sqlite3.connect(db_file) ...
true
d3e7d3e0069156a380ffe62c06bdbd1a147b28f6
ds-ga-1007/assignment7
/jub205/assignment7.py
1,008
4.1875
4
from interval.interval import interval, insert def startProgram(): '''Function runs the program to take list of intervals and then new interval each time from the user and inserts the new interval to the list of intervals and merges if overlapping or adjacent then returns the new list of intervals. Pro...
true
78729217896cd9043c4e073c5a3c8e38fe162a0b
suburban-daredevil/100DaysOfCode
/Day 4/search.py
1,000
4.125
4
# returns the row and column of the target element, if target is found # returns -1,-1 if target is not found def search(mat, target): # we keep decrementing the search space until the target is found # n represents the maximum column value n = len(mat[0]) # row takes the minimum row value row = ...
true
bf75a93a8dde161215dd4e88f9ae6cdf0cf9c24a
flannerychristopher/MIT_online_problem_sets
/6.0001/ps4/ps4a.py
2,100
4.28125
4
# Problem Set 4A # Name: <your name here> # Collaborators: # Time Spent: x:xx def get_permutations(s, i=0): ''' Enumerate all permutations of a given string sequence (string): an arbitrary string to permute. Assume that it is a non-empty string. You MUST use recursion for this part....
true
ef382b4a480d13f62cdd24f7d42be9ff2800f459
stephenmcnicholas/PythonExamples
/progs/CaesarCipherEnhanced.py
521
4.21875
4
# Caesar cipher. text = input("Enter your message: ") shift = int(input("How many characters do you want to shift? ")) cipher = '' for char in text: if not char.isalpha(): cipher += char continue if char.isupper(): code = ord(char) + shift if code > ord('Z'): ...
true
02efbb866401941fead9c61a79f29031f3736102
JanDitzen/python-boot-camp
/think-python/chapter-17/Time.py
2,905
4.5625
5
import datetime import copy class Time(object): """Represents the time of day.""" def __init__(self, hour=0, minute=0, second=0): """Initializes a Time object with the following attributes: hour: (int) minute: (int) second: (int) ...
true
f585ad505d895bba3754ccbf795a086a443c806d
JanDitzen/python-boot-camp
/think-python/chapter-17/Point.py
1,175
4.53125
5
import math class Point(object): """Represents a point in 2D space.""" # solution to exercise 2 def __init__(self, x=0.0, y=0.0): """Initializes a Point object with the following attributes: x: (float) x-coordinate of the point. y: (float) y-coordinate of the p...
true
6f46236c25eebe013fc54d5e1693989d41b63ccd
padawan66/Exploring-Numpy
/numpy_basics/numpy_basics.py
2,494
4.28125
4
import numpy as np # ndarray in numpy is an n dimensional array which contains homogenous element ( of same datatype). array = np.array([[2,3],[4,5]],np.int32) # This is a two dimensional array with two rows and two columns array = np.array([[7,5,4,3,5],[4,5,7,8,2],[1,4,3,5,6]]) # this is a two dimensional array wi...
true
8f717d1c8af82864b479f4c2e6f33ed8d27be203
MaryBeth8/Stand-alone-docs
/loops-max-num.py
272
4.375
4
"""This function named takes a list of numbers named nums as a parameter. It returns the largest number in nums. """ def max_num(nums): largest = nums[0] for num in nums: if largest < num: largest = num return largest print(max_num([50, -10, 0, 75, 20]))
true
b482a0038263c301267f33c355085a92053ac95f
MaryBeth8/Stand-alone-docs
/list-append-sum-last-two.py
363
4.3125
4
"""This function adds the last two elements of lst together and appends the result to lst. It does this process three times and then return lst. """ def append_sum(lst): new_lst = lst count = 3 while count != 0: last1 = new_lst[-1] last2 = new_lst[-2] new_lst.append(last1 + last2) count -= 1 r...
true
b2becc47b07aae17b58c49799e5f28d33da96fa2
AssafHMor/intro2cs-python
/intro2cs-python/ex10/PathScanner.py
2,534
4.4375
4
class PathIterator: """ An iterator which iterates over all the directories and files in a given path (note - in the path only, not in the full depth). There is no importance to the order of iteration. """ pass def path_iterator(path): """ Returns an iterator to the current path's file...
true
c7b82285e70a33d5f53242f1689e017b8acbb571
AssafHMor/intro2cs-python
/intro2cs-python/ex3/findSecondSmallest.py
1,125
4.15625
4
############################################################################### #FILE: findSecondSmallest.py #WRITER: Assaf_Mor + assafm04 + 036539096 #EXCERSICE: intro2cs ex3 2014-2015 #DESCRIPTION: #a program which calculates the second smallest value entered by the user ##############################################...
true
34ebb326eaa3445af03ac0f4fa0d5a3d0f910251
AssafHMor/intro2cs-python
/intro2cs-python/ex3/findLargest.py
898
4.4375
4
############################################################################### #FILE: findLargest.py #WRITER: Assaf_Mor + assafm04 + 036539096 #EXCERSICE: intro2cs ex3 2014-2015 #DESCRIPTION: #this code finds the largest number inserted by the user, while the user #restricts himself with the numbers he is able to ente...
true
a0df03fb0ec1e744a3b7f026a91f306a82e8aaf0
Billoncho/CircleSpiralInput
/CircleSpiralInput.py
1,123
4.65625
5
# CircleSpiralInput.py # Billy Ridgeway # Draws a colorful circle spiral with the number of sides input by the user. import turtle # Imports turtle graphics. t = turtle.Pen() # Creates a new turtle called t. t.speed(0) # Sets the pen's speed to fast. turtle.bgcolor("bla...
true
9f5e96b50c4df2ebbe3c32bbc8af04ee684c3470
hoalexander44/PreviousWorks
/unit_conversion.py
1,192
4.71875
5
#This is a unit converter # intro text that introduces the user what this program does and how to use it print('Welcome to the length conversion wizard') print('This program can convert between any of the following lengths.') print('inches\nfeet\nyards\nmiles\nleagues\ncentimeters\ndecimeters\nmeters\ndecameters\nhect...
true
cfda2ffcc392b008ad4c502d12e5ae49db3d78c4
jwmcgettigan/project-euler-solutions
/solutions/001/solution.py
229
4.15625
4
def multiple_of(num, multiple): return num % multiple == 0 def sum_of_multiples(limit): return sum(x for x in range(limit) if multiple_of(x, 3) or multiple_of(x, 5)) if __name__ == "__main__": print(sum_of_multiples(1000))
true
ec2ee99c8b762cd2ee2b6cb8ea9930396dc3f82d
stavernatalia95/Lesson-7.2-Assignment
/Lesson7.2Exercise #1.py
317
4.34375
4
# Create a program that will output everything in lowercase whatever the user will input. The program should run until the client enters the word “STOP”. user_input="" print("My hobbies are: ") while user_input !="STOP": user_input=input("What are your hobbies? ") print(user_input.lower())
true
1d36ba99a9b75829ac66cb44f17dfdb0cd1c9c31
sahiljethani/Sorting-Searching-Algorithms
/Algorithms in Python/bubble-sort.py
1,077
4.34375
4
# Sorting function def bubbleSort(arr): size = len(arr) for i in range(size - 1): for j in range (0, size - i - 1): if arr[j] > arr[j + 1]: arr[j], arr[j + 1] = arr[j + 1], arr[j] return arr n = int(input("Enter size : ")) arr = list() print("Enter elements : ") fo...
true
7831ef64119affc0e088997bc7afe8a7e8fc1c88
asimkaleem/LPTHW
/ex16.py
1,180
4.125
4
# -*- encoding: UTF-8 -*-# """ close — Closes the file. Like File->Save.. in your editor. read—Reads the contents of the fi le. You can assign the result to a variable. readline—Reads just one line of a text fi le. truncate—Empties the fi le. Watch out if you care about the fi le. write(stuff)—Writes stuff to the file...
true
8b3f5fcce6468ad5da112373ec295aed80f78f11
marmarmar/know_your_neighborhood
/ui.py
1,227
4.3125
4
def printing(content): """Prints output""" print(content) def get_input(inputs): """Takes input from user.""" return input(inputs) def display_menu(): """Prints menu""" print("""\nWhat would you like to do?: (1) List statistics (2) Display 3 citie...
true
7959ea358e20ae2a5c633a8f2ca0fa3fdfaef473
gokul22-rg/Interview_Task
/5th-Qus.py
740
4.28125
4
#5 - Write a function that will take a file name fname and a string s as input. It will return whether s occurs #inside the file. It's possible that the file is extremely large so it cannot be read into memory in one shot. def read_in_chunks(file_object, chunk_size=1024): while True: data = fil...
true
73141680e4c891d84e91da9c3b7b4161d62210f2
approximata/exam-python-2016-06-27
/first.py
586
4.21875
4
# Create a function that takes a list as a parameter, # and returns a new list with every second element from the orignal list # It should raise an error if the parameter is not a list # example: [1, 2, 3, 4, 5] should produce [2, 4] def get_secound_elements(raw_list): if type(raw_list) != list: raise Valu...
true
e59b229696de195d762a3f2e1e2d9f914fea3e4a
Adityavj19/WeekendAssignment1
/Question3.py
629
4.28125
4
#Question-3 Define a function that can accept two strings as input and print the string with maximum length in console. #If two strings have the same length, then the function should print al l strings line by line. string1 = raw_input("Enter first String:") string2 = raw_input("Enter second String:") def CompareStr...
true
1817a166473c58efc6fb4527c684653e0b69d05a
dinnguyen1495/daily-coding
/DC25.py
1,517
4.4375
4
# Daily Coding 25 # Implement regular expression matching with the following special characters: # . (period) which matches any single character # * (asterisk) which matches zero or more of the preceding element # That is, implement a function that takes in a string and a valid regular expression and returns whethe...
true
83c880d94fc21250fc36be1b2a3c0b29b7348a73
dinnguyen1495/daily-coding
/DC04.py
830
4.15625
4
# Daily Coding 0 # Given an array of integers, find the first missing positive integer in linear time and constant space. # In other words, find the lowest positive integer that does not exist in the array. The array can # contain duplicates and negative numbers # For example, the input [3, 4, -1, 1] should give 2. Th...
true
4fcf2c108cbafd67cfdb0b302e9a1ed0d888db98
Voloshiraptor/Python-Learning
/Lesson 3/PigLatin.py
806
4.34375
4
# Pig Latin is a language game, where you move the first letter of the word to the end and add "ay." # So "Python" becomes "ythonpay." To write a Pig Latin translator in Python, here are the steps we'll need to take: # Ask the user to input a word in English. # Make sure the user entered a valid word. # Convert the wo...
true
27f5d99f06351a228c7dba4cb605fd6adb4c8244
31337Anika/study
/Projects/Decision_maker_3.0.py
2,031
4.125
4
values = [] parameters = [] number_of_values = int(input("enter number of values:")) count_of_values = 0 number_of_parameters = int(input("enter number of parameters:")) count_of_parameters = 0 while count_of_values < number_of_values: value_name = input("enter value's name:") values.append(value_name) ...
true
4fcd2cab3d1a3c86f65bb09151d69eaffbccc224
v1ctorf/dsap
/1_python_primer/01_23_C.py
793
4.125
4
print(""" Give an example of a Python code fragment that attempts to write an element to a list based on an index that may be out of bounds. If that index is out of bounds, the program should catch the exception that results, and print the following error message: “Don’t try buffer overflow attacks in Python!” """) f...
true
012384a51364f19aaa8f7de325c07cd2c130cb41
omarakamal/Teaching-Python
/String Methods.py
336
4.3125
4
#string method # .strip() strips the spaces before and aftet the string # len() gives you the length of the characters in the string. its a function # .split() creates a list out of the string you give it #.upper makes the letters uppercase #lower (makes the letters lowercase) text = input("input something: ") print(t...
true
632783afebb9b0852e0455cb6cc07eaa74767845
narcisolobo/march_python_lectures
/lectures/w1d2_am_loops.py
1,749
4.25
4
# Python Stack - Day 2 # Loops (Deeper Dive) # for-in loops with range() function # for-in loops over lists with range() function # colors = ['blue', 'yellow', 'green', 'red'] # for i in range(len(colors)): # print(colors[i]) # # for-in loops over lists without range() function # for color in colors: # prin...
true
ee9e4c88b5f60319d7f4fa9e4533f34f25dd6753
akanimax/toxic-comment-identification-tensorflow
/Models/common/Pickler.py
1,597
4.1875
4
""" The module for helping the pickling process """ import pickle # for pickling the data import os # for path related operations # Simple function to perform pickling of the given object. This function may fail if the size of the object # exceeds # the max size of the pickling protocol used. Although this is high...
true
dfc36b59a8e9506676330c6a347ea3254257d44c
MelaniPrathibha/Guess-the-word
/Guess_the_word.py
1,668
4.25
4
#Guess the word import random def introduction(): global letter_count global turns #introduction print("\nLet's play Guess the Word") print(f"You have {turns} turns to guess the word!") #to show length of the word print(" _ "*letter_count) def main(): global turns global guesses ...
true
3f1015c131e1e8e27e31c54d94f84c95815cd973
frazentropy/DSP
/NumPyTuts/numpy_slicing.py
751
4.21875
4
import numpy as np a = np.arange(10) s = slice(2,7,2) print(a[s]) b = a[2:7:2] print(b) b = a[5] print(b) # slice items starting from index print(a[2:]) # slice items between indices print(a[2:5]) # slice items starting from index a = np.array([[1,2,3],[3,4,5],[4,5,6]]) print('Now we will slice the array from the ...
true
b82ea7cee9a20a5785b3df708ac8ba0e44f3819a
tryan19/375_cs
/chapter02/average_calculator.py
370
4.125
4
#average_calculator.py #test scores to test average #by: Tom Ryan def main(): score=input("whats the score?") total=0 scores=0 while score!="": print(score) total = total + eval(score) score = input("whats the next score?") scores = scores +1 averages = total / scor...
true
331d3d8a175fef3caa6325705c5ceb55e1b370f2
AkhilReddykasu/Lists
/25_selecting_item_randomly.py
426
4.125
4
"""selecting item randomly and print index and values""" li = [] n = int(input("enter the length:")) for i in range(0,n): ele = int(input("enter an element:")) li.append(ele) i = int(input("enter the value you want search for:")) if i in li: print("searched element is available") print("ind...
true
c8f73d012a4b3238ecb79ac8e310fb3433e79ebe
taylorcavazos/hw1-Sorting
/example/algs.py
2,156
4.25
4
import numpy as np def pointless_sort(x): """ This function always returns the same values to show how testing works, check out the `test/test_alg.py` file to see. """ return np.array([1,2,3]) def bubblesort(x): """ Sort array by looping through array, swapping unordered adjacent elem...
true
83c39ad37b13554ae684070d58ed2c5dfb92b04f
brittanyvamvakias/Programming-Lab-3
/q2.py
2,055
4.4375
4
# File: q2.py # Author: Brittany Vamvakias # Date: 02/11/2020 # Section: 501 # E-mail: brittvam@tamu.edu # Description: This code prompts the user to input the height for a triangle and two symbols to use for the triangle. The code then runs a while loop producing the correct amount of symbols in each row, starting fro...
true
7b275d2427955b4a7eafcd1552f4a3e71807188b
sorin-66/Hackathon_V1
/Hackathon_16.py
960
4.25
4
""" 16 - Write a program that can take two strings as an input. The program should swap around every other letter in each string, and return both as an output. For instance, if the input is “Osamu” and “Dazai”, the output should be “Oaaau” and “Dszmi”. If the two input strings are not the same length, the outputs s...
true
577ce6979381bfd85fc34f1d56794975b3db1e4c
sorin-66/Hackathon_V1
/Hackathon_6.py
675
4.21875
4
''' 6 - Write a function that will round a float in reverse. If the input has a decimal greater than or equal to .5 then in should round down. If the decimal is less than .5 it should round up. ''' number_2 = 1.2345 number_1 = 9.8765 # transform the float in a string num1_str = str(number_1) # find the index...
true
b8a833b65f66845341d41b551c922b4c1c9895f3
skhan55/Notes_330_Part2
/helpful non-project code/write_note.py
1,348
4.28125
4
import os import pickle #An extremely simple and bare minimum for writing and reading in user created notes #using python and the pickle library. #make sure to create a folder named note_library in the same directory so the program can actually save the notes class Note(object): def __init__ (self, pbody, author,...
true
6072d7eadf78132a2eb340ca4ffb1b89f400dd99
brcsomnath/competitive-programming
/leetcode/snake-game.py
1,355
4.5
4
''' 353. Design Snake Game Design a Snake game that is played on a device with screen size = width x height. Play the game online if you are not familiar with the game. The snake is initially positioned at the top left corner (0,0) with length = 1 unit. You are given a list of food's positions in row-column order. Wh...
true
b7aa899f973e596410b4fa357d366e8df8f5a9ac
Jmw150/Computational-Science
/old-code/newtonsMethod.py
2,744
4.15625
4
#!/usr/bin/env python # Newton's method # made by: Jordan Winkler # finds an approximation of a root using Newton's Method # This program is weak against injection attacks. # option -f for fractions, default floating point # -d for debugging or verbose mode # -i [number] for iterations of function # ...
true
7ccc974fd865094b5094ffbaddf53283e913d5a2
gautamgitspace/interview-cake
/reverse-words.py
448
4.65625
5
#In Python, strings are immutable. Changing a string does not #modify the string. It creates a new one. Hence no point of doing #it in place. #APPROACH : def reverse_words: split the string to get a list. Perform #in place list reversal by extended slice def reverse_words(input): result = " ".join(input.split()[::...
true
fc6eb00864a7e07c1828e517f7c47b2cb5c222de
gautamgitspace/interview-cake
/highest-product_negative_integers.py
1,282
4.5625
5
""" Keep track of the highest_product_of_2 and lowest_product_of_2(could be a low negative number). If the current number times one of those is higher than the current highest_product_of_three, we have a new highest_product_of_three! So at each iteration we're keeping track of and updating: highest_product_of_three h...
true
3ccd3ad1bc9c5ea77ff7b89864eeb9feb44521aa
lpdonofrio/D06
/HW06_ch09_ex05.py
1,274
4.28125
4
#!/usr/bin/env python3 # HW06_ch09_ex05.py # (1) # Write a function named uses_all that takes a word and a string of required # letters, and that returns True if the word uses all the required letters at # least once. # - write uses_all # (2) # How many words are there that use all the vowels aeiou? How about # aeio...
true
129cd69aba7ec0cdd91342f8971a7f4bbb0755f6
wakafengfan/Leetcode
/hard/longest_valid_parentheses.py
753
4.1875
4
""" Given a string containing just the characters '(' and ')', find the length of the longest valid (well-formed) parentheses substring. Example 1: Input: "(()" Output: 2 Explanation: The longest valid parentheses substring is "()" Example 2: Input: ")()())" Output: 4 Explanation: The longest valid parentheses subst...
true
103a52662137cb93c60a199db26aa2b256a2a3a2
wakafengfan/Leetcode
/medium/greedy__merge_intervals.py
789
4.28125
4
""" Given a collection of intervals, merge all overlapping intervals. Example 1: Input: [[1,3],[2,6],[8,10],[15,18]] Output: [[1,6],[8,10],[15,18]] Explanation: Since intervals [1,3] and [2,6] overlaps, merge them into [1,6]. Example 2: Input: [[1,4],[4,5]] Output: [[1,5]] Explanation: Intervals [1,4] and [4,5] are ...
true
8d00f42d9336d01a6ad68cb9815f9a1b7e35cda9
wakafengfan/Leetcode
/tree/invert_binary_tree.py
960
4.15625
4
""" Invert a binary tree. Example: Input: 4 / \ 2 7 / \ / \ 1 3 6 9 Output: 4 / \ 7 2 / \ / \ 9 6 3 1 Trivia: This problem was inspired by this original tweet by Max Howell: Google: 90% of our engineers use the software you wrote (Homebrew), but you can’t invert a bina...
true
bf2647b15d32824d644f7133d1e69647f4db6ce5
wakafengfan/Leetcode
/medium/greedy__non_overlapping_intervals.py
1,141
4.3125
4
""" Given a collection of intervals, find the minimum number of intervals you need to remove to make the rest of the intervals non-overlapping. Example 1: Input: [[1,2],[2,3],[3,4],[1,3]] Output: 1 Explanation: [1,3] can be removed and the rest of intervals are non-overlapping. Example 2: Input: [[1,2],[1,2],[1,2]...
true
6329deb1d8df152e67d676dd2cc56328b5ce3b82
fatcam84/monitor-beach
/selectiveCopy.py
456
4.21875
4
""" This program will search a given directory for files with desired suffix and move them all to a different directory. In this example, I am searching my 'Downlaods' folder and moving all the .zip files to a folder called 'zip_files'. """ import os, shutil os.chdir('C:\\Users\\Camer\\Downloads') for...
true
239050fcc091665d00c757cd7ca79a2936052063
g2des/taco4ways
/hackerrank/primeorder.py
1,407
4.15625
4
#!/bin/python3 import math import os import random import re import sys # # Complete the 'sortOrders' function below. # # The function is expected to return a STRING_ARRAY. # The function accepts STRING_ARRAY orderList as parameter. # def sortOrders(orderList): # Write your code here primeOrders = [] ...
true
9bbb55df3f385c362604017dd71b02e2fdaa5d68
Jamshid93/TypeConversations
/type.py
450
4.21875
4
name=input("What is your name?") print(type(name)) birth_day=input("Pleace tell me your brithday?") print(type(birth_day)) age=2019-int(birth_day) favourite_color=input("What is your favourite color?") print(type(favourite_color)) print(name +" born at the "+ birth_day +" nowadays his age is " +str(age) + " his likes ...
true
d8fe61aa1db2924aceeb30761254f85e4a89b7bc
jrprotzman/Module2.4
/main/camper_age_input.py
1,297
4.21875
4
""" Program: TDD First Program.py Author: Justin Protzman Last date modified: 06/03/2020 Program specifications: The program will have will prompt for the age of one infant (age 1-5 years) who is attending camp and convert the age in months to years via a function call then print the result. Write a program camper_a...
true
21505d1ce1b739c596561254149f124ac69e5821
reco92/pychallenges
/june20.py
2,102
4.3125
4
def bishops_can_attack(bishops, size): """ On our special chessboard, two bishops attack each other if they share the same diagonal. This includes bishops that have another bishop located between them, i.e. bishops can attack through pieces. You are given N bishops, represented as (row, column) tuples on a...
true
618ab6b27deffdef3aaa89977eea5d43186fe014
dave738/calculator
/infix_calculator.py
2,915
4.46875
4
def precedence(op): ''' Function to find precedence of operators. ''' if op == '+' or op == '-': return 1 if op == '*' or op == '/': return 2 return 0 def apply_op(a, b, op): '''Function to perform arithmetic operations.''' if op == '+': return a + b if op == '-'...
true
a8c1e4c439b5691ac1ccf4c9a682657eeedc32d7
adinath10/Python-Apps
/Unit-5 Dictionaries/Thesaurus_App.py
1,117
4.15625
4
#Python Challenge 21 Thesaurus App import random print("Welcome to the Thesaurus App!") print("\nChoose a word from the thesaurus and I will give you a synonym.") synonyms = { 'Hot' : ['balmy', 'summery', 'tropical', 'boiling', 'scorching'], 'Cold' : ['chilly', 'cool','freezing','frigid','polar'], 'Happy' : ['co...
true
45417e66c82444dafeca5664eb4c3d9d048822a3
adinath10/Python-Apps
/Unit-5 Dictionaries/Frequency_Analysis_App.py
2,029
4.40625
4
#Python Challenge 24 Frequency Analysis App from collections import Counter print("Welcome to the Frequency Analysis App") non_letters = ['1','2','3','4','5','6','7','8','9',' ','.','?','!',',','"',"'",':',';','(',')','%','$','&','#','\n','\t'] key_phrase_1 = input("\nEnter a word or phrase to count the occurrence o...
true
43520c741d0e8be1ae3c7b09dca3fe9735bc3168
Gayatri3achugatla/learning
/even_odd.py
230
4.34375
4
# program to get even and odd numbers using list comprehension #This will print only even or odd not the numbers list1 = [1,34,33,77,98,76,23,21,65,79] even_odd = ['even' if num%2 ==0 else 'odd' for num in list1] print(even_odd)
true
0ae0cadf7888b51c70c3e5a3d4b78a23b2d0eeb3
bdebo236/edit-distance
/edit-distance-recursion.py
1,656
4.28125
4
def editDistance(s1, s2): ## If one of the string is empty then the edit distance will be equal to the length of the other because in that case we just have to ## insert all the letters in that string to duplicate it or remove all from the other to make it empty like the other if len(s1) == 0: retur...
true
a1333895e7fe6e745e9c9459fd2a80ddbe768815
tushartripathi1998/Python_programs
/BeerSong.py
371
4.21875
4
word="bottles" for beer_num in range(3,0,-1): print(beer_num,word,"of beer left") print(beer_num,word,"of beer") print("take one down") print("pass it around") if beer_num==1 : print("no more beer left") else : new_num=beer_num-1 if new_num==1 : word="bottle" ...
true
465168242cebf1ad140455f919c947df09986b39
ManishSkr/Traversal-of-BST
/PythonApplication18.py
1,210
4.1875
4
#All traversals class node: def __init__(self,val): self.val=val self.right=None self.left=None def insert(root,node): if root is None: root=node elif(root.val<node.val): if root.right is None: root.right=node else: ins...
true
3c9667cabafa4f7e95e6936f5637952bb59e9f4e
ewolyror/pythonexercises
/e2.py
559
4.125
4
"""9/24/2019 e2.py The second exercise of the python exercise series Question: Write a program which can compute the factorial of a given numbers. The results should be printed in a comma-separated sequence on a single line. Suppose the following input is supplied to the program: 8 Then, the output should be: 40320 H...
true
4a05dc442be55fff6b8afcb61dbd6cef33a7db35
srinathsubbaraman/python_assignments
/problem set 1/volume.py
363
4.3125
4
''' Name :volume.py Date :04/12/2017 Author :srinath.subbaraman Question:Practice using the Python interpreter as a calculator: a) The volume of a sphere with radius r is 4/3pr3. What is the volume of a sphere with radius 5? Hint: 392.7 is wrong!? ''' r = int(raw_input("Enter the radius:")) v = (4*(3.14)*(r**3))/3...
true
275102cf78abfc4899fc0b5ef40da54949f33731
srinathsubbaraman/python_assignments
/problem set 1/right_justify.py
546
4.1875
4
''' Name :right_justify.py Date :04/12/2017 Author :srinath.subbaraman Question:Python provides a built-in function called len that returns the length of a string, so the value of len('Cigna') is 5. Write a function named right_justify that takes a string named s as a parameter and prints the string with enough lead...
true
be8cba690fe473b85a685cf2e867b4de9d56d2d1
prai05/ProFun
/Assignment 4/Assignment 4.8.py
1,080
4.21875
4
# Assignment 4 # 010123102 Computer Programming Fundamental # # Assignment 4.8 # We want make a package of goal kilos of chocolate. # We have small bars (1 kilo each) and big bars (5 kilos each). # Return the number of small bars to use, assuming we always use big bars before small bars. Return -1 if it can't be done #...
true
1e41d5a5055562bd2f4a5cac8442079f9dcc882c
prai05/ProFun
/Assignment 3/Assignment 3.1.py
1,148
4.46875
4
# Assignment 3 # 010123102 Computer Programming Fundamental # # Assignment 3.1 # 1. You are driving a little too fast, and a police officer stops you. Write code to compute the result, encoded as an int value: # 0=no ticket, 1=small ticket, 2=big ticket. If speed is 60 or less, the result is 0. If speed is between 61 a...
true
0da0eda24546daf956d5c441d0034e582060dfa0
prai05/ProFun
/Assignment 4/Assignment 4.6.py
953
4.125
4
# Assignment 4 # 010123102 Computer Programming Fundamental # # Assignment 4.6 # For this problem, we'll round an int value up to the next multiple of 10 if its rightmost digit is 5 or more, so 15 rounds up to 20. # Alternately, round down to the previous multiple of 10 if its rightmost digit is less than 5, so 12 roun...
true
124e654889603a1b3b2dc88340c1b55477e4d8b0
prai05/ProFun
/Assignment 3/Assignment 3.3.py
687
4.15625
4
# Assignment 3 # 010123102 Computer Programming Fundamental # # Assignment 3.3 # Given a number n, return True if n is in the range 1..10, inclusive. # Unless "outsideMode" is True, in which case return True if the number is less or equal to 1, or greater or equal to 10. # # Phattharanat Khunakornophat # ID 59010126100...
true
25990767469e6f860da810e42a5923b203a23bcc
megactrl/algo
/src/algo/Recursive and Algo/factorial.py
348
4.40625
4
# Recursive Function for calculating factorial of a number def fact(num): print(" Function called with num = " + str(num)) if num == 1: return 1 else: ans = num * fact(num - 1) print("Intermediate result for", num, "* fact(" ,num - 1, ") :", ans) return ans print...
true
e8f994c22d4724f318c464a61fefc0ac4be7ecea
vishrutkmr7/DailyPracticeProblemsDIP
/2023/04 April/db04202023.py
1,050
4.15625
4
""" Given a positive integer, N, return all flippable numbers between one and N inclusive. Note: A flippable number is a number whose digits can be rotated 180 degrees to form a different number. Digits 0, 1, 6, 8, and 9 become 0, 1, 9, 8, and 6 respectively when rotated. Digits 2, 3, 4, 5, and 7 are invalid when rotat...
true
f51a6f1fa176258eb6da647e8d2d22f3a71d0e02
vishrutkmr7/DailyPracticeProblemsDIP
/2022/08 August/db08162022.py
737
4.5
4
""" This question is asked by Microsoft. Implement a trie class that supports insertion and search functionalities. Note: You may assume only lowercase alphabetical characters will added to your trie. Ex: Given the following operations on your trie… Trie trie = new Trie() trie.insert("programming"); trie.search("comp...
true
e06420a730416924a3c1af556bc35294c190c43a
vishrutkmr7/DailyPracticeProblemsDIP
/2022/08 August/db08182022.py
880
4.125
4
""" This question is asked by Google. Given a positive integer N, return the number of prime numbers less than N. Ex: Given the following N… N = 3, return 1. 2 is the only prime number less than 3. Ex: Given the following N… N = 7, return 3. 2, 3, and 5 are the only prime numbers less than 7. """ class Solution: ...
true
b2040c6a443ed0b63c49465325a47bee1bf8059e
vishrutkmr7/DailyPracticeProblemsDIP
/2022/11 November/db11072022.py
1,604
4.15625
4
""" You are given a list of values and a list of labels. The ith element in labels represents the label of the ith element. Similarly, the ith element in values represents the value associated with the ith element (i.e. together, an “item” could be thought of as a label and a price). Given a list of values, a list of l...
true
d1b881a1ec946d2acafab85e20181ed19dd07591
vishrutkmr7/DailyPracticeProblemsDIP
/2019/11 November/dp11232019.py
549
4.125
4
# This problem was recently asked by Apple: # A fixed point in a list is where the value is equal to its index. # So for example the list [-5, 1, 3, 4], 1 is a fixed point in the list since the index and value is the same. # Find a fixed point (there can be many, just return 1) in a sorted list of distinct elements, o...
true
160b7920eb9f6dd4d403b679efa43237ac50b91b
vishrutkmr7/DailyPracticeProblemsDIP
/2022/08 August/db08262022.py
1,581
4.125
4
""" Given a 2D array containing only the following values: -1, 0, 1 where -1 represents an obstacle, 0 represents a rabbit hole, and 1 represents a rabbit, update every cell containing a rabbit with the distance to its closest rabbit hole. Note: multiple rabbit may occupy a single rabbit hole and you may assume every ...
true
38e6a43cbb584dd8680f95d5808b9aefc26c804e
vishrutkmr7/DailyPracticeProblemsDIP
/2022/08 August/db08032022.py
1,641
4.15625
4
""" A frog is attempting to cross a river to reach the other side. Within the river, there are stones located at different positions given by a stones array (this array is in sorted order). Starting on the first stone (i.e. stones[0]), the frog makes a jump of size one potentially landing on the next stone. If the frog...
true
5a3bbc0e16b428978efad7fc30823dcc017d946a
vishrutkmr7/DailyPracticeProblemsDIP
/2023/02 February/db02132023.py
767
4.28125
4
"""You are typing on a computer when all of a sudden you realize you’ve been typing with caps lock on. Given a string s, return a new string containing all of its alphabetical character transformed to lowercase. Note: Do you not use an built in library functions. Ex: Given the following string s… s = "ABC", return "...
true
3a318c63afc7ca864f1d23e8b5ac1a1197875968
vishrutkmr7/DailyPracticeProblemsDIP
/2020/02 February/dp02072020.py
808
4.28125
4
# This problem was recently asked by LinkedIn: # Given a binary tree, find the minimum depth of the binary tree. The minimum depth is the shortest distance from the root to a leaf. class Node: def __init__(self, value, left=None, right=None): self.value = value self.left = left self.right...
true
d735af2075cee3c654745539685f00c90f417851
vishrutkmr7/DailyPracticeProblemsDIP
/2023/04 April/db04062023.py
1,202
4.3125
4
""" Given the reference to the root of a binary tree, and a target value, remove all the leaf nodes that contain the target and return the modified tree. Note: If you remove a leaf node that contains the target value and the parent node now becomes a leaf with a value of target, you must remove the parent as well. Ex...
true
cc41f1a2b12cc20afec3a95ed0b3823a4213c7aa
vishrutkmr7/DailyPracticeProblemsDIP
/2023/04 April/db04212023.py
998
4.28125
4
""" You are given two integer arrays, nums1 and nums2, and asked to sort them in a particular order. The elements in nums2 are distinct and all occur within nums1. Sort the elements of nums1 such that the relative ordering of values are the same as nums2. All elements that don’t appear in nums2 should appear at the end...
true
bafc079043e1c785f0336dc90498bffdec68f61c
vishrutkmr7/DailyPracticeProblemsDIP
/2022/06 June/db06102022.py
1,685
4.125
4
""" This question is asked by Apple. Given two sorted linked lists, merge them together in ascending order and return a reference to the merged list. Ex: Given the following lists... list1 = 1->2->3, list2 = 4->5->6->null, return 1->2->3->4->5->6->null list1 = 1->3->5, list2 = 2->4->6->null, return 1->2->3->4->5->6->...
true
cfe2415395d595d0005340f8a1eb415b0e3f2bb2
vishrutkmr7/DailyPracticeProblemsDIP
/2023/01 January/db01282023.py
1,073
4.25
4
""" Given a binary tree, invert it and return the resulting tree. Ex: Given the following binary tree… 1 / \ 2 3, return... 1 / \ 3 2 Ex: Given the following binary tree… 1 / \ 2 3 / \ / \ 4 5 6 7, return... 1 ...
true