blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
9fd0574ae06a3aa4c704702dbc741b977a4341cb
FlowerbeanAnsh/python_problems_2
/func.calculate.py
570
4.1875
4
def calculate(a,b): if op=='+': c=a+b return c elif op=='-': d=a-b return d elif op=='*': e=a*b return e elif op=='/': f=a/b return f elif op=='%': g=a%b return g else: return False f=float(input("enter the f...
false
9080fdd3d9bc764d2e48e34b8ad3282f8fcf13d6
Nihilnia/reset
/Day 3 - list Comprehension.py
1,032
4.25
4
# LIST COMPREHENSION listem = [1, 2, 3, 4, 5] yeniListem = [] for f in listem: yeniListem.append(f) # print("Eski liste:", listem) # print("Yeni liste:", yeniListem) #ListComp. nihilList = [f for f in listem] print("Nihil list:", nihilList) listeDemet = [(1, 2), (3, 4), (5, 6)] recepList = ...
false
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
7cd318ccc78e1cf79b698818518639ea10ab78b5
VitalShimanski/Study_Python
/Dictionaries_DZ9.py
748
4.21875
4
favorite_languages = { 'jen': 'python', 'sarah': 'c', 'edward': 'ruby', 'phil': 'python', } peoples = ['adam', 'sergey', 'jen', 'sarah', 'edward', 'lesly', 'amanda', 'phil', 'ivan'] for name in peoples: if name in peoples and name not in favorite_languages: print(f"{name.title()} please tak...
false
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
dab9df4b39ba0b10328ea214191edd108e8a3aa1
ja-vu/SeleniumPythonClass
/Class1/venv/sec4.py
705
4.1875
4
""" Sec 4 - 22 """ cars = ["bmw", "audi", "lexus"] empty_list = [] print(cars) print(empty_list) print("*#" * 20) print(cars[0]) num_list = [1, 2, 3] sum_num = num_list[0] + num_list[1] print(sum_num) more_cars = ["honda", "toyota", "KIA"] print(more_cars[1]) more_cars[1] = "Benz" print(more_cars[1]) print(mo...
false
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
4ae8f3a983da434c15c25f8da5df8cfb000789f1
prasoonsoni/Python-Questions-1st-Semester
/EXERCISES/find no of small spheres.py
533
4.25
4
# OPERATORS """ Q.1 --- TO FIND NO OF SMALL SPHERES OF RADIUS 'r' THAT CAN BE STORED IN THE LARGE SPHERE OF RADIUS 'R' """ R = float(input("ENTER RADIUS OF LARGE SPHERE(in cm) : ")) r = float(input("ENTER RADIUS OF SMALL SPHERE(in cm) : ")) V = (4/3)*3.14*R*R*R # V = VOLUME OF L...
false
e7c927f7a0dc6d4b8fedc95b86665744f50c2d2e
prasoonsoni/Python-Questions-1st-Semester
/EXERCISES/how to use elif.py
295
4.21875
4
""" how to use elif if condition: statements elif condition: statements """ # largest of three numbers # a = int(input()) b = int(input()) c = int(input()) if a>b and a>c: print (a, "is greatest") elif b>c: print (b, "is greatest") else: print (c, "is greatest")
false
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
3d8eaebda59ce03927c28a1b41d44248e2885614
BerilBBJ/scraperwiki-scraper-vault
/Users/1/1019987/threecirclesunderneath-each-otherpy.py
838
4.28125
4
""" This program draw three circles underneath each other""" import turtle turtle.color('Red') turtle.circle (50,360) turtle.right(90) turtle.up() turtle.forward(10) turtle.forward(50) turtle.forward(50) turtle.left(90) turtle.color('yellow') turtle.circle(50,360) turtle.up() turtle.down() turtle.right(90) turtle.up()...
false
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
0c6bd0800bf3c1dd2700d50fc7f64de1996ecb5b
Rashi876/python-tasks
/Task 7.py
369
4.125
4
a=float(input("Enter the first number")) b=float(input("Enter the second number")) c=float(input("Enter the third number")) if(a>b): if(a<c): median=a elif(b>c): median=b else: median=c else: if(b<c): median=b elif(a>c): median=a else: med...
false
0244029696dae8f62056f5a9ec987e027a5f9ecb
AH-Toby/PythonBasic
/code/9.python面向对象(二)/demo03.py
1,152
4.15625
4
# 老猫将自己的一身本领传给小猫,同时狗狗也将自己看家的本事传给了小猫 # 定一个父类 class Cat(object): def __init__(self): self.kongfu = "厉害的捉鱼本领" def make_fish(self): print("利用%s抓鱼" % self.kongfu) # 定义第二个父类 class Dog(object): def __init__(self): self.kongfu = "厉害的看家本领" def kanmen(self): print("利用%s看家" %...
false
4258ee738af904684f7d8037c4a5fd2c3a84f7ff
Jesussilverioe/Python-Adventures
/Classes.py
475
4.15625
4
class Dog: """Class to create a dog object""" def __init__(self, name, age): self.name = name self.age = age def sit(self): print(f"{self.name} is sitting...") print(f"{self.name} is sit.") def roll(self): print(f"{self.name} is rolling...") print(f"...
false
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
d38b6f8261f2631f0495bd84160bb6cf1c65400b
julElliot/python
/04.05.2020.py
517
4.125
4
# Программа высчитывает Индекс Массы Тела по введённым параметрам: вес и рост. print('Введите Ваш вес в килограммах: ') weight = int(input()) print('Введите Ваш рост в сантиметрах: ') hight = int(input()) bmi = weight/(hight/100)**2 print('Ваш индекс массы тела:', bmi) STEPS = 40 scale = '10' + "=" * (round(bmi) - ...
false
ada2fab713a61884211b9f9ebf5fa68d37c8ade1
coopwilliams/Intro-Python-I
/src/is_prime.py
785
4.21875
4
def is_prime(n): """Returns True if number is prime.""" if n is not abs(int(n)): return False #test n a positive number. if n < 2: #0 and 1 are not primes return False if n == 2: #2 is the only...
false
36b62323bcec79e9690b95b77543581a22af6bd6
Oscar1305/Python
/Python/Calculadoras.py
478
4.125
4
""" Crea una calculadora que haga las siguientes operaciones con dos números: suma + resta - producto * división / módulo % """ #variables globales: Acceda a elas desde cualquier parte de mi programa num1 = 5 num2 = 6 num3 = 7 print ("suma:" + str(num1 + num2 + num3)) print ("suma:" + str(num2 + num1)) pr...
false
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
79cc3350735b4fa849f7b9d48a10d7f02f24b057
ArthurCisotto/insper.dessoft
/Aula 05. Laço/calcula_soma.py
267
4.125
4
soma = 0 num = float(input('Digite o número que você deseja somar ou digite 0 para concluir a soma')) while num != 0: soma = soma + num num = float(input('Digite o número que você deseja somar ou digite 0 para concluir a soma')) print('A soma é:', soma)
false
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
efdb099231e847d9da3cf288a40ed527b7dd6060
Gowrishankarvv/Hacktoberfest21-letshack
/C Programs/reverseNo.py
263
4.28125
4
def ReverseNo(): num=int(input("Enter the number to reverse:")) reversed_num=0 while num != 0: digit = num % 10 reversed_num = reversed_num * 10 + digit num //= 10 print("Reversed Number: " + str(reversed_num)) ReverseNo()
false
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
b9aa29a971fcda956d7544ff022ba955b1a3a866
Igr1k001/Programming
/Practice/07/Python/07 PY/07 PY/_07_PY.py
2,130
4.125
4
import math print('Введите число 1 или 2:') print('1-ввод параметров треугольника через длины сторон.') print('2-ввод параметров через координаты вершин или другое целое число по модулю.') d = float(input()) while d != 1 and d != 2: print('Ошибочный ввод') print('Введите число 1 или 2:') print('1-ввод пара...
false
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
155c1b1e0fc521c3940f254975c58764777bc127
ankit1997/Computer-Graphics-Programs-in-Python
/dda_line.py
999
4.28125
4
import turtle print("DDA line drawing algorithm implementation.") x1 = int(input("Enter x1: ")) y1 = int(input("Enter y1: ")) x2 = int(input("Enter x2: ")) y2 = int(input("Enter y2: ")) window = turtle.Screen() pointer = turtle.Turtle() pointer.shape("arrow") pointer.hideturtle() pointer.pensize(4) def setPixel(x, ...
false
5d1ffec6bcee9bedbccf214e2bd79c8eab7eb0a0
Sayalikajale/python
/unions.py
939
4.15625
4
def union1(l1, l2): l3 = [] for element in l1: if element not in l3: print element, 'element' count = 0 a = l1.count(element) print a, 'value of a' b = l2.count(element) print b, 'value of b' if a >= b: count1 = a else: count1 = b print count1, 'count' while count1 > 0: l3....
false
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
9ea5dee621ccdce9117e4c3cb15b9be5a414c876
mallikarjuna-sharma/PythonWeb
/MyPy.py
1,888
4.15625
4
import sqlite3 from EmployeeClass import Employee conn = sqlite3.connect('MyDataBase.db') cur = conn.cursor() # cur.execute("""CREATE TABLE employees ( # first text, # last text, # pay integer )""") def insert(emp): with conn: cur.execute("INSERT IN...
false
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
06be15bbdc3c50376550b8f9b3b049da1e5e5849
anmol/algorithm_python
/leetcode/arrays/rotate_k_elems.py
411
4.125
4
#!/usr/bin/env python3 # reverse array subset in place def rev(arr, start, end): while start < end: arr[start], arr[end] = arr[end], arr[start] start += 1 end -= 1 def rotate(nums, k): k %= len(nums) rev(nums, 0, len(nums) - 1) rev(nums, 0, k - 1) rev(nums, k, len(nums) -...
false
681c43fe57b36e028dbf4cb231acd076186bd207
anmol/algorithm_python
/random_problems/counting_mins.py
1,678
4.125
4
""" count mins between the string having a time interval """ def count_mins(s): # split two times t1_raw = s.split('-')[0] t2_raw = s.split('-')[1] t1_12 = get_time_tuple(t1_raw) t2_12 = get_time_tuple(t2_raw) t1 = convert24(t1_12) t2 = convert24(t2_12) # if t2[0] >= t1[0] and t2[1] >...
false
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
be7e215bc2b40ae1920246fdf584fffc8d785ee4
cleversonmuller/cleversonmuller
/atividade4.py
1,116
4.25
4
#Faça um programa que faça 5 perguntas para uma pessoa sobre um crime. As perguntas são: #"Telefonou para a vítima?" #"Esteve no local do crime?" #"Mora perto da vítima?" #"Devia para a vítima?" #"Já trabalhou com a vítima?" # O programa deve no final emitir uma classificação sobre a participação # da pessoa no crime.S...
false
b8ce9abe820e5e2d1640a4928f51de93ac1b30e1
patilvikas0205/python-Exercise
/type_casting_hex_octa_bin_to_int.py
1,104
4.4375
4
#type casting in python convert datatypes explicitely #this program convert binary, octal, hexadecimal object type to int #octal to int octal_num=0O17 print("Type of Octal_num before: ",type(octal_num)) ocatl_to_int=int(octal_num) print("Octal to int: ",ocatl_to_int) print("Type of Octal_num after: ",type(ocat...
false
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
8fa31985dd13ea2f6607f2ed993ae71238fd254c
cassieeric/Python-Exercises_Interview_questions
/简单算法题/排序算法/选择排序/选择排序.py
418
4.15625
4
# -*- coding: utf-8 -*- def selection_sort(list): for i in range(len(list)): min_index = i for j in range(i + 1, len(list)): if list[j] < list[min_index]: min_index = j list[i], list[min_index] = list[min_index], list[i] if __name__ == '__main__': ...
false
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
df951ef9a7474d2b2ad0a29469e4dd68702e8bab
Ananya31-tkm/PROGRAMMING_LAB_PYTHON
/lab_s1/CO1-Q17,Q18.py
291
4.21875
4
dict ={'Swathi':67,'Anu':98,'Riya':66,'Vismaya':88,'Neema':75,'Reshma':89} import operator dict1=sorted(dict.items(),key=operator.itemgetter(1),reverse=True) print("Descending order:",dict1) dict1=sorted(dict.items(),key=operator.itemgetter(1),reverse=False) print("Ascending order:",dict1)
false
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
34ca930f77410dfda01dddb101f95ef5c9b83719
bigcat2014/Intro_to_Graduate_Algorithms
/fib.py
617
4.3125
4
#!/usr/bin/python3 # Calculates the nth fibonacci number recursively # Inputs: n >= 0 # Outputs: The nth fibonacci number # Running Time O(n^2) def FIB1(n): if n == 0: # O(1) return 0 elif n == 1: # O(1) return 1 else: # O(n^2) return FIB1(n - 1) + FIB1(n - 2) # O((n-1)...
false
7d0df7467a4dc36f0ec5833cef30002d5935d660
vthorat1986/python-programs
/Regular_Expressions.py
1,182
4.21875
4
#!/usr/bin/python import re # ========== Search & Replace ============== phoneNum = '8149-13-80-26 # This is a phone number' num = re.sub(r'#.*$', '', phoneNum) print('Phone number after commet removal : ', num) num = re.sub(r'\D', '', phoneNum) print('Phone number ater removal of all non-digits : ', num)...
false