blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
a12565ffe01358c9d543d3464e56df3e23501221
mikeyPower/cryptopals
/set_2/challenge_9.py
1,245
4.53125
5
''' Implement PKCS#7 padding A block cipher transforms a fixed-sized block (usually 8 or 16 bytes) of plaintext into ciphertext. But we almost never want to transform a single block; we encrypt irregularly-sized messages. One way we account for irregularly-sized messages is by padding, creating a plaintext that is an ...
true
875298300541ef4adebafe74e2bed929a72942ac
ebookscg-python/Book1-python
/Chapter 1/Example 1_2.py
604
4.5
4
# -*- coding: utf-8 -*- """ @author: guardati Example 1_2 Printings in Python using methods of strings. """ # Put the first letter into upper case. print("the days are short.".capitalize()) # Center contemplating 20 spaces. print("Spring".center(20)) # Center and fill in with * left and right. print(...
true
c5f8c8907b724808509d9ca26d15568eb0c809d4
vivek1395/python-code
/dict2.py
295
4.25
4
# write a program to create a dictionary by user and add the sum of values. d=eval(input('enter the dictionary:')) print(d) sum2=sum(d.values()) # method-1 print('sum2 is :',sum2) '''sum=0 for i in d.values(): # method-2: sum=sum + i print('sum of number is:',sum)'''
true
d9e2a577c4ea2ce308ba9080005a3bc140fa17c3
vivek1395/python-code
/string2.py
539
4.28125
4
# write a program to access each character of string in forward and backward direction by using while loop. s='vivek loves python' # declaring string n=len(s) # calculating length of string i=0 # intializing the counter while (i<n+1): for x in s: # reading the string forward ...
true
1268bcb725298181102d4b27f0b39b3e697681b8
MichaelPascale/py
/listcomp2.py
472
4.40625
4
#!/usr/bin/env python2 # # Copyright 2019, Michael Pascale # # List Comprehensions # Exercise from ai.berkeley.edu/tutorial.html # # Write a list comprehension which, from a list, generates a lowercased version # of each string that has length greater than five. continents = ['Antarctica', 'Africa', 'Asia', 'Europe', ...
true
4b545065ed19662bf5ac6ea38919cbdb10b350c4
Aislingpurdy01/CA278
/ca278-2021-05-06-purdya2/uploads/2021-05-06/ca278/purdya2/compare_dates.py
1,864
4.6875
5
#!/usr/bin/env python class My_Date: ''' This is a class definition for a calandar date. ''' def __init__(self, day, month, year): ''' This initialises the attributes of the object self. ''' self.day = day self.month = month self.year = year def __str__(self): ''' Returns all th...
true
e30ad92fac2416a2b91c98bb831382e005f6c875
Aislingpurdy01/CA278
/ca278-2021-05-06-purdya2/uploads/2021-02-22/ca278/purdya2/circle04.py
371
4.1875
4
#!/usr/bin/env python from math import pi class Circle: ''' This is a circle class ''' def __init__(self, radius): self.radius = radius def get_area(self): ''' return area of the circle. ''' return pi * self.radius ** 2 def get_circumference(self): ''' return the circumference of...
true
db54e49adb3b134df1a88a21d959d875393438dc
Aislingpurdy01/CA278
/ca278-2021-05-06-purdya2/uploads/2021-02-21/ca278/purdya2/employee04.py
601
4.1875
4
#!/usr/bin/env python class Employee: ''' This is an Employee class definition. ''' def _init_(self, name, job_desc, salary): self.name = name self.job_desc = job_desc self.salary = salary def net_salary(self): '''Return net salary.''' return self.salary * 0.80 if __name__...
true
324e6e2d73806f573c850ca043535ae96bb23f1d
Devarshonly1/Finalyear_Internsip
/Day 1/Nested_If.py
451
4.1875
4
# Nested if... """ if condition : if condition : statement else : statement else : statement """ Num=float(input("Enter value of number : ")) if Num >=0 : if Num == 0 : print("Number is Zero "...
true
87abd8695ea3ac4f89c6eab7c44010d58c202d88
EddyYeung1/Top-75-LC-Questions
/Solutions/Valid_Parentheses.py
1,525
4.28125
4
''' Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid. An input string is valid if: Open brackets must be closed by the same type of brackets. Open brackets must be closed in the correct order. Note that an empty string is also considered valid. Exa...
true
2353166c6bd52fb89a9114478d376d75f9496692
EddyYeung1/Top-75-LC-Questions
/Solutions/BT_Right_side.py
1,136
4.21875
4
''' Given a binary tree, imagine yourself standing on the right side of it, return the values of the nodes you can see ordered from top to bottom. Example: Input: [1,2,3,null,5,null,4] Output: [1, 3, 4] Explanation: 1 <--- / \ 2 3 <--- \ \ 5 4 <--- ''' ''' Solution: Do ...
true
3974a80e5083b0a3f9225afb5aa77ec18b60baf0
EddyYeung1/Top-75-LC-Questions
/Solutions/Longest_Repeating_Char.py
1,177
4.15625
4
from collections import defaultdict ''' Given a string s that consists of only uppercase English letters, you can perform at most k operations on that string. In one operation, you can choose any character of the string and change it to any other uppercase English character. Find the length of the longest sub-string ...
true
1d67b703213c0576208b4c290c9590750382d238
godwinleo/python
/pymongo/Query.py
1,646
4.75
5
Python MongoDB Query Filter the Result When finding documents in a collection, you can filter the result by using a query object. The first argument of the find() method is a query object, and is used to limit the search. Example Find document(s) with the address "Park Lane 38": import pymongo myclient = pymongo.M...
true
a212774b5ec2de9396e9fe41a285aeef77f48293
rachel-benh/reserach_methods_in_software_engineering
/binary_search.py
1,670
4.3125
4
''' This function performs a binary search. Features tested: - Use of temporary variables vs. a single line computation Possible bug creations: - "half_len = math.floor(cur_len/2)" -> "half_len = cur_len/2" - "center_location = low_border+half_len" -> "center_location = high_border+half_len" ''' import math def lon...
true
274187e0e12a46017973be460921d6034613ac14
rifanarasheed/PythonDjangoLuminar
/OBJECTORIENTED/Bank.py
1,362
4.21875
4
from datetime import datetime class Bank: bank_name = "sbi" # bank_name is a static variable as it is same for every customer in this scenario def __init__(self,Ano,Aname,Abalance): self.Ano = Ano ...
true
030faa49096da67eb7b294573d479a9327bfc0b5
shubhangiitd/Capstone-Project
/Numbers/change.py
1,405
4.15625
4
''' The user enters a cost and then the amount of money given. The program will figure out the change and the number of quarters, dimes, nickels, pennies needed for the change. ''' def change(item_cost, cash_paid): coinnage = [('Quarter',25),('Dime',10), ('Nickle',5), ('Penny',1)] number_of_coins = [] ...
true
1ff27bd27f38c67fd7c47c9dd728a8b774fb1666
AdityJadhao/pythonProject
/String_programs.py
650
4.3125
4
# name = input ("Enter your Name:\n") # print("Good Morning: " + name) # write a program to take input date and name and replace in letter letter = '''Dear <|Name|> You are awesome.\nkeep faith in god and practice. Thank you,\n<|Name2|> Date : <|Date|> ''' '''X = input("Enter your Name: ") Dt = input("Enter date in mm...
true
8e7c222a05a88877a477b5d2084a02a0a6ae7349
hamza-yusuff/Enigma-API
/vs.py
2,825
4.25
4
# --- vigenere cipher # works best with lower case letters only # implements the vigenere cipher on the given string, using the provided key # the encrypted key is always given in lower case letters def vigenere_encrypt(string, key): chars = 'abcdefghijklmnopqrstuvwxyz' string = string.lower() string_le...
true
8156ee0e9f1475979aa3a97c6d7db25827f8f872
Zahidsqldba07/python-notes
/regex-example/exp.py
547
4.21875
4
""" 1.) find all lowercase letters in a string 2.) validate username: only lowercase, digists and underscore 3.) replace every charector in a string with another char """ import re p1 = r"[a-z]" s1 ="aDududaauXudffhfd197272xycy" r1=''.join(re.findall(p1,s1)) print(r1) def valid_username(username): p2=r"^[a-z...
true
f73962ff877c9db2a346f75d4e98f31cea9d5d61
LKotonii/Project_Euler
/problem4.py
680
4.40625
4
# Find the largest palindrome made from the product of two 3-digit numbers. # Returns True if reversed string is equal to the string received as parameter def isPalindrome(string): tempList=list(string) tempList.reverse() if (''.join(tempList)==string): return True # Finds largest palindrome made ...
true
8bb636fb37bbd15236193e69a2493a94d9b6b537
Tinkotsu/educative_practice
/Fast & Slow Pointers/Palindrome LinkedList (medium).py
1,537
4.21875
4
""" Given the head of a Singly LinkedList, write a method to check if the LinkedList is a palindrome or not. Your algorithm should use constant space and the input LinkedList should be in the original form once the algorithm is finished. The algorithm should have O(N)O(N) time complexity where ‘N’ is the number of nod...
true
5732945ac02704868f18a35e6b59c357bdede3d8
Tinkotsu/educative_practice
/Sliding_Windows/Permutation in a string.py
1,244
4.28125
4
# Given a string and a pattern, find out if the string contains any permutation of the pattern. # # Permutation is defined as the re-arranging of the characters of the string. # For example, “abc” has the following six permutations: # # 1. abc # 2. acb # 3. bac # 4. bca # 5. cab # 6. cba # # If a string has ‘n’ distinc...
true
a0f36b3f9e557726bc6bc79ad3e86ab9d86865a9
Bharadwaja92/CompetitiveCoding
/CodeSignal/Arcade/DepositProfit.py
1,049
4.4375
4
""" You have deposited a specific amount of money into your bank account. Each year your balance increases at the same growth rate. With the assumption that you don't make any additional deposits, find out how long it would take for your balance to pass a specific threshold. Of course you don't want to wait too long...
true
75b5071d0e7da7c05a1d5a053939a878ed449f26
Bharadwaja92/CompetitiveCoding
/CodeSignal/Arcade/BuildPalindrome.py
715
4.28125
4
""" Given a string, find the shortest possible string which can be achieved by adding characters to the end of initial string to make it a palindrome. Example For st = "abcdc", the output should be buildPalindrome(st) = "abcdcba". """ def checkPalindrome(st): return st[::-1] == st def buildPalindrome(str): ...
true
5a1038c089af54d0a9a0da66510909a21e3fed53
Bharadwaja92/CompetitiveCoding
/HackerEarth/CodeArena/CustomSort.py
1,540
4.40625
4
"""""" """ From the childhood we are taught that a comes before b then b comes before c and so on.So whenever we try to sort any given string we sort it in that manner only placing a before b and so on.But what happens if we initially change the pattern of sorting .This question arrived in Arav's young mind. He thought...
true
784614095b46152d01f002ad4f702e416c76ce8a
Bharadwaja92/CompetitiveCoding
/LeetCode/2460_Apply_Operations_to_an_Array.py
2,403
4.15625
4
""" You are given a 0-indexed array nums of size n consisting of non-negative integers. You need to apply n - 1 operations to this array where, in the ith operation (0-indexed), you will apply the following on the ith element of nums: If nums[i] == nums[i + 1], then multiply nums[i] by 2 and set nums[i + 1] to 0. Ot...
true
98cc1cb1aaf2a96e651038716db2acec8223f734
Bharadwaja92/CompetitiveCoding
/TechGig/30DayChallenge/MultOddEven.py
1,119
4.15625
4
""""""""" Multiplication between odd and even (100 Marks) For this challenge, you need to take number of elements as input on one line and array elements as an input on another line. You need to find the numbers that are odd, add them. find the numbers that are even add them and then multiply the two values that you ...
true
31bd25c9e8a78a2dc1a5d57a117ecc099b8ba2c2
Bharadwaja92/CompetitiveCoding
/TechGig/30DayChallenge/PowerRecursion.py
727
4.15625
4
"""""" """ This program takes two integers from user ( base number and a exponent) and calculates the power. Instead of using loops to calculate power, this program uses recursion to calculate the power of a number. Input Format For this challenge, you need to take 2 integer inputs from stdin which are separated by ...
true
809f05a50180959a825196ef3b960ae7040c82a8
Bharadwaja92/CompetitiveCoding
/CodeSignal/Arcade/EvenDigitsOnly.py
363
4.34375
4
""" Check if all digits of the given integer are even. Example For n = 248622, the output should be evenDigitsOnly(n) = true; For n = 642386, the output should be evenDigitsOnly(n) = false. """ def evenDigitsOnly(n): for c in str(n): print (int(c)) if int(c) % 2 != 0: return False ...
true
8808985af1d7c3537f5a6ed0225c8f4b52233e8f
Bharadwaja92/CompetitiveCoding
/CodeSignal/Arcade/AddBorder.py
607
4.21875
4
"""""" """ Given a rectangular matrix of characters, add a border of asterisks(*) to it. Example For picture = ["abc", "ded"] the output should be addBorder(picture) = ["*****", "*abc*", "*ded*", "*****"] """ def addBorder(picture)...
true
c6c8de7ce52d881279b722ee1939833064838327
Bharadwaja92/CompetitiveCoding
/CodeSignal/Arcade/DecodeString.py
1,038
4.15625
4
""" Given an encoded string, return its corresponding decoded string. The encoding rule is: k[encoded_string], where the encoded_string inside the square brackets is repeated exactly k times. Note: k is guaranteed to be a positive integer. Note that your solution should have linear complexity because this is what yo...
true
d674d7d6afd7bd0f578bd4eea7dec424f72e2168
Bharadwaja92/CompetitiveCoding
/CodeSignal/Arcade/MineSweeper.py
1,476
4.125
4
""" In the popular Minesweeper game you have a board with some mines and those cells that don't contain a mine have a number in it that indicates the total number of mines in the neighboring cells. Starting off with some arrangement of mines we want to create a Minesweeper game setup. Example For matrix = [[true,...
true
f24438326ab0961610b74bcaea9b6c98c2364876
rifatzhub/Currency-Converter
/mvp.py
1,035
4.125
4
# Minimum Viable Product def dollars_to_pounds(dollars): exchange_rate = 0.801344 pounds = dollars * exchange_rate return round(pounds, 2) def pounds_to_dollars(pounds): exchange_rate = 1.24821 dollars = pounds * exchange_rate return round(dollars, 2) # Further planning while True: reque...
true
2815399275306798907f0fa6e04e4b2a1763e319
genos/online_problems
/prog_praxis/soe_002.py
1,324
4.375
4
#!/usr/bin/env python """ Good ol' Sieve. GRE, 6/28/10 """ def _starter_helper(x): """ Initialization condition, to deal with Optimization 1. """ # Special cases; handles evens, 0, and 1 separately if (x == 2): return True elif (x == 0) or (x == 1): return False elif (x % 2 == 0): return Fals...
true
3a09054cc0e0cb62d22b25d40349e4e638fff2c7
orsegal/CS110-FinalProject
/hackingtrees/tutorials/python/conditionals.py
292
4.125
4
a = [1,2,3] print len(a) if len(a) == 3: print "it is three" if len(a) != 2: print "it is not equal to two" if len(a) == 3 and a[0] == 2: print "length is 3 and first is 2" elif len(a) == 3 and a[0] == 1: print "length is 3 and first is 1" else: print "none of these are correct"
true
b947a443c61a6015f047d5860e73f99a021ca0ef
nkuraeva/python-exercises
/week5/row_2.py
314
4.1875
4
# Given two integers A and B. # Print all numbers from A to B inclusive, # in ascending order if A <B, # or in decreasing order otherwise. A = int(input()) B = int(input()) if A < B: for i in range(A, B + 1): print(i, end=' ') if A >= B: for i in range(A, B - 1, -1): print(i, end=' ')
true
1ce2e075a51f6db5f44edd7de8b8ad4e21290461
pawar4/CAM2ImageDatabase
/ImageDB/compare.py
1,947
4.3125
4
import os import csv import sys def fileInCSV(folderPath, csvPath): try: # Store entire list of files in specified folderPath filesInFolder = os.listdir(folderPath) except: print("ERROR: Specified folder path (first argument) doesn't exist") exit(1) # List to store file nam...
true
1d6b6df01890caa50b6ff2a8f95eb10eea835cd7
alexandramilliron/Calculator-2
/calculator.py
1,648
4.21875
4
"""CLI application for a prefix-notation calculator.""" from arithmetic import (add, subtract, multiply, divide, square, cube, power, mod) def calculator(): problem = "" while problem != "q": problem = input("Enter your equation > ") problemsplit = problem.split(' ') ...
true
7f9382bb5107055d3d9de3db1d215bb8c4ea3b6a
grodrigues3/InterviewPrep
/Leetcode/rotateArray.py
578
4.34375
4
""" Rotate an array of n elements to the right by k steps. For example, with n = 7 and k = 3, the array [1,2,3,4,5,6,7] is rotated to [5,6,7,1,2,3,4]. Note: Try to come up as many solutions as you can, there are at least 3 different ways to solve this problem. """ class Solution: # @param nums, a list of integer...
true
584164f1f318c5393d736e2e2a9fe867d83775ca
tusharsathe1/Python
/Practice-Codes/OddOrEven.py
244
4.34375
4
#Ask user to input a number number = input("Enter an integer: ") #Calculate the remainder remainder = int(number) % 2 #Print the result if remainder == 0: print(number + " is an even number") else: print(number + " is an odd number")
true
d036b386b09f294fb270f8f6e4cdd53a2ec1116a
danielasay/small-python-projs
/looplists.py
1,957
4.125
4
def add_greetings(names): greeting_list = [] for name in names: greeting_list.append("Hello, " + name) return greeting_list #Uncomment the line below when your function is done print(add_greetings(["Owen", "Max", "Sophie"])) # Slicing lists with while loop based on parameters def delete_starting_evens(lst...
true
da69af956d2c063123ca6ea29d2fd59ef850ac7a
amadeist/learning-toys
/programiz/16-Find-factorial.py
212
4.3125
4
number = int(input("Enter a number for factorial calculation: ")) def factorial(num): if num == 1: return 1 else: return num * factorial(num-1) result = factorial(number) print(result)
true
27f877387d48b9e3782b7f38e8cfc2be2c28c43e
jacosta18/Python_basics
/user_details_funny_exercise.py
708
4.15625
4
import datetime # This is where I will do my exercise # Filipe told me to sudo code first # Get user first name # Save to variable # Get user other thing # Save somwhere else # Do some formating (What formating should be done and where?) # Out put some data first_name = input('What is your first_name?') last_name = ...
true
28b90261097c556a4acd79202d12e8ae01bbc4b0
jacosta18/Python_basics
/03_data_types_interger.py
1,038
4.5
4
# # Numericals - Intergers, big Intergers and complex numbers # # # Intergers Whole numbers # my_int = 13 # print(type(my_int)) # print(type(13)) # Not the same as print(type('13')) --> STRING! # # # Floats are composite numbers # # print(13.1) # print(type(13.1)) # Long and complex # less used check syntax when neede...
true
72140f50c686416520674cbf6484f26b4877b4d6
pganssle/python-norm-estimate
/subset_generators.py
1,986
4.125
4
""" Subset generator functions. Functions which generate sampling subsets on the fly. """ import random class RandomSubsetGenerator: """ Pulls data from the subset in random order, without replacement (e.g. no duplicates) """ def __init__(self, array_subset, n=None, rand_function=None): """ ...
true
86d461b1ad4b85af91fc66079c15a3d2d18e4408
hzaman193/Practice-Python
/Calculator2.py
934
4.15625
4
class Calculator2: """Do addition, subtraction, multiplication and division.""" def addition(self, a, b): return a + b def subtraction(self, a, b): return a - b def multiplication(self, a, b): return a * b def division(self, a, b): try: return a / b ...
true
39149677273cb89e7fff2d4e4c97638e8d151a2d
vishnutejakandalam/python_learning_2020
/try.py
933
4.125
4
#Exceptions # try: # try if the following code generates errors or not # print("hello world") # except: #catch if any error occurs in the try block and executes this... # print("It will save...") # else: #if there was no problem with try block then this will be executed... # print("else") def t...
true
62898165571e3aa798bbc487fd0f18f32a01400b
vishnutejakandalam/python_learning_2020
/factors.py
553
4.46875
4
"""Program to print all the factors of a composite number ....""" # taking a number from keyboard and converting to int n = int(input("Enter a number:")) def is_composite(number): count = 0 comp_factors = [] for i in range(1,number+1): if number % i ==0: count+=1 comp_factor...
true
2a162bd240e8dd2dcc030465791b9d4f99c24d98
szymekj/python-sandbox
/multiplication-table.py
201
4.25
4
# Display multiplication table for numbers 1 to 10. print ("Multiplication Table") for l1 in range (1, 11): for a1 in range (1,11): print ( str(a1) + " * " + str(l1) + " = " + str(a1*l1))
true
c2ee97d277536921c044a86515f1c6e4d486693b
JohnDRyanIV/Module_8
/more_fun_with_collections/validate_input_in_functions.py
1,823
4.3125
4
def get_test_scores(): """ This function assigns a series of test scores to dictionary values, with keys representing the order they were entered in :return: this returns a dictionary containing values of all test scores entered """ scores_dict = dict() num_scores = 0 invalid_message = "...
true
c796a83e255d85b60a70faf194b06d685c482349
KalvinWei/python-fundamentals
/01_basics.py
1,357
4.4375
4
# python comment format: hashtag + space + comment content # next line is to import math python module to enable us utilize more advanced arithmetic functions from math import * # ---------------SECTION 1: BASICS------------------ # print, string and string operations print("Hello,world") my_name = "john" print("Hel...
true
de7b6518855e6679ee6170d1fb756db0b542bf7b
yanshengjia/algorithm
/leetcode/Two Pointers/88. Merge Sorted Array.py
1,110
4.15625
4
""" Given two sorted integer arrays nums1 and nums2, merge nums2 into nums1 as one sorted array. Note: The number of elements initialized in nums1 and nums2 are m and n respectively. You may assume that nums1 has enough space (size that is greater or equal to m + n) to hold additional elements from nums2. Example: I...
true
cef7c26aa4d532d620dca5d5ada5b5511925e569
yanshengjia/algorithm
/leetcode/Hash Table/299. Bulls and Cows.py
1,692
4.1875
4
""" You are playing the following Bulls and Cows game with your friend: You write down a number and ask your friend to guess what the number is. Each time your friend makes a guess, you provide a hint that indicates how many digits in said guess match your secret number exactly in both digit and position (called "bulls...
true
a2c7c1f50bec47010d3b7a847379ff00dde5be30
yanshengjia/algorithm
/leetcode/Tree & Recursion/101. Symmetric Tree.py
2,510
4.40625
4
""" Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center). For example, this binary tree [1,2,2,3,4,4,3] is symmetric: 1 / \ 2 2 / \ / \ 3 4 4 3 But the following [1,2,2,null,3,null,3] is not: 1 / \ 2 2 \ \ 3 3 Follow up: Bonus points ...
true
34fa080b0677780f26adddc45ad44e06d2b66f6d
yanshengjia/algorithm
/leetcode/String/1614. Maximum Nesting Depth of the Parentheses.py
1,798
4.15625
4
""" A string is a valid parentheses string (denoted VPS) if it meets one of the following: * It is an empty string "", or a single character not equal to "(" or ")", * It can be written as AB (A concatenated with B), where A and B are VPS's, or * It can be written as (A), where A is a VPS. We can similarly define the ...
true
2e2e1a6741c8852c70665db8f5a3a5ca43468a91
yanshengjia/algorithm
/leetcode/Array/766. Toeplitz Matrix.py
1,368
4.46875
4
""" A matrix is Toeplitz if every diagonal from top-left to bottom-right has the same element. Now given an M x N matrix, return True if and only if the matrix is Toeplitz. Example 1: Input: matrix = [ [1,2,3,4], [5,1,2,3], [9,5,1,2] ] Output: True Explanation: In the above grid, the diagonals are: "[9]", "[...
true
c73230fce8e2c60fab812c32864c8043e3ca94d3
yanshengjia/algorithm
/leetcode/Tree & Recursion/114. Flatten Binary Tree to Linked List.py
2,086
4.40625
4
""" Given a binary tree, flatten it to a linked list in-place. For example, given the following tree: 1 / \ 2 5 / \ \ 3 4 6 The flattened tree should look like: 1 \ 2 \ 3 \ 4 \ 5 \ 6 Solution: 1. Recursion (in place) Flatten the left subtree ...
true
bd63b8e1ecf45c334724bc34debf628114b3047e
yanshengjia/algorithm
/leetcode/Hash Table/1213. Intersection of Three Sorted Arrays.py
1,006
4.46875
4
""" Given three integer arrays arr1, arr2 and arr3 sorted in strictly increasing order, return a sorted array of only the integers that appeared in all three arrays. Example 1: Input: arr1 = [1,2,3,4,5], arr2 = [1,2,5,7,9], arr3 = [1,3,4,5,8] Output: [1,5] Explanation: Only 1 and 5 appeared in the three arrays. Sol...
true
957536cb0589f6e4487b5f1693b699492117061d
yanshengjia/algorithm
/leetcode/Hash Table/609. Find Duplicate File in System.py
2,060
4.15625
4
""" Given a list of directory info including directory path, and all the files with contents in this directory, you need to find out all the groups of duplicate files in the file system in terms of their paths. A group of duplicate files consists of at least two files that have exactly the same content. A single dire...
true
f22d15a98805a69648bb5b8cb7bfe232066efda8
yanshengjia/algorithm
/leetcode/Dynamic Programming/70. Climbing Stairs.py
2,369
4.1875
4
""" You are climbing a stair case. It takes n steps to reach to the top. Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top? Note: Given n will be a positive integer. Example 1: Input: 2 Output: 2 Explanation: There are two ways to climb to the top. 1. 1 step + 1 step 2....
true
6273b212ff5c136bfdabaaa35bd047260bd2d608
yanshengjia/algorithm
/lintcode/String/956. Data Segmentation.py
1,095
4.1875
4
""" Given a string str, we need to extract the symbols and words of the string in order. Example 1: input: str = "(hi (i am)bye)" outut:["(","hi","(","i","am",")","bye",")"]. Explanation:Separate symbols and words. Solution: Go through the str, push the alphabetical into stack and append it to res list if we meet a...
true
c0cc6c758c160e3a685eab105fe952deca885c5b
Miguelmargar/ucd_programming1
/practical 6/p6p3.py
381
4.46875
4
# ask user for name # if name is Miguel: # print this # elif name is mickey: # print that # else: # print other name = input("please enter your name: ") if name == "miguel" or name == "Miguel": print("That is a cool name!") elif name == "mickey mouse" or name == "sponge bob": print("Not sure th...
true
9ab39311fee12e974de1165d8840326f07a9a772
Miguelmargar/ucd_programming1
/practical 12/p12p2.py
793
4.21875
4
# create function to find print fibonacci series # ask the user for length of the fibonacci series required # if lenght in equal or less than 0: # print message # else: # call fibonacci function def fibonacci(num): # set fibonacci 1 and 2 fib_0 = 0 fib_1 = 1 # print fibonacci 1 and 2 print(...
true
8def9ca52ab05ac875e0816040c993e403b34508
Miguelmargar/ucd_programming1
/practical 16/p16p2.py
1,038
4.34375
4
# Program to get the common divisors of two positive integers supplied by the user # Demonstrates the use of tuples def findDivisors(num1, num2): """Finds the common divisors of num1 and num2 Assumes that num1 and num2 are positive integers Returns a tuple containing the common divisors of num1 and num2""" ...
true
203498bc8b911d066d42ab22664ac1f2510e6b58
Miguelmargar/ucd_programming1
/practical 10/p10p2.py
752
4.3125
4
""" ask user input if user input == 0: print message elif user input < 0: create new_num = - user input else: new_num = number create counter while counter cubed < new_num: counter up by 1 if counter cubed == new_num: print message else: print message """ number = int(in...
true
2476a8a8b25f79ce82204148ee8d7ca5ded3407d
Miguelmargar/ucd_programming1
/practical 12/p12p3.py
699
4.1875
4
# create approximation function # ask user for number and for tolerance # if user input numbers are negative: # print message # else: # call function def aprox(num, tol): # set the step and the root step = tol ** 2 root = 0.0 # while loop to check conditions while abs(num - root ** 2) >= ...
true
030ff2c1ae65f1577895cba68851ee5bd4acc544
psangappa/mario
/app/save_princess/shortest_path.py
994
4.1875
4
from itertools import permutations from app.save_princess.const import UP, DOWN, LEFT, RIGHT def form_shortest_paths(mario_index, princess_index): """ First we will ignore the obstacles to find shortest paths This method follows the below rules to find the shortest path. If the row difference from Pr...
true
80d902c0729143405e270d028ffb51df409ea44b
plooney81/AlgoPractice
/anagram.py
1,442
4.3125
4
# write a function called anagram that accepts two strings and return True if they are anagrams and false if they aren't. # function that gets a single string from the user def get_a_string(): print('\n\nPlease input a string') while True: try: user_input = input('> ') to_int = ...
true
b3ab07dcd006077569b1b2f1e77dce62117b45dd
seekplum/seekplum
/linux-tools/argparse-sum
1,311
4.125
4
#!/usr/bin/env python # -*- coding: utf-8 -*- import argparse def add(res): result = 0 res = [str(i) for i in res] ret = '+'.join(res) for i in res: result += int(i) result = ret + '=' + str(result) return result def print_result(number): for i in range(1, number+1): if ...
true
92f0622bbcd1a0b0cd7850dcd5c39cec72da8245
jay6413682/ProjectEuler
/Euler/src/Q4.py
1,582
4.125
4
''' Created on Dec 17, 2014 @author: ljiang A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 * 99. Find the largest palindrome made from the product of two 3-digit numbers. ''' import math import timeit #O(n)=(n^2+n)/2 def findLargestPalin...
true
a779e5d0544bc5943dee425d8d58638a42458d4c
sashadev-sky/Python-for-Networking
/chapter2/files/create_file.py
590
4.15625
4
def main(): try: with open('test.txt', 'w') as file: file.write('this is a test file') except IOError as e: print('Exception caught: Unable to write to file ', e) except Exception as e: print('Another error occurred ', e) else: print('File written to successfu...
true
b76c0aaf1a116c7c1f09ba2599fcbbd320aacc90
flkt-crnpio/python-basics
/shape.py
349
4.21875
4
# Task # You are given a space separated list of nine integers. Your task is to convert this list into a 3X3 NumPy array. # # Input Format # A single line of input containing 9 space separated integers. # # Output Format # Print the 3X3 NumPy array. import numpy my_array = numpy.array(input().split(), int) my_array.s...
true
aa67646e94921f516b486298bee3c4847bcd98b2
Mixolydian1/MIT600
/ps3c.py
2,247
4.1875
4
# string things 3 from string import * ''' Write a function, called xxx which takes three arguments: a tuple representing starting points for the first substring, a tuple representing starting points for the second substring, and the length of the first substring. The function should return a tuple of all members (call...
true
e8d47a4241f1b1a0cf85c4f76cf3fede6e4cb4d8
akkipant/CSEE490-Python-and-Deep-Learning-Programming
/ICP_2/Source/strAlternative.py
354
4.28125
4
def string_Alternative(Str): # Function Definition #return Str[::2] # Return alternative characters of string newStr = '' count = 0 for x in Str: count += 1 if count%2: newStr += x return newStr if __name__ == '__main__': print(string_Alternative(input("Enter ...
true
a2fb56ed40ee0fe8019a09d9f158800baae8a0bb
phillipn/Python-Crash-Course-Activities
/shopping_list2.py
1,287
4.15625
4
def welcome_msg(): print("Welcome to to-do list!") print(""" Hit DONE if you are done with the list Hit SHOW to see current list Hit DELETE to delete an item Hit HELP if you are scared """) list = [] welcome_msg() def show_list(): print("Here is your list!") count = 1 for item in list: prin...
true
9b1de3d4d6fbb3b322b4a4128eb2ff73d2d84628
shirgei/lab2
/statistics.py
2,055
4.28125
4
def median(list_of_values): """ Calculates median value of a list :param list_of_values: list :return: median value """ sorted_list = sorted(list_of_values) center_index = int(len(list_of_values)/2) # round to int required because division always produces float # Median value depends on...
true
bde956b4285a093881e3ddc12bda216515c5b5f3
Anand-Chawan/IARCS-OPC-Judge-Problems-codechef-
/Reverse.py
1,795
4.21875
4
''' In this problem the input will consist of a number of lines of English text consisting of the letters of the English alphabet, the punctuation marks ' (apostrophe), . (full stop), , (comma), ; (semicolon), :(colon) and white space characters (blank, newline). Your task is print the words in the text in reverse ord...
true
c314d029507a8dae07185664dd84a5a67d82cdda
jlanks/GuessWho
/a2q2b.py
1,725
4.125
4
# # Name: Julian Lankstead # Student Number: 101043448 # # References: Gaddis, T (2015). "Starting Out With Python" StatementOne = raw_input("Does your arrow only face down? ") if StatementOne == "yes": StatementTwo = raw_input("Are there two lines below the arrow? ") if StatementTwo == "yes": print(...
true
e1aae027e2975f6ecc2d4c80369c6c4bf9dfc2c6
jasonbrackman/dailyprogrammer
/challenge_301/looking_for_patterns.py
2,808
4.40625
4
import itertools def search_for_pattern(pattern, word): """ Breaks down a string into a series of character representations to then see if the same pattern is repeated in the string word passed in. This is looking for a pattern match and not a specific character to character match. :param patte...
true
b6533394adbc8a4c8df73bc113bb2e700ed48e1e
3Nakajugo/python-exercises
/app/turn_to_list.py
575
4.21875
4
""" Qns. 4 """ # Write a program which accepts a sequence of comma-separated numbers # from console and generate a list and a tuple which contains every number. # Suppose the following input is supplied to the program: # 34,67,55,33,12,98 # Then, the output should be: # ['34', '67', '55', '33', '12', '98'] # ('34', '6...
true
3ad3d7c43699a59896ce03745d210bafa5d57612
3Nakajugo/python-exercises
/app/level2_q2.py
843
4.21875
4
# Question 7 # Write a program which takes 2 digits, X,Y as input and generates a 2-dimensional array. # The element value in the i-th row and j-th column of the array should be i*j. # Note: i=0,1.., X-1; j=0,1,¡­Y-1. # Example # Suppose the following inputs are given to the program: # 3,5 # Then, the output of the pr...
true
00cc2b4ade0fc3f14458a731ac94b597e4242640
gerosantacruz/Python
/criptrography/tranpositionCypher.py
1,267
4.125
4
# Transposition Cipher Encryption # https://www.nostarch.com/crackingcodes/ (BSD Licensed) import pyperclip def main(): message = input('Insert the message to encrypt: \n') key= int(input('Insert the key please: \n')) ciphertext = encript_message(key, message) # Print the encrypted string in ciphert...
true
05aaeb58a4a1ab92503751973353b63679c9c711
stostat/holbertonschool-higher_level_programming
/0x06-python-classes/4-square.py
713
4.28125
4
#!/usr/bin/python3 """empty class defining a square.""" class Square: """class defining a Square.""" def __init__(self, size=0): """Initialize private attributes.""" self.size = size @property def size(self): """Getter for private attribute.""" return self.__size ...
true
435d7c0b63d89c4b335fd0e436a22cd704957f01
stostat/holbertonschool-higher_level_programming
/0x07-python-test_driven_development/5-text_indentation.py
360
4.125
4
#!/usr/bin/python3 """Indents text after special characters.""" def text_indentation(text): """Indents text after special characters.""" chars = ['.', ':', '?'] if not isinstance(text, str): raise TypeError("text must be a string") for i in text: if i in chars: print(i) ...
true
d09fd966c72e4c29edae01cdb5545787bafd58d3
JonnyRivers/GoogleMLCrashCourse
/IntroToTensorFlow/programming_concepts.py
1,272
4.125
4
# https://colab.research.google.com/notebooks/mlcc/tensorflow_programming_concepts.ipynb import tensorflow as tf # Tensors are arrays of arbitrary dimensionality # * A scalar is a 0-d array (a 0th-order tensor) # * A vector is a 1-d array (a 1st-order tensor). For example, [2, 3, 5, 7, 11] or [5] # * A matrix is a 2-d...
true
248508b4bed618217f5df439d9abb9957aeef364
LishuGupta652/Python-Projects
/Temprature Forecast
1,811
4.40625
4
#!/usr/bin/env python # coding: utf-8 # # Temprature Forecast Program (In Fewlines of Code) # This is program used re and urllib.request library to show the Temprature of Country on the basic of Capital of the country Entered. This Program is not too tough to understand and it is very easy to calculate the tempratur...
true
b1d0c2d7e8f6c4fc80d22f1320b2b320cbfd4288
avaiyang/Linkedlist
/reverse_linkedList.py.py
1,510
4.5625
5
################################################## # Program to create a linked list, and reverse # # it. # # # # # ################################################## class Node(): #initialising the node def __init__(sel...
true
29f3cb269948525c96c9adcca0ccff98f6f932c2
nagibaeva/python-playground
/ch_6_nesting.py
2,564
4.625
5
# Nesting is storgae of multiple dictionraies in a list, or list as a value in a dictionary, or dictionaries in a dictionary. # List of a dictionaries alien_0 = {'color' : 'green', 'points': 5} alien_1 = {'color' : 'yellow', 'points': 10} alien_2 = {'color' : 'red', 'points': 15} aliens = [alien_0, alien_1, alien_2]...
true
f08ac349eea8d91e03a9aa8bc6b716dfba973170
nagibaeva/python-playground
/ch_10_files_5.py
1,093
4.34375
4
# Storing data using JSON module # JSON is JavaScript Object Notation # json.dump() module stores set of data. Two arguments are needed for json.dump() module: piece of data to be stored and a file object where to store the data. import json numbers = [2, 3, 5, 7, 9, 11, 13] filename = 'text_files/numbers.json' wit...
true
9ece5b82fcc4b000c5009d6cc57cafa4640e4f8a
nagibaeva/python-playground
/ch_10_files_2.py
713
4.3125
4
# Writing to the files. # Python can write to txt documents. To do so, use: open(name_of_file, 'w') where w tells python to open the file in witing mode. # more modes: 'r' - read mode, 'w' - write mode, 'a' - append mode, 'r+' - read and write mode filename = 'text_files/programming_1.txt' with open(filename, 'w'...
true
f92826975f3da24c4e8744b676acf19077821944
nagibaeva/python-playground
/7_1_2_3.py
624
4.1875
4
# Ex 7.1 Rental Car car = input("\nEnter what kind of car would you like to try: ") print(f"Let me see if I can find you a {car.title()}.") # Ex 7_2 Restaurant seating seats = input("How many people are attending the dinner?: ") seats = int(seats) if seats > 8: print("Please wait for a bigger table.") else: ...
true
4c97bb70a4c601d6f39b1c68dc86a8c54ff269c1
nagibaeva/python-playground
/restaurant.py
1,673
4.25
4
class Restaurant: """Simple Restaurant description.""" def __init__(self, name, cuisine): """Indicating name and cuisine type.""" self.name = name self.cuisine = cuisine self.number_served = 0 def describe_restaurant(self): """Describe the name and type of cuisine.""...
true
c6fdb14e34d241068894e385d3359346abf67f0b
nagibaeva/python-playground
/ch_8_functions_2.py
1,634
4.28125
4
# Return value of functions: def get_formatted_name(first_name, last_name): """Return a full name, neatly formated""" full_name = f"{first_name} {last_name}" return full_name.title() musician = get_formatted_name('jimi', 'hendrix') print(musician) # Note: you need a variable that return value will be ass...
true
c1490432c3b2fd618fd24aa5d41daa2b50984f78
nagibaeva/python-playground
/ch_7_while_loops.py
1,975
4.34375
4
# While loop will run program until condition to stop is true: current_number = 1 while current_number <=5: print(current_number) current_number += 1 # You can engage user to stop the while loop. prompt = "\nTell me somthing and I will repeat it back to you!" prompt += "\nEnter 'quit' to end the program: " ...
true
a50b42c24b8a00da0c3da5804e28c595e7b4b26d
Jaipal17/mycaptaintask
/jaipal.py
305
4.15625
4
#Radius and Area of circle from math import pi r=float(input("Input the radius of the circle : ")) area=pi*r*r print("The area of the circle with radius 1.1 is:",area) #Filename and Extension fn=input("Input the Filename: ") f=fn.split(".") print("The extension of the file is : "+repr(f[-1]+"thon"))
true
542f61f3bdd96685543b7e767959ccf1e12ef2f3
Solero93/bcn-algorithm-club-py
/special/src/winter_is_coming.py
1,339
4.21875
4
""" /** * 15 points * * * Winter is coming! Your first job during the contest is to design a standard heater with fixed warm radius to warm all the houses. * * * Now, you are given positions of houses and heaters on a horizontal line, find out minimum radius of heaters so that all houses could be covered by thos...
true
a4c0717d442f3f4f9c3506c402fd00bf9512f408
fatpat314/CS1.3
/reversed_ints.py
813
4.28125
4
"""Write a function that will reverse a integer number using a stack and return the reversed number as an integer. For example, if your input number is 3479 the function will return 9743.""" def reverse_string_with_stack(input_int): my_stack = [] reverse_ints = "" input_str = str(input_int) # step 1: p...
true
b3d47b590c2d7dc612e221e47ad2af9e7d82205a
ngezler/Python_basics
/pyIntro.py
2,062
4.375
4
#importing the modules import random import sys import os #variable a place to store a value greetings = "hello World" print(greetings ) #Lists print('test2') Grocery_list = ['juice', 'potatoes', 'rice', 'beans'] print('first Item :', Grocery_list[0]) #test3 change the value of an item in the list Grocery_list[0]...
true
e90c3c46f8e808dbe2f3a51a16f73ca5da2bd1b3
gayatripingale/Practice
/Udacity_Python/#3 Use of LOOP to find sum of list of values in 1 Key-Multiple Values type of dict.py
519
4.28125
4
# This code is to find the sum of all values given in arrey or list format as a value of a key # monthly_takings = {'January': [54, 63]} # to find the total of 'value' in a arry form [54,63] # of a key 'January'. # i.e. the output should be 54 + 63 = 117 monthly_takings = {'January':[54, 63, 75]} total = 0 lengt...
true
aa3e65e24a9a5cb48a879d444646adb5ca50eeed
TimRexJeff/cs-module-project-recursive-sorting
/src/sorting/sorting.py
1,740
4.21875
4
# TO-DO: complete the helper function below to merge 2 sorted arrays def merge(arrA, arrB): elements = len(arrA) + len(arrB) merged_arr = [0] * elements # Your code here left_index = 0 right_index = 0 current_index = 0 while current_index < elements: if left_index < len(arrA) and rig...
true