blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
a723af9a1faae81b098e9b79025f031a0f8b2038
PhaniMandava7/Python
/FirstPythonProj/GetInputFromKeyboard.py
337
4.21875
4
greeting = "Hello" # name = input("Please enter your name") # print(greeting + ' ' + name) # names = name.split(" ") # for i in names: # print(i) print("This is just a \"string 'to test' \"multiple quotes") print("""This is just a "string 'to test' "multiple quotes""") print('''This is just a "string 'to test' mu...
true
6c7d41a18476a461fbceec79924b253d39f9f311
paalso/learning_with_python
/ADDENDUM. Think Python/10 Lists/10-12_version1.py
2,415
4.28125
4
''' Exercise 10.12. Two words “interlock” if taking alternating letters from each forms a new word. For example, “shoe” and “cold” interlock to form “schooled”. Solution: http://thinkpython2.com/code/interlock.py 1. Write a program that finds all pairs of words that interlock. Hint: don’t enumerate all pairs! 2...
true
1a63f54074f8a96a4a3585950a253a25d068a0d0
paalso/learning_with_python
/18 Recursion/18-7.py
976
4.15625
4
# Chapter 18. Recursion # http://openbookproject.net/thinkcs/python/english3e/recursion.html # Exercise 7 # =========== # Write a function flatten that returns a simple list containing all the values # in a nested list from testtools import test def flatten(nxs): """ Returns a simple list cont...
true
4e13a17fdcaa1022e51da4c4bb808571a02d6177
paalso/learning_with_python
/26 Queues/ImprovedQueue.py
2,311
4.1875
4
# Chapter 26. Queues # http://openbookproject.net/thinkcs/python/english3e/queues.html class Node: def __init__(self, cargo=None, next=None): self.cargo = cargo self.next = next def __str__(self): return str(self.cargo) class ImprovedQueue: def __init__(self): ...
true
ec0915fa2463fb1da2bb9ad4a5b55793d40fac93
paalso/learning_with_python
/09 Tuples/9-01_1.py
1,138
4.5
4
## Chapter 9. Tuples ## http://openbookproject.net/thinkcs/python/english3e/tuples.html ## Exercise 1 ## =========== # We’ve said nothing in this chapter about whether you can pass tuples as # arguments to a function. Construct a small Python example to test whether this # is possible, and write up your finding...
true
e66ceb92103c0c595bbaa0f6bc829e2208b34dba
paalso/learning_with_python
/18 Recursion/18-11/litter.py
1,729
4.21875
4
# Chapter 18. Recursion # http://openbookproject.net/thinkcs/python/english3e/recursion.html # Exercise 11 # ============ # Write a program named litter.py that creates an empty file named trash.txt in # each subdirectory of a directory tree given the root of the tree as an argument # (or the current directory...
true
9ef73be5b8fdf09a171cff7e27c68773fda9963e
paalso/learning_with_python
/06 Fruitful functions/6-9.py
1,849
4.21875
4
##Chapter 6. Fruitful functions ##http://openbookproject.net/thinkcs/python/english3e/fruitful_functions.html ## Exercise 9 ## =========== ##Write three functions that are the “inverses” of to_secs: ##hours_in returns the whole integer number of hours represented ##by a total number of seconds. ##minutes_i...
true
1ada77a6b13c07c35793d86d7dd8671356910c09
paalso/learning_with_python
/ADDENDUM. Think Python/09 Case study - word play/9-6.py
1,370
4.15625
4
''' Exercise 9.6. Write a function called is_abecedarian that returns True if the letters in a word appear in alphabetical order (double letters are ok). How many abecedarian words are there? ''' def is_abecedarian(word): """ Returns True if the letters in a word appear in alphabetical order (doub...
true
32ec6ec6910b4cb9806e82cfdd8eb22e902c8827
paalso/learning_with_python
/04 Functions/4_4_ver0_0.py
1,339
4.28125
4
##4. http://openbookproject.net/thinkcs/python/english3e/functions.html ##4. Draw this pretty pattern: import turtle import math def make_window(colr, ttle): """ Set up the window with the given background color and title. Returns the new window. """ w = turtle.Screen() w.bgc...
true
c9b466df940ce854e8b362a48c71ab720025b83b
paalso/learning_with_python
/ADDENDUM. Think Python/10 Lists/10-9.py
2,446
4.125
4
''' Exercise 10.9. Write a function that reads the file words.txt and builds a list with one element per word. Write two versions of this function, one using the append method and the other using the idiom t = t + [x]. Which one takes longer to run? Why? ''' def load_words(dict_filename): """ Return...
true
3638b74fdff0456af03fd38137c7eceae3ddacb1
paalso/learning_with_python
/ADDENDUM. Think Python/13 Case study - data structure/13-6.py
1,209
4.21875
4
''' Exercise 13.5. Write a function named choose_from_hist that takes a histogram as defined in Section 11.2 and returns a random value from the histogram, chosen with probability in proportion to frequency. For example, for this histogram: >>> t = ['a', 'a', 'b'] >>> hist = histogram(t) # {'a': 2, 'b': 1} your ...
true
7783505fb7040ceefdd5794f88507f573b4d6bcf
paalso/learning_with_python
/07 Iterations/7-1.py
923
4.28125
4
## Chapter 7. Iteration ## http://openbookproject.net/thinkcs/python/english3e/iteration.html ## Exercise 1 ## =========== ## Write a function to count how many odd numbers are in a list. import sys def count_odds(lst): counter = 0 for n in lst: if n % 2 == 1: counter +...
true
e0dbd51a977024665d2211a0f4f82f3a7d5ce224
paalso/learning_with_python
/24 Linked lists/linked_list.py
1,471
4.21875
4
# Chapter 24. Linked lists # http://openbookproject.net/thinkcs/python/english3e/linked_lists.html class Node: def __init__(self, cargo=None, next=None): self.cargo = cargo self.next = next def __str__(self): return str(self.cargo) def print_backward(self): ...
true
6dfea9839760f8124ac74143ec886b836d85fa38
mattwfranchi/3600
/SampleCode/BasicTCPEchoClient.py
1,035
4.21875
4
from socket import * # Define variables that hold the desired server name, port, and buffer size SERVER_NAME = 'localhost' SERVER_PORT = 3602 BUFFER_SIZE = 32 # We are creating a *TCP* socket here. We know this is a TCP socket because of # the use of SOCK_STREAM # It is being created using a with statement, ...
true
086a3773b74c93e12755271fa0cf25d24399cb60
hsinjungwu/self-learning
/100_Days_of_Code-The_Complete_Python_Pro_Bootcamp_for_2021/day-12.py
756
4.15625
4
#Number Guessing Game Objectives: from art import logo import random print(logo) print("Welcome to the Number Guessing Game!\nI'm thinking of a number between 1 and 100.") ans = random.randint(1, 100) attempts = 5 if input("Choose a difficulty. Type 'easy' or 'hard': ").lower() == "easy": attempts = 10 while at...
true
f3ff778147002322c07f7163b50fc1f8f825e220
Pattrickps/Learning-Data-Structures-Using-Python
/data-structures/implement stack using linked list.py
863
4.28125
4
# Implement Stack using Linked List class node: def __init__(self,node_data): self.data=node_data self.next=None class stack: def __init__(self): self.head=None def push(self,data): new_node=node(data) new_node.next=self.head self.head=new_node def pop...
true
8fc847aa8f077e7abec82c05c2f109b324e489ef
code-lucidal58/python-tricks
/play_with_variables.py
528
4.375
4
import datetime """ In-place value swapping """ # swapping the values of a and b a = 23 b = 42 # The "classic" way to do it with a temporary variable: tmp = a a = b b = tmp # Python also lets us use this a, b = b, a """ When To Use __repr__ vs __str__? """ # Emulate what the std lib does:hand today = datetime.date...
true
467335edf1eafb7cdcf912fe46a75d3f6c712c08
ugo-en/some-python-code
/extra_old_code/square.py
326
4.5
4
# Step1: Prompt the user to enter the length of a side of the square length = int(input("Please Enter the LENGHT of the Square: ")) # Step2: Multiply the length by itself and assign it to a variable called area area = length * length # Step3: Display the area of the square to the user print("Your area is: ",...
true
3653c4987ee75687f3ad08710e803d8724ad244e
ugo-en/some-python-code
/extra_old_code/bmi_calcuator.py
680
4.375
4
#Opening remarks print("This app calculates your Body Mass Index (BMI)") #Input variables weight = float(input("Input your weight in kg but don't include the units: ")) height = float(input("Input your height in m but don't include the units: ")) #Calculate the bmi rnd round off to 1 decimal place bmi = weight / (hei...
true
72d67c1ccb8703467153babbd8baae6c15ca226a
ankurt04/ThinkPython2E
/chapter4_mypolygon.py
1,086
4.1875
4
# -*- coding: utf-8 -*- """ Created on Sun Jul 2 10:45:14 2017 @author: Ankurt.04 """ #Think Python - End of Chapter 4 - In lessson exercises import turtle import math bob = turtle.Turtle() def square(t, length): i = 0 while i <= 3: t.fd(length) t.lt(90) i +=1 ...
true
f1a1d08fa7136a770ca44fbe8dfbf8ffc4eee38e
katelevshova/py-algos-datastruc
/Problems/strings/anagrams.py
1,721
4.15625
4
# TASK ''' The goal of this exercise is to write some code to determine if two strings are anagrams of each other. An anagram is a word (or phrase) that is formed by rearranging the letters of another word (or phrase). For example: "rat" is an anagram of "art" "alert" is an anagram of "alter" "Slot machi...
true
e56c99d2a16d2819a3209bf3cc27ea86ae2c8fa0
katelevshova/py-algos-datastruc
/Problems/stacks_queues/balanced_parentheses.py
1,469
4.125
4
""" ((32+8)∗(5/2))/(2+6). Take a string as an input and return True if it's parentheses are balanced or False if it is not. """ class Stack: def __init__(self): self.items = [] def size(self): return len(self.items) def push(self, item): """ Adds item to the end "...
true
edbf5b7c45bd43917d56099a020e9f82a21a0f64
nsuryateja/python
/exponent.py
298
4.40625
4
#Prints out the exponent value eg: 2**3 = 8 base_value = int(input("enter base value:")) power_value = int(input("enter power value:")) val = base_value for i in range(power_value-1): val = val * base_value #Prints the result print(val) #Comparing the result print(base_value ** power_value)
true
0d760ab53b3b0cb5873064ab0ed74b54a1962db1
Cookiee-monster/nauka
/Scripts/Python exercises from GIT Hub/Ex 9.py
567
4.34375
4
#! Python 3 # Question 9 # Level 2 # # Question£º # Write a program that accepts sequence of lines as input and prints the # lines after making all characters in the sentence capitalized. # Suppose the following input is supplied to the program: # Hello world # Practice makes perfect # Then, the output should be: # HEL...
true
07bcdd9aaac7533bca685a1e4bc17f21db3733da
Cookiee-monster/nauka
/Scripts/Python exercises from GIT Hub/Ex 19.py
1,181
4.6875
5
#! Python 3 # Question: # You are required to write a program to sort the (name, age, height) tuples by ascending order where name is string, # age and height are numbers. The tuples are input by console. The sort criteria is: # 1: Sort based on name; # 2: Then sort based on age; # 3: Then sort by score. # The priority...
true
d863997509ddc1bcf91d2217c99681040b2855a6
Fantendo2001/FORKERD---University-Stuffs
/CSC1001/hw/hw_0/q2.py
354
4.21875
4
def display_digits(): try: # prompts user for input num = int(input('Enter an integer: ')) except: print( 'Invalid input. Please enter again.' ) else: # interates thru digits of number and display for dgt in str(num): print(dgt) ...
true
b0b82289495eb50db5191c439cf4f5aa2589c839
karreshivalingam/movie-booking-project
/movie ticket final.py
2,810
4.125
4
#!/usr/bin/env python # coding: utf-8 # In[ ]: global f f = 0 #this t_movie function is used to select movie name def t_movie(): global f f = f+1 print("which movie do you want to watch?") print("1,Acharya ") print("2,vakeel saab ") print("3,chicchore") print("4,back") movie = int...
true
c31091af418177da7206836e40939b51c8f5afa0
meenapandey500/Python_program
/asset.py
497
4.125
4
def KelvinToFahrenheit(Temperature): assert (Temperature >= 0),"Colder than absolute zero!" return ((Temperature-273)*1.8)+32 print(KelvinToFahrenheit(273)) print(int(KelvinToFahrenheit(505.78))) print(KelvinToFahrenheit(-5)) '''When it encounters an assert statement, Python evaluates the accompanying ex...
true
9847bcc11fc8fb376684ec283eb6c13eabf4e44e
nengvang/s2012
/lectures/cylinder.py
957
4.375
4
# Things we need (should know) # # print # Display a blank line with an empty print statement # print # Display a single item on a separate line # print item # Display multiple items on a line with commas (,) separated by spaces # print item1, item2, item3 # print item, # # raw_input([prom...
true
578de93ccb0c029d5ada5b837358451bc4612faa
stechermichal/codewars-solutions-python
/7_kyu/printer_errors_7_kyu.py
1,260
4.28125
4
"""In a factory a printer prints labels for boxes. For one kind of boxes the printer has to use colors which, for the sake of simplicity, are named with letters from a to m. The colors used by the printer are recorded in a control string. For example a "good" control string would be aaabbbbhaijjjm meaning that the p...
true
954696eccde542040c6abd120b33878fead05e65
stechermichal/codewars-solutions-python
/5_kyu/simple_pig_latin_5_kyu.py
453
4.3125
4
"""Move the first letter of each word to the end of it, then add "ay" to the end of the word. Leave punctuation marks untouched. Examples pig_it('Pig latin is cool') # igPay atinlay siay oolcay pig_it('Hello world !') # elloHay orldway !""" def pig_it(text): text_list = text.split() for i, value in enume...
true
c062245d21b75405560e771c16b1811bd17d76b8
NiteshPidiparars/Python-Tutorials
/PracticalProblem/problem4.py
1,081
4.3125
4
''' Problem Statement:- A palindrome is a string that, when reversed, is equal to itself. Example of the palindrome includes: 676, 616, mom, 100001. You have to take a number as an input from the user. You have to find the next palindrome corresponding to that number. Your first input should be the number of test cas...
true
b5e59ae88dabef206e1ca8eba2a3029d5e71d632
phriscage/coding_algorithms
/factorial/factorial.py
889
4.46875
4
#!/usr/bin/python2.7 """ return a factorial from a given number """ import sys import math def get_factorial(number): """ iterate over a given number and return the factorial Args: number (int): number integer Returns: factorial (int) """ factorial = 1 for n in range(int(numbe...
true
4eb679fa74d8e2bf33d3e58984f4c861ad0b7827
gauravarora1005/python
/Strings Challenges 80-87.py
1,973
4.21875
4
#!/usr/bin/env python # coding: utf-8 # In[2]: first_name = input("enter your first name: ") f_len = len(first_name) print("Length of First Name ", f_len) last_name = input("Enter the last name: ") l_len = len(last_name) print("Length for last name is: ", l_len) full_name = first_name + " " + last_name full_len =...
true
2d44b738e87fd3acc226f5c0a9d980ed58d30beb
kseet001/FCS
/Homework5/homework_qn1.py
2,248
4.125
4
# Homework 5 - Question 1 # Encrypt the following plaintext P (represented with 8-bit ASCII) using AES-ECB, # with the key of 128-bit 0. You may use an existing crypto library for this exercise. # P = SUTD-MSSD-51.505*Foundations-CS* from Crypto.Cipher import AES from binascii import hexlify, unhexlify plaintext = "...
true
133249b5665e99fb2291cff6ab49e0c1cb6c800c
vijaynchakole/Proof-Of-Concept-POC-Project
/Directory Operations/Directory_File_Checksum.py
2,950
4.125
4
# -*- coding: utf-8 -*- """ Created on Wed Feb 19 01:02:26 2020 @author: Vijay Narsing Chakole MD5 hash in Python Cryptographic hashes are used in day-day life like in digital signatures, message authentication codes, manipulation detection, fingerprints, checksums (message integrity check), hash tables, password st...
true
ed39c3de6ac1d1296c487fa8206493b46f3c8998
KrishnaRauniyar/python_assignment_II
/f16.py
1,567
4.125
4
# Imagine you are creating a Super Mario game. You need to define a class to represent Mario. What would it look like? If you aren't familiar with SuperMario, use your own favorite video or board game to model a player. from pynput import keyboard def controller(key): is_jump = False if str(key) == 'Key.ri...
true
4969f9c7fdbf0a5239bbf1e1e4d226b5ed336196
KrishnaRauniyar/python_assignment_II
/f4.py
629
4.25
4
# Create a list. Append the names of your colleagues and friends to it. Has the id of the list changed? # Sort the list. # What is the first item on the list? What is the second item on the list? # no id of list is not changed def checkId(string): arr = [] print("The is before append: ", id(arr)) for i ...
true
73181b0a6495350ba3b6bfd29da0f000da2ca5f2
Data-Analisis/scikit-learn-mooc
/python_scripts/parameter_tuning_sol_01.py
2,951
4.375
4
# %% [markdown] # # 📃 Solution for introductory example for hyperparameters tuning # # In this exercise, we aim at showing the effect on changing hyperparameter # value of predictive pipeline. As an illustration, we will use a linear model # only on the numerical features of adult census to simplify the pipeline. # # ...
true
efc2a9bba1db46e90da4f3d1dffaa98ff3fc76ef
LingyeWU/unit3
/snakify_practice/3.py
837
4.1875
4
# This program finds the minimum of two numbers: a = int(input()) b = int(input()) if a < b: print (a) else: print (b) # This program prints a number depending on the sign of the input: a = int(input()) if a > 0: print (1) elif a < 0: print (-1) else: print (0) # This program takes the coo...
true
4bee428ac8e0dd249deef5c67915e62ba1057997
Matshisela/Speed-Converter
/Speed Convertor.py
1,100
4.34375
4
#!/usr/bin/env python # coding: utf-8 # ### Converting km/hr to m/hr and Vice versa # In[1]: def kmh_to_mph(x): return round(x * 0.621371, 2) # return to the nearest 2 decimal places def mph_to_kmh(x): return round(1/ 0.621371 * x, 2) # return to the nearest 2 decimal places # In[2]: speed_km = float(i...
true
5f90cf3ee2b9a95d877d3a61a5f4691535c182f3
s-andromeda/PreCourse_2
/Exercise_4.py
1,469
4.5
4
# Python program for implementation of MergeSort """ Student : Shahreen Shahjahan Psyche Time Complexity : O(NlogN) Memory Complexity : O(logN) The code ran successfully """ def mergeSort(arr): if len(arr) > 1 : # Getting the mid point of the array and dividing the array into 2 using...
true
1bdfb1dfe2b1d5c7b707a38f071a7167f6f514e8
arpitsomani8/Data-Structures-And-Algorithm-With-Python
/Stack/Representation of a Stack using Dynamic Array.py
1,517
4.125
4
# -*- coding: utf-8 -*- """ @author: Arpit Somani """ class Node: #create nodes of linked list def __init__(self,data): self.data = data self.next = None class Stack: # default is NULL def __init__(self): self.head = None # Checks if stack is empty def isempty(self): if self.head == ...
true
b6d143eb55b431f047482aaf881c025382483c0a
SHIVAPRASAD96/flask-python
/NewProject/python_youtube/list.py
432
4.1875
4
food =["backing","tuna","honey","burgers","damn","some shit"] dict={1,2,3}; for f in food: #[: this is used print how many of the list items you want to print depending on the number of items in your list ] print(f,"\nthe length of",f,len(f)); print("\n"); onTeam =[20,23,23235,565]; print("Here are the p...
true
60fc8a28c92e1cf7c9b98260f1dee89940929d68
tsaiiuo/pythonNLP
/set and []pratice.py
1,015
4.34375
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Thu Sep 23 15:24:16 2021 @author: huannn """ #list[item1,item2....] a=['apple','melon','orange','apple'] a.append('tomato') a.insert(3, 'tomato') print(a) a.remove('apple') print(a) a.pop(0)#pop out a certain position print(a) a1=['fish','pork'] #a.append(...
true
152e7b7430ded1d3593c2ec9b3a2cec89d7d270d
pawarspeaks/HACKTOBERFEST2021-2
/PYTHON/PasswordGen.py
606
4.125
4
import string import random #Characters List to Generate Password characters = list(string.ascii_letters + string.digits + "!@#$%^&*()") def password_gen(): #Length of Password from the User length = int(input("Password length: ")) #Shuffling the Characters random.shuffle(characters) #Picking random Characters...
true
de91aed8808c9c1562ace961b39d5e2f6d3d20bc
leolanese/python-playground
/tips/list-comprehensions.py
318
4.34375
4
# Python's list comprehensions vals = [expression for value in collection if condition] # This is equivalent to: vals = [] for value in collection: if condition: vals.append(expression) # Example: even_squares = [x * x for x in range(10) if not x % 2 even_squares # [0, 4, 16, 36, 64]
true
ee2d5fa2d85740d0219040b80426b1ef57087857
datasciencecampus/coffee-and-coding
/20191112_code_testing_overview/02_example_time_test.py
1,166
4.1875
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Mon Nov 11 10:28:55 2019 @author: pughd """ from datetime import datetime class TestClass: # Difficult to automate test this as depends on time of day! def test_morning1(self): assert time_of_day() == "Night" # Far easier to...
true
7042b216761fe26ce8ffa3e913f54a0508d19ca4
sreelekha11/Number-Guessing
/NumberGuessingGame.py
1,254
4.40625
4
#Creating a simple GUI Python Guessing Game using Tkinter and getting the computer to choose a random number, check if the user guess is correct and inform the user. import tkinter import random computer_guess = random.randint(1,10) def Check(): user_guess = int(number_guess.get()) #Determine ...
true
80372221944fbf2c560fd597e48d5e447a0bd4dd
henrikac/randomturtlewalk
/src/main.py
1,077
4.375
4
"""A Python turtle that does a random walk. Author: Henrik Abel Christensen """ import random from turtle import Screen from typing import List from argparser import parser from tortoise import Tortoise args = parser.parse_args() def get_range(min_max: List[int]) -> range: """Returns a range with the turtles ...
true
53f1f2049a3a31a4a63a0fc38fb77d1466e3ffa3
therealrooster/fizzbuzz
/fizzbuzz.py
740
4.21875
4
def fizzbuzz(): output = [] for number in range (1, 101): if number % 15 == 0: output.append('Fizzbuzz') elif number % 3 == 0: output.append('Fizz') elif number % 5 == 0: output.append('Buzz') else: output.append(number) ...
true
81c8b00713bdc7169f2dcaf7051c1dc376385a5a
zeyuzhou91/PhD_dissertation
/RPTS/bernoulli_bandit/auxiliary.py
1,561
4.15625
4
""" Some auxiliary functions. """ import numpy as np def argmax_of_array(array): """ Find the index of the largest value in an array of real numbers. Input: array: an array of real numbers. Output: index: an integer in [K], where K = len(array) """ # Simple but does...
true
b87cafe0bec26f966a8c027f0aa4e3311be3a18f
chris4540/algorithm_exercise
/basic/arr_search/rotated_arr/simple_approach.py
1,736
4.3125
4
""" https://www.geeksforgeeks.org/search-an-element-in-a-sorted-and-pivoted-array/ 1) Find out pivot point and divide the array in two sub-arrays. (pivot = 2) /*Index of 5*/ 2) Now call binary search for one of the two sub-arrays. (a) If element is greater than 0th element then search in l...
true
4a3368612d71c0d50ea714669551caf6922696ba
Sakshipandey891/sakpan
/vote.py
285
4.3125
4
#to take age as input & print whether you are eligible or not to vote? age = int(input("enter the age:")) if age==18: print("you are eligible for voting") elif age>=18: print("you are eligible for voting") else: print("you are not eligible for voting")
true
d4fc59edb7222118899818e3a6bfb3e84d57797e
MikhaelMIEM/NC_Devops_school
/seminar1/1.py
574
4.21875
4
def reverse_int(value): reversed_int = 0 while value: reversed_int = reversed_int*10 + value%10 value = value // 10 return reversed_int def is_palindrome(value): if value == reverse_int(value) and value%10 != 0: return 'Yes' else: return 'No' if __name__ == '__main_...
true
b4b5b23dff3ef54135b31a52c397ab7bb347c298
ashwani99/ds-algo-python
/sorting/merge_sort.py
1,092
4.34375
4
def merge_sort(arr): l = len(arr) return _merge_sort(arr, 0, l-1) def _merge_sort(arr, start, end): if start < end: mid = (start+end)//2 _merge_sort(arr, start, mid) _merge_sort(arr, mid+1, end) merge(arr, start, mid, end) return arr def merge(arr, start, mid, end): ...
true
7024125f920382245e33eae4f71d857d6b3f24b7
shensleymit/HapticGlove
/Haptic Feedback Code/RunMe2.py
1,725
4.375
4
################################################# # This asks the user which function they would # # like to see, and loads that one. Ideally, # # this won't be needed, and instead the choice # # of function and the function will all be part # # of one file. # ####################...
true
9d272a9c8c1733568d01335040bc94a3bec2eb1c
aaronbushell1984/Python
/Day 1/Inputs.py
1,596
4.3125
4
# Python has Input, Output and Error Streams # Python executes code sequentially - Line by Line # Python style guide https://www.python.org/dev/peps/pep-0008/ # Add items to input stream with input - Print variable to output stream name = input('enter your name: ') print("Your name is", name) # Input takes input and ...
true
e24d82a2699dd90ef9551b67975fad2f77bd84a1
bolducp/MIT-6.00SC-OpenCourseWare-Solutions
/Set 1/problem_2.py
1,235
4.15625
4
# Problem Set 1, Problem 2: Paying Off Debt in a Year def get_outstanding_balance(): outstanding_balance = round(float(raw_input("Enter the outstanding balance on the credit card: ")), 2) return outstanding_balance def get_annual_interest_rate(): annual_interest_rate = round(float(raw_input("Enter the a...
true
93fb4f4dab9e74fa1da1499eaa5f874cb2710e15
danielblignaut/movie-trailer-application
/media.py
1,185
4.15625
4
class Movie() : """ This class provides a way to store movie related data """ VALID_RESTRICTIONS = ["G", "PG", "PG-13", "R"] def __init__(self, title, storyline, image_poster, youtube_trailer, rating, restriction) : self.title = title self.storyline = storyline self.image_p...
true
2134dde3da45d97bed30599df119beb184f15eaa
kwahome/python-escapade
/fun-with-problems/in_place_string_reverse.py
1,685
4.3125
4
# -*- coding: utf-8 -*- #============================================================================================================================================ # # Author: Kelvin Wahome # Title: Reversing a string in-place # Project: python-escapade # Package: fun-with-problems # # # Write a function to reverse ...
true
9485759ef1b43b19642b35039ec0e5a0e5408f36
raylyrainetwstd/MyRepo
/M07_Code_Fixed.py
2,458
4.1875
4
#this function takes an input from a user in response to a question #if the user input is not a number, is_num doesn't accept the user input def is_num(question): while True: try: x = int(input(question)) break except ValueError: print("That is not a number") ...
true
91cd8ab16e42d87249023a65929e46bc756e857a
raylyrainetwstd/MyRepo
/SDEV120_M02_Simple_Math.py
452
4.1875
4
#get two numbers from user #add, subtract, multiply, and divide the two numbers together and save the values to variables #print the results on one line num1 = int(input("Please type a number: ")) num2 = int(input("Please type another number: ")) addition = str((num1 + num2)) subtraction = str((num1 - num2)) multiplic...
true
3042a58e9d3deadaad9caa2291f2a672798b482d
cuichacha/MIT-6.00.1x
/Week 2: Simple Programs/4. Functions/Recursion on non-numerics-1.py
621
4.25
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Fri Mar 15 20:54:15 2019 @author: Will """ def isIn(char, aStr): ''' char: a single character aStr: an alphabetized string returns: True if char is in aStr; False otherwise ''' if aStr=="": return False if char==aS...
true
f1f4ca1185dda31236ba9bd5ceded47043312d59
enireves/converter
/andbis.py
462
4.25
4
weather = input("What's the weather like? ") temperature = input("What temperature is it? ") if weather == "rainy" and temperature == "cold" : print("Take an umbrella and a warm jacket.") elif temperature == "warm": print("Take an umbrella and a shirt.") elif weather == "sunny" and temperature == "cold": pr...
true
083a2d404922c25ca29310ead58938ebcf613db7
quangvinh86/python-projecteuler
/PE-010/summation_of_primes.py
949
4.125
4
""" Solution to Project Euler problem 10 @author: vinh.nguyenquang @email: quangvinh19862003@gmail.com """ import math UPPER_LIMIT = 2000000 def is_prime(number): if number <= 1: return False elif number <= 3: return True elif not number % 2: return False max_range = int(ma...
true
cc7bf998dc1b446c9bbe4b5f1455c5e62b7c8276
FrankCardillo/practice
/2016/codewars/python_practice/digital_root.py
577
4.21875
4
# A digital root is the recursive sum of all the digits in a number. # Given n, take the sum of the digits of n. # If that value has two digits, continue reducing in this way until a single-digit number is produced. # This is only applicable to the natural numbers. def digital_root(n): total = 0 stringified = ...
true
b7fab26d44f16a123f15142f6aac5cd697abcf58
fearlessfreap24/codingbatsolutions
/Logic-2/make_chocolate.py
572
4.125
4
def make_chocolate(small, big, goal): # not enough bricks if big * 5 + small < goal: return -1 # not enough small bricks goalmod = goal % 5 if goalmod > small: return -1 # enough small bricks if big < goal // 5: return goal - (big * 5) if big >= goal // 5: ...
true
58724808401d4280a852997f06a00f4480d75aeb
Maidou0922/Maidou
/阶乘.py
421
4.15625
4
b=int(input("pls input number:")) def fact(a): result=1 if a < 0: return("Error") # should be Error elif a == 0 or a==1: return(str(a)) while a > 1: tmp=a*(a-1) result=result*tmp a -=2 return result #return after loop print(fact(b))...
true
73f05af982732d91004c84a6686e2116e2e1b705
rinkeshsante/ExperimentsBackup
/Python learning-mosh/Python Files/learn_02.py
1,123
4.15625
4
# from the python mega course # to run the entire code remove first ''' pair from code # create text file named test.txt containg multiple lines # file handling opening t& reading the file ''' file = open("test.txt", "r") content = file.readlines() # file.read() for all content reading # file.seek(0) to readjustng th...
true
f09c699d0bf7d7486a1f0f881eee9f61686d6403
axentom/tea458-coe332
/homework02/generate_animals.py
1,713
4.34375
4
#!/usr/bin/env python3 import json import random import petname import sys """ This Function picks a random head for Dr. Moreau's beast """ def make_head(): animals = ["snake", "bull", "lion", "raven", "bunny"] head = animals[random.randint(0,4)] return head """ This Function pulls two random animals fr...
true
84db20f7bfcaa6dd31784c4b6b23739fdc1a249d
Arjun-Pinpoint/InfyTQ
/Programming Fundamentals using Python/Day 3/Assignment 22.py
557
4.125
4
''' Write a Python program to generate the next 15 leap years starting from a given year. Populate the leap years into a list and display the list. Also write the pytest test cases to test the program. ''' #PF-Assgn-22 def find_leap_years(given_year): list_of_leap_years=[] count=0 while(count<15): i...
true
030f3b5229cd74842dd83ad861f3463d5e1681e6
Arjun-Pinpoint/InfyTQ
/Programming Fundamentals using Python/Day 7/Assignment 47.py
1,317
4.3125
4
''' Write a python function, encrypt_sentence() which accepts a message and encrypts it based on rules given below and returns the encrypted message. Words at odd position -> Reverse It Words at even position -> Rearrange the characters so that all consonants appear before the vowels and their order should not change ...
true
e4d361c009cd1a4cd312d9ebd6cf5cdd5019c954
JRobinson28/CS50-PSets
/pset7/houses/import.py
933
4.125
4
from cs50 import SQL from sys import argv, exit from csv import reader, DictReader db = SQL("sqlite:///students.db") def main(): # Check command line args if len(argv) != 2: print("Exactly one commmand line argument must be entered") exit(1) # Open CSV file given by command line arg ...
true
7157f20e3565c8ec175b673725fd2073ad8ae33e
fennieliang/week3
/lesson_0212_regex.py
1,082
4.1875
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Wed Aug 25 14:40:57 2021 @author: fennieliang """ #useful links for regular expression #http://python-learnnotebook.blogspot.com/2018/10/python-regular-expression.html #https://www.tutorialspoint.com/python/python_reg_expressions.htm #regular expression i...
true
d32aa6fa40b6dd5c0201e74f53d5bd581d6a3fe9
josephcardillo/lpthw
/ex19.py
1,825
4.375
4
# creating a function called cheese_and_crackers that takes two arguments. def cheese_and_crackers(cheese_count, boxes_of_crackers): print(f"You have {cheese_count} cheeses.") print(f"You have {boxes_of_crackers} boxes of crackers.") print("Get a blanket.\n") print("We can just give the function numbers di...
true
7f97672e9989079ecf723aad9f71c57952440e35
josephcardillo/lpthw
/ex15.py
795
4.375
4
# imports argv module from sys from sys import argv # the two argv arguments script, filename = argv # Using only input instead of argv # filename = input("Enter the filename: ") # Opens the filename you gave when executing the script txt = open(filename) # prints a line print(f"Here's your file {filename}:") # Th...
true
6fb99f7f646c260eb763fc5804868a9bcf529971
Shubham1744/HackerRank
/30_Days_of_code/Day_1_Data_Types/Solution.py
777
4.25
4
int_2 = int(input()) double_2 = float(input()) string_2 = input() # Read and save an integer, double, and String to your variables. sum_int = i + int_2 sum_double = d + double_2 sum_string = s + string_2 # Print the sum of both integer variables on a new line. # Print the sum of the double variables on a new line. ...
true
ad07b60b0c4d663663a286ca854833a903e3ee6a
Philiplam4516/TRM
/Python Workshop/Advnaced Python/Codes/Functions/Functions/F05.py
431
4.125
4
''' Write a program to get a circle radius from terminal, and then compute the area of the circle by a function ''' PI = 3.14 def compute_circle_area(radius): return radius*radius*PI def main(): print("Enter a circle radius (m)") radius=input() radius = float(radius) # type cast from string to float area...
true
307cabfc949ee7f6af494726552b2228f09249d5
jahanzebhaider/Python
/if\else/else.py
1,841
4.15625
4
#THIS CODE WILL PRINT THR HONDA CAR WITH UPPER CASE AND REST WITH LOWER CASE ALPHABETS cars=['audi','bmw','honda','toyota','suzuki'] for car in cars: if car =='Honda': print(car.upper()) else: print(car.lower()) # checking nother of checking in list if 'ponks' in cars: print("it'...
true
5db7c26589e626757b3bd3c34f6470a4667b4508
TheCoderIsBibhu/Spectrum_Internship
/Task1(PythonDev)/prgm2.py
232
4.25
4
#2 Given a number find the number of zeros in the factorial of the number. num=int(input("Enter a Number: ")) i=0 while num!=0: i+=int(num/5) num=num/5 print("The Number of zeros in factorial of the number is ",i)
true
c33def97afff545464952faa066c663e1d472491
RyanMolyneux/Learning_Python
/tutorialPointWork/lab5/test2.py
1,186
4.5625
5
#In this session we will be working with strings and how to access values from them. print("\nTEST-1\n----------------------------\n"); """Today we will test out how to create substrings, which will involve slicing of an existing string.""" #Variables variable_string = "Pycon" variable_substring = variable_string[2...
true
20d19ed63a0dd22c377a915facdb707c2b069732
RyanMolyneux/Learning_Python
/pythonCrashCourseWork/Chapter 8/8-8-UserAlbums.py
844
4.1875
4
#Chapter 8 ex 8 date : 21/06/17. #Variables albums = [] #Functions def make_album(artistName,albumTitle,num_tracks = ""): "Creates a dictionary made up of music artist albums." album = {"artist" : artistName,"album title": albumTitle} if num_tracks: album["number of tracks"] = num_tracks retu...
true
01cb8a39730aca55603be93355359da08d0a453e
RyanMolyneux/Learning_Python
/pythonCrashCourseWork/Chapter 10/ex10/main.py
526
4.25
4
"""This will be a basic program which just consists of code counting the number of times 'the' appears in a text file.""" #Chapter 10 ex 10 DATE:17/07/18. #Import - EMPTY #Variables file_name = "" text = "" #Objects - EMPTY #Functions - EMPTY #Body file_name = input("\n\nPlease enter name of the fil...
true
4bc87ec0732a1bbae109667d396bc02610ecb6c7
Gustacro/learning_python
/become_python_developer/3_Ex_Files_Learning_Python/Exercise Files/Ch3/calendars_start.py
1,776
4.25
4
# # Example file for working with Calendars # # import the calendar module import calendar # create a plain text calendar c = calendar.TextCalendar(calendar.SUNDAY) # st = c.formatmonth(2019, 12, 0, 0) # "formatmonth" method allow format a particular month into a text string # print(st) # create an HTML formatted ca...
true
a212f533bf41ef324030787837c59924207f7b9d
bansal-ashish/hackerR
/Python/Introduction/division.py
1,753
4.34375
4
#!/usr/bin/env python """ In Python, there are two kinds of division: integer division and float division. During the time of Python 2, when you divided one integer by another integer, no matter what, the result would always be an integer. For example: >>> 4/3 1 In order to make this a float division, you would need...
true
35815caac7564a6be04e75a3af3b12139b97eced
jaredcooke/CP1404Practicals
/prac1/fromscratch.py
442
4.15625
4
number_of_items = int(input("Number of items: ")) total_cost = 0 while number_of_items <= 0: print("Invalid number of items!") number_of_items = int(input("Number of items: ")) for i in range(number_of_items, 0, -1): price_of_item = float(input("Price of item: ")) total_cost += price_of_item if total_co...
true
8369dabbbe5680471488c495cf5a9b8599e11ea8
orbache/pythonExercises
/exercise1.py
541
4.40625
4
#!/usr/bin/python __author__ = "Evyatar Orbach" __email__ = "evyataro@gmail.com" '''Exercise 1 Create a program that asks the user to enter their name and their age. Print out a message addressed to them that tells them the year that they will turn 100 years old. ''' from datetime import datetime year = datetime.now()...
true
3bd707a6c0b5a2ffb1657ae2ac8465452aa30d6d
orbache/pythonExercises
/exercise14.py
747
4.5625
5
#!/usr/bin/python __author__ = "Evyatar Orbach" __email__ = "evyataro@gmail.com" '''Exercise 14 Write a program (using functions!) that asks the user for a long string containing multiple words. Print back to the user the same string, except with the words in backwards order. For example, say I type the string: My n...
true
b71c8353038c7cac83a834e5b047cc735648b371
abelar96/PythonPrograms
/HW2.py
425
4.21875
4
##Diego Abelar Morales def distance(s, h): return s * h speed = int(input("What is the speed of the vehicle in mph?: ")) hours = int(input("How many hours has it traveled: ")) print("Hours Distanced Traveled") print("------------------------------") for time in range(1, 1 + hours): distance(...
true
0d58826718124173c580fddc80ab18717d8db13e
Vaishnav95/bridgelabz
/testing_programs/vending_notes.py
758
4.40625
4
''' Find the Fewest Notes to be returned for Vending Machine a. Desc -> There is 1, 2, 5, 10, 50, 100, 500 and 1000 Rs Notes which can be returned by Vending Machine. Write a Program to calculate the minimum number of Notes as well as the Notes to be returned by the Vending Machine as a Change b. I/P -> read the Change...
true
de3f20a97b1f6ad9a4f09553914f7a0b4b55ee54
Vaishnav95/bridgelabz
/algorithm_programs/sort_merge.py
700
4.15625
4
''' Merge Sort ​ - ​ Write a program to do Merge Sort of list of Strings. a. Logic -> ​ To Merge Sort an array, we divide it into two halves, sort the two halves independently, and then merge the results to sort the full array. To sort a[lo, hi), we use the following recursive strategy: b. Base case: If the subarray le...
true
6c802e64c761ee9de46c355b25dad866c867ded1
Vaishnav95/bridgelabz
/logical_programs/tic_tac_toe.py
630
4.25
4
''' Cross Game or Tic-Tac-Toe Game a. Desc -> Write a Program to play a Cross Game or Tic-Tac-Toe Game. Player 1 is the Computer and the Player 2 is the user. Player 1 take Random Cell that is the Column and Row. b. I/P -> Take User Input for the Cell i.e. Col and Row to Mark the ‘X’ c. Logic -> The User or the Compute...
true
f2784c8cc19167c649f41b9f077b127c8eb04cbe
svshriyansh/python-starter
/ex2fiborecur.py
244
4.15625
4
def fib(n): if n == 1: return 0 elif n == 2: return 1 else: return fib(n-1) + fib(n-2) m = int(input("Enter the number to find its fibonacci: ")) for Num in range(1, m+1): print(fib(Num),end=' ')
true
a2380c2f8ea772778259ae69c8851a5ebffffb8e
itodotimothy6/CTCI
/Arrays-&-Strings/1.4/solution.py
1,566
4.25
4
# Given a string, write a function to check if it is a permutation of a # palindrome. A palindrom is a word or phraze that is the same forwards and # backwards. A permutation is a rearrangement of letters. A palindrome does not # need to be linited to just dictionary words. # Note: a maximum of one character should ha...
true
f2ce02fe4a649be8b2646c34427984151f68b8be
23devanshi/pandas-practice
/Automobile Dataset/Exercises.py
2,191
4.34375
4
# Exercises taken from : https://pynative.com/python-pandas-exercise/ import pandas as pd import numpy as np #pd.display df = pd.read_csv('D:/Python tutorial/Pandas Exercises/1 Automobile Dataset/Automobile_data.csv') df.shape #: From given data set print first and last five rows print(df.head()) print(df.t...
true
554e1ac6391e6f8582fcf1e48f3d724e4d992c42
Romeo2393/First-Code
/Comparison Operator.py
220
4.21875
4
temperature = 30 temperature = int(input("What's the temperature outside? ")) if temperature > 30: print("It's a hot day") elif temperature < 10: print("Its a cold day") else: print("Enjoy your day")
true
84e23d7bb5df3549b754b9785c6c4a906f504a97
zacniewski/Decorators_intro
/05_decorators_demystified.py
1,460
4.1875
4
"""The previous example, using the decorator syntax: @my_shiny_new_decorator def another_stand_alone_function(): print "Leave me alone" another_stand_alone_function() #outputs: #Before the function runs #Leave me alone #After the function runs Yes, that's all, it's that simple. @decorator is just a shortcut to: ...
true
f170a6023f6c27d8c4e1b77ff865275fa33dd551
david-ryan-alviola/winter-break-practice
/hackerRankPython.py
1,977
4.40625
4
# 26-DEC-2020 # Print Hello, World! to stdout. print("Hello, World!") # Given an integer, , perform the following conditional actions: # If is odd, print Weird # If is even and in the inclusive range of 2 to 5, print Not Weird # If is even and in the inclusive range of 6 to 20, print Weird # If is even and grea...
true
701c8ac9df8e1544c22b63d94e2894fbf20ab04c
PaulGG-Code/Security_Python
/Simple_File_Character_Calculator.py
242
4.1875
4
#open file in read mode file = open("D:\data.txt", "r") #read the content of file data = file.read() #get the length of the data number_of_characters = len(data) print('Number of characters in text file :', number_of_characters)
true