blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
382a8915e11e58f68d73b4451e9efaa294ff1ffb
niranjan2822/List
/Iterating two lists at once.py
1,777
4.65625
5
# Iterating two lists at once # Sometimes, while working with Python list, we can have a problem in which we have to iterate over two list elements. # Iterating one after another is an option, but it’s more cumbersome and a one-two liner is always recommended over # that ''' Input 1 : [4, 5, 3, 6, 2] Input 2 : [7, ...
true
4ffa4b3471cedec80b47c6408b8bf1318c28dc40
siddbose97/maze
/DFS/maze.py
1,240
4.15625
4
#logic inspired by Christian Hill 2017 #create a cell class to instantiate cells within the grid which will house the maze #every cell will have walls and a coordinate pair class cell: # create pairs of walls wallPairs = {"N":"S", "S":"N", "E":"W", "W":"E"} def __init__(self, x, y): #give a wall ...
true
8b589bdd3f9299888080234f814c617e111817c1
Purushotamprasai/Python
/Rehaman/001_Basic_understanding/001_basic_syntax.py
1,023
4.125
4
#!/usr/bin/python # the above line is shabang line ( path of python interpreter) #single line comment ( by using hash character '#' ''' We can comment multiple lines at a time by using triple quotes ''' # the below code understand for statement concept ''' 1---> single statemnt ''' # a line which is having si...
true
efe69eec4380f3041992e4b82eb1252f32876859
Purushotamprasai/Python
/Rohith_Batch/Operator/Logical Operator/001_understand.py
908
4.3125
4
# this file is understand for logical operators ''' Logical AND ---> and --------------------- Defination : ----------- if 1st input is false case then output is 1st input value other wise 2nd input value is the output Logical OR---> or --------------------- Defination : ----------- if 1st ...
true
ad53e27408916456b808dea9bdc0662692a5fd24
Purushotamprasai/Python
/Z.R/files/002_write.py
355
4.125
4
file_obj = open("readfile.txt","w") ''' file opened as write mode if the file is not existed 1st create then open it" file is existed then removes previous data and open as fresh file if the is open as write mode we cant use read methodes ''' data =input("enter some data") file_obj.write(data) d =...
true
72a0cc33029ff768a219bfe8517ed7793abfe467
Purushotamprasai/Python
/Rohith_Batch/Operator/Relational/Bitwise_Even or Odd.py
299
4.34375
4
''' Program : Find the Given number is Even or Odd using bitwise operator Programmer : Rohit ''' def main(): a = input('Enter a value: ') if a&1==0: print "Number is Even" else: print "Number is Odd" if (__name__=="__main__"): main()
true
e1194fa52edbd9f140b0d048833b2fd13e6517ff
Purushotamprasai/Python
/hussain_mani/python_introduction/003_Python Basic Built-in function/Built_in_function_info.py
1,541
4.21875
4
# python Basic Built -in Function ''' Function :- --------------- -----> Function is a set of instructions for doing any one task -----> there are two types 1. User Defined Function :- --------------------------- The programmer can define function def ----> user defined function 2. Built-in funct...
true
a57998b659eb1ad0d09749a74eb54a6a7db0e58c
TomiMustapha/Shleep
/week.py
623
4.15625
4
## Week class ## ## Each week is a list of fixed size 7 of positive ints ## Represents a week in which we log hours of sleep ## We can then combine weeks into a matrix to be represented graphically import numpy as np class Week(): def __init__(self): self.nodes = np.array([]) def in...
true
97487f7c395f37af614556864394127eeeb006b7
parker57/210CT
/week4/adv2_qs.py
1,754
4.25
4
## Adapt the Quick Sort algorithm to find the mth smallest element out of a list of n integers, where m is ## read from the standard input. ## For example, when m = 5, your version of Quick Sort will output the 5th smallest element out of your ## input list. import random def quickselect(array, m): ...
true
521e916bcc367920ddb63aedcd90e84e38ac7f42
Anshul-GH/jupyter-notebooks
/UdemyPythonDS/DS_BinarySearchTree/Node.py
2,982
4.46875
4
# Defining the class Node class Node(object): # Construction for class Node def __init__(self, data): self.data = data # defining both the child nodes as NULL for the head node self.leftChild = None self.rightChild = None # Defining the insert function. # 'data' contai...
true
99467384dfdee08e2f5794af6db8e964807ccc95
JFarina5/Python
/password_tester.py
1,107
4.25
4
""" This program takes a given user password and adds 'points' to that password, then calculates the total amount of 'points'. The program will take the total amount of points and then inform the user if they have a strong password or a weak password. """ import re def password_test(): value = 0 user_pass = ...
true
8f8505622fbd3ab77638a28c71d98133d5980fa7
JFarina5/Python
/palindrome_tester.py
623
4.4375
4
""" The purpose of this program is to test a string of text and determine if that word is a palindrome. """ # Palindrome method, which disregards spaces in the user's input and reverses that string # in order to test the input to see if it is a palindrome. def palindrome(): string = input("Please insert a palindro...
true
18b0a035d045cfdb818ecabd0c29fad2a166fa70
ImLeosky/holbertonschool-higher_level_programming
/0x0C-python-almost_a_circle/models/square.py
2,164
4.28125
4
#!/usr/bin/python3 """ the class Square that inherits from Rectangle """ from models.rectangle import Rectangle class Square(Rectangle): """ Class Square inherits from Rectangle """ def __init__(self, size, x=0, y=0, id=None): """ Class constructor """ width = size ...
true
830e2ac7c2d5a8e558877538c644ff87a2747f3b
alammahbub/py_begin_oct
/5. list.py
1,402
4.53125
5
# list in python start with square brackets # list can hold any kind of data friends = ["asib","rony","sajia"] print(friends) # accessing list item with there index print(friends[2]+" has index 2") # accessing list from back or, as negative index print(friends[-1]+" has index -1") # Asigning new item in list by...
true
2a6f7cbc33008d2a22ba3974e0e90201caab553a
marko-despotovic-bgd/python
/EndavaExercises/1_3_stringoperations.py
381
4.34375
4
# 1. Strings and Numbers # 1.3. Write a console program that asks for a string and outputs string length # as well as first and last three characters. print('Please enter some string: ') string = (input()) print('Length: {}\nFirst 3 chars: {}\nLast 3 chars: {}'.format(len(string), ...
true
e21afb700a8297f49dc193bd9f7d5c72b5c95c07
4Empyre/Bootcamp-Python
/35python_bike/bike.py
780
4.21875
4
class Bike(object): def __init__ (self, price, max_speed): self.price = price self.max_speed = max_speed self.miles = 0 def displayInfo(self): print "Price:",self.price,"Max Speed:",self.max_speed,"Miles:", self.miles def ride(self): self.miles += 10 ...
true
c2b4a96ee434e18f2be2f2758478331919d65582
brucekaushik/basicblog
/apps/hello-world/valid-month.py
1,189
4.4375
4
# ----------- # User Instructions # # Modify the valid_month() function to verify # whether the data a user enters is a valid # month. If the passed in parameter 'month' # is not a valid month, return None. # If 'month' is a valid month, then return # the name of the month with the first letter # capitalized. # ...
true
6dad3d3891bda5551a6e6a3f03a442236cf2a9ae
cameronww7/Python-Workspace
/Python-Bootcomp-Zero_To_Hero/Sec-14-Py-Adv_Modules/113-Py-ZippingAndUnzippingFiles.py
2,175
4.1875
4
from __future__ import print_function import zipfile import shutil import os """ Prompt 113-Py-ZippingAndUnzippingFiles """ print("113-Py-ZippingAndUnzippingFiles") """ Unzipping and Zipping Files As you are probably aware, files can be compressed to a zip format. Often people use special programs on their computer...
true
ec0cbb2d72776eedda8618778e642c7944080959
cameronww7/Python-Workspace
/Python-Bootcomp-Zero_To_Hero/Sec-14-Py-Adv_Modules/106-Py-Date_Time.py
1,964
4.40625
4
from __future__ import print_function import datetime """ Prompt 106-Py-Date_Time """ print("106-Py-Date_Time") """ datetime module Python has the datetime module to help deal with timestamps in your code. Time values are represented with the time class. Times have attributes for hour, minute, second, and micros...
true
47226b0ba22174336343d4f6fe2648d053ec8612
cameronww7/Python-Workspace
/Python-Bootcomp-Zero_To_Hero/Sec-8-Py-OOP/66-OOP-Challenge.py
2,257
4.3125
4
from __future__ import print_function import math """ Prompt 66-OOP-Challenge """ print("66-OOP-Challenge") """ Object Oriented Programming Challenge For this challenge, create a bank account class that has two attributes: owner balance and two methods: deposit withdraw As an added requirement, withdrawals may ...
true
6e8687c78e8198d41807ef3bd1652efcf16bffe9
romanitalian/romanitalian.github.io
/sections/python/spiral_matrix/VH7Isb3mRqUaaHCc_spiral-matrix-in-python.py
1,751
4.28125
4
#!/usr/bin/env python3 # http://runnable.com/VH7Isb3mRqUaaHCc/spiral-matrix-in-python def change_direction(dx, dy): # not allowed!3 if abs(dx+dy) != 1: raise ValueError if dy == 0: return dy, dx if dx == 0: return -dy, dx def print_spiral(N=5, M=6): if N < 0 or M < 0: ...
true
dff98da96027c42420440cdae33e55c3dcab539b
kelvinadams/PythonTheHardWay
/ex11.py
386
4.40625
4
# Python the Hard Way - Exercise 11 # prompts user for their age, height, and weight print("How old are you?", end=' ') age = input() print("How tall are you?", end=' ') height = input() print("What is your weight?", end=' ') weight = input() # prints out the input in a new format print( f"Alrighty,...
true
b7fc72d816e4fbf3dad343eb6f7f2cf47847a7e7
SujeethJinesh/Computational-Physics-Python
/Jinesh_HW1/Prob1.py
414
4.1875
4
import math def ball_drop(): height = float(input("please input the height of the tower: ")) #This is how many meters tall the tower is gravity = 9.81 #This is the acceleration (m/s^2) due to gravity near earth's surface time = math.sqrt((2.0*height)/gravity) #derived from h = 1/2 gt^2 to solve for time ...
true
f6146b7e9826f07bc27579b30a5b48abbc35be7a
SujeethJinesh/Computational-Physics-Python
/Jinesh_HW1/Prob2.py
870
4.21875
4
import math def travel_time(): distance_from_planet = float(input("Enter distance from planet in light years: ")) #gets user input for light year distance speed_of_craft = float(input("please enter speed as a fraction of c: ")) #gets speed of craft in terms of c from user stationary_observer_time_years =...
true
a037cc7c52fa60741d40e9ac8f715b9e3bd7cc02
carolinemascarin/LPTHW
/ex5.py
714
4.21875
4
#Exercise 5 myname = 'Caroline Mascarin' myage = 27 myheight = 175 myeyes = 'Black' myteeth = 'White' myhair = 'Brown' print "Lets talk about %s." % myname print "She is %d centimeters tall" %myheight print "She's got %s eyes and %s hair" % (myeyes, myhair) print "if I add %d and %d I get %d" % (myage, myheight, myag...
true
99af0848e395225fbdfa555324a93e1f03ede662
nlscng/ubiquitous-octo-robot
/p100/problem-196/MostOftenSubtreeSumBST.py
1,563
4.125
4
# This problem was asked by Apple. # # Given the root of a binary tree, find the most frequent subtree sum. The subtree sum of a node is the sum of all values under a node, including the node itself. # # For example, given the following tree: # # 5 # / \ # 2 -5 # Return 2 as it occurs twice: once as the left leaf, ...
true
43dc120d758dd3a1d5c60582ce1df81c0a6a8459
nlscng/ubiquitous-octo-robot
/p100/problem-188/PythonFunctionalDebug.py
782
4.15625
4
# This problem was asked by Google. # # What will this code print out? # # def make_functions(): # flist = [] # # for i in [1, 2, 3]: # def print_i(): # print(i) # flist.append(print_i) # # return flist # # functions = make_functions() # for f in functions: # f() # How can we...
true
62ebf7681cc0f040b0ccb64d4c2218a1d2c5c7ad
nlscng/ubiquitous-octo-robot
/p000/problem-98/WordSearchPuzzle.py
2,521
4.21875
4
# This problem was asked by Coursera. # # Given a 2D board of characters and a word, find if the word exists in the grid. # # The word can be constructed from letters of sequentially adjacent cell, where "adjacent" cells are those # horizontally or vertically neighboring. The same letter cell may not be used more than ...
true
70bf93d87d438fffa829d69fb3b1eb615a5322a0
nlscng/ubiquitous-octo-robot
/p000/problem-88/DivisionWithoutOperator.py
546
4.21875
4
# This question was asked by ContextLogic. # # Implement division of two positive integers without using the division, multiplication, or modulus operators. # Return the quotient as an integer, ignoring the remainder. def raw_division(n: int, m: int) -> int: if n < m: return raw_division(m, n) quot, ...
true
5a75a95a3a659a9a970c94aebfc13950730718a1
nlscng/ubiquitous-octo-robot
/p000/problem-6/XorLinkedList.py
1,961
4.1875
4
# An XOR linked list is a more memory efficient doubly linked list. Instead of each node holding next and prev # fields, it holds a field named both, which is an XOR of the next node and the previous node. Implement an XOR # linked list; it has an add(element) which adds the element to the end, and a get(index) which r...
true
ede2ca2fec4c1156fb877811d1f5274749299ea2
nlscng/ubiquitous-octo-robot
/p000/problem-58/SearchInRotatedSortedArray.py
1,415
4.15625
4
# Good morning! Here's your coding interview problem for today. # # This problem was asked by Amazon. # # An sorted array of integers was rotated an unknown number of times. # # Given such an array, find the index of the element in the array in faster than linear time. If the element doesn't # exist in the array, retur...
true
c6d5c270f8a215c1b8d8060d15e4073d6339a8bb
nlscng/ubiquitous-octo-robot
/p000/problem-68/AttackingBishop.py
1,467
4.28125
4
# Good morning! Here's your coding interview problem for today. # # This problem was asked by Google. # # 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 g...
true
5b4735c804aafaa74f3a0461bc53fb5befbc6093
chandrikakurla/implementing-queue-with-array-space-efficient-way-in-python-
/qu_implement queue using array.py
2,962
4.1875
4
#class to implement queue class Queue: def __init__(self,size): self.queue=[None] *size self.front=-1 self.rear=-1 self.size=size #function to check empty stack def isEmpty(self): if self.front==-1 and self.rear==-1: return True else: ...
true
041e238b857fa33960c8f51c95e21d5fd2e4cf0d
lindajaracuaro/My-Chemical-Polymorphism
/My chemical polymorphism.py
782
4.28125
4
# Chemical polymorphism! In this program you'll have fun using chemistry and polymorphism. Add elements and create molecules. class Atom: def __init__(self, label): self.label = label def __add__(self, other): # Return as a chemical composition return self.label + other.label def __repr__(sel...
true
6b0f193dc597b8d5f02db807376a3a7f4f39bcdd
rowens794/intro-to-cs
/ps1/ps1.py
599
4.125
4
portion_down_payment = .25 r = .04 annual_salary = float(input('what is your annual salary? ')) portion_saved = float(input('what portion of your salary will you save? ')) total_cost = float(input('how much does your dream house cost? ')) current_savings = 0 months = 0 print('pre loop') print(current_savings) print(...
true
f18337a4c73ad850e323599b21a91263b75ce1d9
JKH2124/jnh-diner-project-py
/diner_project.py
2,157
4.40625
4
# J & K's Diner dinnerMenu = ['STEAK', '15', 'CHICKEN', '12', 'PORK', '11', 'SALAD', '12'] sidesMenu = ['FRIES', 'RICE', 'VEGGIES', 'SOUP', '1'] dinnerSelect = input("Please select an entree: ").upper() if dinnerSelect == dinnerMenu[0]: print("Excellent choice! The price for that entree is {}".format(dinnerMenu[1]...
true
e645165c06b68fadc275ab51ed701a00887f5688
Gaurav-Pande/DataStructures
/leetcode/graphs/add_search_trie.py
1,636
4.15625
4
# link: https://leetcode.com/problems/add-and-search-word-data-structure-design/ class TrieNode(object): def __init__(self): self.children = collections.defaultdict(TrieNode) self.is_word=False class WordDictionary(object): def __init__(self): """ Initialize your data structure...
true
5cc638d480d73a33a413a565f0375a43e51f1606
DeekshaKodieur/python_programs
/python/factorial_num.py
263
4.3125
4
fact=1 num=int(input("Enter the number to find its factorial : ")) #for i in range(1,(num+1)): #fact = fact * i i=1 while(i<=num): fact = fact * i i = i+1 print("Factorial of a number",num,"is",fact) input("press enter to exit")
true
8f6cf04a3d8692607547aa336b7e4f1d370cdb2f
kazinayem2011/python_problem_solving
/reverse_number.py
209
4.21875
4
number=int(input("Please Enter Your Number : ")) reverse=0 i=0 while i<number: last_num=number%10 reverse=(reverse*10)+last_num number=number//10 print("The Reverse of numbers are : ", reverse)
true
768a3e44b3d7e5389f0f30c459ff852808e02642
Adriannech/phyton-express-course
/Greatest_no#.py
693
4.46875
4
print("Description: This program will pick the biggest value from string of numbers") nums = input("Please input number (coma separated):") nums = nums.split(",") if len(nums) == 0: print("There's no input numbers") exit(0) for i in range(len(nums)): if not nums[i].is_numeric(): nums[i] = float(n...
true
6dc92fcd7d63fded3c67a6ea9a5ae6d8abd8f5ee
Li-congying/algorithm_python
/LC/String/string_compression.py
2,062
4.21875
4
''' Given an array of characters, compress it in-place. The length after compression must always be smaller than or equal to the original array. Every element of the array should be a character (not int) of length 1. After you are done modifying the input array in-place, return the new length of the array. Follow ...
true
89bb52bd6f25cd45531546efc8b5474f6a57ab56
gittygupta/Python-Learning-Course
/Tutorials/error_exception.py
650
4.25
4
# Exception handling while True: try: x = int(input('Enter your fav number: \n')) print(8/x) # it can cause a ZeroDivisionError break except ValueError: # "ValueError" means an exception print("ok dude you gotta try again") except ZeroDivisionError...
true
ddcd9d1fb9864438fdb3a1017b7798c2beca0311
gittygupta/Python-Learning-Course
/Tutorials/download_image.py
577
4.125
4
import urllib.request import random def download_image_file(url): name = random.randrange(1, 1000) full_name = str(name) + ".png" urllib.request.urlretrieve(url, full_name) # used to retrive url to download the image # it also stores the name of the file and saves the image in the same directory...
true
95c3a925e8eb187fadaeffb4c6daef30b1f0af77
jmachcse/2221inPython
/newtonApproximation.py
905
4.40625
4
# Jeremy Mach # Function to approximate a square root using Newton's algorithm def sqrt(x): estimate = float(x) approximation = 1.0 while abs(approximation - (estimate / approximation)) > (0.0001 * approximation): approximation = 0.5 * (approximation + (float(x) / approximation)) # When the a...
true
18bdaade58490386dcfc47784443ad2c3f871af6
K-Maruthi/python-practice
/variables.py
635
4.3125
4
# variables are used to assign values , variables are containers for storing values x = 7 y = "Hello World" print(x) print(y) #multiple values to multiple variables (no.of variables should be = no.of values) a,b,c = "orange",22,34.9 print(a) print(b) print(c) # mutliple variables same value p=q=r=2 print(p) print(q) p...
true
f20631d07fb9ce2dfcbb9c79114d497f9920011a
anhnguyendepocen/100-pythonExercises
/66.py
369
4.15625
4
# Exercise No.66 # Create an English to Portuguese translation program. # The program takes a word from the user and translates it using the following dictionary as a vocabulary source. d = dict(weather="clima", earth="terra", rain="chuva") # Solution def translate(w): return d[w] word = input("Enter the word 'ea...
true
af7d4d3637bf4ad38004e1fc1eae269ec73698cf
jeremy-wickman/combomaximizer
/combinationmaximizer.py
913
4.375
4
# A Python program to print all combinations of items in a list, and minimize based on target #Import from itertools import combinations import pandas as pd #Set your list of numbers and the target value you want to achieve numbers = [49.07, 122.29, 88.53, 73.02, 43.99] target = 250 combo_list = [] #Create a list of...
true
6c3f8a7b460c383133353a966a5aea62b71db49c
sunilmummadi/Hashing-1
/groupedAnagram.py
1,572
4.15625
4
# Leetcode 149. Group Anagrams # Time Complexity : O(nk) where n is the size of the array and k is the size of each word in the array # Space Complexity : O(nk) where n is the size of the array and k is the size of each word in the array # Did this code successfully run on Leetcode : Yes # Any problem you faced whi...
true
c661a44b75f35b7599fe3964f8808e57acbd5ed8
AlanOkori/Metodos-Numericos
/FuncPar.py
219
4.125
4
def even(Num): if Num % 2 == 0 : print("Is an even number.") else : print("Isn't an even number.") x = int(input("Please, insert a number: ")) even(x) input("Press key to continue.")
true
296c0ee856471edba71b14b43931c1219abf4ea2
sacobera/practical-python-project
/movie_schedule.py
601
4.1875
4
current_movies = {'The Grinch' : "11:00 am", 'Rudolph' : "1:00 pm", 'Frosty the snowman' : "3:00 PM", 'Christmas Vacation': "5:00 PM"} print ("We're showing the following movies:") for key in current_movies: #this loops over the list of objects print(key)...
true
78cbcdd59219ad25f80c5ee6a7ae9dc9cf4d9d51
Gindy/Challenges-PCC
/Challenges_PCC/Playing_cards/Playing_cards_3-1.py
1,196
4.28125
4
# A standard deck of cards has four suites: hearts, clubs, spades, diamonds. # Each suite has thirteen cards: # ace, 2, 3, 4, 5, 6, 7, 8, 9, 10, jack, queen and king cards = [] suits = ['Hearts'] royals = ["Jack", "Queen", "King", "Ace"] deck = [] # We start with adding the numbers 2 through 10. # Since t...
true
5a55a167f68f2c9cdb2431d6b6f17f6edab23fec
athwalh/py4e_ch9_solutions
/ex_94.py
897
4.125
4
#Exercise 4: Add code to the above program to figure out who has the most messages in the #file. After all the data has been read and the dictionary has been created, look #through the dictionary using a maximum loop (see Chapter 5: Maximum and minimum loops) to #find who has the most messages and print how many messag...
true
7bbf4efdaa89805899f195843f69704c034f7eb5
AadityaDeshpande/TE-Assignments
/SDL/pallindrome.py
366
4.4375
4
#input a string and check it is pallindrome or not #enter a word in a input and submit..!! s=input("Enter the string that is to be checked:") print(s) a=s t=False lnth=len(a) z=lnth-1 for i in range(len(a)): if a[z]!=a[i] or z<0: print("given string is not pallindrome") t=True break z=z-1 if t==False:...
true
9172ed8eb8747a678eb0809c3024adba350657bc
phuclhv/DSA-probs
/absolute_value_sort.py
828
4.28125
4
''' Absolute Value Sort Given an array of integers arr, write a function absSort(arr), that sorts the array according to the absolute values of the numbers in arr. If two numbers have the same absolute value, sort them according to sign, where the negative numbers come before the positive numbers. Examples: i...
true
c7c65f4e20a88881f77348987187501afd310887
jdst103/OOP-basics
/animal_class.py
1,469
4.125
4
# class Animal(): # # characterstics # def __init__(self, name, legs, eyes, claws, tasty): # if we dont follow order, use dictionary to define. # self.name = name # self.legs = legs # self.eyes = eyes # self.claws = claws # self.tasty = ta...
true
103e97a7fe67e1ead44bc00582b08e3013962273
sungfooo/pythonprojects
/hello.py
528
4.5
4
print "hello" variable = "value of the variable" data types #integers 123421 #float (with decimal) 123.23 #boolean True False #array (group of data types) [1,True,"string"] #dictionary or object #{""} #for loop - can be used to loop through arrays or objects one element at a time #for x_element in x_array_or_obj...
true
0e50dbf6b86984d6782b1940797eb9276c41f476
anandjn/data-structure_and_algorithms
/algorithms/sorting/bubble_sort.py
505
4.3125
4
'''implementing bubble sort TASK TIME-COMPLEXITY 1) bubbleSort O(n**2) ''' def bubbleSort(array): #repeat below steps until there seems no change for _ in range(len(array)): #keep swapping for i in range(len(array)-1): #if first number is greater than second then swap ...
true
46b83ee44a8a4645bfd9eff99dfa87be1591d587
jihoonyou/problem-solving
/Educative/subsets/example1.py
676
4.125
4
""" Problem Statement Given a set with distinct elements, find all of its distinct subsets. Example 1: Input: [1, 3] Output: [], [1], [3], [1,3] Example 2: Input: [1, 5, 3] Output: [], [1], [5], [3], [1,5], [1,3], [5,3], [1,5,3] """ def find_subsets(nums): subsets = [[]] for current_num in nums: le...
true
271fe07e5cd53ad165806d4848de1913ad66354c
sashank17/MyCaptain-Python-Tasks
/task5 - function most frequent.py
362
4.125
4
def most_frequent(string): string = string.lower() letters1 = {} for letter in string: c = string.count(letter) letters1[letter] = c letters = sorted(letters1.items(), key=lambda x: x[1], reverse=True) for i in letters: print(i[0], "=", i[1]) str1 = input("Please...
true
9e4246031adc055ca31af9e82ed617cd3942f9a2
BeijiYang/codewars
/7kyu/special_number.py
1,763
4.40625
4
''' Definition A number is a Special Number *if it’s digits only consist 0, 1, 2, 3, 4 or 5 * Task Given a number determine if it special number or not . Warm-up (Highly recommended) Playing With Numbers Series Notes The number passed will be positive (N > 0) . All single-digit numbers with in the interval [0:5] are...
true
da6c16ba70e42bf9fd1db6578b6a116563011989
Hassanabazim/Python-for-Everybody-Specialization
/1- Python for Everybody/Week_4/2.3.py
389
4.28125
4
''' 2.3 Write a program to prompt the user for hours and rate per hour using input to compute gross pay. Use 35 hours and a rate of 2.75 per hour to test the program (the pay should be 96.25). You should use input to read a string and float() to convert the string to a number. ''' hrs = float(input("Enter Hours:")) rph...
true
bf9348541d0a97db5d4c63cf34a01d65b43a5468
NathanJiangCS/Algorithms-and-Data-Structures
/SPFA.py
810
4.125
4
#Python implementation of shortest path faster algorithm #Implementation for weighted graphs. Graphs can have negative values infinity = float('inf') #a is the adjacency list representation of the graph #start is the initial node, end is the destination node def spfa(a, start, end): n = len(a) distances = [in...
true
716028bbd232b3c1b1ab81a8592238fb9dfc733f
ArcticSubmarine/Portfolio
/Python/hangmans_game.py
1,263
4.28125
4
## # This file contains an implementation of the hangsman's game. # The rules are the following : # 1) the computer choses a word (max. 8 letters) in a pre-defined list ; # 2) the player tries to find the letters of this word : at each try, he/she chose a letter ; # 3) if the letter is in the word, the compu...
true
afcd89a627b55a754ae64c577ed0e96c724f1873
daicorrea/my-project
/book_me_up/helpers/date_time.py
440
4.25
4
# Function to verify if param day is weekday or weekend def verify_weekday(date_to_verify): # Using regular expression to get the day of the week inside the parentheses from the inputted data day = date_to_verify[date_to_verify.find("(") + 1:date_to_verify.find(")")] if day in ['mon', 'tues', 'wed', 'thur',...
true
84661d9c5549561aaf66cef611e2454a9985492d
GemmaLou/selection
/selection dev 4.py
547
4.125
4
#Gemma Buckle #03/10/2014 #selection dev 4 grade check mark = int(input("Please enter your exam mark to receive your grade: ")) if 0<=mark<=40: print("Your grade is U.") elif 41<=mark<=50: print("Your grade is E.") elif 51<=mark<=60: print("Your grade is D.") elif 61<=mark<=70: print("You...
true
d833663e075a6d781691dedb79757dce251f45f3
lifewwy/myLeetCode
/Easy/566. Reshape the Matrix.py
1,787
4.1875
4
# Question: # # In MATLAB, there is a very useful function called 'reshape', which can reshape a # matrix into a new one with different size but keep its original data. # # You're given a matrix represented by a two-dimensional array, and two positive # integers r and c representing the row number and column number of ...
true
b11ee4f8692487cba17e93f741642dde1e7439d5
lifewwy/myLeetCode
/Easy/21. Merge Two Sorted Lists.py
2,112
4.1875
4
# Merge two sorted linked lists and return it as a new list. # The new list should be made by splicing together the nodes of the first two lists. # # Example: # # Input: 1->2->4, 1->3->4 # Output: 1->1->2->3->4->4 def println(l, N = 10): if not l: return print(l.val, end='\t') cursor = l.next ...
true
93f5cd0fbbcf5fdc5d568a6a8d2e5bed8154cbbe
trizzle21/advent_of_code_2019
/day_1/day_1.py
1,101
4.3125
4
""" Day 1 > Fuel required to launch a given module is based on its mass. Specifically, to find the fuel required for a module, take its mass, divide by three, round down, and subtract 2. > For example: > For a mass of 12, divide by 3 and round down to get 4, then subtract 2 to get 2. > For a mass of 14, dividing by 3...
true
09526c4fc46617c708a9199e4d9baafec3aaaf0c
Chris-Cameron/SNEL
/substitution.py
470
4.21875
4
#Helper Functions #"Inverts" the ASCII values of the characters in the text file, so that those at the beginning go towards the end and vice-versa def substitute(text): new_message = "" for t in text: new_message += chr(158-ord(t)) #158 is 32+126, which is why it is used for the inversion p...
true
82342cf39fd4969586140838a68af53bf7996ee9
mfarooq28/Python
/Convert_C2F.py
452
4.5625
5
# This program will convert the Celsius Temprature into Farenheit user_response = input (" Please Enter the Celsius Temprature :") celsius = float (user_response) farenheit = ((celsius*9)/5)+32 print ("The Equivalent Farenheit Temprature is :", farenheit , "degrees farenheit. ") if farenheit < 32 : print ("It is f...
true
b41f725cced2727a6b78fc29b0ad1b7feced471a
shubham-camper/Python-Course
/8. Lists.py
476
4.4375
4
friends = ["Kevin", "Karen", "Jim", "Oscar", "Toby"] #this is the list we have created print(friends) print(friends[0]) #this will print out the first element of the list print(friends[1:]) #this will print out 2nd till the last element of the list print(friends[1:3]) #this will print ...
true
bcc0bb8f659c22618267ed54d24129820d78022d
EvanGottschalk/CustomEncryptor
/SortDictionary.py
1,322
4.46875
4
# PURPOSE - This program is for sorting dictionaries class SortDictionary: # This function sorts a dict alphabetically and/or from least to greatest def sortDictByKey(self, dictionary): # Letter characters, numeric characters, and the remaining characters are # separated into 3 different dicts, e...
true
f87b9019600d9cd55a79e8abfbd1d5b37560f447
Prashidbhusal/Pythonlab1
/Lab exercises/question 7.py
452
4.28125
4
#Solve each of the following problems using pythone script . Makes sure you use appropriate variable names and comments. #When there is final answer , have python is to the screen. # A person's body mass index(BMI) is defined as: # BMI=(mass in kg) / (height in m)^2 mass=float(input('enter the mass of person in kg')...
true
17d573930ff954e98579728f47610e0dff7b1574
c0untzer0/StudyProjects
/PythonProblems/check_string.py
639
4.21875
4
#!/usr/local/bin/python3 #-*- coding: utf-8 -*- # # check_string.py # PythonProblems # # Created by Johan Cabrera on 2/15/13. # Copyright (c) 2013 Johan Cabrera. All rights reserved. # #import os #import sys #import re #import random #!/usr/local/bin/python3 # #check_string.py # strng = input("Please enter an upp...
true
0ee88afe44d3292f6f804dea107315db1dad55af
Payalkumari25/GUI
/grid.py
389
4.40625
4
from tkinter import * root = Tk() #creating the label widget label1 = Label(root,text="Hello world!").grid(row=0, column=0) label2 = Label(root,text="My name is Payal").grid(row=1, column=5) label3 = Label(root,text=" ").grid(row=1, column=1) # showing it into screen # label1.grid(row=0, column=0) # label2...
true
6a0b9a98469658afb2ed5d0f6a8ab1cc5d40509f
asiahbennettdev/Polygon-Classes
/polygon.py
2,742
4.4375
4
import turtle # python drawing board module """ Define polygon by certain amount of sides or name """ class Polygon: # trianlges, squares, pentagons, hexagons, ect. def __init__(self, sides, name, size=100, color="blue", line_thinckness=3): # initialize with parameters - whats import to a polygon? self.s...
true
387e8d3706a477ba4449fd49e049f9ccf81a55ea
shivangi-prog/Basic-Python
/Day 5/examples.py
650
4.1875
4
# Set Integers Temperature = int(input("Enter temperature:")) Humidity = int(input("Enter humidity percentage:")) # statements if Temperature >= 100: print("Cancel School, and recommend a good movie") elif Temperature >= 92 and Humidity > 75: print("Cancel schoool") elif Temperature > 88 and Humidity >= 85: ...
true
d0bfd16ddb5208109c3e8d1f826c6f1b269836c7
erickmiller/AutomatousSourceCode
/AutonomousSourceCode/data/raw/squareroot/cfff3ebc-345e-47c3-8afb-6fafaa13dae8__square_root.py
517
4.21875
4
# Find square root of a number # Apply the concept of a BST def square_root(n, precision): low = 0.0 high = n mid = (low+high)/2.0 # precision is the +/- error allowed in our answer while (abs(mid*mid-n) > precision): if (mid*mid) < n: low = mid elif (mid*mid) > n: ...
true
cb89573aca0ed58e385759b6918a1bbd090ca7ac
erickmiller/AutomatousSourceCode
/AutonomousSourceCode/data/raw/sort/9c1ed404-f5b4-4dc0-928c-59e23d75d315__bubble_sort.py
576
4.15625
4
# Sorting a list by comparing it's elements two by two and putting the biggest in the end def sort_two_by_two(ul): for index in range(len(ul)): try: el1 = ul[index] el2 = ul[index + 1] if el1 > el2: ul[index] = el2 ul[index +1] = el1 ...
true
33355877c07b4c62605de51f88829db01a0c07f0
erickmiller/AutomatousSourceCode
/AutonomousSourceCode/data/raw/squareroot/8d5d2074-ace0-410b-a057-28b3eed64467__sqrt_x.py
503
4.21875
4
""" Implement int sqrt(int x). Compute and return the square root of x. """ def mySqrt(self, x): """ :type x: int :rtype: int """ # the root of x will not bigger than x/2 + 1 if x == 0: return 0 elif x == 1: return 1 l = 0 r = x/2 + 1 while r >= l: mid ...
true
1924d3ebb5f9043df9435f96677ac2036d775e4d
erickmiller/AutomatousSourceCode
/AutonomousSourceCode/data/raw/squareroot/0385591b-6a56-4782-9052-1d9ab43f95f4__square_root.py
995
4.3125
4
""" Program that asks the user for a positive number and then outputs the approximated square root of the number. Use Newton's method to find the square root, with epsilon = 0.01. (Epsilon is the allowed error, plus or minus, when you square your calculated square root and compare it to your original number.) """ def...
true
d6d96a671376e09c522197179ec3e1a39e84c16e
erickmiller/AutomatousSourceCode
/AutonomousSourceCode/data/raw/squareroot/117291d5-df0d-4d90-a687-2c82344d1d55__RMSE.py
1,194
4.28125
4
#!/usr/bin/env python # ------- # RMSE.py # ------- def square_of_difference(x, y) : """ Squares the differences between actual and predicted ratings x is one rating from the list of actual ratings y is one rating from the list of predicted ratings return the difference of each actual and predicte...
true
5d2cfbe84e4aec18dccf9804220b0005a4d91328
erickmiller/AutomatousSourceCode
/AutonomousSourceCode/data/raw/squareroot/accf931e-a4c2-45b2-b2df-c999385ff178__ex13-random.py
528
4.28125
4
# the following program let the user play a game where he has to guess the square of # a random number # modify it as follow: # print the square of an natural number and let the player guess the square root. # the square root should be between 1 and 20 import random def askForNumber(): return int(raw_input("Enter...
true
738091fc3650a91d3146a6c31aee64629a33fdd7
erickmiller/AutomatousSourceCode
/AutonomousSourceCode/data/raw/squareroot/6d22552b-74ae-459d-bb4a-395727bbc2be__069-sqrt.py
471
4.125
4
#!/usr/bin/python # Implement int sqrt(int x). # Compute and return the square root of x. import sys # Binary search in range from 1 to x / 2. O(log(n)). def sqrt(x): if x == 0 or x == 1: return x i, j = 1, x / 2 while i <= j: m = (i + j) / 2 if m * m > x: j = m - 1 ...
true
ae33b275f221a81e7d91f603a22e0f44639540f8
erickmiller/AutomatousSourceCode
/AutonomousSourceCode/data/raw/squareroot/73ed9c98-ac54-4356-a553-5c6e12e44eb9__forPeopleNotComputers1.py
861
4.625
5
#!/usr/bin/env python # -*- coding: utf-8 -*- ############ EJEMPLO 1 ############ #Don't write what code is doing, this should be left for the code to explain and can be easily done by giving class, variable and method meaningful name. For example: t=10 #calculates square root of given number #using Newton-Raph...
true
8cb4a22012d691a4ac812cc456464935266ed16e
erickmiller/AutomatousSourceCode
/AutonomousSourceCode/data/raw/sort/0beb9f98-f5de-47a5-aef2-0f5af5117d90__front_x.py
966
4.28125
4
def front_x(words): x_list =[] non_x_list = [] sorted_list = [] for str in words: if str[0].lower().startswith("x"): x_list.append(str) else: non_x_list.append(str) print x_list, print non_x_list print type(x_list) print sorted(x_list) pri...
true
245a22eb50b7bc37e597a13048012fd994730915
erickmiller/AutomatousSourceCode
/AutonomousSourceCode/data/raw/squareroot/1a0efe9c-edb5-4b4a-9d1c-47aca8ecc3bf__main.py
441
4.4375
4
"""This function will approximate the square root of a number using Newton's Method""" x = float(input("Enter a positive number and I will find the square root: ")) def square_root(x): y = x/2 count = 0 while abs((y**2) - x) > 0.01: y = (y+x/y)/2 count += 1 print("After iterating {...
true
f9f788b0b38bc620286738c74daf9732a43ff3db
erickmiller/AutomatousSourceCode
/AutonomousSourceCode/data/raw/squareroot/d411c458-97e1-4a17-b22a-db46445f011a__square_root.py
485
4.125
4
# Python Code for Square Root num = int(input("Enter a positive number: ")) def newtonest(num): return num ** 0.5 def estimate(num): guess = num/3 count = 0 epsilon = 0.01 sq_guess = ((num / guess) + guess)/2 while abs(newtonest(num) - sq_guess) > epsilon: newguess = sq_guess ...
true
012814c4bdfb63d99d967a52027cf6d5b6ebeb8a
erickmiller/AutomatousSourceCode
/AutonomousSourceCode/data/raw/squareroot/04d69a32-54b4-4e9c-b998-1c8e7e844774__newtonsMethodOfSquares.py
253
4.25
4
def newtonSqrt(n): approx = 0.5 * n better = 0.5 * (approx + n/approx) while better != approx: approx = better better = 0.5 * (approx + n/approx) return approx x = float(input("what number would you like to square root?")) print (newtonSqrt(x))
true
faba2172b30a6e3f2a24895770f5210ede6367c7
erickmiller/AutomatousSourceCode
/AutonomousSourceCode/data/raw/squareroot/6d7d2e0c-b0a0-4f91-aad3-218cf30cf40c__sqroot.py
750
4.40625
4
''' Find the square root of n. Input: A number Output: The square root or the integers closest to the square root Assume: positive n Newton's method is a popular solution for square root, but not implemented here. ''' def sqrt(n): for number in range(0, n): if isSqrt(number,n): r...
true
e7ecfb257fcc00f8d2732024c7d7eccb8e188d3a
erickmiller/AutomatousSourceCode
/AutonomousSourceCode/data/raw/squareroot/54adae2c-fd4c-4b83-a622-a64f867c5643__sqrt.py
463
4.125
4
def sqrt(x): """ Calculate the square root of a perfect square""" if x >= 0: ans = 0 while ans * ans < x: ans += 1 if ans * ans == x: return ans else: print(x, "is not a perfect square") return None else: print(x, "is a ...
true
4e9d81dd456aff5c700a0c4570c1302317bedcd3
erickmiller/AutomatousSourceCode
/AutonomousSourceCode/data/raw/sort/ef081f79-c5e5-4dd5-9103-050da101fdfc__basic_sorts.py
2,674
4.46875
4
from heap import Heap def insertion_sort(array): """ Standard insertion sort alogrithm Arguments: array - array of numbers Returns: array - array sorted in increasing order """ for i in range(1, len(array)): j = i - 1 while j >= 0 and array[j] > array[i]: array[i], array[j] = array[j], array[i] ...
true
6d80392cc2a2c228de03adfaa95db8a6db11742f
erickmiller/AutomatousSourceCode
/AutonomousSourceCode/data/raw/squareroot/7e22a661-3c4e-4ed5-a12b-0916b621637d__Loops.py
1,308
4.15625
4
from sys import float_info as sfi def square_root (n): '''Square root calculated using Netwton's method ''' x = n/2.0 while True: y = (x + n/x)/2 # As equality in floating numbers can be elusive, # we check if the numbers are close to each other. if abs(y-x) < sfi.epsil...
true
9599518e6519acb4736f62141cc10e41d9b200e6
erickmiller/AutomatousSourceCode
/AutonomousSourceCode/data/raw/squareroot/83701c06-e19a-4c7b-87a6-fa1d10a49446__squareRootBisection.py
663
4.34375
4
"""Calculate the square cube of a float number""" __author__ = 'Nicola Moretto' __license__ = "MIT" def squareRootBisection(x, precision): ''' Calculate the square root of a float number through bisection method with given precision :param x: Float number :param precision: Square root precision :r...
true
9dc5ed37a27c4c98b989e3bdf2166427e52fcd9a
erickmiller/AutomatousSourceCode
/AutonomousSourceCode/data/raw/sort/96237146-8b34-46ec-99b8-6c2b8cc9d4af__mergesort.py
712
4.15625
4
def merge(a, b): """Merging subroutine. Meant to merge two sorted lists into a combined, sorted list.""" n = len(a) + len(b) d = [0 for i in range(n)] i = 0 j = 0 for k in range(n): if a[i] < b[j]: d[k] = a[i] if i+1 > len(a)-1: for l in b[j:]: d[k+1] = b[j] k += 1 j += 1 return d ...
true
975976dac5dcdacbf94c3c7b5d37973ab501e3a1
erickmiller/AutomatousSourceCode
/AutonomousSourceCode/data/raw/sort/39cf0f2e-d6c1-4606-9e97-3f60bda3a6a1__merge_sort_improved.py
1,024
4.40625
4
# Merge Sort def merge(left, right): """Merges two sorted lists. Args: left: A sorted list. right: A sorted list. Returns: The sorted list resulting from merging the two sorted sublists. Requires: left and right are sorted. """ items = [] i = 0 j = 0...
true
0509c69d4ad62a01518607588f61468cb4aa8ada
erickmiller/AutomatousSourceCode
/AutonomousSourceCode/data/raw/squareroot/d302ddc9-b885-4379-b5c8-13288906db2a__HeronsMethod.py
1,674
4.40625
4
#!/usr/bin/env python """ This script is an implementation of Heron's Method (cs.utep.edu/vladik/2009/olg09-05a.pdf), one of the oldest ways of calculating square roots by hand. The script asks for maximum number of iterations to run, the square root to approximate, and the initial guess for the square root. Each succ...
true
1a9e104e93631dc74a90e6768991dee980bbadb8
erickmiller/AutomatousSourceCode
/AutonomousSourceCode/data/raw/sort/f72b109f-64e1-42d5-a0ed-fcaf72e805a5__bubble_sort.py
491
4.125
4
from create_list import random_list, is_sorted def bubble_sort(my_list): """ Perform bubble sort on my_list. """ while not is_sorted(my_list): for i in range(len(my_list) - 1): if my_list[i] > my_list[i + 1]: my_list[i], my_list[i + 1] = my_list[i + 1], my_list[i] ...
true
72c1e0aa39f4022e3483e98d4a586e3b00032d71
erickmiller/AutomatousSourceCode
/AutonomousSourceCode/data/raw/sort/b104d935-486f-4ca1-b317-bf78949d3ae0__sort.py
1,591
4.34375
4
# Executes merge sort on an unsorted list # Args: # items: Unsorted list of numbers # # Returns: # Sorted list of items def merge_sort(unsorted_list): # If unsorted_list is length = 1, then it's implicitly # sorted. Just return it. Base case. if len(unsorted_list) == 1: return unsorted_list # Create two n...
true
c5172eca5772e56a8ee0cd1f5dc7df51d72db5d1
erickmiller/AutomatousSourceCode
/AutonomousSourceCode/data/raw/sort/67a0a05e-aeae-4325-9ac2-e56575c7747b__insertion.py
671
4.125
4
def sort(coll): ''' Given a collection, sort it using the insertion sort method (sorted by reference). O(n^2) performance O(n) storage :param coll: The collection to sort :returns: The sorted collection ''' for j in range(1, len(coll)): k = coll[j] i = j - 1 w...
true