blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
15e022eb2fbc2d17ee9dd7787a5c301d43dbb89a
GitLeeRepo/PythonNotes
/basics/sort_ex1.py
777
4.59375
5
#!/usr/bin/python3 # Examples of using the sorted() function # example function to be used as key by sorted function def sortbylen(x): return len(x) # List to sort, first alphabetically, then by length a = [ 'ccc', 'aaaa', 'd', 'bb'] # Orig list print(a) # Sorted ascending alphabetic print(sorted(a)) # sorte...
true
8da7f3ba63ae287850cb95fdaf6991da36855947
GitLeeRepo/PythonNotes
/basics/python_sandbox01.py
1,833
4.1875
4
#!/usr/bin/python3 # Just a sandbox app to explore different Python features and techniques for learning purposes import sys def hello(showPrompt=True): s = "Hello World!" print (s) #using slice syntax below print (s[:5]) #Hello print (s[6:-1]) #World print (s[1:8]) #ello wo print (s[1:-4]...
true
66d407d714258a6aceea8e800a10ba5994af040a
ecastillob/project-euler
/101 - 150/112.py
1,846
4.40625
4
#!/usr/bin/env python # coding: utf-8 """ Working from left-to-right if no digit is exceeded by the digit to its left it is called an increasing number; for example, 134468. Similarly if no digit is exceeded by the digit to its right it is called a decreasing number; for example, 66420. We shall call a positive ...
true
3ef7c91a7f379e5b8f4f328c0e79a9238d6bce08
aaryanredkar/prog4everybody
/project 2.py
327
4.3125
4
first_name = input("Please enter your first name: ") last_name = input("Please enter your last name: ") full_name = first_name +" " +last_name print("Your first name is:" + first_name) print("Your last name is:" + last_name) print ("Your complete name is ", full_name) print("Your name is",len(full_name) ,"characters ...
true
6cd1676e716a609f138136b027cbe6655c7292a4
obrienadam/APS106
/week5/palindrome.py
1,178
4.21875
4
def is_palindrome(word): return word[::-1] == word if __name__ == '__main__': word = input('Enter a word: ') if is_palindrome(word): print('The word "{}" is a palindrome!'.format(word)) else: print('The word "{}" is not a palindrome.'.format(word)) phrase = input('What would you li...
true
e65ff801f6792b85f1878d3520b994f2e9dfa682
Ernestbengula/python
/kim/Task3.py
269
4.25
4
# Given a number , check if its pos,Neg,Zero num1 =float(input("Your Number")) #Control structures -Making decision #if, if else,elif if num1>0: print("positive") elif num1==0 : print("Zero") elif num1<0: print(" Negative") else: print("invalid")
true
4359dd4f67584016be61c50548e51c8117ee2bc7
xpbupt/leetcode
/Medium/Complex_Number_Multiplication.py
1,043
4.15625
4
''' Given two strings representing two complex numbers. You need to return a string representing their multiplication. Note i2 = -1 according to the definition. Example 1: Input: "1+1i", "1+1i" Output: "0+2i" Explanation: (1 + i) * (1 + i) = 1 + i2 + 2 * i = 2i, and you need convert it to the form of 0+2i. Example 2:...
true
edace158002f255b7bbfd8d5708575912ab065d9
Varsha1230/python-programs
/ch4_list_and_tuples/ch4_lists_and_tuples.py
352
4.1875
4
#create a list using[]--------------------------- a=[1,2,4,56,6] #print the list using print() function----------- print(a) #Access using index using a[0], a[1], a[2] print(a[2]) #change the value of list using------------------------ a[0]=98 print(a) #we can also create a list with items of diff. data types c=[45,...
true
c43b35b690a329f582683f9b406a66c826e5cabf
Varsha1230/python-programs
/ch3_strings/ch3_prob_01.py
435
4.3125
4
#display a user entered name followed by Good Afternoon using input() function-------------- greeting="Good Afternoon," a=input("enter a name to whom you want to wish:") print(greeting+a) # second way------------------------------------------------ name=input("enter your name:") print("Good Afternoon," +name) #---...
true
5b3ef497693bc27e3d5fee58a9a77867b8f18811
Varsha1230/python-programs
/ch11_inheritance.py/ch11_1_inheritance.py
731
4.125
4
class Employee: #parent/base class company = "Google" def showDetails(self): print("this is an employee") class Programmer(Employee): #child/derived class language = "python" # company = "YouTube" def getLanguage(self): print("the language is {self.language}") def s...
true
c25ee297552465456ca50c12ce5df934c9d399bf
IsaacMarovitz/ComputerSciencePython
/MontyHall.py
2,224
4.28125
4
# Python Homework 11/01/20 # In the Monty Hall Problem it is benefical to switch your choice # This is because, if you switch, you have a rougly 2/3 chance of # Choosing a door, becuase you know for sure that one of the doors is # The wrong one, otherwise if you didnt switch you would still have the # same 1/3 chance...
true
155a6195c974de35a6de43dffe7f1d2065d40787
IsaacMarovitz/ComputerSciencePython
/Conversation2.py
1,358
4.15625
4
# Python Homework 09/09/2020 # Inital grade 2/2 # Inital file Conversation.py # Modified version after inital submisions, with error handeling and datetime year # Importing the datetime module so that the value for the year later in the program isn't hardcoded import datetime def userAge(): global user_age us...
true
774ce49dd157eca63ab05d74c0d542dd33b4f14a
Nyame-Wolf/snippets_solution
/codewars/Write a program that finds the summation of every number between 1 and num if no is 3 1 + 2.py
629
4.5
4
Summation Write a program that finds the summation of every number between 1 and num. The number will always be a positive integer greater than 0. For example: summation(2) -> 3 1 + 2 summation(8) -> 36 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 tests test.describe('Summation') test.it('Should return the correct t...
true
62ef143a7d1a7dd420ad2f2f4b8a4ec9dda89f4f
DanielOram/simple-python-functions
/blueberry.py
2,627
4.625
5
#Author: Daniel Oram #Code club Manurewa intermediate #This line stores all the words typed from keyboard when you press enter myString = raw_input() #Lets print out myString so that we can see proof of our awesome typing skills! #Try typing myString between the brackets of print() below print() #With our stri...
true
15cc2f889516a57be1129b8cad373084222f2c30
viniciuschiele/solvedit
/strings/is_permutation.py
719
4.125
4
""" Explanation: Permutation is all possible arrangements of a set of things, where the order is important. Question: Given two strings, write a method to decide if one is a permutation of the other. """ from unittest import TestCase def is_permutation(s1, s2): if not s1 or not s2: return False if ...
true
9332ac35cb63d27f65404bb86dfc6370c919c2be
viniciuschiele/solvedit
/strings/is_permutation_of_palindrome.py
1,117
4.125
4
""" Explanation: Permutation is all possible arrangements of a set of things, where the order is important. Palindrome is a word or phrase that is the same forwards and backwards. A string to be a permutation of palindrome, each char must have an even count and at most one char can have an odd count. Question: Given ...
true
7de1ba91ebbb95ade3f54e652560b2c65369b1e3
Pasquale-Silv/Improving_Python
/Python Programming language/DataCampPractice/Corso_CISCO_netacad/Strings_in_Python/s8_center_method.py
720
4.25
4
# The one-parameter variant of the center() method makes a copy of the original string, # trying to center it inside a field of a specified width. # The centering is actually done by adding some spaces before and after the string. # Demonstrating the center() method print('[' + 'alpha'.center(10) + ']') print('[' + 'B...
true
27598f79de97818823527e23f3969c27959f8702
Pasquale-Silv/Improving_Python
/Python Programming language/DataCampPractice/Corso_CISCO_netacad/Strings_in_Python/s15_split.py
617
4.46875
4
# The # split() # method does what it says - it splits the string and builds a list of all detected substrings. # The method assumes that the substrings are delimited by whitespaces - the spaces don't take part in the operation, # and aren't copied into the resulting list. # If the string is empty, the resulting list i...
true
0c10af8575d97394bbcb9c2363a82fe424df2bd0
Pasquale-Silv/Improving_Python
/Python Programming language/DataCampPractice/Corso_CISCO_netacad/integers_octal_exadecimal.py
1,053
4.53125
5
# If an integer number is preceded by an 0O or 0o prefix (zero-o), # it will be treated as an octal value. This means that the number must contain digits taken from the [0..7] range only. # 0o123 is an octal number with a (decimal) value equal to 83. print(0o123) # The second convention allows us to use hexadecimal n...
true
fd80e5cecb0c723cf52c16e6b112648476b37388
Pasquale-Silv/Improving_Python
/Python Programming language/DataCampPractice/Python_Data_Science_Toolbox_Part1/Nested_Functions/NestedFunc1.py
548
4.1875
4
# Define three_shouts def three_shouts(word1, word2, word3): """Returns a tuple of strings concatenated with '!!!'.""" # Define inner def inner(word): """Returns a string concatenated with '!!!'.""" return word + '!!!' # Return a tuple of strings return (inner(word1), inner(wor...
true
15d42320cb2c5217991e7b6202330c9e5e5fa414
Pasquale-Silv/Improving_Python
/Python Programming language/DataCampPractice/Corso_CISCO_netacad/Strings_in_Python/s7.py
458
4.4375
4
# Demonstrating the capitalize() method print('aBcD'.capitalize()) print("----------------------") # The endswith() method checks if the given string ends with the specified argument and returns True or False, # depending on the check result. # Demonstrating the endswith() method if "epsilon".endswith("on"): prin...
true
a959f8c5d7ec65d50fea6f6ca640524a04e13501
Pasquale-Silv/Improving_Python
/Python Programming language/DataCampPractice/Regular_Expressions_in_Python/Positional_String_formatting/Positional_formatting1.py
812
4.15625
4
# positional formatting ------> .format() wikipedia_article = 'In computer science, artificial intelligence (AI), sometimes called machine intelligence, ' \ 'is intelligence demonstrated by machines, ' \ 'in contrast to the natural intelligence displayed by humans and anima...
true
968bee9c854610fd5799d875dae04d4227c74cfe
Pasquale-Silv/Improving_Python
/Python Programming language/DataCampPractice/Functions and packages/PackagesInPython/MathPackageInPython.py
653
4.34375
4
""" As a data scientist, some notions of geometry never hurt. Let's refresh some of the basics. For a fancy clustering algorithm, you want to find the circumference, C, and area, A, of a circle. When the radius of the circle is r, you can calculate C and A as: C=2πr A=πr**2 To use the cons...
true
100d7f48a899c20b52ee5479eccd7422a87aa667
Pasquale-Silv/Improving_Python
/Python Programming language/DataCampPractice/Python_Lists/Python_Lists11.py
707
4.125
4
# you can also remove elements from your list. You can do this with the del statement: # Pay attention here: as soon as you remove an element from a list, the indexes of the elements that come after the deleted element all change! x = ["a", "b", "c", "d"] print(x) del(x[1]) # del statement print(x) ...
true
1ff840fef8bc267fcf37268800d9bd29dd86f521
Pasquale-Silv/Improving_Python
/Python Programming language/DataCampPractice/Python_Data_Science_Toolbox_Part2/Generators_and_GENfunc_yield/GEN2.py
462
4.34375
4
# [ LIST COMPREHENSION ] # ( GENERATOR ) # Recall that generator expressions basically have the same syntax as list comprehensions, # except that it uses parentheses () instead of brackets [] # Create generator object: result result = (num for num in range(31)) # Print the first 5 values print(next(result)) print(ne...
true
6ab7b8b1135b74d6572efd98bb64f86f85e468ce
ryanmp/project_euler
/p076.py
1,263
4.15625
4
''' counting sums explanation via example: n == 5: 4 + 1 3 + 2 3 + 1 + 1 2 + 2 + 1 2 + 1 + 1 + 1 1 + 1 + 1 + 1 + 1 if sum == 5 -> there are 6 different combos ''' def main(): return 0 # how many different ways can a given number be written as a sum? # note: combinations, not permutations def count_sum_reps(n): '...
true
240066b054c327e6a05ab214ce54466ba9b39d6f
gonzrubio/HackerRank-
/InterviewPracticeKit/Dictionaries_and_Hashmaps/Sherlock_and_Anagrams.py
992
4.15625
4
"""Given a string s, find the number of pairs of substrings of s that are anagrams of each other. 1<=q<=10 - Number of queries to analyze. 2<=|s|<=100 - Length of string. s in ascii[a-z] """ def sherlockAndAnagrams(s): """Return the number (int) of anagramatic pairs. s (list) - input string """ n...
true
d1d844be30625c6e2038e0596b19c05cf9a489fa
DarioBernardo/hackerrank_exercises
/recursion/num_decodings.py
2,241
4.28125
4
""" HARD https://leetcode.com/problems/decode-ways/submissions/ A message containing letters from A-Z can be encoded into numbers using the following mapping: 'A' -> "1" 'B' -> "2" ... 'Z' -> "26" To decode an encoded message, all the digits must be grouped then mapped back into letters using the reverse of the mappi...
true
5d792080e230b43aa25835367606510d0bb63af7
feynmanliang/Monte-Carlo-Pi
/MonteCarloPi.py
1,197
4.21875
4
# MonteCarloPi.py # November 15, 2011 # By: Feynman Liang <feynman.liang@gmail.com> from random import random def main(): printIntro() n = getInput() pi = simulate(n) printResults(pi, n) def printIntro(): print "This program will use Monte Carlo techniques to generate an" print "experimental...
true
9e7d64fbc8fd69a5d56e3f65a057a2a3ce08da27
revanth465/Algorithms
/Searching Algorithms.py
1,403
4.21875
4
# Linear Search | Time Complexity : O(n) import random def linearSearch(numbers, find): for i in numbers: if(i==find): return "Found" return "Not Found" numbers = [1,3,5,23,5,23,34,5,63] find = 23 print(linearSearch(numbers,find)) # Insertion Sort | Time Complex...
true
6c82627929fa81cdd0998309ec049b8ef4d7bc86
Helen-Sk-2020/JtBr_Arithmetic_Exam_Application
/Arithmetic Exam Application/task/arithmetic.py
2,032
4.125
4
import random import math def check_input(): while True: print('''Which level do you want? Enter a number: 1 - simple operations with numbers 2-9 2 - integral squares of 11-29''') x = int(input()) if x == 1 or x == 2: return x break else: ...
true
0a6b38b73eea3f054edadbf5dc5f08ee4c524cb1
Jrjh27CS/Python-Samples
/practice-python-web/fibonacci.py
690
4.21875
4
#Challenge given by https://www.practicepython.org #Jordan Jones Apr 16, 2019 #Challenge: 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 num...
true
dcbe36488dc453401fb81abd4a01dd2fe29bcbbf
moribello/engine5_honor_roll
/tools/split_names.py
1,231
4.375
4
# Python script to split full names into "Last Name", "First Name" format #Note: this script will take a .csv file from the argument and create a new one with "_split" appended to the filename. The original file should have a single column labled "Full Name" import pandas as pd import sys def import_list(): while ...
true
86773d8aa5d642f444192ecc1336560c86d718ca
siddu1998/sem6_labs
/Cloud Computing/Assignment 1/question9.py
218
4.40625
4
# Write a Python program to find whether a given number (accept from the user) # is even or odd, print out an appropriate message to the user. n=int(input("please enter the number")) print("even" if n%2==0 else "odd")
true
316aa2bdc7e255944d154ce075592a157274c9bc
Jeremyreiner/DI_Bootcamp
/week5/Day3/daily_challenges/daily_challenge.py
2,874
4.28125
4
# Instructions : # The goal is to create a class that represents a simple circle. # A Circle can be defined by either specifying the radius or the diameter. # The user can query the circle for either its radius or diameter. # Other abilities of a Circle instance: # Compute the circle’s area # Print the circle and get ...
true
0cdc78355fca028bb19c771c343ae845b702f555
Jeremyreiner/DI_Bootcamp
/week5/Day1/Daily_challenge/daily_challenge.py
2,265
4.40625
4
# Instructions : Old MacDonald’s Farm # Take a look at the following code and output! # File: market.py # Create the code that is needed to recreate the code provided above. Below are a few questions to assist you with your code: # 1. Create a class called Farm. How should this be implemented? # 2. Does the Farm class ...
true
44971d0672295eea12f2d5f3ad8dad4faea2c47f
Bawya1098/python-Beginner
/Day3/Day3_Assignments/hypen_separated_sequence.py
273
4.15625
4
word = str(input("words to be separated by hypen:")) separated_word = word.split('-') sorted_separated_word = ('-'.join(sorted(separated_word))) print("word is: ", word) print("separated_word is:", separated_word) print("sorted_separated_word is: ", sorted_separated_word)
true
3da597b2bcdcdaf16bfa50bc86a060fa56173667
ND13/zelle_python
/chapter_2/futval.py
792
4.15625
4
#!/usr/bin/python3.6 # File: futval.py # A program that computes an investment carried 10 years into future # 2.8 Exercises: 5, 9 def main(): print("This program calculates the future value of a 10-year investment.") principal = float(input("Enter the principal amount: ")) apr = float(input("Enter the ann...
true
7482b65b788259f74c8719944618f9d856417780
ND13/zelle_python
/chapter_3/pizza.py
450
4.3125
4
# sphere_2.py # calculates the price per square inch of circular pizza using price and diameter def main(): price = float(input("Enter the price for your pizza: $")) diameter = float(input("Enter the diameter of the pizza: ")) radius = diameter / 2 area = 3.14159 * radius ** 2 price_per_sq_inch = ...
true
def2e855860ded62733aa2ddcfe4b51029a8edd2
PSReyat/Python-Practice
/car_game.py
784
4.125
4
print("Available commands:\n1) help\n2) start\n3) stop\n4) quit\n") command = input(">").lower() started = False while command != "quit": if command == "help": print("start - to start the car\nstop - to stop the car\nquit - to exit the program\n") elif command == "start": if started: ...
true
f6b50fb2c608e9990ed1e3870fd73e2039e17b3d
ananyo141/Python3
/uptoHundred.py
301
4.3125
4
#WAP to print any given no(less than 100) to 100 def uptoHundred(num): '''(num)-->NoneType Print from the given number upto 100. The given num should be less than equal to 100. >>>uptoHundred(99) >>>uptoHundred(1) ''' while(num<=100): print(num) num+=1
true
437c321c8a52c3ae13db3bfa5e48c7a5dac2c1eb
ananyo141/Python3
/gradeDistribution/functions.py
2,519
4.15625
4
# This function reads an opened file and returns a list of grades(float). def findGrades(grades_file): '''(file opened for reading)-->list of float Return a list of grades from the grades_file according to the format. ''' # Skip over the header. lines=grades_file.readline() grades_list=[]...
true
67613b888eaa088a69a0fec26f1ace376f95cbbb
ananyo141/Python3
/calListAvg.py
624
4.15625
4
# WAP to return a list of averages of values in each of inner list of grades. # Subproblem: Find the average of a list of values def calListAvg(grades): '''(list of list of num)--list of num Return the list of average of numbers from the list of lists of numbers in grades. >>> calListAvg([[5,2,4,3],[...
true
b7e98df96a4a263667a93d2ae87d397457cd0cb4
ananyo141/Python3
/addColor.py
362
4.1875
4
#WAP to input colors from user and add it to list def addColor(): '''(NoneType)-->list Return the list of colors input by the user. ''' colors=[] prompt="Enter the color you want to add, press return to exit.\n" color=input(prompt) while color!='': colors.append(color) ...
true
6ccdbdcc90fffe223051131e8b7cc1b2c5bb9341
vlytvynenko/lp
/lp_hw/ex8.py
780
4.28125
4
formatter = "{} {} {} {}" #Defined structure of formatter variable #Creating new string based on formatter structure with a new data print(formatter.format(1, 2, 3, 4)) #Creating new string based on formatter structure with a new data print(formatter.format('one', 'two', 'three', 'four')) #Creating new string based on...
true
738774b4756d730e942bcb8c88ec3801afe4b54c
legitalpha/Spartan
/Day_9_ques1_Russian_peasant_algo.py
285
4.125
4
a = int(input("Enter first number : ")) b = int(input("Enter second number : ")) count = 0 while a!=0: if a%2==1: count +=b b=b<<1 a=a>>1 if a%2==0: b=b<<1 a=a>>1 print("The product of first and second number is ",count)
true
edbbed7b9a0ebeae3e1478b4988008deed3cee2e
dgquintero/holbertonschool-machine_learning
/math/0x03-probability/binomial.py
1,951
4.125
4
#!/usr/bin/env python3 """class Binomial that represents a Binomial distribution""" class Binomial(): """ Class Binomial that calls methos CDF PDF """ def __init__(self, data=None, n=1, p=0.5): """ Class Binomial that calls methos CDF PDF """ self.n = int(n) self.p = float(p) ...
true
d5491b784640d17450cbf52b9ecd8019f5b630a7
kvanishree/AIML-LetsUpgrade
/Day4.py
1,393
4.25
4
#!/usr/bin/env python # coding: utf-8 # In[8]: #Q1 print("enter the operation to perform") a=input() if(a=='+'): c=(3+2j)+(5+4j) print(c) elif(a=='-'): c=(3+2j)-(5+4j) print(c) elif(a=='*'): c=(3+2j)*(5+4j) print(c) elif(a=='/'): c=(3+2j)/(5+4j) print(c) elif(a=='//'): print("floo...
true
45031662df9be1dafbac90323ea6b977949328f5
Jerwinprabu/practice
/reversepolish.py
596
4.34375
4
#!/usr/bin/python """ reverse polish notation evaluator Functions that define the operators and how to evaluate them. This example assumes binary operators, but this is easy to extend. """ ops = { "+" : (lambda a, b: a + b), "-" : (lambda a, b: a - b), "*" : (lambda a, b: a * b) } def eval(tokens): stack = [...
true
c5363e8be7c3e46cd35561d83880c3162f6ece0f
ataicher/learn_to_code
/careeCup/q14.py~
911
4.3125
4
#!/usr/bin/python -tt import sys def isAnagram(S1,S2): # remove white space S1 = S1.replace(' ',''); S2 = S2.replace(' ','') # check the string lengths are identical if len(S1) != len(S2): return False # set strings to lower case S1 = S1.lower(); S2 = S2.lower() # sort strings S1 = sorted(S1); S2 ...
true
9317aaa0cb94a12b89f6960525791598088003d6
HeavenRicks/dto
/primary.py
2,273
4.46875
4
#author: <author here> # date: <date here> # --------------- Section 1 --------------- # # ---------- Integers and Floats ---------- # # you may use floats or integers for these operations, it is at your discretion # addition # instructions # 1 - create a print statement that prints the sum of two numbers # ...
true
849c615ac2f77f6356650311deea9da6c32952bf
andrearus-dev/shopping_list
/myattempt.py
1,719
4.1875
4
from tkinter import * from tkinter.font import Font window = Tk() window.title('Shopping List') window.geometry("400x800") window.configure(bg="#2EAD5C") bigFont = Font(size=20, weight="bold") heading1 = Label(window, text=" Food Glorious Food \n Shopping List", bg="#2EAD5C", fg="#fff", font=bigFo...
true
026dc30173ab7427f744b000f55558ffc19099e8
glaxur/Python.Projects
/guess_game_fun.py
834
4.21875
4
""" guessing game using a function """ import random computers_number = random.randint(1,100) PROMPT = "What is your guess?" def do_guess_round(): """Choose a random number,ask user for a guess check whether the guess is true and repeat whether the user is correct""" computers_number = rand...
true
46f70133d8fc36aa8c21c51ba8cd35efd18fcfc7
MenggeGeng/FE595HW4
/hw4.py
1,520
4.1875
4
#part 1: Assume the data in the Boston Housing data set fits a linear model. #When fit, how much impact does each factor have on the value of a house in Boston? #Display these results from greatest to least. from sklearn.datasets import load_boston from sklearn.linear_model import LinearRegression import matpl...
true
9d723b583cec6a1c2ec2aea6497eec0d6dd6d27f
ageinpee/DaMi-Course
/1/Solutions/Solution-DAMI1-Part3.py
2,024
4.15625
4
''' Solution to Part III - Python functions. Comment out the parts you do not wish to execute or copy a specific function into a new py-file''' #Sum of squares, where you can simply use the square function you were given def sum_of_squares(x, y): return square(x) + square(y) print sum_of_squares(3, 5) # Try out you...
true
45fc9452f03b169869eb753bf3ffc017540dd052
sejinwls/2018-19-PNE-practices
/session-5/ex-1.py
620
4.1875
4
def count_a(seq): """"THis function is for counting the number of A's in the sequence""" # Counter for the As result = 0 for b in seq: if b == "A": result += 1 # Return the result return result # Main program s = input("Please enter the sequence: ") na = count_a(s) print...
true
e14736ccc657561a7db0a6653d64f05953b85d30
aratik711/100-python-programs
/eval_example.py
320
4.28125
4
""" Please write a program which accepts basic mathematic expression from console and print the evaluation result. Example: If the following string is given as input to the program: 35+3 Then, the output of the program should be: 38 Hints: Use eval() to evaluate an expression. """ exp = input() print(eval(exp))
true
d33e36b0734802ce63caaa7310a21ecb2b6081d6
aratik711/100-python-programs
/subclass_example.py
382
4.125
4
""" Question: Define a class named American and its subclass NewYorker. Hints: Use class Subclass(ParentClass) to define a subclass. """ class American: def printnationality(self): print("America") class NewYorker: def printcity(self): American.printnationality(self) p...
true
f7b05c070eb88efe3ea889c2d77647a6e9cf6b4d
sureshpodeti/Algorithms
/dp/slow/min_cost_path.py
1,157
4.125
4
''' Min cost path: Given a matrix where each cell has some interger value which represent the cost incurred if we visit that cell. Task is found min cost path to reach (m,n) position in the matrix from (0,0) position possible moves: one step to its right, one step down, and one step diagonally ...
true
e8019a0d7da90f1633bd139a32ca191887b08c10
naroladhar/MCA_101_Python
/mulTable.py
1,074
4.125
4
import pdb pdb.set_trace() def mulTable(num,uIndexLimit): ''' Objective : To create a multiplication table of numbers Input Variables : num : A number uIndexLimit: The size of the multiplication table Output Variables: res : The result of the product return value...
true
92aca135af4da75cb0cd32b9bfac71515384e04d
hakanguner67/class2-functions-week04
/exact_divisor.py
376
4.125
4
''' Write a function that finds the exact divisors of a given number. For example: function call : exact_divisor(12) output : 1,2,3,4,6,12 ''' #users number number = int(input("Enter a number : ")) def exact_divisor(number) : i = 1 while i <= number : # while True if ((number % i )==0) : ...
true
89aa00e1cd5480b1e976fe94a3bbd044f8f671de
hakanguner67/class2-functions-week04
/counter.py
590
4.21875
4
''' Write a function that takes an input from user and than gives the number of upper case letters and smaller case letters of it. For example : function call: counter("asdASD") output: smaller letter : 3 upper letter : 3 ''' def string_test(s): upper_list=[] smaller_list=[] for i in s: if i....
true
38ed49911be4adb634aa662aed898a56c244c5ac
mariadiaz-lpsr/class-samples
/5-4WritingHTML/primeListerTemplate.py
944
4.125
4
# returns True if myNum is prime # returns False is myNum is composite def isPrime(x, myNum): # here is where it will have a certain range from 2 to 100000 y = range(2,int(x)) # subtract each first to 2 primenum = x - 2 count = 0 for prime in y: # the number that was divided will then be divided to find rema...
true
120526d1004799d849367a701f6fa9c09c6bbe05
mariadiaz-lpsr/class-samples
/quest.py
1,314
4.15625
4
print("Welcome to Maria's Quest!!") print("Enter the name of your character:") character = raw_input() print("Enter Strength (1-10):") strength = int(input()) print("Enter Health (1-10):") health = int(input()) print("Enter Luck (1-10):") luck = int(input()) if strength + health + luck > 15: print("You have give ...
true
7251ebc79e8c4968588276efb33d05320b032750
mariadiaz-lpsr/class-samples
/names.py
1,010
4.3125
4
# it first prints the first line print("These are the 5 friends and family I spend the most time with: ") # these are the 2 list name names and nams names = ['Jen', 'Mom', 'Dad', 'Alma', 'Ramon'] nams = ['Jackelyn', 'Judy', 'Elyssa', 'Christina', 'Cristian'] # it is concatenating both of the lists names_nams = names...
true
434182c9ca2fa8b73c4f2fd0b4d9197720b7d406
pktippa/hr-python
/basic-data-types/second_largest_number.py
430
4.21875
4
# Finding the second largest number in a list. if __name__ == '__main__': n = int(input()) arr = list(map(int, input().split())) # Converting input string into list by map and list() new = [x for x in arr if x != max(arr)] # Using list compressions building new list removing the highest number print(max...
true
3c09d0c67801c8748794d163a275a6c6f5b88378
pktippa/hr-python
/itertools/permutations.py
678
4.15625
4
# Importing permutations from itertools. from itertools import permutations # Taking the input split by space into two variables. string, count = input().split() # As per requirement the given input is all capital letters and the permutations # need to be in lexicographic order. Since all capital letters we can directl...
true
e03cc807d94143ba7377b192d5784cbdb07b1abd
pktippa/hr-python
/math/find_angle_mbc.py
376
4.34375
4
# importing math import math # Reading AB a = int(input()) # Reading BC b = int(input()) # angle MBC is equal to angle BCA # so tan(o) = opp side / adjacent side t = a/b # calculating inverse gives the value in radians. t = math.atan(t) # converting radians into degrees t = math.degrees(t) # Rounding to 0 decimals and ...
true
bed0fc094ed0b826db808aa4449cbf31686cbd2a
aryakk04/python-training
/functions/dict.py
549
4.53125
5
def char_dict (string): """ Prints the dictionary which has the count of each character occurrence in the passed string argument Args: String: It sould be a string from which character occurrence will be counted. Returns: Returns dictionary having count of each character in ...
true
2e0deae0231338db84a2f11cd64994bf82900b33
seanakanbi/SQAT
/SampleTests/Sample/classes/Calculator.py
1,677
4.375
4
import math from decimal import * class Calculator(): """ A special number is any number that is - is between 0 and 100 inclusive and - divisible by two and - divisible by five. @param number @return message (that displays if the number is a special number) """...
true
0df98d530f508a752e42a67ad7c6fe0a2608f823
JaiAmoli/Project-97
/project97.py
266
4.21875
4
print("Number Guessing Game") print("guess a number between 1-9") number = int(input("enter your guess: ")) if(number<2): print("your guess was too low") elif(number>2): print("your guess was too high") else: print("CONGRATULATIONS YOU WON!!!")
true
7b9c3c2cd1a9f753a9f3df2adeb84e846c9eb1b4
mschaldias/programmimg-exercises
/list_merge.py
1,395
4.34375
4
''' Write an immutable function that merges the following inputs into a single list. (Feel free to use the space below or submit a link to your work.) Inputs - Original list of strings - List of strings to be added - List of strings to be removed Return - List shall only contain unique values - Li...
true
d089ecb536c7d01e7387f82dbe93da65da98358c
yogabull/TalkPython
/WKUP/loop.py
925
4.25
4
# This file is for working through code snippets. ''' while True: print('enter your name:') name = input() if name == 'your name': break print('thank you') ''' """ name = '' while name != 'your name': name = input('Enter your name: ') if name == 'your name': print('thank you') """ ...
true
ce930feff941e3e78f9629851ce0c8cc08f8106b
yogabull/TalkPython
/WKUP/fStringNotes.py
694
4.3125
4
#fString exercise from link at bottom table = {'John' : 1234, 'Elle' : 4321, 'Corbin' : 5678} for name, number in table.items(): print(f'{name:10} --> {number:10d}') # John --> 1234 # Elle --> 4321 # Corbin --> 5678 ''' NOTE: the '10' in {name:10} means make the name var...
true
c7fc3ced3296f7e181ba9714534800b59d20dd53
thevirajshelke/python-programs
/Basics/subtraction.py
586
4.25
4
# without user input # using three variables a = 20 b = 10 c = a - b print "The subtraction of the numbers is", c # using 2 variables a = 20 b = 10 print "The subtraction of the numbers is", a - b # with user input # using three variables a = int(input("Enter first number ")) b = int(input("Enter first number ")) c ...
true
ef45e2377ab4276345644789a17abdd20da69aca
johnehunt/computationalthinking
/week4/tax_calculator.py
799
4.3125
4
# Program to calculate tax band print('Start') # Set up 'constants' to be used BASIC_RATE_THRESHOLD = 12500 HIGHER_RATE_THRESHOLD = 50000 ADDITIONAL_RATE_THRESHOLD = 150000 # Get user input and a number income_string = input('Please input your income: ') if income_string.isnumeric(): annual_income = int(income_st...
true
8d7ca111c403010de98909a1850ae5f7a1d54b2b
johnehunt/computationalthinking
/number_guess_game/number_guess_game_v2.py
1,262
4.34375
4
import random # Print the Welcome Banner print('===========================================') print(' Welcome to the Number Guess Game') print(' ', '-' * 40) print(""" The Computer will ask you to guess a number between 1 and 10. """) print('===========================================') # Initialise the...
true
0f25b7552ca48fbdc04ee31bd873d899ffae26c6
johnehunt/computationalthinking
/week4/forsample.py
813
4.34375
4
# Loop over a set of values in a range print('Print out values in a range') for i in range(0, 10): print(i, ' ', end='') print() print('Done') print('-' * 25) # Now use values in a range but increment by 2 print('Print out values in a range with an increment of 2') for i in range(0, 10, 2): print(i, ' ', end=...
true
2acb0005b760b130fc4c553b8f9595c91b828c0e
tainagdcoleman/sharkid
/helpers.py
2,892
4.125
4
from typing import Tuple, List, Dict, TypeVar, Union import scipy.ndimage import numpy as np import math Num = TypeVar('Num', float, int) Point = Tuple[Num, Num] def angle(point: Point, point0: Point, point1: Point) -> float: """Calculates angles between three points Args: point...
true
419e9c5cbb652df0abccd13ca68273bc18327cd9
jadugnap/python-problem-solving
/Task4-predict-telemarketers.py
1,300
4.15625
4
""" Read file into texts and calls. It's ok if you don't understand how to read files. text.csv columns: sending number (string), receiving number (string), message timestamp (string). call.csv columns: calling number (string), receiving number (string), start timestamp (string), duration in seconds (string) """ impor...
true
a4b024fe5edf1f5da39078c8d52034ba303a98cc
schirrecker/Math
/Math with Python.py
397
4.15625
4
from fractions import Fraction try: a = Fraction(input("Enter a fraction: ")) b = Fraction(input("Enter another fraction: ")) except ValueError: print ("You entered an invalid number") except ZeroDivisionError: print ("You can't divide by zero") else: print (a+b) def is_factor (a, b): ...
true
9fa0e009c15e00016bfae128e68515f6aaa87e5d
rohanyadav030/cp_practice
/is-digit-present.py
865
4.1875
4
# Python program to print the number which # contain the digit d from 0 to n # Returns true if d is present as digit # in number x. def isDigitPresent(x, d): # Breal loop if d is present as digit if (x > 0): if (x % 10 == d): return(True) else: return(False) ...
true
18bde0bbb7b8f371cbbab5d3a73310f823fa3570
amrutha1352/4040
/regularpolygon.py
280
4.28125
4
In [46]: X= float(input("Enter the length of any side: ")) Y= int(input("Enter the number of sides in the regular polygon: ")) import math numerator= math.pow(X,2)*Y denominator= 4*(math.tan(math.pi/Y)) area= numerator/denominator print("The area of the regular polygon is:",area)
true
34c467f6bcb628d403321d30b29644d35af003f3
jonesm1663/cti110
/cti 110/P3HW2.py
543
4.28125
4
# CTI-110 # P3HW2 - Shipping Charges # Michael Jones # 12/2/18 #write a program tha asks the user to enter the weight of a package #then display shipping charges weightofpackage = int(input("Please enter the weight of the package:")) if weightofpackage<= 2: shippingcharges = 1.50 elif weightofpackag...
true
619ebd59a6875ca0c6feb9a2074ba5412215c4ae
jonesm1663/cti110
/cti 110/P3HW1.py
820
4.4375
4
# CTI-110 # P3HW1 - Roman Numerals # Michael Jones # 12/2/18 #Write a program that prompts the user to enter a number within the range of 1-10 #The program should display the Roman numeral version of that number. #If the number is outside the range of 1-10, the program should display as error message. u...
true
698b8212c16b1a11a5fb9d63af5db687d404039f
beyzakilickol/week1Friday
/algorithms.py
953
4.1875
4
#Write a program which will remove duplicates from the array. arr = ['Beyza', 'Emre', 'John', 'Emre', 'Mark', 'Beyza'] arr = set(arr) arr = list(arr) print(arr) #-------Second way------------------------ remove_dups = [] for i in range(0, len(arr)): if arr[i] not in remove_dups: remove_dups.appen...
true
32f05d2f45e3bad3e2014e1ba768a6b92d4e67b6
soumyadc/myLearning
/python/statement/loop-generator.py
575
4.3125
4
#!/usr/bin/python # A Generator: # helps to generate a iterator object by adding 1-by-1 elements in iterator. #A generator is a function that produces or yields a sequence of values using yield method. def fibonacci(n): #define the generator function a, b, counter = 0, 1, 0 # a=0, b=1, counter=0 while True: ...
true
7400c080f5ce15b3a5537f436e3458772b42d801
soumyadc/myLearning
/python/tkinter-gui/hello.py
737
4.21875
4
#!/usr/bin/python from Tkinter import * import tkMessageBox def helloCallBack(): tkMessageBox.showinfo( "Hello Python", "Hello World") # Code to add widgets will go here... # Tk root widget, which is a window with a title bar and other decoration provided by the window manager. # The root widget has to be c...
true
7b3a4e66395735192270abc17f1c77bc8d5ee5bd
newjoseph/Python
/Kakao/String/parentheses.py
2,587
4.1875
4
# -*- coding: utf-8 -*- # parentheses example def solution(p): #print("solution called, p is: " + p + "\n" ) answer = "" #strings and substrings #w = "" u = "" v = "" temp_str = "" rev_str = "" #number of parentheses left = 0 right = 0 count = 0 # flag correct ...
true
40834ff71cc6200a7028bd1d8a7cacf42c9f886e
nicolaetiut/PLPNick
/checkpoint1/sort.py
2,480
4.25
4
"""Sort list of dictionaries from file based on the dictionary keys. The rule for comparing dictionaries between them is: - if the value of the dictionary with the lowest alphabetic key is lower than the value of the other dictionary with the lowest alphabetic key, then the first dictionary is smaller than the second. ...
true
4fe12c2ab9d4892088c5270beb6e2ce5d96debb1
chapman-cs510-2016f/cw-03-datapanthers
/test_sequences.py
915
4.3125
4
#!/usr/bin/env python import sequences # this function imports the sequences.py and tests the fibonacci function to check if it returns the expected list. def test_fibonacci(): fib_list=sequences.fibonacci(5) test_list=[1,1,2,3,5] assert fib_list == test_list # ### INSTRUCTOR COMMENT: # ...
true
bd7938eb01d3dc51b4c5a29b68d9f4518163cc92
jguarni/Python-Labs-Project
/Lab 5/prob2test.py
721
4.125
4
from cisc106 import * def tuple_avg_rec(aList,index): """ This function will take a list of non-empty tuples with integers as elements and return a list with the averages of the elements in each tuple using recursion. aList - List of Numbers return - List with Floating Numbers """ ...
true
8656ff504d98876c89ead36e7dd4cc73c3d2249e
jlopezmx/community-resources
/careercup.com/exercises/04-Detect-Strings-Are-Anagrams.py
2,923
4.21875
4
# Jaziel Lopez <juan.jaziel@gmail.com> # Software Developer # http://jlopez.mx words = {'left': "secured", 'right': "rescued"} def anagram(left="", right=""): """ Compare left and right strings Determine if strings are anagram :param left: :param right: :return: """ # anagram: left ...
true
846cc6cd0915328b64f83d50883167e0d0910f6a
Teju-28/321810304018-Python-assignment-4
/321810304018-Python assignment 4.py
1,839
4.46875
4
#!/usr/bin/env python # coding: utf-8 # ## 1.Write a python function to find max of three numbers. # In[5]: def max(): a=int(input("Enter num1:")) b=int(input("Enter num2:")) c=int(input("Enter num3:")) if a==b==c: print("All are equal.No maximum number") elif (a>b and a>c): prin...
true
a9169a0606ef75c17087acce0c610bb5aa8e1660
vivek28111992/DailyCoding
/problem_#99.py
624
4.1875
4
""" Given an unsorted array of integers, find the length of the longest consecutive elements sequence. For example, given [100, 4, 200, 1, 3, 2], the longest consecutive element sequence is [1, 2, 3, 4]. Return its length: 4. Your algorithm should run in O(n) complexity. """ def largestElem(arr): s = set(arr) ...
true
f96e8a52c38e140ecf3863d1ea138e15b78c7aa8
vivek28111992/DailyCoding
/problem_#28_15032019.py
1,687
4.125
4
""" Good morning! Here's your coding interview problem for today. This problem was asked by Palantir. Write an algorithm to justify text. Given a sequence of words and an integer line length k, return a list of strings which represents each line, fully justified. More specifically, you should have as many words as p...
true
c80b26a41d86ec4f2f702aab0922b86eec368e84
Brucehanyf/python_tutorial
/file_and_exception/file_reader.py
917
4.15625
4
# 读取圆周率 # 读取整个文件 # with open('pi_digits.txt') as file_object: # contents = file_object.read() # print(contents) # file_path = 'pi_digits.txt'; # \f要转义 # 按行读取 file_path = "D:\PycharmProjects\practise\\file_and_exception\pi_digits.txt"; # with open(file_path) as file_object: # for line in file_object: # ...
true
62bd9b81b6ace8f9bab84fb293710c50ca0bcf29
thekevinsmith/project_euler_python
/4/largest_palindrome_product.py
1,778
4.125
4
# Problem 4 : Statement: # 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. def main(): largest = 0 for i in range(0, 1000, 1): count = 0 ...
true
e604fb50261893929a57a9377d7e7b0e11a9b851
georgeyjm/Sorting-Tests
/sort.py
2,686
4.34375
4
def someSort(array): '''Time Complexity: O(n^2)''' length = len(array) comparisons, accesses = 0,0 for i in range(length): for j in range(i+1,length): comparisons += 1 if array[i] > array[j]: accesses += 1 array[i], array[j] = array[j], arr...
true
a82eb08a4de5bab1c90099a414eda670219aeb95
eliaskousk/example-code-2e
/21-async/mojifinder/charindex.py
2,445
4.15625
4
#!/usr/bin/env python """ Class ``InvertedIndex`` builds an inverted index mapping each word to the set of Unicode characters which contain that word in their names. Optional arguments to the constructor are ``first`` and ``last+1`` character codes to index, to make testing easier. In the examples below, only the ASC...
true