blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
c8f50e663763b379597f86a71c8aa6c630600354
Mihirkumar7/letsupgrade-assignment2
/string is pangram or not.py
519
4.4375
4
# Write a program to check whether a string is a pangram or not. # Pangram is a sentence or string which contains every letters of english alphabet. def is_pangram(s): # This function takes string as an argument. alphabets = 'abcdefghijklmnopqrstuvwxyz' for ch in alphabets: if ch not in s.lowe...
true
4a4469148c1f690e7fd393ab55ebed4bd779b7d1
zhangkai98/ProgrammingForThePuzzledBook
/Puzzle7/roots.py
2,037
4.28125
4
#Programming for the Puzzled -- Srini Devadas #Hip To Be a Square Root #Given a number, find the square root to within a given error #Two strategies are shown: Iterative search and bisection search ##Find the square root of a perfect square using iterative search def findSquareRoot(x): if x < 0: print ('So...
true
e833e62d6b7515e6cabc70e1427cd52cbc3560e8
rohit00001/Assignment-1-letsupgrade-Python-Essentials
/Assignment 1 letsupgrade/question3.py
319
4.21875
4
#Question 3 #Find sum of n numbers by using the while loop – #Program num= int(input("enter the number of terms : ")) if num < 0: print("Enter a positive number") else: sum = 0 # use while loop to iterate until zero while(num > 0): sum += num num -= 1 print("The sum is", sum)
true
6fdafdc64f04cd52aba89a3367da671db6e279ec
wissam0alqaisy/python_begin_1
/begin_3/classes_2.py
1,675
4.59375
5
############################################### # # # Created by Youssef Sully # # Beginner python # # classes 1.2 INSTANCE variables 2 # # methods and __dict__ # # ...
true
0eddfc9e0c7f8552bfa0c0342988a9a420cd3c40
luisas/PythonCourse
/Python/block1_part1.py
1,615
4.125
4
# coding: utf-8 # In[114]: import math # In[115]: # First Exercise def get_cone_volume(radius, height): """The function returns the volume of a cone given, in order, radius and height as input""" return (height/3)*math.pi*(radius**2) # In[69]: # Calculate the factorial of a number n in a re...
true
75619da925967dcea3b32d2b922060c2ec48440e
VeeravelManivannan/Python_training
/python_veeravel/numpy_arrays/numpy_excercise.py
784
4.1875
4
weightlist = [89,98,78,101,171,76] heightlist = [1.78,1.66,1.89,1.76,1.88,1.76] #printing datatype #print(type(weightlist)) import numpy #converting array to numpy array numpy_weightlist = numpy.array(weightlist) numpy_heightlist = numpy.array(heightlist) print("Printing a weight list , without numpy %s" % weigh...
true
f6d61c73127c5d0d6a4de16881457cd05d942e3d
VeeravelManivannan/Python_training
/python_veeravel/closures/closures_trying_out.py
1,440
4.34375
4
#Scenario1: inner function not returning anything , only using and printing def outer_function(outer_function_variable_passed_as_arguement): variable_defined_inside_outer_function = "I am a variable_defined_inside_outer_function " def inner_function(): print("inside inner function , printing all variables of out...
true
1fe0e1b74e36ff6acb5bb0aa7e90ef814ee09cb5
OnsJannet/holbertonschool-higher_level_programming
/0x0B-python-input_output/0-read_file.py
214
4.15625
4
#!/usr/bin/python3 def read_file(filename=""): """ Reads a text file and prints it filename: filename. """ with open(filename, encoding='UTF8') as my_file: print(my_file.read(), end="")
true
b780b1c0a22652ef191e7303727d3ac2d26be3ed
aarbigs/python_labs
/06_classes_objects_methods/06_02_shapes.py
1,241
4.5
4
''' Create two classes that model a rectangle and a circle. The rectangle class should be constructed by length and width while the circle class should be constructed by radius. Write methods in the appropriate class so that you can calculate the area (of the rectangle and circle), perimeter (of the rectangle) and cir...
true
2c760dce41a71fc860f8b9af3d452e9ceb1bd1c0
aarbigs/python_labs
/02_basic_datatypes/02_06_invest.py
392
4.25
4
''' Take in the following three values from the user: - investment amount - interest rate in percentage - number of years to invest Print the future values to the console. ''' invest = int(input("enter investment amount: ")) interest = int(input("enter interest rate: ")) num_years = int(input("enter numb...
true
d400d8f6bd33d30ba3d7d3d350ce90ca9b0ae672
aarbigs/python_labs
/15_variable_arguments/15_01_args.py
344
4.1875
4
''' Write a script with a function that demonstrates the use of *args. ''' def arg_function(*args): # for i in args: # print(i*i) a,b,c = args print(a, b, c) arg_function(1, 2, 3) new_list = [] def arg_function2(*args): for arg in args: new_list.append(arg) print(new_list) arg_...
true
a267f13054cd7b67170aa04a7ad4582bcc3fdc70
aarbigs/python_labs
/06_classes_objects_methods/06_04_inheritance.py
1,358
4.1875
4
''' Build on the previous exercise. Create subclasses of two of the existing classes. Create a subclass of one of those so that the hierarchy is at least three levels. Build these classes out like we did in the previous exercise. If you cannot think of a way to build on your previous exercise, you can start from scr...
true
ce4189a60d6f35d025a0662243d839d83e7bfe2f
Giorc93/Python-Int
/datatype.py
608
4.34375
4
# Strings print("Hello World") print('Hello World') # Prints the sting on the console print("""Hello Word""") print('''Hello World''') print(type('''Hello World''')) # Gets the data type and prints the value print("Bye"+"World") # + links the strings # Numbers print(30) # integer print(30.5) # float # Boolean...
true
dc557c4f23cdcc92ce1f526ed7da471477f9b861
Lina-Pawar/Devops
/sum_digits.py
310
4.15625
4
def Digits(n): sum = 0 for digit in str(n): sum += int(digit) #uses shorthand operator += for adding sum like sum=sum+int(digit) return sum n= int(input(print("Enter an integer number: "))) #inputs an integer number print("Sum of digits is",Digits(n)) #prints the sum
true
6d8a96fb1870197e366cca12db202ea58e134eac
gitter-badger/Erin-Hunter-Book-Chooser
/Erin Hunter Book Chooser Main Window.py
1,645
4.125
4
from tkinter import * import tkinter.messagebox as box window = Tk() window.title("Erin Hunter Book Chooser") label = Label( window, font = ("architects daughter", 11, "normal"), text = "Welcome to the Erin Hunter Book Chooser.\nPlease select your favorite animal below and the app will select your favorite Erin...
true
396d6ad0f092eda6e3404d7b8fd4c53b8ecd3c58
jdamerow/gdi-python-intro
/exercises/game2.py
961
4.125
4
from random import randint items = { 'sword':'ogre', 'cake':'wolf', 'balloons':'bees', 'kitty':'troll', } def does_item_protect(obstacle, item): # Your code goes here. # Your code should do something with the obstacle and item variables and assign the value to a variable for returning # Yo...
true
5c8c9c8d0c4ebe55a7d5ce857fefd416500ad486
MrGallo/classroom-examples
/11-algorithms/03b_bubble_sort_solution.py
1,009
4.28125
4
from typing import List import random def bubble_sort(numbers: List[int]) -> List[int]: # optimization 1: if gone through without swapping, its sorted, stop looping is_sorted = False # optimization 2: each pass, the last element is always sorted, don't loop to it anymore. times_through = 0 while...
true
a2d6f7b306f5dd41a3d994b218f7bfcbc8b28857
ayushi424/PyAlgo-Tree
/Dynamic Programming/Gold Mine Problem/gold_mine_problem.py
2,708
4.34375
4
# Python program to solve # Gold Mine problem # Problem Statement : Returns maximum amount of # gold that can be collected # when journey started from # first column and moves # allowed are right, right-up # and right-d...
true
611ae37b5820df62f36eaa2c9ef7ca03af4a30b0
AozzyA/homeCode
/ch2.py
987
4.15625
4
# Ask first name. nameFirst = input('what is your first name: ').strip() # Ask if you have a midle name. midleAsk = input('do you have a midle name yes or no: ').strip() # Seting nameMidle to nothing. nameMidle = '' # What happens if you type yes to do you have a midle name. if midleAsk.lower() in ['y', 'yes']: #...
true
490c7ef960b63be0a91b233cce81a98050255b7b
xiangormirko/python_work
/clock.py
541
4.15625
4
# File: clock.py # Author: Mirko (xiang@bu.edu) # Description: Definite Loop Exercise # Assignment: A03 # Date: 09/10/13 def main(): print "enter time in 24h format" StartHour=input("enter the start hour:") EndHour=input("enter the end hour:") IncrementMinutes=input("enter the increment in minutes:") ...
true
1e5612fc4db365103732c4fb4532e9a6324c9fd0
xiangormirko/python_work
/savings03.py
1,528
4.40625
4
# File: savings01.py # Author: Mirko (xiang@bu.edu) # Description:accumulating monthly interest # Assignment: A05 # Date: 09/17/13 def main(): goal= input("Enter your savings goal in dollars:") YearRatepercent= input("Enter the expected annual rate of return in percent:") yearRate=YearRatepercent/100 ...
true
364d86b7854d608eaa1caa0415ba465640cbbc62
majomendozam/semanaTec
/cannon.py
2,046
4.28125
4
"""Cannon, hitting targets with projectiles. María José Mendoza Muñiz 06/05/2021 Exercises 1. Keep score by counting target hits. 2. Vary the effect of gravity. 3. Apply gravity to the targets. 4. Change the speed of the ball. """ from random import randrange from turtle import * from freegames import vector ball ...
true
5fb3409b2814f96c093b312aa7c51e8c07d763bd
bambergerz/optimization_for_deep_learning
/bisection.py
1,155
4.1875
4
import numpy as np def bisection(func, deriv, iters, lhs, rhs): """ :param func: Our original function (which takes in a single argument) that we are trying to minimize. Argument is an integer. :param deriv: The derivative of our initial function (see above). Argument is an integer. :param i...
true
55527d6aa9a17804a2aadae86b7e78b9f6e559d8
bwasmith/smash-cs
/final-project/main.py
2,358
4.125
4
import pandas as pd # Read dataset data = pd.read_csv("CSY1Data.csv") # Get the Calculus AB test scores from dataset calculus_scores = data.loc[2] # Prepare variables for the sums I need males_passing_sum = 0 females_passing_sum = 0 another_passing_sum = 0 males_failing_sum = 0 females_failing_sum = 0 another_failin...
true
73c5fe6272768f4a30a38ba50a53afc38adb8318
SwetaSinha9/Basic-Python
/sum_prime.py
410
4.125
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Thu Jun 13 15:46:02 2019 @author: sweta """ # WAP to add all prime numbers from 1 to n and n is given by user. n = int(input("Enter a No: ")) p=0 for j in range(2, n+1): f=0 for i in range(2, int(j/2) + 1): if j % i == 0: f=1 ...
true
c0ae49719eda3526da5a6a6471a9be1f9eb9f65e
Louvani/holbertonschool-higher_level_programming
/0x06-python-classes/6-square.py
1,713
4.5
4
#!/usr/bin/python3 """ definition of a square class """ class Square: """ defines a square with a private instance attribute""" def __init__(self, size=0, position=(0, 0)): """size: Square size""" self.size = size self.position = position def area(self): return self.__size...
true
137ed6bab151a47d13909834b92829b170cfb18c
Louvani/holbertonschool-higher_level_programming
/0x07-python-test_driven_development/2-matrix_divided.py
1,214
4.125
4
#!/usr/bin/python3 """Module that divides all element of a matrix""" def matrix_divided(matrix, div): """Function that divides all element of a matrix""" if div == 0: raise ZeroDivisionError('division by zero') if not isinstance(div, (int, float)): raise TypeError('div must be a number') ...
true
968809686894aeddacb5ab1cb46dcc091fe44162
cannium/leetcode
/design-snake-game.py
2,308
4.125
4
class SnakeGame(object): def __init__(self, width, height, food): """ Initialize your data structure here. @param width - screen width @param height - screen height @param food - A list of food positions E.g food = [[1,1], [1,0]] means the first food is positioned a...
true
770a6e6b9e78a16c3148f3669379014f49518ddb
alandegenhart/python
/prog_ex/08_rock_paper_scissors.py
2,410
4.65625
5
# Practice Python Exercise 08 -- Rock, paper, scissors # # This script allows the user to play rock, paper, scissors. The user is prompted for one of three possible inputs, # randomly chooses an input for the computer, and displays the result. import random as rnd def choose_winner(sel): # Function to determine...
true
c36d93f8567325f35afb52ffcd258aef6cd1cf16
alandegenhart/python
/prog_ex/04_divisors.py
684
4.375
4
# Practice Python Exercise 4 -- Divisors # # This script asks the user for a number and returns all of the divisors of that number. # Get user input and convert to a number x = input('Enter a number: ') # Verify that input number is an integer try: x = float(x) except ValueError: print('The provided in put m...
true
ba38bb24213f0f36bdd424ed8431cad198c1d03b
o-ndr/LPTHW-OP
/ex25.py
2,572
4.28125
4
# I add the 'sentence' variable in Python (run python -i in git bash) # then assign the sentence with a few words to the variable # words = ex25.break_words(sentence) means: # 1: create variable 'words' # 2: run function 'break_words' with argument 'sentence' on 'ex25'. # 3: This function breaks words (using .split me...
true
689f14426fe2ed97bc1023164f2ce89dbd44e501
o-ndr/LPTHW-OP
/ex20.py
1,773
4.46875
4
from sys import argv script, input_file = argv # Function that takes one argument which will be a file. # When the function is called, it will read the contents of the file # and print it all out def print_all(f): print f.read() # when called with argument (file name), the method seek # will take us back to positio...
true
058d4f1f7a556c9e77c73bc65c8350bff741fcb7
xiaoming2333ca/wave_1
/Volume of Cylinder.py
249
4.125
4
import math base_radius = int(input("please enter the base radius of cylinder: ")) height = int(input("please enter the height of cylinder: ")) base_area = math.pi * pow(base_radius, 2) cylinder_volume = base_area * height print(cylinder_volume)
true
5d09a51e7546466a39fae991deb3cd33c2b29205
heangly/AlgoExpert-Problem-Solutions
/solutions-in-python/29. Node Depths.py
1,542
4.15625
4
""" *** Node Depths *** The distance between a node in a Binary Tree and the tree's root is called the node's depth. Write a function that takes in a Binary Tree and returns the sum of its nodes'depths. Each Binary Tree node has an integer value, a left child node, and a right child node. Children nodes can either be B...
true
a653abd7d830dd1f1ae67f0422b934eb39da7037
heangly/AlgoExpert-Problem-Solutions
/solutions-in-python/7. Product Sum.py
950
4.46875
4
""" *** Product Sum *** Write a function that takes in a 'special' array and returns its product sum. A 'special' array is a non-empty array that contains either integers or other 'special' arrays. The product sum of a 'special' array is the sum of its elements, where 'special' arrays inside it are summed themselves a...
true
3e1b09130f09ef3517c3722e0c01a59bf80489c6
heangly/AlgoExpert-Problem-Solutions
/solutions-in-python/1.TwoSum.py
1,797
4.25
4
""" *** Two Number Sum *** Write a function that takes in a non-empty of distinct integers and an integers representing a target sum. If any two numbers in the input array sum up to the target sum, the function should return them in an array. If no two numbers sum up to the target sum. the function should return an em...
true
77c26c1d933feefed022b1b9f86c263e207ddde0
heangly/AlgoExpert-Problem-Solutions
/solutions-in-python/17. Move Element To End.py
822
4.15625
4
""" Move Element To End You're given an array of integers and an integer. Write a function that moves all instances of that integer in the array to the end of the array and returns the array. The function should perform this in place(i.e., it should mutate the input array) and doesn't need to maintain the order of th...
true
016db88baf1a04abbdcca909d55117ee9e799f0c
wyfkwok/CompletePythonBootcamp
/00-PythonObjectAndDataStructureBasics/07-SetsAndBooleans.py
666
4.21875
4
# Sets are unordered collections of unique elements my_set = set() my_set.add(1) print(my_set) my_set.add(2) print(my_set) # Sets only accept unique values. Will not add 2 again. my_set.add(2) print(my_set) my_set.add('2') print(my_set) my_list = [4, 4, 1, 1, 1, 1, 1, 2, 2, 3, 3, 3] # Cast the list as a set. # ...
true
a37fe440410322552ccb20429c2b1e4e08c18086
luowanqian/DSA
/python/dsa/queue/linked_queue.py
1,809
4.25
4
"""A Queue using a Linked List like structure """ from .node import Node class QueueIterator: def __init__(self, queue): self._queue = queue self._pointer = queue.first def __next__(self): if self._pointer is None: raise StopIteration() node = self._pointer ...
true
80cec8f840f5672b75f9c20a7d8df5bf5b07bbf5
easyawslearn/Python-Tutorial
/#2_Python_Basic_Operators.py
1,683
4.46875
4
# Assume variable a = 10 and variable b = 20 # Operator Description Example # + Addition Adds values on either side of the operator. a + b = 30 # - Subtraction Subtracts right hand operand from left hand operand. a – b = -10 # * Multiplication Multiplies values on either side of the operator a * b = 2...
true
0cbb47f532d59ef007f011a648909e93106fb3f7
easyawslearn/Python-Tutorial
/Python-String-Basics/String-Formating.py
1,427
4.71875
5
# Python String Formating Demostration # Python program to demonstrate the # use of capitalize() function # capitalize() first letter of # string. example = "Python LEARNINF" print ("String make to capitalize\n") print(example.capitalize()) # demonstration of individual words # capitalization to generate...
true
7ef7ba9614417fe6c3ee643540da3bbc181916c5
easyawslearn/Python-Tutorial
/#3_Python_Comparison_Operators.py
1,138
4.375
4
# Operator Description Example # == If the values of two operands are equal, then the condition becomes true. (a == b) is not true. # != If values of two operands are not equal, then condition becomes true. (a != b) is true. # > If the value of left operand is greater than the value of righ...
true
862d56aa6f34b506b1496af2c959ec0d6727cb31
easyawslearn/Python-Tutorial
/#6_Python_Type_Conversion.py
1,601
4.65625
5
# Python code to demonstrate Type conversion # int(a,base) : This function converts any data type to integer. ‘Base’ specifies the base in which string is if data type is string. # float() : This function is used to convert any data type to a floating point number # complex(): This function is used to convert any da...
true
29b4b6025cdb4f00a6206db5fd3cb681556f76f8
nyu-compphys-2017/section-1-smfarzaneh
/riemann.py
882
4.5
4
# This is a python file! The '#' character indicates that the following line is a comment. import numpy as np # The following is an example for how to define a function in Python # def tells the compiler that hello_world is the name of a function # this implementation of hello_world takes a string as an argument, # wh...
true
01791bda3d20bae50bc99ca53c710eddf4d752b5
pranaymate/Python_3_Deep_Dive_Part_1
/Section 7 Scopes, Closures and Decorators/97. Global and Local Scopes - Lecture.py
2,046
4.625
5
a = 10 # def my_func(n): # c = n ** 2 # return c # # # def my_func(n): # print('global:', a) # c = a ** n # return print(c) # # my_func(2) # my_func(3) print('#' * 52 + ' ') print('# But remember that the scope of a variable is determined by where it is assigned. In particular, any variable' ...
true
f9d34e423be9b07780ee4b6898d015917736db71
pranaymate/Python_3_Deep_Dive_Part_1
/Section 5 Function Parameters/69. args - Coding.py
2,357
4.625
5
print('#' * 52 + ' Recall from iterable unpacking:') a, b, *c = 10, 20, 'a', 'b' print(a, b) print(c) print('#' * 52 + ' We can use a similar concept in function definitions to allow for arbitrary' ' numbers of positional parameters/arguments:') def func1(a, b, *args): print(a) print(b) ...
true
f5161cb4e51dc2d68c63ce944ed3b4e381094a77
pranaymate/Python_3_Deep_Dive_Part_1
/Section 7 Scopes, Closures and Decorators/103. Closure Applications - Part 1.py
2,457
4.40625
4
print('#' * 52 + ' In this example we are going to build an averager function that can average multiple values.') print('#' * 52 + ' The twist is that we want to simply be able to feed numbers to that function and get a running' ' average over time, not average a list which requires performing the s...
true
c544784f9d91764d713fd742b9ca7efccbf3b244
pranaymate/Python_3_Deep_Dive_Part_1
/Section 5 Function Parameters/75. Application A Simple Function Timer.py
2,061
4.375
4
import time def time_it(fn, *args, rep=5, **kwargs): print(args, rep, kwargs) time_it(print, 1, 2, 3, sep='-') print('#' * 52 + ' Lets modify our function to actually run the print function with any positional' ' and keyword args (except for rep) passed to it: ') def time_it(fn, *args, re...
true
4fb810313217d7bfdd66ebbcd0deec3b22ec995c
tvey/hey-python
/data_types/lists/list_methods.py
1,062
4.46875
4
""" Lists are mutable, and they have a lot of methods to operate on their items. """ # initializing a list with items fellowship = ['Frodo', 'Gandalf', 'Aragorn'] # adding item to the end of the list fellowship.append('Legolas') # you have my bow fellowship.append('Gimli') # and my axe # extending list ...
true
94b377ceb365f720fad2730683784a1e7a592ce3
tvey/hey-python
/functions/parameters_arguments.py
2,058
4.78125
5
""" Functions become ever more useful when we can pass to them some information. Creating a function, we specify the expected information with parameters. On a function call we pass arguments that match these parameters. (In general words “parameters” and “arguments” can be used interchangeably.) There are 4 ways to ...
true
5727d09696de5d71d09e6f5850ab232dcca9dd2b
MauroBCardoso/pythonGame_Zenva
/classes and objects.py
1,108
4.1875
4
#Python (classes and objects) class GameCharacter: speed = 5 # the moment it is created it has the value def __init__(self, name, width, height, x_pos, y_pos): #self is GameCharacter self.name = name self.width = width self.height = height self.x_pos = x_pos se...
true
a5247c0368bf734c5e9c5ddbd28abf0f7d5b1171
carlogeertse/workshops
/workshop_1/exercise_5/exercise1-5-3.py
220
4.3125
4
string = "This is a string with multiple characters and vowels, it should contain all five possible vowels" vowels = ["a", "e", "i", "o", "u"] for vowel in vowels: string = string.replace(vowel, "") print(string)
true
22b6d88065cac062432597e4311b35e7574812ec
yosephog/INF3331
/assignment5/diff.py
2,162
4.21875
4
import sys import re import itertools def read_file(file_name): """ this method just read a file and return it as a list spliting at new line """ sourcefile=open(file_name,'r') file=sourcefile.read() sourcefile.close() return file.split('\n') def diff(original_listinal,modified): """ This method find the di...
true
07e43d26d674d2bbf75ae303fc1ebe5feda09803
suriyaganesh97/pythonbasicprogs
/basic/list.py
535
4.3125
4
fruits = ["Strawberries", "Nectarines", "Apples", "Grapes", "Peaches", "Cherries", "Pears"] vegetables = ["Spinach", "Kale", "Tomatoes", "Celery", "Potatoes"] dirty_dozen = [fruits, vegetables] #nested list print(fruits) print(fruits[1]) #nectarines is printed and not apples fruits[2] = "guava" print(fruit...
true
df754421efc5146bc188b88c6ba70596b96d9b79
suriyaganesh97/pythonbasicprogs
/d19/turtleRace.py
1,016
4.1875
4
from turtle import Turtle, Screen import random screen = Screen() screen.setup(width=500,height=400) user_bet = screen.textinput(title="make your bet", prompt = "which turetle will win the race, enter the colour") colors = ["red", "orange", "yellow", "green", "blue", "purple"] all_turtles = [] y_position = 0 for i in ...
true
cd49287248f1ad37be22352f9c038a49a360e6dc
acharyasant7/Bioinformatics-Algorithms-Coding-Solutions
/Chapter-1/1A_1B_RepeatPattern
1,371
4.21875
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Sat Jun 13 21:10:54 2020 @author: sandesh """ #Function that takes input the string and kmer, and returns all sub-strings of #k-mer length which are repeated the most inside a string def FrequentWords(string, kmer): a = len(string) - kmer +1 Freque...
true
9ab2b4d2a99a78a3b0ca82d3df26e6f4d9a44261
purumalgi/Python-Codes
/Coordinate System.py
523
4.375
4
x = float(input("Enter x-coordinate: ")) y = float(input("Enter y-coordinate: ")) # To find which Quadrant the point lies in if x>0: if y>0: # x is greater than 0, y is greater than 0 print("Quadrant 1") else: # x is greater than 0, y is less than 0 print("...
true
14fa311c77f9734908730f8aadf29c99902cf323
RedBeret/galvanize_prep_self_study
/Control_flow.py
1,746
4.59375
5
# Day 5: Comparisons and Conditionals # Function to check if a number is equal to either 5 or 3 def five_or_three(num): return num == 5 or num == 3 print(five_or_three(3)) # True # Function to check if a number is divisible by the provided divisors def is_divisible_by(num, divisor1, divisor2): if num % divi...
true
6a8b86d98cc2de4c6051970e3aabd158d61bb90c
roman-kachanovsky/checkio-python
/solutions/codeship/the_most_wanted_letter.py
1,697
4.375
4
""" --- The Most Wanted Letter --- Simple You are given a text, which contains different english letters and punctuation symbols. You should find the most frequent letter in the text. The letter returned must be in lower case. While checking for the most wanted letter, casing does not matter, so for the purpose of you...
true
f039d41d68c85faa1079725b859bf3740d241048
roman-kachanovsky/checkio-python
/solutions/elementary/number_base.py
1,050
4.5625
5
""" --- Number Base --- Simple You are given a positive number as a string along with the radix for it. Your function should convert it into decimal form. The radix is less than 37 and greater than 1. The task uses digits and the letters A-Z for the strings. Watch out for cases when the number cannot be converted. ...
true
c5d7dd44f402c052625bd949c8ec6ad98af22f5c
roman-kachanovsky/checkio-python
/solutions/scientific_expedition/the_best_number_ever.py
1,262
4.34375
4
""" --- The best number ever --- Elementary It was Sheldon's version and his best number. But you have the coding skills to prove that there is a better number, or prove Sheldon sheldon right. You can return any number, but use the code to prove your number is the best! This mission is pretty simple to solve. You are...
true
293fcc3afc4787ced510e2ccfd295f5e51dd515c
roman-kachanovsky/checkio-python
/solutions/electronic_station/restricted_sum.py
1,022
4.125
4
""" --- Restricted Sum --- Simple Our new calculator is censored and as such it does not accept certain words. You should try to trick by writing a program to calculate the sum of numbers. Given a list of numbers, you should find the sum of these numbers. Your solution should not contain any of the banned words, even...
true
c3a2f0b420522c9fa33464dde937a1d42fed140a
roman-kachanovsky/checkio-python
/solutions/oreilly/i_love_python.py
1,476
4.25
4
""" --- I Love Python --- Elementary Let's write an essay in python code which will explain why you love python (if you don't love it, when we will make an additional mission special for the haters). Publishing the default solution will only earn you 0 points as the goal is to earn points through votes for your code ...
true
f9d2326d1aa842fc34e38236021e65e592777163
roman-kachanovsky/checkio-python
/solutions/mine/call_to_home.py
2,476
4.21875
4
""" --- Call to Home --- Elementary Nicola believes that Sophia calls to Home too much and her phone bill is much too expensive. He took the bills for Sophia's calls from the last few days and wants to calculate how much it costs. The bill is represented as an array with information about the calls. Help Nicola to ca...
true
f0fd90d791ce8335c0f964334db2483c109c7fec
roman-kachanovsky/checkio-python
/solutions/home/cipher_map.py
2,940
4.1875
4
""" --- Cipher Map --- Simple Help Sofia write a decrypter for the passwords that Nikola will encrypt through the cipher map. A cipher grille is a 4x4 square of paper with four windows cut out. Placing the grille on a paper sheet of the same size, the encoder writes down the first four symbols of his password inside t...
true
db5673deefd527a8d6f54102f0b758fd00070777
roman-kachanovsky/checkio-python
/solutions/mine/count_inversion.py
942
4.4375
4
""" --- Count Inversion --- Simple You are given a sequence of unique numbers and you should count the number of inversions in this sequence. Input: A sequence as a tuple of integers. Output: The inversion number as an integer. How it is used: In this mission you will get to experience ...
true
254950299ae7315540091bbedb56187f2bee55f0
aluramh/DailyCodingProblems
/DailyCodingProblems/problem29.py
1,327
4.1875
4
# This is your coding interview problem for today. # This problem was asked by Amazon. # Run-length encoding is a fast and simple method of encoding strings. # The basic idea is to represent repeated successive characters as a single # count and character. # For example, the string "AAAABBBCCDAA" would be encoded as ...
true
f469304deb48ba6bd2b07a713dc41909129a830e
cmjagtap/Algorithms_and_DS
/recursion/reverse.py
220
4.125
4
#Reverse using recursion def Reverse(data,start,stop): if start<stop-1: data[start],data[stop-1]=data[stop-1],data[start] Reverse(data,start+1,stop-1) data=range(1,10) print data Reverse(data,0,len(data)) print data
true
c4cb54f980a45f593d4fddbe66dd1dcff7a13848
cmjagtap/Algorithms_and_DS
/strings/combinationsWithInbuilt.py
369
4.125
4
# You are given a string . # Your task is to print all possible size replacement combinations of the string in lexicographic sorted order. # Sample Input: # HACK 2 from itertools import combinations_with_replacement def combinations(string,k): temp=[] comb=combinations_with_replacement(sorted(string),k) for x in ...
true
fc26537be41ae42f62a2fbef28e09e4836b60599
rodpoblete/practice_python
/decode_web_page_two.py
1,541
4.375
4
"""Using the requests and BeautifulSoup Python libraries, print to the screen the full text of the article on this website: http://www.vanityfair.com/society/2014/06/monica-lewinsky-humiliation-culture. The article is long, so it is split up between 4 pages. Your task is to print out the text to the screen so that you...
true
3822e6ce8e516a239ab39c06eb2298b7ab674729
rodpoblete/practice_python
/reverse_word_order.py
725
4.40625
4
"""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 name is Michele Then I would see the string: Michele is name My} shown back to me.""" d...
true
e0dc6ce23c8da182cce5e6b6c87d48a23336ebf2
EndaLi/exercise_inbook
/需要调试的文件/word_count.py
769
4.21875
4
def count_words(filename): try: with open(filename) as f_obj: contents = f_obj.read() except FileNotFoundError: pass #msg = "sorry,the file " + filename + " does not exist." #print(msg) else: words = contents.split() num_words = len(words) ...
true
25e02da61259ae477adbe6bf13ee214f71c4a8b0
JacksonYu92/tip-calculator
/main.py
362
4.28125
4
print("Welcome to the tip calculator!") bill = float(input("What was the total bill? $" )) tip = int(input("How much tip would you like to give? 10, 12, or 15? ")) people = int(input("How many people to split the bill? ")) bill_for_individual = bill * ((tip/100)+1) / people final = "{:.2f}".format(bill_for_individual) ...
true
346f61c266e60f57b4a42f189849ed7ca87f038b
yazzzz/MIT
/primes.py
1,305
4.125
4
#!/usr/bin/python # file:///Users/ykhan/hackbright/code/mit/6-00-fall-2008/contents/assignments/pset1a.pdf """pset 1, problem 1: Write a program that computes and prints the 1000th prime number. """ import math def prime1000(): possible_primes = [2, 3, 5, 7] + range (3, 1000) for number in range (3, 1000)...
true
18f3b0ee8f6cdcb94622d8e4397d2507c1e3dd7d
abarciauskas-bgse/code_kata
/cracking_the_coding_interview/chapter_8/8_1_fibonacci.py
991
4.4375
4
# Write a method to generate the nth Fibonacci number. # Following the recommended approach: # 1. What is the subproblem? # Adding two numbers # 2. Solve for f(0): fib(0): return None # 3. Solve for f(1): fib(1): return 1 # 4. Solve for f(2): fib(2): return fib(1) + 1 # 5. Understand how to use f(2) for f(3): f(3) =...
true
48ce3b1e37d0e6031e24ab1739933eae09024bc1
RaphOfficial/CollatzConjecture
/main.py
1,539
4.125
4
# Includes import matplotlib.pyplot as plt from libs import utils from libs import loops def make_line_chart(x_list, y_list): plt.plot(x_list, y_list) plt.show() def calculate_collatz_conjecture(seed): if utils.is_positive(seed): # If is positive numb_sequence = loops.positive_inte...
true
bb991f3af669693bc217da269475efee5389bd35
klipanmali/datastructures
/py/datastructuresGraphDfsStack.py
1,567
4.25
4
# Python3 program to print DFS traversal # from a given given graph, version using recursion from collections import defaultdict from queue import LifoQueue class Graph: def __init__(self): self.graph = defaultdict(list) def add_edge(self,begin_vertex, end_vertex): self.graph[begin_vertex].a...
true
c6807ddea7a7f85f610d03dc70da5135f02edf63
klipanmali/datastructures
/py/datastructuresGraphEulerianDirectedHierholzer.py
2,715
4.40625
4
# Python3 program to print Eulerian circuit in given # directed graph using Hierholzer algorithm # The algorithm assumes that the given graph has a Eulerian cycle. from collections import defaultdict class Graph: def __init__(self, num_of_v): self.num_of_v = num_of_v self.adjacents = defaultdict(...
true
791931eefee9ca2bd234c192872eaef33381aebc
quinn-dougherty/DS-Unit-3-Sprint-1-Software-Engineering
/tmp/aquarium.py
1,701
4.5625
5
#!/usr/bin/env python '''python module for simulating aquariums''' from collections import defaultdict class Aquarium: '''Example class to model an aquarium''' def __init__(self, name="Pierre's Underwater World"): self.name = name self.fish = defaultdict(int) def add_fish(self,fish_sp...
true
44d5481d6aa2663f0f1094807cad6c8591781007
hankli2000/python-algorithm
/traversal.py
1,427
4.15625
4
class Node: def __init__(self, val): self.val = val self.left = None self.right = None def printInorder(root): '''inorder (left, root, right) ''' if root: printInorder(root.left) print(root.val) print(root.right) def printPostOrder(root): '''postorder (left, right, root)''' if root: printPostOrder...
true
aceec6a88d8143e10713ac4e8f6c142441c06d57
mede0029/Python-Programs
/05 - Converting_Files/Lab9B.py
725
4.25
4
## The two text files 2000_BoysNames.txt and 2000_GirlsNames.txt list the popularity of boys names and girls names in 2000. ## The format of the file is simple, one line per entry with the name followed by a space followed by the number of children ## carrying that name. You must write a python program that reads each ...
true
f7aee9c1478a8631c187efb4a5b69f576951cf2e
bkalcho/think-python
/print_hist.py
392
4.15625
4
# Author: Bojan G. Kalicanin # Date: 17-Oct-2016 # Dictionaries have a method called keys that returns the keys of the # dictionary, in no particular order, as a list. Modify print_hist to # print the keys and their values in alphabetical order. import histogram def print_hist(d): k = d.keys() for c in sorted...
true
14be9204764bd2f8390e924f9967a3b35313255b
bkalcho/think-python
/czech_flag.py
650
4.21875
4
# Author: Bojan G. Kalicanin # Date: 28-Oct-2016 # Write a program that draws the national flag of the Czech Republic. # Hint: you can draw a polygon like this: # points = [[-150,-100], [150, 100], [150, -100]] # canvas.polygon(points, fill='blue') from swampy.World import World world = World() canvas = w...
true
95f176f39becb47df908227c5721cfba59cece32
bkalcho/think-python
/most_frequent.py
702
4.21875
4
# Author: Bojan G. Kalicanin # Date: 18-Oct-2016 # Write a function called most_frequent that takes a string and prints # the letters in decreasing order of frequency. Find text samples from # several different languages and see how letter frequency varies # between languages. def histogram(string): h = {} for...
true
502deea46276a5a0d7b96e4bb25c18937e9e99fb
IlyaSavitckiy/python-project-lvl1
/brain_games/games/calc.py
1,190
4.21875
4
"""Logic of the brain calc game.""" from operator import add, mul, sub from random import choice, randint DESCRIPTION = 'What is the result of the expression?' OPERATORS = ('+', '-', '*') def calculate(num_one, num_two, operator): """Calculate a result of an operation with 2 numbers using operator. Args: ...
true
1d629f52543125762317447b89cf6e470f4ee3b7
Jnrolfe/LearningPython
/ControlExercises.py
800
4.25
4
#ControlExercises.py #by James Rolfe #This program shows how to use various control statements in Python3 ''' userInput = input('Enter 1 or 2: ') if userInput == "1": print ("Hello World") print ("How are you?") elif userInput == "2": print("Python3") else: print("stuff") #declaring enum or list pets = ['cats', ...
true
1be991ee0b91969bc8f30e071eea5fc6b8554761
kingzLoFitness/pythonCrashCourse
/2023March20SpeedRun_pythonCrashCourseBook/chapter2_variablesAndSimpleDataTypes/ch2_tryItYourself/ch2_tiy_1.py
623
4.375
4
""" Write a separate program to accomplish each of these exercises. Save each program with a filename that follows standard Python conventions, using lower­case letters and underscores, such as simple_message.py and simple_messages.py. """ # 2-1. Simple Message: Assign a message to a variable, and then print that m...
true
06b5ef581bb9b12af640f0bc664cfd0088cf3d0c
kingzLoFitness/pythonCrashCourse
/firstTry/ch6_dictionaries/1_alien.py
1,851
4.21875
4
''' # a simple Dictionary... am i able to write on iPad Pro 10.5 in pretty fast without my external keyboard? - effectively they can model real-world situations game featuring aliens with different colors and point values as stored information ''' alien_0 = {'color': 'green', 'points': 5} print(alien_0['color']) pr...
true
800de065932f535271ca7f6cde0090ab266d69fb
kingzLoFitness/pythonCrashCourse
/firstTry/ch5_ifStatements/tryItYourself/1_tryitYourSelf_5-12.py
2,673
4.21875
4
# Try it Yourself ''' 5-1. Conditional Tests: Write a series of conditional test. Print a statement describing each test and your prediction for the result of each test. Your code should look something like this: _______________________________________________ car = 'subaru' print("Is car == 'subaru'? I predict True...
true
811917b5fbcbde4100e7a3bc4a8da5b45c4fbd1b
kingzLoFitness/pythonCrashCourse
/firstTry/ch4_workingWithLists/3_even_numbers.py
376
4.125
4
''' Using range() to Make a List of Numbers - continue (last file is first_number.py) ''' # pass a third argument to range() (as a stepsize when generating numbers) # it adds 2 to that value (adding 2 repeatedly until it reaches or passes the end valeu, 11) # and provide this result as the output: [2, 4, 6, 8, 10] eve...
true
69948da74a24b04164206ae9a89a06b04b773a9f
kingzLoFitness/pythonCrashCourse
/2023March20SpeedRun_pythonCrashCourseBook/chapter2_variablesAndSimpleDataTypes/ch2_tryItYourself/ch2_tiy_3.py
680
4.375
4
''' Try It Yourself 2-8. Number Eight: Write addition, subtraction, multiplication, and division operations that each result in the number 8. Be sure to enclose your operations in print() calls to see the results. You should create four lines that look like this: print(5+3) Your output should simply be four lines with ...
true
f7e246c5ee79be880b0f8c3e415842ed264a4b56
harishbharatham/Python_Programming_Skills
/Prob13_12.py
672
4.1875
4
from Triangle import Triangle, TriangleError import sys s1,s2,s3 = eval(input('Enter the three sides of a triangle:')) t1 = Triangle(s1,s2,s3) try: if((s1+s2 < s3) or (s2+s3 < s1) or (s3+s1 < s2)): raise TriangleError except TriangleError: print('The sides do not form a triangle') sys.exit() t1.setC...
true
9d41b7460d3aadc17f460f05a869b7b16f93d57c
nhat2008/projecteuler-solutions
/pro_014_longest_collatz_sequence.py
1,332
4.21875
4
# The following iterative sequence is defined for the set of positive integers: # # n -> n/2 (n is even) # n -> 3n + 1 (n is odd) # # Using the rule above and starting with 13, we generate the following sequence: # # 13 -> 40 -> 20 -> 10 -> 5 -> 16 -> 8 -> 4 -> 2 -> 1 # It can be seen that this sequence (starting at 13...
true
d5881da3df86500cb9bc06f7cd226c33afee7dbc
elgeish/Computing-with-Data
/projects/py/chapter6/lists.py
650
4.5
4
a = [1, 2, 3] # list containing three integers b = [a, "hello"] # list containing a list and a string b.append(4) # modify existing list by appending an element print(a) print(b) # Example: inserting, removing, and sorting elements a = [1, 2, 3] a.insert(1, 100) # insert 100 before index 1 print(a) a.remove(2) #...
true
c3b0f9ec0681884cc9d6208f91685b4a8f1ca669
elgeish/Computing-with-Data
/projects/py/chapter6/reading-and-writing-data-in-text-format.py
579
4.53125
5
# Example: read a text file line by line using a for-loop f = open("mobydick.txt", "r") # open file for reading words = [] for line in f: # iterate over all lines in file words += line.split() # append the list of words in line f.close() # Example: the with statement with open("mobydick.txt") as f: # "rt" is the ...
true
5fee63a5cd16b2a117284a269cc6fdb098720441
elgeish/Computing-with-Data
/projects/py/chapter6/list-comprehensions.py
775
4.46875
4
from collections import Counter # Example: a simple, mundane transformation to a list words = ['apple', 'banana', 'carrot'] modes = [] for word in words: counter = Counter(word) # most_common(n) returns a list and the * # operator expands it before calling append(x) modes.append(*counter.most_common(1)) print(...
true
e613cdb8563ba38312941d5b5e99877bdef92524
Yiraneva/python-coding-practice
/Udacity_Python_CompoundDataStructure.py
1,073
4.3125
4
# Quiz: Adding Values to Nested Dictionaries # Try your hand at working with nested dictionaries. Add another entry, 'is_noble_gas,' to each dictionary in the elements dictionary. After inserting the new entries you should be able to perform these lookups: # >>> print(elements['hydrogen']['is_noble_gas']) # False # >>...
true
64e7cbd97a12b3db818622a02a46e89b7d96b46c
yashbhokare/cse576_project_2
/src/data/formats.py
1,031
4.625
5
"""This module contains functions for formatting data. A formatting function generates a single sentence for the passed task, numbers, and target. Each function accepts three arguments: the task (task_name) as defined in config.TASKS, a list of input numbers, and the target value. The function returns a single sentenc...
true
701a16cae4cdc3c3b7c1e23e1b9b27a1e885d98b
Konrad-git-code/Aspp2021-exercises-day4
/simple_math.py
2,504
4.125
4
""" A collection of simple math operations """ def simple_add(a,b): """ Addition of two numbers. Parameters ---------- a : int, float Number to be added. b : int, float Number to be added. Returns ---------- int, float The result of the ad...
true
b04d9873a978bc8591c9091902de9b46de0a9f62
clede/chemistry
/chemistry.py
2,218
4.34375
4
import initialization class Unit(object): """A unit of measurement for a substance or supplement. e.g. capsule, tablet, drop, or milligram, etc.""" # In the future we will need to track relationships between different units. # e.g. a 'gram' consists of 1000 'milligrams'. def __init__(self, singul...
true