blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
c130d758ef000ea0de0b0ed4154dfa711f0b4504
D-Bits/Math-Scripts
/main.py
1,918
4.40625
4
from vectors import get_dot_product from series import get_fibonacci, get_num_of_fib, sum_of_terms from math import factorial # Choices for the user options = { '1': 'Calculate the dot product of two vectors.', '2': 'Get the sum of the first n terms in an arithmetic series.', '3': 'Get a specific number in...
true
096ac4e7c999f374495576ced8b6f9ac327a57de
pointmaster2/RagnarokSDE
/SDE/Resources/tut_part2.py
1,281
4.3125
4
""" Tutorial - Part 2 Selection """ # You can manipulate the selection of the editor and read its values. # The example below prints the first three elements of the selected items. if (selection.Count == 0): script.throw("Please select an item in the tab!") for tuple in selection: print ...
true
612a5eb267901530782ffe5f82876c970fe34f65
robseeen/Python-Projects-with-source-code
/Mile_to_KM_Converter_GUI/main.py
1,119
4.34375
4
from tkinter import * # creating window object window = Tk() # Program title window.title("Miles to Kilometer Converter") # adding padding to window window.config(padx=20, pady=20) # taking user input miles_input = Entry(width=7) # grid placement miles_input.grid(column=2, row=0) # showing input label miles_label = ...
true
5cba02efb718d3cfdb85ee3439261fb2fa28cf9f
robseeen/Python-Projects-with-source-code
/average_height_using_for_loop.py
852
4.125
4
# Finding average height using for loop. # takeing students height and sperated student_heights = input( "Input a list of students heights. Seperated by commas.\n => ").split() # checking the input in list for n in range(0, len(student_heights)): student_heights[n] = int(student_heights[n]) # printing the st...
true
530fb79024873eee062a23f2eec7096c00c2c3fc
patidarjp87/python_core_basic_in_one_Repository
/29.Co-Prime.py
573
4.125
4
print('numbers which do not have any common factor between them,are called co-prime factors') print('enter a value of a and b') a=int(input()) b=int(input()) if a>b: for x in range(2,b+1): if a%x==0 and b%x==0: print(a,'&',b,'are not co-prime numbers') break else: continue if x==b: print(a...
true
f8471e2937ec8f64d491a1856f103442e7ec41b3
patidarjp87/python_core_basic_in_one_Repository
/71.cheacksubset.py
461
4.34375
4
print("program to check whether a given set is a subset of another given set") s1=set([eval(x) for x in input('enter elements in superset set 1 as it is as you want to see in your set with separator space\n').split()]) s2=set([eval(x) for x in input('enter elements subset set 2 as it is as you want to see in your set ...
true
d78cd51c22c282a5a5e9c2bdc69442237700985c
patidarjp87/python_core_basic_in_one_Repository
/92.Accoutclass.py
1,168
4.25
4
print("define a class Account with static variable rate of interest ,instance variable balance and accounr no.make function to set them") class Account: def setAccount(self,a,b,rate): self.accno=a self.balance=b Account.roi=rate def showBalance(self): print("Balance is ",self.b...
true
776b3c99569733f3f1746eb1dee10bb971d52684
patidarjp87/python_core_basic_in_one_Repository
/84.countwords.py
221
4.125
4
print("script to ciunt words in a given string \n Takes somthing returns something\n Enter a string") s=input() def count(s): l=s.split() return len(l) print('no. of words in agiven string is ',count(s)) input()
true
ca903da90a4a8ce81c24bcc3258259facbef43eb
kapari/exercises
/pydx_oop/adding.py
629
4.15625
4
import datetime # Class that can be used as a function class Add: def __init__(self, default=0): self.default = default # used when an instance of the Add class is used as a function def __call__(self, extra=0): return self.default + extra add2 = Add(2) print(add2(5)) # >> 7 class Pers...
true
394e21f7262da6bedbb53a667bc738662033d26a
Aegis-Liang/Python
/HackerRank/Data Structure/2_LinkedLists/10_GetNodeValue.py
2,559
4.25
4
""" Get Node data of the Nth Node from the end. head could be None as well for empty list Node is defined as class Node(object): def __init__(self, data=None, next_node=None): self.data = data self.next = next_node return back the node data of the linked list in the below method. """ def Get...
true
d525e7b1fc92767c602e4911fed11253e09d58ff
Aegis-Liang/Python
/HackerRank/Data Structure/2_LinkedLists/2_InsertANodeAtTheTailOfALinkedList.py
1,553
4.28125
4
""" Insert Node at the end of a linked list head pointer input could be None as well for empty list Node is defined as class Node(object): def __init__(self, data=None, next_node=None): self.data = data self.next = next_node return back the head of the linked list in the below method """ de...
true
62351503e0025c4fd5c358a16036c52d48eccac6
Aegis-Liang/Python
/HackerRank/Data Structure/2_LinkedLists/3_InsertANodeAtTheHeadOfALinkedList.py
1,496
4.21875
4
""" Insert Node at the begining of a linked list head input could be None as well for empty list Node is defined as class Node(object): def __init__(self, data=None, next_node=None): self.data = data self.next = next_node return back the head of the linked list in the below method. """ def In...
true
9d11b885c5188412b5ed481fea5a49878ae3753e
sangzzz/AlgorithmsOnStrings
/week3&4_suffix_array_suffix_tree/01 - Knuth Morris Pratt/kmp.py
905
4.1875
4
# python3 import sys def find_pattern(pattern, text): """ Find all the occurrences of the pattern in the text and return a list of all positions in the text where the pattern starts in the text. """ result = [] # Implement this function yourself text = pattern + '$' + text s = [0 f...
true
60dcba72cc85538aab4f58ddcd1a989e940f9522
bhargav-makwana/Python-Corey-Schafer
/Practise-Problems/leap_year_functions.py
654
4.3125
4
# Program : Finding the days in the year # Input : days_in_month(2015, 3) # Output : # Numbers of days per month. 0 is used as a placeholder for indexing purposes. month_days = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31] def is_leap(year): """ Return True for leap years, False for non-leap years""" ...
true
7eb795b0920e210e7ff11317e1ba199129013837
HypeDis/DailyCodingProblem-Book
/Email/81_digits_to_words.py
1,058
4.21875
4
""" Given a mapping of digits to letters (as in a phone number), and a digit string, return all possible letters the number could represent. You can assume each valid number in the mapping is a single digit. For example if {“2”: [“a”, “b”, “c”], 3: [“d”, “e”, “f”], …} then “23” should return [“ad”, “ae”, “af”, “bd”, ...
true
a4450612113faaf8813c6163c461fc483f05bb63
HypeDis/DailyCodingProblem-Book
/Chapter-5-Hash-Table/5.2-Cut-Brick-Wall.py
972
4.125
4
""" A wall consists of several rows of bricks of various integer lengths and uniform height. Your goal is to find a vertical line going from the top to the bottom of the wall that cuts through the fewest number of bricks. If the line goes through the edge between two bricks, this does not count as a cut. """ from col...
true
a18a302670bdb1c93bcf41783c1f3763d261c716
HypeDis/DailyCodingProblem-Book
/Chapter-3-Linked-Lists/3.1-Reverse-Linked-List.py
987
4.125
4
from classes import LinkedList myLinkedList = LinkedList(10) def reverse(self): self.reverseNodes(None, self.head) LinkedList.reverse = reverse def reverseNodes(self, leftNode, midNode): # basecase reach end of list if not midNode.next: self.head = midNode else: self.reverseNodes...
true
a717b09b4d4d486e3a05b5a9046fe396a9d65959
Jorza/pairs
/pairs.py
1,367
4.28125
4
def get_pair_list(): while True: try: # Get input as a string, turn into a list pairs = input("Enter a list of integers, separated by spaces: ") pairs = pairs.strip().split() # Convert individual numbers from strings into integers for i in r...
true
3c0042882117531431b5d27506e5bf602c92e3d3
henrikgruber/PythonSIQChallenge
/Skill2.3_Friederike.py
936
4.53125
5
# Create 3 variables: mystring, myfloat and myint. # mystring should contain the word "hello.The floating point number should be named myfloat and should contain the number 10.0, and the integer should be named myint and should contain the number 20. # Finally, print all 3 variables by checking if mystring equals to ...
true
b44f4f5367ae2c8cb39de98e003dc9454d82970a
henrikgruber/PythonSIQChallenge
/#2 Put your solutions here/Skill4.3_Vanessa.py
1,028
4.78125
5
#In this exercise, you will need to add numbers and strings to the correct lists using the "append" list method. # Create 3 lists: numbers, strings and names numbers = [] strings = [] names = [] # Add the numbers 1,2, and 3 to the "numbers" list, and the words 'hello' and 'world' to the strings variable numbers.appe...
true
b659d2d761ee8c0df61154e0497ddcf5a1fe2a80
henrikgruber/PythonSIQChallenge
/#2 Put your solutions here/Skill 2.3 Tamina.py
777
4.40625
4
# Create 3 variables: mystring, myfloat and myint. # mystring should contain the word "hello.The floating point number should be named myfloat and should contain the number 10.0, and the integer should be named myint and should contain the number 20. # Finally, print all 3 variables by checking if mystring equals to "...
true
1b65e04c12a9b0c1df4be645bb0b841c96a67277
henrikgruber/PythonSIQChallenge
/#2 Put your solutions here/Skill1.4_Vanessa.py
512
4.25
4
# This program finds the number of day of week for K-th day of year print("Enter the day of the year:") K = int(input()) a = (K % 7) + 3 if a == 0: print("This day is a Sunday") if a == 1: print("This day is a Monday") if a == 2: print("This day is a Tuesday") if a == 3: print("...
true
364341e055538b367469d9075147b32a326b1cbf
janettem/Coding-Challenges
/finding_adjacent_nodes/finding_adjacent_nodes.py
879
4.15625
4
def are_adjacent_nodes(adjacency_matrix: list, node1: int, node2: int) -> bool: if adjacency_matrix[node1][node2] == 1: return True return False def test(): adjacency_matrix1 = [[0, 1, 0, 0], [1, 0, 1, 1], [0, 1, 0, 1], [0, 1, 1, 0]] adjacency_matrix2 = [ [0, 1, 0, 1, 1], [1, ...
false
d42b959e448133ca39a6798c38daa06c90bb86d1
pombredanne/Rusthon
/regtests/c++/returns_subclasses.py
1,443
4.125
4
''' returns subclasses ''' class A: def __init__(self, x:int): self.x = x def method(self) -> int: return self.x class B(A): def foo(self) ->int: return self.x * 2 class C(A): def bar(self) ->int: return self.x + 200 class D(C): def hey(self) ->int: return self.x + 1 def some_subclass( x:int ) ->A: ...
false
8b8a0b92e6e0697c486e0cdda96874934e4e48f0
Sadashiv/interview_questions
/python/string_set_dictionary.py
2,945
4.34375
4
string = """ Strings are arrays of bytes representing Unicode characters. Strings are immutable. """ print string #String Operations details str = "Hello Python" str1 = "World" print "String operations are started" print str.capitalize() print str.center(20) print str.count('o') print str.decode() print str.encode() ...
true
141f5d9eeb1020a83a79299fc7d3b93637058c83
capncrockett/beedle_book
/Ch_03 - Computing with Numbers/sum_a_series.py
461
4.25
4
# sum_a_series # A program to sum up a series of numbers provided from a user. def main(): print("This program sums up a user submitted series of numbers.") number_count = int(input("How many numbers will we be summing" "up today? ")) summed = 0 for i in range(num...
true
80f931032dd8fbee7d859a1f04b9d2707d233227
capncrockett/beedle_book
/Ch_03 - Computing with Numbers/triangle_area.py
492
4.3125
4
# triangle_area.py # Calculates the area of a triangle. import math def main(): print("This program calculates the area of a triangle.") print() a = float(input("Please enter the length of side a: ")) b = float(input("Please enter the length of side b: ")) c = float(input("Please ent...
true
b30b0e17c9c907d54c1d4e99b68c0580a00808c4
capncrockett/beedle_book
/Ch_07 - Decision Structures/valid_date_func.py
1,101
4.46875
4
# valid_date_func.py # A program to check if user input is a valid date. It doesn't take # into account negative numbers for years. from leap_year_func import leap_year def valid_date(month: int, day: int, year: int) -> bool: days_in_month = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31] if 1 ...
true
b19f9c63a4c64753fc1c46a61177d05a0e08570b
capncrockett/beedle_book
/Ch_06 - Functions/sum_time.py
545
4.25
4
# sum_time.py def sum_up_to(n): summed = 0 for i in range(1, n + 1): summed += i print(f"The sum is {summed}.") def sum_up_cubes(n): summed = 0 for s in range(1, n + 1): summed += s ** 3 print(f"The sum of the cubes is {summed}") def main(): print("This ...
true
cd407e24b339ed7a4c42847457e538505cbcd63f
capncrockett/beedle_book
/Ch_02 - IDLE Examples/distance_converters.py
575
4.34375
4
# This program converts distances def kilometers_miles(): print("This function converts kilometers to miles.") kilometers = eval(input("Enter the distance in kilometers: ")) miles = kilometers * 0.62 print("The distance in miles is", miles) def fahrenheit_kelvin(): print("This func...
false
5c05feac6d95a6375275bc8ddb69d96fcd253f9b
capncrockett/beedle_book
/Ch_07 - Decision Structures/pay_rate_calc.py
583
4.25
4
# pay_rate_calc.py # Program to calculate an employees pay rate, including overtime. def main(): hours = eval(input("Enter employee total hours: ")) pay_rate = eval(input("Enter employee pay rate: ")) if hours <= 40: pay = pay_rate * hours print(f"Total pay = ${pay:0.2f}") ...
true
f759d2714063a7520a42a45e4ca8b4bf58d53e37
capncrockett/beedle_book
/Ch_08 - Loop Structures and Booleans/prime_checker.py
720
4.34375
4
# prime_checker.py # A positive number n > 2 is prime if no num between 2 and # the sqrt of n (inclusive) evenly divides n. import math def prime_check(n): sqrt_n = int(math.sqrt(n)) if n > 2: if n == 3: print("3 is prime") for i in range(2, sqrt_n + 1): ...
false
e9543a36d3cc89e88294035db335cf273c7b037a
capncrockett/beedle_book
/Ch_05 - Sequences/average_word_len.py
998
4.3125
4
# average_word_len # Find the average word length of a sentence. def main(): print("This program finds the average word length of a sentence.") print() sentence = input("Type a sentence: ") word_count = sentence.count(' ') + 1 words = sentence.split() letter_count = 0 for ...
true
a7a921940f1cedee399c3d732f7a2cb4869979ef
DaanvanMil/INFDEV02-1_0892773
/assignment6pt3/assignment6pt3/assignment6pt3.py
367
4.25
4
x = input ("how many rows? ") printed = ("") #The printing string n = x + 1 #Make sure it is x rows becasue of the range for a in range(n): #Main for loop which prints n amount of lines for b in range(a): #For loop which adds a amount of asterisks per line printed += '*...
true
4c687faa942587e54da9a4e4cdcc491865c93b82
Billoncho/TurtelDrawsTriangle
/TurtleDrawsTriangle.py
684
4.4375
4
# TurtleDrawsTriangle.py # Billy Ridgeway # Creates a beautiful triangle. import turtle # Imports turtle library. t = turtle.Turtle() # Creates a new pen called t. t.getscreen().bgcolor("black") # Sets the background to black. t.pencolor("yellow") # Sets the pen's color...
true
55eb79671bcc26fb01f38670730e7c71b5e0b6ff
vymao/SmallProjects
/Chess/ChessPiece.py
956
4.125
4
class ChessPiece(object): """ Chess pieces are what we will add to the squares on the board Chess pieces can either moves straight, diagonally, or in an l-shape Chess pieces have a name, a color, and the number of squares it traverses per move """ Color = None Type = None ListofPieces = [ "Rook", ...
true
49e452747a9a019aec7cef09fd23abb9eb2ce101
hwang-17/forpythonstudy
/contact_list.py
1,407
4.1875
4
''' this is a practice of dict from fishC forum ''' print('§---欢迎使用通讯录程序---§') print('§---1:查询联系人资料---§') print('§---2:添加新的联系人---§') print('§---3:删除已有联系人---§') print('§---4:退出通讯录程序---§') contacts = dict() while 1: instr = int(input('\n请输入相关的指令代码:')) if instr == 1: name = input('请输入联系人姓名') ...
false
d8bc071aba1c639a3d17a2b87ccd45f51530da3d
ronny-souza/Lista-Exercicios-04-Python
/Exercicio02.py
1,107
4.1875
4
# QUESTÃO 02 - Faça um programa que percorre uma lista com o seguinte formato: # [['Brasil', 'Italia', [10, 9]], ['Brasil', 'Espanha', [5, 7]], 'Itália', 'Espanha', [7,8]]]. # Essa lista indica o número de faltas que cada time fez em cada jogo. Na lista acima, no jogo entre Brasil e # Itália, o Brasil fez 10 faltas ...
false
01099d699d3e8b9919b117704f36d1c95ee75bcc
mitalijuneja/Python-1006
/Homework 5/engi1006/advanced/pd.py
1,392
4.1875
4
######### # Mitali Juneja (mj2944) # Homework 5 = statistics functionality with pandas # ######### import pandas as pd def advancedStats(data, labels): '''Advanced stats should leverage pandas to calculate some relevant statistics on the data. data: numpy array of data labels: numpy array of labels...
true
bd367cea336727a2ccbd217e8e201aad6ab42391
Eddie02582/Leetcode
/Python/069_Sqrt(x).py
1,565
4.40625
4
''' Implement int sqrt(int x). Compute and return the square root of x, where x is guaranteed to be a non-negative integer. Since the return type is an integer, the decimal digits are truncated and only the integer part of the result is returned. Example 1: Input: 4 Output: 2 Example 2: Input: 8 ...
true
ef5e3b08084b712e924f564ec05a235e157ce482
Eddie02582/Leetcode
/Python/003_Longest Substring Without Repeating Characters.py
2,886
4.125
4
''' Given a string, find the length of the longest substring without repeating characters. Example 1: Input: "abcabcbb" Output: 3 Explanation: The answer is "abc", with the length of 3. Example 2: Input: "bbbbb" Output: 1 Explanation: The answer is "b", with the length of 1. Example 3: Input: "pwwkew" Output: 3 E...
true
b34977331a8f620c267ae294ddf3977cccf3f8f9
ratansingh98/design-patterns-python
/factory-method/FactoryMethod.py
1,328
4.34375
4
# # Python Design Patterns: Factory Method # Author: Jakub Vojvoda [github.com/JakubVojvoda] # 2016 # # Source code is licensed under MIT License # (for more details see LICENSE) # import sys # # Product # products implement the same interface so that the classes # can refer to the interface not the concrete produc...
true
5513562b84170f92d6581dc1da83414705338443
ratansingh98/design-patterns-python
/abstract-factory/AbstractFactory.py
1,921
4.28125
4
# # Python Design Patterns: Abstract Factory # Author: Jakub Vojvoda [github.com/JakubVojvoda] # 2016 # # Source code is licensed under MIT License # (for more details see LICENSE) # import sys # # Product A # products implement the same interface so that the classes can refer # to the interface not the concrete pro...
true
7dc4a7cd2f0cea643673ee0ace3ccd2b8b5cf117
bliiir/python_fundamentals
/16_variable_arguments/16_01_args.py
345
4.1875
4
''' Write a script with a function that demonstrates the use of *args. ''' def my_args(*args): '''Print out the arguments received ''' print('These are the arguments you gave me: \n') for arg in args: print(arg) # Call the my_args function with a string, a number and a copy of itself my_args(...
true
80af3874703bc28aa1707bb080aa25c332d5569a
YCullen/LeetcodePractice
/0_RotateMatrix.py
533
4.125
4
import pdb def rotate(matrix): # 矩阵转90度的本质是把第i行换到第-i列 N = len(matrix) matrix_copy = [[0 for i in range(N)] for j in range(N)] for i in range(N): for j in range(N): matrix_copy[i][j] = matrix[i][j] for i in range(N): tmp = matrix_copy[i] for j in range(N): ...
false
cf1d92c0821e5bc526fb920787b2306f18f5358e
GilliamD/Digital-Crafts-Day-4
/day_of_the_week.py
320
4.28125
4
day = int(input("Day 0-6? ")) if day == 0: print("Sunday") elif day == 1: print("Monday") elif day == 2: print("Tuesday") elif day == 3: print("Wednesday") elif day == 4: print("Thursday") elif day == 5: print("Friday") elif day == 6: print("day") else: print("Thats\'s not a day, Bud.")
false
609fc7970d1e8a9a1fc194c10d0ae73975e6c428
jfeidelb/Projects
/PythonTextGame.py
2,237
4.34375
4
from random import randint import operator print("This is an educational game where you will answer simple math questions.") print("How many questions would you like to answer?") questionInput = input() def MathQuestion(questionInput): questionLoop = 0 score = 0 try: #loop to control number of que...
true
383cf5c58b65554c25ba6c29ec5805c5e6abfbde
thekushkode/lists
/lists.2.py
1,321
4.375
4
# List Exercise 2 # convert infinite grocery item propt # only accept 3 items # groc list var defined groc = [] #build list while len(groc) < 3: needs = input('Enter one grocery item you need: ') groc.append(needs) #groc2 list var defined groc2 = [] #build list while len(groc2) < 3: needs2 = input('Ente...
true
810912f2f7b530068dfa948332fc404572c3bb8e
abdulalbasith/python-programming
/unit-3/dict_practice.py
521
4.59375
5
my_name= { "a":1, "b":1, "d":1, "u":1, "l":1 } for letter in my_name: print (f"The letter {letter} appears {my_name[letter]} time in my name") def reverse_lookup(state_capitals,value): result = "" for state in state_capitals: if state_capitals [state] == value: ...
false
b8d1d4a3facd658685105842d2ba4d25ce3bdd24
abdulalbasith/python-programming
/unit-2/homework/hw-3.py
368
4.25
4
odd_strings = ['abba', '111', 'canal', 'level', 'abc', 'racecar', '123451' , '0.0', 'papa', '-pq-'] number_of_strings = 0 for string in odd_strings: string_length = len(string) first_char= string [0] last_char= string [-1] if string_length > 3 and first_char == last_char: number_of_str...
true
89d79dc316e679596d8ffe70747316ed83b75442
abdulalbasith/python-programming
/unit-3/sols-hw-pr5.py
1,023
4.125
4
#Homework optional problem #5 def letter_count (word): count = {} for l in word: count[l] = count.get (l,0) +1 return count def possible_word (word_list, char_list): #which words in word list can be formed from the characters in the character list #iterate over word_list valid_words=...
true
ecd28bb5b6fa31378207b40b9a6ea0c93db7e2b0
Amaya1998/business_application
/test2.py
565
4.21875
4
import numpy as np fruits= np.array (['Banana','Pine-apple','Strawberry','Avocado','Guava','Papaya']) print(fruits) def insertionSort(fruits): for i in range(1, len(fruits)): # 1 to length-1 item = fruits[i] # Move elements # to right by one...
true
9b4c24baf6b2a851fb83dfe5857aac73a5d3596d
kajalchoundiye/Python_programs
/truefalse2.py
278
4.25
4
if 0: print("True") else: print("False") name=input("please enter your name ") if name: print("hello,{}".format(name)) else: print("are you the man with no name? ") #if name if name != "": print('hiiii' + name) else: print("no name...!")
false
a1a09bf2afeae4790b4c405446bdfd4d79c23eea
intkhabahmed/PythonProject
/Day1/Practice/Operators.py
243
4.125
4
num1 = input("Enter the first number") #Taking first number num2 = input("Enter the second number") #Taking second number print("Addtion: ",num1+num2) print("Subtraction: ",num1-num2) print("Multiply: ",num1*num2) print("Division: ",num1/num2)
true
5ada27d455d8bf9d51b6e71360ddd85175b0ac95
wang264/JiuZhangLintcode
/AlgorithmAdvance/L2/require/442_implement-trie-prefix-tree.py
1,802
4.3125
4
# Implement a Trie with insert, search, and startsWith methods. # # Example # Example 1: # # Input: # insert("lintcode") # search("lint") # startsWith("lint") # Output: # false # true # Example 2: # # Input: # insert("lintcode") # search("code") # startsWith("lint") # startsWith("linterror") # inser...
true
c952d98015d0b0bb0618b42780fd18d221b0e408
wang264/JiuZhangLintcode
/AlgorithmAdvance/L3/optional/370_convert-expression-to-reverse-polish-notation.py
1,939
4.15625
4
# 370. Convert Expression to Reverse Polish Notation # 中文English # Given a string array representing an expression, and return the # Reverse Polish notation of this expression. (remove the parentheses) # 370. 将表达式转换为逆波兰表达式 # 中文English # 给定一个字符串数组,它代表一个表达式,返回该表达式的逆波兰表达式。(去掉括号) # # Example # Example 1: # # Input: ["3",...
false
c547b2db20d700bdc3b0bc06a7193e38e1d92440
wang264/JiuZhangLintcode
/Algorithm/L4/require/480_binary-tree-paths.py
2,826
4.21875
4
# 480. Binary Tree Paths # 中文English # Given a binary tree, return all root-to-leaf paths. # # Example # Example 1: # # Input:{1,2,3,#,5} # Output:["1->2->5","1->3"] # Explanation: # 1 # / \ # 2 3 # \ # 5 # Example 2: # # Input:{1,2} # Output:["1->2"] # Explanation: # 1 # / # 2 class Solution: ""...
true
48292de617f3eda89c003ac106a37d62e8f445d9
wang264/JiuZhangLintcode
/Algorithm/L7/optional/601_flatten-2d-vector.py
1,398
4.375
4
# 601. Flatten 2D Vector # 中文English # Implement an iterator to flatten a 2d vector. # # 样例 # Example 1: # # Input:[[1,2],[3],[4,5,6]] # Output:[1,2,3,4,5,6] # Example 2: # # Input:[[7,9],[5]] # Output:[7,9,5] from collections import deque class Vector2D(object): # @param vec2d {List[List[int]]} def __init_...
true
7fb4c1cab08e8ecb37dee89edf8a47093e54a1b5
wang264/JiuZhangLintcode
/AlgorithmAdvance/L4/require/633_find-the-duplicate-number.py
1,001
4.125
4
# 633. Find the Duplicate Number # 中文English # Given an array nums containing n + 1 integers where each integer is between 1 and n (inclusive), # guarantee that at least one duplicate number must exist. # Assume that there is only one duplicate number, find the duplicate one. # # Example # Example 1: # # Input: # [5,5,...
true
9539668c96bc480672085947c057285af7b26a6f
wang264/JiuZhangLintcode
/AlgorithmAdvance/L2/optional/432_find-the-weak-connected-component-in-the-directed-graph.py
1,236
4.1875
4
# 找出有向图中的弱连通分量 · Find the Weak Connected Component in the Directed Graph # Union Find # LintCode 版权所有 # 描述 # Find the number Weak Connected Component in the directed graph. Each node in the graph contains a label and # a list of its neighbors. (a weak connected component of a directed graph is a maximum subgraph in whi...
false
c55f839e550c5d851150254ae6f2f151deed02a5
wang264/JiuZhangLintcode
/Algorithm/L7/optional/606_kth-largest-element-ii.py
808
4.21875
4
# 606. Kth Largest Element II # 中文English # Find K-th largest element in an array. and N is much larger than k. Note that it is the kth largest element in the sorted order, not the kth distinct element. # # Example # Example 1: # # Input:[9,3,2,4,8],3 # Output:4 # # Example 2: # # Input:[1,2,3,4,5,6,8,9,10,7],10 # Outp...
false
b20590161658824d6ec48d666ca7dafbb19bcbcd
wang264/JiuZhangLintcode
/Algorithm/L4/require/453_flatten-binary-tree-to-linked-list.py
2,642
4.1875
4
# 453. Flatten Binary Tree to Linked List # 中文English # Flatten a binary tree to a fake "linked list" in pre-order traversal. # # Here we use the right pointer in TreeNode as the next pointer in ListNode. # # Example # Example 1: # # Input:{1,2,5,3,4,#,6} # Output:{1,#,2,#,3,#,4,#,5,#,6} # Explanation: # 1 # /...
true
e9f8b128025f9273474c6c0af58541eb9fcf1ae8
wang264/JiuZhangLintcode
/Intro/L5/require/376_binary_tree_path_sum.py
1,969
4.21875
4
# 376. Binary Tree Path Sum # 中文English # Given a binary tree, find all paths that sum of the nodes in the path equals to a given number target. # # A valid path is from root node to any of the leaf nodes. # # Example # Example 1: # # Input: # {1,2,4,2,3} # 5 # Output: [[1, 2, 2],[1, 4]] # Explanation: # The tree is lo...
true
67b68a4104edef825605d7b8bfeceb5400cab448
Gorilla-Programming/Python-Course
/Assignment 5/Ques 8.py
218
4.28125
4
# Program to print Volume of Cuboid a = float(input("Enter 1st number : ")) b = float(input("Enter 2nd number : ")) c = float(input("Enter 3rd number : ")) print("Average of given Number is : %f " %((a+b+c)/3))
false
4924278da3dba92909c099754236d732d5ae6e09
trinahaque/LeetCode
/Easy/String/reverseWordsInString.py
942
4.15625
4
# Given an input string, reverse the string word by word. # Input: "the sky is blue" # Output: "blue is sky the" def reverseWordsInString(s): if len(s) < 1: return "" elif len(s) < 2: if s.isalnum() == True: return s result = "" # splits the words into an array strArr = ...
true
f8d38ef5ba690a50e58554b0edfb0ecdf3610f95
haoccheng/pegasus
/leetcode/insertion_sort_list.py
1,396
4.125
4
# insertion sort in linked list. class ListNode: def __init__(self, x): self.val = x self.next = None def create_list(values): root = None curr = None for v in values: n = ListNode(v) if root is None: root = n curr = root else: curr.next = n cu...
false
b8c79c64b1f91888afb0fadaf80e9af7921f191d
haoccheng/pegasus
/leetcode/power_of_two.py
416
4.375
4
# Given an integer, determine if it is a power of two. def power_of_two(n): if n <= 0: return False else: value = n while (value > 0): if value == 1: return True else: r = value % 2 if r != 0: return False else: value = value / 2 retur...
true
2029924ab34ced3e322083702d175366ba02b12e
haoccheng/pegasus
/coding_interview/list_sort.py
965
4.125
4
# implement a function to sort a given list. # O(n2): each iteration locate the element that should have been placed in the specific position, swap. class Node: def __init__(self, value, next_node=None): self.value = value self.next = next_node def take(self): buffer = [self.value] if self.next i...
true
963162725075e8a2cf90d90f906a8afc3ac94a54
SAMIFIX/Training_Data_Structure
/mutability.py
1,292
4.8125
5
""" Mutable : هي امكانيه تغير القيمه للمتغير Immutable: غير ممكن تغير القيمه للمتغير Mutable Object: list, dict, set Immutable Object: Integer, float, string, tuple, bool , frozenset """ # Example in Mutable Objects: # list sami = [] sami.append(1) sami.append("Hello") sami.append("For") sami.append(True) prin...
false
c165079e81b5aff822766262f7c4271ba5d8ec88
m-bansal/build_up
/graphic figures.py
850
4.125
4
import turtle t = turtle.Turtle() t.pensize(4)#for thickness t.hideturtle() #line line=int(input("Enter the number of pixels by which a turtle should be moved to draw a line: ")) t.forward(line)#distance moved by turtle t.penup()#move the turtle head t.goto(0, -200)#no outline drawn by turtle t.pendown()...
false
5ca3c133c63549ef5c4c2dc75e83b2e2dd06e454
xartiou/algorithms-and-structures-python
/task_8_l2.py
1,330
4.28125
4
# 8. Посчитать, сколько раз встречается определенная цифра в введенной последовательности чисел. # Количество вводимых чисел и цифра, которую необходимо посчитать, задаются вводом с клавиатуры. # Запросить количество вводимых чисел (n) и цифру для подсчета (d). n = int(input("Введите сколько будет чисел?: ")) d = int(...
false
3f6c4d1f0b362444e84e36ca4d0ff3943bfc6bed
xartiou/algorithms-and-structures-python
/task_1.py
822
4.34375
4
# 1. Найти сумму и произведение цифр трехзначного числа, которое вводит пользователь. # - просим пользователя ввести целое трехзначное число three_digit = int(input('Введите целое трехзначное число: ')) # - выделяем цифры из числа one_d = three_digit // 100 two_d = (three_digit % 100) // 10 three_d = three_digit % 10...
false
9cb6bc62c648f66140ca8cc97a7eb264ce21a88c
ismaelconejeros/100_days_of_python
/Day 04/exercise_01.py
521
4.4375
4
#You are going to write a virtual coin toss program. It will randomly tell the user "Heads" or "Tails". #Important, the first letter should be capitalised and spelt exactly like in the example e.g. Heads, not heads. #There are many ways of doing this. But to practice what we learnt in the last lesson, you should gene...
true
1be3880c9dbce5695a23b3aa8fb6cd4fa043c8bc
ismaelconejeros/100_days_of_python
/Day 03/exercise_05.py
2,192
4.21875
4
#write a program that tests the compatibility between two people. #To work out the love score between two people: #Take both people's names and check for the number of times the letters in the word TRUE occurs. # Then check for the number of times the letters in the word LOVE occurs. # Then combine these numbers to...
true
a5b39aec77a04693499049e27f6ee26ab3ff66e6
Malcolm-Tompkins/ICS3U-Unit4-01-Python-While_Loops
/While_Loops.py
695
4.125
4
#!/usr/bin/env python3 # Created by Malcolm Tompkins # Created on May 12, 2021 # Determines sum of all numbers leading up to a number def main(): # Input user_input = (input("Enter your number: ")) try: user_number = int(user_input) loop_counter = 0 while (loop_counter < user_nu...
true
e37cb75f5da75f5c0e24a79fde1551f7debf8799
exeptor/TenApps
/App_2_Guess_The_Number/program_app_2.py
873
4.25
4
import random print('-------------------------------------') print(' GUESS THE NUMBER') print('-------------------------------------') print() random_number = random.randint(0, 100) your_name = input('What is your name? ') guess = -1 first_guess = '' # used this way in its first appearance only; on the seco...
true
9ac51bc45b2f5dfb09bb397ce0aa9c1e5ae06034
engineerpassion/Data-Structures-and-Algorithms
/DataStructures/LinkedList.py
2,417
4.1875
4
class LinkedListElement(): def __init__(self, value): self.value = value self.next = None class LinkedList(): def __init__(self): self.head = None def is_empty(self): empty = False if self.head is None: empty = True return empty def ...
true
f2f0dc7da7f646a4b647c49cef1810a3c73fb6d6
caged9/lrn-py
/1 half/Lesson 4/task_6.py
974
4.25
4
#В программе генерируется случайное целое число от 0 до 100. #Пользователь должен его отгадать не более чем за 10 попыток. После #каждой неудачной попытки должно сообщаться, больше или меньше #введенное пользователем число, чем то, что загадано. Если за 10 попыток #число не отгадано, вывести ответ import random p...
false
111d2814ccefb468c7c62abcf08708365d551426
caged9/lrn-py
/1 half/Lesson 3/task_1.py
626
4.125
4
#Выполнить логические побитовые операции «И», «ИЛИ» и др. над двумя #введенными пользователем числами. Выполнить над одним из введенных #чисел побитовый сдвиг вправо и влево на два знака a=int(input('Type a: ')) b=int(input('Type b: ')) print(a, ' = ', bin(a)) print(b, ' = ', bin(b)) print('a & b = ', a & b, '('...
false
531470e218f42e9f88b95968c05469ffd5e81554
Morgenrode/Euler
/prob4.py
725
4.1875
4
'''prob4.py: find the largest palidrome made from the product of two 3-digit numbers''' def isPalindrome(num): '''Test a string version of a number for palindromicity''' number = str(num) return number[::-1] == number def search(): '''Search through all combinations of products of ...
true
166ed8b161017285f5fe6c52e76d8a985b6ba903
acheimann/PythonProgramming
/Book_Programs/Ch1/chaos.py
553
4.46875
4
# File: chaos.py # A simple program illustrating chaotic behavior. #Currently incomplete: advanced exercise 1.6 #Exericse 1.6 is to return values for two numbers displayed in side-by-side columns def main(): print "This program illustrates a chaotic function" x = input("Enter a number between 0 and 1: ") ...
true
1262c1d720d1a6d51261e0eb5ca739abe7545254
acheimann/PythonProgramming
/Book_Programs/Ch3/sum_series.py
461
4.25
4
#sum_series.py #A program to sum a series of natural numbers entered by the user def main(): print "This program sums a series of natural numbers entered by the user." print total = 0 n = input("Please enter how many numbers you wish to sum: ") for i in range(n): number = input("Ple...
true
431a0f0002427aa49f2cb3c4df8fb0fd3a6fa2ba
acheimann/PythonProgramming
/Book_Programs/Ch2/convert_km2mi.py
391
4.5
4
#convert_km2mi.py #A program to convert measurements in kilometers to miles #author: Alex Heimann def main(): print "This program converts measurements in kilometers to miles." km_distance = input("Enter the distance in kilometers that you wish to convert: ") mile_equivalent = km_distance * 0.62 print ...
true
45b4cf3fd7e165e8c741d80694e34fe248e48780
va4oz/python_learning
/if_else.py
237
4.125
4
# -*- coding: utf-8 -*- a = 12 if a == 12: print("Верно") b = 13 if b == 12: print("верно") else: print("не верно") c = 5 if c < 2 or c > 3: print("не верно") elif c == 2: print("верно")
false
3d40a99ce2dd3e7965cf4284455091e715ca1227
Ray0907/intro2algorithms
/15/bellman_ford.py
1,630
4.1875
4
#!/usr/bin/python3 # -*- coding: utf-8 -*- # single source shortest path algorithm. from sys import maxsize # The main function that finds shortest # distances from src to all other vertices # using Bellman-Ford algorithm. The function # also detects negative weight cycle # The row graph[i] represents i-th edge with ...
true
e9c98d8d13b3b55e9fd02d19d6ab17df4f1eb0d7
MohamedAamil/Simple-Programs
/BinarySearchWords.py
1,805
4.21875
4
""" BinarySearchWords.py To check whether a word is in the word list, you could use the in operator, but it would be slow because it searches through the words in order. Because the words are in alphabetical order, we can speed things up with a bisection search (also known as binary search), which is similar to ...
true
92f328387b9d1754ad0f5fc71d2626acd3c82666
MohamedAamil/Simple-Programs
/SumOfDigits.py
397
4.21875
4
""" SumOfDigits.py : Displays the Sum of Digits of the given Number """ def get_sumofDigits(Num): """ Calculates the Sum of Digits :param Num: integer , Number """ Sum = 0 while Num != 0: a = Num % 10 Sum = Sum + a Num = Num // 10 print("Sum of Digit...
true
ffaab16f7ee68be9b9599cca7e2906279430d19d
trangthnguyen/PythonStudy
/integercuberootwhile.py
388
4.34375
4
#!/usr/bin/env python3 #prints the integer cube root, if it exists, of an #integer. If the input is not a perfect cube, it prints a message to that #effect. x = int(input('Enter integer number:')) guess = 0 while guess ** 3 < abs(x): guess = guess + 1 if guess ** 3 == abs(x): if x < 0: guess = - guess print('Cube ...
true
c58cd3ffc8bc84c8b21d8821daf55fca3f197eb3
trangthnguyen/PythonStudy
/numberstringsum.py
418
4.1875
4
#!/usr/bin/env python3 #Let s be a string that contains a sequence of decimal numbers #separated by commas, e.g., s = '1.23,2.4,3.123'. Write a program that prints #the sum of the numbers in s. x = input('Enter a string:') count = 0 sum = 0 for i in x: if i in '0123456789': count = count + 1 sum = sum + int(i) if ...
true
f22285f06df5b6c8d79febe605d7471919356199
kshruti1410/python-assignment
/src/q2.py
822
4.15625
4
""" abc is a by default abrstract class present """ from abc import ABC, abstractmethod class Person(ABC): """ inherit ABC class """ @abstractmethod def get_gender(self): """ skipping the function """ pass class Female(Person): """ this class return gender of a person """ def...
true
bcb068344d4db4f5ae984ad6f6d63a378587ad83
Abed01-lab/python
/notebooks/Handins/Modules/functions.py
1,289
4.28125
4
import csv import argparse def print_file_content(file): with open(file) as f: reader = csv.reader(f) for row in reader: print(row) def write_list_to_file(output_file, lst): with open(output_file, 'w') as f: writer = csv.writer(f) for element in lst: f....
true
ad7819e0dde2bf2b8583f992ec18f7ef5261cd0b
Intro-to-python/homework1-MaeveFoley
/problem2.py
534
4.34375
4
#homework1 #Due 10/10/18 # Problem 2 #Write a Python program to guess a number between 1 to 9. # User is prompted to enter a guess. If the user guesses wrong then #the prompt appears again until the guess is correct, on successful guess, #user will get a "Well guessed!" message, and the program will exit. #(Hint use a...
true
edac7d307b6001b92023f46bddd49fd29af13715
williamwbush/codewars
/unfinished/algorithm_night.py
2,116
4.15625
4
# Problem 1: # https://www.hackerrank.com/challenges/counting-valleys/problem # Problem 2: # You found directions to hidden treasure only written in words. The possible directions are "NORTH", "SOUTH","WEST","EAST". # "NORTH" and "SOUTH" are opposite directions, as are "EAST" and "WEST". Going one direction and coming ...
true
615b00ffe0a15294d2b65af008f6889ef622e005
igauravshukla/Python-Programs
/Hackerrank/TextWrapper.py
647
4.25
4
''' You are given a string S and width w. Your task is to wrap the string into a paragraph of width w. Input Format : The first line contains a string, S. The second line contains the width, w. Constraints : 0 < len(S) < 1000 0 < w < len(S) Output Format : Print the text wrapped paragraph. Sample Input...
true
0459d6caa8b5aacf99a1e9fb0e4208d70c72c09c
panditprogrammer/python3
/python88.py
1,374
4.25
4
#Formatting String video 94 #format () method part2 """this is multiline comments in python """ print("fomating string and method rules") print("----------integer---------") print("{}".format(15)) print("{:d}".format(15)) print("{0:d}".format(15)) print("{num:d}".format(num=15)) print("----------float---------\n") pri...
false
83c33d7ffe87715f233c63902d36bcfdab77460a
panditprogrammer/python3
/python72.py
354
4.40625
4
# creating 2D array using zeros ()Function from numpy import * a=zeros((2,3) ,dtype=int) print(a) print("This is lenth of a is ",len(a)) n=len(a) for b in range(n): # range for index like 0,1,in case of range 2. m=len(a[b]) print("This is a lenth of a[b]",m) for c in range(m): #print("This is inner for loop") ...
true
9fdcf03a227850f99153d4948c26c3415ccb34f2
panditprogrammer/python3
/Tkinter GUI/tk_python01.py
774
4.28125
4
from tkinter import * #creating a windows root=Tk() # geometry is used to create windows size root.geometry("600x400") # To creating a label or text you must use Label class labelg=Label(root,text="This is windows",fg= "red", font=("Arial",20)) # fg for forground color and bg for background color to change font colo...
true
ffae30c198f5a7132713304fcb3d0a2a0d4962a6
panditprogrammer/python3
/python78.py
860
4.46875
4
# slicing array in multi dimensional array in python #video 83\ from numpy import * # a=array([[11,13,17], # [11,12,13], # [21,22,23] ]) # print("array after printing") # print(a) # print("1st row 2nd coloum") # b=a[1,2 ] # print(b) # print("2nd coloum") # c=a[0:1,0:1] # print(c) x=array ([ [1,2,3,4,5,]...
false
26230d0e8b712a5ea37bb008e578768ed322b5c7
jktheking/MLAI
/PythonForDataScience/ArrayBasics.py
1,027
4.28125
4
import numpy as np array_1d = np.array([1, 2, 3, 4, 589, 76]) print(type(array_1d)) print(array_1d) print("printing 1d array\n", array_1d) array_2d = np.array([[1, 2, 3], [6, 7, 9], [11, 12, 13]]) print(type(array_2d)) print(array_2d) print("printing 2d array\n", array_2d) array_3d = np.array([[[1, 2, 3], [6, 7, 9]...
true
bd48356cbcf6e50f44dd26a88b8b8e2178311ef0
AtulRajput01/Data-Structures-And-Algorithms-1
/sorting/python/heap-sort.py
1,331
4.15625
4
""" Heap Sort Algorithm: 1. Build a max heap from the input data. 2. At this point, the largest item is stored at the root of the heap. Replace it with the last item of the heap followed by reducing the size of heap by 1. Finally, heapify the root of the tree. 3. Repeat step 2 while the size of the heap is greater t...
true