blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
012ab172576e4caa22fa0661ae304825a6e0f3a5
Linh-T-Pham/Study-data-structures-and-algorithms-
/merge_ll.py
2,625
4.15625
4
""" Merge Linked Lists Write a function that takes in the heads of two singly Ll that are in sorted order, respectively. The function should merge the lists in place(i.e, it should not create a brand new list and return the head of the merged list; the merged list should be in sorted order) Each l...
true
1cca158cb53fe6acf0e9c972240e43af6f30efe1
Linh-T-Pham/Study-data-structures-and-algorithms-
/recursion2.py
596
4.5
4
"""Write a function, reverseString(str), that takes in a string. The function should return the string with it's characters in reverse order. Solve this recursively! Examples: >>> reverseString("") '' >>> reverseString("c") 'c' >>> reverseString("internet") 'tenretni' >>> reverseString("fr...
true
7cb17368d61a76b8bda586fdb12c656cf9f4f37f
Timothy-py/Python-Challenges
/Factorial.py
986
4.40625
4
# A Python program to print the factorial of a number # L1 - This line of code creates a variable named 'multiplier' which will # be used to save the successive multiplications and it # is initialized to 1 because it will be used to do the first multiplication # L3 - Prompt the user to enter a number and save the numb...
true
ca3c224af2531b5777378548a13d2cb2e980bd8a
aloysiogl/CES-22_solutions
/Bimester1/Class1/ex6/exercise6.py
1,316
4.40625
4
#!/usr/bin/python3 import turtle from time import sleep # Question # Use for loops to make a turtle draw these regular polygons (regular means all sides the same # lengths, all angles the same): # ◦ An equilateral triangle # ◦ A square # ◦ A hexagon (six sides) # ◦ An octagon (eight sides) # Function for drawing p...
true
7d7fe99aa3c635252af1a6d74b987fd0ec42c5ba
aloysiogl/CES-22_solutions
/Bimester1/Class6/decorators/decorators.py
1,014
4.3125
4
#!/usr/bin/python3 def round_area(func): """ This decorators rounds the area :param func: area function :return: the rounded area function """ def round_area_to_return(side): """ This function calculates the rounded area to 2 decimal digits :param side: the side of the...
true
f34db4522943068e6e25c0984a6bc52859e92c3a
kbalog/uis-dat630-fall2016
/practicum-1/tasks/task4.py
1,090
4.5625
5
# Finding k-nearest neighbors using Eucledian distance # ==================================================== # Task # ---- # - Generate n=100 random points in a two dimensional space. Let both # the x and y attributes be int values between 1 and 100. # - Display these points on a scatterplot. # - Select one of ...
true
dac2cb25d763900c9b477c0ec27f813b500e2d89
newbieeashish/datastructures_algo
/ds and algo/linkedlist,stack,queue/falttenLL.py
2,556
4.34375
4
'''Suppose you have a linked list where the value of each node is a sorted linked list (i.e., it is a nested list). Your task is to flatten this nested list—that is, to combine all nested lists into a single (sorted) linked list.''' #creating nodes and linked List class Node: def __init__(self,value): ...
true
a6412b37f0cbd97d812d04f6edb564fb43c19b31
newbieeashish/datastructures_algo
/ds and algo/Sorting_algos/counting_inversions.py
2,026
4.15625
4
'''Counting Inversions The number of inversions in a disordered list is the number of pairs of elements that are inverted (out of order) in the list. Here are some examples: [0,1] has 0 inversions [2,1] has 1 inversion (2,1) [3, 1, 2, 4] has 2 inversions (3, 2), (3, 1) [7, 5, 3, 1] has 6 inversions (7, 5), (3...
true
d25ae8395ca06e243b00f3041c19c90c9402377a
mahasahyoun/python-for-everybody
/ch-2/gross-pay.py
586
4.1875
4
""" 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. Do not worry about error checking or bad user ...
true
6e161afe596049d1f120fbc2e8ad3f7cd41e411c
patrickForster/Sandbox
/password_entry.py
388
4.25
4
# password checker MIN_LENGTH = 4 print("Please enter a valid password") print("Your password must be at least", MIN_LENGTH, "characters long") password = input("> ") while len(password) < MIN_LENGTH: print("Not enough characters!") password = input("> ") hidden_password = len(password)*'*' print("Your {}-chara...
true
f7b19217b3ef9895ba0151e729e668e2f7e962cf
ericdong66/leetcode-50
/python/48.search_insert_position.py
1,101
4.1875
4
# Given a sorted array and a target value, return the index if the target is # found. If not, return the index where it would be if it were inserted in # order. # # You may assume no duplicates in the array. # # Here are few examples. # [1,3,5,6], 5 -> 2 # [1,3,5,6], 2 -> 1 # [1,3,5,6], 7 -> 4 # [1,3,5,6], 0 -> 0 # # T...
true
222c0630766643a98e24c8218c8bf148fd2c514d
h3llopy/web-dev-learning
/Learn Python the Hard Way/exercises/ex03.py
812
4.53125
5
print "I will now count my chickens:" # These print out the answer after a string. # The numbers are turned into floating point numbers with a decimal point and zero at the end for accuracy. print "Hens", 25.0 + 30.0 / 6.0 print "Roosters", 100.0 - 25 * 3 % 4 print "Now I will count the eggs" # This prints out the a...
true
387d986223c06ade6346901334c275f70ae5b89f
xcobaltfury3000/baby-name-generator
/Baby_name_generator.py
2,466
4.40625
4
print ("Hello world") import string print(string.ascii_letters) print(string.ascii_lowercase) #since we want a random selection we import random import random #from random library we want to utilize choice method print(random.choice("pullaletterfromhere")) print(random.choice(string.ascii_lowercase)) letter_input_1...
true
d5507e8d1e4565bf343205fcf933096abeead382
AtharvaDahale/Python-BMI-Calculator
/Python BMI Calculator.py
529
4.34375
4
height = float(input("Enter your height in centimeters: ")) weight = float(input("Enter your weight in Kg: ")) height = height/100 BMI = weight/(height*height) print("Your BMI is: ",BMI) if (BMI > 0): if(BMI<=16): print("Your are severely underweight") elif(BMI<=18.5): print("you are un...
true
82f5c6de2568a82c08a8e6f17427b6478277309b
khanmaster/eng88_python_control_flow
/control_flow.py
1,721
4.3125
4
# Control Flow with if, elif and else - loops weather = "sunny" if weather == "thinking": # if this condition is False execute the next line of code print("Enjoy the weather ") # if true this line will get executed if weather != "sunny": print(" waiting for the sunshine") if weather == "cloudy": print("...
true
404d754f6ee9882e6eac12318f3847c3c46d2a9f
s-anusha/automatetheboringstuff
/Chapter 8/madLibs.py
1,814
4.78125
5
#! python3 # madLibs.py ''' Create a Mad Libs program that reads in text files and lets the user add their own text anywhere the word ADJECTIVE, NOUN, ADVERB, or VERB appears in the text file. For example, a text file may look like this: The ADJECTIVE panda walked to the NOUN and then VERB. A nearby NOUN was unaffecte...
true
85d73fc37042cddd112601a2f4a8f013bf569685
s-anusha/automatetheboringstuff
/Chapter 13/brute-forcePdfPasswordBreaker.py
1,721
4.5
4
#! python3 # brute-forcePdfPasswordBreaker ''' Say you have an encrypted PDF that you have forgotten the password to, but you remember it was a single English word. Trying to guess your forgotten password is quite a boring task. Instead you can write a program that will decrypt the PDF by trying every possible English ...
true
e242498ad2180dd426cb2aa1b4cdbe86586e96d6
s-anusha/automatetheboringstuff
/Chapter 6/tablePrinter.py
1,784
4.71875
5
#! python3 # tablePrinter.py ''' Write a function named printTable() that takes a list of lists of strings and displays it in a well-organized table with each column right-justified. Assume that all the inner lists will contain the same number of strings. For example, the value could look like this: tableData = [['app...
true
8bae9a502d852cc6497e804361ba331e80c0b82c
rafiulalam2112/Age-ganaretor
/age_generator.py
530
4.34375
4
print('Hello! I am Rafi Robin. This is my python project.') print('This tool genarate your age :)') now_year=2021 birth_year=int(input('Inter your birth year :')) #When a user input a number the value save as string. To make the input as number use int() . age=(now_year-birth_year) print(f'You are {age} years old...
true
5327adf41dc51315c97e8b473b5709acc6efa7c0
elacuesta/euler
/solutions/0004.py
620
4.28125
4
""" A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 × 99. Find the largest palindrome made from the product of two 3-digit numbers. """ def is_palindrome(n): return list(str(n)) == list(reversed(str(n))) def palindrome(factor_lengt...
true
0f804f75088a1504d0365012cd9ab5e2ec4b16b3
jsonw99/Learning-Py-Beginner
/Lec04(ListAndTuple).py
1,482
4.40625
4
# list ################################################################ classmates = ['Micheal', 'Bob', 'Tracy'] print(classmates) type(classmates) len(classmates) print(classmates[0]) print(classmates[1]) print(classmates[2]) print(classmates[3]) print(classmates[-1]) print(classmates[-2]) print(classmates[-3]) prin...
true
3f693e3ac2a3ca646480defe121ca735abcf664e
jai-somai-lulla/Sem8
/Legacy/ML/LinearRegression/grad.py
1,201
4.1875
4
import numpy as np import pandas as pd #import matplotlib.pyplot as plt def cost_function(X, Y, B): if(type(Y) == np.int64): m=1 else: m = len(Y) J = np.sum((X.dot(B) - Y) ** 2)/(m*2) return J def gradient_descent(X, Y, B, alpha, iterations): cost_history = [0] * iterations m = len...
true
8d0778ee4429cf201fca2e368e9d8c07a1c0f25e
THE-SPARTANS10/Python-Very-Basics
/user_input.py
211
4.1875
4
#By default in python for user input we get everything as string name = input("Enter your name: ") value = input("Enter a number: ") print("your name is " + name + " and your favourite number is: " + value)
true
5b269c95f2eeed5db00155b1a25feed94cd56bfe
TomiwaJoseph/Python-Scripts
/emirp_numbers.py
745
4.34375
4
''' An emirp is a prime that results in a different prime when its decimal digits are reversed. Example: Input: 13 Output: True (13 and 31 are prime numbers) Input: 23 Output: False (23 is prime but 32 is not) Input: 113 Output: True (113 and 311 are prime numbers) ''' print() def know_prime(number): return n...
true
cfab197d408c4a376f486922b7f7c6bbd0377304
TomiwaJoseph/Python-Scripts
/neon_numbers.py
532
4.1875
4
''' A number is considered Neon if the sum of digits of the square of the number is equal to the number itself. Example: Input: 9 9 * 9 == 81 8 + 1 == 9 Output: True ''' print() def neon(number): squared = number ** 2 sum_of_digits = sum([int(i) for i in str(squared)]) return sum_of_digits == number ...
true
bebc9c33456253aac57a78dd4dbf58b3854b75c3
TomiwaJoseph/Python-Scripts
/twin_prime_numbers.py
795
4.15625
4
''' A Twin prime is a prime number that is either 2 less or 2 more than another prime number. For example: (41,43) or (149,151) Example: Input: 0,15 Output: (3,5),(5,7),(11,13) ''' print() def check_prime(number): return number > 1 and not any(number % n ==0 for n in range(2, number)) def twin_prime(number): ...
true
0c2ecd13b13a498ff90c14f10cd2d710c07c56da
TomiwaJoseph/Python-Scripts
/anti-lychrel_numbers.py
1,245
4.125
4
''' An anti-Lychrel number is a number that forms a palindrome through the iterative process of repeatedly reversing its digits and adding the resulting numbers. For example 56 becomes palindromic after one iteration: 56+65=121. If the number doesn't become palindromic after 30 iteratioins, then it is not an anti-Lychr...
true
a091e96b64e922d1c06701fa93a5bafe24258fd3
jchaclan/python
/cat.py
580
4.25
4
# Given the below class: class Cat: species = 'mammal' def __init__(self, name, age): self.name = name self.age = age # 1 Instantiate the Cat object with 3 cats cat1 = Cat('Freddy', 10) cat2 = Cat('Manny', 8) cat3 = Cat('Lucy', 9) # 2 Create a function that finds the oldest c...
true
f825c3e3fd51e813ae357890221d8287edb9f09b
brianbruggeman/lose-7drl
/lose/utils/algorithms/pathing.py
2,765
4.3125
4
# -*- coding: utf-8 -*- import operator import heapq from .distances import log_distance def create_dijkstra_map(graph, start, target=None, cost_func=None, include_diagonals=None): """Creates a dijkstra map Args: graph (list): a set of nodes start (node): the starting position target ...
true
d69954226bd6d65bb7d9fb405a1f21c95a5c55bf
brianbruggeman/lose-7drl
/lose/utils/algorithms/distances.py
2,737
4.5
4
# -*- coding: utf-8 -*- import math from itertools import zip_longest as lzip def manhattan_distance(x, y): """Calculates the distance between x and y using the manhattan formula. This seems slower than euclidean and it is the least accurate Args: x (point): a point in space y (point...
true
4c300e2170cb75b47518e284b545201cfaafd0af
aineko-macx/python
/ch16/16_6.py
2,019
4.28125
4
import copy class Time(object): """Represents a time in hours, minutes, and seconds. """ def print_time(Time): print("%.2d: %.2d: %.2d" %(Time.hour, Time.minute, Time.second)) def add_time(t1, t2): sum = Time() sum.hour = t1.hour + t2.hour sum.minute = t1.minute + t2.minute sum.second = ...
true
f55cd76dfe5ccb409039ae8f53b69d48ffd33677
aineko-macx/python
/ch17/17_1.py
892
4.25
4
class Time(object): """Represents the time of day. """ def __init__(self, hour = 0, minute = 0, second = 0): self.hour = hour self.minute = minute self.second = second def print_time(self): print("%.2d: %.2d %.2d" %(self.hour, self.minute, self.second)) def time_t...
true
6d9f449312a335671fd358bf0482486d59eab245
SoniaB77/Exercise_12_Collections
/exercise12.2.py
267
4.25
4
tup = 'Hello' print(len(tup)) print(type(tup)) # this is a string so the length is checking the iterables of the string which is 5. tup = 'Hello', print(len(tup)) print(type(tup)) # this is a tuple so it is checking the iterables but of a tuple so this outputs 1.
true
11d167121472792a525554e7d54d1bed829a641c
ProgrammingForDiscreteMath/20170823-bodhayan
/code.py
2,748
4.46875
4
""" This is the code file for Assignment from 23rd August 2017. This is due on 30th August 2017. """ ################################################## #Complete the functions as specified by docstrings # 1 def entries_less_than_ten(L): """ Return those elements of L which are less than ten. Args: ...
true
b6c12ae165a10fa29347189009f7e60edba15f91
215shanram/lab4
/lab4-exercise4.py
1,163
4.25
4
import sqlite3 #connect to database file dbconnect = sqlite3.connect("lab4.db"); #If we want to access columns by name we need to set #row_factory to sqlite3.Row class dbconnect.row_factory = sqlite3.Row; #now we create a cursor to work with db cursor = dbconnect.cursor(); #execute insetr statement cursor.execute('''in...
true
76b8b31d7c66daa0600fe3d738803c15899c544c
btab2273/functions
/path_exists.py
946
4.3125
4
# Define path_exists() def path_exists(G, node1, node2): """ Breadth-first seach algorithim This function checks whether a path exists between two nodes( node1, node2) in graph G. """ visited_nodes = set() # Initialize the queue of cells to visit with the first node: queue queue = [node1] # Iterate over the n...
true
b644ba60f87f1ff5c4bdfa9311698112fd6f59a1
paul-tqh-nguyen/one_off_code
/old_sample_code/misc/vocab/vocab.py
1,572
4.40625
4
#!/usr/bin/python # Simple program for quizzing GRE vocab import random import os if __name__ == "__main__": os.system("clear") definitions = open('./definitions1.csv', 'r') # load GRE words from .csv file # We want to split the words by part of speech so that when quizzing, the quizzee cannot guess the answe...
true
654e9a81c02402214df6d7f0e3f2ba226375d205
sanika2106/if-else
/next date print.py
826
4.34375
4
# Write a Python program to get next day of a given date. # Expected Output: # Input a year: 2016 # Input a month [1-12]: 08 # Input a day [1-31]: 23 # The next date is...
true
c516eed37f3a04549028b078464756a786711002
sanika2106/if-else
/16link.py
429
4.1875
4
# c program to check weather the triangle is equilateral ,isosceles or scalene triangle side1=int(input("enter the number:")) side2=int(input("enter the number:")) side3=int(input("enter the number:")) if(side1==side2 and side2==side3 and side1==side3): print("it's a equilateral triangle") elif(side1==side2 or sid...
true
b60fe06fd61994d24e2c6292c0266f2179d1ced9
sanika2106/if-else
/q13.py
658
4.15625
4
age=int(input("enter the number")) if age>=5 and age<=18: print("can go to school") elif age>=18 and age<=21: print("""1.can go to school, 2.can vote in election""") elif age>=21 and age<=24: print("""1.can go to school, 2.can vote in election, 3.can drive a car""") elif age >=24 ...
true
4c7c531576a1c5fd956a08ec5dfc454509604ec0
sanika2106/if-else
/prime number.py
306
4.21875
4
#prime number num=int(input("enter the number:")) if num==1 or num==0: print("not a prime number") elif num%2!=0 and num%3!=0 and num%5!=0 and num%7!=0: print("prime number") elif num==2 or num==3 or num==5 or num==7 : print("it is also a prime number") else: print("not a prime number")
true
720179901f16379215f0160e45b410f039462b33
A-Chornaya/Python-Programs
/LeetCode/same_tree.py
1,823
4.15625
4
# Given two binary trees, write a function to check if they are the same or not. # Two binary trees are considered the same if they are structurally identical and the nodes have the same value. ''' Example 1: Input: 1 1 / \ / \ 2 3 2 3 [1,2,3], [1,2,3] Output: t...
true
d5efc35e0ef0f9c25258247625e9063c8fdd5a92
AhmedFakhry47/Caltech-Learn-from-data-cours-homework-
/PLA.py
736
4.15625
4
''' A simple code (Script) to illustrate the idea behind perception learning algorithm ''' import numpy as np import matplotlib.pyplot as plt ##First step is generating data D = np.random.rand(3,1000) threshold = .4 #target function represented in weights f = np.array([0.2,0.8,0.5]).reshape((3,1)) Y = ...
true
486705e17f2ad4eb0ad7a421deb1319818f4142d
umeshchandra1996/pythonpractice
/palindrome.py
312
4.1875
4
num=int(input("Enter the number ")) numcopy=num #copy num for compare whith reverse reverse=0 while num>0: reminder=num%10 #find reminder reverse=(reverse*10) + reminder num//=10 if(numcopy == reverse): print("Yes It is a plaindrome number ") else: print("It is not plaindrome number ")
true
52b50a64102f7813ab4c7dc2a20df989963965e9
Nsk8012/30_Days_Of_Code
/Day_5/2_List_with_value.py
780
4.53125
5
# Initialing the value fruits = ['banana', 'orange', 'mango', 'lemon', 'apple'] print('Fruits:', fruits) print('Length of Fruits List:', len(fruits)) # List can have items of different data types. lst = ['Nishanth', 15, True, {'Country': 'India', 'City': 'Coimbatore'}] print(lst) # Index of list # [a, b, c, d, e] # 0...
true
265d3fe67eefc5514a347f467ef3e2d4639b174f
Nsk8012/30_Days_Of_Code
/Day_8/1_Creating_Dictionaries.py
504
4.1875
4
# 30_Days_Of_Code # Day 8 # Dictionary will have key:value. empty_dict = {} # Dictionaries with Values dct = {'Key1': 'Value1', 'Key2': 'Value2', 'Key3': 'Value3', 'Key4': 'Value4'} print(dct) # len is used to find the length od dicitionaries print(len(dct)) # Accessing Dictionary Items by calling keys init. print(d...
true
719da2eb3374940257fa83a687556275a47f2351
BlaiseGD/FirstPythonProject
/RockPapScis.py
1,963
4.3125
4
from random import randrange reset = 'y' while reset == 'y': print("This is rock, paper, scissors against a computer!\ny means yes and n means no\nEnter 1 for rock, 2 for paper, or 3 for scissors") #1 is rock 2 is paper 3 is scissors for compInput computerInput = randrange(1, 4) userInput = int(input())...
true
b2d81645b2694214cc0b952a6f0abc694113c8d2
nstrickl87/python
/working_with_lists.py
2,909
4.28125
4
#Looping Through Lists magicians = ['alice', 'david', 'carolina'] for magician in magicians: print(magician) #More WOrk in a Loop magicians = ['alice', 'david', 'carolina'] for magician in magicians: print(magician.title()) #makign Numerical Lists using the range function #Range off by one starts counting fro...
true
6c6293507679501315a1dcf6b5816ce937dc1d42
BC-csc226-masters/a03-fall-2021-master
/a03_olorunpojuessangd.py
1,267
4.1875
4
# Author: David Olorunpoju-Essang # Username: olorunpojuessangd # Assignment: A03: Fully Functional Gitty Psychedelic Robotic Turtles # Purpose: Draws a fractal tree #Reference : https://www.youtube.com/watch?v=RWtNQ8RQkO8 #Google doc link: https://docs.google.com/document/d/1AVxiZuugCxoRw1HFxaOiRBXjW_VQFrHNXVA4CwW8-q...
true
732fb7258b5baae253205e6fbf4c21c49948f15b
rupeshkumar22/tasks.py
/basic/fibonacci.py
1,179
4.25
4
from typing import List def matrixMul(a, b): """ Returns the product of the given matrices """ # Initializing Empty Matrix c = [[0, 0], [0, 0]] # 2x2 matrix multiplication. Essentially O(1) for i in range(2): for j in range(2): for k in range(2): c[i...
true
6b63098f3c1fdeb2fe23804b79d7881edbbbd8a5
MRajibH/100DaysOfCode
/DAY07/classes.py
678
4.21875
4
# OOP - Programming Paradigm # In OOP we think about world in terms of objects # Objects might store information or support the ability todo some operations # OOP helps you to create new types or you can say customized types e.g. 2D Values # class = A templete for a type of objects class point(): # It'll called a...
true
f02d92449a70f0e6365fb7ce764bfb91cbdef928
azarateo/bnds
/python_workspace/as/unicode.py
207
4.15625
4
print('Hello. This program will show you different unicode characters,'+ 'well at least the ones Python 3 can print') for x in range(32, 127): print "Character with number %d is %s in hex %X" % (x,x,x)
true
8bc79e0d2a65ddca96589a3659beed116986b221
garikapatisravani/PythonDeepLearning
/ICP2/StringAlternative.py
311
4.21875
4
# Author : Sravani Garikapati # program that returns every other char of a given string starting with first # Ask user to enter a string s = str(input("Enter a string: ")) # Use slicing to get every other character of string def string_alternative(s): print(s[::2]) if __name__ == '__main__': string_alternative(...
true
1dca25eb10e1ea42cfaa5efada2c760a0d177f3a
rgraveling5/SDD-Task2a---Record-Structure-Lists-
/main.py
973
4.28125
4
#Record structure #Rachael Graveling #28/08/2020 # List to store all records student_records = [] # Number of records number_of_students = 3 # Loop for each student for x in range(number_of_students): student = [] student.append(input('Please enter name: ')) student.append(float(input('Please enter a...
true
1f0b4de15cf6e721462a4a7f1eb0384e082759f0
Aneesh540/python-projects
/NEW/one.py
1,237
4.125
4
""" 1) implementing __call__ method in BingoCage class which gives it a function like properties""" import random words = ['pandas', 'numpy', 'matplotlib', 'seaborn', 'Tenserflow', 'Theano'] def reverse(x): """Reverse a letter""" return x[::-1] def key_len(x): """Sorting a list by their length""...
true
44f1fc9e2a4a0d4daf2dfb19f95b68c4242dd23f
Aneesh540/python-projects
/closures/closures2.py
761
4.3125
4
""" A closure is a inner function that have access to variables in the local scope in which it was created even after outer function has finished execution""" import logging def outer_func(msg): message=msg def inner_func(): # print(message) print(msg) return inner_func hello=outer_func('hello') pri...
true
4de9a04857f0e838acb52dba77a7ba5a98c303d7
meghaggarwal/Data-Structures-Algorithms
/DSRevision/PythonDS/bst.py
809
4.125
4
from dataclasses import dataclass @dataclass class Bst(): data:int left:object right:object def insertNode(data, b): if b is None: return Bst(data, None, None) if data < b.data: b.left = insertNode(data, b.left) else: b.right = insertNode(data, b.right) return b b = None b = i...
true
c24699269a2bdc789332da8b5a523930e6a0d616
mike1806/python
/udemy_function_22_palindrome_.py
439
4.25
4
''' Write a Python function that checks whether a passed string is palindrome or not. Note: A palindrome is word, phrase, or sequence that reads the same backward as forward, e.g., madam or nurses run. ''' def palindrome(x): x = x.replace(' ','') # This replaces all spaces " " with no space ''. (Fixes is...
true
bf9d8f5013c8791f8df90f0f9c50095ed39de6cc
cpd67/Languages
/Python/Python3/Practice3.py
1,911
4.1875
4
#Python program for counting the number of times a letter appears in a string. #Also, learned that locals are NOT reassigned in for loop... def findMax(lis): """Finds the max element in a list.""" index = [0] m1 = [-999999999] #Special use case: empty list if len(lis) == 0: return -1, -1 #Special use case: lis...
true
f0cc6b193e1a77e194295927cea914fe3f1c7424
cpd67/Languages
/Python/Python3/Practice5.py
573
4.25
4
#!/bin/python # Dice Rolling Simulator # THIS CODE ONLY WORKS WITH PYTHON3 import random MIN = 1 MAX = 7 def rollDice(): print("Let's roll some dice!") print("Rolling...") print("The dice roll is: " + str(random.randrange(MIN, MAX))) rollDice() while True: x = input('Would you like to roll again? '...
true
d1acf74226395891e904adb871c7adad36c15ef4
Wattabak/quickies
/selection-sort-python/selection_sort.py
2,371
4.1875
4
""" Time complexity: Worst case: [Big-O] O(n^2) Average case: [Big-theta] ⊝(n^2) Best case: [Big-Omega] Ω(n^2) How it works: - find the position of the minimum element; - swap this element with the first one (because in the sorted array it should be the first); - now regard the sub-array of length N-1, w...
true
2b3155ea06158cec47b36bc822688f83024aeccf
do-py-together/do-py
/examples/quick_start/nested.py
1,369
4.15625
4
""" Nest a DataObject in another DataObject. """ from do_py import DataObject, R class Contact(DataObject): _restrictions = { 'phone_number': R.STR } class Author(DataObject): """ This DataObject is nested under `VideoGame` and nests `Contact`. :restriction id: :restriction name:...
true
80c95e36826f3d3aa0c32986f35024d67b8e7609
carlagouws/python-code-samples
/How tall is the tree.py
1,167
4.21875
4
# ****************************************************************************************** # Description: # Program asks the user how tall the tree is # User inputs the height of the tree in number of rows, e.g. "9" produces a height of 9 rows ''' How tall is the tree : 5 # ### ...
true
4f624c48797695f31507d40cf0c0a84b15fad99c
krishankansal/PythonScripts
/Files/e.py
511
4.1875
4
def count_the(filename): ''' Total number of appeareances of word 'the' in file''' try: f = open(filename) contents = f.read() appeareances = contents.lower().count('the') print(f"The file {filename} has word 'the' appereared {appeareances}. times") except FileNotFoundError: ...
true
dd7ad1c4bb038caab7a793e4b24ff4b657b8dc8c
Bryantmj/iteration-1
/iteration.py
2,203
4.15625
4
# Make a local change # Make another local change # Make a change from home # iteration pattern # [1, 5, 7 ,8 , 4, 3] def iterate(list): # standard for loop with range # for i in range(0, len(list)): # print list[i] # for each loop for item in list: print item def print_list(list): print "" def add_one(l...
true
de773b5afd4597a2f89027b50b0f75a89a530085
VinceSevilleno/variables
/developmentexercise2.py
373
4.375
4
#Vince Sevilleno #24/09/2014 #Development Exercise 2 print("This program will convert a given value in degrees Fahrenheit into degrees Centigrade:") print() fahrenheit=int(input("Please enter any value of temperature:")) centigrade=(fahrenheit-32)*(5/9) print() print("The value {0} degrees Fahrenheit is equa...
true
d60cc8f46dbf6738555f7a715869f1e38e7ca033
girl-likes-cars/MIT_programming_course
/Newton square root calculator.py
577
4.21875
4
# -*- coding: utf-8 -*- """ Created on Sun Jun 24 16:52:15 2018 @author: Maysa """ #Set the epsilon and the square root you want to find #Pick a random starting point for your guess (let's say, guess/2) epsilon = 0.01 k = int(input("Give me a number whose square root you want to find! ")) guess = k/2.0 ...
true
eb4481b19aa8e9c0116ae88a69b596192a05cf9c
AlvaroMenduina/Jupyter_Notebooks
/Project_Euler/41.py
1,564
4.125
4
""" Project Euler - Problem 41 We shall say that an n-digit number is pandigital if it makes use of all the digits 1 to n exactly once. For example, 2143 is a 4-digit pandigital and is also prime. What is the largest n-digit pandigital prime that exists? """ import numpy as np import itertools def is_prime(n): ...
true
fcf684ff90ae780d7070caef6ecfced3749e5c8c
Charlieen/python_basic
/python_tutorial/NumberAndString.py
2,942
4.3125
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Mon Feb 8 09:13:37 2021 @author: dzgygmdhx """ # print(2+2) # print(8/3) # print(17//3) # print(17%3) # print(5**2) width =20 height= 3*9 print(width * height) # begin string '' " " \ \n r print('I like "you", but "you" do not like me') print("I like ...
true
a5e324794898c9ed9a024dcb506366e9617c1694
mvimont/FoundationsofMeasurement
/Chapter1/ThreeProceduresBasicMeasurement/Ordinal/ordinal.py
1,948
4.21875
4
import sys import random #Covers contens of Chapt 1, 1.1.1 pages 2 - 3 #Purpose here to define fundamental concepts (greater than, addition, etc) in definition/conditions used in book #length is here used as means to illustrate attribution of quantities to qualitative observations #transitive property def is_greater(...
true
029d436bddee58022eaa2c619b3adccf19f34884
SeanRosario/assignment9
/lk1818/data.py
1,129
4.125
4
''' This module is for data importing, transforming, and merging. ''' import pandas as pd import numpy as np def load_data(): #this function reads the files and creates two data frames: countries and income in desired format. countries = pd.DataFrame(pd.read_csv('./countries.csv')) income = pd.DataFrame...
true
ed784f7a6638216dc456eccbe7adcf8172234450
Mukesh-SSSDIIT/python2021_22
/Sem5/Collections/List/list_basic3.py
686
4.125
4
list1 = ["aaa","bbb","ccc"] list2 = [111,222,333] list3 = list1 + list2 print(list1) print(list2) print(list3) # Another way to join to lists. # for i in list2: # list1.append(i) # print(list1) # Use extend method list1.extend(list2) print(list1) list4 = list([1,2,3,4]) print(list4) list5 = [10,20,10,20...
true
cac27739601b117356d19c3a8bad348ac16863a9
bilaleluneis/LearningPython
/abstract_class.py
1,708
4.375
4
from abc import ABC, abstractmethod __author__ = "Bilal El Uneis and Jieshu Wang" __since__ = "June 2018" __email__ = "bilaleluneis@gmail.com" """ Animal is an abstract class and I shouldn't be able to create instance of it, but in python there is no abstract keyword or feature that is part of the language construct...
true
09383d8e3d90a1801c149c2506d78660d790c983
JuliaGu808origin/pyModul1
/extraLabba/extra2/extra2/extra2.1.py
341
4.59375
5
# Write a Python program to get the dates 30 days before and after from the current date # !可以顯示再漂亮一點 import datetime today = datetime.datetime.now() before = today - datetime.timedelta(days=30) after = today + datetime.timedelta(days=30) print(f"Today: {today}, \n30 days before: {before}, \n30 days after: {after}")...
true
979d8e871ff93c499b1e2c5fa30084f399b60655
JuliaGu808origin/pyModul1
/extraLabba/extra2/extra2/extra2.2.py
795
4.34375
4
######################################################### # Write a Python program display a list of the dates # for the 2nd Saturday of every month for a given year. ######################################################### import calendar try: givenYear = int(input("Which year -> ")) except: print("Wrong y...
true
08f51078381095f447623fed68837c911cedb949
smraus/python-assignments
/08 startswithIs.py
517
4.375
4
#--------8 program to get a new string from a given string where "Is" has been added to the front------- def main(): while True: try: string = input('Enter a string : ') if string.startswith('Is'): print('Your string' , string , 'is correct.') else: ...
true
f1a30558ce9da0d7f2f57b4782dc406b9e19f819
smraus/python-assignments
/16 x1y1 x2y2.py
757
4.3125
4
#-----16 program to compute the distance between the points (x1, y1) and (x2, y2)---- from math import sqrt def main(): while True: try: print('Enter the pairs in the format x,y') x1_y1 = input('Enter x1,y1 : ') x2_y2 = input('Enter x2,y2 : ') first = x1_y1.sp...
true
3d4a19f5a378a454403c21abe780ee3a62fe9cc7
qainstructorsky2/gitleeds2021c1
/demos/lambda.py
416
4.59375
5
choices = { "R":,Rock "P": Paper, "S: Scissors" } # Get the user's choice of the three user_choice = input("\nType R, P, or S to play against the computer: ") # Print what the user's choice, so she knows what she picked print user_choice # Make sure the user input is valid if user_choice in choices: print "You ch...
true
d02059f5953986a9aaa0680b42321c3f58336189
rob19gr661/Python-Tutorials
/Python/2 - Reading And Writing Files/Writing_Files.py
680
4.125
4
""" Writing Files: """ # Testing the "a" operation """ Test_file = open("Testtest.txt", "a") # Remember that append will add something to the end of the file Test_file.write("\nToby - Official poopscooper") # We add the typed line to the end of the document Test_file.close() """ # Testing the "w" ope...
true
b029fb0cd22c7c7a4c6ae93dc85e2d6223f804e6
AmitKulkarni23/Leet_HackerRank
/LeetCode/Easy/Strings/434_number_of_segments_in_string.py
560
4.28125
4
# Count the number of segments in a string, where a segment is defined to be a contiguous sequence of non-space characters. # # Please note that the string does not contain any non-printable characters. # # Example: # # Input: "Hello, my name is John" # Output: 5 def countSegments(s): """ :type s: str :rty...
true
9b0583e881f7ae10553828b4051968d8b0619a5e
AmitKulkarni23/Leet_HackerRank
/CrackingTheCodingInterview/Bit Manipulation/ith_bit_set.py
795
4.15625
4
""" Python program to check if ith bit is set in the binary representation of a given number To check if the ith bit is set or not (1 or not), we can use AND operator And the given number with 2^i. In 2 ^ i only the ith bit is set. All the other bits are zero. If numb & ( 2 ^ i) returns a non-zero number then the ith ...
true
fd0d1ff9f35f40b9159edd85135d069a02b562b4
AmitKulkarni23/Leet_HackerRank
/Dynamic_Programming/rod_cutting.py
957
4.15625
4
# Given a rod of certain lenght and given prices of different lenghts selling in the # market. How do you cut teh rod to maximize the profit? ################################### def get_cut_rod_max_profit(arr, n): """ Function that will return maximum profit that can be obtained by cutting teh rod into pie...
true
c5d38264a6fc929dad3989817c2965fa3c67c0e6
AmitKulkarni23/Leet_HackerRank
/LeetCode/Easy/Trees/226_invert_binary_tree.py
1,294
4.40625
4
# Invert a binary tree. # # Example: # # Input: # # 4 # / \ # 2 7 # / \ / \ # 1 3 6 9 # Output: # # 4 # / \ # 7 2 # / \ / \ # 9 6 3 1 # Definition for a binary tree node. # class TreeNode(object): # def __init__(self, x): # self.val = x # self.left = N...
true
f5e0e4edbdb2beb39e967a2edbc8d0f246649079
AmitKulkarni23/Leet_HackerRank
/LeetCode/Easy/Strings/844_backspace_string_compare.py
989
4.25
4
# Given two strings S and T, return if they are equal when both are typed into empty text editors. # means a backspace character. # # # # Example 1: # # Input: S = "ab#c", T = "ad#c" # Output: true # Explanation: Both S and T become "ac". # Example 2: # # Input: S = "ab##", T = "c#d#" # Output: true # Explanation: Both...
true
ff3dc719301e1f8dbcfc28964d43173e79c7278d
AmitKulkarni23/Leet_HackerRank
/Dynamic_Programming/maximum_sum_increasing_subsequence.py
1,346
4.25
4
# Given an array of n positive integers. # Write a program to find the sum of maximum sum subsequence of the given array such that the intgers in # the subsequence are sorted in increasing order. For example, if input is {1, 101, 2, 3, 100, 4, 5}, # then output should be 106 (1 + 2 + 3 + 100), # if the input array is {...
true
9a640edb1c2cea9743d4b651dbbae43095032d20
AmitKulkarni23/Leet_HackerRank
/LeetCode/Easy/Trees/572_subtree_of_another_tree.py
2,144
4.15625
4
# Given two non-empty binary trees s and t, check whether tree t # has exactly the same structure and node values with a subtree of s. # A subtree of s is a tree consists of a node in s and all of this node's descendants. # The tree s could also be considered as a subtree of itself. # # Example 1: # Given tree s: # # ...
true
a8dce32f98177322594dbd445b955acfa98c6fcb
AmitKulkarni23/Leet_HackerRank
/LeetCode/Easy/merge_2_sorted_linked_lists.py
2,896
4.125
4
# Merge 2 sorted linked lists # Return the new merged list # Definition for singly-linked list. # class ListNode: # def __init__(self, x): # self.val = x # self.next = None # My Solution - Very poor performance - beats only 26% of python submissions # Runtime for 208 test cases = 88ms # Sometimes...
true
ed006d939bae223afdd788f0becae5ffe29e2ad3
AmitKulkarni23/Leet_HackerRank
/LeetCode/Easy/Bit_Manipulation/number_of_1_bits.py
1,081
4.375
4
# Write a function that takes an unsigned integer and returns the number of '1' bits it has (also known as the Hamming weight). # # Example 1: # # Input: 11 # Output: 3 # Explanation: Integer 11 has binary representation 00000000000000000000000000001011 # Example 2: # # Input: 128 # Output: 1 # Explanation: Integer 128...
true
b2af5b93ed6b9fc6fa6503ed5ad1b93caae1ea70
AmitKulkarni23/Leet_HackerRank
/LeetCode/Medium/BFS/199_binary_tree_right_side_view.py
1,605
4.3125
4
# Given a binary tree, imagine yourself standing on the right side of it, return the values of the nodes you can see ordered from top to bottom. # # Example: # # Input: [1,2,3,null,5,null,4] # Output: [1, 3, 4] # Explanation: # # 1 <--- # / \ # 2 3 <--- # \ \ # 5 4 <--- # ...
true
6e65a2c082edad96b92dc17dced5ed6615e22433
AmitKulkarni23/Leet_HackerRank
/LeetCode/Medium/DFS/439_ternary_expression_parser.py
2,830
4.5625
5
# Given a string representing arbitrarily nested ternary expressions, calculate the result of the expression. You can always assume that the given expression is valid and only consists of digits 0-9, ?, :, T and F (T and F represent True and False respectively). # # Note: # # The length of the given string is ≤ 10000. ...
true
3c9e6d1bc56f8b97daada933d42d642542d3cd5c
AmitKulkarni23/Leet_HackerRank
/LeetCode/Easy/Bit_Manipulation/power_of_2.py
362
4.21875
4
# Given an integer, write a function to determine if it is a power of two. # # Example 1: # # Input: 1 # Output: true # Example 2: # # Input: 16 # Output: true # Example 3: # # Input: 218 # Output: false def isPowerOfTwo(self, n): """ :type n: int :rtype: bool """ if n > 0: ...
true
58589846f783e636a07f40bb1c9a67441cbe9bdd
giancarlo358/cracklepop
/crackle_pop.py
686
4.25
4
#Write a program that prints out the numbers 1 to 100 (inclusive). #If the number is divisible by 3, print Crackle instead of the number. #If it's divisible by 5, print Pop. #If it's divisible by both 3 and 5, print CracklePop. You can use any language. #custom range start = 1 end = 101 my_range = range(start,end) div...
true
f592d4f598ec510ad260fb6133460514ea38e7d4
UjjwalP08/Basics-Of-Python
/Exercises/Exercise 1.py
353
4.125
4
"""In This exercise we can take input from user and compiler return according to its out put Eg:- Key now we can provide some details about it.""" a = {"key": "Use to open lock", "greet": "Means to Call about Good mornig", "IT": "Study of Website and Computer"} "" print(a.keys()) print("Enter Key which details you wan...
true
ee0c50c7586746a4dfdbf6348592f561246942c4
UjjwalP08/Basics-Of-Python
/No_55_Functioncaching.py
2,008
4.65625
5
""" --------------------> Function Caching <--------------------------- some times we are call the same function in program again and again so our time of program is taken more than expected so reduce this we are use the function caching this method is inside the functool module and method is lur_cache "...
true
4a89663ccb22ff3f3a9138af70b346b60aa43ab1
aravinthusa/python-prgramme
/file1.py
479
4.40625
4
program: #to find the radius of the circle r=float(input("input the radius of the circle:")) a=(22*r*r)/7 print("the area of circle with radius",r,"is:",a) output: input the radius of the circle:1.1 the area of circle with radius 1.1 is: 3.8028571428571434 program: #to find the extension of the file a=input("Inp...
true
9665330448fa691346f1117e65665b734cd79aa3
hungnd11111984/DataCamp
/pandas Foundation/Build a DataFrame.py
2,933
4.28125
4
# 1 Zip lists to build a DataFrame # Display tuple print(list_keys) # ['Country', 'Total'] print(list_values) # [['United States', 'Soviet Union', 'United Kingdom'], [1118, 473, 273]] # Zip the 2 lists together into one list of (key,value) tuples: zipped zipped = list(zip(list_keys,list_values)) # Inspect the list usi...
true
3bfa1389d2d43bcbdda5995b99c01a8fb16b6496
yuede/Lintcode
/Python/Reverse-Linked-List.py
495
4.125
4
class Solution: """ @param head: The first node of the linked list. @return: You should return the head of the reversed linked list. Reverse it in-place. """ def reverse(self, head): # write your code here if head is None or head.next is None: return hea...
true
51aa90a32ee61c3e3891f4cad80c6a06d59a81dd
chunweiliu/leetcode2
/insert_interval.py
1,286
4.21875
4
"""Insert a new interval << [[1, 2], [3, 5], [7, 9]], [4, 8] => [[1, 2], [3, 9]] << [[1, 2]], [3, 4] => [[1, 2], [3, 4]] - Insert a number [0, 1, 2, 10], 3 Seperate the intervals to left and right half by comparing them with the target interval - If not overlap, put them ...
true
0c5d9e1322959ea228ef2e8ac23076caa162a192
chunweiliu/leetcode2
/the_skyline_problem.py
1,998
4.21875
4
"""Use a dict to represent heights. For each critical point, pop the heightest. << [[1, 10, 5], [3, 8, 7]] => [[1, 5], [3, 7], [8, 5], [10, 0]] A good illustration of the skyline problem https://briangordon.github.io/2014/08/the-skyline-problem.html Time: O(nlogn) Space: O(n) """ from heapq import * class ...
true
309df73c581fbddafb1d952ef24b7d107e445da4
chunweiliu/leetcode2
/implement_trie_prefix_tree.py
1,849
4.3125
4
""" Each Trie node has a dict and a flag. For inserting a word, insert each character to the Trie if the character is not there yet. For distiguish a word and a prefix, use the '#' symbol. Trie (f) (b) (o) (a) (o)T (r)T """ from collections import defaultdict class TrieNode(object): def _...
true