blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
ee2339b680fadc5f869e3371dfb98513807fcb8f
gasamoma/cracking-code
/Strings/1.4.py
2,415
4.1875
4
#Palindrome Permutation: Given a string, write a function to check if it is a permutation of a palindrome. A palindrome is a word or phrase that is the same forwards and backwards. A permutation is a rearrangement of letters. The palindrome does not need to be limited to just dictionary words #EXAMPLE #Input: Tact Coa ...
true
9454cb7e1942bb081cb24c502bb71ff0d7007edd
PatrickBrennan92/hangman
/word_file_setup.py
516
4.21875
4
# This module was used to write only the basic words to a new file. # It removed all words that contained numbers or other characters. # Also removed any words starting with a capital letter, such as names and # placed etc. words = [] with open("words.txt", "r") as all_words: for word in all_words: if word...
true
aeecd07aeae8eae5ba81a766d8b8b120b2bc2baa
Sajid305/Python-practice
/Source code/Multithreading/Multithreading.py
2,041
4.28125
4
# [1] multitasking # Executing several task simultaneously is the concept of multitasking # The...
true
398300731ca0b213825c12f0227f5fee7f171962
Sajid305/Python-practice
/Source code/so many kind of function , like map,Enumerate,filter etc/any and all function .py
1,877
4.40625
4
# any and all function # finding even number from a list if all of the number # is even then we will print true if one of them are odd then we will return false # i will do it with the help of all function # first with normal way of usi...
true
52a69f0f6abdd0093187519415589e6279960048
Sajid305/Python-practice
/Source code/so many kind of function , like map,Enumerate,filter etc/function_extra_usefull_stuff.py
505
4.28125
4
# Doc string #''' this is doc string '''' def func(a,b): ''' this is a doc string this function use tow argument and return addition of them''' return a+b print(func(1,3)) print(func.__doc__) # ----> this is how we can check our doc string # We can allso see doc...
true
e97c86a58301197e130c6f615853a9491a09c1c2
Sajid305/Python-practice
/Source code/Decoretor/Decorators with arguments .py
916
4.125
4
# Decoretor with argument and nested Decoretor this decoretor will only take string as argument from functools import wraps def only_string_alow(data_type): # ----> this decoretor made for only take str as argument def nested_decoretor(any_function):# ----> this decoretor is for tak...
true
57f29174db1efe288074c09198d9ece7d3bfc950
bhumphris/Word-Jumble
/Word Jumble.py
651
4.15625
4
import random birds = ["Macaw", "Toucan", "Pheasant", "Painted Bunting", "Cardinal", "Crane", "Flamingo", "Parakeet", "Love Bird", "Mallard", "Finch", "Robin", "Dove", "Hawk", "Eagle"] selection = random.choice(birds) answer = selection jumble = list(selection) for current_index in range(len(jumble)): random_index ...
true
ba66d8b9d3be607f5a1d710aafe320fa236c1300
purushottamkaushik/DataStructuresUsingPython
/DyammicProgramming/BricksFilling.py
1,067
4.34375
4
def BrickFilling(n): """ This is Problem which fills N*4 wall with 1*4 bricks this is the recursive solution of the problem :param n is the one dimension of the wall may be width or height :return the number of ways you can put bricks on the wall """ if n==0 or n == 1 or n == 2 or n == 3...
true
c432c895df59851779f957d02f1c9deb77441caa
purushottamkaushik/DataStructuresUsingPython
/ImplementTrieLeetcode208.py
1,809
4.125
4
class Node: def __init__(self,val,isWord=False): self.val = val self.child = {} self.isWord = isWord class Trie: def __init__(self): """ Initialize your data structure here. """ self.root = Node("") def...
true
2244144b6ac2656b94a86bc65919def6364dec81
purushottamkaushik/DataStructuresUsingPython
/ArraysProblem/Python/SelectionSort.py
469
4.125
4
def selectionSort(a): for i in range(len(a)): """Traverse through the whole array""" min_index = i # storing the index as the minimum index for j in range(i+1,len(a)): # from index i + 1 to last if a[j] < a[min_index]: min_index = j a[i] , a[min_index ]...
true
93055cb2e17a911765c8d5851f748d21c6772a98
aclogreco/lpthw
/ex20.py
820
4.25
4
# ex20.py """ Exercise 20 -- Learn Python the Hard Way -- Zed A. Shaw A.C. LoGreco """ from sys import argv # unpack cmd line arguments script, input_file = argv # print out the contents of file f def print_all(f): print f.read() # set file cursor position to the begining of file f def rewind(f): f.seek(0)...
true
2d5710d2e041ed64cc1502c61585800d1b25752f
lunettakim/Project
/turtle_game.py
1,849
4.3125
4
# Turtle game using the package 'turtle' # Import relevant modules import turtle import random import time # Setting up a nice screen for our game screen = turtle.Screen() screen.bgcolor('pink') # Background colour # We want two players and that whoever gets to the other sinde wins. # Player one set up...
true
61c5751ed2815fbbf28de27d166e258c0b06d7ee
Svagtlys/PythonExercises
/PasswordGenerator.py
2,542
4.21875
4
import random import string # Write a password generator in Python. Be creative with how you # generate passwords - strong passwords have a mix of lowercase # letters, uppercase letters, numbers, and symbols. The passwords # should be random, generating a new password every time the user # asks for a new pas...
true
eff41102ff734ac7ca4579b47549adee5ac6114a
Svagtlys/PythonExercises
/Fibonacci.py
649
4.34375
4
# 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 the number of numbers # in the sequence to generate def gen_fib(length, mylist = []): if(len(mylis...
true
77844a8b6a18dd00e1f2dba0cc8f0b4800d0b927
Svagtlys/PythonExercises
/ElementSearch.py
1,148
4.1875
4
# Write a function that takes an ordered list of numbers (a list where # the elements are in order from smallest to largest) and another number. # The function decides whether or not the given number is inside the list # and returns (then prints) an appropriate boolean. # Extras: # Use binary search. def searc...
true
6f3ecd911dec9a1c3b037b361a851a9f7a38a156
Pravin-N/python-scripts
/pro_movefiletype.py
1,619
4.34375
4
#! Python3 # Write a program that walks through a folder tree and searches for files with a certain file extension # (such as .pdf or .jpg). Copy these files from whatever location they are in to a new folder. #import necessary modules to be used. import os, shutil from pathlib import Path # create function that mov...
true
cf86bea9b198d357c9d02c6d99ecbbbde2654a25
susejzepol/Proyectos_python
/Find.divisors.of a.number.py
637
4.25
4
""" Task... Find the number of divisors of a positive integer n. Random tests go up to n = 500000. Examples divisors(4) = 3 # 1, 2, 4 divisors(5) = 2 # 1, 5 divisors(12) = 6 # 1, 2, 3, 4, 6, 12 divisors(30) = 8 # 1, 2, 3, 5, 6, 10, 15, 30 """ def divisors(n): count = 0 for num...
true
666d9427145c035218c161ac7d5a0a31ae26db50
kishanameerali/Coding_Dojo_Python1
/Foo_and_bar.py
753
4.21875
4
#Foo and Bar """ Write a program that prints all the prime numbers and all the perfect squares for all numbers between 100 and 100000. For all numbers between 100 and 100000 test that number for whether it is prime or a perfect square. If it is a prime number print "Foo". If it is a perfect square print "Bar". If it ...
true
ceae7932304264bcb33d200039f44dd1c76daf0e
kishanameerali/Coding_Dojo_Python1
/Checkerboard_2.py
283
4.46875
4
#Checkerboard Assignment using nested for loops #Write a program that prints a 'checkerboard' pattern to the console. for row in range(1,9): for col in range(1,9): if (row % 2 is odd and col % 2 is 0): print " " if (row % 2 is 0 and col % 2 is 0):
true
ee17f742cf9883dde7031e7caa3b2ac50a8969b7
libra202ma/cc150Python
/chap04 Trees and Graphs/4_5.py
1,015
4.15625
4
""" Implement a function to check if a binary tree is binary search tree. - Search. Modified, in-order DFS and keep track of a global variable last_visited. Check if left branch is binary search tree, if false, return false. Check if current data is less or equal to global min, if yes, retrun false. Update the last_vi...
true
12a0da6e4b394d7f570ebded0c4d733c735d32d0
libra202ma/cc150Python
/chap05 Bit Manipulation/5_1.py
984
4.15625
4
""" You are given two 32-bit number, N and M, and two bit positions, i and j. Write a method to insert M into N such that M starts at bit j and ends at bit i. You can assume that the bits j through i have enough space to fit all of M. That is, if M = 10011, you can assume that there are at least 5 bits between j and i....
true
30dd034601cb0942414a7d6d33931bc114d71a82
libra202ma/cc150Python
/chap03 Stacks and Queues/3_5.py
1,134
4.21875
4
""" Implement a MyQueue class which implements a queue using two stacks. - Naive. For every enqueue operation, just enqueue it onto s1. For every dequeue operation, we first pop all nodes from s1 to s2, then pop from s2 to get the oldest element, then pop all nodes from s2 back to s1. - lasy execuation. Again fo...
true
3d2a1ac662fb5fa45415c0d438a8d6b1c91fcda6
libra202ma/cc150Python
/chap03 Stacks and Queues/3_3.py
1,800
4.125
4
""" Imagine a (literal) stack of plates. If the stack gets too high, it might topple. Therefore, in real life, we would likely start a new stack when the previous stack exceeds some threshold. Implement a data structure SetOfStacks that mimics this. SetOfStacks should be composed of several stacks and should create a n...
true
0b65056f2e3025cc5812aa3763c9e6d2fbb9ecd4
libra202ma/cc150Python
/chap09 Recursion and Dynamic Programming/9_09.py
1,138
4.125
4
""" Write an algorithm to print all ways of arranging eight queens on an 8x8 chess board so that none of them share the same row, column or diagonal. In this case, "diagonal" means all diagonals, not just the two that bisect the board. - classic. Firstly, the queens should be on different rows and columns. That is, fo...
true
bc71c13906df3fbef02182d3962078664612d798
HareshSankaliya/HareshPython
/HareshPy/HareshPractice/Datetimeformat.py
539
4.21875
4
from datetime import date from datetime import time from datetime import datetime today=date.today() #today date print(today) print(today.strftime("%Y")) # Print only year with yyyy format print(today.strftime("%y")) # Print only year with yy format print(today.strftime("%a")) # Print today week name print(today.strft...
true
a94cce2fcc9f305be51aa53edd18b54745182aec
dsmilo/DATA602
/hw2.py
2,525
4.1875
4
# Dan Smilowitz DATA 602 hw2 #1. fill in this class # it will need to provide for what happens below in the # main, so you will at least need a constructor that takes the values as (Brand, Price, Safety Rating), # a function called showEvaluation, and an attribute carCount class CarEvaluation: 'A simple clas...
true
98bb48d3f58796ed29294a615af14a314f4c8284
carlgriffin57/python-exercises
/data_types_and_variables.py
2,134
4.21875
4
# You have rented some movies for your kids: The little mermaid (for 3 days), Brother Bear (for 5 days, they # love it), and Hercules (1 day, you don't know yet if they're going to like it). If price for a movie per day # is 3 dollars, how much will you have to pay? num_of_little_mermaid_days = 3 num_of_brother_bear_...
true
a240a672532d266ab35092738f9a51726a4f5b41
DVEC95/PY4E
/Chapter 5 - Iterations/PY4E_L5_Ex1.py
812
4.1875
4
# Exercise 1: # Write a program which repeatedly reads numbers until the user enters “done”. # Once “done” is entered, print out the total, count, and average of the numbers. # If the user enters anything other than a number, detect their mistake using try and except and print an error message and skip to the next n...
true
019feef40b84fc4261d3130d738fc2d44ad64019
DVEC95/PY4E
/Chapter 7 - Files/PY4E_L7_Ex2.py
943
4.3125
4
# Exercise 2: # Write a program to prompt for a file name, and then read through the file and look for lines of the form: # X-DSPAM-Confidence: 0.8475 # When you encounter a line that starts with “X-DSPAM-Confidence:” pull apart the line to extract the floating-point number on the line. # Count these lines an...
true
4d12e59d208e7ddcaf9bf6df41c8f7436a4a3f23
orvindemsy/python-practice
/19.08.16 beginner project/letterCapitalizeVer2.py
769
4.21875
4
''' Written by: Orvin Demsy Date: 17 August 2019 Source: https://coderbyte.com/solution/Letter%20Changes#Python I'm rewriting it to get a better understanding Challenge: Have the function LetterCapitalize(str) take the str parameter being passed and capitalize the first letter of each word. Words will be separated b...
true
ad82ed794489e9e0326d8b6ffddde41c85f871d0
orvindemsy/python-practice
/CodeWars 8kyu Challenges/isItPalindromeVer2.py
353
4.125
4
''' Written by: Orvin Demsy Date: 19 August 2019 Description: Write function isPalindrome that checks if a given string (case insensitive) is a palindrome. Only one-word input is accepted e.g. madam = True Mom = True walter = False ''' def is_palindrome(word): word = word.lower() return word == word[::-1] w...
true
59284127bf0405c4b2e4d14115a38d4e48bcb343
orvindemsy/python-practice
/19.08.16 beginner project/letterChanges.py
1,400
4.34375
4
''' Written by: Orvin Demsy Date: 16 August 2019 Challenge : Have the function LetterChanges(str) take the str parameter being passed and modify it using the following algorithm. Replace every letter in the string with the letter following it in the alphabet (ie. c becomes d, z becomes a). Then capitalize every vowel ...
true
4bc7c98ee2f36bc3bb74268cad48108be82b5f44
orvindemsy/python-practice
/19.08.16 beginner project/reverseString.py
737
4.375
4
''' Written by: Orvin Demsy Date: 16 August 2019 Create a function that takes a string as an argument and spit out that string in reverse e.g: hello -> olleh ''' #The first method extended slice syntax def reverse_word_1(word): return word[::-1] #Return olleH print("The reversed input is = " + reverse_word_1(in...
true
3552eb59106c8bcf07113cd7d23c516e179b55b7
muradsamadov/python_learning
/python_exercises_practice_solution/python_basic/part_25.py
238
4.25
4
# Write a Python program to concatenate all elements in a list into a string and return it. def function(list): result = "" for i in list: result = result + str(i) return result print(function([1, 5, 12, 2]))
true
92907bac9ec611f8f5550bfa200d6c9b11d093d7
muradsamadov/python_learning
/python_exercises_practice_solution/python_modules/module_random/part_4.py
927
4.53125
5
# Write a Python program to generate a random integer between 0 and 6 - excluding 6, random integer between 5 and 10 - excluding 10, random integer between 0 and 10, with a step of 3 and random date between two dates. Use random.randrange() import random import datetime print("Generate a random integer between 0 and 6...
true
fdc453807fbadc53426aa1ec020cd68e8253067f
Stefanos1312/Hello-World
/task 1 section 3.py
384
4.25
4
print ("This program will add 2 different numbers and will find the results") #define numbers as integer number1 = int(input("please enter the first number")) number2 = int(input("please enter the second number")) print ("thank you") #now I will define the results by just adding '+' the numbers together result = ...
true
97bd113620df5f0f1b70d6be454811cfe743f0ce
SakshiBheda/Apni_Dictionary
/apni_dictionary.py
457
4.125
4
print("This is My own Dictionary : 'Apni Dictionary'") print("key ,"" book "", comb "" ,mouse "" , joey ") dic1={"key":"something which unlocks a lock", "book":"a compiled set of pages which describes a certain topic", "comb":"a plastic item to set hairs", "mouse":"an animal which is afraid of ca...
true
993fd1bcd8d453af376f78ad4357e32e3f38800a
DianaLuca/Algorithms
/Leetcode_WeeklyContests/contest_49/ImplementMagicDictionary676.py
1,964
4.125
4
""" Implement a magic directory with buildDict, and search methods. For the method buildDict, you'll be given a list of non-repetitive words to build a dictionary. For the method search, you'll be given a word, and judge whether if you modify exactly one character into another character in this word, the modified word ...
true
5efa072bc226c13308ed74407f0e6c86fcd4c72e
DianaLuca/Algorithms
/Leetcode_WeeklyContests/contest_60/AsteroidCollision735.py
1,306
4.1875
4
""" We are given an array asteroids of integers representing asteroids in a row. For each asteroid, the absolute value represents its size, and the sign represents its direction (positive meaning right, negative meaning left). Each asteroid moves at the same speed. Find out the state of the asteroids after all collisi...
true
70b56e0356fa654b58a288e4de9c01e85d5e6d04
narendra-manchala/GFG-DSA
/bitwise algorithms/power_of_2.py
518
4.53125
5
def power_of_2(n): """Find if the number is power of 2 or not. Arguments: n {int} -- The number to find if it is power of 2 or not. Explanation: 1. In binary a power of 2 has only one 1. So doing a bitwise-and with n-1 will give us 0 if it is power of 2. eg: n =...
true
e9e9b78d7898e71dd2a62962bcde4a206bf13d74
rwisecar/scrabble_cheat
/scrabble.py
1,687
4.15625
4
""" This is a simple python script to take a Scrabble rack of 7 letters and return all possible word iterations, with the associated scores.""" import re # Dictionary of letters and values scores = { "a": 1, "c": 3, "b": 3, "e": 1, "d": 2, "g": 2, "f": 4, "i": 1, "h": 4, "k": 5...
true
3d1d244bef39869f8192536a369f6124ff594960
ciaranmccormick/advent-of-code-2019
/2/main.py
2,303
4.15625
4
#! /bin/env python3 from argparse import ArgumentParser, Namespace from typing import List, Tuple from computer import Computer STOP = 99 ADD = 1 MULTIPLY = 2 def load_instructions(filename: str) -> List[int]: """Read in a list of comma separated integers""" with open(filename, "r") as f: codes = f....
true
af45aee1ab6efe5194766784c94439a4c201852f
JaimePazLopes/dailyCodingProblem
/problem086.py
1,561
4.21875
4
# Problem #86 # Given a string of parentheses, write a function to compute the minimum number of parentheses to be removed to make # the string valid (i.e. each open parenthesis is eventually closed). # # For example, given the string "()())()", you should return 1. Given the string ")(", you should return 2, since...
true
8c12755934693f84fe28b32352fb780bd773d622
JaimePazLopes/dailyCodingProblem
/problem034.py
2,217
4.25
4
# Problem #34 [Medium] # Given a string, find the palindrome that can be made by inserting the fewest number of characters as possible # anywhere in the word. If there is more than one palindrome of minimum length that can be made, return the # lexicographically earliest one (the first one alphabetically). # # For...
true
c43cc3f44200da29beaf525c92f11ade48fbe515
JaimePazLopes/dailyCodingProblem
/problem046.py
1,091
4.15625
4
# Problem #46 [Hard] # Given a string, find the longest palindromic contiguous substring. # If there are more than one with the maximum length, return any one. # # For example, the longest palindromic substring of "aabcdcb" is "bcdcb". # The longest palindromic substring of "bananas" is "anana". def longest...
true
3bd671741d9d5a5f079fcaae9b2a900885912df9
JaimePazLopes/dailyCodingProblem
/problem109.py
814
4.125
4
# Problem #109 # # Given an unsigned 8-bit integer, swap its even and odd bits. The 1st and 2nd bit should be swapped, the 3rd and 4th # bit should be swapped, and so on. # # For example, 10101010 should be 01010101. 11100010 should be 11010001. # # Bonus: Can you do this in one line? def swap_bits(x): ...
true
5915005ff5af0c7f85f45d9e80eac07f5d6d32cf
JaimePazLopes/dailyCodingProblem
/problem033.py
2,805
4.3125
4
# Problem #33 [Easy] # # Compute the running median of a sequence of numbers. That is, given a stream of numbers, # print out the median of the list so far on each new element. # # Recall that the median of an even-numbered list is the average of the two middle numbers. # # For example, given the sequence [2, 1,...
true
4919f1c45cb054ba3bab2a99ced47bed8105db1d
bryanyaggi/Coursera-Algorithms
/course1/pa1.py
2,533
4.3125
4
#!/usr/bin/env python3 ''' Programming Assignment 1 In this programming assignment you will implement one or more of the integer multiplication algorithms described in lecture. To get the most out of this assignment, your program should restrict itself to multiplying only pairs of single-digit numbers. You can imple...
true
c6ea854dc477ae6d5c0b5cbf226f8f71f1cfbb2a
ximuwang/Python_Crash_Course
/Chap9_Classes/Practice/Restaurant.py
1,288
4.125
4
# A module named restaurant class Restaurant(): '''A class representing a restaurant''' def __init__(self, name, cuisine_type): '''Initialize the restaurant''' self.name = name self.cuisine_type = cuisine_type self.number_served = 0 def describe_restaurant(self): ...
true
daa35e217038a987d89248fa3de548c77ac61e5a
Someshwaran/Python-Basics
/employee_dataSaver.py
2,069
4.5
4
from employee import Employee class employee_data_saver: # to store the all employee objects employee_data = [] def __init__(self): self.employee_d = Employee() # this method for read and store the data for a employee def getting_values(self): self.emp...
true
65c95e58fb3cdaa31db7ab4ec6626378a376c8b0
K-Ellis/airline_seating_assignment
/Rough work folder/kron_sql_test_file.py
2,225
4.15625
4
import sqlite3 #Connect to the database using sqlite2's .connect() method which returns a #connection object conn = sqlite3.connect("airline_seating_test.db") #From the connection we get a cursor object cur = conn.cursor() #create a database with different name, dimensin, col letters def create_db(rows, col_letters):...
true
660abd61196b475b705ea4c63e4f5fef0a5b23df
golkedj/Complete_Python_Masterclass
/ProgramFlowChallenge/challenge.py
2,311
4.46875
4
# Create a program that takes an IP address entered at the keyboard # and prints out the number of segments it contains, and the length of each segment. # # An IP address consists of 4 numbers, separated from each other with a full stop. But # your program should just count however many are entered # Examples of the in...
true
0dd7705fb79d54f3343b7fe77c4c267e49e58ca5
DKCisco/Starting_Out_W_Python
/2_7.py
592
4.34375
4
""" 7. Miles-per-Gallon A car's miles-per-gallon (MPG) can be calculated with the following formula: MPG 5 Miles driven 4 Gallons of gas used Write a program that asks the user for the number of miles driven and the gallons of gas used. It should calculate the car's MPG and display the result. """ # Receive ...
true
264997cbfa001842a434411ed7743781afdc7a93
DKCisco/Starting_Out_W_Python
/3_1PE.py
502
4.3125
4
""" Write a program that asks the user to enter an integer. The program should display “Positive” if the number is greater than 0, “Negative” if the number is less than 0, and “Zero” if the number is equal to 0. The program should then display “Even” if the number is even, and “Odd” if the number is odd. """ ...
true
d0e5ab73ec31f809d5db4c820fb91835abe86424
DKCisco/Starting_Out_W_Python
/average_rainfall.py
1,324
4.4375
4
""" 5. Average Rainfall Write a program that uses nested loops to collect data and calculate the average rainfall over a period of years. The program should first ask for the number of years. The outer loop will iterate once for each year. The inner loop will iterate twelve times, once for each month. Each itera...
true
e0f5e232bfc86a8b66c68aa464ecf980c02c6740
DKCisco/Starting_Out_W_Python
/test_average.py
728
4.25
4
""" This program calculates the average of 3 test scores using decision structure. """ # Assign varibale to score above 95% average. HIGH_AVERAGE = 95 # Get the test scores from user. test1 = int(input('Enter the score for test 1: ' )) test2 = int(input('Enter the score for test 2: ' )) test3 = int(input(...
true
1b304e5f6ae0a2c208377a15b31189ae990c09e1
fizzywonda/CodingInterview
/Recursion&Dynamic Program/RecursiveMultiply.py
1,549
4.5
4
""" Recursive Multiply: Write a recursive function to multiply two positive integers without using the *operator.You can use addition, subtraction, and bit shifting, but you should minimize the number of those operations. """ """Brute force Approach""" def multiply(x, y): if y == 0: return 0 result = x ...
true
26e3c6573df720de85538db9c86d0f24d469b13a
fizzywonda/CodingInterview
/Recursion&Dynamic Program/RobotInGrid.py
1,727
4.46875
4
""" Robot in a Grid: Imagine a robot sitting on the upper left corner of grid with r rows and c columns. The robot can only move in two directions, right and down, but certain cells are "off limits" such that the robot cannot step on them. Design an algorithm to find a path for the robot from the top left to the bottom...
true
837a1620e23665aa6492269ae6da3ee8ec530b16
YoungsAppWorkshop/codewars
/r1/day12_counting_duplicates.py
1,531
4.28125
4
#!/usr/bin/env python3 """ Counting Duplicates - 6 kyu Write a function that will return the count of distinct case-insensitive alphabetic characters and numeric digits that occur more than once in the input string. The input string can be assumed to contain only alphabets ...
true
bff80bbce617c38683818404de6303502ad9dfc5
YoungsAppWorkshop/codewars
/r1/day19_detect_pangram.py
870
4.15625
4
#!/usr/bin/env python3 """ Detect Pangram A pangram is a sentence that contains every single letter of the alphabet at least once. For example, the sentence "The quick brown fox jumps over the lazy dog" is a pangram, because it uses the letters A-Z at least once (case is irrelevant). Given a ...
true
1f0aeec8258dfc8157c34ac91b8f27b20f28df0f
YoungsAppWorkshop/codewars
/r1/day28_pyramid_slide_down.py
2,081
4.53125
5
#!/usr/bin/env python3 """ Pyramid Slide Down Pyramids are amazing! Both in architectural and mathematical sense. If you have a computer, you can mess with pyramids even if you are not in Egypt at the time. For example, let's consider the following problem. Imagine that you have a plane pyramid bu...
true
ea62b2be949b188490713b11c43b9f0eeada73f7
Limitlessmatrix/automation_scripts
/list_comprehensions.py
2,236
4.375
4
#deriving one list to another using comprehension to shorten filtering or mapping a = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] squares = [x**2 for x in a] print(squares) #try writing as a function:::: #def squares(numbers_squared): # squaring = [x**2 for x in a] # return print(squaring) #visually nosiy example::::::::::...
true
e64cedf7e615f119c03b35944d462a182e4eda4d
ngirmachew/my_codes_on_sololearn
/GPA_calculator_2020_05_12.py
700
4.28125
4
grade_scale = {'A': 4.0, 'A-':3.7, 'B+':3.3, 'B':3.0, 'B-':2.7, 'C+':2.3, 'C':2.0, 'C-':1.7, 'D':1.3, 'D-':0.7,'F':0} print(f'This program computes your GPA \nPlease enter your completed courses \nTerminate your entry by entering 0 credits') allcredit = [] allgrades = [] while True: credit = int(input('Credits?:' ...
true
beec15fef21dd80eb11ebb2710b60f8f826562ca
vinamrathakv/pythonCodesMS
/TurtleTwoCircle.py
2,064
4.4375
4
# display if circles overlap or not using turtle import turtle import math # get user input for both the circls' co-ordinates and radii x1, y1, r1 = eval(input("Enter the x co-ordinate, y co-ordinate and radius of circle 1 : ")) x2, y2, r2 = eval(input("Enter the x co-ordinate, y co-ordinate and radius of c...
true
2ec5653b1eec72cf5393a979cee5992d3ecb796e
vinamrathakv/pythonCodesMS
/AreaOfTriangle2_14.py
802
4.34375
4
# Calculate area of a triangle given 3 vertices x1, y1 = eval(input("Enter first point of the triangle : ")) x2, y2 = eval(input("Enter second point of the triangle : ")) x3, y3 = eval(input("Enter third point of the triangle : ")) side_1 = ((x1-x2)**2 + (y1-y2)**2)**0.5 side_2 = ((x2-x3)**2 + (y2-y3)**2)**0.5...
true
94ae0cc5d1e9490f5f1a6f8ca09b087c023e5ec5
vinamrathakv/pythonCodesMS
/LongestCommonPrefix8_13.py
419
4.125
4
# find longest common prefix between two stringStart def prefix(s1, s2): p = '' for c in s1: p += c if s2.startswith(p): continue else: return p[0:len(p)-1] def main(): s1 = input("String 1 : ") s2 = input("string 2 : ") ...
true
209439c405be2e7ca51d764037183b8916e2fcae
vinamrathakv/pythonCodesMS
/PalindromicPrime6_24.py
1,670
4.15625
4
#check if entered integer is palindromic prime #check if input is prime def isPrime(number): divisor = 2 while divisor <= number / 2: if number % divisor == 0: # If true, number is not prime return False # number is not a prime divisor += 1 return True...
true
625b8778c2ab8b0de731d6fdf6acb49e97a34570
DomenOslaj/step-counter
/main.py
392
4.34375
4
# Create a function that will calculate the number of steps that you # make for a certain distance. def calculate_steps(distance, step_length): steps = int(distance/step_length) print("Number of steps: {0}".format(steps)) distance_m = int(input("Enter a distance in meters: ")) step_length_m = int(input("Ent...
true
9833a362eaee6c6e998d7be088f6baabae1cf4ea
gutiantian123Abc/algorithm-py
/DFS/Matrix_Water_Injection.py
1,972
4.125
4
""" 1410. Matrix Water Injection Given a two-dimensional matrix, the value of each grid represents the height of the terrain. The flow of water will only flow up, down, right and left, and it must flow from the high ground to the low ground. As the matrix is surrounded by water, it is now filled with water from (R,C)...
true
64d39c5d6ffac35f897299a02a128eaf862941bf
bopopescu/SQL-Pthon
/tests/span1.py
1,515
4.1875
4
# the from is the name of th efile with the class definition and import the name of the class from span import Student # we make a instance of the class while also passing arguments to use the init method and assigning values student1 = Student("Jim", "Business", 2.1, False) student2 = Student student2.name = "Pam" p...
true
978dd023fbfe18346c98a3e25b1ade8b80b2134d
Gaydarenko/PY-111
/Tasks/d0_stairway.py
1,397
4.34375
4
from typing import Union, Sequence def stairway_path(stairway: Sequence[Union[float, int]]) -> Union[float, int]: """ Calculate min cost of getting to the top of stairway if agent can go on next or through one step. :param stairway: list of ints, where each int is a cost of appropriate step :return: ...
true
91070b64174970d708ec237ab85415979062f749
Parth-Bhavsar-98/Python-for-Everybody-Coursera-
/Course-1 Programming for Everybody (Getting Started with Python)/Week 6/Assignment_1.py
922
4.34375
4
#Write a program to prompt the user for hours and rate per hour using input to compute gross pay. #Pay should be the normal rate for hours up to 40 and time-and-a-half for the hourly rate for all hours worked above 40 hours. #Put the logic to do the computation of pay in a function called computepay() and use the f...
true
1191edc1718f6c98b55cdcfd5eaedb1f43093436
Parth-Bhavsar-98/Python-for-Everybody-Coursera-
/Course-1 Programming for Everybody (Getting Started with Python)/Week 4/Assignment_1.py
216
4.21875
4
#Write a program that uses input to prompt a user for their name and then welcomes them. # Enter your name as Input and welcome youself to teh world of Python name = input("Enter your name") print("Hello", name)
true
1302bdc4e059ab4eb2c35593b888e4a01e6e234a
AndreeaNenciuCrasi/Programming-Basics-Exercises
/Second SI week/dimensional_ex7.py
624
4.1875
4
# Create a list a which contains three tuples. The first tuple should contain a single element, the second two elements # and the third three elements. # Print the second element of the second element of a. # Create a list b which contains four lists, each of which contains four elements. # Print the last two elements ...
true
8954f3be1e7af3a3814cb3f53a96a3c32f1d37f7
AndreeaNenciuCrasi/Programming-Basics-Exercises
/Second SI week/function_ex4.py
1,524
4.375
4
import math # Write a function called calculator. It should take the following parameters: two numbers, an arithmetic operation # (which can be addition, subtraction, multiplication or division and is addition by default), and an output format # (which can be integer or floating point, and is floating point by default)...
true
73d57d9579fd819f1f485b02e935e8e4208bc1e3
VVVictini/Calculator
/main.py
2,406
4.125
4
import time import sys def main(): def add(x,y): return x+y def subtract(x,y): return x-y def multiply(x,y): return x*y def divide(x,y): return x/y def delay_print(s): for c in s: sys.stdout.write(c) sys.stdout.flush() time.sleep(0.05) ...
true
1726b8c5772153e4cfc7fa62fae6921c4d1ac9cd
megangodwin/cp1404practicals
/prac5/string_occurances.py
236
4.25
4
""" CP1404/CP5632 Practical Counts the occurrences of words in a string """ string_to_evaluate = input("Text :") string_dict = {} string_dict = string_to_evaluate.split() for item in string_dict: item in print(string_list)
true
2d4230d06a2b5ec17f0c3efea8a79c3129fcaa3d
FilipLe/DailyInterviewPro-Unsolved
/Convert to Hexadecimal (SOLVED)/dec_to_hex.py
1,411
4.25
4
import math #Examples step by step converting to Hex #Example 1: 1365 to hex #1365 ÷ 16 = 85 R 5 --> 5 # 85 ÷ 16 = 5 R 5 --> 5 # 5 --> 5 #--> Hex value: 555 #Example 2: 1237 #1237 ÷ 16 = 77 R 5 --> 5 # 77 ÷ 16 = 4 R 13 --> 13 = D --> D # 4 --> 4 #-->Hex Value: 4D5 def to_hex(n): hexVal = '' ...
true
8c5bf3e6d5d7cd8ce823d8d2d2204a49c98f120d
FilipLe/DailyInterviewPro-Unsolved
/Palindrome Integers (SOLVED)/checkPalindrome.py
939
4.125
4
import math def is_palindrome(n): # Fill this in. #Convert num into string stringVal = str(n) #Store the digits in a list arr = [] #Loop through the digits and append them into the list arr[] for digits in stringVal: arr.append(digits) #Number of the digits ...
true
37e896be8e1aaaa16be19ba3b122bb8c0dacc84f
FilipLe/DailyInterviewPro-Unsolved
/Intersection of Lists (SOLVED)/listIntersection.py
477
4.34375
4
def intersection(list1, list2, list3): # Fill this in. #Array to store intersections arr = [] #Iterate through all the elements in list1 for i in list1: #Logic Gate AND #-->Both conditions have to be met in order to execute #-->Add element ONLY if it's in both list2...
true
bba97d7fe44664aa78c96693003aa168d589a5e9
deesnow/PrincipleOfComputing
/HW1_q9/py.py
416
4.28125
4
def appendsums(lst): """ Repeatedly append the sum of the current last three elements of lst to lst. """ for i in range(25): new_value = lst[len(lst)-1] + lst[len(lst)-2] + lst[len(lst)-3] lst.append(new_value) print lst return lst ...
true
1f0d67b96fb3d80015d44aac2fe07263382df42b
jupa005/Guessing_games.py
/Program guesses your number.py
684
4.125
4
from random import * print('HELLO! WELCOME TO GUESSING GAME!') print('Imagine one number 1-100 and i will try to guess it') print('If your number is lower than my guess, press 1') print('If your number is higher than my guess, press 2') print('If I hit your number, press 3') mini=1 maks=100 av=50 guess=0 c=ra...
true
99874d7fe26a1d3fe66e812fc4b4a47ac88d1675
Suyash906/Design-2
/232_Implement_Queue_using_Stacks.py
1,944
4.15625
4
# Time Complexity : # push: O(n) # pop: O(1) # top: O(1) # empty: O(1) # # Space Complexity : O(n) [n is the number of elements inserted into Stack] # # Did this code successfully run on Leetcode : Yes # # Any problem you faced while coding this : No # # Problem Approach # 1. Two stack(main_stack an...
true
d61e5149effa07c69f1160d8e3634e5a2c18833b
felipecpassos/Rat-Escape-AI-Pathfinding
/priority_queue.py
1,001
4.125
4
# Modified implementation of PriorityQueue using tuple as value class PriorityQueue(object): def __init__(self): self.queue = [] def __str__(self): return ' '.join([str(i) for i in self.queue]) # for checking if the queue is empty def isEmpty(self): return len(self.queue) =...
true
e80e5097cf98b0be5a2ca0ecacad47947a48b9f0
aishahanif666/Python_practice
/Rock, paper, scissor(game).py
1,601
4.21875
4
#Rock, paper, Scissor game import random comp = 0 user = 0 comp_list=["Rock","Paper","Scissors"] while True: user_choice=input('Enter "R" for Rock, "P" for Paper and "S" for Scissor: ') comp_choice = random.choice(comp_list) print("Computer's Choice:",comp_choice) if user_choice=="R" and comp_c...
true
61a9a7c6c08c348944c2b6083850467c8928fb3f
lopezz/py-scripts
/random-passwd/generate_pass.py
1,306
4.1875
4
""" Generate a random password based of the lenght specified optional arguments can be passed to specify the use of different sets of characters. """ import random import string def generate_pass(lenght=8, lower=True, upper=True, digits=True, special=True): """Returns a random password based of the lenght specifie...
true
b6c9f122f81180bb9a62791e53646b6108c30244
geangohn/nlp_projects
/dish_tagging/src/data_cleansing.py
2,015
4.34375
4
import pandas as pd import numpy as np def clean(df): """Cleans the dataset""" # Drop dishes that does not have product name df = df[~df['product_name'].isna()] print('taking into account only dishes with product names: {}'.format(df.shape[0])) # Drop dishes without ingredients information ...
true
1cc66a9deff9e35be0a13c6e87ba38d3fc2d12f7
Azfarbakht/Python-Games
/9. Eat Food Game/Eat Food Game.py
2,568
4.15625
4
#We have learnt so much about so far. We have seen what variables are and how we can store data in them. We have seen how we can reduce the lines in our code by writing loops and automating different parts of our project. Exlored conditionals. We have even learnt how to make a game. #Importing Libraries import turtle ...
true
a7f7a27d99de535050d1a3d59e9b4c0df27f2678
nishantsingh01/Python
/Ques4.py
253
4.1875
4
print("Enter a No. greater than or equal to 10:") num = int(input()) if num >= 10: _set = set() while num != 0: _set.add(num%10) num = int(num/10) print("Set: ", _set) else: print("Sorry! Number is less than 10")
true
95f45218766ef02750cead71ef1e8164c10e5a4c
Avani18/Algorithms
/Sorting/MergeSort.py
1,572
4.40625
4
#Merge Sort- Split array into half and recursively split both the halves till 1 element is left and then they are merged in order #Function for Merge Sort def mergeSort(arr): #If length of array is greater than 1 if (len(arr) > 1): #Index of mid element mid = len(arr) // 2 #Left half of array left = arr[:m...
true
1c003c1f5f7e3b4aa4d013bdf084c469fb258621
JacksonMorton/Advanced_Python_at_NYU
/Session_1/homework_1_4.py
2,388
4.53125
5
#!/usr/bin/env python """ Advanced Python @ NYU w/ David Blaikie homework_1_4.py (Extra Credit) Write the classic "number guessing" program in which you think of a number and the computer program attempts to guess it. See suggested output for behavioral details. """ from sys import argv from sys import exit print '...
true
d00984ccc4161ea9d4e4af07905a5980d419bf3a
Er-Divya/PythonBegins
/ReadingaFile.py
563
4.28125
4
# This code will demonstrate how to read files in python emp_file = open("employee_file_read.txt", "r") # Check if the file is readable or not print(emp_file.readable()) # Read first line. Once this command run cursor be on second line and we can read that by writing same command. line = emp_file.readline() print(l...
true
63f2b572930b83c406247bcd1520a53d451b7a99
Er-Divya/PythonBegins
/UnPacking.py
376
4.4375
4
# UnPacking items = [1, 2, 3, 4, 5, 6, 7] print(items) # Below code will unpack first element of list in a and rest will be ignored. a, _ = [3, 4] print(a) # First two elements of the list will be unpacked and stored in x and y. Rest all will be stored in z x, y, *z = [10, 11, 12, 13, 14, 15, 16, 17, 18] print("Prin...
true
802cfb9696a785d97501de97edfabbcb14f2fdd8
bhumip214/Data-Structures
/heap/max_heap.py
2,932
4.21875
4
class Heap: def __init__(self): self.storage = [] # adds the input value into the heap; this method should ensure that the inserted value is in the correct spot in the heap def insert(self, value): self.storage.append(value) self._bubble_up(len(self.storage) - 1) # removes and returns the 'topmost...
true
c53fcea372864928e8396f5261d2e7d868cfb460
Rings-Of-Neptune/Python-Project-Repository
/IT-140 3.12 Lab.py
894
4.15625
4
input_month = input() input_day = int(input()) valid_dates = {"January":31, "February":28, "March":31, "April":30, "May":31, "June":30, "July":31, "August":31, "September":30, "October":31, "November":30, "December":31} if (input_month in valid_dates) and (0 < input_day <= valid_dates[input_month]): if ((input_mo...
true
70ded82c64ecbaf715229a60c11a2de5daa8ed0b
DannyMeister177/CEBD-1160-PyCharm
/pandas-notebook/pandas-homework-advanced.py
2,691
4.40625
4
import pandas as pd # 2. Load the insurance.csv in a DataFrame using pandas. Explore the dataset using functions like to_string(), columns, # index, dtypes, shape, info() and describe(). Use this DataFrame for the following exercises. df = pd.read_csv('winter2020-code/4-python-advanced-notebook/data/insurance.csv', he...
true
4dfb659cfb4fada710bbe1f21f910247fb0a1b0e
egolodnikov/qa_projects
/exceptions/exceptions.py
1,365
4.375
4
""" # Syntax error example: print(15/5)) """ """ # ZeroDivisionError example: print(15 / 0) """ """ # Example custom ValueError: name = input("Enter your name: ") age = int(input("Enter your age: ")) print("Your name is: " + name) if age < 18: raise ValueError("Error: you need to be over 18") else: print("Yo...
true
9c11afa8ca1f9cffa53b812396d6dcddb1ed03fa
M4cs/python-ds
/algorithms/sorting/bubble_sort.py
343
4.25
4
''' Bubble Sort worst time complexity occurs when array is reverse sorted - O(n^2) Best time scenario is when array is already sorted - O(n) ''' def bubbleSort(array): n = len(array) for i in range(n): for j in range(0, n-i-1): if array[j] > array[j+1]: array[j], array[j+1]...
true
d1270d8e71fa26d016c3097167efb2a1c626ea16
C1ickz/NNfS
/p03-Dot-Product.py
837
4.125
4
""" 1D Array = Vector 2D Array = Matrix - Array of vectors 3D Array = Tensor A tensor is an object that can be represented as an array, not just an array. """ import numpy as np inputs = [4, 5, 6, 7] weights = [[0.1, 0.3, -0.5, 0.402], [0.584, 0.102, -0.808, 0.404], [0.27, 0.53, -0.511, 0.22]]...
true
97d65f9db793caf625f081442d7b5365230dfd6f
Gangadharbhuvan/31-Day-Leetcode-May-Challenge
/Day-16_Odd_Even_Linked_List.py
1,384
4.125
4
''' Given a singly linked list, group all odd nodes together followed by the even nodes. Please note here we are talking about the node number and not the value in the nodes. You should try to do it in place. The program should run in O(1) space complexity and O(nodes) time complexity. Example 1: Input: 1->2-...
true