blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
82c6394b591153d264668ab7784b2efb48df3db2
ajpiter/PythonProTips
/DataVisualization/ScatterPlots.py
820
4.1875
4
#Scatter plots are best used to show the relationship bewteen two numeric variables or #to flag potential errors not found by looking at one variable. #To create a scatter plot using matplotlib import matplotlib.pyplot as plt lista = [2001, 2002, 2003, 2004] listb = [1, 2, 3, 4] plt.plot(lista, listb) plt.show() ...
true
bb9b9d74a269478d6fd491dbf37df0ef5fd2b6ab
ajpiter/PythonProTips
/PythonBasics/Function/Method.py
822
4.125
4
### Methods call functions on objects #Objects (Lists, Strings etc) have built in methods and you cannot run the method on the wrong object type. #A method used on a list will not work on a string. ### List Methods #Example, use the function index() on a list to see the index number of a specified value basiclist = ...
true
8b1f7b65588a94e86983856c089d94a5ec0bf7dc
ajpiter/PythonProTips
/Stats/ExploratoryDataAnalysis.py
1,289
4.28125
4
#The process of organizing, plotting, and summarizing a data set #Graphicial Exploratory Data Analysis, involves taking data from a table, and converting it into a graph #Below is how to take a table and convert it into a histogram #for EDA _ are used as a placeholder(dummy variable) when you don't care about the var...
true
a1c5a32f3e9ace0630e97cbe0792b2811203a66b
vikmreddy/D09
/keys.py
1,150
4.375
4
""" Write three functions: sort1(langauges) sort2(languages) sort3(langauges) Goal: Print exactly the below w/ three functions: 1: Arabic English Koine Greek Latin Romanian C++ JavaScript Python R 2: R C++ Latin Arabic Python English Romanian JavaScrip...
true
ad7b6bd5d407d631e6c9f8d6ba0d0e7d7a5f29ea
GeorgiusKurli/GeorgiusKurli_ITP2017_Exercises
/4-11. My Pizzas, Your Pizzas.py
437
4.1875
4
#Taken from 4-1. Pizzas pizzas = ["Pepperoni", "Deluxe Cheese", "Tuna Melt"] for pizza in pizzas: print("I like " + pizza + " pizza.") print("\nI love pizza!") friend_pizzas = pizzas[:] pizzas.append("Meat Lover") friend_pizzas.append("Sausage") print("\nMy favourite pizas are:") for pizza in pizzas: print(pi...
true
a720af16e5184b18331943faf8d99774ca269c9f
cococ0j/ThinkPython-answers
/11-11.py
980
4.125
4
""" Setting return True or False is essential in this part. """ from pronounce import read_dictionary def make_word_dict(): fin = open("words.txt") d = {} for line in fin: word = line.strip() word = word.lower() d[word]= word return d def homephones(a, b, phonetic): if a ...
true
07262adbfdfe29e9b5394a5103a2f21e405fba1c
enigmatic-cipher/basic_practice_program
/Q59) WAP onvert height (in feet and inches) to centimeters.py
369
4.1875
4
print("Feet & Inch Converter") value = float(input("Enter the value: ")) con = int(input("Press 1 to convert feet into centimeter or Press 2 to convert inch into centimeter: ")) if con == 1: print(f"{value} feet in centimeter is {value * 30.48} cm") elif con == 2: print(f"{value} Inch in centimeter is {valu...
true
e5e40e8f0b20ac4428a073d467697cbd300e2814
Priya-dharshini-r/practice
/KMP_algo.py
690
4.15625
4
# Knuth Morris and pratt algorithm to find if there is a pattern in given text. ''' Step-1: Find an LPS(Longest purpose prefix which is also suffix) --> Working of LPS: 1. Create an 1D array with the size of the given pattern. LPS = []*len(Pattern) 2. Set LPS[0] = 0 3. Have two variable for iteration i and j res...
true
f3889a806e21c723449d890ef0bd534f0813d31a
Priya-dharshini-r/practice
/multiply_elements_in_list.py
522
4.28125
4
# defining a function to multiply all the elements in a list def multiply_all_elements_in_a_list(mylist): length = len(mylist) result = 1 for i in range(length): element = mylist[i] result = result*element return result if __name__ == "__main__": n = int(input("Enter number of elements to be in list: ")) myl...
true
b65cd1b868ea9e9e33789a7dc81a89089dafce56
Priya-dharshini-r/practice
/linear_search.py
810
4.21875
4
# Initialize a empty list and get elements from the user. list = [] n = int(input("Enter number of elements:")) # Use a for loop to get each element in the list. for i in range(n): elements = int(input()) list.append(elements) print(list) # Ask the element to be searched. search_element = int(input("Enter the elem...
true
e1523bf2dc7b1da5c23c7cf3b98509a2108909e7
Comphus/five_tasks
/AWS_Docker_CentOS/flask/app/Task1/task_one.py
980
4.125
4
""" First Python Task. Reads a CSV file and output two CSV files First output file is a copy of the input, and second output file is the transposed version of the CSV file Written by Gabriel Lopez """ import pandas as pd def create_csv(file_name, output_one, output_two): """ The main function used to complete Task...
true
8948bb91ecc62872f15ceebd11947e5e8761bb8f
DongYao01/Meijingzhuang-Python
/Grade.py
494
4.21875
4
score = input('Please enter your scores:') try : score = float(score) if score >= 0.9 and score < 1 : print('Grade is "A"') elif score >= 0.8 and score < 0.9 : print('Grade is "B"') elif score >= 0.7 and score < 0.8 : print('Grade is "C"') elif score >= 0.6 and score < 0.7 :...
true
d6a0d47b411cb4e43944923922150cae4a1dc820
SimonWong35/daily-coding-problem-examples
/chapter-03-linked-lists/example-3-3-1.py
472
4.21875
4
#!/usr/bin/python def alternate(linkedlist): even = True current = linkedlist while current.next == True: if current.data > current.next.data and even: current.data, current.next.data = current.next.data, current.data elif current.data < current.next.data and not even: ...
true
ff506e9d27a830d6054d29c08df363b08043afb9
ark229/CodeAcademy_Python
/concatenating_strings.py
393
4.3125
4
###Write a function called account_generator that takes two inputs, first_name and last_name and ###concatenates the first three letters of each and then returns the new account name. first_name = "Julie" last_name = "Blevins" def account_generator(first_name, last_name): return first_name[:3] + last_name[:3] n...
true
cfb3a939ce87417b8b6f4cf6e7a6da889d31f46b
ark229/CodeAcademy_Python
/iterating_strings_practice.py
299
4.125
4
###Write a new function called get_length() that takes a string as an input and returns the number of characters in that string. ###Do this by iterating through the string, don’t cheat and use len() def get_length(string): counter = 0 for length in string: counter += 1 return counter
true
710015293631e8dac8fac805ff16eaa56cd69a91
Semuca/PyConsole
/assets/jamesstuff/UsefulFile/shimport.py
2,076
4.125
4
import __main__ def Add (items): #Adds all floats passed - Takes two or more parameters if (len(items) >= 2): result = 0 for item in items: try: item = float(item) result = result + item except: return __main__.ThrowInvalidValu...
true
8dcc3baccc3c3c0ee09ff4cb2ece986542565f06
0as1s/leetcode
/225_MyStack.py
1,590
4.1875
4
import queue class MyStack: def __init__(self): """ Initialize your data structure here. """ self.q1 = queue.deque() self.q2 = queue.deque() self.last = None def push(self, x: int) -> None: """ Push element x onto stack. """ if ...
true
af449683103bee78b3c995b9b8bc2c2a5a3ab55b
ChrisDel86/EDU.
/Timer_projekt/hello world.py
1,083
4.46875
4
# a simple miles calculator # Program make a simple calculator # This function multiplies two numbers def multiply(x, y): return x * y # This function divides two numbers def divide(x, y): return x / y print("Select form of calculation") print("1. Time Usage") print("2. Drive distance") whil...
true
46cf2c58fa3b6bb0a96b2544cef50acd4f547f64
SyedYousha/PythonProjects
/Rock Paper Scissors.py
2,391
4.90625
5
#rock, paper, scissors from random import randint #to import random numbers user = input('rock (r), paper (p), scissors (s)?') #Let's the user input something and assigns #it to whatever option it picked. So the next line, user will show as r, p, or s. print(user, 'against') #Just prints out the user input and...
true
17b0a29aa63fa0f84a49bab35f6a4eae61a3c6eb
arianjewel/Python_with_oop
/Python_OOP/class_n_object.py
2,041
4.25
4
'''class Car: name='' color='' def __init__(self,name,color): #constructor self.name=name self.color=color def start(self=0): print('Starting the engine') Car.name='Axio' Car.color='black' print('Name of car is',Car.name) print('color:',Car.color) Car.start() print(dir...
true
bc83b89e87778e75102f04f2124a4e6480c0600d
xx-m-h-u-xx/Natural-Language-Processing
/Supervised-Classification.py
2,411
4.125
4
''' Feature Extraction prog ''' ''' Classification is the task of choosing the correct class label for a given input ''' """The first step in creating a classifier is deciding what features of the input are relevant, and how to encode those features. The following feature extractor function builds a dictionary conta...
true
7d5fa74a8179873d43fe7afee286a1878c400d7f
catherinealvarado/data-structures
/algorithms/sorting/quicksort/test_quick_sort.py
1,238
4.1875
4
import unittest from quick_sort import sort class QuickSortTests(unittest.TestCase): """ These are several tests for the function sort that is an implementation of quick sort. """ def test_empty_list(self): """Is an empty list sorted to an empty list?""" self.assertTrue(sort([])==[]...
true
2079d4b550729ad517735ec9bed419062603e9f6
fleimari/PythonMultiThreading
/ex2/main.py
809
4.34375
4
"""" Exercise 2. Write similar program than in exercise 1 but this time use subclass of Thread of threding module and hello_world() -function printing the text should be member function (method) of class you created. The console output should look similar than in exercise 1. Hello World: 0 Hello World: 2 Hello World:...
true
32577919b341d4c5d58b45008a2df990f5a7c04d
mindful-ai/teq-b5-py-dsc-ml
/WEEK01/difference.py
385
4.25
4
# Program to identify if the result of subtraction # is positive, negative or zero # input a = int(input('Enter first number: ')) b = int(input('Enter second number: ')) # process d = a - b # output print('RESULT:' , d) if( d > 0 ): print('The result is positive') elif(d < 0): print('T...
true
06c7ac7e4f8c5f0e7e614ba75a0ba9bfa9532410
goncalossantos/Algorithms
/Sorting/sorting.py
1,200
4.15625
4
import operator def insertion_sort(array, reverse=False): lt = operator.lt if not reverse else operator.gt for index in range(1, len(array)): currentvalue = array[index] position = index while position > 0 and lt(currentvalue, array[position - 1]): array[position] = arra...
true
5e7fed9f5a1de854328aa9668bbd222163cf8824
goncalossantos/Algorithms
/Challenges/CCI/Chapter 02/remove.py
519
4.15625
4
from Algorithms.LinkedLists.linked_list import LinkedList def remove(node): if node.next: node.value = node.next.value node.next = node.next.next else: # Node at the end of the list raise Exception("Node not in the middle") def test_remove(): test_list = LinkedList([1, 2...
true
e1b35ffa48c27ed608f44a04aa84e4077259cd27
Pranay2309/Python_Programs
/tuple concepts.py
426
4.1875
4
t1=10,20,30 #type=tuple t2=(10,20,30) #type=tuple #conversion of list into tuple a=[10,20,30,2,12] print(type(a)) t=tuple(a) print(t,type(t),"length of tuple =",len(t)) print(t[0]) #slice operator in tuple print(t[1:3]) print(t[::-1]) #reversing with the help of slice operator #sorting the tup...
true
455bcc2376e475467f991bef419e2b4fcf82cbe1
Phil-U-U/leetcode-practice-2
/valid-binary-search-tree.py
1,798
4.3125
4
''' Given a binary tree, determine if it is a valid binary search tree (BST). Assume a BST is defined as follows: The left subtree of a node contains only nodes with keys less than the node's key. The right subtree of a node contains only nodes with keys greater than the node's key. Both the left and right subtrees m...
true
a83652453c60311b310f8e4abfedeba9446b3d2f
vandanagarg/practice_python
/learning_python/mit_lectures/functions/Coordinate.py
1,377
4.65625
5
''' Creating a Class/ random abstract datatype of type Coordinate This is an example for OOPS concept in programming ''' class Coordinate(object): def __init__(self, x, y): self.x = x self.y = y def distance(self, other): x_diff_sq = (self.x - other.x) ** 2 y_diff_sq = (self.y...
true
084f6702316d76e460457ed6e4281fb4c730c253
vandanagarg/practice_python
/learning_python/classes/Circle.py
425
4.21875
4
class Circle: # Class Object Attribute PI = 3.14 def __init__(self, radius= 1): self.radius = radius self.area = radius*radius*self.PI # self.pi can also be written as Circle.pi #Method def get_circumference(self): return self.radius * self.PI * 2 my_circle = Circle(30)...
true
c730fc75c052e419e7cd1748421a87bda129739a
vandanagarg/practice_python
/learning_python/data_structures/lists/lists_basic_operations.py
2,763
4.625
5
#Lists ,we have to use [] these brackets to store a bunch of values and thus we create a list of some related data that we wish to have #We can put anything in a list i.e: a number, boolean or a string #list is mutable friends = [ "Peeyush Singla", "PS", "groom", "VG"] friends_two = [ "Peeyush Singla", "PS", "groom", ...
true
6594a05a236f4db69f0e71d0f3cc181afc967b2d
vandanagarg/practice_python
/learning_python/functions/functions/multiply.py
244
4.1875
4
#Q5: multiply all numbers in a list numbers = [2,5,8,4] def multiply(numbers): mul_result = 1 for item in range(0, len(numbers)): mul_result = mul_result * int(numbers[item]) return mul_result print(multiply(numbers))
true
d761b068c2046f5ad0e9886a416f30f647ac1b03
vandanagarg/practice_python
/learning_python/branching_statements/statements.py
1,601
4.25
4
''' Pass/ Continue/ Break statements ''' ''' The break statement in Python terminates the current loop and resumes execution at the next statement ''' print("\n break examples:") # First Example print("\n Example 1st \n") my_sum = 0 for i in range(5, 11, 2): my_sum += i if my_sum == 5: break ...
true
595c7f9c7d393a3c757add264fd0e71e837f49ce
vandanagarg/practice_python
/learning_python/hacker_rank/problem2.py
269
4.15625
4
# swapcase and reversing the string def reverse_words_order_and_swap_cases(sentence): return sentence = "aWESOME is cODING" # print(len(sentence)) s = sentence.split() print(s) s.reverse() print(s) text = " " new = text.join(s) print(new) print(new.swapcase())
true
bb99751daf0c097ce76c2c3e2b3e4fc8de96c452
vandanagarg/practice_python
/learning_python/inheritance/Chef/ChineseChef.py
1,125
4.15625
4
#lets say we have a chinese chef who has all qualities of generic chef (Chef.py) and it makes something extra as well class ChineseChef: def make_chicken(self): print("The chef makes a chicken.") def make_salad(self): print("The chef makes a salad.") def make_special_dish(self): p...
true
27f25895ffbfb386e04cbf925ebbb6dfbd232f8f
rvaishnavigowda/Hackerrank-SI-Basic
/compute fibonacci number.py
521
4.4375
4
''' For a given positive integer - N. Compute Nth fibonacci number. Input Format Input contains a positive integer - N. Constraints 1 <= N <= 20 Output Format For given input, print the Nth fibonacci number. Sample Input 0 4 Sample Output 0 3 Explanation 0 The fibonacci series: 1, 1, 2, 3, 5, 8,...... At 4th ...
true
095c60da97bb1967ab80b83b71db16acada6980e
pshushereba/Data-Structures
/singly_linked_list/singly_linked_list.py
2,536
4.15625
4
class ListNode: def __init__(self, value, next=None): self.value = value self.next = next class LinkedList: def __init__(self, node=None): self.head = node self.tail = node self.length = 1 if node is not None else 0 def add_to_tail(self, value): node = List...
true
eff62d6bf7cee49e3d70be04d6924ee75392a3f2
mmcgee26/PythonProjects
/6_2.py
2,055
4.28125
4
class Node: def __init__(self,data): self.val = data self.next = None # create a linked list (adding nodes) that is identified as 'head' head = Node(None) n1 = Node(10) n2 = Node(20) n3 = Node(30) head.next = n1 n1.next = n2 n2.next = n3 # print the linked list def print_linked_list...
true
435480dc29ac57b67823cac19ec5b0b114e7d164
mmcgee26/PythonProjects
/hw3example.py
2,226
4.1875
4
print("Post-fix Calculator") print("For help, type \"help\" or \"?\"") while True: str_in = raw_input("> ") tokens = str_in.split(" ") stack = [] if tokens[0] == "help" or tokens[0] == "?": print("Post-fix calculator takes in post-fix formatted equations and evaluates them.") print("In...
true
cd28b6cfa1510ca81f8ec70d98e422ed92f167a9
maayansharon10/intro_to_cs_python
/ex2/temperature.py
606
4.3125
4
def is_it_summer_yet(best_temp, first_temp, second_temp, third_temp): """ the function recieves 4 arguments - the first is the 'best temperature' which is the pre-condition. function will return True when the 2nd and 3rd and 4th arg are larger then best_temp. Otherwise will return False """ i...
true
d45cf56b1772f426995514d004e71895e75f0765
maayansharon10/intro_to_cs_python
/ex2/shapes.py
1,567
4.3125
4
""" זה אוטומטית חוזר לי לNONE לא משנה מה אני מקלידה""" import math def circle_area(): """ receives input from user about the radius and calculates the area of a circle""" radius = float(input("choose radius")) circle_calc = radius*radius*math.pi return circle_calc def rectangle_...
true
982fde0bb1d327f7f05692a652c8f74730ef14da
kdgreen58/is210_lesson_06
/task_02.py
818
4.40625
4
#!/usr/bin/env python # -*- coding: utf-8 -*- """Task 02 code.""" import task_01 import data def get_average(numbers): """Finds the average of a list. Args: numbers(num): A numeric type that reads in number(s). Returns: numeric (float): returns the average of a list Example: ...
true
f47e7289d64bac0638fa9fdceacfb8297ca0bc1a
Lior303/NumAnalytics
/root/secant_method.py
1,330
4.34375
4
def secant_method(f, x0, x1, epsilon=10**-4, nMax=100): """ secant method to calculate x's (roots) of a function :param f: the function :param x0: start value :param x1: start value :param epsilon: fault degree allowed :param nMax: maximum of iterations """ n=1 while n<=nMax: ...
true
0d52c863746f5bbf169e94e7d61a8569d5a648ea
nevosial/learnpy
/refresh/sets.py
685
4.21875
4
#Sets in 3.6 p = {True, 3, 'nev', 4, 6, 7} q = {False, True, 1,2,'vic', 'zoe',6, 7, 'nev'} # union will return new set with all elements r = p.union(q) print(r) # intersection will return only the common elements found in both s = p.intersection(q) print(s) # difference will return only the uncommon elements found ...
true
fcbf8c044c03803243cf850f225f6ccdceb6caa0
Shridevi-PythonDev/quotebook
/day6_learning.py
1,640
4.15625
4
### Conditions # if a = 90 b = 60 if b<a: print("Yes a is greater than b") print(b) print(a*b) else: print("b is greater") print(a) #### elif a = 25 b = 18 if b > a: print("if condtion, b greater") elif a == b: print("you are in elif condition, equal") else: print("else condition,...
true
3287cbc23a4aaa096004f94cf7ece69f4029ac5f
Kodermatic/SN-web1
/07_HW - Python (write into file)/Storing_data_into_file.py
1,279
4.34375
4
# Plan: # User enters lines of file # User can exit adding new lines with :q # User is asked if file shall be saved. If yes file is saved and user is asked if file shall be printed. path = "./07_HW - Python (write into file)/" new_line = "" file_text = "" while True: if new_line != ":q\n": file_text = file_text...
true
80694ad66007e718d884ced92f79c7ef5c9eab6a
yash872/PyDsa
/Array/Search_a_2D_Matrix.py
1,086
4.15625
4
''' Write an efficient algorithm that searches for a value in an m x n matrix. This matrix has the following properties: - Integers in each row are sorted from left to right. - The first integer of each row is greater than the last integer of the previous row. Example 1: Input: matrix = [[1,3,5,7], ...
true
d1274fc5de939a7e26602bc32c150f9f38b98736
thithick/selenium-python
/D1_reverse_method1.py
319
4.25
4
# Method2 # Using function def reverseNumber(number): reverse = 0 while (number > 0): lastDigit = number % 10 reverse = (reverse * 10) + lastDigit number = number // 10 print(reverse) number = int(input("Please input a number to be reversed.\n")) reverseNumber(number);
true
b5dd39b448ae8e248f7a62a5be894596606fbfae
learnMyHobby/if_python
/leapYear.py
498
4.3125
4
# Write a program to check whether the entered year is leap year or not. # leap year means it has to be 366 days and it will occur once every four years year = int(input("Enter a year: ")) if (year % 4) == 0: if (year % 100) == 0: if (year % 400) == 0: print("{0} is a leap year".format(year)) ...
true
0b1460d5dab91ae25b1ea9ff6e2ab587bee6f259
giraffesyo/School-Assignments
/Intoduction to Computer Programming - CSYS 1203/Assignment 3/average.py
359
4.21875
4
# This simple program will average the numbers entered by a user. # By Michael McQuade CSYS1203 def main(): print("This program will average comma separated numbers you enter.") n = eval(input("How many numbers are to be averaged? ")) avg = eval(input("Please enter the numbers you would like averaged: ")) ...
true
ff7db4aee1d82ca246adcc2cf2e065e08adef553
Harsh5751/Python-Challenges-with-CodeWars
/Binary Addition.py
533
4.34375
4
''' Binary Addition Implement a function that adds two numbers together and returns their sum in binary. The conversion can be done before, or after the addition. The binary number returned should be a string. ''' def add_binary(a,b): binary = str(bin(a + b)) return binary[2: ] #Sample Tests Te...
true
06681e8dbe843cdcdab6b5bbccef4c17042f9a5c
Harsh5751/Python-Challenges-with-CodeWars
/sum of odd numbers.py
510
4.125
4
''' Sum of odd numbers Given the triangle of consecutive odd numbers: 1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 ... Calculate the row sums of this triangle from the row index (starting at index 1) e.g.: rowSumOddNumbers(1); // 1 rowSumOddNu...
true
f8f70eaf3830c19b5d91ba2b25e34e667e2c337e
Greycampus/python
/datatypes/array.py
546
4.46875
4
''' Python program to take input a sequence of numbers from user and store it in a list or array Input 3 11 12 13 Output [11, 12, 13] ''' msg = 'enter the number of elements:' #printing message for user input print(msg) # taking length of list to be inputted a = raw_input() #stripping extra spaces in input a = int(a....
true
c1c87e66aa1e0677343f57612e69493660e18f23
Greycampus/python
/variables/local.py
915
4.15625
4
''' python program to use local variable by taking user input and print nearest power of 3 Input 4 Output 3 ''' #import math library for log functions from math import log,floor,ceil msg = 'enter the number:' #printing message for user input print(msg) #taking input and casting it into integer n = raw_input() #stripp...
true
c735202659fff96ffa73d2b0a1379343d90618b0
Greycampus/python
/regex/repla.py
478
4.5
4
''' Python program to replace all the patterns like '[!*]' using loops Input enter the string: [![![!*][!*]*]*]abc Output string before modification:[![![!*][!*]*]*]abc abc ''' import re msg = 'enter the string:' print(msg) k = str(raw_input()) print('string before modification:'+k) #replacing the pattern in string ...
true
b40c1ecde281f3021e79e19a2b5fa25dcfb239fc
Greycampus/python
/regex/occur.py
728
4.21875
4
''' python program to find the total occurences of a symbol in string using reqular expressions Input enter the main string: 1qaz!@#$!@#$zxswedc@#$% enter the symbol you wish find occurences: @ Output @ occured 3 times in 1qaz!@#$!@#$zxswedc@#$% ''' import re msg= 'enter the main string:' print(msg) #getting main st...
true
ba2082fbbcf8ddf40333a4c3e6930584416991d0
Greycampus/python
/file_handling/filenopen.py
583
4.125
4
''' Python program to open a text file and print the nth line in text file if nth line does not exist print 'no data' Input enter the line number: 4 Ouput 4th line:hello python programmer ''' #opeing the text file f = open('text1.txt','r') #getting nth line number from user msg = 'enter the line number:' print msg n...
true
669c1c377f6336ac8bde5baa2a43cfb28f4fdfcf
haddow64/CodeEval
/Easy/01 - Fizz Buzz.py
2,470
4.25
4
#Players generally sit in a circle. The player designated to go first says the number "1", #and each player thenceforth counts one number in turn. However, any number divisible by 'A' e.g. #three is replaced by the word fizz and any divisible by 'B' e.g. five by the word buzz. Numbers #divisible by both become fizz buz...
true
e3b7a1ddd339af3646ba2b60d0da043bd1fe8d05
Piwero/bootcamp_projects
/find_py.py
333
4.21875
4
''' Find PI to the Nth Digit - Enter a number and have the program generate PI up to that many decimal places. Keep a limit to how far the program will go. ''' #import the math import math def find_pi(n): print(format(math.pi,'.{}f'.format(n))) #---------------------TEST------------------- find_pi(6) find_pi(4...
true
e1044cb36bdfb2180af54f435d5cb202f5213501
Anna1027/CaesarCipherEncryption
/caesarCipher.py
485
4.125
4
#c = (x - n)%26 def encrypted(string, shift): cipher= ' ' for char in string: if char==' ': cipher = cipher+char elif char.isupper(): cipher= cipher+chr((ord(char)+shift-65)%26+65) else: cipher=cipher+chr((ord(char)+shift-97)%26+97) return cipher ...
true
be76d86c066d19f1eb3c787f3cf54c26292b71de
mtthwgrvn/Python-Resources
/operators.py
2,052
4.6875
5
#Python Operators #Operators are used to perform operations on variables and values. #Python divides the operators in the following groups: #Arithmetic operators #Assignment operators #Comparison operators #Logical operators #Identity operators #Membership operators #Bitwise operators #Python Arithmetic Operators #...
true
a32f351dcbec0cb4051e4afaf172d7742ba36836
GiftofHermes/Practice
/Odd or Even.py
996
4.21875
4
#Ask the user for a number. Depending on whether the number is even or odd, print out an appropriate message to the user. #Hint: how does an even / odd number react differently when divided by 2? #If the number is a multiple of 4, print out a different message. #Ask the user for two numbers: one number to check (call...
true
afb9a0cdb6ab48ef53d67deeeab070acdca2548b
GiftofHermes/Practice
/Birthday JSON.py
940
4.5
4
#load the birthday dictionary from a JSON file on disk, # rather than having the dictionary defined in the program. #Ask the user for another scientist’s name and birthday # to add to the dictionary, and update the JSON file # you have on disk with the scientist’s name. import json with open('Writings/info.json', '...
true
02e70f100addb87527434118fb24357083b08b8f
bryanalves/euler-py
/src/001.py
351
4.21875
4
#!/usr/bin/env python """ If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23. Find the sum of all the multiples of 3 or 5 below 1000. """ def euler_1(n): return sum(a for a in range(n) if a % 3 == 0 or a % 5 ==0) if __name__ == "__mai...
true
112d62993b58f994ff2c9bf977c357b903990a49
AslanDevbrat/Programs-vs-Algorithms
/Problem 1 Square Root of an Integer/Problem 1 Square Root of an Integer.py
1,260
4.4375
4
#!/usr/bin/env python # coding: utf-8 # In[2]: def sqrt(number): """ Calculate the floored square root of a number Args: number(int): Number to find the floored squared root Returns: int: Floored Square Root """ def find_floor_sqrt(number,start,stop): #print(start,stop)...
true
f0b07aea5b1d1ab99a53c6024858e4fc6a53f89b
jdevadkar/Python
/Basic Python/calculator.py
1,078
4.21875
4
# this method implement addintion of two number def add(x,y): return x + y # this method implement subtraction of two number def subtract(x,y): return x -y # this method implement multiplication of two number def multiply(x,y): return x * y # this method implement Division of two number def divide(x, y): ...
true
a4a23f40a60dbdb11f967fa7e636997ec005bb48
99YuraniPalacios/Trigometria
/trigonometry.py
1,208
4.125
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Tue Feb 26 13:07:28 2019 @author: jzuluaga """ from enum import Enum import numpy as np PI=3.14159265359 class Unit(Enum): DEG=1 RAD=2 class Angle(object): #Atributos: value, unit #Métodos def __init__(self,value,unit): s...
true
7617a7d2233c7dcaa3e2db5a3b4a20c2703003b8
atkell/learn-python
/exercises/ex31.py
1,873
4.40625
4
# making decisions: now that we have if, else and elif we may start to create scrpipts that decide things! # in this exercise, we'll explore asking a user questions nd then make decisions based on the answer(s) provided print("""You enter a dark room with two doors. Do you go through the door #1 or door #2?""") door ...
true
9a5f9d8b5920456ffe5e9a3e1d5c07a5d9262536
atkell/learn-python
/exercises/ex24.py
1,790
4.3125
4
# this exercise is intentionally long and all about building up stamina # the next exericse will be the same. do them both, get them exactly right and do your checks print("Let's practice everything we know thus far...") print('You\'d need to know \'bout escapes with \\ that do:') print('\n newlines and \t tabs') poe...
true
3b0e57fb2b13652513fb9d080fb24eaab5a09ad5
atkell/learn-python
/exercises/ex19.py
1,811
4.21875
4
# functions and variables # the takeaway here is scope, mostly that the variable we use in our functions are not connected to variables in our script def cheese_and_crackers(cheese_count, boxes_of_crackers): # here we define our function for ex19 called cheese_and_crackers. it takes 2 arguments, cheese_count and boxe...
true
a9f51c70c1a4979e1fa49a7030c3aeeab59d4b00
atkell/learn-python
/exercises/ex8.py
702
4.3125
4
formatter = "{} {} {} {}" # huzzah! we are introducing the concept of a function # we're just working with integers here print(formatter.format(1, 2, 3, 4)) # now we're working with strings print(formatter.format("one","two","three","four")) # now we're workign with booleans print(formatter.format(True, False, False, T...
true
4a809d9f88da2db4541509cb254d492d407ac6f1
atkell/learn-python
/exercises/ex3.py
968
4.53125
5
# numbers and math, joy! # + is addition (plus) # - is subtraction (minus) # / is division (slash) # * is multiplication (asterisk) # & is remainder after division (modulous) # < is less than and > is greatter than # <= is less than or equal to and >= is greater than or equal to # remember the order of operations "PEM...
true
f9f4914364541aafeb58b593b7117926b73e24d8
xuwei0455/design_patterns
/FactoryMethod.py
2,357
4.125
4
# -*- coding: utf-8 -*- """ Factory Method pattern The distinction of Simple Factory and Factory Method is, Simple Factory pattern only offer one factory to produce, otherwise, Factory Method can horizontal scaling by add new Factory. And, when there just one factory, pattern fall back to Simple Factory. When just ...
true
24c755ce860af891b453f245740705eb406206e5
gunveen-bindra/OOP
/single_inheritance.py
684
4.21875
4
# Defining base class "Shape". class Shape: # Function to initialize data members. def _getdata(self, length, breadth): self._length = int(input("Enter the Length: ")) self._breadth = int(input("Enter the Breadth: ")) # Defining derived class "Rectangle". class Rectangle(Shape): ...
true
e25de8b07e2449f5be7cc2df8284cf8815bbd99a
TheFutureJholler/TheFutureJholler.github.io
/module 6-Tuples/tuple_delete.py
321
4.125
4
# -*- coding: utf-8 -*- """ Created on Sun Dec 31 20:38:37 2017 @author: zeba """ tup = ('physics', 'chemistry', 1997, 2000); print(tup) del tup print ("After deleting tup : ") print(tup) '''This produces the following result. Note an exception raised, this is because after del tup tuple does not exist any more '''...
true
7e282a9e3b589c4e641054900b47a060146e07e4
dhanrajsr/hackerrank-practice-exercise
/if_else_ex.py
583
4.5
4
#https://www.hackerrank.com/challenges/py-if-else/problem def find_odd_even(input_number): """ If a number divided by 2 leaves a remainder 1, then the number is odd, if a number divided by 2 leaves a remainder 0, then the number is even. The % helps to calculate the remainder. eg: number % ...
true
8d9b15cf0add58beed7dca83ebbd5f84a0f248b8
joedeller/pymine
/mandel.py
2,074
4.21875
4
#!/usr/bin/python # Joe Deller 2014 # A very simplified version of the Mandelbrot set # Level : Intermediate # Uses : Libraries, variables, lists # I have taken some example code for how to draw the Mandelbrot set from Wikipedia # and made it compatible with the Pi. # This isn't a true fractal program as we can't zo...
true
36761b573cf0907ef8fff401966de660a6671975
zhchwolf/pylearn
/python_code/frist.py
401
4.59375
5
#!/usr/bin/env python # -*- coding: utf-8 -*- # calculate the area and circumference of a circle from its radius # Step 1: prompt for a radius # Step 2: apply the area formula # Step 3: print out the results import math radiusString = input('Enter radius of circle:') radiusInt = int(radiusString) circumference = 2*ma...
true
2b14e9c509c5d2e3f6cae1dd81eac27d8313d61c
GriffGeorgiadis/python_files
/decode.py
2,128
4.21875
4
#Griffin Georgiadis #Write a program that uses a dictionary to assign “codes” to each letter of the alphabet #set global variables ENCRYPT = 1 DECRYPT = 2 #start main function def main(): try: #print menu print('Welcome to my encryption program, You can choose to encrypt a file or decrypt an encryp...
true
2f3e73af97ec226ddb0da068830b2de7b072facb
dandenseven/week1
/day2/Day2_exercises/exercises/1-core-functions/define_functions.py
433
4.34375
4
#print allows you to output to your console what you want to print. print("this is my string") print(" 2 + 2 equals 4 this is the answer.") a = 9 * 9 relax = ("meditating is good for your mind") print( a ) print("meditating", a, "times is good for your mind") #input lets you ask a use for some text to input, it tells ...
true
6e2a7e74c4ef4859eb18fd571044e12bde07a115
jesse-bro/Data_Structure_Problems
/Compress_String.py
715
4.25
4
### Method to perform basic string compression using the ### counts of repeated characters. String only contains ### uppercase and lowercase letters (a-z). def stringCompress(string): compressed = "" count = 0 for i, ch in enumerate(string[:-1]): if ch != string[i+1] or i+1 >= len(strin...
true
f792c60fca40895c5b85f7b35db15d79e2a5ae8a
PacktPublishing/Python-3-Project-based-Python-Algorithms-Data-Structures
/Section 03/4_strings_2_notes.py
1,446
4.6875
5
# We can use string concatenation and add strings # together message = "Welcome to the course" name = "Mashrur" print(message + name) # We can add an empty space in there too print(message + " " + name) # Strings are sequences of characters which are indexed # We can index into a string by using square bracket notati...
true
2670d9d8d6c53b26330b4983790bef744c24e8c9
PacktPublishing/Python-3-Project-based-Python-Algorithms-Data-Structures
/Section 04/12_merge_sort_demo_starter.py
454
4.125
4
def merge_sorted(arr1,arr2): print("Merge function called with lists below:") print(f"left: {arr1} and right: {arr2}") sorted_arr = [] i, j = 0, 0 print(f"Left list index i is {i} and has value: {arr1[i]}") print(f"Right list index j is {j} and has value: {arr2[j]}") return sorted_arr # xxx...
true
578df8e4753a6be6252f68cead393522cd4d1559
ramonsolis159/csc1010
/csc1010_Pycharm_Projects_Python/hmwk_4.py
849
4.34375
4
# Ramon Montoya # 10/08/2018 # This program is for an assignment. movie = "I am currently watching a movie!" print(movie) type = "It is a action and scifi movie." print(type) type = "It is pretty good!" print(type) name = "eric" message = "Hello " + name.title() + ", would you like to learn Python today?" print(m...
true
ec895f5c728871d691c3816cb53cc16f633818d3
priyankapiya23/BasicPython
/String/reverse_string.py
788
4.1875
4
#reverse string string=input("enter any string") print('reverse of string is using methhod') print(string[::-1]) # extended slice syntax '''Explanation : Extended slice offers to put a “step” field as [start,stop,step], and giving no field as start and stop indicates default to 0 and string length respectively and “-1”...
true
24601bddd6d86b6233380e3b65011276164373ac
ahmadabdullah407/python-basics
/stringlisttupleindexcountconcatinaterepeat.py
1,460
4.1875
4
# # Concatination(Addition of lists)(+): # fruit = ["apple","orange","banana","cherry"] # print([1,2] + [3,4]) #Concatination # print(fruit+[6,7,8,9]) #Concatination # # Repitition(Multiplication of lists)(*): # print((fruit + [0,1])*4) #Repitition (Use parenthisis) # # a = ['first'] + ("second","green") # Error List ...
true
d929cfc88e59978e8add9795e5513ce6c73e11c6
danielnwankwo/control_flow
/control_flow.py
1,149
4.34375
4
# control flow # if statements # syntax: if then conditions age = 15 # will run because conditions have been met. without the = then it will not run as 15 does not satisfy either statement # by itself if age > 15: print("Thank You. You may watch this movie ") elif age <= 15: print("sorry you are not the requi...
true
7494a5d939e68da759c450b3eeda9c80db3382d3
jimjshields/interview_prep
/hashing/map_class.py
2,508
4.1875
4
class Map(object): """Represents a map/assoc. array/dictionary ADT.""" def __init__(self): """Initializes w/ an empty list of keys and empty list of values.""" self.dict = {} def add_key_val_pair(self, key, val): """Adds a key/value pair to the map. Replaces value if key already present.""" self.dict[key...
true
1b5a0da81fab26681c9cab11fa45d5586d06cee2
jimjshields/interview_prep
/practice/19_shell_sort.py
959
4.125
4
# Shell sort - aka diminishing increment sort # Improves on insertion sort - breaks original list into smaller sublists # Each of which is sorted using insertion sort # Big O: # Worst case: O(n^2) # Avg. case: Depends on gap selection # Best case: O(nlog(n)) # Aux. space: O(1) def shell_sort(a_list): sub_list_count ...
true
a629d6a370a39826e03748b571c263ff43c12d84
code-in-public/leetcode
/best-time-to-buy-and-sell-stock/test.py
812
4.28125
4
#!/usr/bin/env python3 import unittest import solution """ Example 1: Input: prices = [7,1,5,3,6,4] Output: 5 Explanation: Buy on day 2 (price = 1) and sell on day 5 (price = 6), profit = 6-1 = 5. Note that buying on day 2 and selling on day 1 is not allowed because you must buy before you sell. Example 2: Input: ...
true
92f058ec4f9d59f583e42839a757d604ba961bb7
Techwrekfix/Starting-out-with-python
/chapter-3/4. Roman_numerals.py
773
4.21875
4
#This program displays the roman numeral version #of a number entered by a user #Assigning the numeric numbers to a variable one = 1 two = 2 three = 3 four = 4 five = 5 six = 6 seven = 7 eight = 8 nine = 9 ten = 10 #Prompting the user to enter a numeric number number = int(input("Enter a numeric number: ")) #Display...
true
9d76d0b71433637d8e740f45faa894bc5c96c32c
Techwrekfix/Starting-out-with-python
/chapter-8/Sum_of_digits_in_a_string.py
560
4.34375
4
#This program displays the sum of digits in a string #ALGORITHM in pseudocode #1. get a series of single-digit number from the user # set total accumulator to zero #2. for every digit in user input: # convert digit to integer # add the digit to the accumulator #3. Display total #CODE def main(): u...
true
1f55026aa62f17b9449bfa7315dba35209d5a220
Techwrekfix/Starting-out-with-python
/chapter-2/3. land_calculation.py
385
4.125
4
#This program calculates the number of acres in a tract total_square_feet = float(input('Please enter the total ' \ 'square feet of the tract' \ 'of land: ')) number_of_acres = total_square_feet / 43560 #Displaying results print('The number of acres in...
true
f3d2f5fc63aa813d13150d89f80d71947b478863
Techwrekfix/Starting-out-with-python
/chapter-2/8. tip_tax_total.py
541
4.15625
4
#This program displays the total #cost of a meal purchased at a restaurant meal_charge = float(input('Enter the cost of the meal: ')) tip = 0.18 * meal_charge #calculating 18% tip of the meal sales_tax = 0.07 * meal_charge #calculating 7% sales tax of the meal total = meal_charge + tip+sales_tax #calculating total...
true
147900a7dba4bcf3dcf61da7595d1b8dee7a7612
Techwrekfix/Starting-out-with-python
/chapter-6/2. File_head_display.py
618
4.28125
4
#File head display program def main(): #creating variables for max lines and number of line in the file max_line = 5 count_lines = 0 #ask user for file name file_name = input('Enter the name of your file: ') #open the file user_file = open(file_name,'r') #read the first line in the fi...
true
c70c9318953230c1f0816dff97a67a720fa960a4
Techwrekfix/Starting-out-with-python
/chapter-5/6. Calories_from_fat_and_carbohydrates.py
724
4.28125
4
#This program calculates calories from a fat def main(): fat_grams = float(input('Enter the number of fat grams: ')) carb_grams = float(input('Etner the number of carb_grams: ')) fat_calories = calculate_fat_calories(fat_grams) carb_calories = calculate_carb_calories(carb_grams) #Displaying fats c...
true
f84509cdcded11e6a1b53af3bbf930437dd0f3e3
Techwrekfix/Starting-out-with-python
/chapter-9/1. course_Information.py
1,419
4.40625
4
#This proram is about course information #Algorithm in pseudocode #1.The create_dictionary function creates three different # dictionaries(Room_number,Instructor and Meeting_time) and # returns a refrence to the dictionaries # #2. Inside the main fucntion: # 1.ask user enter a course number # 2.if user i...
true
57f08ee56cff62dd8570f2460253461bc550d4ae
Techwrekfix/Starting-out-with-python
/chapter-4/4. Distance_traveled.py
396
4.53125
5
#This program displays distance travelled in miles speed = int(input('Enter the speed of the vehicle in mph: ')) time = int(input('Enter the hours traveled by the vehicle: ')) #Creating a table print('Hour \t Distance Traveled') print('--------------------------') #Using a loop to display the table for hours in range...
true
661837cd7886c47de2847f854b1a86cd6ab8dadb
Techwrekfix/Starting-out-with-python
/chapter-3/5. Mass_and_weight.py
447
4.4375
4
#This program measure the weight of objects #Getting the mass of an object from user mass_of_object = float(input("Enter the mass of the" \ " mass of the object: ")) #Calculating the weight: weight = mass_of_object * 9.8 print("\nThe weight of the object is N", format(weight,'.2f'),sep='')...
true
6c11ae57279bbbaa47daa26e5e56ea85830c3aea
Rohit-iitr/pythonBasics
/PythonProblems/G4G/RotateString.py
1,078
4.125
4
#User function Template for python3 #Function to check if a string can be obtained by rotating #another string by exactly 2 places. def isRotated(str1,str2): flagAntiCloclwise = False flagCloclwise = False if (len(str1)>1 and len(str2)>1): count =0 index =2 y='' ...
true