blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
7deb2d43fbf45c07b5e2186c320e77bdad927c18
iAmAdamReid/Algorithms
/recipe_batches/recipe_batches.py
1,487
4.125
4
#!/usr/bin/python import math def recipe_batches(recipe, ingredients, count=0): # we need to globally track how many batches we've made, and pass recursively # TODO: find how to do this w/o global variables global batches batches = count can_cook = [] # if we do not have any necessary ingredient, return ...
true
1f0d340225be278ee074362f280207a60be9ed63
Ardra/Python-Practice-Solutions
/chapter3/pbm11.py
332
4.125
4
'''Problem 11: Write a python program zip.py to create a zip file. The program should take name of zip file as first argument and files to add as rest of the arguments.''' import sys import zipfile directory = sys.argv[1] z = zipfile.zipfile(directory,'w') length = len(sys.argv) for i in range(2,length): z.write(s...
true
09c3839dbbe5c8cfc50eff2e5bd07fa5851695c0
Ardra/Python-Practice-Solutions
/chapter6/pbm1.py
203
4.21875
4
'''Problem 1: Implement a function product to multiply 2 numbers recursively using + and - operators only.''' def mul(x,y): if y==0: return 0 elif y>0: return x+mul(x,y-1)
true
c19f67d6f4a5d2448fb4af73f1e3f12d3786bd1c
Ardra/Python-Practice-Solutions
/chapter3/pbm2.py
742
4.21875
4
'''Problem 2: Write a program extcount.py to count number of files for each extension in the given directory. The program should take a directory name as argument and print count and extension for each available file extension.''' def listfiles(dir_name): import os list = os.listdir(dir_name) return list d...
true
29d5d901fc4ea681b9c2caa9f2dddf954174da4d
Ardra/Python-Practice-Solutions
/chapter2/pbm38.py
399
4.15625
4
'''Problem 38: Write a function invertdict to interchange keys and values in a dictionary. For simplicity, assume that all values are unique. >>> invertdict({'x': 1, 'y': 2, 'z': 3}) {1: 'x', 2: 'y', 3: 'z'}''' def invertdict(dictionary): new_dict = {} for key, value in a.items(): #print key, value ...
true
874438d788e903d45edc24cc029f3265091130b1
IDCE-MSGIS/sample-lab
/mycode_2.py
572
4.25
4
""" Name: Banana McClane Date created: 24-Jan-2020 Version of Python: 3.4 This script is for randomly selecting restaurants! It takes a list as an input and randomly selects one item from the list, which is output in human readable form on-screen. """ import random # importing 'random' allows us to pick a random elemen...
true
c5a84486c9e216b5507fb076f1c9c64257804232
DaveG-P/Python
/BookCodes/DICTIONARIES.py
2,745
4.59375
5
# Chapter 6 # A simple dictionary person = {'name': 'david', 'eyes': 'brown', 'age': 28} print(person['name']) print(person['eyes']) # Accessing values in a dictionary print(person['name']) # If there is a number in value use str() print(person['age']) # Adding new key-valu pairs person['dominate side'] = 'left' pers...
true
9773d6abe3781c5c2bc7c083a267a3b84bc30983
proTao/leetcode
/21. Queue/622.py
1,931
4.1875
4
class MyCircularQueue: def __init__(self, k: int): """ Initialize your data structure here. Set the size of the queue to be k. """ self.data = [None] * k self.head = 0 self.tail = 0 self.capacity = k self.size = 0 def enQueue(self, value...
true
be7f5249e86caa685f932b2cbd962d11fb9596a5
purusottam234/Python-Class
/Day 17/exercise.py
722
4.125
4
# Create a list called numbers containing 1 through 15, then perform # the following tasks: # a. Use the built in function filter with lambda to select only numbers even elements function. # Create a new list containing the result # b.Use the built in function map with a lambda to square the values of numbers' eleme...
true
03b3e29c726f1422f5fa7f6ec200af74bad7b678
purusottam234/Python-Class
/Day 17/generatorexperessions.py
530
4.1875
4
from typing import Iterable # Generator Expression is similar to list comprehension but creates an Iterable # generator object that produce on demand,also known as lazy evaluation # importance : reduce memory consumption and improve performance # use parenthesis inplace of square bracket # This method doesnot crea...
true
c212f377fd1f1bf1b8644a068bbf0a4d48a86fb0
purusottam234/Python-Class
/Day 5/ifelif.py
524
4.28125
4
# pseudo code # if student'grade is greater than or equal to 90 # display "A" # else if student'grade is greater than or equal to 80 # display "B" # else if student'grade is greater than or equal to 70 # display "C" # else if student'grade is greater than or equal to 60 # display "D" # else # display "E" # Python impl...
true
dd012da4f847a1ac2d8ee942adcad572104fa345
pianowow/projecteuler
/173/173.py
967
4.125
4
#------------------------------------------------------------------------------- # Name: module1 # Purpose: # # Author: CHRISTOPHER_IRWIN # # Created: 05/09/2012 ##We shall define a square lamina to be a square outline with a square "hole" so ##that the shape possesses vertical and horizontal ...
true
d28564c2c36afa5fe4e96ce763d90bd07b6f2bcd
alok162/Geek_Mission-Python
/count-pair-sum-in-array.py
901
4.125
4
#A algorithm to count pairs with given sum from collections import defaultdict #function to calculate number of paris in an array def countPairSum(d, arr, sum): count = 0 #storing every array element in dictionary and #parallely checking every element of array is previously #seen in dictionary or not ...
true
0700f44ab1b11b60d28cd635aeaf20df5b90959d
jaolivero/MIT-Introduction-to-Python
/Ps1/ProblemSet1.py
779
4.125
4
r = 0.04 portion_down_payment = 0.25 current_savings = 0.0 annual_salary = float(input( "What is your annual salary: ")) portion_saved = float(input("what percentage of your salary would you like to save? write as a decimal: ")) total_cost = float(input("what is the cost of your deam home: ")) monthly_sav...
true
04acb5cf7f7f70354415001e67ba64b6062e97aa
isiddey/GoogleStockPrediction
/main.py
2,377
4.25
4
#Basic Linear Regression Tutorial for Machine Learning Beginner #Created By Siddhant Mishra #We will try to create a model to predict stock price of #Google in next 3 days import numpy as np import pandas as pd import quandl as qd import math from sklearn import preprocessing, cross_validation from sklearn.linear_mod...
true
6545045e6e520f70af769078d008a3e72492c4fe
saifazmi/learn
/languages/python/sentdex/basics/48-53_matplotlib/51_legendsAndGrids.py
728
4.15625
4
# Matplotlib labels and grid lines from matplotlib import pyplot as plt x = [5,6,7,8] y = [7,3,8,3] x2 = [5,6,7,8] y2 = [6,7,2,6] plt.plot(x,y, 'g', linewidth=5, label = "Line One") # assigning labels plt.plot(x2,y2, 'c', linewidth=10, label = "Line Two") plt.title("Epic Chart") plt.ylabel("Y axis") plt.xlabel("X ...
true
b6a0bc120206cbb24f780c8b35065925c9ae038a
saifazmi/learn
/languages/python/sentdex/intermediate/6_timeitModule.py
1,765
4.1875
4
# Timeit module ''' ' Measures the amount of time it takes for a snippet of code to run ' Why do we use timeit over something like start = time.time() ' total = time.time() - start ' ' The above is not very precise as a background process can disrupt the snippet ' of code to make it look like it ran for longer than it...
true
dcc08fb3c7b4ef7eeee50d79bd1751b537083339
saifazmi/learn
/languages/python/sentdex/basics/8_ifStatement.py
302
4.46875
4
# IF statement and assignment operators x = 5 y = 8 z = 5 a = 3 # Simple if x < y: print("x is less than y") # This is getting noisy and clutered if z < y > x > a: print("y is greater than z and greather than x which is greater than a") if z <= x: print("z is less than or equal to x")
true
f9d01749e966f4402c3591173a145b65380d2102
saifazmi/learn
/languages/python/sentdex/basics/62_eval.py
900
4.6875
5
# Using Eval() ''' ' eval is short for evaluate and is a built-in function ' It evaluates any expression passed through it in form of a string and will ' return the value. ' Keep in mind, just like the pickle module we talked about, eval has ' no security against malicious attacks. Don't use eval if you cannot ' trust...
true
27634a1801bd0a5cbe1ca00e31052065a8e4ce9b
saifazmi/learn
/languages/python/sentdex/basics/64-68_sqlite/66_readDB.py
852
4.40625
4
# SQLite reading from DB import sqlite3 conn = sqlite3.connect("tutorial.db") c = conn.cursor() def read_from_db(): c.execute("SELECT * FROM stuffToPlot") # this is just a selection data = c.fetchall() # gets the data print(data) # Generally we iterate through the data for row in data: pr...
true
95443c1973cf14c5467b2fb8c4e24fda942bdfa9
saifazmi/learn
/languages/python/sentdex/intermediate/7_enumerate.py
830
4.40625
4
# Enumerate ''' ' Enumerate takes an iterable as parameter and returns a tuple containing ' the count of item and the item itself ' by default the count starts from index 0 but we can define start=num as param ' to change the starting point of count ''' example = ["left", "right", "up", "down"] # NOT the right way o...
true
8bbb0737979d0709d1edca705a4966f369a110de
saifazmi/learn
/languages/python/sentdex/intermediate/2_strConcatAndFormat.py
1,161
4.21875
4
# String concatenation and formatting ## Concatenation names = ["Jeff", "Gary", "Jill", "Samantha"] for name in names: print("Hello there,", name) # auto space print("Hello there, " + name) # much more readable, but makes another copy print(' '.join(["Hello there,", name])) # better for performance, no co...
true
04652bd04e648972fd819c39d288b8f52577eb14
saifazmi/learn
/languages/python/sentdex/basics/43_tkMenuBar.py
1,464
4.25
4
# Tkinter Menu Bar ''' ' Menus are defined with a bottom-up approach ' the menu items are appended to the menu, appended to menu bar, ' appended to main window, appended to root frame ''' from tkinter import * class Window(Frame): def __init__(self, master = None): Frame.__init__(self, master) ...
true
2f6bb6a1d83586fe2504c1ceb787392891bd011d
lucky1506/PyProject
/Item8_is_all_digit_Lucky.py
311
4.15625
4
# Item 8 def is_all_digit(user_input): """ This function validates user entry. It checks entry is only digits from 0 to 9, and no other characters. """ numbers = "0123456789" for character in user_input: if character not in numbers: return False return True
true
086101d275de833242f8fcfd2acddbfd6af62919
gelfandbein/lessons
/fibonacci.py
1,176
4.625
5
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Wed Mar 4 18:50:32 2020 @author: boris """ """Write a program that asks the user how many Fibonnaci numbers to generate and then generates them. Take this opportunity to think about how you can use functions. Make sure to ask the user to enter ...
true
7d7d6e70123576f89a5c8d318fc7339ec7c1a771
shreyan-naskar/Python-DSA-Course
/Strings/Max frequency/prog.py
532
4.3125
4
''' Given a string s of latin characters, your task is to output the character which has maximum frequency. Approach:- Maintain frequency of elements in a separate array and iterate over the array and find the maximum frequency character. ''' s = input("Enter the string : ") D = {} Freq_char = '' Freq = 0 for i in s...
true
591e06efb766c4fd99986c756192b68d91ea2fd3
shreyan-naskar/Python-DSA-Course
/Functions in Python/find primes in range/primes.py
429
4.15625
4
#Finding all primes in a given range. def isPrime( n ) : count = 0 for i in range(2,n) : if n%i == 0 : count = 0 break else : count = 1 if count == 1 : return True else : return False n = int(input('Enter the upper limit of Range : ')) List_of_Primes = [] for i in range(1,n+1) : if isPrime(i) ...
true
2dbeef63ca251b9d9ab446b8776ea376ac3b0451
akshajbhandari28/guess-the-number-game
/main.py
1,584
4.1875
4
import random print("welcome to guess the number game! ") name = input("pls lets us know ur name: ") print("hello, ", name, "there are some things you need tp know before we begin..") print("1) you have to guess a number so the number u think type only that number and nothing else") print("2) you will get three chance...
true
3829020674ee0e08dd307a6e89606752f27f810b
Meowsers25/py4e
/chapt7/tests.py
2,099
4.125
4
# handle allows you to get to the file; # it is not the file itself, and it it not the data in file # fhand = open('mbox.txt') # print(fhand) # stuff = 'hello\nWorld' # print(stuff) # stuff = 'X\nY' # print(stuff) # # \n is a character # print(len(stuff)) # 3 character string # a file is a sequence of lines with \n...
true
fe5e4243e64ebedaa1b31718b2be256e24cd52a3
bipulhstu/Data-Structures-and-Algorithms-Through-Python-in-Depth
/1. Single Linked List/8. Linked List Calculating Length.py
1,401
4.21875
4
class Node: def __init__(self, data): self.data = data self.next = None class LinkedList: def __init__(self): self.head = None def print_list(self): cur_node = self.head while cur_node: print(cur_node.data) cur_node = cur_node.ne...
true
05caa2fd68e08437ee71919e6bc044168d4b69fc
emsipop/PythonPractice
/pig_latin.py
680
4.28125
4
def pig_latin(): string = input("Please enter a string you would like translating: ").lower() #Changes case of all characters to lower words = string.split(" ") # Splitting the user's input into an array, each item corresponding to each word in the sentence translation = [] # An empty array which each tr...
true
4a1333b1c3da67ad28f85a9094066b52c6ad51b6
gaurav9112in/FST-M1
/Python/Activities/Activity8.py
238
4.125
4
numList = list(input("Enter the sequence of comma seperated values : ").split(",")) print("Given list is ", numList) # Check if first and last element are equal if (numList[0] == numList[-1]): print("True") else: print("False")
true
0e8240844666542eeb745b0e53c5471e9a7d55a9
sergiuvidican86/MyRepo
/exerc4 - conditions 2.py
327
4.1875
4
name = "John" age = 24 if name == "John" and age == 24: print("Your name is John, and you are also 23 years old.") if name == "test" pass if name == "John"or name == "Rick": print("Your name is either John or Rick.") if name in ["John", "Rick"]: print("Your name is either John or ...
true
63c29133e42fb808aa8e42954534eef33508e22b
oscarwu100/Basic-Python
/HW4/test_avg_grade_wu1563.py
1,145
4.125
4
################################################################################ # Author: BO-YANG WU # Date: 02/20/2020 # This program predicts the approximate size of a population of organisms. ################################################################################ def get_valid_score():#re print the ...
true
6dd26ecb710eec1d072c7971044b29362b244b10
AMRobert/Simple-Calculator
/Simple_Calculator.py
1,846
4.15625
4
#SIMPLE CALCULATOR #Function for addition def addition(num1,num2): return num1 + num2 #Function for subtraction def subtraction(num1,num2): return num1 - num2 #Function for multiplication def multiplication(num1,num2): return num1 * num2 #Function for division def division(num1,num2): return num1 / ...
true
e8af57b1a0b5d1d6ec8e8c7fa2899c2ddc8f2135
lnogueir/interview-prep
/problems/stringRotation.py
1,174
4.40625
4
''' Prompt: Given two strings, s1 and s2, write code to check if s2 is a rotation of s1. (e.g., "waterbottle" is a rotation of "erbottlewat"). Follow up: What if you could use one call of a helper method isSubstring? ''' # Time: O(n), Space: O(n) def isStringRotation(s1, s2): if len(s1) != len(s2): return False...
true
334d1b51189b1492bb754f0db69a2357cc8e0f15
abideen305/devCamp-task
/Bonus_Task_2.py
1,845
4.46875
4
#!/usr/bin/env python # coding: utf-8 # In[4]: # program to replace a consonant with its next concosnant #Starting by definig what is vowel and what is not. Vowel are just: a,e,i,o,u #defining a function with the name vowel and its argument v def vowel(v): #if statement to taste if the word containing any of the...
true
97433547ac2da4227d9c64499727b46c5b05c3f7
Mayank2134/100daysofDSA
/Stacks/stacksUsingCollection.py
490
4.21875
4
#implementing stack using #collections.deque from collections import deque stack = deque() # append() function to push # element in the stack stack.append('a') stack.append('b') stack.append('c') stack.append('d') stack.append('e') print('Initial stack:') print(stack) # pop() function to pop element from stack i...
true
3f81995adbbbc6c32e77ca7aaa05c91f5dd25d99
Lexielist/immersive---test
/Prime.py
204
4.15625
4
A = input("Please input a number: ") print ("1 is not a prime number") for number in range (2,A): if num%A == 0: print (num," is a prime number) else: print (num,"is not a prime number)
true