blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
3d937fce84d5cb59a5424014b4d0a42942fb3661
alvinwang922/Data-Structures-and-Algorithms
/Matrices/Flood-Fill.py
1,521
4.21875
4
""" An image is represented by a 2-D array of integers, each integer representing the pixel value of the image (from 0 to 65535). Given a coordinate (sr, sc) representing the starting pixel (row and column) of the flood fill, and a pixel value newColor, "flood fill" the image. To perform a "flood fill", consider the ...
true
7cbab018f0905dadf19ee3b27ede26839cb27aab
alltej/kb-python
/data_structures/tuples.py
782
4.65625
5
##TUPLES - A tuple is a one dimensional, fixed-length, immutable sequence. tup = (1, 2, 3) print(tup) #convert to tuple list_1 = [1,2,3] tup_1 = type(tuple(list_1)) #create a nested tuple nested_tup = ([1,2,3],(4,5)) print(nested_tup) print(nested_tup[0]) # Although tuples are immutable, their contents can conta...
true
1206dbd776ea188e499d301fcb655040e5d6d434
Jhon112/holbertonschool-higher_level_programming
/0x07-python-test_driven_development/5-text_indentation.py
649
4.15625
4
#!/usr/bin/python3 """prints a text with 2 new lines after each of these characters: ., ? and :""" def text_indentation(text): """replace the characters ., ? and : for a 2 blank_lines Args: text (str): str that will be modified Returns: prints the new text Raises: TypeError:...
true
2e2d6a28de15808f95b8c848338905b202764ec9
Jhon112/holbertonschool-higher_level_programming
/0x07-python-test_driven_development/tests/6-max_integer_test.py
1,350
4.375
4
#!/usr/bin/python3 """Test max_integer function""" import unittest max_integer = __import__('6-max_integer').max_integer class TestMaxInteger(unittest.TestCase): """class to test max_integer function No attributes are needed but different methods for differents test cases are. """ def test_empty_li...
true
e6e4a29ab2520be59425f9651c40d6e49866d720
ik2y/recode-beginner-python
/materials/week-4/src/solveTogether-bmi.py
649
4.28125
4
# The formula is BMI = weight(kg) / height (m) ^ 2 # - Underweight: < 18.5 # - Normal: 18.5 - 24.9 # - Overweight: 25 - 29.9 # - Obese: > 30 userWeight = input("Insert your weight in KG: ") userWeight = float(userWeight) userHeight = input("Insert your height in meters: ") userHeight = float(userHeight) bmiValue = u...
true
e01a7b6001470bf28970a96664e8a212033d22d6
ik2y/recode-beginner-python
/materials/week-7/src/takeHomeChallenge-wordCounter/app.py
1,101
4.15625
4
############################################################### # do not modify the code in here ############################## from helper.TxtReader import TxtReader import helper.Utility import clearScreen DATA_PATH = "text.txt" # load data txtReader = TxtReader(DATA_PATH) rawSentence = txtReader.load() # do not d...
true
57e5e4ff4c6ed09c3c4902bdd182b373c4686422
srisivan/python
/divisibility.py
396
4.3125
4
# To find divisible numbers for 3. divisors = [] my_num = int(input("Enter the desired number : ")) for i in range (1, (my_num + 1)): if my_num % i == 0: divisors.append(i) length = len(divisors) if length == 2: print("%s is a prime number" % my_num) else: print("%s is a composite number...
true
57b2759986521a7435beed8922aafc8a19b25f75
nikolaosmparoutis/Algorithms_and_Data_Structures_Python
/breadth_first_search.py
920
4.3125
4
# Implementation of breadth first search using queue. Add children then BFS the tree # from left to right. Input an empty array where the return from the BFS will fill it with the nodes. # T=O(V+E) traverse the nodes + for each node traverse its edges(children), # space O(V) class Node: def __init__(self, name): ...
true
1495c305585fd90afb2967e3a753e7bfd89e69d0
Stanislav144/python
/rekord.py
1,411
4.15625
4
# Programm record # scores = [] choice = None while choice != "0": try: print( """ 0- Exit 1- View record 2- Add record 3- Delete record 4- Sorted list """ ) choice = input('Enter position: ') print() # Exit if choice == '0': print("Good...
true
d9b99b09041ae56608107cf6993b6cc1665120ff
jc98924/Metis-Data-Science-Prework
/lessons/python_intro/calc_row_value.py
837
4.59375
5
#!/usr/bin/python import os import sys def calc_row_value(input_string): """ This function takes a string input, converts it to an integer value and then outputs a "new value". --- args: input_string(str): input string returns: calc_value (int): output value """ if type...
true
8fef04cee7bd39d7a23c2e9f74b5e741f424bf61
serre-lab/smart-playroom-kalpit
/kinectpath/source/utils/misc.py
1,385
4.21875
4
"""Miscellaneous helper functions required for calculations """ import numpy as np def calc_line_point_distance(line, point): """Function to calculate the distance of a point from a line Parameters ---------- line : list (x1, y1, z1, x2, y2, z2) - the endpoints of the line segment point :...
true
4e27bf1d7ec0a4f8d87c8f01e47577029413c4fe
mndimitrov92/Python3_deep_dive
/Functional_Closure_decorators/decorators_with_attributes.py
1,063
4.25
4
""" Decorators which can contain additional attributes that can be accessed. """ from functools import wraps def my_decorator(fn): my_var = {} @wraps(fn) def wrapper(*args, **kwargs): print("Decorating...") result = fn(*args, **kwargs) print("Finished") return result def my_helper_func(): print("Help ...
true
9e3a4323ce922225209ba8eb326ce434a9c6e77c
Somesh1501/Codes
/sort_method.py
229
4.3125
4
#sort method is used for sorting element in a list #sorted function animals = ['dog','fox','cow','cat'] animals.sort(reverse = True) print(animals) ''' print(sorted(animals)) x=(sorted(animals)) x.reverse() print(x)'''
true
e5701d4e69fba20f6478ec1ab94a57e567d2a82d
peninah-odhiambo/andela-day4
/missing_number.py
401
4.125
4
def find_missing (list1, list2): """ The lists represent two different lists""" # list1 = set (list1) # list2 = set (list2) if len(list1) > len(list2): for number in list1: if number not in list2: return number else: for number in list2: if number not in list1: return number """set gets rids of...
true
072c2b2b60dc5e4e056742228f14a85902a2b83e
ninarobbins/astr-119-session-2
/dictionaries.py
376
4.125
4
# dictionaries have key:value for elements example_dict = { 'class' : 'Astr 119', 'prof' : 'Brant', 'awesomeness' : 10 } print(type(example_dict)) #get value with key course = example_dict['class'] print(course) #change a value via key example_dict['awesomeness'] += 1 #increase awesomeness print(example_dict) f...
true
b83bb0e5c7c7c284c9b5d7dce366b3b626856f9a
VINEETHREDDYSHERI/Python-Deep-Learning
/ICPLab2/src/Question1.py
879
4.1875
4
studentCount = int(input("Enter No.of Students: ")) # Asking the User to provide count of students studentHeightsInFeet = [] studentHeightsInCM = [] for i in range(studentCount): height = float(input("Enter the Student-{} height in Feet ".format(i))) # Accepting Height of the each student # from user and conv...
true
811d5e93df6669d787ddd75713785ec4d9d6f006
livsmith77/Reading-text-files
/MAP_REDUCE_FILTER.py
1,751
4.15625
4
1. Temperature conversions def fahrenheit(t): return ((float(9)/5)*t + 32) def celsius(t): return (float(5)/9*(t - 32)) def to_fahrenheit(values): return map(fahrenheit, values) def to_celsius(values): return map(celsius, values) 2. Return maximum value from list def max(values): r...
true
c54ee7da573fab0b4fe1f9c8b93d90cfb0b7d17f
arnab0000/StartUps
/CaseStudy/solution1.py
2,762
4.34375
4
# 1. Your Friend has developed the Product and he wants to establish the product startup and he is searching for a perfect location where # getting the investment has a high chance. But due to its financial restriction, he can choose only between three locations - Bangalore, # Mumbai, and NCR. As a friend, you...
true
ebef709fb875dbccc987fb7fc94ac1474bbd9f56
AwsafAlam/Python_Problems
/Basics/List_Pract.py
2,395
4.53125
5
courses = ['Datastructures' , 'AI' , 'Micro' , 'Assembly'] print(courses) print(courses[0]) print(courses[len(courses) - 1]) # or, we can use negative indexes print(courses[-1]) ## So, we can traverse in reverse as well print(courses[0:3]) ## starting at 0 , and upto but not including 3 (ie, < 3 ) print(courses[:2]...
true
49c8c5504bf0d1932ef3f7b3a294e7577fd1be7b
antoni-g/programming-dump
/vgg/manhattan.py
875
4.25
4
# The following method get the manhatten distance betwen two points (x1,y1) and (x2,y2) def manhattan_distance(x1, y1, x2, y2): return abs(x1 - x2) + abs(y1 - y2) def convert(l): try: l[0] = float(l[0]) l[1] = float(l[1]) except ValueError: print("An input character was not a number.") exit() # Enter yo...
true
2b609dccec107322e639da52fcaa496e1be3200f
choroba/perlweeklychallenge-club
/challenge-228/pokgopun/python/ch-1.py
698
4.125
4
### Task 1: Unique Sum ### Submitted by: Mohammad S Anwar ### You are given an array of integers. ### ### Write a script to find out the sum of unique elements in the given array. ### ### Example 1 ### Input: @int = (2, 1, 3, 2) ### Output: 4 ### ### In the given array we have 2 unique elements (1, 3). ### Example 2...
true
0410ee45731cc27f26fd509d21b5e8c37e7fcd0f
choroba/perlweeklychallenge-club
/challenge-025/lubos-kolouch/python/ch-2.py
2,635
4.59375
5
def chaocipher_encrypt(message: str) -> str: """ Encrypts a message using the Chaocipher algorithm. Chaocipher is a symmetric encryption algorithm that uses two mixed alphabets to perform a double substitution on each letter of the plaintext. The two alphabets are predetermined and fixed. Args...
true
8c7d82cd01beb8066fb38276e41783c950a5027d
choroba/perlweeklychallenge-club
/challenge-208/lubos-kolouch/python/ch-2.py
1,435
4.40625
4
#!/usr/bin/env python # -*- coding: utf-8 -*- from typing import List, Tuple, Union def find_missing_and_duplicate(nums: List[int]) -> Union[Tuple[int, int], int]: """ Finds the duplicate and missing integer in a given sequence of integers. Args: nums (List[int]): A list of integers with one mis...
true
67e59949be5273b74bd40126657c52ad8022feec
choroba/perlweeklychallenge-club
/challenge-212/manfredi/python/ch-1.py
1,080
4.125
4
#!/usr/bin/env python3 # Python 3.9.2 on Debian GNU/Linux 11 (bullseye) print('challenge-212-task1') # Task 1: Jumping Letters # You are given a word having alphabetic characters only, and a list of positive integers of the same length # Write a script to print the new word generated after jumping forward each letter...
true
e0fc6f2aaee11b9eb1cf92e1db5a0030d047aec9
choroba/perlweeklychallenge-club
/challenge-206/spadacciniweb/python/ch-1.py
1,732
4.25
4
# Task 1: Shortest Time # Submitted by: Mohammad S Anwar # # You are given a list of time points, at least 2, in the 24-hour clock format HH:MM. # Write a script to find out the shortest time in minutes between any two time points. # # Example 1 # Input: @time = ("00:00", "23:55", "20:00") # Output: 5 # # Since the d...
true
c8ca87012b85e47b31c3de061e2f614fc3c0b936
choroba/perlweeklychallenge-club
/challenge-034/lubos-kolouch/python/ch-2.py
1,111
4.40625
4
#!/usr/bin/env python # -*- coding: utf-8 -*- # Define a function to add two numbers def add(a, b): return a + b # Define a function to subtract two numbers def subtract(a, b): return a - b # Define a function to multiply two numbers def multiply(a, b): return a * b # Define a function to divide two...
true
0d747cbd92407a75a2bc104bf5dbe0968dc9e372
choroba/perlweeklychallenge-club
/challenge-023/lubos-kolouch/python/ch-2.py
1,466
4.21875
4
#!/usr/bin/env python # -*- coding: utf-8 -*- import sys from typing import List def prime_decomposition(n: int) -> List[int]: """ Compute the prime factors of a number. Args: n: An integer greater than or equal to 2. Returns: A list of prime factors of the input number. Raises...
true
9f5bef0b4d288b4f35fa4f7dd3e300ea5cdf95e2
choroba/perlweeklychallenge-club
/challenge-228/spadacciniweb/python/ch-1.py
868
4.125
4
# Task 1: Unique Sum # Submitted by: Mohammad S Anwar # # You are given an array of integers. # Write a script to find out the sum of unique elements in the given array. # # Example 1 # Input: @int = (2, 1, 3, 2) # Output: 4 # # In the given array we have 2 unique elements (1, 3). # # Example 2 # Input: @int = (1, 1...
true
3a5da53de265165f484f3df00a716bd2f67b2577
HelmuthMN/python-studies
/begginer_projects/acronym.py
227
4.25
4
print("Enter the full meaning and we provide the acronym.") acronym = " " meaning = input("Full Meaning: ") phrase = (meaning.replace('of', '')).split() for word in phrase: acronym = acronym + word[0].upper() print(acronym)
true
f13d007eea6e94814615fc1c33abd4eb5f3df379
JoseSerrano22/basic-calculator-recursion
/main.py
1,473
4.1875
4
import art print(art.logo) def add(n1,n2): result = n1+n2 return result def substract(n1,n2): result = n1-n2 return result def mult(n1,n2): result = n1*n2 return result def div(n1,n2): result = n1/n2 return result operations = { #dictionary of funcions "+": add, "-": substract, "*": mult, ...
true
a699bb554458b43e6a6418f8e1eff32feb139eaa
maxthemouse/myhpsc
/homework/homework2/hw2a.py
1,143
4.125
4
""" Demonstration script for quadratic interpolation. Update this docstring to describe your code. Modified by: M. Adam Webb """ import numpy as np import matplotlib.pyplot as plt from numpy.linalg import solve # Set up linear system to interpolate through data points: # Data points: xi = np.array([-1., 1., 2]) yi =...
true
536c642ab2156d9eb572b0d2123c6828cd6d4ae6
Marist-CMPT120-FA19/-Gabi-Gervasi--Lab-3
/tree.py
329
4.21875
4
def tree(): print("How many branches in the tree") print() height = input("Number of Branches : ") length = int(height)*2-1 space = (length-1)/2 x=1 while x <= int(height): print (" "* (int(space)- x +1 ), "#"*(2*x-1)) x=x+1 print(" "*(int(height) -1), "#") tree() ...
true
49eb017ae455509a32fda6f5073bf032b79334e2
kawing13328/Basics
/My Homework/Ex_9-3.py
1,634
4.84375
5
"""9-3: Users 1. Make a class called User. Create two attributes called first_name and last_name, and then 2. create several other attributes that are typically stored in a user profile. 3. Make a method called describe_user() that prints a summary of the user’s information. 4. Make another method called greet_user() ...
true
3e7903b6dec9f72cf5e9f88ec4abcdc9499fc5c6
rraj29/ProgramFlow
/searching2.py
1,004
4.25
4
shopping_list = ["milk", "pazzta", "eggs","spam", "bread", "rice"] item_to_find = "albatross" #The next initialization is important if the item is not found in the list. Otherwise we'll get error. found_at = None #we are searching for something, we need to find the index at which it is located #for index in range(6)...
true
b0784098e30c43588a5dcd5535006eb7f8b44ef1
kajili/interview-prep
/src/cracking_the_coding_interview/ch_01_arrays_and_strings/Q1_04_PalindromePermutation.py
1,178
4.25
4
# CTCI Question 1.4 Palindrome Permutation # Given a string, write a function to check if it is a permutation of a palindrome. # A palindrome is a word or phrase that is the same forwards and backwards. # A permutation is a rearrangement of letters. # The palindrome does not need to be limited to just dictionary words...
true
9f102c93e36f09140eb08ab9954101c59a229de9
mouday/SomeCodeForPython
/test_from_myself/leetcode/760. Find Anagram Mappings.py
1,178
4.125
4
""" 760. Find Anagram Mappings Given two lists Aand B, and B is an anagram of A. B is an anagram of A means B is made by randomizing the order of the elements in A. We want to find an index mapping P, from A to B. A mapping P[i] = j means the ith element in A appears in B at index j. These lists A and B may contain d...
true
d4a618dbff9c023f636126babb245f533da50a08
abmish/pyprograms
/100Py/Ex37.py
282
4.125
4
""" Define a function which can generate and print a list where the values are square of numbers between 1 and 20 (both included). """ def num_square_list(num): sq_list = list() for i in range(1, num+1): sq_list.append(i ** 2) print sq_list num_square_list(20)
true
be8d6f2cc44daeca5e03c98ff560e8eccb351f5c
abmish/pyprograms
/100Py/Ex2.py
556
4.1875
4
""" Write a program which can compute the factorial of a given list of comma-separated numbers. The results should be printed in a comma-separated sequence on a single line. Suppose the following input is supplied to the program: 8,5 Then, the output should be: 40320,120 """ def factorial(num): if num ==0: ...
true
4026f1f3ceba0ae5ac94b3af49de6529209c4222
abmish/pyprograms
/intermediate/I5.py
1,870
4.21875
4
""" PALPRIM - Palindromic Primes A Palindromic number is a number without leading zeros that remains the same when its digits are reversed. For instance 5, 22, 12321, 101101 are Palindromic numbers where as 10, 34, 566, 123421 are not. A Prime number is a positive integer greater than 1 that has no positive divisors ot...
true
5c74dc0f564824fd35817728941b6c82381f952a
abmish/pyprograms
/100Py/Ex86.py
252
4.1875
4
""" By using list comprehension, please write a program to print the list after removing numbers which are divisible by 5 and 7 in [12,24,35,70,88,120,155] """ tlist = [12,24,35,70,88,120,155] print [num for num in tlist if num%5 == 0 and num%7 == 0]
true
1b3ddb739a4cbd02e853f3312fa0b08c3bd0cd18
abmish/pyprograms
/100Py/Ex44.py
280
4.53125
5
""" Write a program which accepts a string as input to print "Yes" if the string is "yes" or "YES" or "Yes", otherwise print "No". """ input_str = raw_input("input yes variation:") if input_str=="yes" or input_str=="YES" or input_str=="Yes": print "Yes" else: print "No"
true
c49a758c98c06b5f3d4d631310a59e1fcadd5169
abmish/pyprograms
/100Py/Ex71.py
310
4.25
4
""" Please write a program which accepts basic mathematical expression from console and print the evaluation result. If the following string is given as input to the program: 35+3 Then, the output of the program should be: 38 """ user_exp = raw_input("Input a mathematical expression :") print eval(user_exp)
true
e11fd9c5ef073e8e0636346f15adb29c87d9562d
abmish/pyprograms
/euler/e30.py
659
4.125
4
""" Surprisingly there are only three numbers that can be written as the sum of fourth powers of their digits: 1634 = 1^4 + 6^4 + 3^4 + 4^4 8208 = 8^4 + 2^4 + 0^4 + 8^4 9474 = 9^4 + 4^4 + 7^4 + 4^4 As 1 = 1^4 is not a sum it is not included. The sum of these numbers is 1634 + 8208 + 9474 = 19316. Find the ...
true
632395e421c68037fa58d4876a541be446d4428a
abmish/pyprograms
/100Py/Ex24.py
663
4.3125
4
""" Python has many built-in functions, and if you do not know how to use it, you can read document online or find some books. But Python has a built-in document function for every built-in functions. Please write a program to print some Python built-in functions documents, such as abs(), int(), raw_input() And add doc...
true
f7a07ea2f7fb455ea2afddea71e9405f23a70d5b
google/google-ctf
/third_party/edk2/AppPkg/Applications/Python/Python-2.7.2/Demo/scripts/fact.py
1,182
4.4375
4
#! /usr/bin/env python # Factorize numbers. # The algorithm is not efficient, but easy to understand. # If there are large factors, it will take forever to find them, # because we try all odd numbers between 3 and sqrt(n)... import sys from math import sqrt def fact(n): if n < 1: raise ValueE...
true
b7855277caad219b7e696201229ca46c036d84ff
sufairahmed/Udacity-Introduction-to-Python-Practice
/sum_of_series.py
520
4.21875
4
def sum_of_series(num_series): total = 0 for i in range(0, num_series): total = total + i print("The sum of the series {} = {}".format(num_series, total)) def sum_of_square_series(num_series): total = 0 total = (num_series * (num_series + 1) * (2 * num_series + 1 )) / 6 p...
true
385df9987fa2baa4709aa28d27c190371b134f3a
DavidBlazek18/Python-Projects
/python_Polymorphism_Assignment_P193.py
2,891
4.15625
4
#Parent class class Airline_Passenger: name = "Chuck Yeager" email = "Yeager@gmail.com" password = "1234abcd" def getLoginInfo(self): entry_name = input("Enter your name: ") entry_email = input("Enter your email: ") entry_password = input("Enter your password: ") if ent...
true
0286c74096a35d30aebee609727ca21e66bada45
ICS3U-Programming-JonathanK/Unit5-01-Python
/temp_convert.py
838
4.28125
4
#!/usr/bin/env python3 # Created by: Jonathan Kene # Created on: June 1, 2021 # The program will use one for loop and one if statement, # outputting five integers per line with each separated by a space. def fahrenheit(): user_string = input("Enter the Temperature (°C): ") print("") # make sure if the u...
true
c5524e0f95241287a34536f24fefa49a60136e53
uniquearya70/Python_Practice_Code
/q15_odd.py
464
4.375
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Fri Jun 15 16:49:35 2018 @author: arpitansh """ ''' Use a list comprehension to square each odd number in a list. The list is input by a sequence of comma-separated numbers. Suppose the following input is supplied to the program: 1,2,3,4,5,6,7,8,9 Then, t...
true
8e1b506f8b585879cfe91b215aa660c75598e03e
uniquearya70/Python_Practice_Code
/q42_lambda.py
429
4.21875
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Mon Jun 18 00:40:29 2018 @author: arpitansh """ ''' Write a program which can filter even numbers in a list by using filter function. The list is: [1,2,3,4,5,6,7,8,9,10]. ''' ''' li = [1,2,3,4,5,6,7,8,9,10] evenNumber = filter(lambda x: x%2==0, li) print...
true
da2116af1f80d95c24399be57ebf10219e9cba51
uniquearya70/Python_Practice_Code
/q61.py
747
4.15625
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Mon Jun 18 13:54:37 2018 @author: arpitansh """ ''' The Fibonacci Sequence is computed based on the following formula: f(n)=0 if n=0 f(n)=1 if n=1 f(n)=f(n-1)+f(n-2) if n>1 Please write a program using list comprehension to print the Fibonacci Sequence ...
true
fe4c37e3083ffd64145d3177ac205dc94a719164
uniquearya70/Python_Practice_Code
/q40.py
362
4.21875
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Mon Jun 18 00:08:41 2018 @author: arpitansh """ ''' Write a program to generate and print another tuple whose values are even numbers in the given tuple (1,2,3,4,5,6,7,8,9,10). ''' tp=(1,2,3,4,5,6,7,8,9,10) lst=list() for i in tp: if tp[i]%2==0: lst...
true
c1805d558362add81db3e79c33335eb8b537b100
uniquearya70/Python_Practice_Code
/q21_leftrigtupdn.py
1,052
4.375
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Sun Jun 17 13:57:52 2018 @author: arpitansh """ ''' A robot moves in a plane starting from the original point (0,0). The robot can move toward UP, DOWN, LEFT and RIGHT with a given steps. The trace of robot movement is shown as the following: UP 5 DOWN 3...
true
af2e45c06a6b024e20d8da0d8887c45f4cf1aec5
shubhamsahu02/cspp1-assignments
/M22/assignment1/read_input.py
288
4.28125
4
''' Write a python program to read multiple lines of text input and store the input into a string. ''' STR_ING = "" S_1 = int(input()) for i in range(S_1): STR_ING += input() +'\n' i += 1 print(STR_ING) def main(): '''main function''' if __name__ == '__main__': main()
true
359b1f4d28ca3238a2c91373735629256c0bcdc6
kingpipi/rock-paper-scissors
/rps.py
2,751
4.125
4
from random import randint #intro print("Rock...") print("Paper...") print("Scissors...") player_name = str(input("New player, choose your nickname:")).capitalize() #Interact with user comp_react = randint(0,2) if comp_react == 0: greeting = f"Welcome {player_name} to Rock, Paper, Scissors!" elif comp_react == ...
true
03c56238131336fc92e230f52d2e744dc9fb63f3
KiranBahra/PythonWork
/PythonTraining/Practice/6.StringLists.py
484
4.65625
5
#Ask the user for a string and print out whether this string is a palindrome or not. (A palindrome is a string that reads the same forwards and backwards.) varInput = input("Enter Text:") #this reverses the text as a string is a list varReverse=varInput[::-1] print(varReverse) if (varInput== varReverse): print("This ...
true
65ffd09d4d2d792f58d772e43a8253587a66813c
anupamnepal/Programming-for-Everybody--Python-
/3.3.py
621
4.46875
4
#Write a program to prompt the user for a score using raw_input. Print out a letter #grade based on the following table: #Score Grade #>= 0.9 A #>= 0.8 B #>= 0.7 C #>= 0.6 D #< 0.6 F #If the user enters a value out of range, print a suitable error message and exit. #For the test, enter a score of 0.85. score = raw_i...
true
6d9960c8e6239326706f88c882ff21e9d0116b20
ad002/LPTHW
/ex39_Notes.py
1,709
4.3125
4
things = ['a', 'b', 'c', 'd'] print(things[1]) #= b things[1]='z' print(things[1]) #=z print(things) #output:['a', 'z', 'c', 'd'] #lists = you can only use numbers to get items out of a list #e.g. things[1] #dict = lets you use anything, not just numbers. It associates one thing #to another, no matter what it is st...
true
8e94a7d2a71ea6b2de0cb595ff79e2cfb36d5120
jnkg9five/Python_Crash_Course_Work
/Styling_Python_Code.py
1,833
4.375
4
#Python_List_Exercise #PYTHON CRASH COURSE Chapter#3 #When changes will be made to the Python language, they write a Python Enhancement Proposal (PEP) #The oldest PEPs is PEP8 which instructs programmers on how to style their code. #Code will be read more often then its written. #You will write your code and then rea...
true
1f9426a958a249bb01f48035782704ebc906e27e
saisai/tutorial
/python/python_org/library/data_types/itertools/product.py
360
4.1875
4
from itertools import product def cartesian_product(arr1, arr2): # return the list of all the computed tuple # using the product() method return list(product(arr1, arr2)) if __name__ == '__main__': arr1 = [1, 2, 3] arr2 = [5, 6, 7] print(cartesian_product(arr1, arr2)) # https://www.geek...
true
853bb4c8af140d5d7b6ce04b19708b23446c1f9f
saisai/tutorial
/python/techiedelight_com/stack/check-given-expression-balanced-expression-not.py
1,501
4.28125
4
''' https://www.techiedelight.com/check-given-expression-balanced-expression-not/ ''' from collections import deque # function to check if given expression is balanced or not def balance_parenthesis(exp): # base case: length of the expression must be even if len(exp) & 1: return False # take a...
true
16759348c64f450a463cd8c1ad363bd51675995b
saisai/tutorial
/python/python_org/tutorial/introduction.py
1,563
4.15625
4
print("""\ Usage: thingy [OPTIONS] -h Display this usage message -H hostname Hostname to connect to """) print() # 3 times 'un', followed by 'ium' print(3 * 'un' + 'ium') print(40 * '-' + 'end') print() print("Py" "thon") print() text = ('Put several strings within parentheses ' 'to have...
true
49f37fcc2b6474a9e8eb03eb4de38ffb9e0213fb
Issaquah/NUMPY-PYTHON
/EDX_DATA-SCIENCE/NUMPY/Sorting/sorting.py
1,226
4.375
4
import numpy as np random_array = np.random.rand(10) # generate array of random values unsorted_array = np.array(random_array) print("Unsorted array=\n", unsorted_array) print("") sorted_array = np.sort(unsorted_array) # use sort to arrange array elements in ascending order print("Sorted array=\...
true
2185d6e49b8f3909d05e18bbe27fb3e0eea6be58
simrangrover5/Advance_batch2020
/t3.py
362
4.46875
4
import turtle rad = int(input("\n Enter the radius : ")) pen = turtle.Pen() pen.right(90) pen.up() #it will not show anything that will be drawn on the interface pen.forward(50) pen.down() pen.color('red','blue') #color(foreground,background) pen.begin_fill() pen.circle(rad) pen.end_fill() #fill the background col...
true
e5da9a08bf869df6258aa66149a1835d082b78ea
18zgriffin/AFP-Work
/Test Python.py
289
4.1875
4
print("Hello World") name = input("You?: ") age = int(input("Age: ")) print("Hello", name, age) print("Hello " + name + " " + str(age)) #the comma simply outputs the result #the plus tries to output the variables as they are #therefore we must convert the integer to a string outselves
true
5fc0397b2c2934f177f857aca178db27d28e43e4
bedralin/pandas
/Lesson4/slicedice_data.py
1,886
4.3125
4
# Import libraries import pandas as pd import sys print 'Python version ' + sys.version print 'Pandas version: ' + pd.__version__ # Our small data set d = [0,1,2,3,4,5,6,7,8,9] # Create dataframe df = pd.DataFrame(d) print d print df # Lets change the name of the column df.columns = ['Rev'] print "Lets change name ...
true
f0836493a5aabd316d71a60b2478c108aa442040
bedralin/pandas
/Lesson2/create_data.py
1,070
4.28125
4
# Import all libraries needed for the tutorial import pandas as pd from numpy import random import matplotlib.pyplot as plt import sys #only needed to determine Python version number # Enable inline plotting #matplotlib inline print 'Python version ' + sys.version print 'Pandas version ' + pd.__version__ print "\nCr...
true
113f1e6b37f3cdf9e0fee294b24af7b359fac917
abegpatel/LinkedList-Data-Structure-Implementation
/DataStructure/linkedlist/SinglyLinkedlist.py
2,298
4.15625
4
# -*- coding: utf-8 -*- """ Created on Wed Mar 24 20:28:33 2021 @author: Abeg """ #singly Linkedlist Implementation # Create a node class Node: def __init__(self, item): self.item = item self.next = None class LinkedList: def __init__(self): self.head = None #...
true
4c2a3fa7101263b3a820397fe9b54f2c11e956ee
NunoTomas83/Python
/lists_functs.py
494
4.28125
4
""" Script to use several python list functions""" my_list = [5, 2, 9, 1] second_list = list(range(5)) print("Length :", len(my_list)) print("1st Index :", my_list[0]) print("1st 3 Values :", my_list[0:3]) print("9 in List :", 9 in my_list) print("Index for 2 :", my_list.index(2)) print("How Many 2s :", my_list.coun...
true
83825e787a8d45bed32f76904a68446f733dc183
NunoTomas83/Python
/elevevator.py
1,409
4.15625
4
""" Simulates the an elevator """ class Elevator: def __init__(self, bottom, top, current): """Initializes the Elevator instance.""" self.bottom = bottom self.top = top self.current = current pass def __str__(self): return "The elevator is in the {}th floor".for...
true
b493d9f16771f592ca6e7a4e0d41f10e61f056c9
gmkerbler/Learn-Python-the-hard-way-Tutorial
/ex10_1.py
794
4.25
4
print "ASCII backspace, deletes a single space before it" print "** blabla \b blabla" #\b is an ASCII backspace, which deletes a single space before it print "ASCII bell, puts a single space before it" print "** blabla \a blabla" #\a is an ASCII bell, which puts a single space before it print "ASCII formfeed, puts a ...
true
36574929054c1d21c46a45bb0f04d1f1de1ea1bc
nathantau/YouuuuRL
/flask/string_utils/string_utils.py
354
4.21875
4
def get_6_digit_representation(code: str) -> str: ''' Given a code, it fills it up with 0s to make it 6-digits. Parameters: code (str): The code to add 0s to. ''' num_zeroes_needed = 6 - len(code) zeroes_str = '' for _ in range(num_zeroes_needed): zeroes_str = str(0) + zeroes...
true
9fbe9cf530242d1065d9fa5c2e973c99c80fd1c7
venkunikku/exercises_learning
/PycharmProjects/HelloWorldProject/inheritance_polymorphism.py
1,251
4.28125
4
#Inheritance and polymorphism example class Animal: """ Example of poly.""" """More comments about this class.""" def quack(self): return self.strings['quack'] def bark(self): return self.strings['bark'] def talk(self): return self.strings['talk'] def mcv_pattern(self): return self._do...
true
264736c4a5eac5a0d7fc36c8180ec640ccb7a792
andyskan/26415147
/python/array.py
942
4.28125
4
#!/usr/bin/python3 #this is a list, that looks like an array, just say that this is array list = [ 'John', 1998 , 'Cena', 70.2,4020 ] list2 = ['ganteng', 91] print (list) # print complete list print (list[0]) # print element n print (list[1:3]) # print element on a range print (list[2:]) # pr...
true
df2b5d7c681a944cbe9e4998ef149a5a14737c92
onionmccabbage/advPythonMar2021
/my_special.py
609
4.21875
4
# special operators # for example the asterisk can mean mathematical multiply or repeat a string # __mult__ # overriding the __eq__ built-in operator class Word(): def __init__(self, text): self.text = text def __eq__(self, other_word): return self.text.lower() == other_word.text.low...
true
4e9e6fd0802da69251fda87b6e8d87a16ec64370
onionmccabbage/advPythonMar2021
/using_functions.py
933
4.125
4
# args and kwargs allow handling function parameters # we use args for positionl/ordinal arguments and kwargs for keyword arguments def myFn(*args): # *args will make a tuple containing zero or more arguments passed in # one-arg outcome if(len(args)== 1): return 'one argument: {}'.format(args[0]) ...
true
1e6eda8ef2ccf528295680be48a94c61ac7a9184
AmruthaRajendran/Python-Programs
/Counting_valleys.py
1,551
4.59375
5
# HackerRank Problem ''' Gary is an avid hiker. He tracks his hikes meticulously, paying close attention to small details like topography. During his last hike he took exactly n steps. For every step he took, he noted if it was an uphill,U, or a downhill, D step. Gary's hikes start and end at sea level and each step ...
true
701792debbb3529c73a5f97fa159f0cbbd594bc6
AmruthaRajendran/Python-Programs
/Cats_and_Mouse.py
2,111
4.21875
4
# Hackerrank Problem ''' Question: Two cats and a mouse are at various positions on a line. You will be given their starting positions. Your task is to determine which cat will reach the mouse first, assuming the mouse doesn't move and the cats travel at equal speed. If the cats arrive at the same time, the mouse wil...
true
608807c992a9013012f15cc155633e8b5c4914f0
AmruthaRajendran/Python-Programs
/Password_Problem.py
1,549
4.21875
4
# This was asked on the SAP Labs online preplacement test. # Question: you are given two strings from which you have to create a new string which is considered as a password. # The password should be made by combining the letters from each string in alternate fashion. # eg: input: abc, def output: adbecf #Program: de...
true
062f2c51748e40ea410c1c6fd8fbe436fd93d164
vechaithenilon/Python-learnings
/MORNINGPROJECTRemovingVowels.py
409
4.375
4
VOWEL = ('a','e','i','o','u') #Tuple message = input('Enter your message here: ') new_message = '' for letter in message: if letter in VOWEL: print(letter, 'is a vowel') #the latter part is used to print the end of line with a space in between if letter not in VOWEL: # new_mess...
true
f5bfd1699b1d9dba71f41840add964af2209b890
nanodoc2020/Physics
/timeDilator.py
1,249
4.3125
4
# -*- coding: utf-8 -*- """ Created on Tue Dec 31 20:15:48 2019 timeDilator calculates the relativistic time dilation between two reference frames. This is an application of Einstein's special relativity and can be used to compute the time passed in either frame of reference, moving or stationary. No units necessarry f...
true
6b03b117630c9ee39ad2f472b0a530a66c0d0d76
jordanNewberry21/python-practice
/lesson20-string-methods.py
2,534
4.5
4
# string methods return a new value rather than modifying in place # this is because strings as a data type are immutable spam = 'Hello world!' print(spam.upper()) print(spam.lower()) answer = input() if answer == 'yes': print('Playing again.') answer.lower() # lower() and upper() methods return the string a...
true
552940c34e423babaf52f2c62449d29bc3850db8
robwa10/pie
/python/unpacking-function-arguments.py
1,342
4.71875
5
# Unpacking Function Arguments """ ## Function params - args passes in a tuple - *args unpacks the tuple before passing them in """ def multiply(*args): total = 1 for arg in args: total = total * arg return total # print(multiply(1, 3, 5)) """ ## Passing multiple arguments """ def add(x, y...
true
51a029659882714adb03b696cd70e4f38353a1d2
VisheshSingh/Get-to-know-Python
/stringformatting.py
877
4.28125
4
# STRING FORMATTING radius = int(input("Enter the radius: ")) area = 3.142 * radius ** 2 print('The area of circle with radius =', radius,'is', area) num1 = 3.14258973 num2 = 2.95470314 #PREVIOUS METHOD print('num1 is', num1, 'and num2 is', num2) # num1 is 3.14258973 and num2 is 2.95470314 #FORMAT METHOD print('num...
true
433db8f06cf604fd9e95cbce266bd315bbdc7cdf
orikhoxha/itmd-513
/hw4/hw4-1.py
1,607
4.1875
4
''' fn: get_user_input(message) Gets the user input. Parameters ---------- arg1 : string message for the console Returns --------- string returns the input of the user ''' def get_user_input(message): return input(message) ''' fn: validate_input_blank(messag...
true
0f2b90e06bd55e069eb02f6e90e6206c5c43a9af
Acrelion/various-files
/Python Files/ex34.py
648
4.34375
4
# Looping through a list, printing every item + string. # In the last line we print index of the elements and then the element itself. # The element is being selected/called by using its index: # Give me the element from list animals with index i. animals = ['bear', 'python', 'peacock', 'kangaroo', 'whale',...
true
159e9cfd8bc0e50f2cd0a8d699b29ca71c906fa1
emilyvroth/cs1
/homework/homework3/hw3Part3.py
787
4.125
4
name=input("Name of robot => ") print(name) x=int(input("X location => ")) print(x) y=int(input("Y location => ")) print(y) energy=10 command='' while command !='end': print("Robot {} is at ({},{}) with energy: {}".format(name,x,y,energy)) command=input("Enter a command (up/left/right/down/attack/end) => ") print(...
true
ed00f211b21e7c0c4d7f991ef5f07c03f1d8369e
kamran1231/INHERITENCE-1
/inheritance1.py
887
4.125
4
# INHERITANCE METHOD class Mobile: def __init__(self, brand, model, price): self.brand = brand self.model = model self.price = price def display_all(self): return f'MOBILE: {self.brand}, MODEL: {self.model} and PRICE: {self.price}' class Smartphone(Mobile): ...
true
1a901ca15f4d9254980157bbd2a0ef07e8e31d69
SaiPranay-tula/DataStructures
/PY/Da.py
427
4.25
4
#generators def prints(ran): for i in range(1,ran): yield(i*i) a=prints(10) print(next(a)) for i in a: print(i) g=(i for i in range(10)) print(list(g)) #generator dont until they are called #they are effecient than list when dont want to store the values #generator adds functionality to f...
true
457a30dc984dc1f9d23b3af76eab9e79ae8dfe68
kyrienguyen5701/LeetCodeSolutions
/Medium/ZigZagConversion.py
738
4.1875
4
''' The string "PAYPALISHIRING" is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed font for better legibility) P A H N A P L S I I G Y I R And then read line by line: "PAHNAPLSIIGYIR" Write the code that will take a string and make this conve...
true
b860e390ffe1908ea53b1ce7ce41bde96dae4726
kyrienguyen5701/LeetCodeSolutions
/Hard/ShortestPalindrome.py
588
4.21875
4
''' You are given a string s. You can convert s to a palindrome by adding characters in front of it. Return the shortest palindrome you can find by performing this transformation. ''' def shortestPalindrome(s): def isPalindrome(word, i, j): while i < j: if word[i] != word[j]: r...
true
11d1a81c923da796cf20d053f9b3e7c678102d65
kyrienguyen5701/LeetCodeSolutions
/Medium/MergeInBetweenLinkedLists.py
847
4.125
4
''' You are given two linked lists: list1 and list2 of sizes n and m respectively. Remove list1's nodes from the ath node to the bth node, and put list2 in their place. ''' class ListNode: def __init__(self, val=0, next=None): self.val = val self.next = next def mergeInBetween(self, list1, a, b, l...
true
017a603f8be512c3564cb9d72db5e61e0063c7ab
dylcruz/Automate_The_Boring_Stuff
/chapter2/guessTheNumber.py
662
4.15625
4
#This is a guess the number game. The player has 6 tries to guess a random number between 1 and 20 import random import sys number = random.randint(1,20) guess = 0 tries = 0 print('I\'m thinking of a number between 1 and 20.') while guess != number: if tries > 5: print("You lose! My number was " + str(n...
true
13a94688618057631f760685cfb529e03499ed95
akavenus/Calculator
/Calculater.py
1,242
4.25
4
print('Welcome to the vennus calculater') print('Addition is +') print('Subtraction is -') print('Multiplication is *') print('Division is /') xe=input('Enter a operater ') num_1=float(input('Enter your first number: ')) num_2=float(input('Enter your second number: ')) if xe == '+': print('Your answer is...
true
e941ba4379ca69ed4a8a76bc6cbe66f20101e419
abhigun1234/jsstolearnpython
/weekendbatch/sequence/chapter1/operators.py
749
4.21875
4
#aretemetic operators # + - / * ** % # print('enter a no and check the no is even or odd') # a=int(input('enter a no ')) # reminder=a%2 # print("result",reminder) # if(reminder==1): # print('it is a odd no') # else : # print("it is a even no ") # result=a+b # print(result) # result=a*b # print(result) #if '...
true
00b3ff2a9e3e8e13011c9999524622db10856ef9
kidexp/91leetcode
/array_stack_queue/380InsertDeleteGetRandomO(1).py
1,789
4.15625
4
import random class RandomizedSet: def __init__(self): """ Initialize your data structure here. """ self.num_index_dict = {} self.value_list = [] def insert(self, val: int) -> bool: """ Inserts a value to the set. Returns true if the set did not already...
true
360e24dfc79fdf12562cbad8fc8075c087d3ba71
yashasvi-goel/Algorithms-Open-Source
/Sorting/Quick Sort/Python/QuickSort.py
1,202
4.15625
4
#Implementation of QuickSort in Python def partition(arr,low,high): # index of smaller element i = (low-1) # Pivot is the last element in arr pivot = arr[high] print("Pivot is: " + str(pivot)) for j in range(low,high): # Checks if the current element is smaller than or # equal ...
true
864b1739ea38bb0e8578ae5d89844e56f978b19d
mrdebator/171-172
/DrawingARightTriangle.py
925
4.5625
5
# This program will output a right triangle based on user specified height triangle_height and symbol triangle_char. # # (1) The given program outputs a fixed-height triangle using a * character. Modify the given program to output a right triangle that instead uses the user-specified triangle_char character. (1 pt) # #...
true
1edcd3b9b6474bea839131948277d7540f49baaf
mrdebator/171-172
/FileIntro.py
1,116
4.34375
4
# In this lab, you will experiment with opening an reading files. # # A file has been attached to this lab called english.txt. It contains a selection of random english words. There is one word on each line. # # Open the file by using the command # # f = open("english.txt","r") # Ask the user for a single letter. Loop ...
true
a7cd36032fd5b60aa3d163e0d59824addfd84c12
orel1108/hackerrank
/practice/data_structures/linked_lists/reverse_doubly_linked_list/reverse_doubly_linked_list.py
586
4.15625
4
""" Reverse a doubly linked list head could be None as well for empty list Node is defined as class Node(object): def __init__(self, data=None, next_node=None, prev_node = None): self.data = data self.next = next_node self.prev = prev_node return the head node of the updated list """ ...
true