blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
2de9437f4bb2df0f0928ac1928e62efb8e1eaafa
Nihilnia/reset
/Day 16 - Simple Game_Number Guessing.py
1,782
4.21875
4
# Simple Game - Number Guessing from time import sleep from random import randint rights = 5 number = randint(1, 20) hintForUser = list() userChoices = list() for f in range(number - 3, number + 3): hintForUser.append(f) print("Welcome to BASIC Number Guessing Game!") while rights != 0: pr...
true
622934e84d6a56e6a1b627272ff1b4eaf1b62e12
Nihilnia/reset
/Day 14 - Parameters at Functions.py
685
4.21875
4
# Parameters at Functions # if we wanna give any parameters to a Function #we should insert a value while using. def EvilBoy(a, b): print("Function 'EvilBoy' Worked!") return a + b print(EvilBoy(2, 3)) # that was a classic function as we know. # But we can make it some default parameters. def...
true
4e9f13a8c7ecab8c17168286a77e91f07b0c9d73
favour-22/holbertonschool-higher_level_programming
/0x06-python-classes/5-square.py
1,124
4.34375
4
#!/usr/bin/python3 """Module containing the Square class""" class Square: """The Square class""" def __init__(self, size=0): """Initializing an instance of Square Args: size (int): The size of the Square instance. Default value is 0. """ self.size = size @prop...
true
867215b59920586cda5067058b049d1373502c6a
skm2000/OOPS-
/Python/Assignment 2/Exercise20/controller.py
1,907
4.25
4
''' @author: < add your name here > ''' from tkinter import * from quiz import Quiz class Controller: ''' Drive an interactive quiz GUI ''' def __init__(self, window): ''' Create a quiz and GUI frontend for that quiz ''' self.quiz = Quiz() self.question_text = Te...
true
6a658a044bee82ceaf20b137cd32ffdc110d1a6b
Aabha-Shukla/Programs
/Aabha_programs/9.py
300
4.34375
4
#Write a program that accepts sequence of lines as input and prints the #lines after making all characters in the sentence capitalized. #Suppose the following input is supplied to the program: str=input('Enter a string:') if str.lower(): print(str.upper()) else: print(str.upper())
true
691ce469febbe5b4404a3e0fb6e0d65681ab0e2c
Khokavim/Python-Advanced
/PythonNumpy/numpy_matrix_format.py
497
4.53125
5
import numpy as np matrix_arr =np.array([[3,4,5],[6,7,8],[9,5,1]]) print("The original matrix {}:".format(matrix_arr)) print("slices the first two rows:{}".format(matrix_arr[:2])) # similar to list slicing. returns first two rows of the array print("Slices the first two rows and two columns:{}".format(matrix_arr[:2, 1...
true
8801ca4c2ab7197cb3982477f37ed8f743ccac3c
MaineKuehn/workshop-advanced-python-hpc
/solutions/021_argparse.py
715
4.25
4
# /usr/bin/env python3 import argparse import itertools import random CLI = argparse.ArgumentParser(description="Generate Fibonacci Numbers") CLI.add_argument('--count', type=int, default=random.randint(20, 50), help="Count of generated Numbers") CLI.add_argument('--start', type=int, default=0, help="Index of first ge...
true
08f5b82ba5051d45de9dee198e9e50cdd2b47e0a
sadath-ms/ip_questions
/unique_char.py
523
4.15625
4
""" UNIQUE CHARCTER IN A STRING Given a string determines, if it is compresied of all unique characters,for example the string 'abcde' has all unique characters it retrun True else False """ def unique_char(st): return len(set(st)) == len(st) def unique_char_v2(st): chars = set() for u in st: ...
true
97f80fb49430024d4d1e7d5742ad5f2ba5e73e59
rishabhworking/python
/takingInputs.py
293
4.34375
4
# Python Inputs print('Enter the number: ') num1 = int(input()) # This is how to take an input print('Enter the power: ') num2 = int(input()) power=num1**num2 print(num2,'th power of',num1,'is:',power) # This is how you print vars with strs # int(input()) # float(input()) # str(input())
true
5273a16984fb7298dc231b4cdff161d4529ab76b
ja-vu/SeleniumPythonClass
/Class1/onlineExercises/Q6/StringList.py
537
4.40625
4
""" Ask the user for a string and print out whether this string is a palindrome or not. (A palindrome is a string that reads the same forwards and backwards.) https://www.practicepython.org/exercise/2014/03/12/06-string-lists.html """ word = input("Give me a word and I will check if this is a palindrome or not: ") #...
true
e0d350abd7dc0c984321314ecc148c6b48b4becd
jbhowsthisstuffwork/python_automateeverything
/Practice Projects/theCollatzSequence.py
968
4.375
4
# Create a program that allows a user to input an integer that calls a collatz() # function on that number until the function returns the value 1. import time, userInput = '' stepsToComplete = 0 def collatz(number): global userInput evaluateNumber = number % 2 if evaluateNumber == 0: userInput = n...
true
892c6518f5cd2648b1279998c02168a4c1a00214
parkjungkwan/telaviv-python-basic
/intro/_12_iter.py
848
4.3125
4
# *********************** # -- 이터 # *********************** ''' list = [1,2,3,4] it = iter(list) # this builds an iterator object print (next(it)) #prints next available element in iterator Iterator object can be traversed using regular for statement !usr/bin/python3 for x in it: print ...
true
c6453dc21a3783d471a24360a8f96b9f64c89e6e
Edinburgh-Genome-Foundry/DnaFeaturesViewer
/dna_features_viewer/compute_features_levels.py
2,402
4.28125
4
"""Implements the method used for deciding which feature goes to which level when plotting.""" import itertools import math class Graph: """Minimal implementation of non-directional graphs. Parameters ---------- nodes A list of objects. They must be hashable. edges A list of the fo...
true
26be85957e8f376c3c24c368451c3b5676a75faa
sanketsoni/practice
/practice/even_first_array.py
685
4.46875
4
""" Reorder array entries so that even entries appear first Do this without allocating additional storage example- a = 3 2 4 5 3 1 6 7 4 5 8 9 0 output = [0, 2, 4, 8, 4, 6, 7, 1, 5, 3, 9, 5, 3] time complexity is O(n), Space complexity is O(1) """ def even_first_array(a): next_even, n...
true
778862869cc7e90380b8953d186d59de6b49c950
Banehowl/MayDailyCode2021
/DailyCode05102021.py
950
4.3125
4
# ------------------------------------------------ # # Daily Code 05/10/2021 # "Basic Calculator (again)" Lesson from edabit.com # Coded by: Banehowl # ------------------------------------------------ # Create a function that takes two numbers and a mathematical operator + - / * and will perform a # calcula...
true
8f872ae832a6b0a8c3296c46581eb390fca1c4e4
expelledboy/dabes-py-ddd-example
/domain/common/constraints.py
701
4.15625
4
def create_string(field_name: str, constructor: function, max_len: int, value: str): """ Creates a string field with a maximum length. :param field_name: The name of the field. :param constructor: The constructor function. :param max_len: The maximum length of the string. :param value: The valu...
true
b763671aa6e2edab48338ca9250b4ec7d1039944
NFellenor/AINT357_Content
/P3_Recursion_Dynamic_Programming/P3_Recursion_Dynamic_Programming/P3_Recursion_Dynamic_Programming.py
729
4.25
4
#Practical 3: Recursion and dynamic programming: #Recursivley compute numbers 1-N: def sumOf(n): if (n <= 1): return 1 return n + sumOf(n - 1) #Recursive line print("Input value for n.") n = int(input()) #Set value for n by user print("Sum of values from 1 - n:") print(sumOf(n)) #Recursivel...
true
22dc7651851f3296a2eac7d6d7e035a212ad885a
Nishad00/Python-Practice-Solved-Programs
/Validating_Roman_Numerals.py
588
4.1875
4
# You are given a string, and you have to validate whether it's a valid Roman numeral. If it is valid, print True. Otherwise, print False. Try to create a regular expression for a valid Roman numeral. # Input Format # A single line of input containing a string of Roman characters. # Output Format # Output a single ...
true
35f10ea897580ce47d4fd020aa9bb9781b1a87e4
Trent-Farley/All-Code
/Python1/Train Ride/yourturn.py
621
4.40625
4
#Create a trapezoid Calculator-- Here is the formula ((a+b)/2)*h #USER input #Create a test to see if an in is even use % (mod) to test #divisible by zero. USER INPUT #Find the remainder of a number -- Number can be your choice #Find the volume and area of a circle from user input #volume = 4/3 *pi*r^3 #Area ...
true
9a7a7be1657ff95c6ad6eba58bb1bce27adce8c5
Trent-Farley/All-Code
/Python1/Old stuff/Assignemt2.py
671
4.375
4
# Farley, Trent # Assignemt 2 # Problem Analysis: Write a program to calculate the volume # and surface area of a sphere. # Program specifications: use the formualas to create a program # that asked for a radius and outputs the dimensions. # Design: # I need to create a float input value. Once that value is cal...
true
2b8eb76b4162442da56ba1aaf0ff755e076e7501
Menda0/pratical-python-2021
/7_data_structures_exercises.py
1,228
4.40625
4
# 1. Create a list with 5 people names # 2. Create a tuple with 5 people names ''' 1. Create 6 variables containing animals (Example: Salmon, Eagle, Bear, Fox, Turtle) 2. Every animal must have the following information 2.1 Name, Color, Sound 3. Create 3 variables for animal families (Exa...
true
7404f874819261a132afccf8937de39a39860cf7
stahura/school-projects
/CS1400/Projects/rabbits_JRS.py
2,774
4.28125
4
''' Jeffrey Riley Stahura CS1400 Project: Rabbits, Rabbits, Rabbits Due March 10th 2018 Scientists are doing research that requires the breeding of rabbits. They start with 2 rabbits, 1 male, 1 female. Every pair reproduces one pair, male and female. Offspring cannot reproduce until after a month. Offspring cannot hav...
true
e99e3544eed9a000f67f50aac98fb08c6519c64d
johnsogg/cs1300
/code/py/lists.py
482
4.125
4
my_empty_list = [] print type(my_empty_list) my_list = [ 1, 7, 10, 2, 5 ] my_stringy_list = [ "one", "three", "monkey", "foo"] my_mixed_list = [ 42, "forty two", True, 61.933, False, None ] for thing in my_list: print "My thing is:" + str(thing) print "" for thing in my_stringy_list: print "My stringy thi...
true
12183c6d111eed9b38757e939c3e28ba0051cd01
tannerbender/E01a-Control-Structues
/main10.py
1,789
4.21875
4
#!/usr/bin/env python3 import sys, utils, random # import the modules we will need utils.check_version((3,7)) # make sure we are running at least Python 3.7 utils.clear() # clear the screen print('Greetings!') #printing the word "greetings" colors = ['red','orange','yellow',...
true
36cc2b81e8c17f789d8c1271e9edb497fb9b3b28
FilipposDe/algorithms-structures-class
/Problems vs. Algorithms/problem_2.py
2,625
4.3125
4
def rotated_array_search(input_list, number): """ Find the index by searching in a rotated sorted array Args: input_list(array), number(int): Input array to search and the target Returns: int: Index or -1 """ if len(input_list) == 0: return -1 return sea...
true
94c6d0c3e3b41e61e93a07bff3efb13f19864891
StefanFischer/Deep-Learning-Framework
/Exercise 3/src_to_implement/Layers/ReLU.py
1,211
4.5
4
""" @description The Rectified Linear Unit is the standard activation function in Deep Learning nowadays. It has revolutionized Neural Networks because it reduces the effect of the "vanishing gradient" problem. @version python 3 @author Stefan Fischer Sebastian Doerrich """ import numpy as np class ReLU: def __...
true
4460227115e90388f6b97735aff31ee75e45dc5b
marymarine/sem5
/hometask2/task2.py
824
4.1875
4
"""Task 2: The most popular word""" def get_list_of_words(): """return list of input words""" list_of_words = [] while True: new_string = input() if not new_string: break list_of_words.extend(new_string.split()) return(list_of_words) #transform text to list of words...
true
2cd1ed48f5ae3a42ed397974fd56366d82cc733f
zingpython/kungFuShifu
/day_four/23.py
1,289
4.28125
4
#Convert an interger to a binary in the form of a string def intToBinary(number): #Create empty string to hold our new binary number binary_number = "" #While our number is greater than 0 Keep dividing by 2 and adding the remainder to binary_number while number > 0: #Divmod divindes the 1st number by the 2nd nu...
true
a37cee394a218707cb0ed3b273b2b37316d7aad1
zingpython/kungFuShifu
/day_four/7.py
1,651
4.28125
4
import math class SpaceShip: target = [] #2 values, X and then Y coordinate = [] #2 values X and then Y speed = float() name = "" def __init__(self, coordinate, target, speed, name): self.coordinate = coordinate self.target = target self.speed = speed self.name = name #To find the distence calculate t...
true
ff7553d909f1de5f201c5967b9b0a3a4ba62196f
annanymaus/babysteps
/fibrec.py
952
4.375
4
#!/usr/bin/env python3 #program to find the nth fibonacci number using recursion (and no for loops) import sys #function definition def fib(p): if (p == 0): return 0 elif (p == 1): return 1 else: #recursive equation c = fib(p-1) + fib(p-2) return c #take an input...
true
cbbd52a5f99ae5018930bbaa3adf865f6e54fefd
prabhatcodes/Python-Problems
/Placement-Tests/Interview-Prep-Astrea/DS.py
585
4.15625
4
# Linked List class Node: def __init__(self, data): self.data = data self.next = None # Null class LinkedList: def __init__(self): self.head = None if __name__=="__main__": llist = LinkedList() llist.head = Node(1) second = Node(2) third = Node(3) ...
true
2762945abefafb8b1bd35f556a8a313c174dad99
prabhatcodes/Python-Problems
/Data_Structures/Queues/ArrayQueue.py
1,182
4.125
4
class ArrayQueue: """FIFO queue implementation using a Python list as underlying storage""" DEFAULT_CAPACITY = 10 # moderate capacity for all new queues def __init__(self): """Create an empty queue""" self._data = [None]*ArrayQueue.DEFAULT_CAPACITY self._size = 0 self._...
true
b94e21fffffeede85942ca87aab41a1ce47a0dfc
sjaney/PDX-Code-Guild---Python-Fullstack-Solution
/python/lab9v2.py
409
4.125
4
# Lab 9v2 ROT Cipher import string print('Encrypt your word into a ROT Cipher.') user = input('Enter a word(s) you would like to encrypt: ') move = int(input('Enter an amount for rotation: ')) alphabet = string.ascii_lowercase encryption = '' for char in user: if char in alphabet: new_encrypt = alphab...
true
03d19cf620451f9f7d2da74b76cacb689846bdad
holmanapril/Assessment_Quiz
/how_many_questions_v1.py
456
4.1875
4
# Asks how many questions user would like to play question_amount = int(input("How many questions would you like to play? 10, 15 or 20?")) # If questions_amount is equal to 10, 15 or 20 it print it if question_amount == 10 or question_amount == 15 or question_amount == 20: print("You chose {} rounds".format(questio...
true
5c4e35cc40030d343bc1cd5504da985827569aa7
XUMO-97/lpthw
/ex15/ex15.py
1,610
4.375
4
# use argv to get a filename from sys import argv # defines script and filename to argv script, filename = argv # get the contents of the txt file txt = open(filename) # print a string with format characters print "Here's your file %r:" % filename # print the contents of the txt file print txt.read() tx...
true
457605325a3338e41c9e802600e7b1788b26d476
ketkiambekar/data-structures-from-scratch
/BFS.py
728
4.3125
4
# Using a Python dictionary to act as an adjacency list graph = { '5' : ['3','7'], '3' : ['2', '4'], '7' : ['8'], '2' : [], '4' : ['8'], '8' : [] } visited = set() # Set to keep track of visited nodes of graph. queue=[] def bfs(visited, graph, node): visited.add(node) queue.append(node) w...
true
e358ecfabb655068f2fb70954677d220ad1104cd
cwalker4/youtube-recommendations
/youtube_follower/db_utils.py
2,024
4.15625
4
import sqlite3 from sqlite3 import Error def create_connection(db_path): """ Creates the sqlite3 connection INTPUT: db_path: (str) relative path to sqlite db OUTPUT: conn: sqlite3 connection """ try: conn = sqlite3.connect(db_path) except Error as e: print(e) return conn def create_record(conn, tabl...
true
e37406cab1e981fa6fac68b16cdd9dba407020dd
FrauBoes/PythonMITx
/midterm/midterm str without vowels.py
621
4.25
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Wed Jun 7 14:30:50 2017 @author: thelma """ def print_without_vowels(s): ''' s: the string to convert Finds a version of s without vowels and whose characters appear in the same order they appear in s. Prints this version of s. Does n...
true
9888442f8b0c95a2076f5da795ca2e9773a55bd5
FrauBoes/PythonMITx
/list largest int odd times.py
583
4.25
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Wed Jul 26 15:42:29 2017 @author: thelma """ def largest_odd_times(L): """ Assumes L is a non-empty list of ints Returns the largest element of L that occurs an odd number of times in L. If no such element exists, returns None """ ...
true
213c8884c28e68a3786eecb730f0d4672b031a32
FrauBoes/PythonMITx
/max value tuple.py
662
4.34375
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Mon Jul 31 10:12:33 2017 @author: thelma """ def max_val(t): """ t, tuple or list Each element of t is either an int, a tuple, or a list No tuple or list is empty Returns the maximum int in t or (recursively) in an element of t...
true
8bd6ed86b4ea0f992b531f5b229b7026525125c4
shovals/PythonExercises
/max of 3.py
307
4.34375
4
# max of 3 show the largest number from 3 numbers One = input('Enter first number: ') Two = input('Enter second number: ') Third = input('Enter third number: ') if One > Third and One > Two: print 'Max is ', One elif Two > One and Two > Third: print 'Max is ', Two else: print 'Max is', Third
true
d5336239b5db506f80269d85f8b0b4bb6ca9f4ab
dcragusa/LeetCode
/1-99/70-79/75.py
2,062
4.34375
4
""" Given an array with n objects colored red, white or blue (represented by integers 0, 1, and 2), sort them in-place so that objects of the same color are adjacent, with the colors in the order red, white and blue. Note: You are not suppose to use the library's sort function for this problem. Example: Input: [2, 0, ...
true
bd42aae37e10dd6af40b2f9deaef942a5bfa4218
dcragusa/LeetCode
/100-199/110-119/112.py
1,419
4.1875
4
""" Given the root of a binary tree and an integer `target_sum`, return `True` if the tree has a root-to-leaf path such that adding up all the values along the path equals `target_sum`. A leaf is a node with no children. Example 1: Input: root = [5, 4, 8, 11, None, 13, 4, 7, 2, None, None, None, 1], target_sum = 22, ...
true
6b1914ee8aab2ad9a6d4dacc0ade2581acaf5894
dcragusa/LeetCode
/1-99/90-99/98.py
1,908
4.3125
4
""" Given a binary tree, determine if it is a valid binary search tree (BST). Assume a BST is defined as follows: The left subtree of a node contains only nodes with keys less than the node's key. The right subtree of a node contains only nodes with keys greater than the node's key. Both the left and right subtrees mu...
true
ab4cde1297d67e70cf920c2288309e179085cdf8
dcragusa/LeetCode
/1-99/20-29/24.py
1,823
4.34375
4
""" Given a linked list, swap every two adjacent nodes and return its head. You may not modify the values in the list's nodes, only nodes itself may be changed. Example: Given 1->2->3->4, you should return the list as 2->1->4->3. """ """ Firstly we swap the first two elements. We then iterate across the list, copying...
true
efd2f12aa8c7ab9bc45d150e747852c70010529f
dcragusa/LeetCode
/1-99/70-79/70.py
2,026
4.28125
4
""" You are climbing a staircase with n steps. Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top? Note: Given n will be a positive integer. Example 1: Input: 2, Output: 2 Explanation: There are two ways to climb to the top. 1. 1 step + 1 step 2. 2 steps Example 2: Input:...
true
1e941dff165827fd643b735fb82593730409c85b
dcragusa/LeetCode
/100-199/110-119/113.py
1,532
4.125
4
""" Given the root of a binary tree and an integer `target_sum`, return `True` if the tree has a root-to-leaf path such that adding up all the values along the path equals `target_sum`. A leaf is a node with no children. Example 1: Input: root = [5, 4, 8, 11, None, 13, 4, 7, 2, None, None, 5, 1], target_sum = 22 Outpu...
true
9fbc99a4530e82bbeb3d7e3b378e840ad23a5662
dcragusa/LeetCode
/100-199/140-149/144.py
1,042
4.15625
4
""" Given the root of a binary tree, return the preorder traversal of its nodes' values. Example 1: Input: root = [1, None, 2, 3], Output: [1, 2, 3] 1 \ 2 / 3 Example 2: Input: root = [], Output: [] Example 3: Input: root = [1], Output: [1] Example 4: Input: root = [1, 2], Output: [1, 2] 1...
true
7e6d0cac3b718470e86944b508f19fda5343da79
dcragusa/LeetCode
/1-99/40-49/43.py
958
4.5625
5
""" Given two non-negative integers num1 and num2 represented as strings, return the product of num1 and num2, also represented as a string. Example 1: Input: num1 = "2", num2 = "3", Output: "6" Example 2: Input: num1 = "123", num2 = "456", Output: "56088" Note: The length of both num1 and num2 is < 110. Both num1...
true
58df73678cbd095fea3ed3c477f05cbe81eebf9d
dcragusa/LeetCode
/1-99/60-69/67.py
528
4.1875
4
""" Given two binary strings, return their sum (also a binary string). The input strings are both non-empty and contains only characters 1 or 0. Example 1: Input: a = "11", b = "1", Output: "100" Example 2: Input: a = "1010", b = "1011", Output: "10101" """ """ This is fairly trivial to do by converting the argume...
true
c1b6ad529f2be7716814c1a16d4afd51c4aeeddb
dcragusa/LeetCode
/1-99/20-29/22.py
1,998
4.3125
4
""" Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses. For example, given n = 3, a solution set is: ['((()))', '(()())', '(())()', '()(())', '()()()'] """ """ We start with one pair of parentheses, which can only be (). For each additional pair, we add an open brac...
true
27419cc9188daaf8cf78d2be008f21ce35b4d98c
dcragusa/LeetCode
/1-99/30-39/38.py
1,668
4.28125
4
""" The count-and-say sequence is the sequence of integers with the first five terms as following: 1. 1 2. 11 3. 21 4. 1211 5. 111221 1 is read off as "one 1" or 11. 11 is read off as "two 1s" or 21. 21 is read off as "one 2, then one 1" or 1211. Given an integer n where 1 ≤ n ≤ 30, generate the ...
true
a7642a80d728d5c5ed8b717e02f31973c13c997d
dcragusa/LeetCode
/1-99/90-99/92.py
1,845
4.21875
4
""" Reverse a linked list from position m to n. Do it in one-pass. Note: 1 ≤ m ≤ n ≤ length of list. Example: Input: 1->2->3->4->5->NULL, m = 2, n = 4, Output: 1->4->3->2->5->NULL """ """ We obtain the first node we are reversing (current), along with the node before that (reversal_head). Then we iterate along the n...
true
1f30fbf51386a7dff9fdf22a6032fb0f554578e2
dcragusa/LeetCode
/1-99/50-59/50.py
1,934
4.1875
4
""" Implement pow(x, n), which calculates x raised to the power n (x^n). Example 1: Input: 2.00000, 10, Output: 1024.00000 Example 2: Input: 2.10000, 3, Output: 9.26100 Example 3: Input: 2.00000, -2, Output: 0.25000, Explanation: 2-2 = 1/22 = 1/4 = 0.25 Note: -100.0 < x < 100.0, n is a 32-bit signed integer, wi...
true
9e13c18fc3efdb57e2b52a035f8449b1288e312e
dcragusa/LeetCode
/1-99/70-79/71.py
2,137
4.25
4
""" Given an absolute path for a file (Unix-style), simplify it. Or in other words, convert it to the canonical path. In a UNIX-style file system, a period . refers to the current directory. Furthermore, a double period .. moves the directory up a level. Note that the returned canonical path must always begin with a sl...
true
5f5faa9ed086ea1741a7ac316ecc196fb6ebe763
dcragusa/LeetCode
/100-199/120-129/129.py
1,552
4.21875
4
""" You are given the root of a binary tree containing digits from 0 to 9 only. Each root-to-leaf path in the tree represents a number. For example, the root-to-leaf path 1 -> 2 -> 3 represents the number 123. Return the total sum of all root-to-leaf numbers. A leaf node is a node with no children. Example 1: Input: r...
true
2016b3800a0096045b21c9268298c6ebdd011527
dcragusa/LeetCode
/1-99/40-49/49.py
886
4.375
4
""" Given an array of strings, group anagrams together. Example: Input: ["eat", "tea", "tan", "ate", "nat", "bat"], Output: [["ate", "eat", "tea"], ["nat", "tan"], ["bat"]] Note: All inputs will be in lowercase. The order of your output does not matter. """ """ Firstly we sort each string in the given array - this ...
true
881e3c309d3efcbe76537c5bea6454795674d692
dargen3/matematika-a-programovani
/1-lesson/games_with_number/collatz_sequence.py
573
4.21875
4
def collatz_sequence(n): # return number of steps of collatz sequence for n count = 0 while n != 1: if n % 2 == 0: n = n / 2 else: n = n * 3 + 1 count += 1 return count def largest_sequence(max): # print number from interval (2, max) which have highest num...
true
6c2d06066c0e0fcf57ed491e3638a3d56bb92d07
Swarnabh3131/sipPython
/sip/sipF05_DFsortcreate.py
413
4.15625
4
# -*- coding: utf-8 -*- import pandas as pd #https://thispointer.com/pandas-sort-rows-or-columns-in-dataframe-based-on-values-using-dataframe-sort_values/ #df creation matrix = [(222, 16, 23),(333, 31, 11)(444, 34, 11), ] matrix # Create a DataFrame object of 3X3 Matrix dfObj = pd.DataFrame(matrix, index=list('abc')...
true
fd721bc36a9bce2cea562e277cb8ba50a2d155d1
sewayan/Study_Python
/ex25.py
1,620
4.28125
4
# function will be imported & executed in python # """ Insert comment text """ -> 'documentation comment' #if code is run in interpreter, documentation comment = help txt def break_words(stuff): """This func will break up words for us.""" """put a space between the sperators -> '' """ words = stuff.split(' ') ret...
true
45ddd16506befea1a06a2b46f73abd88461a4a1f
shiv-konar/Python-GUI-Development
/FocusingandDisablingWidgets.py
1,211
4.3125
4
import tkinter as tk from tkinter import ttk # For creating themed widgets win = tk.Tk() # Create an instance of the Tk class win.title("Python GUI") # Set the title of the window win.resizable(0, 0) # Disable resizing the GUI aLabel = ttk.Label(win, text='Enter a name:') # Create a named Label instance to be u...
true
b315920c07eed5a3baa4c35ce5d583dac0e1ac23
Chetali-3/python-coding-bootcamp
/session-9/Strings/hello.py
450
4.34375
4
#Types of functions """ # finding out length name = input("Enter your name") length = len(name) print(length) """ """ # capitalising name = input("Enter your name") new_name = name.capitalize() print(new_name) """ """ #finding out a letter name = input("Enter your name") new_name = name.find(input("enter the word you ...
true
59bf443228d622dfe3cab82e3d1498ffbfba5dd9
moses-mugoya/Interview-Practical
/second_largest_number.py
802
4.1875
4
def find_second_largest(): n = input("Enter the value of n: ") if (int(n) > 10 or int(n) < 2): print("The value of n should be between 2 and 10") return else: numbers = input("Enter {} numbers separated by a space: ".format(n)) num_list = numbers.split(" ") num_list =...
true
45aa263197f2257470a192294cce88680e8c839d
Aishwarya-11/Python-learnings
/program2.py
454
4.15625
4
def list() : print ("Creating a list and performing insertion and deletion operations\n ") print ("Enter the length :") length = int(input()) print("Enter the values :") list1 = [] for i in range(length) : value = input() list1.append(value) print (list1) print ("Enter the value to insert :") num1 = input(...
true
e0d5492aa7d98d9e968aacbdcb6b36d8a057d91b
patilvikas0205/python-Exercise
/Assignment_No_15.py
568
4.4375
4
''' 15. Define a class named Shape and its subclass Square. The Square class has an init function which takes a length as argument. Both classes have a area function which can print the area of the shape where Shape's area is 0 by default. ''' class Shape: def area(self): print("Area Of Shape is...
true
6f6ed62f8f510fa72eaaf6120570334ceed1c78c
patilvikas0205/python-Exercise
/Assignment_No_11.py
853
4.28125
4
''' 11. Write a program to compute the frequency of the words from the input. The output should output after sorting the key alphanumerically. Suppose the following input is supplied to the program: New to Python or choosing between Python 2 and Python 3? Read Python 2 or Python 3. Then, the output should be: 2 :2...
true
fd174f0aee0488cd3be6a50bd2da5990fe2fa0c8
tuanphandeveloper/practicepython.org
/divisors.py
459
4.3125
4
# Create a program that asks the user for a number and then prints out a list of all the divisors # of that number. (If you don’t know what a divisor is, it is a number that divides evenly into another # number. For example, 13 is a divisor of 26 because 26 / 13 has no remainder.) number = int(input("Please enter a...
true
c2497c1c1f430f290d1eee2c230a26abcd6ab338
tuanphandeveloper/practicepython.org
/listEnds.py
356
4.15625
4
# Write a program that takes a list of numbers (for example, a = [5, 10, 15, 20, 25]) # and makes a new list of only the first and last elements of the given list. For practice, # write this code inside a function. import random a = [5, 10, 15, 20, 25] b = random.sample(range(100), 20) print(b) c = [] c.append(b...
true
51bcb2204eedf71f3a7cf0c7c5ec7c9612919904
Genius98/HackerrankContestProblem
/Football Points.py
356
4.28125
4
#Create a program that takes the number of wins, draws and losses and calculates the number of points a football team has obtained so far. WIN = int(input("Enter win match: ")) DRAWS = int(input("Enter draws match: ")) LOSSES = int(input("Enter losses match: ")) points = WIN * 3 + DRAWS * 1 + LOSSES * 0 print("F...
true
f8e095325f58a1aa00b659cf173c623738f51014
Gautam-MG/SL-lab
/pgm6.py
581
4.5625
5
#Concept: Use of del function to delete attributes of an object and an object itself class Person: def __init__(self,name,age):#This is the constructor of the class Person self.name = name; self.age = age; p1 = Person("Suppandi",14) print("\n Name of Person #1 is",p1.name) print("\n age of a Person #1 is",p1.a...
true
122ce533b91ca38868f0c31ec49c17162500453d
ProgressBG-Python-Course/ProgressBG-VMware-Python-Code
/lab3/comparison_operators.py
1,306
4.21875
4
""" Notes: Lexicographical Comparison: First the first two items are compared, and if they differ this determines the outcome of the comparison.If they are equal, the next two items are compared, and so on, until either sequence is exhausted Comparison operator Chaining: https://docs.python.org/3/referenc...
true
8443ae90b2b72e1f1a91c6fdc098df29528dd82d
USussman/rambots-a19
/Classes/driver.py
2,514
4.125
4
#!/usr/bin/env python3 """ Driver class module Classes ------- Driver interface with wheels for holonomic drive """ from .motor import Motor import math class Driver: """ A class for driving the robot. Methods ------- drive(x, y, r) drive with directional components and rotation. ...
true
d3075a86a63b8fa4b649aefaacee1ff999cd6138
HakujouRyu/School
/Lab 5/nextMeeting.py
1,084
4.3125
4
todaysInt = 8 while todaysInt < 0 or todaysInt > 7: try: todaysDay = input("Assuming Sunday = 0, and Saturday = 6, please enter the day of the week: ") todaysInt = int(todaysDay) except ValueError: if todaysDay == "help": print("Monday 0") print("Tuesday 1") ...
true
fe703b6364b1835b433410da896166adaf129654
elijahsk/cpy5python
/practical04/q05_count_letter.py
509
4.1875
4
# Name: q05_count_letter.py # Author: Song Kai # Description: Find the number of occurences of a specified letter # Created: 20130215 # Last Modified: 20130215 # value of True as 1 and value of False as 0 def count_letter(string,char): if len(string)==1: return int(string[0]==char) return int(string[0]==char)+...
true
66488b56ef595a4ce86f4936262ce9c47c2030d0
elijahsk/cpy5python
/practical03/q08_convert_milliseconds.py
813
4.1875
4
# Name: q08_convert_milliseconds.py # Author: Song Kai # Description: Convert milliseconds to hours,minutes and seconds # Created: 20130215 # Last Modified: 20130215 # check whether the string can be converted into a number def check(str): if str.isdigit(): return True else: print("Please enter a prope...
true
6dce3c4965f32564385623ffb9ef1528a180a016
siddk/hacker-rank
/miscellaneous/python_tutorials/mobile_number.py
469
4.125
4
""" mobile_number.py Given an integer N, and N phone numbers, print YES or NO to tell if it is a valid number or not. A valid number starts with either 7, 8, or 9, and is 10 digits long. """ n = input() for i in range(n): number = raw_input() if number.isdigit(): number = int(number) if (len...
true
b90e89de330807f02410bee5f6faa321376c0a26
siddk/hacker-rank
/miscellaneous/python_tutorials/sets.py
684
4.3125
4
""" sets.py You are given two sets of integers M and N and you have to print their symmetric difference in ascending order. The first line of input contains the value of M followed by M integers, and then N and N integers. Symmetric difference is the values that exist in M or N but not in both. """ m = input() m_lis ...
true
cbb33de2960bed126ad694a163a15aca703bc40a
askwierzynska/python_exercises
/exercise_2/main.py
702
4.125
4
import random print('-----------------------------') print('guess that number game') print('-----------------------------') print('') that_number = random.randint(0, 50) guess = -1 name = input("What's your name darling? ") while guess != that_number: guess_text = input('Guess number between 0 an 50: ') gues...
true
1607baf5554044a4870c9402e79c1ae0867faa0e
obayomi96/Algorithms
/Python/simulteneous_equation.py
786
4.15625
4
# solving simultaneous equation using python print('For equation 1') a = int(input("Type the coefficient of x = \n")) b = int(input("Type the coefficient of y = \n")) c = int(input("Type the coefficient of the constant, k = \n")) print("For equation 2") d = int(input("Type the coefficient of x = \n")) e = int(input("T...
true
9b6acd981eb913452c020d5bd66aac70f329fd6c
heyhenry/PracticalLearning-Python
/randomPlays.py
1,096
4.15625
4
import random randomNumber = random.randint(1, 10) randomNumber = str(randomNumber) print('✯ Welcome to the guessing game ✯') username = input('✯ Enter username: ') guessesTaken = 0 print(username, 'is it? \nGreat name! \nOkay, the rules are simple.\n') print('⚘ You have 6 attempts. \n⚘ Enter a number ranging betwe...
true
39f360ae4828952b4da6249bacfadda4671911d2
aryashah0907/Arya_GITSpace
/Test_Question_2.py
454
4.40625
4
# 3 : Write a Python program to display the first and last colors from the following list. # Example : color_list = ["Red","Green","White" ,"Black"]. # Your list should be flexible such that it displays any color that is part of the list. from typing import List color_list = ["Red", "Green", "White", "Black", "Pink", ...
true
ac9de1f5797579203874fef062220415cc7a3c13
cvhs-cs-2017/sem2-exam1-LeoCWang
/Function.py
490
4.375
4
"""Define a function that will take a parameter, n, and triple it and return the result""" def triple(n): n = n * 3 return (n) print(triple(5)) """Write a program that will prompt the user for an input value (n) and print the result of 3n by calling the function defined above. Make sure you include the neces...
true
1712892d8d87ea7ffc0532bedeb31afd088c47bc
damianserrato/Python
/TypeList.py
693
4.46875
4
# Write a program that takes a list and prints a message for each element in the list, based on that element's data type. myList = ['magical unicorns',19,'hello',98.98,'world'] mySum = 0 myString = "" for count in range(0, len(myList)): if type(myList[count]) == int: mySum += myList[count] elif type(m...
true
2d5273b86616f827bed2a4496b4fe6854acf5ac3
damianserrato/Python
/FindCharacters.py
388
4.15625
4
# Write a program that takes a list of strings and a string containing a single character, and prints a new list of all the strings containing that character. word_list = ['hello','world','my','name','is','Anna'] char = 'o' newList = [] for count in range(0, len(word_list)): for c in word_list[count]: if ...
true
8a833841f94024fa0c6e5185a78d4b404716ba8c
Hikareee/Phyton-exercise
/Programming exercise 1/Area of hexagon.py
266
4.3125
4
import math #Algorithm #input the side #calculate the area of the hexagon #print out the area #input side of hexagon S = eval(input("input the side of the hexagon: ")) #area of the hexagon area=(3*math.sqrt(3)*math.pow(S,2))/2.0 #print out the area print (area)
true
0fd112e01e2545fb78af3211f1f1d12dd0159d24
Lukhanyo17/Intro_to_python
/Week7/acronym.py
538
4.15625
4
def acronym(): acro = '' ignore = input("Enter words to be ignored separated by commas:\n") title = input("Enter a title to generate its acronym:\n") ignore = ignore.lower() ignore = ignore.split(', ') title = title.lower() titleList = title.split() titleList.append("end"...
true
a51357020c8422857735e9092ed7b35fa3992060
samvelarakelyan/ACA-Intro-to-python
/Practicals/Practical5/Modules/pretty_print.py
667
4.25
4
def simple_print(x:int): """ The function gets an integer and just prints it. If type of function argument isn't 'int' the function print 'Error'. """ if isinstance(x,int): print("Result: %d" %x) else: print("Error: Invalid parametr! Function parametr should be integer") def...
true
6ca26100985fc23524b13578e97cde54a42f2f70
twhay/Python-Scripts
/Dice Simulator.py
509
4.21875
4
# Python Exercise - Random Number Generation - Dice Generator # Import numpy as np import numpy as np # Set the seed np.random.seed(123) # Generate and print random float r = np.random.rand() print(r) # Use randint() to simulate a dice dice = np.random.randint(1,7) print(dice) # Starting step step = 50 # Finish th...
true
6065b6d6ecb45e18d532a5a3bcf765851e97d1eb
iMeyerKimera/play-db
/joins.py
929
4.34375
4
# -*- coding: utf-8 -*- # joining data from multiple tables import sqlite3 with sqlite3.connect("new.db") as connection: c = connection.cursor() # retrieve data c.execute(""" SELECT population.city, population.population, regions.region FROM population, regions WHERE population.city = r...
true
2909e9da710ee8da8f33f9c67687f697c8db7385
lorenanicole/abbreviated-intro-to-python
/exercises/guessing_game_two.py
1,143
4.34375
4
#!/usr/bin/env python # -*- coding: utf-8 -*- from __future__ import print_function import random """ ITERATION THREE: Now that you have written a simple guessing game, add some logic in that determines if the game is over when either: * user has correctly guesses the number * user has reached 5 guesses Let's use tw...
true
b9a599544b5dbf2e0cf855cfe9b848f3fec098eb
juliakyrychuk/python-for-beginners-resources
/final-code/oop/car.py
777
4.25
4
class Car: """Represents a car object.""" def __init__(self, colour, make, model, miles=0): """Set initial details of car.""" self.colour = colour self.make = make self.model = model self.miles = miles def add_miles(self, miles): """Increase miles by given n...
true
70504fde426af3e446033709871f1d5219844539
Farmerjoe12/PythonLoanLadder
/pythonLoanLadder/model/Loan.py
1,234
4.1875
4
import numpy import math class Loan: """ A representation of a Loan from a financial institution. Loans are comprised of three main parts, a principal or the amount for which the loan is disbursed, an interest rate because lending companies are crooked organizations which charge y...
true
0a0558e50b0bd8f9f41348596aae5c06ac66c7e7
LIZETHVERA/python_crash
/chapter_7_input_while/parrot.py
788
4.3125
4
message = input ("Tell me something, and i will repetar it back to you: ") print (message) name = input ("please enter your name: ") print ("hello, "+ name + "!") prompt = "If you tell us who you are, we can personalize the messages you see" prompt += "\nWhat is your first name?" name = input (prompt) print ("\nHe...
true
f25f1e4333a6c8a4ef1f22eb18a430ad3be862ab
olsgaard/adventofcode2019
/day01_solve_puzzle1.py
801
4.5
4
""" 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 and rounding do...
true
77da7fdefd5a5ddc68ce5652094f4ad1b627d3a3
stefantoncu01/Pizza-project
/pizza_project.py
2,981
4.125
4
class Pizza: """ Creates a pizza with the attributes: name, size, ingredients """ def __init__(self, name, size): self.name = name self.size = size self.ingredients = None @property def price(self): """ Calculates the price based on size and i...
true
e378f29d1bd2dbf43f88f0a0d2333f811150be2f
scvetojevic1402/CodeFights
/CommonCharCount.py
660
4.15625
4
#Given two strings, find the number of common characters between them. #Example #For s1 = "aabcc" and s2 = "adcaa", the output should be #commonCharacterCount(s1, s2) = 3. #Strings have 3 common characters - 2 "a"s and 1 "c". def commonCharacterCount(s1, s2): num=0 s1_matches=[] s2_matches=[] f...
true
c2d0e8489e7783edf1fc6a5548825a77da605e57
dayanandtekale/Python_Basic_Programs
/basics.py
1,303
4.125
4
#if-else statements: #score=int(input("Enter your score")) #if score >=50: # print("You have passed your exams") # print("Congratulations") #if score <50: # print("Sorry,You have failed Exam") #elif statements: #score=109 #if score >155 or score<0: # print("Your score is invalid") #elif s...
true
613a833ae062123c4f5a81af2e957fb28fea74cd
cxdy/CSCI111-Group4
/project1/GroupProect1 BH.py
1,054
4.40625
4
firstname1 = input("Enter a first name: ") college = input("Enter the name of a college: ") business = input("Enter the name of a business: ") job = input("Enter a job: ") city = input("Enter the name of a city: ") restaurant = input("Enter the name of a restaurant: ") activity1 = input("Enter an activity: ") activity2...
true
10e396f5019fd198a588d543c6746a642867496c
DSR1505/Python-Programming-Basic
/04. If statements/4.05.py
309
4.15625
4
""" Generate a random number between 1 and 10. Ask the user to guess the number and print a message based on whether they get it right or not """ from random import randint x = randint(1,10) y = eval(input('Enter a number between 1 and 10: ')) if(x == y): print('You get it right') else: print('Try again')
true
4c590e8a0ff2058228a40e521d4dc31b1978ee9e
DSR1505/Python-Programming-Basic
/02. For loops/2.14.py
276
4.34375
4
""" Use for loops to print a diamond. Allow the user to specify how high the diamond should be. """ num = eval(input('Enter the height: ')) j = (num//2) for i in range(1,num+1,2): print(' '*j,'*'*i) j = j - 1 j = 1 for i in range(num-2,0,-2): print(' '*j,'*'*i) j = j + 1
true