blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
6ebdc47b984d3f9b7b65663b2ba01f9b54fc7edf
dks1018/CoffeeShopCoding
/2021/Code/Python/Exercises/Calculator2.py
1,480
4.1875
4
# Variable statements Number1 = input("Enter your first number: ") Number2 = input("Enter your second number: ") NumberAsk = input("Would you like to add a third number? Y or N: ") if NumberAsk == str("Y"): Number3 = input("Please enter your third number: ") Operation = input("What operation would you like to perfo...
true
7b98a668260b8d5c0b729c6687e6c0a878574c9d
ajanzadeh/python_interview
/games/towers_of_hanoi.py
1,100
4.15625
4
# Tower of Hanoi is a mathematical puzzle where we have three rods and n disks. The objective of the puzzle is to move the entire stack to another rod, obeying the following simple rules: # 1) Only one disk can be moved at a time. # 2) Each move consists of taking the upper disk from one of the stacks and placing it on...
true
ca091bae52a3e79cece2324fe946bc6a52ca6c2f
mrmuli/.bin
/scripts/python_datastructures.py
2,019
4.15625
4
# I have decided to version these are functions and operations I have used in various places from mentorship sessions # articles and random examples, makes it easier for me to track on GitHub. # Feel free to use what you want, I'll try to document as much as I can :) def sample(): """ Loop through number ran...
true
356122c10a2bb46ca7078e78e991a08781c46254
KingHammer883/21.Testing-for-a-Substring-with-the-in-operator.py
/21.Testing-for-Substring-With-the-in-operator.py
752
4.40625
4
# -*- coding: utf-8 -*- """ Created on Fri Jan 18, 2019 File: Testing for a Substring with the in operator @author: Byen23 Another problem involves picking out strings that contains known substrings. FOr example you might wnat to pick out filenames with a .txt extension. A slice would work for this but using Pyt...
true
0606ac38799bfe01af2feda28a40d7b863867569
PacktPublishing/Python-for-Beginners-Learn-Python-from-Scratch
/12. Downloading data from input/downloading-data.py
260
4.15625
4
print("Program that adds two numbers to each other") a = int(input("First number: ")) b = int(input("Second number: ")) #CASTING allows you to change ONE type of variable to another type of variable print("Sum of a =", a, "+", "b =", b, "is equal to", a + b)
true
9dbcec24d2b156aa7f69a8bf1e65ade631e0eea3
sdelpercio/cs-module-project-recursive-sorting
/src/sorting/sorting.py
2,202
4.1875
4
# TO-DO: complete the helper function below to merge 2 sorted arrays def merge(arrA, arrB): elements = len(arrA) + len(arrB) merged_arr = [None] * elements # Your code here while None in merged_arr: if not arrA: popped = arrB.pop(0) first_instance = merged_arr.index(None...
true
e0f808f1c93b832eeb29f9133a86ce99dbbe678d
NuradinI/simpleCalculator
/calculator.py
2,097
4.40625
4
#since the code is being read from top to bottom you must import at the top import addition import subtraction import multiplication import division # i print these so that the user can see what math operation they will go with print("Select operation.") print("1.Add") print("2.Subtract") print("3.Multiply") print("...
true
8ba9f444797916c33a00ce7d7864b1fa60ae6f24
Bongkot-Kladklaen/Programming_tutorial_code
/Python/Python_basic/Ex24_UserInput.py
271
4.1875
4
#* User Input """ Python 3.6 uses the input() method. Python 2.7 uses the raw_input() method. """ #* Python 3.6 username = input("Enter username:") print("Username is: " + username) #* Python 2.7 username = raw_input("Enter username:") print("Username is: " + username)
true
d982dbcd9d34ecfd77824b309e688f9e077093d5
gcvalderrama/python_foundations
/DailyCodingProblem/phi_montecarlo.py
1,292
4.28125
4
import unittest # The area of a circle is defined as πr ^ 2. # Estimate π to 3 decimal places using a Monte Carlo method. # Hint: The basic equation of a circle is x2 + y2 = r2. # we will use a basic case with r = 1 , means area = π ^ 2 and x2 + y2 <=1 # pi = The ratio of a circle's circumference ...
true
24cf6864b5eb14d762735a27d79f96227438392f
ramalldf/data_science
/deep_learning/datacamp_cnn/image_classifier.py
1,545
4.28125
4
# Image classifier with Keras from keras.models import Sequential from keras.layers import Dense # Shape of our training data is (50, 28, 28, 1) # which is 50 images (at 28x28) with only one channel/color, black/white print(train_data.shape) model = Sequential() # First layer is connected to all pixels in original im...
true
60b60160f8677cd49552fedcf862238f9128f326
Prash74/ProjectNY
/LeetCode/1.Arrays/Python/reshapematrix.py
1,391
4.65625
5
""" You're given a matrix represented by a two-dimensional array, and two positive integers r and c representing the row number and column number of the wanted reshaped matrix, respectively. The reshaped matrix need to be filled with all the elements of the original matrix in the same row-traversing order as they were...
true
3d999f7baa9c6610b5b93ecf59506fefd421ff86
Minglaba/Coursera
/Conditions.py
1,015
4.53125
5
# equal: == # not equal: != # greater than: > # less than: < # greater than or equal to: >= # less than or equal to: <= # Inequality Sign i = 2 i != 6 # this will print true # Use Inequality sign to compare the strings "ACDC" != "Michael Jackson" # Compare characters 'B' > 'A' # If statement example ag...
true
f256746a37c0a050e56aafca1315a517686f96c8
luxorv/statistics
/days_old.py
1,975
4.3125
4
# Define a daysBetweenDates procedure that would produce the # correct output if there was a correct nextDay procedure. # # Note that this will NOT produce correct outputs yet, since # our nextDay procedure assumes all months have 30 days # (hence a year is 360 days, instead of 365). # def isLeapYear(year): if ye...
true
bf6d09ae3d5803425cf95dd4e53fe62dad41fda0
reveriess/TarungLabDDP1
/lab/01/lab01_f.py
618
4.6875
5
''' Using Turtle Graphics to draw a blue polygon with customizable number and length of sides according to user's input. ''' import turtle sides = int(input("Number of sides: ")) distance = int(input("Side's length: ")) turtle.color('blue') # Set the pen's color to blue turtle.pendown() # Start drawing d...
true
2c2b4f56fc3f3c0c76ba69866da852edcfbf8186
Anshikaverma24/to-do-app
/to do app/app.py
1,500
4.125
4
print(" -📋YOU HAVE TO DO✅- ") options=["edit - add" , "delete"] tasks_for_today=input("enter the asks you want to do today - ") to_do=[] to_do.append(tasks_for_today) print("would you like to do modifications with your tasks? ") edit=input("say yes if you would like edit your tasks - ") if edit=="ye...
true
6fd57771b4a4fdbd130e6d408cd84e02f89f48a4
Jayasuriya007/Sum-of-three-Digits
/addition.py
264
4.25
4
print ("Program To Find Sum of Three Digits") def addition (a,b,c): result=(a+b+c) return result a= int(input("Enter num one: ")) b= int(input("Enter num one: ")) c= int(input("Enter num one: ")) add_result= addition(a,b,c) print(add_result)
true
2da2d69eb8580ba378fac6dd9eff065e2112c778
sk24085/Interview-Questions
/easy/maximum-subarray.py
898
4.15625
4
''' Given an integer array nums, find the contiguous subarray (containing at least one number) which has the largest sum and return its sum. A subarray is a contiguous part of an array. Example 1: Input: nums = [-2,1,-3,4,-1,2,1,-5,4] Output: 6 Explanation: [4,-1,2,1] has the largest sum = 6. Example 2: Input: nums ...
true
daa21099590ab6c4817de8135937e9872d2eb816
sk24085/Interview-Questions
/easy/detect-capital.py
1,464
4.34375
4
''' We define the usage of capitals in a word to be right when one of the following cases holds: All letters in this word are capitals, like "USA". All letters in this word are not capitals, like "leetcode". Only the first letter in this word is capital, like "Google". Given a string word, return true if the usage of ...
true
bca49786c266839dc0da317a76d6af24b20816e5
mtahaakhan/Intro-in-python
/Python Practice/input_date.py
708
4.28125
4
# ! Here we have imported datetime and timedelta functions from datetime library from datetime import datetime,timedelta # ! Here we are receiving input from user, when is your birthday? birthday = input('When is your birthday (dd/mm/yyyy)? ') # ! Here we are converting input into birthday_date birthday_date = datet...
true
2937f2007681af5aede2a10485491f8d2b5092cf
mtahaakhan/Intro-in-python
/Python Practice/date_function.py
649
4.34375
4
# Here we are asking datetime library to import datetime function in our code :) from datetime import datetime, timedelta # Now the datetime.now() will return current date and time as a datetime object today = datetime.now() # We have done this in last example. print('Today is: ' + str(today)) # Now we will use tim...
true
e797aa24ce9fbd9354c04fbbf853ca63e967c827
xtdoggx2003/CTI110
/P4T2_BugCollector_AnthonyBarnhart.py
657
4.3125
4
# Bug Collector using Loops # 29MAR2020 # CTI-110 P4T2 - Bug Collector # Anthony Barnhart # Initialize the accumlator. total = 0 # Get the number of bugs collected for each day. for day in range (1, 6): # Prompt the user. print("Enter number of bugs collected on day", day) # Input the number...
true
6e7401d2ed0a82b75f1eaec51448f7f20476d46e
xtdoggx2003/CTI110
/P3HW1_ColorMix_AnthonyBarnhart.py
1,039
4.40625
4
# CTI-110 # P3HW1 - Color Mixer # Antony Barnhart # 15MAR2020 # Get user input for primary color 1. Prime1 = input("Enter first primary color of red, yellow or blue:") # Get user input for primary color 2. Prime2 = input("Enter second different primary color of red, yellow or blue:") # Determine secon...
true
c3ffa8b82e2818647adda6c69245bbc9841ffd76
tsuganoki/practice_exercises
/strval.py
951
4.125
4
"""In the first line, print True if has any alphanumeric characters. Otherwise, print False. In the second line, print True if has any alphabetical characters. Otherwise, print False. In the third line, print True if has any digits. Otherwise, print False. In the fourth line, print True if has any lowercase char...
true
4d1605f77acdf29ee15295ba9077d47bc3f62607
zakwan93/python_basic
/python_set/courses.py
1,678
4.125
4
# write a function named covers that accepts a single parameter, a set of topics. # Have the function return a list of courses from COURSES # where the supplied set and the course's value (also a set) overlap. # For example, covers({"Python"}) would return ["Python Basics"]. COURSES = { "Python Basics": {"Pytho...
true
6ce838e30b83b79bd57c65231de2656f63945486
prashant2109/django_login_tas_practice
/python/Python/oops/polymorphism_info.py
2,144
4.40625
4
# Method Overriding # Same method in 2 classes but gives the different output, this is known as polymorphism. class Bank: def rateOfInterest(self): return 0 class ICICI(Bank): def rateOfInterest(self): return 10.5 if __name__ == '__main__': b_Obj = Bank() print(b_Obj.rateOfInterest()...
true
f7b7853e9332ef9fd2a5c16733f1908c00ea2a04
redoctoberbluechristmas/100DaysOfCodePython
/Day03 - Control Flow and Logical Operators/Day3Exercise3_LeapYearCalculator.py
826
4.375
4
#Every year divisible by 4 is a leap year. #Unless it is divisible by 100, and not divisible by 400. #Conditional with multiple branches year = int(input("Which year do you want to check? ")) if(year % 4 == 0): if(year % 100 == 0): if(year % 400 == 0): print("Leap year.") else: print("Not leap...
true
d167ac2865745d4e015ac1c8565dd07fba06ef4d
redoctoberbluechristmas/100DaysOfCodePython
/Day21 - Class Inheritance/main.py
777
4.625
5
# Inheriting and modifying existing classes allows us to modify without reinventing the wheel.add class Animal: def __init__(self): self.num_eyes = 2 def breathe(self): print("Inhale, exhale.") class Fish(Animal): def __init__(self): super().__init__() # The call to super() ...
true
d999a0fd4f5a5516a6b810e76852594257174245
redoctoberbluechristmas/100DaysOfCodePython
/Day08 - Functions with Parameters/cipherfunctions.py
846
4.125
4
alphabet = [ 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z' ] def caesar(start_text, shift_amount, ...
true
9006fe1d04ceee567b8ced73bddd2562d0239fb8
zhartole/my-first-django-blog
/python_intro.py
1,313
4.21875
4
from time import gmtime, strftime def workWithString(name): upper = name.upper() length = len(name) print("- WORK WITH STRING - " + name * 3) print(upper) print(length) def workWithNumber(numbers): print('- WORK WITH NUMBERS') for number in numbers: print(number) if number...
true
b5b8ad763c493b7e79cd419bdc08170b1a11dd58
TranshumanSoft/quotient-and-rest
/modulexercises.py
268
4.15625
4
fstnumber = float(input("Introduce a number:")) scndnumber = float(input("Introduce another number:")) quotient = fstnumber//scndnumber rest = fstnumber%scndnumber print(f"Between {fstnumber} and {scndnumber} there's a quotient of {quotient} and a rest of {rest}")
true
bd6b8a39bd376c6bcf9a3a56a4a70453159e05f4
baixianghuang/algorithm
/python3/merge_linked_lists.py
2,215
4.3125
4
class ListNode: def __init__(self, val): self.val = val self.next = None def merge_linked_lists_recursively(node1, node2): """"merge 2 sorted linked list into a sorted list (ascending)""" if node1 == None: return node2 elif node2 == None: return node1 new_h...
true
96133f56fdadf80059d2b548a3ae485dee91f770
suhaslucia/Pythagoras-Theorem-in-Python
/Pythagoras Theorem.py
1,114
4.40625
4
from math import sqrt #importing math package print(" ----------Pythagoras Theorem to Find the sides of the Triangle---------- ") print(" ------------ Enter any one side as 0 to obtain the result -------------- ") # Taking the inputs as a integer value from the user base = int(input("Enter the base of the Trian...
true
68e32356ee24ab2bbfc87c4ca3508e89eacd3a0b
Kumar1998/github-upload
/scratch_4.py
397
4.25
4
d1={'Canada':100,'Japan':200,'Germany':300,'Italy':400} #Example 1 Print only keys print("*"*10) for x in d1: print(x) #Example 2 Print only values print ("*"*10) for x in d1: print(d1[x]) #Example 3 Print only values print ("*"*10) for x in d1.values(): print(x) #Example 4 Print only key...
true
f38bd5b4882bd3787e78bcb653ca07d48b1f7093
Kumar1998/github-upload
/python1.py
573
4.3125
4
height=float(input("Enter height of the person:")) weight=float(input("Enter weight of the person:")) # the formula for calculating bmi bmi=weight/(height**2) print("Your BMI IS:{0} and you are:".format(bmi),end='') #conditions if(bmi<16): print("severly underweight") elif(bmi>=16 and bmi<18.5): print(...
true
98f763bd336731f8fa0bd853d06c059dd88d8ca7
septhiono/redesigned-meme
/Day 2 Tip Calculator.py
316
4.1875
4
print('Welcome to the tip calculator') bill = float(input('What was the total bill? $')) tip= float(input('What percentage tip would you like to give? ')) people = float(input("How many people split the bill? ")) pay= bill*(1+tip/100)/people pay=float(pay) print("Each person should pay: $",round(pay,2))
true
fea4e23725b61f8dd4024b2c52065870bbba6da1
rugbyprof/4443-2D-PyGame
/Resources/R02/Python_Introduction/PyIntro_05.py
548
4.15625
4
# import sys # import os # PyInto Lesson 05 # Strings # - Functions # - Input from terminal # - Formatted Strings name = "NIKOLA TESLA" quote = "The only mystery in life is: why did Kamikaze pilots wear helmets?" print(name.lower()) print(name.upper()) print(name.capitalize()) print(name.title()) print(name.isalpha...
true
79d70dca2e86013310ae0691b9a8e731d26e2e75
nidhinp/Anand-Chapter2
/problem36.py
672
4.21875
4
""" Write a program to find anagrams in a given list of words. Two words are called anagrams if one word can be formed by rearranging letters to another. For example 'eat', 'ate' and 'tea' are anagrams. """ def sorted_characters_of_word(word): b = sorted(word) c = '' for character in b: c += character re...
true
a1b103fb6e85e3549090449e71ab3908a46b2e9c
nidhinp/Anand-Chapter2
/problem29.py
371
4.25
4
""" Write a function array to create an 2-dimensional array. The function should take both dimensions as arguments. Value of element can be initialized to None: """ def array(oneD, twoD): return [[None for x in range(twoD)] for x in range(oneD)] a = array(2, 3) print 'None initialized array' prin...
true
4cbcb6d66ee4b0712d064c9ad4053456e515b14b
SandipanKhanra/Sentiment-Analysis
/tweet.py
2,539
4.25
4
punctuation_chars = ["'", '"', ",", ".", "!", ":", ";", '#', '@'] #This function is used to strip down the unnecessary characters def strip_punctuation(s): for i in s: if i in punctuation_chars: s=s.replace(i,"") return s # lists of words to use #As part of the project this hypothetical .t...
true
8c79d7caeb39a173173de7e743a8e2186e2cfc0a
osirisgclark/python-interview-questions
/TCS-tataconsultancyservices2.py
344
4.46875
4
""" For this list [1, 2, 3] return [[1, 2, 3], [2, 4, 6], [3, 6, 9]] """ list = [1, 2, 3] list1 = [] list2 = [] list3 = [] for x in range(1, len(list)+1): list1.append(x) list2.append(2*x) list3.append(3*x) print([list1, list2, list3]) """ Using List Comprehensions """ print([[x, 2*x, 3*x] for x in r...
true
7cc58e0ee75580bc78c260832e940d0fd07b9e2a
minerbra/Temperature-converter
/main.py
574
4.46875
4
""" @Author: Brady Miner This program will display a temperature conversion table for degrees Celsius to Fahrenheit from 0-100 degrees in multiples of 10. """ # Title and structure for for table output print("\nCelsius to Fahrenheit") print("Conversion Table\n") print("Celsius\t Fahrenheit") for celsius in rang...
true
ec2ffda93473b99c06258761740065801e017162
saimkhan92/data_structures_python
/llfolder1/linked_list_implementation.py
1,445
4.28125
4
# add new node in the front (at thr root's side) import sys class node(): def __init__(self,d=None,n=None): self.data=d self.next=n class linked_list(node): def __init__(self,r=None,l=0): self.length=l self.root=r def add(self,d): new_node=node() ...
true
d7fb7ba1b47eb9787dc45de53dd221d75d52a05f
catterson/python-fundamentals
/challenges/02-Strings/C_interpolation.py
1,063
4.78125
5
# Lastly, we'll see how we can put some data into our strings # Interpolation ## There are several ways python lets you stick data into strings, or combine ## them. A simple, but very powerful approach is to us the % operator. Strings ## can be set up this way to present a value we didn't know when we defined the ## s...
true
dc0755a55ce75ca7b9b98acb9d32c4c04663b834
glennlopez/Python.Playground
/SANDBOX/python3/5_loops_branches/break_continue.py
332
4.28125
4
starting = 0 ending = 20 current = starting step = 6 while current < ending: if current + step > ending: # breaks out of loop if current next step is larger than ending break if current % 2: # skips the while loop if number is divisible by 2 continue current += step pri...
true
4f619614442506f1567eb9ecc0de6c989f0c2c21
ashburnere/data-science-with-python
/python-for-data-science/1-2-Strings.py
2,344
4.28125
4
'''Table of Contents What are Strings? Indexing Negative Indexing Slicing Stride Concatenate Strings Escape Sequences String Operations ''' # Use quotation marks for defining string "Michael Jackson" # Use single quotation marks for defining string 'Michael Jackson' # Digitals and spaces in string '1 2...
true
d86edccc25b0e5e6aebddb9f876afd3219c58a65
ashburnere/data-science-with-python
/python-for-data-science/4-3-Loading_Data_and_Viewing_Data_with_Pandas.py
2,038
4.25
4
'''Table of Contents About the Dataset Viewing Data and Accessing Data with pandas ''' '''About the Dataset The table has one row for each album and several columns artist - Name of the artist album - Name of the album released_year - Year the album was released length_min_sec - Length of the album (hours,...
true
a016c597b8fc5f70e2ab5d861b756d347282289d
jourdy345/2016spring
/dataStructure/2016_03_08/fibonacci.py
686
4.125
4
def fib(n): if n <= 2: return 1 else: return fib(n - 1) + fib(n - 2) # In python, the start of a statement is marked by a colon along with an indentation in the next line. def fastFib(n): a, b = 0, 1 for k in range(n): a, b = b, a+b # the 'a' in the RHS is not the one in the RHS. Python distinguis...
true
be9b1b682cc8b1f6190fead9c3441ce72f512cf4
Nathan-Dunne/Twitter-Data-Sentiment-Analysis
/DataFrameDisplayFormat.py
2,605
4.34375
4
""" Author: Nathan Dunne Date last modified: 16/11/2018 Purpose: Create a data frame from a data set, format and sort said data frame and display data frame as a table. """ import pandas # The pandas library is used to create, format and sort a data frame. # ...
true
bfd6a6a1ce1a215bd6e698e732194b26fd0ec7b4
tjnelson5/Learn-Python-The-Hard-Way
/ex15.py
666
4.1875
4
from sys import argv # Take input from command line and create two string variables script, filename = argv # Open the file and create a file object txt = open(filename) print "Here's your file %r:" % filename # read out the contents of the file to stdout. This will read the whole # file, because the command ends a...
true
6b9281109f10fd0d69dfc54ce0aa807f9592109a
xy008areshsu/Leetcode_complete
/python_version/intervals_insert.py
1,267
4.125
4
""" Given a set of non-overlapping intervals, insert a new interval into the intervals (merge if necessary). You may assume that the intervals were initially sorted according to their start times. Example 1: Given intervals [1,3],[6,9], insert and merge [2,5] in as [1,5],[6,9]. Example 2: Given [1,2],[3,5],[6,7],[8,...
true
7e3a1b29b321ff31e6e635d825ddcfb1668aeb5c
xy008areshsu/Leetcode_complete
/python_version/dp_unique_path.py
1,531
4.15625
4
""" A robot is located at the top-left corner of a m x n grid (marked 'Start' in the diagram below). The robot can only move either down or right at any point in time. The robot is trying to reach the bottom-right corner of the grid (marked 'Finish' in the diagram below). How many possible unique paths are there? A...
true
c20802ed076df2adc4c4b430f6761742487d37a7
samluyk/Python
/GHP17.py
900
4.46875
4
# Step 1: Ask for weight in pounds # Step 2: Record user’s response weight = input('Enter your weight in pounds: ') # Step 3: Ask for height in inches # Step 4: Record user’s input height = input('Enter your height in inches: ') # Step 5: Change “string” inputs into a data type float weight_float = float(weight) height...
true
0448e9274de805b9dec8ae7689071327677a6abb
wxhheian/hpip
/ch7/ex7_1.py
641
4.25
4
# message = input("Tell me something, and I will repeat it back to you: ") # print(message) # # name = input("Please enter your name: ") # print("Hello, " + name + "!") # prompt = "If you tell us who you are,we can personalize the messages you see." # prompt += "\nWhat is your first name? " # # name = input(prompt) # ...
true
856461a845a16813718ace33b8d2d5782b0d7914
JapoDeveloper/think-python
/exercises/chapter6/exercise_6_3.py
1,891
4.40625
4
""" Think Python, 2nd Edition Chapter 6 Exercise 6.3 Description: A palindrome is a word that is spelled the same backward and forward, like “noon” and “redivider”. Recursively, a word is a palindrome if the first and last letters are the same and the middle is a palindrome. The following are functions that take a...
true
6ffba84aafcdb3a4491c8268cba8ea1e2adfdf1e
JapoDeveloper/think-python
/exercises/chapter6/exercise_6_2.py
951
4.3125
4
""" Think Python, 2nd Edition Chapter 6 Exercise 6.2 Description: The Ackermann function, A(m,n), is defined: n + 1 if m = 0 A(m,n) = A(m-1, 1) if m > 0 and n = 0 A(m-1, A(m,n-1)) if m > 0 and n > 0 See http://en.wikipedia.org/wiki/Ackermann_function. Write a function named ac...
true
508a885f71292a801877616a7e8132902d1af6c5
JapoDeveloper/think-python
/exercises/chapter6/exercise_6_4.py
643
4.3125
4
""" Think Python, 2nd Edition Chapter 6 Exercise 6.4 Description: A number, a, is a power of b if it is divisible by b and a/b is a power of b. Write a function called is_power that takes parameters a and b and returns True if a is a power of b. Note: you will have to think about the base case. """ def is_power(a...
true
8c5faf13fe2952f33dd45000bf56e87bd1a0747e
Shubham1304/Semester6
/ClassPython/4.py
711
4.21875
4
#31st January class #string operations s='hello' print (s.index('o')) #exception if not found #s.find('a') return -1 if not found #------------------check valid name------------------------------------------------------------------------------------- s='' s=input("Enter the string") if(s.isalpha()): print ("Valid ...
true
b896f3577f80daaf46e56a70b046aecacf2288cb
sukirt01/Python-for-Beginners-Solve-50-Exercises-Live
/17.py
718
4.375
4
''' Write a version of a palindrome recognizer that also accepts phrase palindromes such as "Go hang a salami I'm a lasagna hog.", "Was it a rat I saw?", "Step on no pets", "Sit on a potato pan, Otis", "Lisa Bonet ate no basil", "Satan, oscillate my metallic sonatas", "I roamed under it as a tired nude Maori", "Rise t...
true
40589034a276810b9b22c31ca519399df66bd712
sukirt01/Python-for-Beginners-Solve-50-Exercises-Live
/02.py
277
4.125
4
''' Define a function max_of_three() that takes three numbers as arguments and returns the largest of them. ''' def max_of_three(a,b,c): if a>b and a>c: print a elif b>c and b>a: print b else: print c print max_of_three(0,15,2)
true
fc24e9ff6df3c2d766e719892fae9426e33f81f6
Isonzo/100-day-python-challenge
/Day 8/prime_number_checker.py
460
4.15625
4
def prime_checker(number): if number == 0 or number == 1: print("This number is neither prime nor composite") return prime = True for integer in range(2, number): if number % integer == 0: prime = False break if prime: print("It's a...
true
6e8ac25e465a4c45f63af8334094049c0b660c4b
IrisCSX/LeetCode-algorithm
/476. Number Complement.py
1,309
4.125
4
""" Promblem: Given a positive integer, output its complement number. The complement strategy is to flip the bits of its binary representation. Note: The given integer is guaranteed to fit within the range of a 32-bit signed integer. You could assume no leading zero bit in the integer’s binary representation. Example...
true
124f02540d0b7712a73b5d2e2e03868ac809b791
anikaator/CodingPractice
/Datastructures/HashMap/Basic/Python/main.py
687
4.15625
4
def main(): # Use of dict contacts = {} contacts['abc'] = 81 contacts['pqr'] = 21 contacts['xyz'] = 99 def print_dict(): for k,v in contacts.items(): print 'dict[', k, '] = ', v print("Length of dict is %s" % len(contacts)) print("Dict contains:") print_dic...
true
e2350657520b17cc90a0fb9406a4cc6f99cee53a
CookieComputing/MusicMaze
/MusicMaze/model/data_structures/Queue.py
1,532
4.21875
4
from model.data_structures.Deque import Deque class Queue: """This class represents a queue data structure, reinvented out of the wheel purely for the sake of novelty.""" def __init__(self): """Constructs an empty queue.""" self._deque = Deque() def peek(self): """Peek at the...
true
9bc3ae714f881fd44890ed63429dc9bc4de89b5c
codewithgauri/HacktoberFest
/python/Learning Files/10-List Data Type , Indexing ,Slicing,Append-Extend-Insert-Closer look at python data types.py
1,129
4.28125
4
l=[10,20,22,30,40,50,55] # print(type(l)) # 1 Lists are mutable = add update and delete # 2 Ordered = indexing and slicing # 3 Hetrogenous # indexing and slicing: # print(l[-1]) # print(l[1:3]) #end is not inclusive # reverse a Lists # print(l[::-1]) # if you want to iterate over alternate characters # for value in l...
true
453eb80f8c7d3c8353c7288f4beea8e3f7e0c1c5
codewithgauri/HacktoberFest
/python/Cryptography/Prime Numbers/naive_primality_test.py
576
4.21875
4
##Make sure to run with Python3 . Python2 will show issues from math import sqrt from math import floor def is_prime(num): #numbers smaller than 2 can not be primes if num<=2: return False #even numbers can not be primes if num%2==0: return False #we have already checked numbers < 3 #finding primes up to N we...
true
51d1cb5a523fa102734d50143a3b9eab17faf2cb
codewithgauri/HacktoberFest
/python/Learning Files/13-Dictionary Data Types , Storing and Accessing the data in dictionary , Closer look at python data types.py.py
1,580
4.3125
4
# dict: # 1. mutable # 2.unordered= no indexing and slicing # 3.key must be unque # 4.keys should be immutable # 5. the only allowed data type for key is int , string , tuple # reason mutable data type is not allowed # for example # d={"emp_id":101 , [10,20,30]:100,[10,20]:200} # if we add an element into [10,20] of 30...
true
2725b85849ce224e97685919f148cc9807e60d83
bdngo/math-algs
/python/checksum.py
1,155
4.21875
4
from typing import List def digit_root(n: int, base: int=10) -> int: """Returns the digital root for an integer N.""" assert type(n) == 'int' total = 0 while n: total += n % base n //= base return digit_root(total) if total >= base else total def int_to_list(n: int, base: int=10) ...
true
52c44bf0aa15ba0bfcc1abda81fffefba6be075c
DistantThunder/learn-python
/ex33.py
450
4.125
4
numbers = [] # while i < 6: # print("At the top i is {}".format(i)) # numbers.append(i) # # i = i + 1 # print("Numbers now: ", numbers) # print("At the bottom i is {}\n{}".format(i, '-')) def count_numbers(count): count += 1 for i in range(0, count): numbers.append(i) return 0...
true
1fe48d3656b9437f43b79afa4ba5d9f2ffe13c2f
adamfitzhugh/python
/kirk-byers/Scripts/Week 1/exercise3.py
942
4.375
4
#!/usr/bin/env python """Create three different variables: the first variable should use all lower case characters with underscore ( _ ) as the word separator. The second variable should use all upper case characters with underscore as the word separator. The third variable should use numbers, letters, and undersco...
true
d925d4b637199ad159b36b33dcb0438ccca0f95a
adamfitzhugh/python
/kirk-byers/Scripts/Week 5/exercise3.py
1,788
4.15625
4
""" Similar to lesson3, exercise4 write a function that normalizes a MAC address to the following format: 01:23:45:67:89:AB This function should handle the lower-case to upper-case conversion. It should also handle converting from '0000.aaaa.bbbb' and from '00-00-aa-aa-bb-bb' formats. The function should have one...
true
2c9a6858ef76026d57e96ce85724e7c062e657d5
nileshmahale03/Python
/Python/PythonProject/5 Dictionary.py
1,487
4.21875
4
""" Dictionary: 1. Normal variable holds 1 value; dictionary holds collection of key-value pairs; all keys must be distinct but values may be repeated 2. {} - curly bracket 3. Unordered 4. Mutable 5. uses Hashing internally 6. Functions: 1. dict[] : returns value at specified index 2. len() ...
true
e3f5d349f45c8d01cd939727a9bbd644ddaa0bdd
changjunxia/auto_test_example1
/test1.py
228
4.125
4
def is_plalindrome(string): string = list(string) length = len(string) left = 0 right = length - 1 while left < right: if string[left] != string[right]: return False left += 1 right -= 1 return True
true
a1a7e5faad35847f22301b117952e223857d951a
nestorsgarzonc/leetcode_problems
/6.zigzag_convertion.py
1,459
4.375
4
""" The string "PAYPALISHIRING" is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed font for better legibility) P A H N A P L S I I G Y I R And then read line by line: "PAHNAPLSIIGYIR" Write the code that will take a string and make this conve...
true
e2349b63116bb7f3e83aa436c41175efda4a8d9d
llNeeleshll/Python
/section_3/string_play.py
290
4.15625
4
text = "This is awesome." # Getting the substring print(text[8:]) print(text[0:4]) # text[start:end:step] print(text[0:14:2]) print(text[0::2]) # Reversing the string print(text[::-1]) # Print a word 10 times? print("Hello " * 10) print("Hello " * 10 + "World!") print("awe" in text)
true
2690856645451099474cbed49d688a0fecd653f4
KaviyaMadheswaran/laser
/infytq prev question.py
408
4.15625
4
Ex 20) 1:special string reverse Input Format: b@rd output Format: d@rb Explanation: We should reverse the alphabets of the string by keeping the special characters in the same position s=input() alp=[] #index of char ind=[] for i in range(0,len(s)): if(s[i].isalpha()): alp.append(s[i]) else: ind.append(i) rev=alp...
true
50e3bc5493956708bf1897a74600cd9639777bf8
KaviyaMadheswaran/laser
/w3 resource.py
403
4.1875
4
Write a Python program to split a given list into two parts where the length of the first part of the list is given. Go to the editor Original list: [1, 1, 2, 3, 4, 4, 5, 1] Length of the first part of the list: 3 Splited the said list into two parts: ([1, 1, 2], [3, 4, 4, 5, 1]) n=int(input()) l=list(map(int,input().s...
true
5539d4170fa7ecc1a9a97ba4aa3ed2f23650bd1a
KaviyaMadheswaran/laser
/Birthday Cake candle(Hackerrank).py
490
4.125
4
Output Format Return the number of candles that can be blown out on a new line. Sample Input 0 4 3 2 1 3 Sample Output 0 2 Explanation 0 We have one candle of height 1, one candle of height 2, and two candles of height 3. Your niece only blows out the tallest candles, meaning the candles where height = 3. ...
true
a5ed73ac78f673fa965b551bef169860cd38a658
timclaussen/Python-Examples
/OOPexample.py
441
4.25
4
#OOP Example #From the simple critter example, but with dogs class Dog(object): """A virtual Dog""" total = 0 def _init_(self, name): print("A new floof approaches!") Dog.total += 1 #each new instance adds 1 to the class att' total self.name = name #sets the constructor inp...
true
7ca7a468dcc8aea1cc45757f9430b5fa0c0d736f
JuanHernandez2/Ormuco_Test
/Ormuco/Strings comparator/comparator.py
1,188
4.25
4
import os import sys class String_comparator: """ Class String comparator to compare two strings and return which is greater, less or equal than the other one. Attributes: string_1: String 1 string_2: String 2 """ def __init__(self, s1, s2): """ Class constr...
true
1ed4ea179560b5feec261b094bdbe5b2848b4e03
Sharmaanuj10/Phase1-basics-code
/python book/book projects 1/4-7/input while loop/flag.py
321
4.1875
4
active = True print("if you want to quit type quit") while active: message = input("Enter your message: ") if message == 'quit': # break # to break the loop here active = False #comtinue # to execute left over code exiting the if else: print(message) ...
true
0227e6263035a7b7e6cf67dadde3eb91576afc0b
Sharmaanuj10/Phase1-basics-code
/python book/book projects 1/4-7/input while loop/deli.py
710
4.28125
4
user_want = {} # fistly define a dictonairy empty poll_active = True while poll_active: name = input('Enter your name: ') want = input('if you visit one place in the world where you visit? ') repeat = input('waant to know others wnats (yes,no)? ') # after input store the data at dictionar...
true
8592b3147c28ef1b09589c048dfa30e0eb87aa5a
Sharmaanuj10/Phase1-basics-code
/python book/Python/password.py/password 1.5.py/password1.5.py
1,287
4.28125
4
name = input("Enter your username: ") passcode = input("Enter you password: ") # upper is used to capatilize the latter name = name.upper() # all the password saved def webdata(): webdata= input("Enter the key word : ") user_passwords = { 'youtube' : 'subscribe', # here now you can save...
true
213ebf4489f815cf959de836a11e2339ca8bcfaa
rsleeper1/Week-3-Programs
/Finding Max and Min Values Recursively.py
2,148
4.21875
4
#Finding Max and Min Values #Ryan Sleeper def findMaxAndMin(sequence): #This method finds the max and min values of a sequence of numbers. if len(sequence) < 2: #This catches a sequence that doesn't have enough numbers to compare (less than 2) and returns the invalid sequence. print("Ple...
true
d075b9df570b98066efa80959ee3d102bca91614
chigozieokoroafor/DSA
/one for you/code.py
259
4.28125
4
while True: name = input("Name: ") if name == "" or name==" ": print("one for you, one for me") raise Exception("meaningful message required, you need to put a name") else: print(f"{name} : one for {name}, one for me")
true
28e8f771a7968081d3ced6b85ddec657163ad7d1
avi527/Tuple
/different_number_arrgument.py
248
4.125
4
#write a program that accepts different number of argument and return sum #of only the positive values passed to it. def sum(*arg): tot=0 for i in arg: if i>0: tot +=i return tot print(sum(1,2,3,-4,-5,9))
true
711646003de502ae59915ebcd3fff47b56b0144d
Wh1te-Crow/algorithms
/sorting.py
1,318
4.21875
4
def insertion_sorting(array): for index in range(1,len(array)): sorting_part=array[0:index+1] unsorting_part=array[index+1:] temp=array[index] i=index-1 while(((i>0 or i==0) and array[i]>temp)): sorting_part[i+1]=sorting_part[i] sorting_part[i]=temp ...
true
ba0bf77d3202493747e94c0a686c739d6cb98e9f
srisreedhar/Mizuho-Python-Programming
/Session-18-NestedConditionals/nestedif.py
510
4.1875
4
# ask user to enter a number between 1-5 and print the number in words number=input("Enter a number between 1-5 :") number=int(number) # if number == 1: # print("the number is one") # else: # print("its not one") # Nested conditions if number==1: print("number is one") elif number==2: print("num...
true
04c4b07e6e7e980e7d759aff14ce51d38fa89413
davelpat/Fundamentals_of_Python
/Ch2 exercises/employeepay.py
843
4.21875
4
""" An employee’s total weekly pay equals the hourly wage multiplied by the total number of regular hours, plus any overtime pay. Overtime pay equals the total overtime hours multiplied by 1.5 times the hourly wage. Write a program that takes as inputs the hourly wage, total regular hours, and total overtime hours an...
true
d5367ee9332da2c450505cb454e4e8dac87b2bf8
davelpat/Fundamentals_of_Python
/Student_Files/ch_11_student_files/Ch_11_Student_Files/testquicksort.py
1,817
4.15625
4
""" File: testquicksort.py Tests the quicksort algorithm """ def quicksort(lyst): """Sorts the items in lyst in ascending order.""" quicksortHelper(lyst, 0, len(lyst) - 1) def quicksortHelper(lyst, left, right): """Partition lyst, then sort the left segment and sort the right segment.""" if left ...
true
1a7183d7758f27abb21426e84019a9ceeb5da7c7
davelpat/Fundamentals_of_Python
/Ch3 exercises/right.py
1,344
4.75
5
""" Write a program that accepts the lengths of three sides of a triangle as inputs. The program output should indicate whether or not the triangle is a right triangle. Recall from the Pythagorean theorem that in a right triangle, the square of one side equals the sum of the squares of the other two sides. Use "The t...
true
82808ac569c685a2b864fd668edebbb7264cd07d
davelpat/Fundamentals_of_Python
/Ch9 exercises/testshapes.py
772
4.375
4
""" Instructions for programming Exercise 9.10 Geometric shapes can be modeled as classes. Develop classes for line segments, circles, and rectangles in the shapes.py file. Each shape object should contain a Turtle object and a color that allow the shape to be drawn in a Turtle graphics window (see Chapter 7 for detai...
true
f9a84cff7e4e9c4a92167506a09fcf09726ecfc1
davelpat/Fundamentals_of_Python
/Ch3 exercises/salary.py
1,387
4.34375
4
""" Instructions Teachers in most school districts are paid on a schedule that provides a salary based on their number of years of teaching experience. For example, a beginning teacher in the Lexington School District might be paid $30,000 the first year. For each year of experience after this first year, up to 10 ye...
true
2ee467b7f70e740bce32e857df97bd311034e494
davelpat/Fundamentals_of_Python
/Ch4 exercises/decrrypt-str.py
1,106
4.5625
5
""" Instructions for programming Exercise 4.7 Write a script that decrypts a message coded by the method used in Project 6. Method used in project 6: Add 1 to each character’s numeric ASCII value. Convert it to a bit string. Shift the bits of this string one place to the left. A single-space character in the encrypt...
true
5b3f98828c1aa52309d9450094ecb3ab990bae91
davelpat/Fundamentals_of_Python
/Ch4 exercises/encrypt-str.py
1,246
4.53125
5
""" Instructions for programming Exercise 4.6 Use the strategy of the decimal to binary conversion and the bit shift left operation defined in Project 5 to code a new encryption algorithm. The algorithm should Add 1 to each character’s numeric ASCII value. Convert it to a bit string. Shift the bits of this string on...
true
8b70613ee7350c54156a4eb076f11b82356055f7
davelpat/Fundamentals_of_Python
/Ch3 exercises/population.py
1,828
4.65625
5
""" Instructions A local biologist needs a program to predict population growth. The inputs would be: The initial number of organisms The rate of growth (a real number greater than 1) The number of hours it takes to achieve this rate A number of hours during which the population grows For example, one might start wi...
true
d4a8cd543636b4375918bfe64430df051604c4da
nachoaz/Data_Structures_and_Algorithms
/Stacks/balanced_brackets.py
745
4.15625
4
# balanced_brackets.py """ https://www.hackerrank.com/challenges/balanced-brackets """ from stack import Stack def is_balanced(s): if len(s) % 2 == 1: return 'NO' else: stack = Stack() counterparts = {'{':'}', '[':']', '(':')'} for char in s: if char in c...
true
15198370140d3b04074d6647eda200767cc2479d
rahulpawargit/UdemyCoursePractice
/Tuples.py
290
4.1875
4
""" Tuples are same as list. The diffferance between list and tuples. Tuples are unmutalble. Tuples add using parenthesis """ my_tuple=(1, 2, 3, 4,3, 3, 3) print(my_tuple) print(my_tuple[1]) print(my_tuple[1:]) print(my_tuple[::-1 ]) print(my_tuple.index(3)) print((my_tuple.count(3)))
true
f7ec1c0eca2e27e733473040f284640f75c37a80
flahlee/Coding-Dojo
/pythonFundamentals/string_list.py
586
4.125
4
#find and replace words = "It's thanksgiving day. It's my birthday, too!" day = 'day' print words.find(day) print words.replace(day, "month") #min and max x = [2,54,-2,7,12,98] print min(x) print max(x) #first and last x = ["hello", 2, 54, -2, 7, 12, 98, "world"] newX= [x[0],x[7]] print newX #new list '''sort list f...
true
75f2c8f77f19883b41af604e0bb70318243efcd5
Sameer19A/Python-Basics
/HelloWorld.py
243
4.28125
4
#Compulsory Task 3 name = input("Enter your name: ") age = input("Enter your age: ") print(name) #prints user entered name print(age) #prints user entered age print("") #prints a new empty line print("Hello World!")
true
286cb30b15f984cb922dc229773e6e2eda569ddd
Shreyasi2002/CODE_IN_PLACE_experience
/Section2-Welcome to python/8ball.py
954
4.1875
4
""" Simulates a magic eight ball. Prompts the user to type a yes or no question and gives a random answer from a set of prefabricated responses. """ import random RESPONSES = ["As I see it, yes.", "Ask again later.", "Better not to tell you now." , "Cannot predict now.", "Concentrate and ask again.", "Don't count on i...
true