blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
fade8fcd236ccbf30038d4ca49cd11dd18dae898
isaolmez/core_python_programming
/com/isa/python/chapter6/ShallowCopy.py
1,228
4.28125
4
## SHALLOW COPY person = ["name", ["savings", 100.00]] print id(person), id(person[:]) print "---- Slice copy" husband = person[:] print id(person), id(person[:]) print id(person), id(husband) # They both refer to the same string "name" as their first element and so on. print "id() of names:", id(person[0]), id(husban...
true
0c2c06e78b487259157082a78e21bdcf951a457b
Supython/SuVi
/+or-or0.py
287
4.5
4
#To Check whether the given number is positive or negative S=int(input("Enter a number: ")) if S>0: print("Given number {0} is positive number".format(S)) elif S<0: print("Given number {0} is negative number".format(S)) else: print("Given number {0} s Zero".format(S))
true
d4c1b4e64302f1f0a851ed7fa7061142b687320d
chisoftltd/PythonFilesOperations
/PythonWriteFile.py
1,443
4.375
4
# Write to an Existing File import os f = open("demofile2.txt", "a") f.write("Now the file has more content! TXT files are useful for storing information in plain text with no special formatting beyond basic fonts and font styles.") f.close() myfile = open("Tutorial2.txt", "w") myfile.write("Python Programming Tutor...
true
8c2035389bee962cd81c58f710e21d5f5e15d5cd
artorious/simple_scripts_tdd
/test_longer_string.py
998
4.15625
4
#!/usr/bin/env python3 """ Tests for longer_string.py """ import unittest from longer_string import longer_string class TestLongerString(unittest.TestCase): """ Test cases for longer_string() """ def test_invalid_input(self): """ Tests both arguments are strings """ self.assertRaises( ...
true
e4a9b2f2f3c847ea444f2380217eca63adf7ffd3
JessBrunker/euler
/euler23/euler23.py
2,576
4.125
4
#!/usr/bin/python3 ''' A perfect number is a number for which the sum of its proper divisors is exactly equal to the number. For example, the sum of the proper divisors of 28 would be 1+2+4+7+14=28, which means 28 is a perfect number. A number n is called deficient if the sum of its proper divisors is less than n and...
true
8ffa90066929fb6ada2524fedba217edd785c2e4
jorge-jauregui/guess-the-number-game
/guess the number.py
587
4.125
4
print("Welcome to Jorge's 'guess the number' game!") print("I have in mind a number between 1 and 100. Can you guess what it is?") import random random.randrange(1, 101) number_guess = random.randrange(1, 101) chances = 0 while chances < 100000: user_guess = int(input("Type your guess: ")) if user_guess == n...
true
316688cfd723a90690b103add5d1b582ca75bbf9
akshay-1993/Python-HackerRank
/Staircase.py
574
4.40625
4
# Problem # Consider a staircase of size : n = 4 # # # # ## # ### # #### # Observe that its base and height are both equal to n, and the image is drawn using # symbols and spaces. The last line is not preceded by any spaces. # # Write a program that prints a staircase of size n. #!/bin/python3 im...
true
36d0406ea682acc2c1847191849ac889a75d75c9
dagamargit/absg_exercises
/04_changing_the_line_spacing_of_a_text_file.py
1,063
4.125
4
#!/usr/bin/python # Write a script that reads each line of a target file, then writes the line back to stdout, #+but with an extra blank line following. This has the effect of double-spacing the file. # # Include all necessary code to check whether the script gets the necessary command-line argument (a filename), #+and...
true
e267a34267b31cae25ca650817d9f6ec23097ccc
jeremy-techson/PythonBasics
/tuples.py
621
4.375
4
# Tuples are immutable list numbers = (1, 2, 3, 4, 5) print(numbers) # Operations available to tuples are almost the same with list print(numbers[0:3]) print("Length: ", len(numbers)) numbers = numbers + (6, 7) print(numbers) print("7 in tuple?", 7 in numbers) for num in numbers: print(num, end=", ") print(""...
true
2500df19b972bec81642da911c1ee72101bf0ee8
tjguk/kelston_mu_code
/20181124/primes.py
635
4.21875
4
"""A simple function which will indicate whether a number is a prime or not """ def is_prime(n): # # Check every number up to half of the number # we're checking since if we're over half way # we must have hit all the factors already # for factor in range(2, 1 + (n // 2)): if n % factor ...
true
316e325d6eb23a574569332c4796dc70118847bc
ardenzhan/dojo-python
/arden_zhan/Python/Python Fundamentals/string_list.py
862
4.125
4
''' String and List Practice .find() .replace() min() max() .sort() len() ''' print "Find and Replace" words = "It's thanksgiving day. It's my birthday, too!" print "Position of first instance of day:", words.find("day") print words.replace("day", "month", 1) print "" print "Min and Max" x = [2,54,-2,7,12,98] print "...
true
4d79f25d46800b34809bfa18691f99567f91ce20
ardenzhan/dojo-python
/arden_zhan/Python/Python Fundamentals/scores_and_grades.py
800
4.34375
4
'''Scores and Grades''' # generates ten scores between 60 and 100. Each time score generated, displays what grade is for particular score. ''' Grade Table Score: 60-79; Grade - D Score: 70-79; Grade - C Score: 80-89; Grade - B Score: 90-100; Grade - A ''' # import random # #random_num = random.random() # #random funct...
true
c63063ed71536d139b127cc48d2aae18a915e8ba
muhammad-masood-ur-rehman/Skillrack
/Python Programs/adam-number.py
665
4.375
4
Adam number A number is said to be an Adam number if the reverse of the square of the number is equal to the square of the reverse of the number.  For example, 12 is an Adam number because the reverse of the square of 12 is the reverse of 144, which is 441, and the square of the reverse of 12 is the square of 21, whic...
true
7451ad703a6c8c56d0976ef8e6d481ef3e7feae0
muhammad-masood-ur-rehman/Skillrack
/Python Programs/sum-unit-digit-3-or-6.py
667
4.34375
4
Sum - Unit Digit 3 or 6 The program must accept N integers as the input. The program must print the sum of integers having the unit digit as 3 or 6 as the output. If there is no such integer then the program must print -1 as the output. Boundary Condition(s): 1 <= N <= 100 1 <= Each integer value <= 10^5 Example Input...
true
1c96e07d40bd8283d1b28ac27fe4c5d8af4d31e4
muhammad-masood-ur-rehman/Skillrack
/Python Programs/replace-border-with-string.py
907
4.3125
4
Replace Border with String The program must accept a character matrix of size RxC and a string S as the input. The program must replace the characters in the border of the matrix with the characters in the string S in the clockwise direction. Then the program must print the modified matrix as the output. Example Inpu...
true
ada01c186d7844f188d4231a43681cedd802029c
muhammad-masood-ur-rehman/Skillrack
/Python Programs/product-of-current-and-next-elements.py
1,369
4.125
4
Product of Current and Next Elements Given an array of integers of size N as input, the program must print the product of current element and next element if the current element is greater than the next element. Else the program must print the current element without any modification. Boundary Condition(s): 1 <= N <= ...
true
5c30823a56d59cc5c51b764f4781fed4b1ba1997
muhammad-masood-ur-rehman/Skillrack
/Python Programs/find-duplicates-in-folder.py
1,562
4.1875
4
Find Duplicates In Folder The directory structure of a file system is given in N lines. Each line contains the parent folder name and child file/folder name. If a folder has two files/folders with the same name then it is a duplicate. Print all the duplicate file/folders names sorted in ascending order. If there is no...
true
63f9c82f95090e789395286b4f977b74ac621a4b
muhammad-masood-ur-rehman/Skillrack
/Python Programs/matching-word-replace.py
1,307
4.3125
4
Matching Word - Replace ? The program must accept two string values P and S as input. The string P represents a pattern. The string S represents a set of words. The character '?' in P matches any single character. The program must print the word in S that matches the given pattern P as the output. If two or more words...
true
5de0252734c9525ea7956e7cd76d14401e1b3d7d
muhammad-masood-ur-rehman/Skillrack
/Python Programs/python-program-for-interlace-odd-even-from-a-to-b.py
1,509
4.4375
4
Python Program for Interlace odd / even from A to B Two numbers A and B are passed as input. The program must print the odd numbers from A to B (inclusive of A and B) interlaced with the even numbers from B to A. Input Format: The first line denotes the value of A. The second line denotes the value of B. Output Format...
true
c2b2db90bec32dd87464306cbc8a57b91b3d0243
muhammad-masood-ur-rehman/Skillrack
/Python Programs/odd-even-row-pattern-printing.py
940
4.59375
5
Odd Even Row - Pattern Printing Given a value of N, where N is the number of rows, the program must print the character '*' from left or right depending on whether the row is an odd row or an even row. - If it is an odd row, the '*' must start from left. - If it is an even row, the '*' must start from right. After the...
true
25e72d166e88791aaac58cdd83ed552c38b3867f
muhammad-masood-ur-rehman/Skillrack
/Python Programs/check-sorted-order.py
1,127
4.125
4
Check Sorted Order The program must accept N integers which are sorted in ascending order except one integer. But if that single integer R is reversed, the entire array will be in sorted order. The program must print the first integer that must be reversed so that the entire array will be sorted in ascending order. Bo...
true
a8d6708bf1f9958cd05214bf00e43a3cf3dcdfe0
muhammad-masood-ur-rehman/Skillrack
/Python Programs/count-overlapping-string-pattern.py
1,039
4.1875
4
Count Overlapping String Pattern Two string values S and P representing a string and pattern are passed as the input to the program. The program must print the number of overlapping occurrences of pattern P in the string S as the output. Note: The string S and pattern P contains only lowercase alphabets. Boundary Cond...
true
6ee5cd6a8e090682bf699c788e467ccb8cfb975c
muhammad-masood-ur-rehman/Skillrack
/Python Programs/first-m-multiples-of-n.py
558
4.46875
4
First M multiples of N The number N is passed as input. The program must print the first M multiples of the number Input Format: The first line denotes the value of N. The second line denotes the value of M. Output Format: The first line contains the M multiples of N separated by a space. Boundary Conditions: 1 <= N <...
true
15125f1513e68e317ad5bc79e4f09f7c6dbb4dbd
muhammad-masood-ur-rehman/Skillrack
/Python Programs/direction-minimum-shift.py
2,093
4.3125
4
Direction & Minimum Shift The program must accept two string values S1 and S2 as the input. The string S2 represents the rotated version of the string S1. The program must find the minimum number of characters M that must be shifted (Left or Right) in S1 to convert S1 to S2. Then the program must print the direction (...
true
c88a8f7c2ef64b308a95bd5b040b5f98df2f40b1
muhammad-masood-ur-rehman/Skillrack
/Python Programs/remove-characters-from-left.py
1,445
4.28125
4
Remove Characters from Left Remove Characters from Left: The program must accept two string values S1 and S2 as the input. The program must print the minimum number of characters M to be removed from the left side of the given string values so that the revised string values become equal (ignoring the case). If it is n...
true
aa6ea506e424f5b0a50f4537652395b31a901596
muhammad-masood-ur-rehman/Skillrack
/Python Programs/rotate-matrix-pattern.py
1,377
4.46875
4
Rotate Matrix Pattern The program must accept an integer matrix of size N*N as the input. The program must rotate the matrix by 45 degrees in the clockwise direction. Then the program must print the rotated matrix and print asterisks instead of empty places as the output. Boundary Condition(s): 3 <= N <= 100 Input For...
true
8ec84a6f4492aa2fc49b4fee6a9e6a9ca41083f6
muhammad-masood-ur-rehman/Skillrack
/Python Programs/sum-of-digits-is-even-or-odd.py
690
4.125
4
Sum of Digits is Even or Odd Sum of Digits is Even or Odd: Given an integer N as input, the program must print Yes if the sum of digits in a given number is even. Else it must print No. Boundary Condition(s): 1 <= N <= 99999999 Input Format: The first line contains the value of N. Output Format: The first line contain...
true
1321a5a0862b67f2f4568189562a86f3444a201e
muhammad-masood-ur-rehman/Skillrack
/Python Programs/batsman-score.py
844
4.125
4
Batsman Score Batsman Score: Given an integer R as input, the program must print Double Century if the given integer R is greater than or equal to 200. Else if the program must print Century if the given integer R is greater than or equal to 100. Else if the program must print Half Century if the given integer R is gr...
true
dc3805fb23ea3f2f06c3263183c16edd3967deed
muhammad-masood-ur-rehman/Skillrack
/Python Programs/toggle-case.py
617
4.3125
4
Toggle Case Simon wishes to convert lower case alphabets to upper case and vice versa. Help Simon by writing a program which will accept a string value S as input and toggle the case of the alphabets. Numbers and special characters remain unchanged.  Input Format: First line will contain the string value S  Output For...
true
cd8de721b5a119f128606b24071ed7a2c4aafed0
muhammad-masood-ur-rehman/Skillrack
/Python Programs/top-left-to-bottom-right-diagonals-program-in-python.py
1,296
4.28125
4
Top-left to Bottom-Right Diagonals Program In Python The program must accept an integer matrix of size RxC as the input. The program must print the integers in the top-left to bottom-right diagonals from the top-right corner of the matrix. Boundary Condition(s): 2 <= R, C <= 50 1 <= Matrix element value <= 1000 Input ...
true
6c7286a208f6e7c8152d488ceb97ebb1df8c7bbf
muhammad-masood-ur-rehman/Skillrack
/Python Programs/unique-alphabet-count.py
596
4.3125
4
Unique Alphabet Count A string S is passed as input to the program which has only alphabets (all alphabets in lower case). The program must print the unique count of alphabets in the string. Input Format: - The first line will contain value of string S+ Boundary Conditions: 1 <= Length of S <= 100 Output Format: The ...
true
5ae44003eed074094a44f7b9f3edf268e48f022f
muhammad-masood-ur-rehman/Skillrack
/Python Programs/python-program-to-print-fibonacci-sequence.py
575
4.5625
5
Python Program To Print Fibonacci Sequence An integer value N is passed as the input. The program must print the first N terms in the Fibonacci sequence. Input Format: The first line denotes the value of N. Output Format: The first N terms in the Fibonacci sequence (with each term separated by a space) Boundary Condit...
true
10e61b1d76df5b45f241b64dc305f9420d297a2e
muhammad-masood-ur-rehman/Skillrack
/Python Programs/print-numbers-frequency-based.py
1,045
4.46875
4
Print Numbers - Frequency Based An array of N positive integers is passed as input. The program must print the numbers in the array based on the frequency of their occurrence. The highest frequency numbers appear first in the output. Note: If two numbers have the same frequency of occurrence (repetition) print the sma...
true
1370e5de23f56dad4a80ed2d09096913b7899778
muhammad-masood-ur-rehman/Skillrack
/Python Programs/sparse-matrix.py
706
4.34375
4
Sparse Matrix Write an algorithm and the subsequent Python program to check whether the given matrix is sparse or not. A matrix is said to be a “Sparse” if the number  of zero entries  in the matrix,  is greater than or equal to the number  of non-zero entries. Otherwise it is  “Not sparse”. Check for boundary conditi...
true
82212ae4feda9fea0df5846fdc235aee5d457ddf
muhammad-masood-ur-rehman/Skillrack
/Python Programs/all-digits-pairs-count.py
1,119
4.21875
4
All Digits - Pairs Count The program must accept N integers as the input. The program must print the number of pairs X where the concatenation of the two integers in the pair consists of all the digits from 0 to 9 in any order at least once. Boundary Condition(s): 2 <= N <= 100 1 <= Each integer value <= 10^8 Input Fo...
true
27381d83b8d936ffeff2ef2e10665d913a7a166b
alexandroid1/PytonStarter_Lesson1_PC
/calculator.py
370
4.1875
4
x = float(input("First number: ")) y = float(input("Second number: ")) operation = input("Operation") result = None if operation == '+': result = x + y elif operation == '-': result = x-y elif operation == '*': result = x*y elif operation == '/': result = x/y else: print('Unsupported operation') i...
true
fc8f710a881f74f7bf2cfc65a6c00ecccd939dfe
urstkj/Python
/thread/thread.py
1,484
4.125
4
#!/usr/local/bin/python #-*- coding: utf-8 -*- import _thread import threading import time # Define a function for the thread def print_time(threadName, delay): count = 0 while count < 5: time.sleep(delay) count += 1 print("%s: %s" % (threadName, time.ctime(time.time()))) # Create two...
true
38aa843a83904894f86e1c447fcdb138b281a370
luckeyme74/tuples
/tuples_practice.py
2,274
4.40625
4
# 12.1 # Create a tuple filled with 5 numbers assign it to the variable n n = ('2', '4', '6', '8', '10') # the ( ) are optional # Create a tuple named tup using the tuple function tup = tuple() # Create a tuple named first and pass it your first name first = tuple('Jenny',) # print the first lette...
true
abe6186dcccda09293dd055eb09cbb0c24de9a93
saidaHF/InitiationToPython
/exercises/converter2.py
1,031
4.15625
4
#!/usr/bin/env python # solution by cpascual@cells.es """ Exercise: converter2 --------------------- Same as exercise converter1 but this time you need to parse the header to obtain the values for the gain and the offset from there. Also, you cannot assume that the header has just 3 lines or that the order of the i...
true
e1be8a6391e8d69d9906b8712357a171952493c4
mauricejenkins-00/Python-Challenge
/pypoll/main2.py
2,486
4.34375
4
#Import libraries os, and Csv import os import csv #Give canidates a variable to add the canidates and vote count to candidates = {} #election_csv is a variable that calls for the election data file in the resources folder election_csv = os.path.join('.','Resources','election_data.csv') #With statement opens...
true
1c4c1304afa4fb8619848032eafba93110c4eb19
jackmar31/week_2
/parkingGarage/# Best Case: O(n) - Linear.py
901
4.28125
4
# Best Case: O(n) - Linear def swap(i,j, array): array[i],array[j] = array[j],array[i] def bubbleSort(array): # initially define isSorted as False so we can # execute the while loop isSorted = False # while the list is not sorted, repeat the following: while not isSorted: # assume t...
true
06ea29eec33fe7ef9b2254a7b3fcd28b33bd6a60
simgroenewald/StringDataType
/Manipulation.py
869
4.34375
4
# Compulsory Task 3 strManip = input("Please enter a sentence:")#Declaring the variable StrLength = len(strManip)#Storing the length of the sentence as a variable print(StrLength)# Printing the length of the sentence LastLetter = strManip[StrLength-1:StrLength] #Storing the last letter of the lentence as a variable...
true
3695661c954293f8c27fd7f1ea75e22e4003c377
ulicqeldroma/MLPython
/basic_slicing.py
696
4.15625
4
import numpy as np x = np.array([5, 6, 7, 8, 9]) print x[1:7:2] """Negative k makes stepping go toward smaller indices. Negative i and j are interpreted as n + i and n + j where n is the number of elements in the corresponding dimension.""" print x[-2:5] print x[-1:1:-1] """If n is the number of items in the dimens...
true
da2a27e14b2e98b13c25310fea2ea62af5f9e07c
JIANG09/LearnPythonTheHardWay
/ex33practice.py
354
4.125
4
def while_function(x, j): i = 0 numbers = [] while i < j: print(f"At the top i is {i}") numbers.append(i) i = i + x print("Numbers now: ", numbers) print(f"At the bottom i is {i}") return numbers numbers_1 = while_function(7, 10) print("The numbers: ") for ...
true
620a67cbe340ace45f2db953d28b110f9fb0ac3d
timwilson/base30
/base30/base30.py
2,528
4.4375
4
#!/usr/bin/env python3 """ This module provides two functions: dec_to_b30 and b30_to_dec The purpose of those functions is to convert between regular decimal numbers and a version of a base30 system that excludes vowels and other letters than may be mistaken for numerals. This is useful for encoding large numbers in...
true
400b14f32ee96af63ee8fbf4c750443ec51c1532
hamk-webdev-intip19x6/petrikuittinen_assignments
/lesson_python_basics/side_effect.py
629
4.375
4
# WARNING! DO NOT PROGRAM LIKE THIS # THE FOLLOWING FUNCTION HAS AN UNDOCUMENTED SIDE EFFECT def mymax(a): """Return the item of list a, which has the highest value""" a.sort() # sort in ascending order return a[-1] # return the last item a = [1, 10, 5, -3, 7] print(mymax(a)) print(a) # a is sorted as ...
true
047fe4c0903be5318f414cff2ce4fbb295768f58
hamk-webdev-intip19x6/petrikuittinen_assignments
/lesson_python_file_and_web/ask_float_safely.py
533
4.15625
4
def ask_float(question): """display the question string and wait for standard input keep asking the question until user provides a valid floating point number. Return the number""" while True: try: return float(input(question)) except ValueError: print("Please giv...
true
8b3498cef391bc920ca5d9db2966bd3cbe71bcfd
hamk-webdev-intip19x6/petrikuittinen_assignments
/lesson_python_basics/closure.py
322
4.21875
4
# Example of a closure def make_multiplier(x): # outer / enclosing function def multiplier(y): # inner / nested function return x*y return multiplier mul10 = make_multiplier(10) # mul is the closure function print(mul10(5)) # 50 print(mul10(10)) #100 mul2 = make_multiplier(2) print(mul2(10)) # 2...
true
f162f9720be4566474fcd6e09731c5f43a727059
sterlingb1204/EOC2
/HW4.py
998
4.5
4
#-- Part 2: Python and SQLite (25 Points) #-- #-- Take your Homework 1, Part 1 module and re-write #-- it to so that it queries against the sqlite3 #-- babynames database instead. #-- #-- The beauty of this approach is that, because #-- your original code was in a module, you can #-- change how the module fulfills the...
true
e37de75b4b15d71da1d709b52889d49cbef78bd8
volodiny71299/Right-Angled-Triangle
/02_number_checker.py
1,010
4.3125
4
# number checker # check for valid numbers in a certain range of values # allow float def num_check(question, error, low, high, num_type): valid = False while not valid: try: response = num_type(input(question)) if low < response < high: return response ...
true
2571fb011cab5aed53fa2d7a10bb66470982bbf9
volodiny71299/Right-Angled-Triangle
/01_ask_what_calculate.py
962
4.40625
4
# ask user what they are trying to calculate (right angled triangle) valid_calculations = [ ["angle", "an"], ["short side", "ss"], ["hypotenuse", "h"], ["area", "ar"], ["perimeter", "p"] ] calculation_ok = "" calculation = "" for item in range(0,3): # ask user for what they are trying to cal...
true
8f24a35c4ff8b1ebbb4e476e7ac6dd74d4a652dc
pjarcher913/python-challenges
/src/fibonacci/module.py
1,020
4.15625
4
# Created by Patrick Archer on 29 July 2019 at 9:00 AM. # Copyright to the above author. All rights reserved. """ @file asks the user how many Fibonacci numbers to generate and then generates them """ """========== IMPORTS ==========""" """========== GLOBAL VARS ==========""" """========== MAIN() ==========""" ...
true
c4cccf258eab393d27882e0e80b006df10784546
phu-n-tran/LeetCode
/monthlyChallenge/2020-05(mayChallenge)/5_02_jewelsAndStones.py
1,349
4.15625
4
# -------------------------------------------------------------------------- # Name: Jewels and Stones # Author(s): Phu Tran # -------------------------------------------------------------------------- """ You're given strings J representing the types of stones that are jewels, and S representing the s...
true
0482288b53ef2ee63980d4d388ae8dc7d9b6ae7f
phu-n-tran/LeetCode
/monthlyChallenge/2020-06(juneChallenge)/6_29_UniquePaths.py
2,214
4.5
4
# -------------------------------------------------------------------------- # Name: Unique Paths # Author(s): Phu Tran # -------------------------------------------------------------------------- """ A robot is located at the top-left corner of a m x n grid (marked 'Start' in the diagram below). ...
true
68cb6a414b42c04874e1a204a7bd2ffd16f3dba9
phu-n-tran/LeetCode
/monthlyChallenge/2020-07(julychallenge)/7_02_BTLevelOrderTraversal2.py
2,801
4.21875
4
# -------------------------------------------------------------------------- # Name: Binary Tree Level Order Traversal II # Author(s): Phu Tran # -------------------------------------------------------------------------- """ Given a binary tree, return the bottom-up level order traversal of its nodes'...
true
5b5cda38002926df07c4809361992ba67ed62c2a
phu-n-tran/LeetCode
/monthlyChallenge/2020-06(juneChallenge)/6_18_HIndex_V2.py
2,119
4.25
4
# -------------------------------------------------------------------------- # Name: H-Index II # Author(s): Phu Tran # -------------------------------------------------------------------------- """ Given an array of citations sorted in ascending order (each citation is a non-negative integer) of a re...
true
862417cfb9e359619f04610c0a1ee27492e43ddc
phu-n-tran/LeetCode
/monthlyChallenge/2020-06(juneChallenge)/6_13_LargestDivisibleSubset.py
2,169
4.15625
4
# -------------------------------------------------------------------------- # Name: Largest Divisible Subset # Author(s): Phu Tran # -------------------------------------------------------------------------- """ Given a set of distinct positive integers, find the largest subset such that every pair (S...
true
890540caa1d454ce7c0d7dd0944d8fde13ed3193
aernesto24/Python-el-practices
/Basic/Python-university/Functions/ArithmeticTables/arithmeticTables.py
2,650
4.46875
4
"""This software shows the arithmetic tables based on the input the user provides, it can show: multiplication table, sum tablet, etc. """ #Function to provide the multiplication table from 0 to 10 def multiplicationTables(LIMIT, number): counter = 0 print("Tabla de multiplicar de " + str(number)) for...
true
15a69ecb35cec652121faaf582966f25ea7dad8b
gaoyangthu/leetcode-solutions
/004-median-of-two-sorted-arrays/median_of_two_sorted_arrays.py
1,815
4.28125
4
#! /usr/bin/env python # -*- coding: utf-8 -*- """ There are two sorted arrays nums1 and nums2 of size m and n respectively. Find the median of the two sorted arrays. The overall run time complexity should be O(log (m+n)). Example 1: nums1 = [1, 3] nums2 = [2] The median is 2.0 Example 2: nums1 = [1, 2] nums2 = [3...
true
3153c6df49836cc64a8b4cf94a57c9bcf1b30927
dgibbs11a2b/Module-9-Lab-Assignment
/Problem2NumList10.py
711
4.1875
4
#---------------------------------------- #David Gibbs #March 10, 2020 # #This program will use a while loop to append the current #value of the current counter variable to the list and #then increase the counter by 1. The while loop then stops #once the counter value is greater than 10. #------------------------------...
true
84cce619cee66ec68eb13425e3d6c11ef2cb6ec1
JonasKanuhsa/Python
/Survey/Survey.py
573
4.1875
4
''' Make a program that can take survey information. @author: Jonas Kanuhsa ''' question = "What is your name?" name = input("What is your name") print(name) response = "What is your favorite color?" color = input("What is your favorite color?") print(color) var = = "What city did you grow up in?" city = inp...
true
f0345277450b059093e85d4a310eddb279d501ea
MistyLeo12/Learning
/Python/double_linked.py
1,967
4.21875
4
class Node(object): def __init__(self, data = None): self.data = data self.next = None self.prev = None class doublyLinkedList(object): def __init__(self): self.root = Node() self.size = 0 def get_size(self): current = self.root counter = 0 ...
true
da11b4c7fdf486d72914db90af4b471bb91709bf
ErickMwazonga/learn_python
/others/mothly_rate.py
1,097
4.1875
4
import locale # set the locale for use in currency formatting result = locale.setlocale(locale.LC_ALL, '') if result == 'C': locale.setlocale(locale.LC_ALL, 'en_US') # display a welcome message print("Welcome to the Future Value Calculator") # print() choice = 'Y' while choice.lower() == 'y': # get input from the ...
true
85c7222686015f91f512afc68fa49a2d3689f67a
edithclaryn/march
/hobbies.py
251
4.28125
4
"""Create a for loop that prompts the user for a hobby 3 times, then appends each one to hobbies.""" hobbies = [] # Add your code below! for i in range(3): hobby = input("Enter your hobby: ") print (hobby) hobbies.append(hobby) i += 1
true
0a2280f39b0f3bcc6ed11af2df1001813cc342b9
edithclaryn/march
/battleship.py
945
4.21875
4
"""Create a 5 x 5 grid initialized to all 'O's and store it in board. Use range() to loop 5 times. Inside the loop, .append() a list containing 5 "O"s to board. Note that these are capital letter "O" and not zeros.""" board = [] for i in range(0,5): board.append(["O"]*5) print (board) #Use the print command to displa...
true
291b9fcbb8a201634e37bc6ffded8ca809404b6e
nahymeee/comp110-21f-workspace
/exercises/ex05/utils.py
1,120
4.125
4
"""List utility functions part 2.""" __author__ = "730330561" def only_evens(first: list[int]) -> list[int]: """Gives back a list of only the even numbers.""" i: int = 0 evens: list[int] = [] while i < len(first): if first[i] % 2 == 0: evens.append(first[i]) i += 1 ret...
true
1f23bfe9500c5f4405f3f1ad69e472dd5a755a05
NickPerez06/Python-miniProjects
/rpsls.py
1,802
4.34375
4
''' This mini project will create the game rock, paper, scissors, lizard, spock for your enjoyment. Author: Nicholas Perez ''' import random def name_to_number(name): '''converts string name to number for rpsls''' number = 0 if( name == "rock" ): number = 0 return number elif ( name == "Spock" ...
true
29bcc76645fbf2a3133fe36f2799a53ac5de279b
MicahJank/Intro-Python-I
/src/16_stretch.py
1,893
4.3125
4
# 3. Write a program to determine if a number, given on the command line, is prime. # 1. How can you optimize this program? # 2. Implement [The Sieve of # Eratosthenes](https://en.wikipedia.org/wiki/Sieve_of_Eratosthenes), one # of the oldest algorithms known (ca. 200 BC). import sys import math #...
true
99bfc65a4a0cffca30b37ff18a129edd81b8b359
kom50/PythonProject
/Simple Code/Factorial.py
369
4.21875
4
# find factorial using loop def fact(num): # 1st function f = 1 for i in range(1, num + 1): f *= i return f # find factorial using recursive function def fact1(num): # 2nd function if num == 1: return 1 return num * fact1(num - 1) # 1st function print('Factorial : ', fact(4))...
true
6aa47cd97da9f307b127f9ba7df2b81325f5674b
tlkoo1/Lok.Koo-Chatbot
/ChatBotTemplate.py
569
4.25
4
#open text document stop-words.txt file = open("stop-words.txt") stopwords = file.readlines() #function going through all stopwords def removeStopwords(firstWord): for word in stopwords: next = word.strip() firstWord = firstWord.replace(" " + next + " ", " " ) return firstWord #while inpu...
true
ef6c8b1057839016de9dd2b51ffd879435043270
martinaobrien/pands-problem-sets
/sumupto.py
1,128
4.28125
4
# Martina O'Brien: 24 - 02 - 2019 # Problem Set Programming and Scripting Code 1 #Calculate the sum of all factorials of positive integer # Input variable needed for calculation # Int method returns an integer as per python programming # input "Enter Number" will be visible on the user interface # setting up va...
true
0debb74096cb6fb8c78922e17677242b87b884d9
rmaur012/GraphicalSequenceAlgorithm
/GraphicalSequenceAlgorithm.py
2,392
4.3125
4
#Setting up the sequence list try: sizeOfSeq = raw_input("How many vetices are there? ") sizeOfSeq = int(sizeOfSeq) index = 0 sequence = [None]*sizeOfSeq except ValueError: print 'A Non-Numerical Value Was Entered. Please Try Again And Enter With A Numerical Value.' quit(...
true
adab3d9ccab42569ced54c6fd3551335a7b34969
hsrwrobotics/Robotics_club_lectures
/Week 2/Functions/func_echo.py
1,497
4.375
4
# -*- coding: utf-8 -*- """ Created on Mon Oct 21 16:15:36 2019 HSRW Robotics @author: mtc-20 """ # A function definition starts with the keyword def followed the function # name which can be anything starting with an alphabet, preferably in # lowercase followed by a colon {:}. The body(the block of code to...
true
0161be485ecedd4e17fd86e5049d4ef2bea9191d
liyouzhang/Algos_Interviews
/sum_of_two_values.py
1,254
4.375
4
def find_sum_of_two_one(A, val): ''' input - array of numbers; val - a number output - bool 1. native: - try all combinations of two numbers in array: 2 for loops - for each, test if == target ''' #1. naive approach for a in A: for b in A: if b != a: if a + b == val: retur...
true
50b40bb9f10c8abbe769296dea8d895e517ee13e
liyouzhang/Algos_Interviews
/819_most_common_word.py
2,900
4.34375
4
''' Given a paragraph and a list of banned words, return the most frequent word that is not in the list of banned words. It is guaranteed there is at least one word that isn't banned, and that the answer is unique. Words in the list of banned words are given in lowercase, and free of punctuation. Words in the paragr...
true
87ae2f7ef55554516cf8cdce8e1a57837533b3e8
doraithodla/py101
/learnpy3/word_freq_2.py
783
4.15625
4
# wordfreq2 - rewrite the wordfreq program to take the text from a file and count the words def word_freq1(str): """ takes a string and calculates the word frequency table :param str: string input :return: frequency dictionary """ frequency = {} for word in str.split(): if word in f...
true
16ba194d28de4bf38a2764f173606bce7cde982b
doraithodla/py101
/shapes.py
282
4.28125
4
from turtle import forward, right def shape(sides,length): for i in range(sides): forward(length) right(360/sides) ''' length = int(input("Length: ")) sides = int(input("Number of sides:")) ''' for sides in range(3,5): shape(sides, 100)
true
41b4bb8bda85667c76cc72387e98ef65fc4fd871
doraithodla/py101
/learnpy2/wordset.py
328
4.125
4
noise_words = {"if", "and", "or", "the", "add"} def wordset(string): """ converts a list of words to a set :param list: string input from the user :return: set object """ string_set = set(string.split()) print(string_set) print(noise_words) wordset("a is a test to check the test of ...
true
bea6d8a0680e3c04423bf50c4e89d162cdace2af
eternalseptember/CtCI
/04_trees_and_graphs/01_route_between_nodes/route_between_nodes.py
1,044
4.1875
4
""" Given a directed graph, design an algorithm to find out whether there is a route between two nodes. """ class Node(): def __init__(self, name=None, routes=None): self.name = name self.routes = [] if routes is not None: for item in routes: self.routes.append(item) def __str__(self): list_of_rou...
true
275a53e865259a0d15f82cdacdc2a58a641b9343
eternalseptember/CtCI
/07_object-oriented_design/11_file_system/file_system.py
2,226
4.28125
4
""" Explain the data structures and algorithms that you would use to design an in-memory file system. Illustrate with an example in code where possible. """ # What is the relationship between files and directories? class Entry(): def __init__(self, name, parent_dir): self.name = name self.parent_dir = parent_di...
true
005103cb3b2736711e6dd9a194a19cb0db8bd420
jcs-lambda/cs-module-project-algorithms
/sliding_window_max/sliding_window_max.py
1,016
4.34375
4
''' Input: a List of integers as well as an integer `k` representing the size of the sliding window Returns: a List of integers ''' def sliding_window_max(nums, k): # initialize first window and max window = nums[:k] current_max = max(window) maxes = [current_max] # slide window for x in nums...
true
f01f3cb9fdf5bd6c4167da2ff209ec7df0308681
subashchandarA/Python-Lab-Pgms-GE8151-
/11MostFrequentWord.py
660
4.34375
4
#Most Frequent word in a string #str="is program is to find the of the word in the string" filename=input("Enter the file name to find the most frequent word: ") fo=open(filename,'r') str=fo.read() print("The given string is :",str) wordlist = str.split(" ") d={} for s in wordlist: if( s in d.keys(...
true
5dac50e3ef0821386d271fe18a353c279e69ea1e
subashchandarA/Python-Lab-Pgms-GE8151-
/6.1 selecion sort(python method).py
1,356
4.21875
4
def selectionsort(lt): "select the min value and insert into its position" for i in range(len(lt)-1): #min_pos=x #for x in range(i+1,len(lt)): # if(lt[min_pos]>lt[x]): # min_pos=x min_pos=lt[i:].index(min(lt[i:])) # FIND THE INDEX OF M...
true
a7cd794a1ef6fc543980181f1cf7144b6dd6639f
ShreyaPriyanil/Sorting-in-Python
/insertionsort.py
514
4.21875
4
def insertionSort(alist): for index in range(1,len(alist)): print("TRAVERSAL #: ",index) position = index while position>0 and alist[position-1]>alist[position]: temp = alist[position] alist[position] = alist[position-1] alist[position-1] = temp ...
true
df1eb693316cd623603e43fbee56746b8445b821
shivdazed/Python-Projects-
/Exceptionhandling.py
324
4.15625
4
try: a = int(input("Enter the number A:")) b = int(input("Enter the number B:")) c = a/b print(c) #except Exception as e: # print(e) except ZeroDivisionError: print("We can't divide by zero") except ValueError: print("Your entered value is wrong") finally: print("Sum = ",a+...
true
08e7e22f6f39a02caca937e0fca7982fb33c901c
Poonam-Singh-Bagh/python-question
/Loop/multiplication.py
228
4.21875
4
''' Q.3 Write a program to print Multiplication of two numbers without using multiplication operator.''' i = 1 a = int(input("enter a no.")) b = int(input("enter a no.")) c = 0 while i <= b: c = c + a i = i + 1 print (c)
true
13cd95427f9fed8977a2b5de25abae5c22d361c6
ONJoseph/Python_exercises
/index game.py
1,013
4.375
4
import random def main(): # 1. Understand how to create a list and add values # A list is an ordered collection of values names = ['Julie', 'Mehran', 'Simba', 'Ayesha'] names.append('Karel') # 2. Understand how to loop over a list # This prints the list to the screen one value at a time fo...
true
ca67ed3630bf2bf15468aaacd138312cb1854ad8
shubhamjha25/FunWithPython
/coin_flipping_game/coinflipgame.py
635
4.21875
4
import random import time print("-------------------------- COIN FLIPPING GAME -----------------------------") choice = input("Make your choice~ (heads or tails): ") number = random.randint(1,2) if number == 1: result = "heads" elif number == 2: result = "tails" print("-------------------------------- DECIDING ...
true
d1cee333a1147bc53c0040e732128b8a5d05abca
Anisha7/Tweet-Generator
/tasks1-5/rearrange.py
1,612
4.28125
4
# build a script that randomly rearranges a set of words provided as command-line arguments to the script. import sys import random # shuffles given list of words def rearrange(args): result = [] while (len(args) > 0) : i = random.randint(0, len(args)-1) result.append(args.pop(i)) ret...
true
bb8749c3abda670d006b2184f7b620449bb54f07
joseramirez270/pfl
/Assignment4/generate_model.py
1,180
4.1875
4
"""modify this by generating the most likely next word based on two previous words rather than one. Demonstrate how it works with a corresponding conditional frequency distribution""" import nltk """essentially, this function takes a conditional frequency distribution of bigrams and a word and makes a sentence. ...
true
0a93e0ded92ef09809aa22bd801667587171f6ed
jyoung2119/Class
/Class/demo_labs/PythonStuff/5_10_19Projects/dateClass.py
1,918
4.15625
4
#Class practice class Date: def __init__(self, m, d): self.__month = m self.__day = d #Returns the date's day def get_day(self): return self.__day #Returns the date's month def get_month(self): return self.__month #Returns number of days in ...
true
ac1971b1544ccb491d9ed862258cc4bf3dbccae2
inbsarda/Ccoder
/Python_codes/linked_list.py
2,030
4.1875
4
################################################### # # Linked List # ################################################### class node: def __init__(self, data): self.data = data self.next = None def insertAtBegining(head,data): ''' Insert node at begining ''' newnode = node(data) ...
true
a4c58d8162dbb4317ec0cfced87e8e3c71860f74
inbsarda/Ccoder
/Python_codes/reverse_list.py
1,161
4.3125
4
################################################################## # # Reverse the linked list # ################################################################## class node: def __init__(self, data): self.data = data self.next = None class linkedlist: def __init__(self): self.head =...
true
a1593b01f3f3c09d1c392c63612e81506d90243a
doritger/she-codes-git-course-1
/ex2.py
1,049
4.28125
4
from datetime import datetime # imports current date and time def details(): first_name = input("Please enter your first name: ") surname = input("Please enter your surname: ") birth_year = input("Please enter the year of your birth: ") # asks the user to enter name, surname and year of birth print...
true
5fe884067f7af8df12f114e84a40953cab414d6e
abby-does-code/youtube_practice_intmd
/dictionaries!!.py
2,766
4.3125
4
# START ## Keep chugging away bb! # Dictionary: data type that is unordered and mutable ##Consists of key:value pairs; maps value to associated pair # Create a dictionary(30:00) mydict = {"name": "Max", "age": 28, "city": "New York"} print(mydict) # Dict method for creation # mydict2 = dict(name = "Mary", age = 27, ...
true
18f75cc839f336f3a2f815a578eb5871ad2a7f5c
pranabsg/python-dsa
/get_fibonacci.py
381
4.28125
4
"""Implement a function recursively to get the desired Fibonacci sequence value. """ def get_fib(position: int) -> int: if position == 0 or position == 1: return position return get_fib(position - 1) + get_fib(position - 2) def main(): # Test cases print(get_fib(2)) print(get_fib(11)) ...
true
f78a79c275e90a90394269b230cdef39dbc4d979
danecashion/python_example_programs
/first_largest.py
284
4.5625
5
""" Python program to find the largest element and its location. """ def largest_element(a): """ Return the largest element of a sequence a. """ return None if __name__ == "__main__": a = [1,2,3,2,1] print("Largest element is {:}".format(largest_element(a)))
true
8bf8929bbfe763af15cf61cdb294ca78b59bc057
annamwebley/PokerHand
/deck.py
2,626
4.15625
4
# Project 3b # Anna Markiewicz # May 12 # deck.py # Shuffle the Card objects in the deck import random from card import Card class Deck: """Card Deck, which takes self as input, and creates a deck of cards """ def __init__(self): self.cards = [ ] for suit in ['C', 'D', 'H', 'S']: ...
true
492eddbeffe120a0ca71fc4767ce8e6523b04978
lshpaner/python-datascience-cornell
/Analyzing and Visualizing Data with Python/Importing and Preparing Data/LoadDataset.py
2,531
4.125
4
#!/usr/bin/env python # coding: utf-8 # ## Analyzing the World Happiness Data # # # ### Preparing the data for analysis # In this exercise, we will do some initial data imports and preprocessing to get the data ready for further analysis. We will repeat these same basic steps in subsequent exercises. Begin by exe...
true
28b512c74e3fd196b8ca592e9c81d72bfe1f9672
lshpaner/python-datascience-cornell
/Constructing Expressions in Python/Computing the Average (Mean) of a List of Numbers/exercise3.py
975
4.53125
5
""" Computing the Average (Mean) of a List of Numbers Author: Leon Shpaner Date: July 19, 2020 In exercise3.py in the code editor window, create a new list containing a mixture of letters and numbers: my_other_list = [1, 2.3, 'a', 4.7, 'd'], and write an expression computing its average value using a similar expre...
true