blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
4bf00048cb0797c83a7b79a1525b4bf504d9be68
erickmiller/AutomatousSourceCode
/AutonomousSourceCode/data/raw/squareroot/da7d2364-a2f6-4ca1-924c-9801f5195742__findSquareRoot.py
1,049
4.3125
4
#!/usr/local/bin/python import sys usage = """ Find square root of a give number Usage: findSquareRoot.py <number> Example: findSquareRoot.py 16""" def main(argv): """ Executes the main() flow @param argv: Command-line arguments @type argv: array of strings """ if (len...
true
0ca64c1c83f6b6ba01a3a8f5082d5aa3b88afcdd
kocoedwards/CTBlock4P4
/firstParsonsProblems.py
837
4.5
4
""" March 2, 2021 Use this document to record your answers to the Parson's Problems shared in class. Remember: the idea behind a Parson's Problem is that you are shown completely correct code that is presented OUT OF ORDER. When arranged correctly, the code does what the Parson's Problem says it should do. ...
true
20af73f2c6effe194835b9f137cabf854269f249
breezey12/collaborative-code
/tryingArgv.py
977
4.34375
4
from sys import argv def count(start, end, incrementBy=1): # enumerates between start and end, only lists even numbers if even = true while start <= end: print start start += incrementBy def even(start): start += start % 2 incrementBy = 2 return start, incrementBy def countBy(c...
true
287e21c219a5666f20d2a14b23d70cbc4154cec2
ebogucka/automate-the-boring-stuff
/chapter_7/strong_password_detection.py
948
4.28125
4
#!/usr/bin/env python3 # Strong Password Detection import re def check(password): lengthRegex = re.compile(r".{8,}") # at least eight characters long if lengthRegex.search(password) is None: print("Password too short!") return lowerRegex = re.compile(r"[a-z]+") # contains lowercase cha...
true
1f6f43f9f60431b78ccec1d4499c2f52f4ee2646
soluke22/python-exercise
/primenumbers.py
496
4.15625
4
#Ask the user for a number and determine whether the number is prime or not. def get_numb(numb_text): return int(input(numb_text)) prime_numb = get_numb("Pick any number:") n = list(range(2,int(prime_numb)+1)) for a in n: if prime_numb == 2: print("That number is prime.") break elif prime_numb == 1: ...
true
00f478709a36a8623a38ec865bd78d189b369fec
hichingwa7/programming_problems
/circlearea.py
519
4.125
4
# date: 09/21/2019 # developer: Humphrey Shikoli # programming language: Python # description: program that accepts radius of a circle from user and computes area ######################################################################## # def areacircle(x): pi = 3.14 r = float(x) area = pi * r * r re...
true
10c7603e3a8f8d390134f23b5891604f6d0dc74b
krushnapgosavi/Division
/div.py
923
4.1875
4
import pyttsx3 print("\n This is the program which will help you to find the divisible numbers of your number!!") ch=1 engine= pyttsx3.init() engine.setProperty("rate", 115) engine.say(" This is the program which will help you to find the divisible numbers of your number") while ch==1: engine.runAndWait() en...
true
1c53c34020a44ea95474c71168179987913b4bcd
lvncnt/Leetcode-OJ
/Dynamic-Programming/python/Unique-Paths.py
1,069
4.1875
4
""" Problem: A robot is located at the top-left corner of a m x n grid. The robot can only move either down or right at any point in time. The robot is trying to reach the bottom-right corner of the grid (marked 'Finish' in the diagram below). How many possible unique paths are there? Note: m and n will be at most 1...
true
782bd10d6cad1e6f4893e311078968e191bc236b
dktlee/university_projects
/intro_to_comp_sci_in_python/bar_chart.py
2,705
4.53125
5
## ## Dylan Lee ## Introduction to Computer Science (2015) ## # bar_label_length(data, max_label_length, index) produces the length # of the largest bar label that will be created from data, which is # max_bar_length, by checking to see if the label in data at index is bigger # than the max_bar_length so far # requi...
true
e7953f05fcd5ee001e04a473e1ed6b315c9a304e
akhitab-acharya/Mchine-learning
/Python.py
1,981
4.34375
4
ERROR: type should be string, got "https://cs231n.github.io/python-numpy-tutorial/\nPython & Numpy Tutorial by Stanford - It's really great and covers things from the ground up.\n\n#Quicksort\n\ndef quicksort(arr):\n if len(arr) <= 1:\n return arr\n pivot = arr[len(arr) // 2]\n left = [x for x in arr if x < pivot]\n middle = [x for x in arr if x == pivot]\n right = [x for x in arr if x > pivot]\n return quicksort(left) + middle + quicksort(right)\n\nprint(quicksort([3,6,8,10,1,2,1]))\n\n\n# Prints \"[1, 1, 2, 3, 6, 8, 10]\"\n\n-----------------------------------------\n\n#LIST COMPREHENSION:\n\nnums = [1, 2, 3, 4]\nnum_squares = [x**2 for x in nums]\nprint(num_squares)\n\n\n# list comprehension with conditions:\n\nnum_even_square = [x**2 for x in nums if x % 2 == 0]\nprint(num_even_square)\n\n------------------------------------------------------------\n\n# DICTIONARY COMPREHENSION:\n\nnums = [0, 1, 2, 3, 4]\neven_num_to_square = {x: x ** 2 for x in nums if x % 2 == 0}\nprint(even_num_to_square) # Prints \"{0: 0, 2: 4, 4: 16}\"\n\n--------------------------------------------------------------------------------------\ns = \"hello\"\nprint(s.capitalize()) # Capitalize a string; prints \"Hello\"\nprint(s.upper()) # Convert a string to uppercase; prints \"HELLO\"\nprint(s.rjust(7)) # Right-justify a string, padding with spaces; prints \" hello\"\nprint(s.center(7)) # Center a string, padding with spaces; prints \" hello \"\nprint(s.replace('l', '(ell)')) # Replace all instances of one substring with another;\n # prints \"he(ell)(ell)o\"\nprint(' world '.strip()) # Strip leading and trailing whitespace; prints \"world\"\n------------------------------------------------------------------------------------------\n\n# EX. OF ENUMERATE:\n\nanimals = {'cat', 'dog', 'cow'}\nfor idx, animal in enumerate(animals):\n print('#%d %s' % (idx + 1, animal))\n\n# Prints \"#1: cat\", \"#2: dog\", \"#3: monkey\", each on its own line\n\n-------------------------------------------------------------------\n\n\n"
true
320fec5ea73f27447974d41dbcf7b80251e4bc88
Viheershah12/python-
/Practice_Projects/odd-even.py
656
4.21875
4
num = int(input("Enter a number of your choice: ")) check = 2 dev = num % 2 if dev > 0: print("The number ",num," is a odd number") else: print("The number ",num," is a even number") # more complex function to see if the number is divisible by 4 num = int(input("give me a number to check: ")) check = int(i...
true
9cbbed20321eab76d4f326fc164df529b8b64b88
Viheershah12/python-
/FutureLearn/conditional/IFSTATEMENTS.py
295
4.34375
4
x = 5 if x == 5: print("this number is ",x) else: print("this number is not",x) if x > 5 : print("this number is greater than ",x) else: print("this number is less than or equal to ",x) if x != 5: print("this number is not equal to ",x) else: print("this number is ",x)
true
a88fa735ad3cccfca126e03b4005848c88fd569d
Viheershah12/python-
/Lessons/calculatorfunc.py
371
4.25
4
#define a function to return the square of a given number #define anathor function to add up the numbers #use the functions created to solve the equation # x = a + b^2 def add(x,y): return x + y def square(x): return x * x num1 = int(input("Enter number 1: ")) num2 = int(input("Enter number 2: ")) x = add(nu...
true
54af20a4223a7fce77f976c6063056318656c59a
vamotest/yandex_algorithms
/12_01_typical_interview_tasks/L. Extra letter.py
427
4.125
4
from itertools import zip_longest def define_anagrams(first, second): li = list(zip_longest(first, second)) for letter in li: if letter[0] != letter[1]: return letter[1] if __name__ == '__main__': first_word = ''.join(sorted(list(str(input())))) second_word = ''.joi...
true
414441654abcc71a08ba8a04f1d38f17f5c26184
mtavecchio/Other_Primer
/Python/lab4/circle.py
1,075
4.40625
4
#!/usr/local/bin/python3 #FILE: circle.py #DESC: A circle class that subclasses Shape, with is_collision(), distance(), and __str__() methods from shape import Shape from math import sqrt class Circle(Shape): """Circle Class: inherits from Shape and has method area""" pi = 3.14159 def __init__(self, r = 1...
true
1a468b1e78271d168daf89fadb04ea212bd91b50
foobar167/junkyard
/simple_scripts/longest_increasing_subsequence.py
2,000
4.25
4
l = [3,4,5,9,8,1,2,7,7,7,7,7,7,7,6,0,1] empty = [] one = [1] two = [2,1] three = [1,0,2,3] tricky = [1,2,3,0,-2,-1] ring = [3,4,5,0,1,2] internal = [9,1,2,3,4,5,0] # consider your list as a ring, continuous and infinite def longest_increasing_subsequence(l): length = len(l) if length == 0: return 0 # list is ...
true
7554a545e73e15f55208072f9e28dc3d10bb53ee
MaxwellGBrown/tom_swift
/tom_swift.py
1,895
4.1875
4
"""Trigrams application to mutate text into new, surreal, forms. http://codekata.com/kata/kata14-tom-swift-under-the-milkwood/ """ from collections import defaultdict import random def read_trigrams(text): """Return a trigrams dictionary from text.""" trigrams = defaultdict(list) split_text = text.split...
true
a672c36493d46e20be291214640e0fbe11f2162f
Devfasttt/Tkinker
/Positioning With Tkinter's Grid System.py
469
4.375
4
#import tkinter from tkinter import * #main window root=Tk() #create a label widget myLabel1=Label(root, text="hello i am a good, really good person")#.grid(row=0, column=0) myLabel2=Label(root, text="Who are you?")#.grid(row=3, column=7) myLabel3=Label(root, text=" ")#.grid(row=8, column=5) #shovi...
true
527fc33c42c57314783a3c73ba753bc37cde9a36
vishaltanwar96/DSA
/problems/mathematics/integer_to_roman.py
1,698
4.375
4
def int_to_roman(num: int) -> str: """ number is represented as its place value i.e. 5469 = 5000 + 400 + 60 + 9 Conversion is supported till 9999. A helper hashmap is needed to map values to a string representation of that number in roman. For converting a number to roman number we follow a simple s...
true
872fa237b31821e8cc70700017314d2273a9ea9f
jaejun1679-cmis/jaejun1679-cmis-cs2
/startotend.py
946
4.15625
4
import time def find(start, end, attempt): if start > end: countdownfrom(start, end, attempt) elif end > start: countupfrom(start, end, attempt) def countdownfrom(start, end, attempt): if start == end: print "We made it to " + str(end) + "!" else: time.sleep(1) ...
true
f93622696104e20e2079975a9cd6b98ce5a75a2d
gk90731/100-questions-practice
/16.py
234
4.25
4
#Please complete the script so that it prints out the value of key b . #d = {"a": 1, "b": 2} #Expected output: 2 d = {"a": 1, "b": 2} print(d["b"]) # lists have indexes, while dictionaries have keys which you create by yourself.
true
07d6bdf68d139c030ecb46a0a789146621671217
matttu120/Python
/HackerRank/WhatsYourName.py
724
4.1875
4
''' Problem Statement Let's learn the basics of Python! You are given the first name and the last name of a person. Your task is to read them and print the following: Hello firstname lastname! You just delved into python. It's that simple! In Python you can read a line as a string using s = raw_input() #here s read...
true
eb9f909b5f7c13edf72d05b8554dd8608f21acd7
Eliacim/Checkio.org
/Python/Home/Sun-angle.py
1,503
4.46875
4
''' https://py.checkio.org/en/mission/sun-angle/ Every true traveler must know how to do 3 things: fix the fire, find the water and extract useful information from the nature around him. Programming won't help you with the fire and water, but when it comes to the information extraction - it might be just the thing you...
true
3baebfc0fe2aa3a56263a967dcb288b2fd88b6da
Eliacim/Checkio.org
/Python/Electronic-Station/All-upper-ii.py
769
4.5
4
''' https://py.checkio.org/en/mission/all-upper-ii/ Check if a given string has all symbols in upper case. If the string is empty or doesn't have any letter in it - function should return False. Input: A string. Output: a boolean. Precondition: a-z, A-Z, 1-9 and spaces ''' def is_all_upper(text: str) -> bool: ...
true
59c8a0575f9a59348cfcb6a0fb8029f9c3b32366
Eliacim/Checkio.org
/Python/Mine/Fizz-buzz.py
1,125
4.46875
4
''' https://py.checkio.org/en/mission/fizz-buzz/ Fizz Buzz Elementary "Fizz buzz" is a word game we will use to teach the robots about division. Let's learn computers. You should write a function that will receive a positive integer and return: "Fizz Buzz" if the number is divisible by 3 and by 5; "Fizz" if the numb...
true
b8b26c1d753a8c1511d2243bb31a373790e6ce0a
ITorres20/week2-hello-world
/helloworld.py
626
4.46875
4
#Ivetteliz Torres # this program is suppose to display the hello world greeting in three different languages language1= 'Hola Mundo!' language2= 'Ola Mundo!' language3= 'Bonjour le monde!' print 'Hello World!' # greeting print 'Please select one of the following languages.' # ask the user for language selection #lan...
true
5b0002f4992b9cd73d114d3cc2fe02735a473e36
anchaubey/pythonscripts
/file_read_write_operations/file1.py
2,790
4.71875
5
There are three ways to read data from a text file. read() : Returns the read bytes in form of a string. Reads n bytes, if no n specified, reads the entire file. File_object.read([n]) readline() : Reads a line of the file and returns in form of a string.For specified n, reads at most n bytes. However, does not reads ...
true
7fb04b986773cf7a002ceb8078dc11f6b3f9b6b5
learnMyHobby/list_HW
/sets.py
586
4.5625
5
# A = [‘a’,’b’,’c’,’d’] B = [‘1’,’a’,’2’,’b’] # Find a intersection b and a union b import math # declaring the function def Union(A,B): result = list(set(A) | set(B)) # | it is or operator it adds the list since we cannot return result # add the sets # finding the intersection of li...
true
b2358665ea9f13f35c00143fdb19b89cb52959cb
jhhalls/machine_learning_templates
/Clustering/k-means.py
1,926
4.34375
4
""" @author : jhhalls K - MEANS 1. Import the libraries 2. Import the data 3. Find Optimal number of clusters 4. Build K-means Clustering model with optimal number of clusters 5. Predict the Result 6. Visualize the clusters """ import numpy as np import matplotlib.pyplot as plt import pandas as pd #import mall dat...
true
f13f34892527aea07186b8785b0d083bb9fed5ef
SJChou88/dsp
/python/q8_parsing.py
915
4.3125
4
# The football.csv file contains the results from the English Premier League. # The columns labeled ‘Goals’ and ‘Goals Allowed’ contain the total number of # goals scored for and against each team in that season (so Arsenal scored 79 goals # against opponents, and had 36 goals scored against them). Write a program t...
true
9a12200c5d3af09cc03550fb4f3449cd5be6dfdd
susunini/leetcode
/110_Balanced_Binary_Tree.py
2,508
4.15625
4
# Definition for a binary tree node. # class TreeNode(object): # def __init__(self, x): # self.val = x # self.left = None # self.right = None class Solution(object): """ Wrong. Different fromt this problem, another definition of height balanced tree. -> max depth of leaf node - min...
true
fc81d349674608957642b6ef0663e1a1c6433370
susunini/leetcode
/143_Reorder_List.py
1,109
4.125
4
# Definition for singly-linked list. # class ListNode(object): # def __init__(self, x): # self.val = x # self.next = None class Solution(object): """ Linked List. Classic problem. It is composed of three steps which are commonly used for different linked list problems. step ...
true
b98bd948a6cf84a855a21a9912242964ff285ea3
RonKang1994/Practicals_CP1404
/Practical 4/Lecture 4.py
779
4.21875
4
VOWELS_CHECK = 'aeiou' def check_vowel(): name = str(input("Name: ")) letter = 0 vowel = 0 for char in name: letter += 1 for v_check in VOWELS_CHECK: if char.lower() == v_check.lower(): vowel += 1 print("Out of {} letters {} has {} vowels".format(letter,...
true
cea319acb2704979a43663448216e9cc322e3feb
LizhangX/DojoAssignments
/PythonFun/pyFun/Multiples_Sum_Average.py
690
4.4375
4
# Multiples # Part I - Write code that prints all the odd numbers from 1 to 1000. Use the for loop and don't use a list to do this exercise. for i in range(0,1000): if i % 2 != 0: print i # Part II - Create another program that prints all the multiples of 5 from 5 to 1,000,000. for i in range(5,1000000):...
true
180f640a3db8b9ba5ec1dba6d8c0605968ac0fa1
xdisna2/4FunctCalc
/test.py
876
4.4375
4
# Testing type conversions # Entering an int x = float(input("Number 1:")) # Convert to float # So matter its a string it will include the .0 to make it a float print(x) # Change from float to int x = 11.0 print(type(x)) x = round(11.0) print(type(x)) # Test out is_integer function # Note to self you must declare it...
true
757e96688c44e4f4994e151c5b664878d2a2c8d7
RAMYA-CP/PESU-IO-SUMMER
/coding_assignment_module1/one.py
348
4.3125
4
#Write a Python program which accepts a sequence of comma-separated numbers from the user and generate a list and a tuple with those numbers. l=input().split(',') list_n=[] for i in l: list_n.append(int(i)) tuple_n=tuple(list_n) print("THIS IS A LIST OF ELEMENTS:") print(list_n) print("THIS IS A TUPLE OF E...
true
c063891b5f3f8ad713ca6a22416235e38553b7e4
biomathcode/Rosalind_solutions
/Bioinformatics Stronghold/IEN.py
1,081
4.15625
4
## Calculating Expected offspring """ Given: Six nonnegative integers, each of which does not exceed 20,000. The integers correspond to the number of couples in a population possessing each genotype pairing for a given factor. In order, the six given integers represent the number of couples having the following genotyp...
true
f180736db7b68d0c12b796a04106660f5ed1a28b
PurityControl/uchi-komi-python
/problems/euler/0008-largest-product-in-series/ichi/largest_product_in_series.py
893
4.40625
4
def largest_product(length, str_of_digits): """ returns the largest product of contiguous digits of length length in a string of digits args: length: the length of contiguous digits to be calculated str_of_digits: the string of digits to calculate the products from """ return max(produc...
true
702d0eea27aa14c1d522ac6c06673dc0cecd0778
PurityControl/uchi-komi-python
/problems/euler/0009-special-pythagorean-triplet/ichi/pythagorean_triplet.py
596
4.25
4
def pythagorean_triplet(sum): """ returns the first pythagorean triplet whose lengths total sums args: sum: the amount the lengths of the triangle must total """ return first(a * b * c for (a, b, c) in triplets_summing(sum)) def triplet_p(a, b, c): return (a * a) + (b * b) == (c * c) def fi...
true
0f76d1582d68ace6e5b7d92e07ec84805220ae92
ktops/SI-206-HW04-ktops
/magic_eight.py
843
4.125
4
def user_question(): user_input = input("What is your quesiton? ") return user_input user_input = "" while user_input is not "quit": user_input = user_question() if user_input[-1] is not "?": print("I'm sorry, I can only answer questions.") else: break import random possible_answe...
true
e3487062e8ae883c7c7e77df308fef5291821f2f
kedarjk44/basic_python
/lambda_map_filter_reduce.py
485
4.21875
4
# lambda can be used instead of writing a function add_two_inputs = lambda x, y: x + y print(add_two_inputs(8, 5)) print(add_two_inputs("this", " that")) # map can be used to apply a function to each element of a list list1 = [1, 2, 3, 4] print(*list(map(lambda x: x**2, list1))) # or can be done as print(*[x**2 for x...
true
f1e43c1f7195269a40c8b2e4e9c721f062c5f617
canadian-coding/posts
/2019/August/21st - Basic Logging in python/logging_demo.py
1,777
4.21875
4
import logging # Module that allows you to create logs; Logs are very helpful for down the road debugging import datetime # Used in formatting strings to identify date and time def print_num(): """Takes user input, and if it's an int or float prints it.""" logging.debug("Starting print_int") # Only gets logged...
true
0f7e7f6a8fd56a5a5e7c50ae78a0662050735c7e
canadian-coding/posts
/2019/July/8th - Optional boolean arguments in argparse/optional_boolean_arguments.py
949
4.3125
4
"""A demo of optional boolean arguments using argparse.""" import argparse # Module used to set up argument parser # Setting up Main Argument Parser main_parser = argparse.ArgumentParser(description="A demo of optional boolean arguments") # Adding optional boolean argument main_parser.add_argument("-r", '--run', help...
true
1d3124d8e22793e7cb0a9abc4d1e4a9005e2bad4
lastcanti/learnPython
/review2.py
555
4.15625
4
# python variables and collections print("I am a print statement") # use input to get data from console #someData = input("Enter some data: ") #print(someData) # lists are used to store data a = [] a.append(1) a.append("a") a.pop() b = [2] print a print a + b c = (1,"a",True) print(type(c)) print(len(c)) # tuples a...
true
85527d167d7805f2f402da1c2f59e03178e3043a
Todai88/me
/kmom01/plane/plane1.py
445
4.5
4
""" Height converter """ height = format(1100 * 3.28084, '.2f') speed = format(1000 * 0.62137, '.2f') temperature = format(-50 * (9/5) + 32, '.2f') print("""\r\n########### OUTPUT ###########\r\n\r\nThe elevation is {feet} above the sea level, \r\n you are going {miles} miles/h, \r\n finally the temperature outs...
true
d6a5422996f26970b11e5a756af66c7e0d33ca0e
Todai88/me
/kmom01/hello/hello.py
681
4.4375
4
""" Height converter """ height = float(input("What is the plane's elevation in metres? \r\n")) height = format(height * 3.28084, '.2f') speed = float(input("What is the plane's speed in km/h? \r\n")) speed = format(speed * 0.62137, '.2f') temperature = float(input("Finally, what is the temperature (in celsius) outs...
true
b0b67c197c66734915eef38b4d00787eda45e06c
cabbageGG/play_with_algorithm
/LeetCode/125_isPalindrome.py
1,034
4.25
4
#-*- coding: utf-8 -*- ''' Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases. For example, "A man, a plan, a canal: Panama" is a palindrome. "race a car" is not a palindrome. Note: Have you consider that the string might be empty? This is a good question to ...
true
9949c12df71be1f193ee8de7427701ec75d6b4b7
DoneWithWork/Number-Guessing-Game
/Number Guessing Game.py
1,547
4.53125
5
# Import random module import random # Number of guesses is 3 guesses = 3 # Getting a random number between and including 1 and 10 number = random.randint(1,10) # Some basic print statements print("Welcome to guess the number") print("You have to guess a number from 1-10") print("You have 3 guesses") ...
true
73692164f112b92a5786c10df1691a17aca9b38f
BolajiOlajide/python_learning
/beyond_basics/map_filter_reduce.py
616
4.15625
4
from functools import reduce import operator mul = lambda x: x * 2 items = [1, 2, 4, 5, 6, 8, 9, 10] print(map(mul, items)) # [4, 8, 12, 16, 20] # if you are using python3 then the result of map and filter will # be lazy loaded so you have to manually convert to a list first_names = ["John", "Jane", "James", "Jacob...
true
43c0bc0302ce5d541f29de7c3cac24a926b21209
jm-avila/REST-APIs-Python
/Refresher/09_the_in_keyword/code.py
299
4.125
4
movies_watched = {"The Matrix", "Green Book", "Her"} user_movie = input("Enter something you've watched recently: ") print("in movies_watched", user_movie in movies_watched) vowels = "aeiou" user_letter = input("Enter a letter and see if it's a vowel: ") print("in vowels", user_letter in vowels)
true
92988d12250b0d14e4a4a6d5e688f33f973b8b2d
DavidCorzo/EstructuraDeDatos
/#SearchingAndSorting/Sorting.py
1,159
4.125
4
def selection_sort(unsorted: list) -> list: for i in range(0, len(unsorted) - 1): min = i for j in range(i + 1, len(unsorted)): if unsorted[j] < unsorted[min]: min = j if min != i: unsorted[i], unsorted[min] = unsorted[min], unsorted[i] return ...
true
6e1c537e147eeccb2c51a55c25900c4f0c7fa19f
PriyanshuChatterjee/30-Days-of-Python
/day_6/06_tuples.py
1,847
4.25
4
emptyTuple = () brothers = ('Arijit','Debrath') sisters = ('Apurba',) siblings = brothers+sisters noofSiblings = len(siblings) parents = ('Ma','Papa') family_members = siblings+parents (firstSibling, secondSibling, thirdSibling, firstparent, secondParent) = family_members fruits = ('apples','mangoes','bananas'...
true
3034f8af8cb037de81db93f3c283ffbb8cb48116
karthikkbaalaji/CorePython
/loops.py
399
4.28125
4
# Have the user enter a string, then loop through the # string to generate a new string in which every character # is duplicated, e.g., "hello" => "hheelllloo" #import print function from python3 from __future__ import print_function #get the input from the user print("Enter a string:", end='') inputString = raw_inp...
true
f18d0ba8eeb0dad5a1b4bad385ade4d88fa8f5fa
karthikkbaalaji/CorePython
/lists.py
2,279
4.5625
5
#write a Python program to maintain two lists and loop #until the user wants to quit #your program should offer the user the following options: # add an item to list 1 or 2 # remove an item from list 1 or 2 by value or index # reverse list 1 or list 2 # display both lists #EXTRA: add an option to check if lists...
true
987d0755225cb89e923d22b48d212ca75cfcf9c0
mcfaddeb4311/cti110
/M5T1_KilometerConverter_BobbyMcFadden.py
515
4.4375
4
# Convert kilometer to miles. # 6-28-2017 # CTI-110 M5T1_KilometerConverter # Bobby McFadden CONVERSION_FACTOR = 0.6214 def main (): # Get the distance in kilometers. kilometers = float (input('Enter a distance in kilometers: ')) #Display the distance converted to miles. show_miles (kilometers) ...
true
cad19fd15b16c7a8494fd52bece96ff572d86487
csbridge/csbridge2020
/docs/starter/lectures/Lecture6/school_day.py
544
4.28125
4
""" This program tells whether go to school or not for a particular day. """ MONDAY = 1 TUESDAY = 2 WEDNESDAY = 3 THURSDAY = 4 FRIDAY = 5 SATURDAY = 6 SUNDAY = 7 def main(): print("Should I go to school?") day = int(input("Enter a day: ")) if MONDAY <= day <= FRIDAY: # day is between Monday and Friday ...
true
3b0e7cd368a3f121c67b9a20c75f67e532de6ae3
Cova14/PythonCourse
/dicts_exercise_1.py
518
4.3125
4
# We need to receive the basic info of a user # (first_name, last_name, age, email) # and save them as keys into a dict call user. # After receive the data, show the info in the console user = {} user['first_name'] = input('Hey bro, cual es tu nombre?: ') user['last_name'] = input('Como dices que se apellidan tus gfe...
true
5a97ae18e7319001e3eb66d4a7e55bc0f642fc48
xuefengCrown/Files_01_xuef
/all_xuef/程序员练级+Never/想研究的/python-further/metaclass1.py
2,426
4.96875
5
#http://blog.jobbole.com/21351/ #http://stackoverflow.com/questions/100003/what-is-a-metaclass-in-python """ Secondly, metaclasses are complicated. You may not want to use them for very simple class alterations. You can change classes by using two different techniques: ·monkey patching ·class decorators 99% of the ti...
true
72ccad5f29e9918974a57e7ccc14b85935d52afb
xuefengCrown/Files_01_xuef
/all_xuef/程序员练级+Never/xuef code/xuef_code_python/composing_programs/4. Data Processing/4.2.6 Python Streams.py
2,460
4.3125
4
""" Streams offer another way to represent sequential data implicitly. A stream is a lazily computed linked list. Like an Link, the rest of a Stream is itself a Stream. Unlike an Link, the rest of a stream is only computed when it is looked up, rather than being stored in advance. That is, the rest of a stream is comp...
true
ea486935f6eb853ec567831155935518d9407807
itrevex/ProgrammingLogicAndela
/coffee.py
2,024
4.46875
4
''' Andela Making Coffee App ''' #Make my coffee INGREDIENTS = ['coffee', 'hot water'] print('Started making coffee...') print('Getting cup') print('Adding {}'.format(' and '.join(INGREDIENTS))) print('Stir the mix') print('Finished making coffeee...') MY_COFFEE = 'Tasty Coffee' print("--Here's your {}, Enjoy!!-- Mr....
true
d75b2ad3ccccbbc64101c9d69749f14ac09e7ef1
N-eeraj/code_website
/Code/py/queue_ds.py
929
4.21875
4
def isEmpty(): return True if end == 0 else False def isFull(): return True if end == size else False queue = [] size = int(input("Enter Queue Size: ")) while True: print("Queue:", queue) end = len(queue) option = input("\nSelect Queue Operation\n1. Is Empty?\n2. Is Full?\n3. Enqueue\n4. Dequeu...
true
ee36f2aa49982e1926fc9859ea52987fd598bc7a
jscelza/PythonKnightsSG
/week01/funWithSys.py
868
4.1875
4
"""Playing with sys by using examples from Chapter 1. http://www.diveintopython3.net/your-first-python-program.html Available Functions printSyspath() Print value of sys.path addDirToSyspath(string) Adds string to sys.path """ import sys def display_syspath(): """Print sys.path value.""" print("sys.p...
true
13f76295927ed7cef99d759a3d4a39afaf7c47da
Pjmcnally/algo
/strings/reverse_string/reverse_string_patrick.py
874
4.46875
4
# Authored by Patrick McNally # Created on 09/15/15 # Requests a string and prints it reversed def reverse_string(chars): """Takes in a string and returns it reversed. Parameters ---------- Input: chars: string Any string or list Output: chars: string A reversed version of t...
true
1dd422098c2b504fef437676c9895036a45ada70
Pjmcnally/algo
/sort_visualized/bubble_sort.py
2,950
4.28125
4
"""Visualization of the bubble sort algorithm. For reference: https://matplotlib.org/2.1.2/gallery/animation/basic_example_writer_sgskip.html https://github.com/snorthway/algo-viz/blob/master/bubble_sort.py """ from random import shuffle import matplotlib.pyplot as plt import matplotlib.animation as ani # Create a l...
true
7b83ce10efb3bf9da2f9650cc1718327bf462193
Pjmcnally/algo
/math/primes/primes_old.py
2,206
4.34375
4
# Authored by Patrick McNally # Created on 09/15/15 # Requests a number from the user and generates a list of all primes # upto and including that number. import datetime def list_primes(n): """Return a list of all primes up to "n"(inclusive). Parameters ---------- Input: n: int or float ...
true
e887c0efe28523e4de25a523684cea8e1e1b2d92
Neha-kumari31/Sprint-Challenge--Data-Structures-Python
/names/bst.py
1,456
4.125
4
''' Binary search trees are a data structure that enforce an ordering over the data they store. That ordering in turn makes it a lot more efficient at searching for a particular piece of data in the tree. ''' class BSTNode: def __init__(self, value): self.value = value self.left = None se...
true
3483d89da70d27855bc0854d531361b2f17b10fa
TanbirulM/Rock-Paper-Scissors
/rps.py
1,551
4.125
4
import random def play_game(): print('Welcome to Rock Paper Scissors!') player_score = 0 bot_score = 0 while True: print('Make your choice:') choice = str(input()).lower() print("My choice is", choice) choices = ['rock', 'paper', 'scissor', 'end'] bot_choices = ['rock', 'paper', 'scissor'] bot_ch...
true
1cbbe648adf947a8c230a15578b1117c3a523064
jitensinha98/Python-Practice-Programs
/ex32_2.py
433
4.15625
4
y=int(raw_input("Enter the starting element:")) z=int(raw_input("Enter the ending element:")) element=[] for i in range(y,z+1): element.append(i) print "All elements are stored in the list." print "Do you want to veiw the list :" raw_input() print "All elements in the list are :" for numbers in element: pr...
true
f911f45e6505a6a3916aa7a900bcaa2379a00075
garycunningham89/pands-problem-set
/solution1sumupto.py
657
4.4375
4
#Gary Cunningham. 03/03/19 #My program intends to show the sum of all the numbers for, and including, the inputted integer from number 1. #Adaptation from python tutorials @www.docs.python.org and class tutorials. n = input("Please enter a positive integer: ") # Inputting the first line of the program as per the reques...
true
251f9d376aefb865fffdbba56b6d4c9bbe0b305c
shawnTever/documentAnalysis
/week1/PythonBasicsTutorial.py
2,480
4.28125
4
my_list2 = [i * i for i in range(10)] # Creates a list of the first 10 square integers. my_set2 = {i for i in range(10)} my_dict2 = {i: i * 3 + 1 for i in range(10)} print(my_list2) print(my_set2) print(my_dict2) # Comprehensions can also range over the elements in a data structure. my_list3 = [my_list2[i] * i for i...
true
8982047e06eceb6dd3a530bc09584d55cf734e25
aa-fahim/practice-python
/OddOrEven.py
846
4.21875
4
## The programs asks the user to input an integer. The program will then ## determine if the number is odd or even and also if it is a multiple of 4. ## The second part of program will ask for two numbers and then check ## if they are divisble or not. number = int(input('Please enter a number:\n')) a = number...
true
b8abc55567a07dcd99e00d752a3790ab409f6858
aa-fahim/practice-python
/ListEnds.py
213
4.1875
4
## List Ends # Takes first and last element of input list a and places into new list and # prints it. def list_ends(a): a = [5, 10, 15 ,20 ,25] new_list = [a[0], a[len(a)-1]] print(new_list)
true
c3ecd3b01a046af4f3e6c203878b0864d85a0317
bio-chris/Python
/Courses/PythonBootcamp/Project_3_Pi.py
517
4.21875
4
# Project 3: 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. """ Using the Bailey-Borwein-Plouffe formula """ from decimal import * def pi(i): pi_value = 0 getcontext().prec = i for n in range(i...
true
4e98356bdc6f0df8b2715536dacf8f55a792f5a9
Nayan-Chimariya/Guess-the-number
/app.py
2,562
4.15625
4
#game game from random import randint import time import os guess_count = 5 hint_count = 3 def end_screen(): print("\nSee ya later loser! \n") time.sleep(1) exit() def counters(guess_count, hint_count): print(f"\nNumber of guess left = {guess_count}") print(f"Number of hints left = {hint_count}") def hi...
true
4cd731424693d2ae3287132de455cd2a75c1e59f
taismassaro/stunning-engine
/anagram-finder/anagram_finder.py
559
4.125
4
with open('anagram_finder/2of4brif.txt') as in_file: words = in_file.read().strip().split('\n') words = [word.lower() for word in words] lookup_word = 'charming' anagrams = [lookup_word] for word in words: if word != lookup_word: # to find out if a word is an anagram of another, we can convert th...
true
9605f705daf53c27cd8292df1a5b0c6cba86604f
TimurTimergalin/natural_selection
/simulation/app.py
2,141
4.15625
4
import pygame class App: """ Methods: set_variables create_sprite_groups main_loop run set_variables: Args: None Returns: None Set constant variables to use it in the simulation create_sprite_groups: Args: None Returns: None ...
true
927b69be4111dd0b12631e59cd8d42c3bb0e9074
gygergely/Python
/Misc/FizzBuzz/fizzbuzz.py
1,237
4.1875
4
def welcome(): """ Simple welcome message to the user. :return: None """ print('Welcome to the \'fizzbuzz\' game') def user_number_input(): """ Request a number from the user. :return: int """ while True: try: nr = int(input('Please enter a number between 1 ...
true
4163960e911dc1a91fed505e1a348d5ffb6e9d25
AndreaCossio/PoliTo-Projects
/AmI-Labs/lab_1/e02.py
277
4.375
4
# Lab 01 - Exercise 02 # Retrieving the string string = input("Insert a string: ") # Checking length and printing if len(string) > 2: print("'" + string + "' yields '" + string[0] + string[1] + string[len(string) - 2] + string[len(string) - 1] + "'") else: print("")
true
e73464eaff804a0128456f9c37ad348b08856049
AndreaCossio/PoliTo-Projects
/AmI-Labs/lab_2/e01.py
1,214
4.25
4
# Lab 02 - Exercise 01 # List of tasks tasks = [] num = -1 # Main loop while num != 4: # Printing menu print("""Insert the number corresponding to the action you want to perform: 1. Insert a new task 2. Remove a task (by typing its content exactly) 3. Show all existing tas...
true
06cee3b6c3d1dc86c477216ae1ac9369b75dbdf0
chasegarsee/Algorithms
/recipe_batches/recipe_batches.py
1,679
4.1875
4
#!/usr/bin/python import math def recipe_batches(recipe, ingredients): # getting the Keys from the KEY::VALUE pairs current_recipe = set(recipe.keys()) print(current_recipe) # printing the keys if current_recipe.intersection(ingredients.keys()) != current_recipe: # if they keys in current ...
true
23f2a8f4b69924299a87f3821777b1ba6ddcf691
dev-bloke/examples
/python/simple/collections.py
1,829
4.3125
4
# Simple list and indexing first_list = [1, 2, 3] print(first_list[0]) # Working from the end of the list and appending. second_list = [1, "b", 3, "Hello"] print(second_list[3]) print(second_list[-2]) second_list[1] = "B" second_list.append("world") second_list.append(first_list) print(second_list) # Extending, ins...
true
06dbec69c44712a70985ed9ce526d2c86082c871
lovababu/python_basics
/datastructures/dictionary.py
1,105
4.5
4
about = {"Name": "Avol", "Age": 32, "Address": "Bangalore"} # called dictionary key value pairs. print(type(about)) # access keys. # returns all keys as dict_keys (Note: dict_keys is not a list, index access may result type error). keys = about.keys() print(type(keys)) print(keys) # keys[0] result type error dict_...
true
ff2ba366ce3df5ad0049f46db9e44a5e50942675
ratanvishal/hello-python
/main12.py
384
4.1875
4
#a=8 #b=5 #c=sum((a,b)) #print(c) #def function(a,b): #print("hello function r u there",a+b) def function(a,b): """This is the function which calculates the average of two numbers. and this function does't work for three numbers""" average= (a+b)/2 # print(average) return (average) #v=funct...
true
73a6a5a6f21b8e7f0a8a234836b9864c021c12b6
green-fox-academy/Unicorn-raya
/week-01/day-2/count_from_to.py
586
4.375
4
# Create a program that asks for two numbers # If the second number is not bigger than the first one it should print: # "The second number should be bigger" # # If it is bigger it should count from the first number to the second by one # # example: # # first number: 3, second number: 6, should print: # # 3 # 4 # 5 fi...
true
1b0fcc447b81b5ee00c14a93b8d87802997c3593
green-fox-academy/Unicorn-raya
/week-01/day-3/Functions/Sort_that_list.py
992
4.21875
4
# Create a function that takes a list of numbers as parameter # Returns a list where the elements are sorted in ascending numerical order # Make a second boolean parameter, if it's `True` sort that list descending def bubble(arr): arr_length = len(arr) if arr_length == 0: return -1 for i in rang...
true
aeeb60f44fafdf45d1c48180c6f1957adb84f2c8
green-fox-academy/Unicorn-raya
/week-01/day-2/draw_pyramid.py
460
4.25
4
# Write a program that reads a number from the standard input, then draws a # pyramid like this: # # # * # *** # ***** # ******* # # The pyramid should have as many lines as the number was length = int(input()) level = 0 tmp = "" while level < length + 1: for i in range(length-level): tmp += " " ...
true
9e464ff53c74b314555a19755b90c971a2d4efbf
green-fox-academy/Unicorn-raya
/week-01/day-3/Functions/Factorial.py
224
4.34375
4
# - Create a function called `factorio` # that returns it's input's factorial def factorio( number ): if number == 1: return number else: return number * factorio (number - 1) print(factorio(5))
true
9d9afc31d603928f64561a29faafe584b8296be4
aduxhi/learnpython
/mid_test/lac_string_2.py
863
4.21875
4
#!/usr/bin/python ''' Write a recursive procedure, called laceStringsRecur(s1, s2), which also laces together two strings. Your procedure should not use any explicit loop mechanism, such as a for or while loop. We have provided a template of the code; your job is to insert a single line of code in each of the indicated...
true
ef6c2b63ae1b3ef0175632bf06fc8123eed45d37
aduxhi/learnpython
/return_print.py
715
4.15625
4
# -*- coding: UTF-8 -*- ''' the print() function writes, i.e., "prints",a string in the console. The return statement causes your function to exit and hand back a value to its caller.(使函数终止并且返回一个值给它的调用者) The point of functions in general is to take in inputs and return something. The return statement is used when a fun...
true
492afa72418991d88094b69f59f6f548abf5fe0a
aduxhi/learnpython
/ProblemSet3/getGuessedWord.py
656
4.1875
4
#!/usr/bin/python # -*- coding: UTF-8 -*- # 返回已经猜到的单词 def getGuessedWord(secretWord, lettersGuessed): ''' secretWord: string, the word the user is guessing lettersGuessed: list, what letters have been guessed so far returns: string, comprised of letters and underscores that represents what letters in secretWor...
true
d591b7440e04f08c2c65f2aa93e386db4ef5595b
danieltran-97/Python-practice
/polygon.py
655
4.21875
4
import turtle class Polygon: def __init__(self, sides,name, size=100): self.sides = sides self.name = name self.size = size self.interior_angles = (self.sides -2) * 180 self.angle = self.interior_angles/self.sides def draw(self): for i in range(self.sides): ...
true
3b6dbcc99b5fddb652c3bf6fc0ff43c3162879b2
Karanvir93875/PythonStuff
/RealTimeClock.py
907
4.15625
4
#This is a program which provides a close to accurate representation of real time import os #clear screen functioning import time #variables display time length seconds = float(0) #want to display decimals of each second minutes = int(0) #want min to be dislayed as whole numbers hours = int(0) #want hours ...
true
2dfe462d34c82b016bb249e719f86b1ca81d9603
ferryleaf/GitPythonPrgms
/numbers/plus_minus.py
2,118
4.15625
4
#!/bin/python3 ''' Given an array of integers, calculate the fractions of its elements that are positive, negative, and are zeros. Print the decimal value of each fraction on a new line. Note: This challenge introduces precision problems. The test cases are scaled to six decimal places, though answers with absolute er...
true
11cc4e82a74f71bf0c395392b69bb827e5719544
ferryleaf/GitPythonPrgms
/arrays/rotate_array.py
1,792
4.15625
4
''' Given an unsorted array arr[] of size N, rotate it by D elements in the COUNTER CLOCKWISE DIRECTION. Example 1: Input: N = 5, D = 2 arr[] = {1,2,3,4,5} Output: 3 4 5 1 2 Explanation: 1 2 3 4 5 when rotated by 2 elements, it becomes 3 4 5 1 2. Example 2: Input: N = 10, D = 3 arr[] = {2,4,6,8,10,12,14,16,18,20} ...
true
fd461e5e74a42b5e42b6d28e7d656811263f8c69
ferryleaf/GitPythonPrgms
/numbers/factor_of_numbers.py
450
4.125
4
''' Find the Factors of a Number: Example: The factors of 320 are: 1 2 4 5 8 10 16 20 32 40 64 80 160 320 ''' import math class Solution: def find_factors(self,num:int) -> None: factors=list() for i in range(1,int(math.sqrt(num))+1): if(num%i==0): factors.append(i) ...
true
de46cea01e81b8c4fe93c82a4e692ae76fc5a493
ferryleaf/GitPythonPrgms
/strings/strstr.py
1,504
4.125
4
''' Your task is to implement the function strstr. The function takes two strings as arguments (s,x) and locates the occurrence of the string x in the string s. The function returns and integer denoting the first occurrence of the string x in s (0 based indexing). Example 1: Input: s = GeeksForGeeks, x = Fr Output:...
true
5d4a34e282b9f7a119110f197a9d5af1c791adc6
Gaurav-Dutta/python_learning
/Basics/Functions/function1.py
921
4.21875
4
#a function is defined by using the ketyword "def". The block of code following the funciton definition is called function block #function may or may not return a value if the function returns a value it uses the return keyword to return a value #the first functionn below does not return any value, the second function ...
true
56a689b12738635f8e5afbefe694677f81e2e51b
Gaurav-Dutta/python_learning
/Basics/datatypes/list3.py
544
4.65625
5
#many times we have to access each item in a list and do something with it, a process called list iteration #the simplest way of doing list iteration is using for each method on the list myList = ["dog", "cat", "penguin", "giraffe"] for animal in myList: print(animal.capitalize()) print("hello") #adding othe...
true
84c3d33f89d054cda35e0533dbd82ad4ad30bbb5
shaikhjawad94/MITx-6.00.1x
/PS2/P3.py
1,124
4.125
4
low = balance / 12 high = (balance * (1 + (annualInterestRate/12.0))**12.0) / 12.0 minPay = (low + high) / 2 rerun = True #low is the lowest minimum possible payment, i.e., when interest is 0% #high is highets possible payment, i.e., when one payment made at the end of the year def FixedPayBis(balance, annualIntere...
true
23efc9bf59c75c93eb3dc71c5c170943b5b24df2
tarunsingh8090/twowaits_python_programs
/Day 3/Problem 5.py
503
4.15625
4
size1 =int(input("Enter the no. of elements that you want to enter in List1:")) List1=[] print("Enter elements in List1 one by one:") for i in range(size1): List1.append(input()) size2= int(input("Enter the no. of elements that you want to enter in List2:")) List2=[] print("enter elements in List2 one by one...
true