blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
9167003e750f0216857d8dab3aa3424231a33e11
jiezheng5/PythonFundamentals
/app5-DatabaseAppUsing-TinkerSqlite/app5_backend.py
2,261
4.375
4
""" A program that stores the book information: Title, Author Year, ISBN User can: view all records search an entry add entry update entry delete close https://www.udemy.com/the-python-mega-course/learn/v4/t/lecture/4775396?start=0 """ from tkinter import * import sqlite3 import numpy as np import ...
true
a521ef2d94a766a9dfbfcc33fa6145537855af9e
Rekapi/PyProblemSolving
/PS02.py
2,898
4.1875
4
# Continue from __future__ import print_function import sys import math import textwrap import http.client # 41. how to Sum two given numbers and return a number (functions) def summation(x, y): suma = x + y if suma in range(15, 20): return 20 else: return suma print(summation(2, 2)) #...
true
90aa9b98e719c314488a86b049ba9d220eda47fb
PrtagonistOne/Beetroot_Academy
/lesson_04/task_2.py
815
4.21875
4
def main(): number = input('Enter your phone number here: ') message = phone_validator(number) if message == 'lenght': print('Your number should consist of exactly 10 digits') elif message == 'digits': print('Your number should consist of only numerical chars') elif message == 'vali...
true
5faa6ec0949f2cc7700a12ead0f83e74265d6bb3
PrtagonistOne/Beetroot_Academy
/lesson_07/task_1.py
704
4.125
4
# Make a program that has some sentence (a string) on input and returns a dict # containing all unique words as keys and the number of occurrences as values. # For testing: # 'Hello, my name is Andrey. Andrey is from Odessa. Andrey currently studies python language at Beetroot Academy in Python for Begginers course....
true
94204564422e698810bbcad1c30c3faf3fc20833
PrtagonistOne/Beetroot_Academy
/lesson_13/task_1.py
1,157
4.21875
4
# Method overloading. # Create a base class named Animal with a method called talk and then create two subclasses: Dog and Cat, # and make their own implementation of the method talk be different. For instance, Dog’s can be to print ‘woof woof’, # while Cat’s can be to print ‘meow’. # Also, create a simple generic ...
true
7c68e814e22c38c69fdd41fc981f8bcfb9153479
Pabitra-26/Problem-Solved
/LeetCode/Flipping_an_image.py
792
4.28125
4
# Problem name: Flipping an image # Description: Given a binary matrix A, we want to flip the image horizontally, then invert it, and return the resulting image. # To flip an image horizontally means that each row of the image is reversed. # For example, flipping [1, 1, 0] horizontally results in [0, 1, 1]. # To in...
true
88433a61b1a4375a5c71b61e8aa900e11a954961
Pabitra-26/Problem-Solved
/Hackerrank/Marc'sCakewalk.py
1,290
4.28125
4
# Problem name: Marc's Cakewalk """ Description: Marc loves cupcakes, but he also likes to stay fit. Each cupcake has a calorie count, and Marc can walk a distance to expend those calories. If Marc has eaten j cupcakes so far, after eating a cupcake with c calories he must walk at least (2^j)*c miles to maintain his...
true
fd7c6633a7d1479b223fa8ce8f9e2cf5a05d326c
Pancc123/python_learning
/base_practice/quit.py
475
4.21875
4
pizza='' message='\nplease choose a ingredients on pizza:' message+="\nplease input 'quit' to stop" while pizza != 'quit': pizza=input(message) if pizza != 'quit': print(pizza) message='How old are you ?' age='' while True: age=input(message) if int(age)<3: print('you can look the movie for free.') elif...
true
c74ff911b9ee2da78543d23f131934fcff166f4e
alehpineda/bitesofpy
/Bite_15/enumerate_data.py
1,061
4.1875
4
""" Iterate over the given names and countries lists, printing them prepending the number of the loop (starting at 1). Here is the output you need to deliver: 1. Julian Australia 2. Bob Spain 3. PyBites Global 4. Dante Argentina 5. Martin USA 6. Rodolfo Mexico Notice that the 2nd column sh...
true
e9220e9906b453816143716ec56a5f26cd294959
alehpineda/bitesofpy
/159/calculator.py
733
4.125
4
import operator CALCULATIONS = { "+": operator.add, "-": operator.sub, "*": operator.mul, "/": operator.truediv, } def simple_calculator(calculation): """Receives 'calculation' and returns the calculated result, Examples - input -> output: '2 * 3' -> 6 '2 + 6' -> 8 Suppo...
true
22ba385cb0df70b44cb22f6fea070d33db4ecb7a
alehpineda/bitesofpy
/Bite_107/list_comprehensions.py
570
4.15625
4
""" Complete the function below that receives a list of numbers and returns only the even numbers that are > 0 and even (divisible by 2). The challenge here is to use Python's elegant list comprehension feature to return this with one line of code (while writing readable code). """ def filter_positive_even_numbers...
true
1c0617c520da6181d9379cf8e7ba471b8b8a78c6
alehpineda/bitesofpy
/119/xmas.py
913
4.21875
4
def generate_xmas_tree(rows=10): """Generate a xmas tree of stars (*) for given rows (default 10). Each row has row_number*2-1 stars, simple example: for rows=3 the output would be like this (ignore docstring's indentation): * *** *****""" xmas = [] for row in range(1, rows + ...
true
cd70d79780f6305f1feaa9af76346bf3568d5ef5
alehpineda/bitesofpy
/127/ordinal.py
1,286
4.53125
5
def get_ordinal_suffix(number): """Receives a number int and returns it appended with its ordinal suffix, so 1 -> 1st, 2 -> 2nd, 4 -> 4th, 11 -> 11th, etc. Rules: https://en.wikipedia.org/wiki/Ordinal_indicator#English - st is used with numbers ending in 1 (e.g. 1st, pronounced first)...
true
07fff703625eb01413ea7445b7be39b9c0590681
alehpineda/bitesofpy
/Bite_3/wordvalue.py
2,730
4.21875
4
""" Calculate the dictionary word that would have the most value in Scrabble. There are 3 tasks to complete for this Bite: - First write a function to read in the dictionary.txt file ( = DICTIONARY constant), returning a list of words (note that the words are separated by new lines). - Second write a function t...
true
c1a03320e99ded66b6d47084423527e367ed43c8
Innanov/PYTHON
/Area_of_rectangle.py
282
4.1875
4
# By INNAN Nouhaila # Compute the area of a rectangle, given its width and height. width = 5 height = 9 # Rectangle area formula area = width * height print("A rectangle " + str(width) + " inches wide and " + str(height) + " inches high has an area of " + str(area) + " square inches.")
true
bf2deeb289ddb3539008fcf4312d09921fc8d477
Ratna04priya/-Python-worked-problems-
/prob_-_soln/age_finder.py
359
4.21875
4
# Gives the age from datetime import date def calculate_age(dtob): today = date.today() return today.year - dtob.year - ((today.month, today.day) < (dtob.month, dtob.day)) a= int(input("Enter the year of birth : ")) b= int(input("Enter the month of birth : ")) c= int(input("Enter the date of birth : ...
true
b8cd317c831848b1d33ba51ad96ec0acc80c1272
poly451/Tutorials
/Instance vs Class Variables/dunder classes (iter, next).py
1,819
4.3125
4
# ------------------------------------------------- # clas Car # ------------------------------------------------- class Car: def __init__(self, name, tires, seats): self.name = name self.tires = tires self.seats = seats def print_car(self): s = "name: {}, ...
true
a9036924ef986718c083163b1dff30880ad8d108
orkunkarag/py-oop-tutorial
/oop-py-code/oop-python-main.py
696
4.15625
4
# Object Oriented Programming ''' def hello(): print("hello") x = 1 print(type(hello)) ''' ''' string = "hello" print(string.upper()) ''' #creating class class Dog: #special method init def __init__(self, name, age): self.name = name #Attribute of the class Dog - unique for every object self.age = age def...
true
f7729652596f8a71a8b172e337a95a10b18435ef
alluong/code
/python/prime.py
510
4.28125
4
def is_prime(num): if num > 1: if len(check_prime_list) == 0: return True return False while 1: num = int(input("please enter a number: ")) # check_prime_list is empty if num is a prime number # otherwise, check_prime_list contains a list of divisors divisible by num ch...
true
d06da6cf62aa2ac6cc4d915a83ce74e7ac03cfc0
balbachl/CIT228-1
/Chapter10/addition.py
402
4.125
4
def addition(n,d): return n+d quit="" while quit != "q": try: n = int(input("Type an integer")) d = int(input("Type another integer")) except ValueError: print("You entered a non-integer") else: print(n, "+", d, "=", addition(n,d)) finally: print("Thank you f...
true
9c99d10cdd77bb0e433ac2e69bd0b353c469d1b3
balbachl/CIT228-1
/Chapter7/multiplesOfTen.py
235
4.28125
4
number = int(input("Please enter a number and I will tell you if it is a multiple of ten")) if number%10==0: print("The number ", number, " is a multiple of ten") else: print("The number ", number, " is not a multiple of ten")
true
4bb93fb5614fc29bc99632a3103b870995c98b4f
aavinashjha/IamLearning
/Algorithms/Sorting/mergeSort.py
2,049
4.125
4
""" - Divide array into half - Merge in sorted order - Single element is always sorted: Base Case Time Complexity: - MergeSort uses at most NlgN compares and 6NlgN array accesses to sort any array of size N - C(N) <= C(ceil(N/2)) + C(ceil(N/2)) + N for N>1 with C(1) = 0 - A(N) <= A(ceil(N/2)) + A(ceil(N/2)...
true
4ea3a2bc913ad93cb3dad696b9cc9b138ac04309
aavinashjha/IamLearning
/OOPS/Patterns/factory.py
2,921
4.8125
5
""" Problem: - Who should be responsible for creating objects when there are special considerations such as complex creation logic, a desire to separate the creation responsibilites for better cohesion? When you need a factory pattern? - When you don't know ahead of time what class object you need - Wh...
true
bbf313aac3b7fb8130c4a3f4503011d5abf59a69
Mohitgola0076/Day6-Internity
/Creating_Arrays.py
1,549
4.15625
4
''' A new ndarray object can be constructed by any of the following array creation routines or using a low-level ndarray constructor. ''' numpy.empty # It creates an uninitialized array of specified shape and dtype. It uses the following constructor − numpy.empty(shape, dtype = float, order = 'C') # Exam...
true
fbc8821835083eea2a2002bb3970d740e80cf48b
yavani/pycourse
/merge.py
675
4.21875
4
""" merge module """ def merge ( list1, list2) : # set everything to zero. i = j = k = 0 list3 = [ ] ''' The below method merges two lists in sorted order, returns sorted new list. Prerequisite: all argument lists should eb sorted. ''' while True: if len ( list1 ) == i ...
true
9fa852a2e8d7479a8e48fe829ccaae77c646b47c
AhmetGurdal/Guess-Game
/Guess-Game.py
1,914
4.125
4
#-*- coding: cp1254 -*- import random import time print "Name?" ad = raw_input(":") print "OK, ",ad,"! let's play a game I think a number that between 1 and 1000." while True: print "If u can ,guess" num = random.randrange(1,1000) ts = 1 while True: ta = input(":") if num > ta: print "up" ts = ts + 1...
true
591d3941a9c5218323cb600c46d81bfce0eb4666
yarnpuppy/Python-the-Hard-Way
/ex6.py
922
4.15625
4
# d is some sort of variable. % allows you define the value x = "There are %d types of people." % 10 # defines binary as a string binary binary = "binary" # defines do_not as the string "don't" do_not = "don't" # Compound variable description for s and s. %(s,s), allows for consecutive variable substitution. y = "Thos...
true
99be2dd68589f521adffd6594f42cc1b0c95b395
e-walther-rudman/ProjectEulerSolutions
/PE_problem4_Maxime_Emily.py
647
4.125
4
#A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 × 99. # #Find the largest palindrome made from the product of two 3-digit numbers. LargestPalindrome = 0 for FirstNumber in range(100,1000): for SecondNumber in range(FirstNumber, 1000...
true
a7e42c9f2b2ad26b47ba97061729c86bc3b14c87
MarHakopian/Intro-to-Python-HTI-3-Group-2-Marine-Hakobyan
/Homework_3/factorial.py
222
4.15625
4
def factorial_f(n): factorial_n = 1 for i in range(1, int(n) + 1): factorial_n = factorial_n * i return f"The factorial of {n} is {factorial_n}!" n = input("Enter the number: ") print(factorial_f(n))
true
f50ee5231eaa848d646ffe5aa71ad76a13498c7c
HaykBarca/Python
/tuples.py
457
4.4375
4
# A tuple is an immutable container that stores objects in a specific order my_tuple = tuple() print(my_tuple) my_new_tuple = () print(my_new_tuple) # You should add items when you creating tuple, you can't change, add, remove items from tuple tuple_items = ("Apple", "Orange") print(tuple_items) print(tuple_items[1])...
true
f1864d27157164507fde1e72b21b10d7a681701f
ashish-netizen/AlgorithmsAndDataStructure
/Python/DataStructure/Stack/stack.py
505
4.40625
4
#here we are using demonstrating stack in python #Initally we take an empty list a then we use append function to push element in the list. #printed [1,2,3] #after that elements poped out in Last In First Out Order a = [] a.append(1) a.append(2) a.append(3) print('Initial stack') print(a) print('\nEl...
true
98ac1ee97fbfb2e0b931aee26ba575164ff4d002
crawler4o/Learning_Python
/Hang_Man/hangman.py
2,483
4.375
4
### Hangman ### Exercise 32 (and Solution) ### ### This exercise is Part 3 of 3 of the Hangman exercise series. The other exercises are: Part 1 and Part 2. ### ### You can start your Python journey anywhere, but to finish this exercise you will have to have finished Parts 1 and 2 or use the solutions (Part 1 an...
true
528baefe3109452a19479d82a649018bbb35aa3b
terrylovesbird/lecture-w2-d2-OOP-CSV
/classes/animals/dog.py
676
4.34375
4
class Dog: species = "Canis Lupus Familiaris" # example of a *class attribute* sound = "Woof" legs = 4 tail = 1 mammal = True def __init__(self, name, breed): self.name = name # example of an *instance attribute* self.breed = breed def __str__(self): return f"I am a...
true
4b3d9a9351988f4e9038ed24535be5473fa8b048
jasminegrewal/algos
/algorithms/bubbleSort.py
1,050
4.125
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Mon Aug 28 11:14:37 2017 @author: jasmine """ def bubbleSort(arr): for i in range(len(arr)-1): ''' i will go from 0 to second last element last element will be compared at second last position''' for j in range((len(arr)-1)-i):...
true
b2578f87fc2bd326e5f588888a11e7a98ab670c4
Luxura/Learning
/Collatz square.py
328
4.21875
4
# this will try to use the collatz squar # if number even return number // 2, sinon number * 3 +1 # projet en cours def collatz(number): if number % 2 == 0: b = number // 2 print(b) else: b = number * 3 + 1 print(b) b = (int(input("Taper un chiffre: "))) while b != 1: col...
true
aed710442c5cf49a03b9c8e2d21eec260d75ef75
vvek475/Competetive_Programming
/Competitive/comp_8/Q2_LION_squad.py
687
4.28125
4
def reverse_num(inp): #this line converts number to positive if negative num=abs(inp) strn=str(num) nums=int(strn[::-1]) #these above lines converts num to string and is reversed if inp>0: print(nums) else: #if input was negative this converts to negative again after above proce...
true
e79b3bee9714ca2a548311b7e78fd203503d70e1
ShifaZaman/IntroToPython
/Pyramid.py
215
4.34375
4
print("Input a number to make a pyramid!") number=input() for a in range(2,13): #I started at 2 because when you start at 1, it repeats. it'll be like #3 #3 #33 #333 print(number*a) '''c="5" print(3*c)'''
true
fc0c9b2102f094a2f6b79dd97e276ed6eb0f0679
ShifaZaman/IntroToPython
/24hourto12hour.py
1,283
4.5
4
print("Type hours in 24-hour mode") hours=int(input()) hoursnew=hours%12 #% - gives you the remainder. Modulus of something that is smaller will be itself e.g 11 is smaller than 12 so it will be 11 if((hours>24)|(hours<1)): # If comparing two things, put brackets around both so it does bedmas and evaluates brackets fi...
true
bb66288e230ed522491b095ba3e344221bd27ba1
CodeSeven-7/password_generator
/password_generator.py
670
4.25
4
# password_generator.py import random import string print('Welcome to PASSWORD GENERATOR!') # input the length of password length = int(input('Enter the length of the password you would like to create: ')) # define data num = string.digits symbols = string.punctuation lower = stri...
true
df43194f5d82d5808925736e24351938641ac355
Juanjo-M/Primero
/Lab31112.py
360
4.125
4
year = int(input("Enter a year: ")) if year >= 1582: if year % 4 != 0: print("This is a common year.") elif year % 100 != 0: print("This is a leap year.") elif year % 400 != 0: print("This is a common year.") else: print("This is a leap year.") else: print("Not within...
true
473e2eff54f1ee5faa5151c8968fab0f705b73c1
unclebae/python_tutorials
/DataStructures/DictionariesTest.py
2,154
4.34375
4
# Dictionaries are sometimes found in other languages as "associative memories" or "associative arrays" # Unlike sequences, which are indexed by a range of numbers, dictionaries are indexed by keys, # which can be any immutable type; # strings and numbers can always be keys tel = {'jack':4098, 'sape':4139} tel['guido'...
true
4598d2e50265da88fab8cfe116c5581a57816524
nshagam/Python_Practice
/Divisors.py
463
4.28125
4
# Create a program that asks the user for a number and then prints out a list of all # the divisors of that number. (If you don’t know what a divisor is, it is a number that # divides evenly into another number. For example, 13 is a divisor of 26 because 26 / 13 has no remainder.) num = int(input("Enter a number: ...
true
ed105b7cf0dbaee6468a2c8a298708a344894b08
shanekelly/SoftDesSp15
/toolbox/word_frequency_analysis/frequency.py
1,568
4.5625
5
""" Analyzes the word frequencies in a book downloaded from Project Gutenberg """ import string def get_word_list(file_name): """ Reads the specified project Gutenberg book. Header comments, punctuation, and whitespace are stripped away. The function returns a list of the words used in the book as a list. A...
true
ddc7d4172e1200bef9ffa01f9b5682eab34e8be1
bearddan2000/python-cli-pydoc-ugly-num-functional-prog
/bin/main.py
1,323
4.1875
4
""" Given a number find the next number that is divides by 2, 3, or 5. """ def max_divide(a, b): """ This function divides a by greatest divisible power of b :param a: const number 2, 3, 5 :param b: current number iteration :return: max number 2, 3, 5 """ if a % b != 0: return a; ...
true
aa124bfe70359c8c48a3e43d12949bc2ec18c8d0
Sarah1108/HW070172
/hw_5/ch_6_3.py
475
4.21875
4
#exercise 3 # import math def sphereArea(radius): area = 4* math.pi * radius**2 return area def sphereVolume(radius): volume = 4/3 * math.pi* radius**3 return volume def main(): print("This programm calculates the Volume and surface area of a sphere.") print() radius = int(input("Ente...
true
a56255215d64a8f5e8481ec0ab04c7132510bf0c
AayushmanJung/pythonProjectlab1
/lab1/lab6.py
371
4.34375
4
''' Solve each of the problem using Python Scripts. Make sure you use appropriate variable names and comments. When there is a final answer have Python print it to the screen. A person's body mass index (BMI) is defined as: BMI = mass in kg / (height in m)**2 ''' mass= int(input('Enter the mass')) height= int(input('E...
true
dfcf70c0ecbb6bc19cec52deee8c5483ecce962f
divyatejakotteti/100DaysOfCode
/Day 62/Collections.deque().py
753
4.125
4
''' Task Perform append, pop, popleft and appendleft methods on an empty deque . Input Format The first line contains an integer , the number of operations. The next lines contains the space separated names of methods and their values. Constraints Output Format Print the space separated eleme...
true
edc95514a21b81e5ed7c36399fb35a1b5ba666a4
divyatejakotteti/100DaysOfCode
/Day 23/SherlockAndAnagrams.py
1,512
4.21875
4
''' Two strings are anagrams of each other if the letters of one string can be rearranged to form the other string. Given a string, find the number of pairs of substrings of the string that are anagrams of each other. For example s= mom, the list of all anagrammatic pairs is [m,m],[mo,om]at positions [[0],[2]],[[0,...
true
d0dab6a753a2682e9a5f4a898ca72cef7908d9b5
divyatejakotteti/100DaysOfCode
/Day 38/FairRations.py
2,329
4.15625
4
''' You are the benevolent ruler of Rankhacker Castle, and today you're distributing bread. Your subjects are in a line, and some of them already have some loaves. Times are hard and your castle's food stocks are dwindling, so you must distribute as few loaves as possible according to the following rules: Every...
true
dc1b524bca8b58ea8c13d461eda010e45d759ba4
divyatejakotteti/100DaysOfCode
/Day 74/CheckStrictSuperset.py
1,057
4.15625
4
''' You are given a set and other sets. Your job is to find whether set is a strict superset of each of the sets. Print True, if is a strict superset of each of the sets. Otherwise, print False. A strict superset has at least one element that does not exist in its subset. Example Set is a strict sup...
true
2f8d24b3f1bea47e316b56a6484a82888b9c80ab
divyatejakotteti/100DaysOfCode
/Day 60/WordOrder.py
1,079
4.125
4
''' You are given words. Some words may repeat. For each word, output its number of occurrences. The output order should correspond with the input order of appearance of the word. See the sample input/output for clarification. Note: Each input line ends with a "\n" character. Constraints: The sum of the le...
true
f574490c0c3e9924c031d262b6d43440d5ad5552
divyatejakotteti/100DaysOfCode
/Day 25/SequenceEquation.py
917
4.15625
4
''' Given a sequence of integers, where each element is distinct and satisfies . For each x where 1<=x<n, find any integer y such that p(p(y))=x and print the value of y on a new line. Function Description Complete the permutationEquation function in the editor below. It should return an array of integers that r...
true
2a88f0aa503ceb61fcd07144fdd10e2562c32b62
divyatejakotteti/100DaysOfCode
/Day 37/FlatlandSpaceStations.py
1,718
4.5
4
''' Flatland is a country with a number of cities, some of which have space stations. Cities are numbered consecutively and each has a road of length connecting it to the next city. It is not a circular route, so the first city doesn't connect with the last city. Determine the maximum distance from any city to it's...
true
b6be72984e340456b8f87b4ddd8ec845a21fc938
divyatejakotteti/100DaysOfCode
/Day 27/SherlockAndSquares.py
1,206
4.46875
4
''' Watson likes to challenge Sherlock's math ability. He will provide a starting and ending value describing a range of integers. Sherlock must determine the number of square integers within that range, inclusive of the endpoints. Function Description Complete the squares function in the editor below. It should r...
true
3a054171a05293d817336dc7b56af7ab7421fcb3
divyatejakotteti/100DaysOfCode
/Day 25/BeautifulDays_at_theMovies.py
1,733
4.4375
4
''' Lily likes to play games with integers. She has created a new game where she determines the difference between a number and its reverse. For instance, given the number 12, its reverse is 21. Their difference is 9. The number 120reversed is 21, and their difference is 99. She decides to apply her game to decisio...
true
339c11950657fd59e71804f3a54b0f548642c627
divyatejakotteti/100DaysOfCode
/Day 48/StrongPassword.py
2,194
4.15625
4
''' Louise joined a social networking site to stay in touch with her friends. The signup page required her to input a name and a password. However, the password must be strong. The website considers a password to be strong if it satisfies the following criteria: Its length is at least . It contains...
true
eb5770b15ba0e06dbff9cb5e9f4ac1b4aaca1453
divyatejakotteti/100DaysOfCode
/Day 06/SocksMerchant.py
1,064
4.5625
5
''' John works at a clothing store. He has a large pile of socks that he must pair by color for sale. Given an array of integers representing the color of each sock, determine how many pairs of socks with matching colors there are. For example, there are n=7 socks with colors ar=[1,2,1,2,1,3,2]. There is one pair o...
true
606334ca145a342d401e35dc271d7d0ee5080fab
joehammahz808/CS50
/pset6/mario/mario.py
789
4.125
4
# Ruchella Kock # 12460796 # this program will take a given height and print a pyramid with two spaces in between from cs50 import get_int # prompt user for positive integer while True: height = get_int("height: ") if height > 23 or height < 0: continue else: break # do this height times ...
true
110737c9958d67282c27f00c82543f97723bbf06
bpatgithub/hacker
/python/objectPlay/Inheritance.py
1,495
4.53125
5
# Understanding inheritance. # class PartyAnimal: # this class has two local data store x and name. x = 0 name = "" # now lets define constructor. # Constructor is optional. Complier will perform that operation by itself if you don't. # all methods with __ are special. # self is just the ...
true
3c6ee85b82e2410032e6f5be4c6d9750b59977e4
bpatgithub/hacker
/machineLearning/mapReduce/asymmetricFriends/mr_asymmetric_friends.py
1,780
4.21875
4
''' Find all Asymmetric relationship in a friend circle. The relationship "friend" is often symmetric, meaning that if I am your friend, you are my friend. MapReduce algorithm to check whether this property holds. It will generate a list of all non-symmetric friend relationships. Map Input Each input record is a 2 ele...
true
a8bd48aeefb58ed69fd609ffa55c27bb32aa048f
borko81/SU_OOP_2021
/Iterators_generators/fibo_gen.py
256
4.21875
4
def fibonacci(): previous = 0 current = 1 while True: yield previous previous, current = current, current + previous if __name__ == '__main__': generator = fibonacci() for i in range(5): print(next(generator))
true
b3080e1275ecd99a94af2492bfe5ed5894b48fc8
likair/python-programming-course-assignments
/Assignment3_4.py
773
4.15625
4
''' Created on 15.5.2015 A program, which finds all the indexes of word 'flower' in the following text: "A flower is a beautiful plant, which can be planted in the garden or used to decorate home. One might like a flower for its colors and the other might like a flower for its smell. A flower t...
true
b6184226d54b6c62649165d0c0cfec0eec104e2a
TimJJTing/test-for-gilacloud
/part1_multiples.py
703
4.3125
4
# part1_multiples.py # 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 find_multiples_of_3_or_5(below): # ans = [] # multiples of 3 # n = 0 # while 3...
true
f9db575371ab34db729a931c0db269a8ae17e041
wildflower-42/FLVS-Foundations-of-Programing
/FavoriteColoursProgram.py
1,710
4.375
4
#Alaska Miller #6/23/2020 #The Perpouse of this program is to prompt the human end user to input a series of questions that will have them rank their favorite colours, then the program will match them against MY previously listed into the program, favorite colours! def favoritesCompare(): #This section of code creates...
true
ea3ee2d7d504aa666b0c6823f27359135482ec0e
jeffdeng1314/CS16x
/cs160_series/python_cs1/labs/lab2/again.py
261
4.28125
4
x = input("Give me a positive number that is less than 256\n") try: x = int() if x > 256 or x <0: print('error') else: while (x > 0): print(int(x%2)) x=x//2 except ValueError: print('bad input')
true
f3ebdc3e84c3eaf396fccbe1d32eef39b1eb97e0
sarcasm-lgtm/Python-Learning
/Printing Arrays Homework Assignment.py
616
4.3125
4
#I tried doing it, but it said this: #['Ahana', 'is', 'my', 'sister'] #Traceback (most recent call last): #File "/Users/aarohi/Documents/Printing Arrays Homework Assignment.py", line 4, in <module> #v=ahana #NameError: name 'ahana' is not defined array1=["Ahana","is","my","sister"] print(array1) v="Ahana " q="i...
true
2d16bb6cf202fdccdee2c8e1b679173b652fb48c
armstrong019/coding_n_project
/Jiuzhang_practice/implement_trie.py
2,083
4.25
4
class TrieNode(): def __init__(self): self.children = {} self.is_word = False class Trie(object): def __init__(self): """ Initialize your data structure here. """ self.root = TrieNode() def insert(self, word): """ Inserts a word into the trie...
true
5ebd4360a8efde45eb3803b5e0adffea32030691
Abhishek19009/Algorithms_and_Data_structures
/Common_Algorithms/String_splitting.py
649
4.5
4
# String splitting algorithm is basic but will be used multiple times so know how to create it # String splitter will split the string into list based on the special character def string_splitter(string, replace): string_temp = "" string_list = [] for char in string: if char != replace: ...
true
981f67ed61c882fff9322d9538615cbde8a99a68
Abhishek19009/Algorithms_and_Data_structures
/Miscellaneous/Swap_quickly.py
320
4.25
4
''' Python has a very cool and short codeline to swap elements without using any temporary variable. ''' arr = [3,4,5,6,9,1] arr[2],arr[3] = arr[3],arr[2] # swap element at 3 index with element at 2 index ''' This is much shorter than creating temp variable to store 3 element and then assigning it to 2 element. '''
true
ce648722f6691b0801d22da61026fe3b8f1e04d3
Abhishek19009/Algorithms_and_Data_structures
/Data Structures/Hashing/Hashing_with_chaining.py
419
4.125
4
''' Usually hashing creates problem of multiple elements belonging to same hash. To accommodate this we can store such elements in some data structure like list. ''' # Consider the hash function f(n) = n mod 7 where n is the element of the list. arr = [15, 47, 23, 34, 85, 97, 56, 89, 70] # Creating 7 empty buckets ...
true
4e293ceb648bf422376f5deb5386b8923ef5ad57
Abhishek19009/Algorithms_and_Data_structures
/Common_Algorithms/Graph/Dijkstra_shortest_path.py
1,956
4.1875
4
# Implementing Dijkstra # Not working, fix the bug import heapq as hp class Node: def __init__(self, index, distance): # We can also add extra properties of the node. self.index = index self.distance = distance class Graph: def __init__(self, n): # n == no of nodes self.n = n self.adj = [...
true
0bf431af9180d8e61c6d6ef1bd95d453d72d9a82
antoniotorresz/python
/py/Logical/factorial_number.py
324
4.375
4
#Recursive function to calculate factorial froma given number def get_factorial(number): if not number == 0 or number == 1: return (get_factorial(number - 1) * number) else: return 1 x = int(input("Please, type a number to calculate its factorial: ")) print(str(x) + "! = " + str(get_factorial(x...
true
5a7b7cfe9cef4d67c8942b549b604ce77f2b7dd0
rusalinastaneva/Python-Advanced
/07. Error handling/01. Numbers Dictionary.py
1,039
4.3125
4
numbers_dictionary = {} line = input() class IsNotNumberStringError(Exception): """Raised when the value is a digit""" pass while line != "Search": try: number_as_string = line if number_as_string.isdigit(): raise IsNotNumberStringError("Input must be a string") numb...
true
71013446d528f0dce9a7439ee4c84b364a5ea2c6
hancoro/Python_Learn_Project
/PythonFile_RPH7_If_Statements.py
1,036
4.4375
4
# set a boolean variable as true boolean_for_if_statement = False second_boolean_for_if_statement = False # If statement with one condition if boolean_for_if_statement: print("One condition if statement HAS been met") else: print("One condition if statement was NOT met") # If statement with multip...
true
3b31c41338a759b313b8195f4765aebca106c17c
hancoro/Python_Learn_Project
/PythonFile_RPH13_Exponent_Function.py
266
4.15625
4
# this is a function that accepts 2 parameters def raise_to_the_power_of(base_num, pow_num): result = 1 for num in range(pow_num): result = result * base_num # print(num) return result print(raise_to_the_power_of(3, 3))
true
aeaf4ad44859525a4845e9a178e66bc3173c137f
hancoro/Python_Learn_Project
/PythonFile_RPH14_2d_lists_nested_loops.py
661
4.5
4
# 2d lists are essentially lists of lists # for example number_grid = [ [1, 2, 3], [4, 5, 6], [7, 8, 9], [0] ] # the example now has 4 rows with three columns # to access a specific element in the list by reference to the row and column print(number_grid[1][2]) # This will print row 1, co...
true
fba98d5bc7c45544c8dbc47aa6ca5b75c4ae7762
anuraga2/Coding-Problem-Solving
/Sorting/BubbleSort.py
404
4.1875
4
#Function to sort the array using bubble sort algorithm. def bubbleSort(self,arr, n): # code here # running the outer loop for i in range(n-1): swapped = True for j in range(n-i-1): if arr[j] > arr[j+1]: arr[j], arr[j+1] = arr[j+1], arr[j] swa...
true
386583b7139d1ffa01daaf3f430e2972e9dd821e
SravaniDash/Coursera-Python-For-Everyone
/exercises/chapter13/extractXML.py
696
4.125
4
# In this assignment you will write a Python program somewhat similar to http://www.py4e.com/code3/geoxml.py. The program will # prompt for a URL, read the XML data from that URL using urllib and then parse and extract the comment counts from the XML data, # compute the sum of the numbers in the file. # Actual Data: ht...
true
143b32c0cbf692e4072c707d9e9de0bf77fb077f
HohShenYien/Harvard-CS50
/Week6/credit.py
1,954
4.125
4
def main(): # Putting in all the return strings into a list # so that the function just return an int return_type = ["INVALID", "AMEX", "MASTERCARD", "VISA"] nums = all_nums(get_nums()) # Print invalid if failed Luhn algorithm if not luhn_check(nums): print(return_type[0]) # Prev...
true
b84126a63bac595977f08afcfe84130d80bd6f64
Jahir575/Python3.8OOP
/EmployeeAssaignment.py
1,342
4.4375
4
""" Create an Employee class with following attributes and methods: - constructor, which will create an instance of Employee class based on provided arguments: first name, last name, email address and monthly salary - get_annual_salary method, which will calculate and return employee annual salary - show_employe...
true
a34dc0a076d26372679924c80bafee594878891b
gocommitz/PyLearn
/pydict.py
732
4.15625
4
#Import library import json #Loading the json data as python dictionary #Try typing "type(data)" in terminal after executing first two line of this snippet data = json.load(open("data.json")) #Function for retriving definition def retrive_definition(word): if word in data: return data[word] elif word.t...
true
941223ed6e1f2897992eb7b0db86c7918305110a
Bshock817/basic-python
/basic2.py
1,709
4.1875
4
""" # Countdown - Create a function that accepts a number as an input. # Return a new list that counts down by one, from the number (as the 0th element) down to 0 (as the last element). def countdown(num): nums = [] for val in range(num,-1,-1): nums.append(val) return nums print(countdown(1...
true
1111183e8cd379b298acbc3535787508395ba06b
Ajay-Puthiyath/Luminar_Django
/Luminar_Project/Flow_Controls/Decesion_Making_Statement/Maximum_Of_Three_Numbers.py
985
4.25
4
num1 = int(input("Enter the first number")) num2 = int(input("Enter the second number")) num3 = int(input("Enter the third number")) if(num1>=num2) and (num1>=num3): largest = num1 print("The largest number is",largest) elif(num2>=num1) and (num2>=num3): largest = num2 print("The largest number is",larg...
true
e8a759ffe437a57b693b79f6d3eb7dcff18f921e
addinkevin/programmingchallenges
/MedalliaChallenges/2017Challenge/problema2.py
1,382
4.1875
4
import unittest """ Given an integer n, we want you to find the amount of four digit numbers divisible by n that are not palindromes. A palindromic number is a number that remains the same when its digits are reversed. Like 1661, for example, it is "symmetrical". For example, if n equals 4000, the only four digit numb...
true
04caeadc2469e4bca2256b0731e62ee1d93c13a1
SreeramSP/Python-Data-Collection-and-Processing
/#Below, we have provided a list of tuuple.py
399
4.34375
4
#Below, we have provided a list of tuples that contain students’ names and their final grades in PYTHON 101. Using list comprehension, create a new list passed that contains the names of students who passed the class (had a final grade of 70 or greater). l1 = ['left', 'up', 'front'] l2 = ['right', 'down', 'back']...
true
fc72535954544203ce0c60b5dbdfa23c608bf7f3
JustinKnueppel/CSE-1223-ClosedLab-py
/ClosedLab07a.py
374
4.25
4
def getWordCount(input): numWords = 1 while " " in input: numWords += 1 input = input[input.index(' ') + 1: len(input)] return numWords string = input('Enter a string: ') while not string: print('ERROR - string must not be empty\n') string = input('Enter a string: ') print(getWordCount(string)) print('Your s...
true
e68cf7c5c99d97df4dc021ba20c7a0fd01ae791b
UF-CompLing/Word-Normalization
/FromLecture.py
1,010
4.21875
4
import re TextName = 'King-James-Bible' ## ~~~~~~~~~~~~~~~~~~~~ ## START OF FUNCTIONS print('opening file\n') input_file = open('Original-Texts/' + TextName + '.txt', 'r') # the second parameter of both of these open functions is # the permission. 'r' means read-only. # # The 'Original-Texts/' part is so that i...
true
2aa0ea0761121f1eeb626b17e3c04c97282c9bd1
amcclintock/Breakfast_Programming_Guild
/broken_1_6.py
1,217
4.46875
4
Take user input, and tell me stuff about the data user_input = input('Enter something:') #Check if the data contains alpha if (user_input.isalpha()): print (user_input, " contains alpha characters") #Do some math on characters three_user_input = user_input * 3 print (user_input, " three...
true
abad7aaa10a6918b8eb3b763e179178eeb677253
driscoll42/leetcode
/0876-Middle_of_the_Linked_List.py
1,381
4.15625
4
''' Difficulty: Easy Given a non-empty, singly linked list with head node head, return a middle node of linked list. If there are two middle nodes, return the second middle node. Example 1: Input: [1,2,3,4,5] Output: Node 3 from this list (Serialization: [3,4,5]) The returned node has value 3. (The judge's seria...
true
016b4c71006d62f4ca5857c8d3eb52c46a109c74
saisatwikmeda/Personal-Programs
/find_short.py
471
4.15625
4
#Sai Satwik Reddy Meda # Returning the length of the smallest word in a given string def find_short(s): L = s.split(' ') #split list final = "" final = L[0] for i in range(len(L)): if len(final) > len(L[i]): final = L[i] # Assign smallest word everytime it changes i += 1 ...
true
36ad03ca7141958e68f7429d438c9f0f7a51834e
clintmod/aiden
/2023.05.06/Worldcount.py
451
4.15625
4
# Ask the user to enter a sentence sentence = input("Enter a sentence: ") # Initialize a variable to count vowels vowel_count = 0 # Loop over each character in the sentence for char in sentence: # Check if the character is a vowel if char.lower() in "aeiou": # If it is, increment the vowel count ...
true
98c9974136879a86fbc53fcc7ec65c4ee81b9864
Davin-Rousseau/ICS3U-Assignment-6-Python
/assignment_6.py
1,198
4.25
4
#!/usr/bin/env python3 # Created by: Davin Rousseau # Created on: November 2019 # This program uses user defined functions # To calculate surface area of a cube import math def surface_area_cube(l_c): # calculate surface area # process surface_area = (l_c ** 2) * 6 # output return surface_area...
true
83376880f7ac1c33a8b35d4b00b6b703891a1d32
jkim23/python-code-samples-1
/radius JTKIM (1).py
445
4.34375
4
#jt kim #2.29.2019 #compute radius of circle #radius = int(input("Enter radius for your circle: ")) #area_of_circle = (radius * 3.14) * radius #print ("Your circle is: ", area_of_circle) def areaOfCircle(radius): area = (radius ** 2) * 3.14 return area print("the area of the circle is ", areaOfCir...
true
4cbdb9a15e97a8bc1158cc1db2588d095bfc6003
carlos-carlos/different-solutions
/solution_03.py
1,535
4.46875
4
''' Write a script that sorts a list of tuples based on the number value in the tuple. For example: unsorted_list = [('first_element', 4), ('second_element', 2), ('third_element', 6)] sorted_list = [('second_element', 2), ('first_element', 4), ('third_element', 6)] ''' #driver code and empty list for the desired resu...
true
34dc764b76b229373cda809ddde5a0372170ef6b
outoftune2000/Python
/strings/substringcount.py
508
4.5
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- #program to count the number of times a given substring has been repeated in a given string def countingSubstrings(string,substring): count=0 for i in range(0,len(string)): if string[i:i+len(substring)]==substring: count=count+1 return count...
true
accd5bfd406cab61113d642643f2bed1307bd865
danieltshibangu/Mini-projects
/kilometer.py
598
4.34375
4
# This program will prmpt for distance in km # then convert distace to miles by formula # miles = kilometers * 0.6214 # define variables miles = 0.0 kilometers = 0.0 # define miles constant K_FACTOR = 0.6214 # main will prompt for kilometers, # use km to miles funtion # print result def main(): kilometers = floa...
true
1cdb8009743880959b3f7b17feecfec0a3e64031
danieltshibangu/Mini-projects
/PYTHON PRACT.py
598
4.21875
4
# This program displays property taxes TAX_FACTOR = 0.0065 #Represents tax factor # Get the first lot number print( 'Enter the property lot number' ) print( 'or rnter 0 to end.' ) lot = int( input( 'Lot number: ' ) ) # continue processing as long as the user # does not enter lot number 0 while lot != 0: #Get...
true
a2b2651ad516b9d159954d37d301cda056dcced4
danieltshibangu/Mini-projects
/initials.py
932
4.1875
4
# this program gets title data from user and # prints the data # the main function gets a first, middle and # last name from user, passing them as arguments # for get_initials functions. Initial name # entered and the initials of name printed def main(): first = input( "Enter first name: " ) middle = input( "...
true
e6710b0744d0703493aa2434f4a7a171cda70c28
danieltshibangu/Mini-projects
/total_sales.py
709
4.34375
4
# this program will display the total sales for # the days of the week # DAYS_OF_WEEK is used as a constant for the # size of the list DAYS_OF_WEEK = 7 def main(): # create the list for days of the week sales = [0] * DAYS_OF_WEEK # define the accumulator total = 0.0 # get the sales for each day ...
true
ba2de7234a0c6c4ad0c467db583dd97bd6721be2
danieltshibangu/Mini-projects
/kinetic_energy.py
732
4.3125
4
# program calculates kinetic energy of object # define variables mass = 0.0 velocity = 0.0 k_energy = 0.0 # main function will prompt for # mass and velocity, call the kinetic_energy # function and display the kinetic energy def main(): mass = float( input( "Enter mass in kilograms: " ) ) velocity = float( i...
true