blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
2d7c28b85fb3133aaba47533de077cdd16e4a802
yohanesusanto/Markovchaintextgenerator
/markov_chain_text_generator.py
2,486
4.21875
4
# https://blog.upperlinecode.com/making-a-markov-chain-poem-generator-in-python-4903d0586957 # I found this on the web where a text-file is read, first. Following this, for each word in # the text-file as key, a Python-Dictionary of words-that-immediately-followed-the-key was # constructed. We start from a random-in...
true
57367bee7da71ff6af5f18f68296240fda53b7d1
gkimetto/PyProjects
/GeneralPractice/ListComprehension.py
415
4.21875
4
x = [i for i in range(10)] print(x) squares = [] squares = [i**2 for i in range(10)] print(squares) inlist = [lambda i:i%3==0 for i in range(5)] print(inlist) # a list comprehension cubes = [i**3 for i in range(5)] print(cubes) # A list comprehension can also contain an if statement to enforce # a condition on...
true
d6fca675a0adb8f5a09db74ccc24d3b540ceb578
gkimetto/PyProjects
/GeneralPractice/OddOrEven.py
2,323
4.375
4
''' Exercise 2: 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? Extras: If the number is a multiple of 4, print out a different message. Ask the user for two numbers: on...
true
b413b106ed1265d8fbfd7748c0d04678475d9c04
Teju-28/321810304018-Python-assignment3
/321810304018-Three strings comparision.py
658
4.5
4
#!/usr/bin/env python # coding: utf-8 # ## Take three inputs from user and check: # # 1. all are equal # 2. any two are equal # In[1]: str1=str(input("Enter first string:")) str2=str(input("Enter second string:")) str3=str(input("Enter third string:")) if (str1==str2==str3): print("All Strings are equal") eli...
true
8e9a5d0c7b5e4fd51b61170d49ec38caeedf3df3
luke-mao/Data-Structures-and-Algorithms-in-Python
/chapter7/q1.py
1,203
4.1875
4
""" find the second-to-last node in a singly linked list. the last node is indicated by a "next" reference of None. Use two pointers: this idea is quite common in Leetcode """ from example_singly_linked_list import SinglyLinkedList def find(linked_list): # import a linked list, find the second-to-last node, prin...
true
557bf6b8bd015627f607db208d919275ed3d275f
luke-mao/Data-Structures-and-Algorithms-in-Python
/chapter6/q13.py
617
4.25
4
""" a deque with sequence (1,2,3,4,5,6,7,8). given a queue, use only the deque and queue, to shift the sequence to the order (1,2,3,5,4,6,7,8) """ from example_queue import ArrayQueue from example_double_ended_queue import ArrayDoubleEndedQueue D = ArrayDoubleEndedQueue() for i in range(1, 8+1): D.add_last(i) Q...
true
470b2df2a6bc64b4d49ede0eaf8e7e37e24df276
luke-mao/Data-Structures-and-Algorithms-in-Python
/chapter6/q21.py
1,326
4.375
4
""" use a stack and queue to display all subsets of a set with n elements """ from example_stack import ArrayStack from example_queue import ArrayQueue def subset_no_recursion_use_array_queue(data): """ stack to store elements yet to generate subsets, queue store the subsets generated so far. method:...
true
94ff02e3cac8ae2fcd69ad2f9dde568f470a4650
luke-mao/Data-Structures-and-Algorithms-in-Python
/chapter7/q3.py
814
4.125
4
""" describe a recursive algorithm that count the number of nodes in a singly linked list method: similar to the counting of the height of a tree, quite simple and straightforward """ from example_singly_linked_list import SinglyLinkedList def count(node): """give the head element, count the number""" if n...
true
0297636bbc9549fdf551e3bf55740326e9c05f34
je-clark/decoratorsexamples
/advanced_decorated_function.py
1,445
4.21875
4
# This is an advanced example for decorators. Not only can we access information # about the function and control its execution, but the decorator can take arguments # so that it can be reused for multiple functions from random import choice, randint def add_description(operation = ""): # Contains details about the d...
true
ebea4a362f1872bd045bd5cd66f63c84586d31d8
ymsonnazelle/MITx-6.00.1x
/odd.py
440
4.28125
4
''' Week-2:Exercise-Odd Write a Python function, odd, that takes in one number and returns True when the number is odd and False otherwise. You should use the % (mod) operator, not if. This function takes in one number and returns a boolean. ''' #code def odd(x): ''' x: int returns: True if x is odd, Fal...
true
d6ab975cd8404bb702b4bc7bd4a931914dea1ab9
Constantino/Exercises
/Python/fill_it_nice.py
796
4.15625
4
from sys import argv def quick_sort(List): if len(List) > 1: pivot = len(List)/2 numbers = List[:pivot]+List[pivot+1:] left = [e for e in numbers if e < List[pivot]] right =[e for e in numbers if e >= List[pivot]] return quick_sort(left)+[List[pivot]]+quick_sort(right) return List de...
true
9d43b7e00a1fdd19d9d3f6e17517347dbcee3b67
leihuagh/python-tutorials
/books/AutomateTheBoringStuffWithPython/Chapter13/PracticeProjects/P4_PDFbreaker.py
1,497
4.21875
4
# Say you have an encrypted PDF that you have forgotten the password to, but you # remember it was a single English word. Trying to guess your forgotten password # is quite a boring task. Instead you can write a program that will decrypt the # PDF by trying every possible English word until it finds one that works. # #...
true
01146104e5b2d6fb2000615363f9103a9ba7c385
fedeweit-2/Programming
/problemset_08_weithaler/priority_queue.py
1,552
4.25
4
# Implementation of the unbounded Priority Queue ADT using a Python list # with new items appended to the end. class PriorityQueue: # Create an empty unbounded priority queue. def __init__(self): self._qList = list() # Returns True if the queue is empty. def is_empty(self): return len(...
true
ef566a5ea5da4dc682bd2948db1b60cc5ca4d5b1
bouzidnm/python_intro
/notes_27Feb2019.py
2,620
4.75
5
## Notes for 27 Feb 2019 ## For loops; .append(); .keys(); .values() ## Used to iterate over a sequence of values; to simplify redundant code ## Print out each item of a list individually my_list = ['A', 'B', 'C', 'D', 'E'] ## Two types of for loops ### Easy way: prints item for i in my_list: # 'i is a variable that ...
true
410bd8f7ae4f92900d83942c680df24852cbe029
kevinlong206/learning-python
/70sum.example.py
360
4.1875
4
# there is a list comprehension in this one # but it the entire list needs to be created # before sum can run on the list s1 = sum([n**2 for n in range(10**6)]) # these are the same, s3 just has redunant parenthesis # this is a generator expression s2 = sum((n**2 for n in range (10**6))) s3 = sum(n**2 for n in range...
true
e1be6d365efe0a2972c48dff9551d9d53fb53778
drafski89/useful-python
/file_handling/file_handling.py
1,577
4.4375
4
# Purpose: Demonstrate basic file handling with Python 2 # Declare the input and output file names (same directory) # Note: Possible to declare the full path if reading from another directory INPUT_FILE_NAME = "input.txt" OUTPUT_FILE_NAME = "output.txt" # Open the input file as "r" reading with open(INPUT_FILE_NAME, ...
true
68021c77c0ee0ad4339ea6f035207dae6ea9a485
drafski89/useful-python
/loops/for.py
305
4.1875
4
# Basic example of implementing a for-loop # Create a variable called count to hold the current count count = 1 print x # For loop # for [variable] in range (start amount, stop amount, increment amount) for count in range(1, 12, 1): # Add 1 to count and print the result count = count + 1 print count
true
e1d807afe73812d5149402af15cac11853f59233
o9nc/CSE
/Jazmeene Hangman.py
1,127
4.15625
4
import random # import string """ A general guide for Hangman 1. Make a word bank - 10 items 2. Pick a random item from list 3. Add a guess to the list of letters guessed 4. Reveal letters already guessed 5. Create the win condition """ movie_list = ["Love in basketball", "Vampire diaries", "Insidious", "Split", "The ...
true
a99987bd4112710b8d4e4e10c9de1e9c7e3710ba
humengdoudou/a_func_a_day_in_python
/test_random_20180329.py
1,275
4.40625
4
#!/usr/bin/python # -*- coding: UTF-8 -*- # # This is the python code for testing random function in python lib. # # Author: hudoudou love learning # Time: 2018-03-29 import random # random lib test print(random.random()) # randomly generate a float in [0,1) print(random.uniform(1, 5)) ...
true
8dbdc538a049d3e4552a1ddc9e328975bd4abbe6
cvhs-cs-2017/practice-exam-lucasrosengarten
/Range.Function.py
291
4.34375
4
"""Use the range function to print the numbers from 1-20""" x = (1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20) print (x) """Repeat the exercise above counting by 2's""" a = (2,4,6,8,10,12,14,16,18,20) print (a) """Print all the multiples of 5 between 10 and 200 in DECENDING order"""
true
c6c6d77afa2d449f6763a5bb23130d419a37a84a
Olugbenga-GT/Python-Chapter-three
/Cubes _and _Squares.py
597
4.5625
5
# 3.7 (Table of Squares and Cubes) In Exercise 2.8, you wrote a script to calculate the # squares and cubes of the numbers from 0 through 5, then printed the resulting values in # table format. Reimplement your script using a for loop and the f-string capabilities you # learned in this chapter to produce the following ...
true
877fcdfb0769400495a89e19e70e4d3404fca59e
deepikavashishtha/pythonLearning
/gen.py
525
4.3125
4
"""Modules for demonstrating generator execution""" def take(count, iterable): """ This method takes items from iterable :param count: :param iterable: :return: generator Yields: At most 'count' items from 'iterable' """ counter = 0 for item in iterable: if counter == cou...
true
bd09846b2d246ce7e11ebf73af0254c249690554
utkarshsaraf19/python-object-oriented-programming
/08_docstrings/eigth_class.py
1,263
4.375
4
import math class Point: """Represents the point in two dimensional coordinate""" def __new__(cls): """ Constructor class which is called before object is created """ print("Creating instance") return super(Point, cls).__new__(cls) # default values initializer ...
true
3b227b93f6e65cd6c6ff748afec1474172627bb8
jp-tran/dsa
/problems/subsets/evaluate_expression.py
1,291
4.4375
4
""" Given an expression containing digits and operations (+, -, *), find all possible ways in which the expression can be evaluated by grouping the numbers and operators using parentheses. Soln: If we know all of the ways to evaluate the left-hand side (LHS) of an expression and all of the ways to evaluate the rig...
true
113e00314debeb37a36fcf3e82b203f5d5a3dd34
yaswanth12365/coding-problems
/Ways to sort list of dictionaries by values in Python.py
893
4.5625
5
# Python code demonstrate the working of sorted() # and itemgetter # importing "operator" for implementing itemgetter from operator import itemgetter # Initializing list of dictionaries lis = [{ "name" : "Nandini", "age" : 20}, { "name" : "Manjeet", "age" : 20 }, { "name" : "Nikhil" , "age" : 19 }] # using sorted an...
true
d658869baf27a2d2dc76621f91fbece0700f136c
yaswanth12365/coding-problems
/Python program to interchange first and last elements in a list.py
342
4.25
4
# Python3 program to swap first # and last element of a list # Swap function def swapList(list): # Storing the first and last element # as a pair in a tuple variable get get = list[-1], list[0] # unpacking those elements list[0], list[-1] = get return list # Driver code newList = [12, 35, 9, 56, 24] prin...
true
886af12ca48a2c80ab930372a4c03897c6cc5b70
wangjiliang1983/test
/crashcourse/ex08_08_albumwhile.py
448
4.15625
4
def make_album(singer, album): album_dict = {'singer': singer, 'album': album} return album_dict while True: print("\nPlease give me the singer name and album name:") print("(Enter 'q' to quit)") singer = input("Please enter the singer name: ") if singer == 'q': break album = input...
true
f8bfeceaa6e54f795b199327b66439031eca81f5
rayallen20/Problem-Solving-with-Algorithms-and-Data-Structures-Using-Python
/Chapter1. Introduction/code/input.py
268
4.1875
4
aName = input('Please enter your name ') print("Your name in all capitals is ", aName.upper(), "and has length ", len(aName)) sRadius = input("Please enter the radius of the circle ") radius = float(sRadius) diameter = 2 * radius print("diameter is %E\n" % diameter)
true
ae4cf9a310cb91aa9e3f5c3f8f59178816f898c2
lukapejic23/pythonintro
/big_fibonacci.py
276
4.34375
4
def big_fibonacci(): previous_num, result = 0, 1 desiredlength = int(input("enter the number of digits : ")) while len(str(result)) < desiredlength: previous_num, result = result, previous_num + result return result print(big_fibonacci())
true
009c7bb85317759c5b43e03e579f3186251f5d1e
Platforuma/Beginner-s_Python_Codes
/9_Loops/32_For_Loop--Counting-char-in-string.py
466
4.28125
4
''' Write a Python program that accepts a string and calculate the number of digits and letters. Sample Data : Python 3.2 Expected Output : Letters 6 Digits 2 ''' string = input("Enter a string: ") digit = length = 0 for char in string: if char.isdigit(): digit = digit + 1 elif char....
true
d2f76c0be047088b29d7ea7097a8b4e0ea4c8ce4
Platforuma/Beginner-s_Python_Codes
/8_Conditional_Statements/18_if_Dictionary--Month-Days.py
2,510
4.34375
4
''' Write a Python program to convert month name to a number of days. Expected Output: List of months: January, February, March, April, May, June, July, August , September, October, November, December Input the name of Month: February No. of ...
true
38c52b307d8135e8ee48d71215fe91edbda459bf
TomKite57/advent_of_code_2020
/python/headers/day2.py
1,701
4.25
4
# -*- coding: utf-8 -*- """ Day 2 of Advent of Code 2020 This script will read a file formatted as such: int1-int2 char: string and will process the code according to two criteria 1) int1 <= string.count(char) <= int2 2) (string[int1-1], string[int2-1]).count(char) == 1 Tom Kite - 02/12/2020 """ from aoc_tools.adve...
true
d6bcd3d1109cc2db021ae1e6850cfad606f11e05
pallegithub/Python
/Assignment5_case8.py
251
4.15625
4
def factorial(n): if n == 0: print("") return 1 else: recurse = factorial(n-1) result = n * recurse print(result) return result n=int(input("Enter the number=======>")) factorial(n)
true
49dc5f99bdc0a52cebad58b4c102456ad0383451
estoicodev/holbertonschool-higher_level_programming-1
/0x0B-python-input_output/2-read_lines.py
516
4.34375
4
#!/usr/bin/python3 """This module defines the read_lines function""" def read_lines(filename="", nb_lines=0): """Reads n lines of a text file (UTF8) and prints it to stdout Args: filename (str): Filename nb_lines (int): number of lines to read """ with open(filename, encoding='utf-8') as file...
true
8732c89f39d09ae65d70f900e2ab925c346d600f
debajit13/100Days-of-Code
/Practice/Sum_of_first_&_last_digit.py
324
4.125
4
def sum(n): #calculate sum of the first and last digit last_digit = n%10 first_digit = n while(first_digit > 10): first_digit = first_digit//10 s = first_digit + last_digit return s print("_____SUM OF FIRST AND LAST DIGIT_____") number = int(input("Enter the number : ")) print(sum(numbe...
true
f9c6385b3b4024830c34dd69cd813a906e253bc3
ramondfdez/57Challenges
/1_InputProcessingOutput/6_RetirementCalculator.py
1,295
4.625
5
# Your computer knows what the current yearis, which means # you can incorporate that into your programs. You just have # to figure out how your programming language can provide # you with that information. # Create a program that determines how many years you have # left until retirement and the year you can retire. I...
true
a5e7632f74441340f70c9be95fda130df0b0f128
ramondfdez/57Challenges
/7_WorkingWithFiles/44_ProductSearch.py
1,522
4.21875
4
# Create a program that takes a product name as input and # retrieves the current price and quantity forthat product. The # product data is in a data file in the JSON format and looks # like this: # { # "products" : [ # {"name": "Widget", "price": 25.00, "quantity": 5 }, # {"name": "Thing", "price": 15.00, "quantity": ...
true
9acd2a0ca2f4a748b78c5e01956821ce6eb66b7f
ramondfdez/57Challenges
/1_InputProcessingOutput/3_PrintingQuotes.py
880
4.40625
4
# Quotation marks are often used to denote the start and end # of a string. But sometimes we need to print out the quotation # marks themselves by using escape characters. # Create a program that prompts for a quote and an author. # Display the quotation and author as shown in the example # output. # # Example Output ...
true
5bad112b200e163bc45bc8371d13b0f41b0f13e0
ramondfdez/57Challenges
/7_WorkingWithFiles/46_WordFrequencyFinder.py
1,255
4.3125
4
# Knowing how often a word appears in a sentence or block # of text is helpful for creating word clouds and other types # of word analysis. And it’s more useful when running it # against lots of text. # Create a program thatreads in a file and counts the frequency of words in the file. Then construct a histogram displa...
true
f6e368eb5ae65130f7c0b7b26b64fbaf4d4f726c
ramondfdez/57Challenges
/2_Calculations/12_ComputingSimpleInterest.py
1,364
4.3125
4
# Computing simple interest is a great way to quickly figure # out whether an investment has value. It’s also a good way # to get comfortable with explicitly coding the order of operations in your programs. # Create a program that computes simple interest. Prompt for # the principal amount, the rate as a percentage, an...
true
1ea4a6f2876cf5613140319832f031efa1ec3870
ramondfdez/57Challenges
/6_DataStructures/38_FilteringValues.py
1,189
4.40625
4
# Sometimes input you collect will need to be filtered down. # Data structures and loops can make this process easier. # Create a program that prompts for a list of numbers, separated by spaces. Have the program print out a new list containing only the even numbers. # # Example Output # Enter a list of numbers, separa...
true
a86966cedb820536a599aaec9cbe373c3f7a659f
arpan-k09/INFOSYS-PYTHON-PROG
/6_1.py
389
4.28125
4
#PF-Assgn-40 def is_palindrome(word): s = word.lower() string = "".join(reversed(s)) if string == s: return True else: return False #Provide different values for word and test your program result=is_palindrome("MadAMa") print(result) if(result): print("The given word is a...
true
4b8cf0ab6a4a0e6a4baa6118840c963513b3dbd9
GarciaFrida/Python_Projects_DC
/multiple.py
956
4.25
4
#Create a program that will ask for a username and then a password. #If the username or password length is less than 6 charecters give a too short message. #if the username or password length is greater than 12 charecters give a too long message #Have the user confirm the password in again. #If the passwords match give...
true
e8afc6fd440c9102c0c60ac608e4c8d2ad29c966
GarciaFrida/Python_Projects_DC
/hello.py
730
4.5
4
my_name = "Frida" #my_name is the variable name and it prints out the statement "Frida" which is my name my_favorite_drink = "beet juice" my_favorite_dessert = "cookie" my_favorite_meal = "french fries and a big fat juicy burger" #print(my_name) #print(my_favorite_drink) #print(my_favorite_dessert) #print(my_favorite...
true
a7eae1870e22708722fe5ebb8d5a8ae208eea9a0
GarciaFrida/Python_Projects_DC
/name_welcome.py
412
4.40625
4
#Create a program that asks for your name and the returns it back to you with a greeting. #Use Variables when possible #Create a program that will ask for you age and then put 3 lines down and say "wow" at the end. #Only 2 strings can be used. print("Hi there, please insert your name ") user_name = input() print("W...
true
6bf763f1050fb481c74265266eddba815411b32a
rtate7/CSS-225-Module-4
/time.py
421
4.21875
4
# Edited for debugging by Robert Tate on 1/22/21 # # Gets current time and wait time from user and prints the time # when the wait will be completed currentTimeStr = input("What is the current time (in hours 0-23)? ") waitTimeStr = input("How many hours do you want to wait? ") currentTimeInt = int(currentTimeStr) wa...
true
c00c0f0befdb7c80ed1d2fc8f46af15f8f8f8497
enchantress085/Python-Basic
/Functions_loops/even_odd_num.py
1,290
4.3125
4
# -*- coding: utf-8 -*- """ Odd or even Number using for loops """ for n in range(1, 20): #-- [2,3,4,5,6,7,8,9.....] for x in range(2,n):#-- [],[2],[2,3],[2,3,4].... if n % x == 0: print(f'{n} Equals {x} * {n//x} >') break else: print(f"{n} is a prime Number >") #...
true
a431d456c7bff65f589faf3675b398599b44a543
enchantress085/Python-Basic
/advance_set.py
976
4.46875
4
""" A set is an unordered collection of items. Every element is unique (no duplicates) and must be immutable (which cannot be changed). However, the set itself is mutable. We can add or remove items from it. Sets can be used to perform mathematical set operations like union, intersection, symmetric difference etc....
true
f154da00adc92b4aee4b2782e23da8360820e5cd
maoriko/w3resource
/6 get list and tuple input.py
316
4.34375
4
# Write a Python program which accepts a sequence of comma-separated numbers from user and generate a list and a tuple with those numbers. input_list = input("to get list please enter your numbers seperated with comma: ") list = input_list.split(",") tuple = tuple(list) print('List :', list) print('Tuple:', tuple)
true
28027fb02ced983b8365a26bae6b7b9ef4f4d39f
abhishekbisneer/Python_Code
/Exercise-24.py
1,364
4.46875
4
#Exercise 24 (and Solution) ''' This exercise is Part 1 of 4 of the Tic Tac Toe exercise series. The other exercises are: Part 2, Part 3, and Part 4. Time for some fake graphics! Let’s say we want to draw game boards that look like this: --- --- --- | | | | --- --- --- | | | | --- --- --- | | ...
true
09277ed6f52083f817f9bdc9226d7b14836b92a5
abhishekbisneer/Python_Code
/Exercise-26.py
2,855
4.15625
4
#Check Tic Tac Toe Solutions #Exercise 26 ''' This exercise is Part 2 of 4 of the Tic Tac Toe exercise series. The other exercises are: Part 1, Part 3, and Part 4. As you may have guessed, we are trying to build up to a full tic-tac-toe board. However, this is significantly more than half an hour of coding, so we’r...
true
e12517c6df4f7796b63bdc26efef650d43c127c6
abhishekbisneer/Python_Code
/Exercise-33.py
1,210
4.625
5
#Birthday Dictionaries #Exercise 33 (and Solution) ''' This exercise is Part 1 of 4 of the birthday data exercise series. The other exercises are: Part 2, Part 3, and Part 4. For this exercise, we will keep track of when our friend’s birthdays are, and be able to find that information based on their name. Create a ...
true
96f6a4af0f3d01f702cc3785c70d2ae712206015
SnyderMbishai/python_exercises
/reverse.py
372
4.125
4
def reverse_string(): string = input("Write a sentence of your own choice: ") new_string = [] string = string.split() l = len(string)-1 for i in string: new_string.append(string[l]) l -= 1 return (' '.join(new_string)) print(reverse_string()) #a simpler way string2=input("sentence here: ...
true
9f50209768c777ae643c87f4e036ffabed413545
SnyderMbishai/python_exercises
/arithmetic.py
761
4.15625
4
"""Create a program that reads two integers, a and b, from the user.Your program should compute and display: • The sum of a and b • The difference when b is subtracted from a • The product of a and b""" from math import log10 def arithmetic(): a = int(input("Enter a number: ")) b = int(input("Enter ...
true
53584396541214a896e050f167ba024c47cbf905
AngryCouchPotato/AlgoExpert
/arrays/LongestPeak.py
1,405
4.40625
4
# Longest Peak # # Write a function that takes in an array of integers and returns # the length of the longest peak in the array. # # A peak is defined as adjacent integers in the array that are strictly # increasing until they reach a tip ( the highest value in the peak), # at which point they become strictly decreasi...
true
ef9b1893fc0559fed7835ae8f434577db66302cc
nchullip/Group-Project-I-Data-Analysis
/GetCountryList.py
863
4.34375
4
# Importing Dependencies import pandas as pd import numpy as np def get_country_list(data_file, num): ################################################ # This function takes the Data file as input and returns # a list of countries with the most population. # # Argument: data_file - CSV file # num - In...
true
50799ccd441cbb2651a1e265d81def7c9b083d4d
guhaneswaran/Django-try
/scratch_7.py
782
4.125
4
# Instance variables - changes depends on the object. Defined inside __init__ # Class Variables - is fixed. Defined outside __init__ inside the class # Namespace- the space where we create and store object/variable # Class namespace - to store all the class variable # Instance namespace - to store all the ...
true
4eafb7b0b9bd65b3f7cb8184dd33250f056cf10f
guhaneswaran/Django-try
/scratch_8.py
1,387
4.15625
4
# Methods: # Instance method , class method , static method # Instance method - two types Accessor method and Mutator method # Accessor method - Just fetch the value of instance variable # Mutator method - Change the value of the instance variable class Student: school = 'Telusko' # Class variable ...
true
e36fe2b79f4190942303519cef67a3ddc26a7982
VendrickNZ/GuessTheNumber
/GuessTheNumber.py
1,677
4.3125
4
import random """The computer generates a random number and the user tries to guess it.""" def random_number(): """picks a random number from a range function and returns the range bounds and chosen number""" range = number_range() low = range[0] high = range[1] return (random.randrange(low, ...
true
973095bd95e959ab76aaa94a2cc19ced49761efd
marshalloffutt/lists
/places.py
650
4.5625
5
places = ["Mars", "Egypt", "Venice", "Tokyo", "Vancouver"] # Print places print(places) # Print sorted places in alphabetical order print(sorted(places)) # Print original places print(places) # Print sorted places in reverse alphabetical order print(sorted(places, reverse=True)) # Show that original list is unchan...
true
1504c91c99c544ff2fd4baa478f7ac6a048d7132
pallavim98/ProxyCloud
/Threading/threading_example.py
1,789
4.78125
5
# Python program to illustrate the concept # of threading # importing the threading module import threading def print_cube(num): """ function to print cube of given num """ print("Cube: {}".format(num * num * num)) def print_square(num): """ function to print square of given num """ ...
true
f28878e88c75381e75a59524d9f1a2a62b39ef09
Derrick-Guo/Learning
/EPI/EPI12-1.py
592
4.15625
4
# Tip: A string can be permuted to form a palindrome if and only if # the number of chars whose occurence is odd is at most 1. import collections def can_form_palindrome(s): res=collections.Counter(s) counter=0 for num in res.values(): if num%2!=0: counter+=1 if counter>1: return False return True # Optim...
true
46afe5aea6c250f16ea65ced3f693900dba39db4
rastgeleo/python_algorithms
/etc/finding_gcd.py
403
4.125
4
def finding_gcd(a, b): """Euclid's algorithm 21 = 1 * 12 + 9 12 = 1 * 9 + 3 9 = 0 * 3 + 0 """ while (b != 0): result = b a, b = b, a % b print(a, b) return result def test_finding_gcd(): number1 = 21 number2 = 12 assert(finding_gcd(number1, numb...
true
13cb53b4afc73762e4101ea7800b1ee3a81a7c77
rastgeleo/python_algorithms
/sorting/quick_sort_inplace.py
1,549
4.1875
4
import random def quicksort(unsorted, start=0, end=None): """quicksort inplace""" if end is None: end = len(unsorted) - 1 if start >= end: return # select random element to be pivot pivot_idx = random.randrange(start, end + 1) # include idx end pivot_element = unsorted[pivo...
true
13ecd9dfd2b1633a3e8788edc632efacfd640e86
adela8888/CS995-Introduction-To-Programming-Principles
/Library/edevice.py
2,096
4.34375
4
class EDevice: """ A class to represent a real-life object with its parameters. In this case to represent an electronic device """ def __init__(self, member = None): """ A constructor to initialize the instance members of the class EDevice """ self.typeOfDevice = "no...
true
7817f6ec9f063f74dccb25bf04368acee6671eb7
gabrypol/Algorithms-and-data-structure-IC-
/nth_fibonacci.py
2,176
4.25
4
''' Write a function fib() that takes an integer n and returns the nth Fibonacci number. Let's say our Fibonacci series is 0-indexed and starts with 0. So: fib(0) # => 0 fib(1) # => 1 fib(2) # => 1 fib(3) # => 2 fib(4) # => 3 ... ''' ''' Solution 1: Using recursion, I can reduce the given problem...
true
826cd37957db210480006ac6b14cdba95e906d20
gabrypol/Algorithms-and-data-structure-IC-
/word_cloud.py
2,678
4.28125
4
''' You want to build a word cloud, an infographic where the size of a word corresponds to how often it appears in the body of text. To do this, you'll need data. Write code that takes a long string and builds its word cloud data in a dictionary, where the keys are words and the values are the number of times the word...
true
62a0c2be9dd1b181e966e60fd515f128499ce34f
whereistanya/toddlerclock
/events.py
2,502
4.3125
4
#!/usr/bin/python3 """A clock to tell your toddler whether they can wake you.""" import logging import time MINUTES_IN_DAY = 1440 class Event(object): """A single event on a clock, with a start and stop time.""" def __init__(self, start_time, stop_time, description): """Create an event. Can't cross midnight ...
true
7aa74971b0ac528ac4a3094223fe784cd51b12bb
julianfrancor/holbertonschool-higher_level_programming
/0x07-python-test_driven_development/5-text_indentation.py
473
4.25
4
#!/usr/bin/python3 "function that prints a square with the character" def text_indentation(text): """Args: text must be a string """ if not isinstance(text, str): raise TypeError("text must be a string") delimiters = [".", "?", ":"] aux = "." for char in text: if char ...
true
faa204a805bc22d636100b2d6552e1a82888561d
pdelboca/hackerrank
/Algorithms/Implementation/Utopian Tree/solution.py
985
4.25
4
# -*- coding: utf-8 -*- """ Created on Fri Sep 4 18:06:25 2015 @author: pdelboca Problem Statement The Utopian Tree goes through 2 cycles of growth every year. The first growth cycle occurs during the spring, when it doubles in height. The second growth cycle occurs during the summer, when its height increases by ...
true
9c45711d85c91f82586408a10981442712a571a0
jlbattle/lpthw_exercises
/ex16/ex16_2.py
927
4.34375
4
#this round, I open the file and read it again after writing to it from sys import argv script, filename = argv print "We're going to erase %r." % filename print "If you don't want that, hit CNTRL-C (^C)" print "If you do want that, hit RETURN." raw_input("?") #Opens the file in write('w') and truncate('+') mode p...
true
5a14c31da8d6a4c2e1c919f3150fb16da884b687
jlbattle/lpthw_exercises
/ex19/ex19.py
1,314
4.125
4
#define the function, its parameters, and its content def cheese_and_crackers(cheese_count, boxes_of_crackers): print "You have %d cheeses!" % cheese_count print "You have %d boxes of crackers!" % boxes_of_crackers print "That's enought for a party!" print "Get a blanket. \n" #These are all different ways we can ...
true
e3e11669edf28ac80b535942e56fb9637a2b54cb
TmNguyen12/python_algos
/reverse_an_array.py
1,567
4.1875
4
# Given a string, that contains special character together with alphabets (‘a’ to ‘z’ and ‘A’ to ‘Z’), # reverse the string in a way that special characters are not affected. # Examples: # Input: str = "a,b$c" # Output: str = "c,b$a" # Note that $ and , are not moved anywhere. # Only subsequence "abc" is revers...
true
b026bfb3863229b22bd241c1e7ed3451136f6cd2
TmNguyen12/python_algos
/reverse_string.py
508
4.53125
5
# Write a program to reverse an array or string # Given an array (or string), the task is to reverse the array/string. # Examples : # Input : arr[] = {1, 2, 3} # Output : arr[] = {3, 2, 1} # Input : arr[] = {4, 5, 1, 2} # Output : arr[] = {2, 1, 5, 4} def reverseString(word): start = 0 end = len(word) - 1 w...
true
05a285c72d052f8c832c28d1e110023bd1926e78
Dylans123/First-Step-Python-Workshops
/Week 1/functions.py
1,766
4.5625
5
""" FUNCTIONS In programming often times we write code that we want to reuse many times. It can be difficult if we have to write all of our code together and have no way of deciding which code we want to execute and when. The way this problem is solved is by splitting our code up into functions and then calling them w...
true
741f24f3b77be7357709f50d594afdb5bb44b2ca
emeznar/PythonPrograms
/setAlarmClock.py
379
4.3125
4
#ask user to input time in hours current_time = int(input("What time is it now(hours only please)?")) #ask user how many hours they want to wait for an alarm alarm_set = int(input("When do you want to set an alarm(in hours)")) #compute time with alarm hours added to it wake_time = (current_time + alarm_set)%24 print ("...
true
7ef87965a60157dc1f9c96454319008ff6196c44
emeznar/PythonPrograms
/functionThatReturnsAreaofaCircle.py
683
4.25
4
import math # TODO: use def to define a function called areaOfCircle which takes an argument called r def areaOfCircle(r): a = r**2 * math.pi return a #print (areaOfCircle (5)) # TODO implment your function to return the area of a circle whose radius is r # below are some tests so you can see if your co...
true
f5d2740548dbbfe5dc486b5f69ce7a8dad4135e2
emeznar/PythonPrograms
/askUserforNumberofSidestoDrawPolygon.py
380
4.28125
4
import turtle wn = turtle.Screen() sides = int(input("How many sides does your figure have?")) distance = int(input("How long is each side?")) color = input("What color is your turtle?") fill = input("What color should it be filled with") alex = turtle.Turtle() alex.color(color) alex.fillcolor(fill) for i in range(si...
true
8bd3fe01788ce6558bd822dc58fc186b50c0e5fa
Superdadccs57/The_Ultimate_Fullstack_web_development_Bootcamp
/Python101/lesson400_Comparison.py
1,200
4.28125
4
# can_code = True # if can_code == True: # #Do a thing # print("You can code!") # else: # #Do Something Else # print("You don't know how to code yet!") # teacher = "Kalob Taulien" # if teacher == "Kalob Taulien": # print("Show the teacher portal") # else: # print("You are a student. Welc...
true
dfaa0f21933cb52997fb8b377a439550c849a6fb
Superdadccs57/The_Ultimate_Fullstack_web_development_Bootcamp
/Python101/lesson406_Functions.py
1,077
4.53125
5
print("") def welcome(name): print(f"Welcome to Lesson 406 Functions; {name}") print("________________________________________") welcome("Thomas") print("") print("The welcome message just happens to be the first example of this lesson and is designed to welcome me into the lesson using a function!") pr...
true
95eb8152ede1763b246b427fac1225e09df0a0d6
achkataa/Softuni-Programming-Fundamentals
/Functions/6. Password Validator.py
750
4.125
4
input_password = input() def validator(password): is_valid = True if len(password) < 6 or len(password) > 10: is_valid = False print("Password must be between 6 and 10 characters") for el in password: if el.isdigit() == False: if el.isalpha() == False: ...
true
2fee2311d86f92deec4ee9296b4e4709ac113933
kerembalci90/python-challenges
/string_sort.py
237
4.1875
4
# input: string of words seperated by space # output: string of words order alphabetically def sort_word_list(full_string): list_of_words = full_string.split() list_of_words.sort(key=str.lower) return ' '.join(list_of_words)
true
4a5d8339547a50321c779fb411e67a5bedc9da54
G00398347/pands-problem-sheet
/Week 02/bmi.py
752
4.40625
4
#this is a programme that calculates somebody's Body Mass Index (BMI) #Author: Ruth McQuillan strweight = input ('Enter your weight in kilograms: ') # this line asks for the persons weight in kgs strheight = input ('Enter your height in centimetres: ') # ditto for height in cms heightinmetres= float(...
true
a3106b26c45b9b6d34066b35c8e844d23ea2dc10
mstiles01/learningpython
/listandfunctions/lists.py
372
4.15625
4
#Value "friends" is a list. String, Number, Boolean friends = ["Kevin", "Karen", "Jim", "Oscar", "Toby"] print(friends) #Indicating the Index print(friends[0]) #Denotes grabbing element from index one and over print(friends[1:]) #Grabs range of index, not the last index though print(friends[1:3]) #Changing index p...
true
5c3e70ff64c9cb390a629acfaef4397af327dbb4
rianayar/Python-Projects
/Girls Code Inc./Session2.py
1,764
4.40625
4
# # inputs # print("What is your name?") # name = input() # print("Hello", name) # print() # # COMMENT ABOVE CODE BEFORE CONTINUING # # Conditionals: if, elif, else # x = 15 # y = -8 # if(x > y): # print("x is greater than y") # elif(x == y): # print("x is equal to y") # else: # print("x is less than y") # # ...
true
7d0c33c932809af6af84f92072043db310e283b2
clemencegoh/Python_Algorithms
/algorithms/HackerRank/level 1/warmups/countingValleys.py
1,731
4.40625
4
""" Gary is an avid hiker. He tracks his hikes meticulously, paying close attention to small details like topography. During his last hike he took exactly steps. For every step he took, he noted if it was an uphill, U, or a downhill, D step. Gary's hikes start and end at sea level and each step up or down represents a...
true
8a4f773f11a2f0b9b71728993b190ac71c57b50d
basilwong/coding-problems
/hackerrank/python/easy/exercises/regex-and-parsing/detecting-floating-point-number.py
642
4.21875
4
""" Verifies that the given strings can be converted into float numbers. Note: A quicker way would have been to use REGEX: import re for _ in range(int(input())): print(bool(re.match(r'^[-+]?[0-9]*\.[0-9]+$', input()))) """ def check_float(s): try: float(s) except(Exception): return False ...
true
127ea566e279a49376fdba651b1c8086e5e3dee9
ArjunBisen/assignments
/calculator.py
481
4.15625
4
#!usr?bin/env python """this program defines four functions (multiply, add, subtract, and divide)""" # This part of the code defines a multiply function def multiply(a,b): return a * b def add(a,b): return a + b def subtract(a,b): return a - b def divide(a,b): return a / b def square(a): return a ** 2 de...
true
c645fe0b5568fa3dc0fe8e55cf8e7f72a7280fdf
gmdmgithub/pandas-playground
/validators_util.py
2,235
4.34375
4
import re import pandas as pd import validators import util_func as ut def valid_email(val): """ simple email validation - to consider using python validate_email - existence is possible Arguments -- val: single cell Return: 0 - not valied, 1 valied """ if ut.isnull(val): return ...
true
cd84527fd7b49f9837dd3ca6b60a96c1c10e1d15
sudhirmd005/PYTHON-excerise-files-
/cl_var.py
1,482
4.15625
4
# instance variable and class variable """ DEFINE : INSTANCE variable can be accessable inside the each instances where as class variable can be accessible through out the class Instance variables are variables whose value is assigned inside a constructor or method with 'self'...
true
99da173ebb0630569b348bb913912ff2ffd216da
ayushgnero/temporary
/Pyhton/Problem Solving/Very Big Number.py
1,394
4.1875
4
""" In this challenge, you are required to calculate and print the sum of the elements in an array, keeping in mind that some of those integers may be quite large. Function Description Complete the aVeryBigSum function in the editor below. It must return the sum of all array elements. aVeryBigSum has the following p...
true
d56261addd33e68f1a5be1e10a5452c2021fe276
Drakshayani86/MathBot
/trignometry.py
897
4.1875
4
#importing required modules and files import math #finds the trignometic values def trignometric_val(): #takes user choice as input value = int(input("Enter your value : ")) if(value>=1 and value<=6): #takes the user input in degrees deg = int(input("Enter value of degree: ")) #conv...
true
a91a8218ffb59dfe1f6ef6888d3021ad6aca1250
SumanSunuwar/python-basic-advance
/advance_scopes.py
1,652
4.21875
4
#scopes = > global and local scope # num = 10 # gloabal variable (Immutable obj) # def some_func(): # global num # num += 1 #local variable # print(f"this is inside function: {num}") # print(f"value of num before function exec: {num}") # some_func() # print(f"value of num after function exec: {num}") # alist =...
true
8ea0e242d2f0027b357281d5ff2e95111711838c
mvkumar14/Data-Structures
/code_challenge_2.py
2,279
4.40625
4
# Print out all of the strings in the following array that represent a number divisible by 3: # [ # "five", # "twenty six", # "nine hundred ninety nine, # "twelve", # "eighteen", # "one hundred one", # "fifty two", # "forty one", # "seventy seven", # "six", # "twelve", # "four", # "sixteen" # ...
true
ed1438961951485f7787cb4a0fdb5f8e71924ad2
chandan-stak/AI_1BM18CS026
/prog3_IDDFS/IDDFS.py
2,798
4.125
4
# Python program to print DFS traversal from a given # given graph from collections import defaultdict # This class represents a directed graph using adjacency # list representation class Graph: def __init__(self, vertices): # No. of vertices self.V = vertices # default di...
true
7d90b4076944f7330a557b2a3dc625f4c039d83e
dp1608/python
/LeetCode/17/171021third_maximum_number.py
2,077
4.21875
4
# -*- coding: utf-8 -*- # @StartTime : 10/21/2017 14:34 # @EndTime : 10/21/2017 14:49 # @Author : Andy # @Site : # @File : 171021third_maximum_number.py # @Software : PyCharm """ Given a non-empty array of integers, return the third maximum number in this array. If it does not exist, return the maximu...
true
bf75bd8eadff62ac94ad23de041ddf5bc5416086
dp1608/python
/LeetCode/17/171009max_area_of_island.py
2,305
4.125
4
# -*- coding: utf-8 -*- # @StartTime : 10/9/2017 14:18 # @EndTime : 10/9/2017 15:15 # @Author : Andy # @Site : # @File : 171009max_area_of_island.py # @Software : PyCharm """ Given a non-empty 2D array grid of 0's and 1's, an island is a group of 1's (representing land) connected 4-directionally (hori...
true
8bb8bfe62a053c3c6dc005e90d69d21167b397e2
dp1608/python
/LeetCode/1806/180608zigzag_conversion.py
1,565
4.15625
4
# -*- coding: utf-8 -*- # @Start_Time : 2018/6/8 17:43 # @End_time: # @Author : Andy # @Site : # @File : 180608zigzag_conversion.py """ The string "PAYPALISHIRING" is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed font for better legibility) ...
true
1d38d807788b0e3ba2b9c896dcf5c656e7976357
dp1608/python
/LeetCode/1807/116_populating_next_right_pointers_in_each_node_180702.py
2,627
4.125
4
# -*- coding: utf-8 -*- # @Start_Time : 2018/7/2 15:30 # @End_time: # @Author : Andy # @Site : # @File : 116_populating_next_right_pointers_in_each_node_180702.py """ Given a binary tree struct TreeLinkNode { TreeLinkNode *left; TreeLinkNode *right; TreeLinkNode *next; } Populate each next pointer to po...
true
7da2a3869b97014c1638dc19f39e0676a67ad973
dp1608/python
/LeetCode/17/171018best_time_to_buy_and_sell_stock.py
1,851
4.1875
4
# -*- coding: utf-8 -*- # @StartTime : 10/18/2017 15:13 # @EndTime : 10/18/2017 15:58 # @Author : Andy # @Site : # @File : 171018best_time_to_buy_and_sell_stock.py # @Software : PyCharm """ Say you have an array for which the ith element is the price of a given stock on day i. If you were only permit...
true