blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
94429272ebae1933b44b59643dc92008b43576be
Gangadharbhuvan/31-Day-Leetcode-May-Challenge
/Day-14_Implement_a_trie.py
1,768
4.40625
4
''' Implement a trie with insert, search, and startsWith methods. Example: Trie trie = new Trie(); trie.insert("apple"); trie.search("apple"); // returns true trie.search("app"); // returns false trie.startsWith("app"); // returns true trie.insert("app"); trie.search("app"); // returns t...
true
d7d62cbaf2e5de9069c544030619bf7120fa1073
18-2-SKKU-OSS/2018-2-OSS-E5
/Maths/find_hcf.py
651
4.3125
4
# Program to find the HCF of two Numbers def find_hcf(num_1, num_2): if num_1 == 0: #exception case return num_2 if num_2 == 0: #exception case return num_1 # Base Case if num_1 == num_2: #if two numbers are equal return num_1 if num_1 > num_2: #if num1 is larger than num2, r...
true
c787c1170025b7371e6cbb7c2f8246f9c297aebc
s3wasser/List-Organization
/mergeSory.py
1,188
4.3125
4
''' Author: Sabrina Wasserman Date: December 1, 2015 Title: mergeSort Purpose: to run merge sort on these algorithms ''' num_array = list() elements = raw_input("Please enter the number of elements in your array:") print 'Enter each element of your array, followed by "enter"' for i in range(int(elements)): n = raw...
true
ecc24982c3a3e97fd79d2b006f5cea39de434ce0
darothub/Pythonprog
/caesar.py
1,013
4.1875
4
from sys import argv def caesar(): key = argv[1] plaintext = input("plaintext: ") length = len(plaintext) for x in range(length): letter = plaintext[x] convert = ord(letter) word = '' if (convert >= 65 and convert < 90): convert = convert + int(key...
true
084e970f2b49e77293304980a5e4f077417d0022
iishchenko/PythonCoursesExercises
/130.py
847
4.34375
4
#The Collatz conjecture describes a sequence: starting with a positive number, if the number if even, halve it. If the number is odd, triple it and and add 1. Repeat. This sequence will always eventually reach 1, and should then stop. For example, if we started with 17: #17 β†’ 52 β†’ 26 β†’ 13 β†’ 40 β†’ 20 β†’ 10 β†’ 5 β†’ 16 β†’ 8 β†’...
true
bf02ea2fbda8767acd68af9a52b3114f07a76fac
iishchenko/PythonCoursesExercises
/47.py
1,743
4.375
4
#Imagine you're writing the software for an inventory system for #a store. Part of the software needs to check to see if inputted #product codes are valid. # #A product code is valid if all of the following conditions are #true: # # - The length of the product code is a multiple of 4. It could # be 4, 8, 12, 16, 20, ...
true
e8bf31247e2f545878208826e9bf3b98808100aa
nikhithagoli/basic
/cspp1-practice/m6/p3/digit_product.py
804
4.15625
4
''' Given a number int_input, find the product of all the digits example: input: 123 output: 6 ''' def main(): ''' Read any number from the input, store it in variable int_input. ''' int_input = int(input()) if int_input == 0: print("0") elif int_input < 0: int_input = -int_inp...
true
e99a9a3144136fee9878c309c87e701f942d5af4
gyam28/CodeChallengePython
/song.py
1,538
4.3125
4
""" 6. SONG CHALLENGE: A playlist is considered a repeating playlist if any of the songs contain a reference to a previous song in the playlist. Otherwise, the playlist will end with the last song which points to None. Implement a function is_repeating_playlist that returns true if a playlist is repeating or false if...
true
5acb4977f0ec3bc33f39573ea81f97cae5d60824
aaron-sc/CSCI-100
/exact__change.py
1,327
4.21875
4
# Dicts to hold val of each type of change change = {"dollar" : 100, "quarter" : 25, "dime" : 10, "nickel" : 5, "penny" : 1} # User's change amount_of_change = {"dollar" : 0, "quarter" : 0, "dime" : 0, "nickel" : 0, "penny" : 0} # Total change amount_to_convert = int(input()) # No change if(amount_to_convert <= 0): ...
true
292882535f5e10142e1a43bad2a346054c03a2e1
Zhu-Justin/ZGEN
/rna.py
2,001
4.1875
4
# Functions for RNA data def isRNANucleotide(letter): """Determines if letter is an RNA nucleotide""" if letter == 'A' or letter == 'C' or letter == 'G' or letter == 'U': return True return False def RNAparser(text): """Parses text to create valid RNA sequence""" upper_text = text.upper(...
true
1bd659bd6857ed0d8cef37a69f476f1594fb3caf
calvinshalim/BINUSIAN-2023
/Functions/function2.py
552
4.125
4
# Palindrome checking str_tocheck = input("Enter your string: ") def ispalindrome(input_str): return (input_str == input_str[::-1]) print (ispalindrome(str_tocheck)) # Task 1: Create a function to return a reversed string (e.g Input: asda; Output: adsa) # Task 2: Create a function to print the total of even num...
true
beae4c6c0adbe39d88098921978517b619bba1b8
JustinAnthonyB/Python
/wk3/f6.py
471
4.25
4
""" Ask the user to enter a password that is 8 characters or long Using an if statement, output whether text meets requirement Input from user? 1: no, default = text outputs(s): message of whether text meets requirement data structures / sanitation: no. not really """ default = input("Ente...
true
ef90ca1a04d285a87bace03a4ab4e09aa66e1ac6
JustinAnthonyB/Python
/Feb2020/words.py
484
4.75
5
# Python3 code to demonstrate # to extract words from string # using regex( findall() ) import re x = re.findall(r'\w',) # # initializing string # test_string = "Geeksforgeeks, is best @# Computer Science Portal.!!!" # # printing original string # print ("The original string is : " + test_string) # # using r...
true
b4f485fef096563349f4142d3638530f1001420d
prasadghagare/learning
/ex1/module2.py
1,780
4.28125
4
#lets make a list #they are really arrays #https://docs.python.org/2/faq/design.html#how-are-lists-implemented num = [23,41,73,37,81,12] #check its type on your system #access O(1) print "index 2 = ", num[2] #slice it print "slicing operation again gives a list : ", num[3:6] #print following line for me using str...
true
e8a5c68aab1b4c939050f824934dbdf7aa7a3c5c
stacygo/2021-01_UCD-SCinDAE-EXS
/05_Working-with-Dates-and-Times-in-Python/05_ex_1-10.py
376
4.375
4
# Exercise 1-10: Representing dates in different ways # Import date from datetime import date # Create a date object andrew = date(1992, 8, 26) # Print the date in the format 'YYYY-MM' print(andrew.strftime("%Y-%m")) # Print the date in the format 'MONTH (YYYY)' print(andrew.strftime("%B (%Y)")) # Print the date i...
true
f3bb55326b5038f9df244ef148441ed559fc0389
stacygo/2021-01_UCD-SCinDAE-EXS
/02_Python-Data-Science-Toolbox-2/02_ex-1-03.py
415
4.4375
4
# Exercise 1-03: Iterating over iterables (1) # Create a list of strings: flash flash = ['jay garrick', 'barry allen', 'wally west', 'bart allen'] # Print each list item in flash using a for loop for person in flash: print(person) # Create an iterator for flash: superhero superhero = iter(flash) # Print each it...
true
0dfa257c543a31b4f4dcd04f5e4667155b4b4041
Shruti-D/Python
/Basics/Ex1.py
247
4.34375
4
#Python Program to check if a Number Is Positive Or Negative. num = int(input("Enter a Number:")) if num>0: print("Number is Positive.") elif num==0: print("Number is neither Negative nor Positive.") else: print("Number is Negative.")
true
b07b972e358ae371d2ba425d429b3ff7978804f8
Parmida-Mohebali/Into-Python
/ex2/prog2.py
870
4.15625
4
evenlist=[] def prog2(a, b): """(int, int)-> list Return list of even numbers between a and b. No matter which one is bigger. Ex) input: 10, 5 output:[6, 8] Ex) input:32, 43 output:[34, 36, 38, 40, 42] """ if a<b: if a%2==0: for i in range(a+2, b, 2): ...
true
b37dfb5b484ae5e63b5a2f6a965f27237337c9fb
YMalinov/py-misc-code
/recursive/multifactorial.py
724
4.375
4
#!/bin/python def multitorial(number, level): if (level == 0): return number result = 1 for num in range(2, number + 1): result *= multitorial(num, level - 1) return result number = int(raw_input('Enter a number: ')) levels = int(raw_input('Enter levels: ')) print multitorial(number, leve...
true
e26bb12116baa61126ee4286c6ade70ced87503b
fazl/python
/hellotkinter/keyboard-event.py
911
4.21875
4
# Loosely following tuturial at # http://effbot.org/tkinterbook/tkinter-events-and-bindings.htm # For Python2 need uppercase T i.e. Tkinter # try: import tkinter as Tk ## python3: tkinter except ImportError: import Tkinter as Tk ## python2: tkinter # To invoke this listener needs two pre-requisites: # 1)...
true
e723696b4db1c8e8e2cca007daed99077b4d3419
omkar-28/python
/str_format.py
341
4.34375
4
name = input("What is your name ") age = input("Whatis your age ") program = input("which programm language are you learning ") print("Your name is {}, aged {} and your are interested in learning {} program language.".format(name, age, program)) print(f"your name is {name} and your age is {age}, and your interested in ...
true
789455c72a6929b2279a5cfbd434ecf25b39825a
ShaikAbdulArafat/Python_Practice
/src/concepts/DataTypes/mutable_datatypes.py
2,437
4.6875
5
""" A first fundamental distinction that Python makes on data is about whether or not the value of an object changes. If the value can change, the object is called mutable, while if the value cannot change, the object is called immutable. ********* Mutable Data Types *****...
true
498f138f5bf8a9584ddeeb5bdaeb6ea6a356ca35
ShaikAbdulArafat/Python_Practice
/src/concepts/DataTypes/frozenset_functions.py
1,413
4.125
4
""" frozenset is 'immutable' data type. Hence we can't enhance the data of a frozenset * Like we can't append more elements to a frozenset * Can't Insert an element to a frozenset * Can't remove an element from a frozenset ...
true
46a5270700a06eada24a1f26a78dfe9b6817c4f5
Farhad16/Python
/Data Structure/dictionary_comprehension.py
386
4.21875
4
# Simple lopping values = {} for x in range(5): print(x*2) # comprehesion # [expression for item in items] # expression = x*2 # item = x # items = range # for list comprehension values = [x * 2 for x in range(5)] print(values) # for dictionary comprehension values = {x: x*2 for x in range(5)} print(values) # For...
true
609cf443cec2a9c02e9b913590ff461c7fa6737c
wilbertgeng/LintCode_exercise
/BFS/611.py
2,761
4.15625
4
"""611. Knight Shortest Path """ """ Definition for a point. class Point: def __init__(self, a=0, b=0): self.x = a self.y = b """ class Solution: """ @param grid: a chessboard included 0 (false) and 1 (true) @param source: a point @param destination: a point @return: the shortes...
true
8fcdd469802782ace737efaa245ee6dba51fa62c
Stuming/Harbor
/Sorting/sorting.py
472
4.1875
4
# -*- coding: utf-8 -*- """ Created on Thu Apr 12 15:49:07 2018 @author: Administrator """ def quick_sort(arr): if len(arr) <= 1: return arr pivot = arr[len(arr) // 2] left = [x for x in arr if x < pivot] middle = [x for x in arr if x == pivot] right = [x for x in arr if x > pivot] ...
true
45f4ad29116227cfdd7143ce48fc4cc4a63aa8ec
mjferna/Lab-Notes
/wordcount.py
1,031
4.21875
4
##An attempt at a word count application via terminal import os name = raw_input('Hey there! What\'s your name?\n') print 'Nice to meet you, {0}.'.format(name) print 'Welcome to TextsCount!' print 'This program counts the number of words, lines, and sentences in a given text file.' lines, blanklines, sentences, words...
true
9703369767ae4a28bcc4372957284ba392675fab
brandonriis/Draft-of-a-barge
/Draft_of_a_barge.py
1,428
4.5
4
#201358937 Tonge_Brandon-CA01.py #October 2018 #This program accepts the users imputs regarding the specification of a barge #and then uses these inputs to calculate the draft of said barge. This #calculation is made assuming the barge is constructed using iron. The #program will then output each of the calculated valu...
true
d5a29c1b0b14c9ed8cd3d52286ef2842054b0c27
n-pochet/python-training-exercises
/tests/caesar_cipher/example.py
814
4.40625
4
def encrypt(message): """Encrypt the given message Arguments: message {str} -- Message to encrypt Returns: str -- The encrypted string """ if message: enc_message = list(map(encrypt_letter, message)) enc_message = "".join(enc_message) return enc_mes...
true
db5ea1abcdb78ab856c855935e1856f7659f20b7
n-pochet/python-training-exercises
/classes/line/example.py
729
4.25
4
from math import pow, sqrt class Point(): """Point class """ def __init__(self, x, y): self.x = x self.y = y class Line(): """Line class Raises: TypeError -- Raises if p1 or p2 is not an instance of Point """ def __init__(self, p1, p2): if not isins...
true
b557358fa21ab920c49f91ebec570c10aa4643e4
X3llus/CompSci12
/bug/debug.py
973
4.125
4
# Cass Smith # 11 February 2019 # Loop.py: loops and control structures demo from random import randint def getInput(): while True: try: x = integer(input("Enter a guess:\n>> ")) if x < 1 and x > 10: raise Exception("Invalid input") else: ...
true
6f9b2e8ba337763321b79be93c45244d3eaf3070
aouellette77/Learning-Python
/PracticePython/Exercise5.py
971
4.15625
4
# Take two lists, say for example these two: # # a = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89] # b = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13] # and write a program that returns a list that contains only the elements that are common between the # lists (without duplicates). Make sure your program works on two lists ...
true
4670f6265068fe20fee2fecfc1c4e162944d2ae4
Bhavya-Agrawal/Py_Projects
/numpy_ass.py
2,371
4.28125
4
#!/usr/bin/python3 ##run this file as python3 file_name import numpy as np global count count = 0 #for counting no of inputs valid_input = 1 #for getting inputs until q is reached print("enter the values and press q: to stop as any further input") even=0 user_input = input() list_elements=[] #to check count of no...
true
a93acff0f927a281308d2422c207eab1aeb0244d
ekkys/day-1-3-exercise-restart
/main.py
209
4.25
4
#Write your code below this line πŸ‘‡ # For input name name = input("Whats your name?\n") # Print how long the character with len() print(len(name)) # One line program print(len(input("What's your name?")))
true
314ed1a4fb3ddf52ebcfb092a10552befb2785f7
elmanko/python101
/examples/leap.py
493
4.25
4
# fist value is a placeholder, number of days per month month_days = [0, 31, 28, 31 ,30, 31, 30 ,31, 31, 30, 31, 30, 31] def is_leap(year): return year % 4 == 0 and (year % 100 != 0 or year % 400 == 0) def days_in_month(year, month): if not 1 <= month <= 12: return 'Invalid month' if mon...
true
3a4539df2818b9a3dad27c430001be4ded2dc4df
narayanants/complete-python-bootcamp
/5 Object Oriented Programming/homework.py
1,707
4.15625
4
# Fill in the Line class methods to accept coordinates as a pair of tuples and return the slope and distance of the line. class Line(object): def __init__(self, c1, c2): self.c1 = c1 self.c2 = c2 def distance(self): x1, y1 = self.c1 x2, y2 = self.c2 return ((x2-x1)**2 ...
true
2706007dea4aa46bf09ae80b7a33fc232995302a
JamesonDavis/CS0008-f2016
/Chapter 3/Ch3Ex1.py
365
4.125
4
day = input('Input a number 1-7') day = int(day) if day == 1: print ('Monday') elif day == 2: print ('Tuesday') elif day == 3: print ('Wednesday') elif day == 4: print ('Thursday') elif day == 5: print ('Friday') elif day == 6: print ('Saturday') elif day == 7: print ('Sunday') else: pri...
true
6acd8018441c4927d42a334435221b1d25d1adf8
JamesonDavis/CS0008-f2016
/f2016_cs8_JPD59_a1/f2016_cs8_JPD59_a1.py
2,181
4.5625
5
#First ask user to input unit system preference #Input 'USC' or 'metric' unit = input('Choose either USC or metric:') #Ask for distance driven and how much gas was used. Use if-elif statement to properly follow user's unit system choice #Define variables based on unit system used #else statement placed at the end in ca...
true
13424cb336d1569a795ebcaf8294487bafab3a86
Sallison24/Personal-Projects
/Programming/Python/Strings and Conditionals.py
893
4.40625
4
""" 1. Write a function called contains that takes two arguments, big_string and little_string and returns True if big_string contains little_string. For example contains("watermelon", "melon") should return True and contains("watermelon", "berry") should return False. 2. Write a function called common_lette...
true
4a59baae50b86797be6f2a98c30cbe2ee3ea58ce
dvncan/python_fun
/Basics/stringtype.py
592
4.15625
4
s=" you are awesome! " print(s) s1 = """you are the creator of your destiny""" print(s1) #indexing print(s[2]) #repition print(s*3) print(len(s1)) print(len(s)) #slicing print(s[0:5]) print(s[0:]) print(s[:8]) #-1 is the last element print(s[-3:-1]) #step of 2 now. print(s[0:9:2]) #-1 is the reverse order wh...
true
85353fd1e62d0247bbb96d34339ebad0a3507bd0
Princecodes4115/myalgorithms
/hackerrank/arraysum.py
765
4.34375
4
# Given an array of integers, can you find the sum of its elements? # Input Format # The first line contains an integer, , denoting the size of the array. # The second line contains space-separated integers representing the array's elements. # Output Format # Print the sum of the array's elements as a single int...
true
74b8c46672d8d9b5f6815cdf06c79c7a5cdfbc43
NLucuab/pre-ada-exercises
/Ada Build/Rock_Paper_Scissors_Game.py
984
4.1875
4
print("Enter a choice for Player 1!") print("rock, paper, or scissors!") Player1 = input() print("Enter a choice for Player 2!") print("rock, paper, or scissors!") Player2 = input() print("Let's see who wins~~") if Player1 == Player2: print("It's a tie!") elif Player1 == "rock": if Player2 == "paper": print...
true
1513ba808d4b029d331995ef638983f9037ff380
ludoro/King_card_game
/StartingInformation.py
2,394
4.125
4
def starting_info(): print('-'*10 + "KING" + "-"*10) print("Welcome! We are going to play King.") print("Do you know how to play? Y or N?") user_input = input(">") if user_input == "Y": print("Nice, you already know the rules.") elif user_input == "N": print("Alright, here is a s...
true
ce849d264a36a39de92a82c9b7ee9da2ca8e7329
ZayaanHaider/Roulette
/Roulette.py
1,924
4.25
4
import random # Game Intro print("Welcome to Roulette") print("Roulette starts with players making bets.") print("The croupier (or dealer) throws a ball into the spinning roulette wheel. Players can still makes bets within the process.") print("While the ball is rolling at the roulette wheel, the croupier/dealer annou...
true
d769a1ad8ca4fe8aa90ff0a57ad63cdb0a40741c
sachag678/100DaysofCode
/algorithms/number_swapper.py
736
4.25
4
# Write a function to swap a number in place (that is without temporary variables.) # hint 1: Try picturing the two numbers, a and b on a number line. # hint 2: Let diff be the difference between a and b. Can you use the diff in some way? Then can you get rid of this # temporary variable # hint 3: You could also try us...
true
f5337debdcbaaea09988bc34146be8c76434d15a
Esquire-gh/MontyHallSimulation
/montygame.py
2,859
4.125
4
import random class MontyHallGame: ''' This is code that simulates the monty hall problem Author: Esquire_gh ''' def __init__(self): self.option = [1,2,3] self.prize = ['goat', 'goat', 'car'] self.host_options = [] print("Starting New Game: ") #method that shuffles the doors and the prizes behin...
true
1bc3a658f23ba61759b807d45398705391a451d9
jbacos7/C-
/secondDojo answers1/Python/Python Week 1/mathdojoAM.py
870
4.125
4
# HINT: To do this exercise, you will probably have to use 'return self'. If the method returns itself (an instance of itself), we can chain methods. # Create a Python class called MathDojo that has the methods add and subtract. Have these 2 functions take at least 1 parameter. # # Then create a new instance called m...
true
a60b27884d13fe9daebfec9d2795c05de65bb4b3
Mike46604/RPS
/RPS.py
2,546
4.28125
4
import random yourscore = 0 computerscore = 0 #Gives a value of zero to yourscore and computerscore def game(): global yourscore global computerscore #Brings the values yourscore and computerscore into the function. player = input("Enter your choice (rock/paper/scissors):") #Allows the player to put ...
true
c1429f921b7486337918a2ec12d73fdd3e7f0df9
flaith-nycd/python-samples
/yield_explanation.py
1,954
4.21875
4
""" http://khmel.org/?p=1151 https://www.quora.com/What-does-the-%E2%80%9Cyield%E2%80%9D-keyword-do-in-Python https://docs.python.org/3.6/library/itertools.html """ """ Short explanation: Yield can pause a function and return current result. So yield works almost as return in the function. How to get value a...
true
b845ad0bda65047e046e15b02354c6ec7905563b
rafiramadhana/oop-python
/youtube/Corey_Schafer/Python_OOP_Tutorial/02_class_variables.py
1,186
4.40625
4
class Employee: # class variables num_of_employees = 0 raise_amount = 1.04 def __init__(self, first, last, pay): # instance variables self.first = first self.last = last self.pay = pay self.email = f"{first}.{last}@company.com" Employee.num_of_employees +...
true
29fd5d9ba31f79c08409bc6fb0eb966a1aa350b3
kath-k3/kath_python_core
/week_02/k3_solutions/4_loops_ex5.py
577
4.25
4
#Take two numbers from the user, an upper and lower bound. Using a loop, calculate the sum #of numbers from the lower bound to the upper bound. Also, calculate the average of numbers. #Print the results to the console. lower_input = int(input("Please give me a number ")) higher_input = int(input("Please give me a high...
true
6d994f34fa91bda2bfef378808e6157d2414bb99
nabaz/python-experiments
/top-100-liked-questions/spiral-order.py
428
4.375
4
''' Given a matrix of m x n elements (m rows, n columns), return all elements of the matrix in spiral order. For example, Given the following matrix: [ [ 1, 2, 3 ], [ 4, 5, 6 ], [ 7, 8, 9 ] ] You should return [1,2,3,6,9,8,7,4,5]. ''' def spiral_order(matrix): """ :type matrix: List[List[int]] :rtype: ...
true
08db32d40f3bbf606aef9f20fc5bebf2c519ef40
Jarquevious/Tweet-Generator
/histogram.py
2,211
4.25
4
import string from time import time # A histogram() function which takes a source_text argument (can be either a filename # or the contents of the file as a string, your choice) and return a histogram data structure # that stores each unique word along with the number of times the word appears in the source text. # A ...
true
b266f0292f2c11532825da0f377d89484e23b9e6
jwesleylima/Bin2Dec-Python
/bin2dec.py
1,006
4.1875
4
"""Module written on 08/22/2021 by JWesleyLima. Visit my profile: https://github.com/jwesleylima.""" def bin2dec(*, binary_digits: str) -> int: """Converts binary digits into decimal numbers. - Keyword Parameters: binary_digits: Binary digits as a string. - Return: int: Decimal number - Usage...
true
d9183f0d33ae32910adb2e795365672536a25173
refrain62/python_study
/004_simple_output/simple_output.py
213
4.3125
4
# Python 3: Simple output (with Unicode) print("Hello, I'm Python!") #Hello, I'm Python! # Input, assignment name = input('What is your name?\n') print('Hi, %s.' % name) #What is your name? #Python #Hi, Python.
true
135e93398eaa8cdc7be235c11759085dd8c8d2ae
absentee-neptune/Personal-Projects
/Python/PycharmProjects_1718/Week 3 Programming Assignment/Functions.py
2,469
4.1875
4
#Week 3 Programming Assignment - Functions import math def miles_to_kilometers(length_in_miles): # This function converts a number from miles to kilometers # Arguments: # length_in_miles(float): The length to convert # Returns: # float: The length in kilometers # Assump...
true
79c24a570d9b9870ad58b844a77ee418c5a800f4
baothais/Practice_Python
/if_else.py
922
4.28125
4
a = 20 b = 30 c = 40 if a > b: print("a > b") elif a < b: print("a < b") else: print("a=b") # One line if statement if a==b: print("a=b") # One line if else statement print(a) if a < b else print(b) # One line if else statement, with 3 conditions print(a) if a > b else print(b) if a < b else print(a, b) # T...
true
0146fdf72ef8fdf9b290f6392d86e376baccc97d
suhas-arun/Google-Code-In
/Two-Circles/main.py
2,479
4.25
4
"""App that shows the state of two circles""" import sys import pygame def identify_circles(radius1, radius2): """Returns which circle is bigger and which is smaller""" if radius1 > radius2: bigger, smaller = radius1, radius2 else: bigger, smaller = radius2, radius1 return (bigger, s...
true
147afd241ab4af3ac02fbff8724fb7746ed3a62e
madhavms/Python_Digital_Programs
/longestsubstring.py
853
4.3125
4
""" Given a string s, find the length of the longest substring without repeating characters. Example 1: Input: s = "abcabcbb" Output: 3 Explanation: The answer is "abc", with the length of 3. Example 2: Input: s = "bbbbb" Output: 1 Explanation: The answer is "b", with the length of 1. Example 3: Input: s = "pwwke...
true
f13e23cc3c37254a88a9f3c0fe5834b0f7af0ee8
cosmos-nefeli/practice_python
/stacks.py
708
4.1875
4
class Stack: def __init__(self): self.stack = [] def add(self, dataval): #Use list append method to add element if dataval not in self.stack: self.stack.append(dataval) return True else: return False #use peek to look at the top of the stack d...
true
f6f6db3976318c379c60a3df2cd7bc3cf2d1ce1c
z-memar/PigLatinLanguage
/TranslatingToPiglatinLanguage.py
1,701
4.28125
4
print(" Zahra Memar",'\n',"Homework#3",'\n',"September 25,2019") print("") import string VOWEL=['a','e','i','o','u'] piglet_vowel='hay' piglet_constant='ay' def AskUserForSentences(): while True: try: sentence= str(input('''Please input a sentence that contains three words and spaces, Or t...
true
68628d5be0224de8f091379a95c6e795bba26478
allybrannon/week1_friday
/sean_replace_2.py
415
4.15625
4
# working on removing names from a list and replacing with another name staff_list = ["Sean", "David", "Mary Ella", "Liz", "Natalie", "Tasha", "Jake", "Max"] print(staff_list) staff_list[staff_list.index("Sean")] = "Ranger" print(staff_list) if "David" in staff_list: indexofDavid = staff_list.index("David") ...
true
62d2e18572025024c6eb278852524bf98658756e
JWLee89/python-study
/src/property/factory.py
1,784
4.21875
4
import typing as t class Dummy: """ Used as dummy to prove that property is a class. Note that both classes and functions are similar in the fact that both are "callable" objects """ def __init__(self): self.a = 10 print(f"function callable: {callable(print)}, " ...
true
895420a6cb856322be1e37686e80882adf090de0
estraviz/Python_Design_Patterns_Lynda
/Behavioral_Patterns/visitor.py
1,848
4.25
4
class House(object): """ The class being visited """ def accept(self, visitor): """ Interface to accept a visitor """ # Triggers the visiting operation! visitor.visit(self) def work_on_hvac(self, hvac_specialist): #Β We have a reference to the HVAC (Heating, ventilation and...
true
72543c8b0fbed2dcd0d5cc2eac9a86dd91338fef
Rvelchuri/OO-Melons
/melons.py
1,885
4.125
4
"""Classes for melon orders.""" class AbstractMelonOrder(): """A melon order within the USA.""" def __init__(self, species, qty, tax): """Initialize melon order attributes.""" self.species = species self.qty = qty self.shipped = False self.tax = tax def get_total(s...
true
386baf28ebba3261b361c17db314ae03ac67a426
hashansl/dash-plotly-training
/Python OOP/method_init.py
495
4.125
4
#2 class Computer: #Basically we use inti to initialize variables #We are actually passing 3 arguments here (com1,cpu,ram) ---> com1 passes automatically def __init__(self,cpu,ram): self.cpu = cpu; self.ram= ram; def config(self): print("Config is ",self.cpu,self.ram) #when w...
true
047de24233a89b6340204c64fa8ffd7348e1ac34
meeree/Python-stuff
/math/knights_problem.py
409
4.25
4
#Every time that a y value is changed: call a function that checks if any x values are below it and, if so, sends them through all possible ys. Method to change the current position of a number import numpy as np my_list = [i for i in range(1, 9)] print(my_list) board = np.zeros((7,8)) print(board) board = np.insert(bo...
true
28b6fc79bbc16a20bacde899f43a76a665676c5d
AFresnedo/computer-science-theory
/graphs/python/bfs.py
1,734
4.125
4
# Current version is flimsy & unrefactored code to practice algorithm design # Lists do not dequeue effeciently (requires position updates) from collections import deque # Graph is implemented using an adjacency list (instead of adj matrix) class Graph: def __init__(self): self.adj_list = {} def add...
true
3be1451c533dc8121e909b7f40def217dcf7f4a6
AishwaryaBhaskaran/261644_Daily-commits-Python
/str.py
470
4.25
4
#Write a python program to check the user input abbreviation.If the user enters "lol", print "laughing out loud".If the user enters "rofl", print "rolling on the floor laughing".If the user enters "lmk", print "let me know".If the user enters "smh", print "shaking my head" str=input() if str=="lol": print("laughing...
true
1b6ebe3c39ee3a64f8f49b5df8c074c1ef5c5310
ilyaostapchenko/ostapchenko
/homework/lesson_18_Ostapchenko_I/task_4_lesson_18_Ostapchenko_I.py
510
4.1875
4
def readlines(filename): with open(filename, "r") as file: lines = file.readlines() return lines def get_longest_line(lines): lst = [item.strip() for item in lines] longest_line = lst for item in lst: if len(item) > len(longest_line): longest_line = item return ...
true
f49be953a520cb36bb7f984a8b3bc0cb841a3d39
Alirezak2n/Python-Tutorials
/9-Generators.py
1,252
4.15625
4
# Generators range(100) # it is a generator too # all generators like range are iterables but not are iterables like list are generator def generator_func(num): for i in range(num): yield i # it pause function and comes back later, if we use return it is not a generator for item in generator_fun...
true
ad040c6e7c8227334ae22e9e32438076f8255409
Jeff-Hill/Python-Intro
/exercises/tuples/zoo.py
1,672
4.5625
5
# Create a tuple named zoo that contains 10 of your favorite animals. # Find one of your animals using the tuple.index(value) syntax on the tuple. zoo = ("gorilla", "zebra", "giraffe", "lion", "tiger", "parrot", "snake", "elephant", "rhino", "monkey") print(zoo.index("gorilla")) # Determine if an animal is in your tup...
true
8344db2a7dd3c4b57d532d75de75c4eba89463ab
nephewtom/hacker-rank
/day1/plus-minus.py
894
4.15625
4
#!/bin/python3 import math import os import random import re import sys # # Complete the 'plusMinus' function below. # # The function accepts INTEGER_ARRAY arr as parameter. # def plusMinus(arr): # Write your code here zeroes = 0 positives = 0 negatives = 0 for x in arr: if x > 100 or x ...
true
3eeb6da03607d75a10acc793b18b47036d592da7
khatriamit/HackerRankPythonTest
/task17.py
1,061
4.125
4
""" You are given an HTML code snippet of lines. Your task is to print the single-line comments, multi-line comments and the data. Print the result in the following format: Sample Input 4 <!--[if IE 9]>IE9-specific content <![endif]--> <div> Welcome to HackerRank</div> <!--[if IE 9]>IE9-specific content<![endif]-->...
true
360fba7d84412af9c4c5198b56f9abbf529dd8dd
james-soohyun/CS61A_old
/Guerilla/guerilla02.py
2,281
4.25
4
# Question 1 def make_skipper(n): """Return a function that takes int x as an input and prints all numbers between 0 and x, skipping every nth number (meaning skip any value that is a multiple of n). Args: n (int): Multiple that must be skipped when printing x (int): Upper limit of numbers that ...
true
5769647cf9002a2f50c3a3f32d482e4a7091f8a0
YichaoLeoLi/CS550
/Fall term/homework /userinput.py
438
4.125
4
#Leo Li #09/27/18 #Description: Create a list of 15 random numbers from 0-100. Ask the user for one input from 0-100. Append this input to the list. Sort the list into descending order. import random x = [] y = 0 while y<15:#take 15 random numbers x.append(random.randint(0,100)) y+=1 z = int(input("\nplease enter a ...
true
612a375cdfc326c9049eddf86ac1ebf9a5da9621
adambatchelor2/python
/codewars_test.py
447
4.15625
4
# The main idea is to count all the occurring characters in a string. If you have a string like aba, then the result should be {'a': 2, 'b': 1}. # # What if the string is empty? Then the result should be empty object literal, {}. strIn = "asdasda" listIn = list(strIn) listIn.sort() dict = {} for x in listIn: i...
true
64e0285214f7485ff5c17158419f98c40d79c795
adambatchelor2/python
/Edabit_27122019_IterateSum.py
323
4.25
4
#Create a function that takes a number as an argument. Add up all the numbers from #1 to the number you passed to the function. For example, if the input is 4 then your #function should return 10 because 1 + 2 + 3 + 4 = 10. def add_up(num): y = 0 for x in range(1,num+1): y = y + x return y print (add_up(1...
true
84d2195b0617ece5fde3b1b813bb104e60570e3c
bayliewarrick/python101
/11-13/lecture_notes.py
1,186
4.1875
4
""" #open file in write mode file_object = open('todo.txt','w') file_object.write('hello, python!') file_object.close() #better way to write to file, will automatically close for you. with open('todo.txt', 'w') as file_object: file_object.write("Hello world!!!") #read text from file: with open('MyTasks.txt') as...
true
d6c85e4d25a4f4ea40ecbe9b5e6a348c85e4ca6d
feliciahsieh/holbertonschool-webstack_basics
/0x01-python_basics/13-add_integer.py
777
4.5
4
#!/usr/bin/python3 """ 13-add_integer.py - adds 2 integers with type checking """ def add_integer(a, b): """ add_integer - adds 2 integers with type checking Arguments: a: operand 1 b: operand 2 Returns: raises an rror with a message """ # Check for Infinite number if a == float('...
true
8c53e36527e8c53096172ad852e06a0996aa215e
feliciahsieh/holbertonschool-webstack_basics
/0x01-python_basics/10-simple_delete.py
486
4.125
4
#!/usr/bin/python3 """ 10-simple_delete.py - delete a dictionary entry with given key """ def simple_delete(my_dict, key=""): """ simple_delete() - delete a dictionary entry with given key Arguments: my_dict: dictionary to check key: key in dictionary to delete Returns: original my_dict if key...
true
540c011658d3bcc053c051e012dc4d62e11746fe
sukhadagholba/Sprint-Challenge--Intro-Python
/src/cityreader.py
2,695
4.3125
4
# Create a class to hold a city location. Call the class "City". It should have # fields for name, latitude, and longitude. import csv # TODO class City(): def __init__(self, name, latitude, longitude): self.name=name self.latitude=latitude self.longitude=longitude # We have a collection ...
true
bf054145a75bac5cbc073d4d4e9f58a72a06cf1c
pavanghuge/Training
/BasicExercise1/six.py
237
4.21875
4
#Exercise 6: Given a list of numbers, Iterate it and print only those numbers which are divisible of 5 inputList = [10, 20, 33, 46, 55] print("Divisible by 5 in a list") for num in inputList: if(num%5==0): print(num)
true
2ad53a615af98e54fbc2a56da0ca7ed691cb88c9
pavanghuge/Training
/taskFive.py
2,341
4.21875
4
#1. Write a program in Python to allow the error of syntax to be handled using # exception handling.HINT: Use SyntaxError try: b = 10 print(b) eval('a === 10') except SyntaxError: print("Caught syntax error") print("You can only catch SyntaxError if it's thrown out of an eval, exec, or import opera...
true
2e9f12d27784c83c3de54c29bee6037a089d4263
mlawan252/testrepo
/firstpython.py
270
4.4375
4
#Display the output print("New python File") # program that print out the factors of a given integer number = int(input("Enter a positive integer ")) for i in range(1,number + 1): if number % i == 0: print(f"{i} is a factor of {number}")
true
f091fc940499f8393f3fa3fd3e4335285184216a
jdputsch/WPE
/J18_10/multiziperator.py
999
4.28125
4
#!/bin/env python def multiziperator(*args): """Return elements of iterable inputs one at a time. Args: *args: One or more iterables Yields: Return elements of each input, interleaved, one at a time. Example: Given: letters = 'abcde' numbers = [1,2...
true
ffbc2a77cd0d3ce5d482f2554add6603942e4527
jlameiro87/cs50
/mario-more.py
739
4.1875
4
from cs50 import get_int # main function def main(): # initialize height in 0 to emulates the do while height = 0 # keep asking a valid height value to the customer until type something valid between 1 and 8 while height < 1 or height > 8: height = get_int('Height: ') # calling the printi...
true
4bd2212d2a726b5b5501bf10626e19a0b6ca282b
sn-orla-x/Imperative-vs-OO-Calendar-Implementations
/imperative_calendar_app.py
2,851
4.28125
4
#dictionary was hard coded appoints = {"Monday" : [], "Tuesday": [], "Wednesday": [], "Thursday": [], "Friday": [], "Saturday": [], "Sunday": []} #prompty prompts the user to enter commands on their terminal and then runs the command that they enter def prompty(): prompt = input("Enter a comma...
true
2a467366c2a35b92dac656f78e0c3fcf1623738d
prpllrhd/python-project
/learn.class/classmethodExample1.py
1,310
4.65625
5
from datetime import date ''' here we are using @classmethod to create instance using a different method. so here the age is not being passed but birthyear. this is an example of alternate constructor. here you use "fromBirthYear(cls, name, birthYear):" to create an alternate constructor which is "def __init__(self,na...
true
2b6560589b03a3a642f2233ad45ea4fc6717da89
lindsaymarkward/cp1404_inclass_demos_2021_2
/encrypt_solutions.py
1,903
4.15625
4
"""Shift encrypt names/strings from text file Let string A be the first 6 characters of your last-name (if your last-name is less than 6 characters, repeat the last letter until you get a six-character string). (a) Encrypt string A using ROT3 cipher in the English alphabet. (b) Encrypt string A using One-Time-Pad ciph...
true
bd72699a3b5fe0f00cb3a5d9a99a92a3169f999e
alarconm/web-caesar
/caesar.py
646
4.21875
4
from helpers import alphabet_position, rotate_character def encrypt(text, rot): '''take a message and rotate each character by the integer rot via helper function''' newtext = '' for char in text: newtext += rotate_character(char, rot) return newtext def main(): '''get message and rotatio...
true
4208fc76fb272d48216e279fb55f64664e3d20a1
migliom/Computer-Network-Security-Encryption-Algorithms-
/HW03/mult_inv.py
2,673
4.21875
4
#HW03 Coding Problem #Matteo Miglio #miglio@purdue.edu #02/11/2021 #!/usr/bin/env python3 #mult_iv.py import sys '''This function was derived through the help of the following youtube video, the implementation is unique to this specific program''' '''https://www.youtube.com/watch?v=w3m3xdw1E-Q&ab_channel=CPlus%2B'''...
true
2bdae899f97a3de98c2c7328302718d5eeb2ee42
SenorNoName/projectEuler
/euler4.py
727
4.125
4
''' 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. ''' num1 = 100 num2 = 100 productArr = [] palindromeArr = [] def palindromeCheck(int): int = str(int...
true
526e53e4c97cbc694fe7c776e1199144d7c540ff
eliasdabbas/advertools
/advertools/word_tokenize.py
2,752
4.53125
5
""" .. _word_tokenize: Tokenize Words (N-grams) ======================== As word counting is an essential step in any text mining task, you first have to split the text into words. The :func:`word_tokenize` function achieves that by splitting the text by whitespace. Another important thing it does after splitting is...
true
92cb8099b670c5861621f7cb2d264f40144c6205
jtwong1/math361
/python-code/week1to3/intro_vectorize.py
1,719
4.34375
4
"""Vectorization (in numpy) and append vs. pre-allocation example. Calculates x*sin(x) for a large number of x's. - Note that the vectorized operation is much faster than a for loop. - Appending tends to be a bit slower than pre-allocating. - the numpy array append is *extremely slow* (its not recom...
true
c3839667a5ac0d42cf7aeedaa77fd44f342827b5
jtwong1/math361
/python-code/week1to3/hw2_template.py
1,669
4.34375
4
""" HW 2 template code: - newton's method - example for the reivew problem. """ import numpy as np import matplotlib.pyplot as plt def make_2d_array(): """ quick example for review: creating 2d arrays and indexing. """ # version 1: list of lists (rows) v1 = [[0 for j in range(3)] for k in range(...
true
25c3f21e5aeb6ab6116f09f43ee24598c05c895c
Cheese229/DataAssignmentCIS
/color_change.py
2,123
4.28125
4
""" Code source here: https://stackoverflow.com/questions/40160808/python-turtle-color-change Trying to see how this person uses turtle.stamp to change the color of their turtles I cannot seem to make sense out of it, or at least be able to use some sort of form out of this ;-; """ from turtle import...
true
965d37e82c4b4d75020c5ac1501d653e0da7e733
AadityaAgarwal/NumberGuessing
/NumberGuessing.py
534
4.1875
4
chance=5 ans=8 print("number Guessing Game") print("Choose a number (between 0-9)") while (chance>=0): inputAnswer=int (input("Enter Your Guess:- ")) if(inputAnswer<=7): chance-=1 print("Guess a number greater then ",inputAnswer ) elif(inputAnswer==8): print("Congratulations...
true
2360adde9f7da57626a0efc9e672dadcd5f7486d
prayas2409/Machine_Learning_Python
/Week2/StringQ4.py
615
4.21875
4
flag: bool = True while flag: try: string1 = input("Enter a string") # checking if the length is more than 3 if string1.__len__() < 3: print("no change") else: if string1.endswith("ing"): # if already has ing string1 += 'ly' ...
true
1eb262666fee0981fe5baf531ced23961431c54b
crwandle/AutoRockClimber
/decisionengine/min_heap.py
1,443
4.28125
4
import heapq class MinHeap(object): """ Class to keep track of where everything is in the priority queue. """ def __init__(self): self.heap = [] self.items = {} self.counter = 0 def is_empty(self): """Returns whether priority queue is true or not. Returns:...
true