blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
0dfcd53fb2f4d82b58ce43b5726c6d682b61dc95
SarwarSaif/Python-Problems
/Hackerank-Problems/NestedList.py
1,897
4.25
4
# -*- coding: utf-8 -*- """ Created on Sat Sep 29 12:30:26 2018 @author: majaa """ if __name__ == '__main__': marksheet=[] """ for _ in range(int(input())): marksheet.append([input(),float(input())]) """ n = int(input()) marksheet = [[input(), float(input())] for _ in ra...
true
afb1f832a96caef7312c407477962a7b7ccbd0e5
kubawyczesany/python
/case_swapping.py
253
4.375
4
# Given a string, simple swap the case for each of the letters. # e.g. HeLLo -> hEllO string = input ("Give a string to swap: ") def swap(string_): _string = ''.join([i.upper() if i.islower() else i.lower() for i in string_]) return (_string)
true
dc31d568218f5f710d20afc46f9b876c0e09c8a9
lsaggu/introduction_to_python
/programs/programs.py
1,874
4.28125
4
#! /usr/bin/python import sys ''' her is the task i like you to do to reinforce the learning experience once you are done with the tutorial. a) write a program that uses loops over both x and y coordinates while x is in 1,2,3,4,5 and y is in 5,4,3,2,1 and prints the x and y coordinate b) write a program that sums u...
true
e689091397f37f3b4b166d1510e3dac045b8f799
AbdulMoizChishti/python-practice
/Pfundamental Lab/Lab 7/task 2.py
269
4.25
4
def max(a, b, c): if a>b and a>c: print(a) elif b>c and b>a: print(b) else: print(c) a=int(input("first number=")) b=int(input("second number=")) c=int(input("third number=")) max(a, b, c) print("is the maximum of three integers")
true
0ec6649be950c71297dbc01a294c67b4ba388fc2
CharlieCarlon/EstructuraDeDatos20188
/Actividad2Unidad1.py
1,693
4.21875
4
"""Iciciamos variables""" n=0 """Creamos la libreria cache esta va a guardar las llamadas a la fuuncion mas renciente para que no gaste tanto en memoria volviendo a llamar a la funcion""" fibonacci_cache = {} def fibonacci(n): """Se revisa si el valor esta guardado en nuestra libreria, si no calculamos el te...
false
461ad5fff551ecfbb109842b78c03a33c3fe6156
akshaali/Competitive-Programming-
/Hackerrank/minimumDistances.py
1,525
4.375
4
""" We define the distance between two array values as the number of indices between the two values. Given , find the minimum distance between any pair of equal elements in the array. If no such value exists, print . For example, if , there are two matching pairs of values: . The indices of the 's are and , so their ...
true
34240c8a1cd3c2132e6bd8121ae449b44ec92c58
akshaali/Competitive-Programming-
/Hackerrank/TimeConversion.py
1,432
4.1875
4
""" Given a time in -hour AM/PM format, convert it to military (24-hour) time. Note: Midnight is 12:00:00AM on a 12-hour clock, and 00:00:00 on a 24-hour clock. Noon is 12:00:00PM on a 12-hour clock, and 12:00:00 on a 24-hour clock. Function Description Complete the timeConversion function in the editor below. It sh...
true
689a7f8c2643819de8930cfc93ceab46697b605a
akshaali/Competitive-Programming-
/Hackerrank/pickingNumbers.py
2,479
4.5625
5
""" Given an array of integers, find and print the maximum number of integers you can select from the array such that the absolute difference between any two of the chosen integers is less than or equal to . For example, if your array is , you can create two subarrays meeting the criterion: and . The maximum length su...
true
c9488b2c6856e3c6b87db68ee117bb4e01380325
akshaali/Competitive-Programming-
/Hackerrank/designerPDFViewer.py
2,008
4.21875
4
""" When you select a contiguous block of text in a PDF viewer, the selection is highlighted with a blue rectangle. In this PDF viewer, each word is highlighted independently. For example: PDF-highighting.png In this challenge, you will be given a list of letter heights in the alphabet and a string. Using the letter ...
true
0e016e34e46435270dc0bba650016e7ba56a2ced
akshaali/Competitive-Programming-
/Hackerrank/gridChallenge.py
2,281
4.15625
4
""" Given a square grid of characters in the range ascii[a-z], rearrange elements of each row alphabetically, ascending. Determine if the columns are also in ascending alphabetical order, top to bottom. Return YES if they are or NO if they are not. For example, given: a b c a d e e f g The rows are already in alphabe...
true
918519d14aa6d0984c66c9bd431c51d9ac82c263
akshaali/Competitive-Programming-
/Hackerrank/anagram.py
2,668
4.4375
4
""" Two words are anagrams of one another if their letters can be rearranged to form the other word. In this challenge, you will be given a string. You must split it into two contiguous substrings, then determine the minimum number of characters to change to make the two substrings into anagrams of one another. For e...
true
54c0a48e87f31af1f129a16230921cce367a1dbc
akshaali/Competitive-Programming-
/Hackerrank/AppendandDelete.py
2,682
4.125
4
""" You have a string of lowercase English alphabetic letters. You can perform two types of operations on the string: Append a lowercase English alphabetic letter to the end of the string. Delete the last character in the string. Performing this operation on an empty string results in an empty string. Given an integer...
true
ce478a6ae35501cd55525ebe7526d08075507965
ariv14/python
/Day2_number_manipulation/life_left_mini_project/life_left_mini_project.py
676
4.15625
4
# Lifetime calculator print("Lifetime calculator\nEnter your age and maximum expected age\n") age = input("Enter your age : ") max_age = input("Enter your maximum lifetime age :") print("\n") age_in_months = int(age) * 12 age_in_days = int(age) * 365 age_in_weeks = int(age) * 52 max_age_years = int(max_age) max_age_mo...
false
83e4ae0872601c41974ea40725d6dace62e0d338
ariv14/python
/Day3_if_else/ifelse.py
328
4.4375
4
# Even or odd number finder print("Welcome!! Please input any number to check odd or even !!\n") # Get the input number as integer number = int(input("Which number do you want to check? ")) #Write your code below this line if number % 2 == 0: print("The number is even number") else: print("The number is odd n...
true
5b05abfb21bf9b8dea2dd9de4d1d859b09dc0dd5
selinoztuurk/koc_python
/inclass/day1Syntax/lab1.py
1,416
4.25
4
def binarify(num): """convert positive integer to base 2""" if num<=0: return '0' digits = [] division = num while (division >= 2): remainder = division % 2 division = division // 2 digits.insert(0, str(remainder)) digits.insert(0, str(division % 2)) return ''.join(digits) print(binarify(10)...
true
6f384b9f9c31765b2c7cb5e22af25202d686deb0
JusticeLenon/ProjectEuler
/project_euler.py
456
4.1875
4
''' List all multiples of 3 and 5 from 0 to 10000 and return the sum''' def if_multiple( nat_number ): '''Return True if it is a multiple of 3 or 5''' for i in range(1,10): if i % 3 == 0 or i % 5 == 0 : print i, 'True' else: print i, 'False return def apppend_to_arrray( myarray, ite...
false
c08f06f789fc81a1672e797a41c1d8cc39801864
ptrkptz/udemy_python
/Python_Course/17_conditionals.py
841
4.125
4
grade1 = float(input ("Type the grade of the first test: ")) grade2 = float(input ("Type the grade of the second test: ")) absenses = int(input ("Type the number of absenses: ")) total_classes = int(input("Type the total number of classes: ")) avg_grade = (grade1 + grade2) /2 attendance = (total_classes - absenses) / ...
true
1055f864fb549ae4202482553b16be2c046ff3d6
ptrkptz/udemy_python
/Python_Course/15_booleans.py
249
4.125
4
num1 = float(input("Type the 1st num:")) num2 = float(input("Type the 2nd num:")) if (num1 > num2): print(num1, " is greater than ", num2) elif(num1==num2): print(num1, " is equal to ", num2) else: print(num1, " is less than ", num2)
true
504b12b8de997337e4c6166ded242ff6d93d14ce
nimus0108/python-projects
/Tri1/anal_scores.py
535
4.25
4
# Su Min Kim # Analysis Scores num = input("") num_list = num.split() greater = 0 less = 0 def get_mean (num_list): m = 0 i = 0 x = len(num_list) for i in range (0, x): number = int(num_list[i]) m += number mean = m/x return mean for num in num_list: number = int(num) ...
true
c876053f4a23e86dcda291995c5142396ae5709f
meanJustin/Algos
/Demos/MergeSort.py
1,451
4.15625
4
# Python program for implementation of Selection # Sort import sys import time def mergeSort(arr): if len(arr) >1: mid = len(arr)//2 # Finding the mid of the array L = arr[:mid] # Dividing the array elements R = arr[mid:] # into 2 halves mergeSort(L) # Sorting the first ...
true
181accc46b0d03467a765e1b6f1fe8949f2799dc
prathapSEDT/pythonnov
/Collections/List/Slicing.py
481
4.1875
4
myList=['a',4,7,2,9,3] ''' slicing is the concept of cropping sequence of elements to crop the sequence of elements we need to specify the range in [ ] synatx: [starting position: length] here length is optinal, if we wont specify it, the compiler will crop the whole sequence form the starting position ''' # from inde...
true
8c94185a47805431f457cb157523350c318ba831
prathapSEDT/pythonnov
/Collections/List/Len.py
208
4.1875
4
''' This length method is used to get the total length of elements that are available in the given list ''' myList=['raj','mohan','krish','ram'] ''' get the toatal length of a given list''' print(len(myList))
true
3aee5a7a4a62a9ab4339ff518c5efaa5e0afa539
prathapSEDT/pythonnov
/looping statements/WhileLoop.py
244
4.1875
4
''' while loop is called as indefinite loop like for loop , while loop will not end by its own in the while we need write a condition to break the loop ''' ''' Print Numbers from 1-50 using while loop ''' i=1 while(i<=50): print(i) i+=1
true
74095d49c7c1c157eb5aaed88edc31662600440c
wangrui-spiderNet/Python-100examples
/homework01.py
1,454
4.15625
4
# coding=UTF-8 ''' 【程序2】 题目:企业发放的奖金根据利润提成。利润(I)低于或等于10万元时,奖金可提10%;利润高    于10万元,低于20万元时,低于10万元的部分按10%提成,高于10万元的部分,可可提    成7.5%;20万到40万之间时,高于20万元的部分,可提成5%;40万到60万之间时高于    40万元的部分,可提成3%;60万到100万之间时,高于60万元的部分,可提成1.5%,高于    100万元时,超过100万元的部分按1%提成,从键盘输入当月利润I,求应发放奖金总数? 1.程序分析:请利用数轴来分界,定位。注意定义时需把奖金定义成长整型。       2.程序源代码: ''' ...
false
9266236293a7e1c49900110e7e408876fcddf99d
VectorSigmaGen1/Basic_Introductory_Python
/Practical 10 - 3rd October 2019/p10p1.py
1,261
4.28125
4
# program to calculate the positive integer square root of a series of entered positive integer """ PSEUDOCODE request input for a positive integer and assign to variable num print "Please enter the positive integer you wish to calculate the square root of (Enter a negative integer to exit program): " ...
true
13080a3947d52e11797bd399fe8e3e3342dc4091
VectorSigmaGen1/Basic_Introductory_Python
/Practical 13 - 10th October/p13p5.py
1,013
4.53125
5
# Program to illustrate scoping in Python # Added extra variables and operations """ Pseudocode DEFINE function 'f' of variable 'x' and variable 'y' PRINT "In function f:" Set x = x+1 Set y = y * 2 set z = x-1 PRINT "x is", 'x' PRINT "y is", 'y' PRINT "z is", 'z' RETU...
true
7d1038aaa9fe2af8374685ac523187026e58280a
VectorSigmaGen1/Basic_Introductory_Python
/Practical 09 - 3rd October 2019/p9p3.py
969
4.28125
4
# program to calculate the factorial of an entered integer """ Pseudocode Set num = 0 WHILE input >= 0; Request input Print "Please enter a positive integer (If you wish to terminate the program, please enter a negative integer): " run = 1 for i in range(1, input+1, 1) run = run * i...
true
0f1ad4d9a1bb6273f8e442b39f5c3281b4bd7e1a
VectorSigmaGen1/Basic_Introductory_Python
/Practical 07 - 26th Sep 2019/p7p3.py
619
4.34375
4
# program to print the first 50 integers and their squares # for this program, I've used the first 50 positive integers starting with 0 and ending with 49 ''' print 'This is a program to print the integers 0 to 49 and their squares' set variable=int(0) While variable <50 print variable print variab...
true
7a63238e5cb6c4ea552dfa07a6c3f7470c452dfa
VectorSigmaGen1/Basic_Introductory_Python
/Practical 12 - 8th October 2019/p12p2.py
1,703
4.40625
4
# Define the function fibonacci which displays 'a' number of terms of the Fibonacci Sequence # Program to check if an entered integer is a positive integer and if so to apply the function factorial to produce an answer """ Pseudocode Define function 'fibonacci' of a variable 'a': IF a > 0 set vari...
true
6f859d260c8d4fd41bb03d315defb665e4bc20f2
VectorSigmaGen1/Basic_Introductory_Python
/Practical 11 - 3rd October 2019/p11p3.py
1,772
4.5
4
# Program to check if an entered integer is a positive integer and if so to display that number of terms from the Fibonacci Sequence """ Pseudocode request the input of an integer and assign it to variable 'length' print "Please enter the number of terms in the Fibonacci Sequence you would like: " WHILE leng...
true
7fb84f004a36f1ca3e2b6dee6c5c91652c8b46ef
VectorSigmaGen1/Basic_Introductory_Python
/Practical 07 - 26th Sep 2019/p7p4.py
746
4.28125
4
# program to add the first 5000 integers and give an answer # for this program, I've used the first 5000 positive integers, # starting with 0 and ending with 4999. """ print 'This is a program to add the integers 0 to 4999 and give a total' set variable=int(0) set sum=int(0) While variable <5000 set s...
true
db540b0084bd73a4f11a39cdadc04c394ad4e7cb
VectorSigmaGen1/Basic_Introductory_Python
/Practical 18 - 17th October 2019/p18p1.py
1,328
4.34375
4
# an iterative version of the isPal function # Checks whether a supplied string is a palindrome """ Pseudocode DEFINE function 'isPal(s)' Get the length of 's' and assign it to variable 'length' IF 'length' <=1 RETURN TRUE ELSE set variable 'check' = 0 FOR 'i' in rang...
true
bfdacaad653068d62f82e45ace3cb120c33a5572
Vanshikagarg17/StonePaperScissor-Game
/Rock_Paper_Scissors v1.1.py
1,039
4.25
4
from random import randint winning=2 #scores comp=0 p=0 #scores while p<winning and comp<winning: rand_num = randint(0,2) print(f"computer score:{comp} player score:{p}\n") player = input("Player, make your move: \n").lower() if player=="quit" or player=="q": break if rand_num == 0: computer = "rock" elif ...
false
6416bbd289069b4ad2208b0db6efe9e78c2cd05b
LuckyTyagi279/Misc
/python/loops_if.py
481
4.1875
4
#!/usr/bin/python # Loops # While Loop while 0 : Var=0 while Var < 5 : Var = Var + 1 print Var print "This is not in the loop!" # Conditional Statement # If statement while 0 : Var=1 if Var == 2 : print "Condition is TRUE!" else : print "Condition is FALSE!" while 0 : Var = 0 while Var <= 100 : if...
true
9176b405a1e2bf36da7475b43bc8470864f44aa1
zacherymoy/cs-module-project-recursive-sorting
/src/sorting/sorting.py
1,583
4.15625
4
# TO-DO: complete the helper function below to merge 2 sorted arrays def merge(arrA, arrB): elements = len(arrA) + len(arrB) merged_arr = [0] * elements # Your code here # print("merging",arrA,arrB) arrA_idx = 0 arrB_idx = 0 idx = 0 while arrA_idx < len(arrA) and arrB_idx < len(arrB): ...
false
0adc8e05c38e52d54f8667a0fc8e4a99337941ed
traines3812/traines3812.github.io
/range_demo.py
605
4.5625
5
# The range function generates a sequence of integers a_range = range(5) print('a_range ->', a_range) print('list(a_range) ->', list(a_range)) # It is often used to execute a "for"loop a number of times for i in range (5): print(i, end= ' ') # executed five times print() # It is similar to the slice functio...
true
7fea623eb32b3b2fbb1b8ef06f61ff42a4f5aeeb
HumayraFerdous/Coursera_Python_Basics
/Week4.py
1,728
4.125
4
#Methods mylist=[] mylist.append(5) mylist.append(27) mylist.append(3) mylist.append(12) print(mylist) mylist.insert(1,12) print(mylist) print(mylist.count(12)) print(mylist.index(3)) print(mylist.count(5)) mylist.reverse() print(mylist) mylist.sort() print(mylist) mylist.remove(5) print(mylist) lastitem=mylist.p...
true
33c556c7f36355f3735523e7cde0cf12868de8ae
Viniciusli/basic-of-python
/5.poo/e6.py
1,500
4.15625
4
# crie uma clsse Elevador. # attrs: andar atual, total de andares (exluindo terreo), capacidade do elevador, # e quantidade de pessoas presentes nele # métodos: incializa, recebe a capacidade, total de andares, entra, acrescenta uma pessoa # sai, subtrae uma pessoa, sobe, sobe um andar, desce, desce um andar # nesse ex...
false
8ab5b7d8b7625d9a4401f9fff431dafc67627cf2
Viniciusli/basic-of-python
/3.lambdas/e12.py
265
4.125
4
# Exercício 2 - Crie uma função que receba uma string como argumento e retorne a mesma # string em letras maiúsculas. Faça uma chamada à função, passando como parâmetro uma # string def str_upper(str): return str.upper() print(str_upper("exemplo"))
false
96bf134d00802ad032852d9f789349fc358b042f
Jennykuma/coding-problems
/codewars/Python/invert.py
368
4.15625
4
''' Invert Values Level: 8 kyu Given a set of numbers, return the additive inverse of each. Each positive becomes negatives, and the negatives become positives. invert([1,2,3,4,5]) == [-1,-2,-3,-4,-5] invert([1,-2,3,-4,5]) == [-1,2,-3,4,-5] invert([]) == [] You can assume that all values are integers. ''' def invert(...
true
b36a9a9b65550021d6a95067e28fadf68555ec67
nishantgautamIT/python_core_practice
/pythonbasics/SetInPython.py
1,273
4.125
4
# Set in python # method in set # 1.union() set1, set2, set3 = {1, 2, 3}, {3, 4, 5}, {5, 6, 7} set_UN = set1.union(set2, set3) print(set1) print(set_UN) # 2. intersection() set_int = set2.intersection(set1) print(set_int) # 3. difference() set_diff = set1.difference(set2) print(set_diff) # 4. symmetric_difference() ...
true
a250d32dc61ec7b738b96e5e911c09434cc6f25f
nvincenthill/python_toy_problems
/string_ends_with.py
417
4.25
4
# Complete the solution so that it returns true if the first argument(string) passed in ends with the 2nd argument (also a string). # Examples: # string_ends_with('abc', 'bc') # returns true # string_ends_with('abc', 'd') # returns false def string_ends_with(string, ending): length = len(ending) sliced = st...
true
c5167aaf0b17bc6b744043c389924270e3e235fe
nguyenlien1999/fundamental
/Session05/homework/exercise3.py
408
4.625
5
# 3 Write a Python function that draws a square, named draw_square, takes 2 arguments: length and color, # where length is the length of its side and color is the color of its bound (line color) import turtle def draw_square(size,colors): f = turtle.Pen() f.color(colors) # f.color(color) for i in range(3): ...
true
3c927b72492f4f9a438ed8711aaff757b0f56009
Elijah-M/Module10
/class_definitions/invoice.py
2,468
4.40625
4
""" Author: Elijah Morishita elmorishita@dmacc.edu 10/26/2020 This program is used for creating an example of the uses of a class """ class Invoice: """ A constructor that sets the variables """ def __init__(self, invoice_id, customer_id, last_name, first_name, phone_number, address, items_with_price=...
true
60769c7f9ecb97369f20e2fcbdb9ba9fd8c70b85
jasanjot14/Data-Structures-and-Algorithms
/Algorithms/iterative_binary_search.py
1,661
4.375
4
# Function to determine if a target (target) exists in a SORTED list (list) using an iterative binary search algorithm def iterative_binary_search(list, target): # Determines the search space first = 0 last = len(list) - 1 # Loops through the search space while first <= last: # ...
true
cdb88499d6704ec00b71e07c6386dde534e1acfe
316112840/Programacion
/ActividadesEnClase/EjemplosListas.py
771
4.125
4
S = "==========================================================" #Sucesión de Fibonacci: ListaFib = [1,1] for i in range(10): ListaFib.append( ListaFib[i] + ListaFib[i+1]) print(ListaFib) print(S) #Secuencia de Lucas: ListaLucas = [2,1] for i in range(10): ListaLucas.append( ListaLucas[i] + ListaLucas[i+1])...
false
06bf16ed3dc113f6c43578271d1e63088317cfbc
ajit-jadhav/CorePython
/1_Basics/7_ArraysInPython/a1_ArrayBasics.py
2,409
4.40625
4
''' Created on 14-Jul-2019 @author: ajitj ''' ## Program 1 ## Creating an integer type array import array a = array.array('i',[5,6,7]) print('The array elements are: ') for element in a: print (element) ## Program 2 ## Creating an integer type array v2 from array import * a = arr...
true
fac0907fa4db80c8d9aa200e6f2f25d260e7e3d0
alex-gagnon/island_of_miscripts
/pyisland/src/classic_problems/StringToInteger.py
1,677
4.15625
4
import re class Solution: """Convert a string to an integer. Whitespace characters should be removed until first non-whitespace character is found. Next, and optional plus or minus sign may be found which should then be followed by any number of numerical digits. The digits should...
true
dc5ec5f58a2ea2a44b36b921354884c3ce20d05b
JuliyaVovk/PythonLessons
/Lesson2/task2.py
883
4.46875
4
""" Для списка реализовать обмен значений соседних элементов, т.е. Значениями обмениваются элементы с индексами 0 и 1, 2 и 3 и т.д. При нечетном количестве элементов последний сохранить на своем месте. Для заполнения списка элементов необходимо использовать функцию input() """ my_list = [] while True: item = input(...
false
d42c35cf40853e6e1b60742c5c8aadf0a840d573
returnzero1-0/logical-programming
/sp-7.py
315
4.21875
4
# Python Program to Read Two Numbers and Print Their Quotient and Remainder ''' Quotient by floor division // Remainder by mod % ''' num1=int(input("Enter number 1 :")) num2=int(input("Enter number 2 :")) quotient=num1//num2 remainder=num1%num2 print("Quotient is :",quotient) print("Remainder is :",remainder)
true
a9356775b5a368568b29edc3b03d8a7f0e4a0a94
hscspring/The-DataStructure-and-Algorithms
/CodingInterview2/32_01_PrintTreeFromTopToBottom/print_tree_from_top_to_bottom.py
1,166
4.25
4
""" 面试题32(一):不分行从上往下打印二叉树 题目:从上往下打印出二叉树的每个结点,同一层的结点按照从左到右的顺序打印。 """ class BinaryTreeNode: def __init__(self, val): self.val = val self.left = None self.right = None def connect_binarytree_nodes(parent: BinaryTreeNode, left: BinaryTreeNode, ...
false
d480263ae734088e84a8f207e420f2c85babbf91
hscspring/The-DataStructure-and-Algorithms
/CodingInterview2/06_PrintListInReversedOrder/print_list_in_reversed_order.py
1,152
4.40625
4
""" 面试题 6:从尾到头打印链表 题目:输入一个链表的头结点,从尾到头反过来打印出每个结点的值。 """ class Node: def __init__(self, x): self.val = x self.next = None def print_list_reverse(node) -> list: """ print_list_reverse(Node) Print a linklist reversedly. Parameters ----------- Node: Node Returns ...
false
fd8f8bb43ed0602c7c7d022d9113e0e1b2707462
hscspring/The-DataStructure-and-Algorithms
/CodingInterview2/58_02_LeftRotateString/left_rotate_string.py
1,034
4.125
4
""" 面试题 58(二):左旋转字符串 题目:字符串的左旋转操作是把字符串前面的若干个字符转移到字符串的尾部。 请定义一个函数实现字符串左旋转操作的功能。比如输入字符串 "abcdefg" 和数 字 2,该函数将返回左旋转 2 位得到的结果 "cdefgab"。 """ def left_rotate_string(s: str, index: int) -> str: """ Parameters ----------- Returns --------- Notes ------ """ if not s: re...
false
d30ef4fe2f71d84f33e76247a4952772ccbbbdb1
hscspring/The-DataStructure-and-Algorithms
/CodingInterview2/55_02_BalancedBinaryTree/balanced_binary_tree.py
2,994
4.25
4
""" 面试题55(二):平衡二叉树 题目:输入一棵二叉树的根结点,判断该树是不是平衡二叉树。如果某二叉树中 任意结点的左右子树的深度相差不超过1,那么它就是一棵平衡二叉树。 """ class BSTNode: """docstring for BSTNode""" def __init__(self, val): self.val = val self.left = None self.right = None def connect_bst_nodes(head: BSTNode, left: BSTNode, right: BSTNode) -> BSTN...
false
533516eaf7b44a007b79a9f00e283bfd865ad017
friedaim/ITSE1359
/PSET4/PGM1.py
1,934
4.125
4
# Program to calculate loan interest, # monthly payment, and overall loan payment. def calcLoan(yrRate,term,amt): monthRate = yrRate/12 paymentNum = (pow(1+monthRate,term)*monthRate) paymentDen = (pow(1+monthRate,term)-1) payment = (paymentNum/paymentDen)*amt paybackAmt = payment*term totalInte...
true
532eb7059007dab0ce39b0e7a53559d12c696d86
mjadair/intro-to-python
/functions/arguments.py
1,473
4.375
4
# Navigate to functions folder and type python arguments.py to run # * 🦉 Practice # ! ⚠️Remember to comment out your practice code before attempting below, "cmd" + "/" # ? Define a function "sayHello" that accepts a "name" parameter. It should return a string of 'Hello (the name)!' # ? Call and print the result ...
true
485f7f408cbe0ba4f7ed22f940dfe1da28fc18b4
mjadair/intro-to-python
/control-flow/loops.py
1,190
4.1875
4
# * ----- FOR LOOPS ------ * # ! Navigate to the directory and type `python loops.py` to run the file # * 🦉 Practice # ! ⚠️Remember to comment out your practice code before attempting below, "cmd" + "/" # ? Write a for loop that prints the numbers 0 - 10 # ? Write a for loop that prints the string 'Hello W...
true
afca7c31b72f51f3cf3b96c33dcf0e9da76a4f39
Zahidsqldba07/Python_Practice_Programs
/college/s3p4.py
235
4.1875
4
# WAP to find largest and smallest value in a list or sequence nums = [] n = int(input("How many numbers you want to input? ")) for i in range(n): nums.append(int(input(">"))) print("Max: %d\nMin: %d" % (max(nums), min(nums)))
true
1d91eda9d5e992d2ba82dd74cec9586b5d0c58b4
Zahidsqldba07/Python_Practice_Programs
/college/p7.py
279
4.375
4
# WAP to read a set of numbers in an array & to find the largest of them def largest(arr): return max(arr) arr = list() num = input("How many elements you want to store? ") for i in range(int(num)): num = input("Num: ") arr.append(int(num)) print(largest(arr))
true
6c39bdf7ab868326265d9724569004623651d493
Zahidsqldba07/Python_Practice_Programs
/college/s2p7.py
269
4.125
4
# WAP that demonstrates the use break and continue statements to alter the flow of the loop. while True: name = str(input("Name: ")) if name.isalpha(): print("Hello %s" % name) break else: print("Invalid name.\n") continue
true
b237f52ce5495587b91a32e80c9ab9645fde6c1d
Zahidsqldba07/Python_Practice_Programs
/college/2_9.py
2,585
4.15625
4
relation=raw_input('Enter the relationship:') name=raw_input('Enter the name:') if relation=='parents' and (name=='madd' or name=='sally'): print 'parents are cathy and don' elif relation=='parents' and name=='sarah' : print 'parents are frank and jill' elif relation=='parents' and (name=='frank' or name=='cath...
false
b2cece558ed3391220af52e1e13b2329bca82ab3
Zahidsqldba07/Python_Practice_Programs
/college/s8p2.py
358
4.1875
4
# Define a class name circle which can be constructed using a parameter radius. # The class has a method which can compute the area using area method. class Circle: radius = 0 def __init__(self, radius): self.radius = radius def displayArea(self): print("Area:", (3.14 * (self.radius ** 2...
true
1905d855a2b37259c47229175eefec2625df5482
Zahidsqldba07/Python_Practice_Programs
/college/s4p1.py
264
4.1875
4
# WAP to create a function to swap values of a pair of integers def swap(a, b): a, b = b, a return (a, b) in_a, in_b = input("a: "), input("b: ") print("Before swap a:", in_a, " b:", in_b) s = swap(in_a, in_b) print("After swap a:", s[0], " b:", s[0])
false
6a77a5bca7b96861c6bbd9404ebc467afd28d470
kokilavemula/python-code
/inheritances.py
922
4.25
4
#Create a Parent Class class Person: def __init__(self, fname, lname): self.firstname = fname self.lastname = lname def printname(self): print(self.firstname, self.lastname) #Use the Person class to create an object, and then execute the printname method: x = Person("kokila", "vemula") x.printname()...
true
403e3c0dc245a2f412c3de8ed7d78c3f12fd2e4a
kokilavemula/python-code
/dictionaries.py
611
4.40625
4
thisdict = { "brand": "moto", "model": "2nd gen", "year": 2016 } print(thisdict) #Accessing Items thisdict = { "brand": "moto", "model": "2nd gen", "year": 2016 } x = thisdict["model"] print(x) #Accessing Item in another method thisdict = { "brand": "moto", "model": "2nd gen", "year": 2016 } x = ...
false
7b2d2d37f5acf56da96b52e0665532969285978c
gnoubir/Network-Security-Tutorials
/Basic Cryptanalysis/basic-analyze-file.py
1,983
4.15625
4
#!/usr/bin/python # # computer the frequency of lowercase letters __author__ = "Guevara Noubir" import collections import argparse import string import numpy as np import matplotlib.pyplot as plt parser = argparse.ArgumentParser(description='Analyze a file.') # ./basic-analyze-file.py file # program has one pa...
true
ae9f2189f73437e8ab24932c8f44108d7cbb467d
UMBC-CMSC-Hamilton/cmsc201-spring2021
/classes_start.py
1,501
4.21875
4
""" A class is a new type ints, floats, strings, bool, lists, dictionaries class <-- not really a type a type maker. What kind of things can types have? data inside of them (member variables, instance variables) functions inside of them. """ class Lion: """ ...
true
0fac1e302275fd8c77181ceca7f85afdf0056bc4
mackrellr/PAsmart
/rock_paper_scissors.py
2,208
4.1875
4
import random player_choice = 0 npc_choice = 0 game_on = True # Indicate choices for win def choices(p1, p2): print() if p1 == 1: print('Player choose Rock.') if p1 == 2: print('Player choose Paper.') if p1 == 3: print('Player choose Scissors.') if p2 == 1: pr...
true
9ee2c7e4e8b520c97faf5a6e0c176c1732f991a2
EharaProgramming/python_introduction
/4/4_1.py
814
4.3125
4
# リストの関数 list1 = ["Banana", "Apple", "Tomate", 4000] print(list1) # 要素の追加 list1.append("dddd") print(list1) # リストの結合 list += ["z","c","v","b"] list1.extend(["z","c","v","b"]) print(list1) # 指定した場所に要素を挿入 list1.insert(4, "n") print(list1) # 要素の削除 関数ではない del list1[4] print(list1) # 要素の削除 値指定 lis...
false
a41f693540a8e551d59dc79c64619b7f56220c31
EharaProgramming/python_introduction
/10/10.py
406
4.21875
4
# イテレータ # まずはリストの確認 list = [1, 2, 3, 4, 5] for i in list : if i < 3 : print(i) elif i == 3 : print(i) break for i in list : print(i) # リストからイテレータを生成 it = iter(list) for i in it : if i < 3 : print(i) elif i == 3 : print(i) break ...
false
bde72147f0609811ecca5e12bd8a2b56f1c8d06f
kaliadevansh/data-structures-and-algorithms
/data_structures_and_algorithms/challenges/array_reverse/array_reverse.py
2,916
4.53125
5
""" Reverses input array/list in the order of insertion. """ def reverseArray(input_list): """ Reverses the input array/list in the order of insertion. This method reverses the list by iterating half of the list and without using additional space. :param input_list: The list to be reversed. Returns No...
true
a41a499a78fc0dc44174812b5b3b7db1e12239b3
FranVeiga/games
/Sudoku_dep/createSudokuBoard.py
1,654
4.125
4
''' This creates an array of numbers for the main script to interpret as a sudoku board. It takes input of an 81 character long string with each character being a number and converts those numbers into a two dimensional array. It has a board_list parameter which is a .txt file containing the sudoku boar...
true
b1acafeca378a52e04c04b3935c2cf65a6c65445
chengguobiao/SortAlgorithm
/SelectionSort.py
1,466
4.28125
4
#!usr/bin/env python #-*- coding: utf-8 -*- ''' 名字:直接插入排序(选择排序) 思想:从所有序列中先找到最小的,然后放到第一个位置。之后再看剩余元素中最小的,放到第二个位置 直至排序结束,程序中首轮一般会选第一个元素作为最小值。 ''' import time import random def randomnumber_generate(total_num=100, max_num=1000): num_list = [] n = 1 #得到1000以内的100个随机数 while n <= total_num: lin...
false
828066159ed3f735e0ea6b16ce8c81b23e62ff1d
DipeshDhandha07/Data-Structure
/infix to postfix2.py
1,310
4.1875
4
# The main function that converts given infix expression # to postfix expression def infixToPostfix(self, exp): # Iterate over the expression for conversion for i in exp: # If the character is an operand, # add it to output if self.isOperand(i): self.output.append(i...
true
ca1ad7d1ad24c77156a97b54683f63dc205c2730
kaushikamaravadi/Python_Practice
/Transcend/facade.py
888
4.125
4
"""Facade Design Pattern""" class Vehicle(object): def __init__(self, type, make, model, color, year, miles): self.type = type self.make = make self.model = model self.color = color self.year = year self.miles = miles def print(self): print("vehicle ty...
true
ff5ca971a1feac7ea7c26d34f8e3b63e4a4c2ea5
kaushikamaravadi/Python_Practice
/DataStructures/linked_list.py
2,244
4.1875
4
"""Linked List""" class Node(object): def __init__(self, data=None, next=None): self.data = data self.next = next def get_data(self): return self.data def get_next(self): return self.next def set_next(self, new_next): self.next = new_next class LinkedList(...
true
98dbb8522901dbbc9af3fc2f30eecf2a88dce9b9
toopazo/static_MT_BET_analysis
/python_code/eg_abstract.py
1,252
4.125
4
# Python program showing # abstract base class work from abc import ABC, abstractmethod class Polygon(ABC): @abstractmethod def noofsides(self): pass def classname(self): print('Base class method: type(self) %s ' % type(self)) class Triangle(Polygon): def noofsides(self): p...
false
a80c87614a06de6b2c9b0293520196b93418e5ea
Rokesshwar/Coursera_IIPP
/miniproject/week 2_miniproject_3.py
2,291
4.1875
4
# template for "Guess the number" mini-project # input will come from buttons and an input field # all output for the game will be printed in the console import simplegui import random # initialize global variables used in your code range = 100 secret_num = 0 guesses_left = 0 # helper function to start...
true
d40fe25d7ba3e8e78e35176b949e7a7b09febedc
asperaa/back_to_grind
/DP/0_1_Knapsack | DP 10.py
880
4.1875
4
"""We are the captains of our ships and we stay 'till the end. We see our stories through. """ """https://practice.geeksforgeeks.org/problems/0-1-knapsack-problem/0 [Naive Recursion] """ def knapsack(weight, value, capacity): number_of_items = len(weight) return knapsack_helper(number_of_items-1, 0, weigh...
false
0704dff3bae91c29dadd9867b9fc72259f59c1ce
kivensu/learnpython3
/ListAndOperation/bicycles.py
1,246
4.1875
4
# print list bicycles = ['creak', 'cannondale', 'trip', 'alex'] print(bicycles) # list indexes # print(bicycles[0]) # print(bicycles[1]) # print(bicycles[-1]) print("My first bicycles is " + bicycles[0].title() + " !") # change list element motorcycles = ['honda', 'yamaha', 'suzuki'] print(motorcycles) # motorcycles[...
false
7928e5ce41ebcaada9146563521dc9cb61776715
stephra34/MIT-OCW
/turtle_test.py
1,889
4.125
4
#setup import turtle s = turtle.getscreen() t = turtle.Turtle() t.shape("turtle") t.speed(9) #set up screen #turtle.bgcolor("blue") turtle.title("Hunter's Game") # #u = input("Would you like me to draw a shape? Type yes or no: ") #if u == "yes": # t.penup() # t.goto(200,200) # t.pendown() # n=10 # whil...
false
fd00acdfa7e5f6187dcef82ca53e2a34595bb3e9
erinmiller926/adventurelab
/adventure_lab.py
2,337
4.375
4
# Adventure Game Erin_Miller import random print("Last night, you went to sleep in your own home.") print("Now, you wake up in a locked room.") print("Could there be a key hidden somewhere?") print("In the room, you can see:") # The menu Function: def menu(list, question): for item in list: print(1...
true
bc4cf020e12cef8167f0ce3cad98399b5d7d9f8f
michealwave/trainstation
/lesson.py
1,763
4.4375
4
# Calculation, printing, variables # Printing to the screen # The built in function print(), prints to the screen # it will print both Strings and numbers print("Printing to the screen") print("Bruh") # in quotes are called strings print('bruhg') print(6) #a number print("6") print(6 + 6) #prints 12 print("...
true
840ac0b807f67faca806e65f63fb4512c8ec1f40
niskrev/OOP
/old/NotQuiteABase.py
636
4.28125
4
# from Ch 23 of Data science from scratch class Table: """ mimics table in SQL columns: a list """ def __init__(self, columns): self.columns = columns self.rows = [] def __repr__(self): """ pretty representation of the table, columns then rows :return: ...
true
36872204f3439dbafd3370cc89e3a26fb245930a
pranavnatarajan/CSE-163-Final-Project
/MatchTree.py
2,753
4.15625
4
""" Alex Eidt- CSE 163 AC Pranav Natarajan - CSE 163 AB CSE 163 A Final Project This class represents a Data Structure used to build up the bracket of the UEFA Champions League to create the bracket graphics. """ import random class MatchTree: """ Data Structure used to represent a full brack...
true
0e180c7692a5807f278056be53142739700d5fce
anitakumarijena/Python_advantages
/deepak.py
1,275
4.1875
4
graph ={ 'a':['c'], 'b':['d'], 'c':['e'], 'd':['a', 'd'], 'e':['b', 'c'] } # function to find the shortest path def find_shortest_path(graph, start, end, path =[]): path = path + [start] if start == end: return path shortest = None for node in graph[start]: if n...
true
4c786e38d93357f3a768506f39993248e8414b64
Isoxazole/Python_Class
/HW2/hm2_william_morris_ex_1.py
447
4.1875
4
"""Homework2, Exercise 1 William Morris 1/29/2019 This program prints the collatz sequence of the number inputted by the user.""" def collatz(number): if number == 1: print(number) return 1 elif number % 2 == 0: print(number) return collatz(int(number/2)) else: prin...
true
5e4d121ef247320d9f3a90162561d10694c2ab49
Isoxazole/Python_Class
/HW4/hm4_william_morris_ex_1.py
1,461
4.21875
4
""" Homework 4, Exercise 1 William Morris 2/22/19 This program has 3 classes: Rectangle, Circle, and Square. Each class has the functions to get the Area, Diagonal, and perimeter of their respective shape. At the end of this program, the perimeter of a circle with radius the half of the diagonal of a rectangle with len...
true
d57991f5faa7b5b8d3ed8ade332d57c55242bb98
Ottermad/PythonBasics
/times_tables.py
564
4.125
4
# times_tables.py # Function for times tables def times_tables(how_far, num): n = 1 while n <= how_far: print(n, " x ", num, " = ", n*num) n = n + 1 # Get user's name name = input("Welcome to Times Tables. What is your name?\n") print("Hello " + name) # Get timestable and how far do you want ...
true
7b6739be5389da8351294fa3b430002989b83b84
avin82/Programming_Data_Structures_and_Algorithms_using_Python
/basics_functions.py
2,225
4.59375
5
def power(x, n): # Function name, arguments/parameters ans = 1 for i in range(0, n): ans = ans * x return ans # Return statement exits and returns a value. # Passing values to functions - When we call a function we have to pass values for the arguments and this is done exactly the same way as as...
true
ea834767462615e5a124b4e723e4507dcf393cec
MillaKelhu/tiralabra
/Main/Start/board.py
2,127
4.28125
4
from parameters import delay, error_message import time # User interface for asking for the board size from the user def get_board(): while True: print("Choose the size of the board that you want to play with.") print("A: 3x3 (takes three in a row to win)") print("B: 5x5 (takes four in a ...
true
e16aa01c242c5fc654d01f889c1a3cde6551d618
elvargas/calculateAverage
/calculateAverage.py
2,865
4.4375
4
# File: calculateAverage.py # Assignment 5.1 # Eric Vargas # DESC: This program allows the user to choose from four operations. When an operation is chosen, they're allowed to choose # two numbers which will be used to calculate the result for the chosen operation. Option 5. will ask the user how # many numbers th...
true
c0e32988331e72474e7b50ea59ac3891627ebd6b
georgeescobra/algorithmPractice
/quickSort.py
1,408
4.25
4
# this version of quicksort will use the last element of the array as a pivot import random import copy def quickSort(array, low, high): if(low < high): partitionIndex = partition(array, low, high) quickSort(array, low, partitionIndex - 1) quickSort(array, partitionIndex + 1, high) # don't necessarily have to ...
true
e18f0f34927a7aa2398152077a7f88a811466f11
klandon94/python3_fundamentals
/lambda.py
820
4.1875
4
def square(num): return num*num square(3) #Lambda is used to specify an anonymous (nameless) function, useful where function only needs to be used once and convenient as arguments to functions that require functions as parameters #Lambda can be an element in a list: y = ['test_string', 99, lambda x: x ** 2] print...
true
96a5711b2d05f6a28605e5ee5a5f9a2c385bb49f
msemjan/coding_interview_questions
/src/pythagoreanTriplets.py
665
4.28125
4
''' # Find Pythagorean Triplets (Uber) Given a list of numbers, find if there exists a pythagorean triplet in that list. A pythagorean triplet is 3 variables a, b, c where a^2 + b^2 = c^2 Example: > Input: [3, 5, 12, 5, 13] > > Output: True Here, 5^2 + 12^2 = 13^2. ''' def findPythagoreanTriplets(nums): nums_s...
false
107fa70fc1d1525a6f2b78cd0dfd228f3b8d1ad1
Shantti-Y/Algorithm_Python
/chap02/prac13.py
2,456
4.25
4
# coding: utf-8 # 日付を表す構造体が次のように与えられているとする。 # # typedef struct { # int y; # int m; # int d; # } Date; # # 以下に示す関数を作成せよ。 # ・y年m月d日を表す構造体を返却する関数DateOf # Date DateOf(int, y, int m, int d); # ・日付xのn日後の日付を返す関数After # Date After(Date x, int n); # ・日付xのn日前の日付を返す関数Before # Date Before(Date x, int n); ...
false
9aa90a2df1734f12f98a22e925575be47ccbb0f8
Shantti-Y/Algorithm_Python
/chap02/prac04.py
778
4.1875
4
from random import randint as rand #coding: utf-8 # List2-6(参考書参照)は身長を乱数で生成した上で身長の最大値を求めるプログラムであった。 # 身長だけでなく人数も乱数で生成するように書き換えたプログラムを作成せよ。 # 人数は、5以上20以下の乱数とすること。 def maxof(a, n): max = a[0] for i in range(n - 1): if(max < a[i + 1]): max = a[i + 1] return max #Main function print("C...
false
1769e7ee9a9dad0296ef5fd1e189ac4f8ac1e6c6
ayush94/Python-Guide-for-Beginners
/FactorialAlgorithms/factorial.py
1,290
4.1875
4
from functools import reduce ''' Recursively multiply Integer with its previous integer (one less than current number) until the number reaches 0, in which case 1 is returned ''' def recursive_factorial(n): # Base Case: return 1 when n reaches 0 if n == 0 : return 1 # recursive call to function with the integer ...
true
e224a34ec37f50014e7dde73993710b560d54606
FilipM13/design_patterns101
/pattern_bridge.py
2,431
4.28125
4
""" Bridge. Structure simplifying code by deviding one object type into 2 hierarchies. It helps solving cartesian product problem. Example: In this case if I want to create one class for every combination of plane and ownership i'd need 16 classes (4 planes x 4 ownerships) Thanks to bridge pattern I only have 8 cl...
true
78b5b3a4e8076f804716015f9ea3d8bcb419ea2f
samuelluo/practice
/bst_second_largest/bst_second_largest.py
2,041
4.125
4
""" Given the root to a binary search tree, find the second largest node in the tree. """ # ---------------------------------------- class Node: def __init__(self, val, left=None, right=None): self.val = val self.left = left self.right = right def bst_insert(root, val): if root is None...
true