blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
6ef6acc1c6c365f082c551708635ebd79d1f849a
Yobretaw/AlgorithmProblems
/Py_leetcode/032_longestValidParentheses.py
2,145
4.125
4
import sys import math """ Given a string containing just the characters '(' and ')', find the length of the longest valid (well-formed) parentheses substring. For "(()", the longest valid parentheses substring is "()", which has length = 2. Another example is ")()())", where the longest valid parenthese...
true
f21356398a5e226ef2c8aa70ed53a3a34e8f1385
kraftea/python_crash_course
/Chap_7/7-4_pizza_toppings.py
270
4.1875
4
prompt = "List what toppings you want on your pizza: " prompt += "When you're done adding toppings, type 'quit.' " toppings = "" while toppings != 'quit': toppings = input(prompt) if toppings != 'quit': print("I'll add " + toppings + " to your pizza.")
true
441c611474f45cb2a4300f7bae33f8e80087c059
attacker2001/Algorithmic-practice
/Codewars/Number climber.py
1,076
4.40625
4
# coding=utf-8 """ For every positive integer N, there exists a unique sequence starting with 1 and ending with N and such that every number in the sequence is either the double of the preceeding number or the double plus 1. For example, given N = 13, the sequence is [1, 3, 6, 13]. Write a function that returns this ...
true
3a1e27e4bf95753641b933cdee233462c11e11bc
attacker2001/Algorithmic-practice
/Codewars/[5]Sum of Pairs.py
1,998
4.125
4
# coding=utf-8 """ https://www.codewars.com/kata/sum-of-pairs/train/python Sum of Pairs Given a list of integers and a single sum value, return the first two values (parse from the left please) in order of appearance that add up to form the sum. sum_pairs([11, 3, 7, 5], 10) # ^--^ 3 + 7 = ...
true
2df60ffb99ecac399ac959168224e58f96372bb2
attacker2001/Algorithmic-practice
/Codewars/Find the odd int.py
672
4.25
4
# coding=UTF-8 ''' Given an array, find the int that appears an odd number of times. There will always be only one integer that appears an odd number of times. test.describe("Example") test.assert_equals(find_it([20,1,-1,2,-2,3,3,5,5,1,2,4,20,4,-1,-2,5]), 5) 即找出列表中 出现次数为奇数的元素 ''' def find_it(seq): for i in seq: ...
true
356d4accbfb6562795dc85a76257f8e44e1b91e0
attacker2001/Algorithmic-practice
/leetcode/43. Multiply Strings.py
1,309
4.4375
4
#!/usr/bin/env python # -*- coding: utf-8 -*- """ @file: 43. Multiply Strings.py @time: 2019/11/05 Given two non-negative integers num1 and num2 represented as strings, return the product of num1 and num2, also represented as a string. Example 1: Input: num1 = "2", num2 = "3" Output: "6" Example 2: Input: num1...
true
f701c3ec7108cbd939b6440753180c9bdea1e932
attacker2001/Algorithmic-practice
/Codewars/Sexy Primes.py
582
4.28125
4
# coding=UTF-8 ''' Sexy primes are pairs of two primes that are 6 apart. In this kata, your job is to complete the function sexy_prime(x, y) which returns true if x & y are sexy, false otherwise. Examples: sexy_prime(5,11) --> True sexy_prime(61,67) --> True sexy_prime(7,13) --> True sexy_prime(5,7) --> False '''...
true
351027c7112eddd41a40383cf9707aa282daa42c
attacker2001/Algorithmic-practice
/Codewars/[8]Square(n) Sum.py
551
4.15625
4
# coding=utf-8 """ Complete the squareSum method so that it squares each number passed into it and then sums the results together. For example: square_sum([1, 2, 2]) # should return 9 """ def square_sum(numbers): sum_num = 0 for i in numbers: sum_num += i*i return sum_num if __name__ == '__ma...
true
77fa8e4bc4cff43f7b7601d0870b671156d983d2
attacker2001/Algorithmic-practice
/leetcode/70. Climbing Stairs.py
2,959
4.25
4
#!/usr/bin/env python # -*- coding: utf-8 -*- """ @file: 70. Climbing Stairs.py @time: 2019/04/28 You are climbing a stair case. It takes n steps to reach to the top. Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top? Note: Given n will be a positive integer. Examp...
true
77f7a48858b463f00c310fcef4388410c89d3659
ritwiktiwari/AlgorithmsDataStructures
/archive/linked_list/link_list_reversal.py
1,419
4.1875
4
class Node(object): def __init__(self,data): self.data = data self.nextNode = None class LinkedList(object): def __init__(self): self.head = None def insert(self,data): newNode = Node(data) if self.head == None: self.head = newNode else: ...
true
c4a7cf3914e30fe219eebd359c529659dc00060e
facufrau/beginner-projects-solutions
/solutions/rockpaperscissors.py
2,305
4.3125
4
# Beginner project 5. # Rock-paper-scissors game. from random import randint import time print("Rock, paper and scissors game") # Create a moves list and a score. moves = ["R","P","S"] score = {"Player": 0 , "Computer": 0, "Ties": 0} # Function to evaluate winner and add score. def play(player, computer): """ ...
true
eee31bafc8faf23461d003b3123788816619a517
facufrau/beginner-projects-solutions
/solutions/num_generator_functions.py
1,371
4.25
4
# Generates a 5 digit random number until reach a goal number and count the qty of tries. from random import randint from time import sleep def countdown(): ''' Counts down from 3 and prints to the screen ''' for i in [3, 2, 1]: print(f'{i}...') sleep(1) def ask_number(): ''' ...
true
75a32476ded737b570551260a8d9950b90d66faf
facufrau/beginner-projects-solutions
/solutions/countdown.py
2,120
4.34375
4
#Beginner project 22 - Countdown timer. ''' Create a program that allows the user to choose a time and date, and then prints out a message at given intervals (such as every second) that tells the user how much longer there is until the selected time. Subgoals: If the selected time has already passed, have the pro...
true
badd05c91d29aa690abaf492d18d1be96a18bb59
joebrainy/Lab-1-Data
/hello_world.py
256
4.1875
4
name = input("What is your name?") birth_year = int(input("When were you born?")) print(f"Hello, {name}") from datetime import datetime this_year = datetime.now().year age = this_year - (birth_year) print(f"You must be {age}") print(f"goodbye, {name}")
true
9a598ff515f8fdb50499ea91d23778103e917cd5
SrilakshmiMaddali/PycharmProjects
/devops/github/food_question.py
2,829
4.125
4
#!/usr/bin/env python3 # Dictionary to keep track of food likes counter = {} # Open up the favorite foods log and count frequencies using the dictionary with open("favorite_foods.log", "r") as f: for line in f: item = line.strip() if item not in counter: counter[item] = 1 else:...
true
eae2d1d244b241449a9527f223f6f16313a8f534
laodearissaputra/data-structures
/trees/inorderPredecessorAndSuccessor.py
2,099
4.1875
4
# Python program to find predecessor and successor in a BST # A BST node class Node(object): def __init__(self, data): self.data = data self.left = None self.right = None def findPredecessorAndSuccessor(self, data): global predecessor, successor predecessor = None ...
true
88f039201cd0c170d00c82e17f56362d5a598b37
gitmocho/fizzbuzz
/fizzbuzz.py
446
4.46875
4
""" Write a program - prints the numbers from 1 to 100. - But for multiples of three print 'Fizz' instead of the number - and for the multiples of five print Buzz. - numbers which are multiples of both three and five print FizzBuzz. Sample output: """ x = 0 for x in range(0,100): if x % 3 == 0 and x % 5 == 0: ...
true
7a5e0ef2c7f0d7f6227751954f98abaaba7c3219
saedislea/forritun
/sequence.py
604
4.21875
4
#Algorithm #Print the following sequence: 1,2,3,6,11,20,37... #Sum first 3 numbers (1,2,3=6) #Then num1 becomes num2 and continue #Input number from user n = int(input("Enter the length of the sequence: ")) # Do not change this line sum = 0 num1 = 1 num2 = 2 num3 = 3 for i in range(1,n+1): if i == 1: ...
true
fd5d6d42e68cbc29c741a8114e5a6e8262a358b6
MyVeli/ohjelmistotekniikka-harjoitustyo
/src/logic/investment_costs.py
1,122
4.34375
4
class YearlyCosts: """Class used to hold list of costs for a particular year. Used by InvestmentPlan class """ def __init__(self, cost): """constructor for yearly costs Args: cost (tuple): description, value, year """ self.year = cost[2] self.costs = list...
true
3e1c37b7b610a94a31be79ef8ba92e7a7133b7ad
dnbadibanga/Python-Scripts
/Pattern.py
1,585
4.4375
4
## #Assignment 6 - Pattern.py #This program creates a pattern of asterisks dependant on a number given #by the user # #By Divine Ndaya Badibanga - 201765203 # #define the recursive function that will write out a pattern def repeat(a, b): #the base case that ensures the function ends once the pattern ...
true
3bbfc8abdfcd57d2bd42c918710d5d6bd32869ff
dnbadibanga/Python-Scripts
/NLProducts.py
1,589
4.34375
4
## #This program calculates price ish # #Set cost to produce per unit ITEMA_COST = 25 ITEMB_COST = 55 ITEMC_COST = 100 #markup MARKUPTEN = 1.1 MARKUPFIFTEEN = 1.15 #enter data itemA_num = int(input('Please enter the number of ItemA sold: ')) itemB_num = int(input('Please enter the number of ItemB sold...
true
8d479521727e008011feceab37f1d921afa5a17a
108krohan/codor
/hackerrank-python/learn python/standardize-mobile-number-using-decorators - decorators mobile numbers.py
1,535
4.3125
4
"""standardize mobile number using decorators at hackerrank.com """ """ Problem Statement Lets dive into decorators! You are given N mobile numbers. Sort them in ascending order after which print them in standard format. +91 xxxxx xxxxx The given mobile numbers may have +91 or 91 or 0 written before the...
true
8c8b4e17b90c88882d4a986847fa7ede8c6eb906
108krohan/codor
/hackerrank-python/learn python/map-and-lambda-expression - cube a factorial by mapping it.py
1,721
4.3125
4
"""map and lambda expression at hackerrank.com Problem Statement Let's learn some new python concepts! You have to generate a list of the first N fibonacci numbers, 0 being the first number. Then, apply the map function and a lambda expression to cube each fibonacci number and print the list. Input Format ...
true
5486cbf6316d70c3e9097ba40ca562ca0594d70e
108krohan/codor
/hackerrank-python/learn python/regex - regular expressions, phone number checking validity.py
1,655
4.90625
5
# -*- coding: cp1252 -*- """ Problem Statement Let's dive into the interesting topic of regular expressions! You are given some inputs and you are required to check whether they are valid mobile numbers. A valid mobile number is a ten digit number starting with 7, 8 or 9. Input Format The first line con...
true
c9c2dfb39da519c66735e1a52099f508b41bbcc4
108krohan/codor
/hackerrank-python/algorithm/strings/funnyString - reverse string and ord check.py
1,532
4.15625
4
# -*- coding: utf-8 -*- """funny string at hackerrank.com """ """ Problem Statement Suppose you have a string S which has length N and is indexed from 0 to N−1. String R is the reverse of the string S. The string S is funny if the condition |Si−Si−1|=|Ri−Ri−1| is true for every i from 1 to N−1. (Note: Give...
true
bf70462b8a25e767c0336a420dea9b43de95d671
108krohan/codor
/hackerrank-python/learn python/defaultdicts.py
2,305
4.1875
4
# -*- coding: utf-8 -*- """ Problem Statement DefaultDict is a container in the collections class of Python. It is almost the same as the usual dictionary (dict) container but with one difference. The value fields' data-type is specified upon initialization. A basic snippet showing the usage follows: from col...
true
115322603ea25e037e0672875eae1221cced3a67
108krohan/codor
/MIT OCW 6.00.1x python/memoryAndSearchMethodsSorting.py
2,558
4.1875
4
"""Recorded lecture 9. =Selection sort =Merge sort =String Merge sort =Function within function """ ## ####Selection Sort ##def selSort(L): ## ##ascending order ## for i in range (len(L)-1): ## ##Invariant : the list L[:] is sorted ## minIndex = i ## minVal = L[i] ## j = ...
true
efdac446b4f2fc678c0ebdef33124b46fc3acd49
108krohan/codor
/hackerrank-python/learn python/piling up, traversing list from both sides to reach common point.py
2,936
4.15625
4
# -*- coding: utf-8 -*- """piling up at hackerrank.com Problem Statement There is a horizontal row of n cubes. Side length of each cube from left to right is given. You need to create a new vertical pile of cubes. The new pile should be such that if cubei is on cubej then sideLengthj≥sideLengthi. But at a ti...
true
fe4e651dc4bfe552af76448e23cc6ff03861f5c0
LizaChelishev/class2010
/circum_of_a_rectangle.py
282
4.40625
4
def circum_of_a_rectangle(height, width): _circum = height * 2 + width * 2 return _circum width = float(input('Enter the width: ')) height = float(input('Enter the height: ')) circum = circum_of_a_rectangle(height, width) print(f'The circum of the rectangle is {circum}')
true
15204536853cfb1c049bedfe6775bcbff045ba6e
AnushavanAleksanyan/data_science_beyond
/src/second_month/task_2_3.py
1,005
4.125
4
import numpy as np from numpy import newaxis # task_2_3_1 # Write a NumPy program to find maximum and minimum values of an array def min_max(arr): mx = np.max(arr) mn = np.min(arr) return mn, mx # task_2_3_2 # Write a NumPy program to find maximum and minimum values of the secont column of an array def min_max_s...
true
dc8141598f1afe6eec21121c1e1e839f92f388f3
gadamslr/A-Level-Year-1
/GroupU/gtin_Task1.py
1,648
4.125
4
#GTIN challenge # Initialise variables GTINcheck = False gtinList = [] checkDigit = 0 # Checks that the GTIN number entered is valid while GTINcheck == False: gtinNum = input("Please enter a 7 or 8 digit GTIN number!!") try: # Validation check to ensure the value entered is numeric. if...
true
8b7fb945d5a66792d6bc7613114b4a2d6e84f8aa
susanmpu/sph_code
/python-programming/learning_python/date_converter.py
644
4.34375
4
#!/usr/bin/env python def main(): """ Takes a short formatted date and outputs a longer format. """ import sys import string months = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December", ] short = raw_in...
true
30c43127770096540cf10c087a9bc901b6dbb0ce
susanmpu/sph_code
/python-programming/learning_python/ascii_to_plain.py
574
4.15625
4
#!/usr/bin/env python # by Samuel Huckins def main(): """ Print the plain text form of the ASCII codes passed. """ import sys import string print "This program will compute the plain text equivalent of ASCII codes." ascii = raw_input("Enter the ASCII codes: ") print "Here is the plainte...
true
ca292ea53fa1ca32820061f1891393d063e9106b
susanmpu/sph_code
/python-programming/learning_python/hydrocarbon_weight.py
1,060
4.15625
4
#!/usr/bin/env python # by Samuel Huckins def hydrocarbon_weight(hydrogen, carbon, oxygen): """ Calculates the weight of a hydrocarbon atom containing the passed number of atoms present per type. hydrogen -- Number of hydrogen atoms. carbon -- Number of carbon atoms. oxygen -- Number of ox...
true
a292a52811e08fc803e02ce315635fd34ff4c752
susanmpu/sph_code
/python-programming/learning_python/find_distance.py
759
4.21875
4
#!/usr/bin/env python # by Samuel Huckins import math def find_distance(point1, point2): """ Find the distance between the points passed. point1 -- X and Y coordinates of the first point. point2 -- X and Y coordinates of the second point. """ distance = math.sqrt((point2[0] - point1[0]) *...
true
a56363e486fe4bf9d7795a274b220cfbf81e7eab
susanmpu/sph_code
/python-programming/learning_python/bmi_calc.py
644
4.40625
4
#!/usr/bin/env python import math def main(): """ Asks for height and weight, returns BMI and meaning. """ height = raw_input("What is your height (FEET INCHES)? ") height = int(height.split(" ")[0]) * 12 + int(height.split(" ")[1]) weight = int(raw_input("What is your weight (lbs)? ")) w...
true
971fd0f327e8e2243ee8b2d3875c1707c214bffe
ashifujjmanRafi/code-snippets
/python3/data-structures/array/array.py
1,289
4.15625
4
# import array module import array # declare an array arr = array.array('i', [1, 2, 3]) # print the original array using for loop for i in range(3): print(arr[i], end=' ') print('\r') print(arr.itemsize) # return the length of a item in bytes print(arr.typecode) # return the type code print(arr.buffer_info()) ...
true
f6bae3bb7208e83faf06ed7cd445da0c05062aca
ashifujjmanRafi/code-snippets
/python3/learn-python/built-in-functions/complex.py
627
4.3125
4
""" The complex() method returns a complex number when real and imaginary parts are provided, or it converts a string to a complex number. complex([real[, imag]]) * real - real part. If real is omitted, it defaults to 0. * imag - imaginary part. If imag is omitted, it defaults to 0. """ z = co...
true
45a3228f62c9e74a9cce37f4218aa49ab0e0ed3a
awzeus/google_automation_python
/01_Crash_Course_on_Python/Week 2/05_Practice_Quiz_03.py
1,435
4.25
4
# Complete the script by filling in the missing parts. The function receives a name, then returns a greeting based on whether or not that name is "Taylor". def greeting(name): if name == "Taylor": return "Welcome back Taylor!" else: return "Hello there, " + name print(greeting("Taylor")) print(greeting("J...
true
34d00da742e866e6456553c6e58e95cab1c50ff4
suganthi2612/python_tasks
/24_jul/program15.py
785
4.59375
5
from sys import argv #importing argv function from sys module, in order to get the user input script, filename = argv #assigning argv to the var "filename" and initializing script txt = open(filename) #opening "filename" which should be a file from user and storing it in "txt" print "Here's your file %r:" % f...
true
adb489a31b399721a19ed6342a8f21fe6b9e3bad
jmjjeena/python
/advanced_set/code.py
854
4.28125
4
# Create a list, called my_list, with three numbers. The total of the numbers added together should be 100. my_list = [25, 25, 50] r = my_list[0] + my_list[1] + my_list[2] print(r) # Create a tuple, called my_tuple, with a single value in it my_tuple = ('a',) print(len(my_tuple)) ''' --> When generating a one-ele...
true
793a4b1adc1127552dc7d22d1861eef2d1267cb2
o-power/python-intro
/assignment3_task2.py
2,943
4.5625
5
# A dealership stocks cars from different manufacturers. # They have asked you to write a program to manage the different manufacturers they stock. # a. Create an appropriately named list and populate it with at least 10 manufacturers, # making sure you don’t add them in alphabetical order manufacturers = ['Nissa...
true
cc9fead76d2b970d753c926a045822e8931d7a82
o-power/python-intro
/assignment6_task1.py
735
4.59375
5
# 1. Create three lists of car models, each list should only have the models for a particular manufacturer. # For example, you could have one list of Fords, one of Toyotas, and one of Reanults. Give the lists # appropriate names nissan_models = ['Micra','Leaf','Qashqai','Juke'] toyota_models = ['Yaris','Corolla...
true
ba2727bac22e06d7e71e038c3eef748f119d49cf
aceFlexxx/Algorithms
/Algorithms Course/CS3130Pr1_prgm3.py
712
4.3125
4
# An example of a non-recursive function to # calculate the Fibonacci Numbers. import math import time def Fibo(n): """This is a recursive function to calculate the Fibinocci Numbers""" fLess2 = 0; fLess1= 1; fVal = fLess1 + fLess2 for i in range(2, n+1): fVal = fLess1 + fLess2 ...
true
edb4bdab58f7303a69c2d59b0edbb698305b0f83
michdcode/Python_Projects_Book
/Math_Python/chp_one_prac.py
2,036
4.46875
4
from fractions import Fraction def factors(num): """Find the factors of a given number.""" for numbers in range(1, num+1): if num % numbers == 0: print(numbers) your_num = input('Please enter a number: ') your_num = float(your_num) if your_num > 0 & your_num.is_integer(): ...
true
034f54d21418d137bf4337bccff3cced66268f3b
adaxing/leetcode
/design-linked-list.py
2,060
4.15625
4
class Node: def __init__(self, val): self.val = val self.next = None class MyLinkedList: def __init__(self, val, next=None): """ Initialize your data structure here. """ self.val = val self.next = next def get(self, index): """ ...
true
4777821a747d9810b49350bb7caba98301c638ce
Thestor/RanDomRepoSitory
/Practice1.py
409
4.125
4
# -*- coding: utf-8 -*-' """ Name: Exercise 1 @author: Matthew """ print("Enter your height.") try: heightinfeet = eval(input("Feet: ")) heightininches = eval(input("Inches: ")) except: print("That is an invalid input.") else: heightincm = (heightinfeet * 30.48) + (heightininches * 2.5...
true
cbd2a896c08ca4401888a9a8699a3d079f0e27b3
madanaman/leetCodeSolutions
/arrays/inserting_in_arrays/merge_sorted_array.py
1,905
4.125
4
""" Given two sorted integer arrays nums1 and nums2, merge nums2 into nums1 as one sorted array. The number of elements initialized in nums1 and nums2 are m and n respectively. You may assume that nums1 has a size equal to m + n such that it has enough space to hold additional elements from nums2. """ class Solutio...
true
d2f96b6a2763deceefd38207aa08877d9115f7e9
RosemaryDavy/Python-Code-Samples
/leapyear.py
377
4.125
4
#Rosemary Davy #March 4, 2021 #This function takes a es a year as a parameter and #returns True if the year is a leap year, False if it is otherwise year = int(input("Please enter a year:")) def checkLeap(year): leap = False if year % 400 == 0 : leap = True elif year % 4 == 0 and year % 100 != 0...
true
06c2c1377c5cc6c299c6e2def9a703f936c877fa
RosemaryDavy/Python-Code-Samples
/davy_print_new_line.py
362
4.28125
4
#Rosemary Davy #February 13, 2021 #This program prints each number in list #on its own line num = [12, 10 , 32 , 3 , 66 , 17 , 42 , 99 , 20] for x in num: print(x) #and also prints the given numbers along with their square #on a new line squared = [ ] for x in num: sqr = x * x squared.append(sqr) ...
true
21696cbcd0318f7c0aadddd126c04653c36cd6c6
RosemaryDavy/Python-Code-Samples
/mpg.py
518
4.65625
5
string_miles = input("How many miles did you travel?") float_miles = float(string_miles) string_gallons = input("How many gallons of gas did you use?") float_gallons = float(string_gallons) mpg = float_miles // float_gallons print("Your car can travel approximately" , mpg , "miles per gallon of gasoline.") #Rosemary D...
true
d8b33e98ef5d4e8894764376f6254af24529ac63
jdbrowndev/hackerrank
/algorithms/strings/sherlock-and-anagrams/Solution.py
733
4.25
4
""" Author: Jordan Brown Date: 8-13-16 Solves the sherlock and anagrams problem by counting all unordered, anagrammatic pairs in all substrings of each input string. Link to problem: https://www.hackerrank.com/challenges/sherlock-and-anagrams """ def count_anagrammatic_pairs(str): anagrams = {} for start in r...
true
bd60aa0314779cda8ff7ade34189fe1da8356f91
jdbrowndev/hackerrank
/algorithms/strings/funny-string/Solution.py
500
4.125
4
""" Author: Jordan Brown Date: 9-3-16 Solves the funny string problem. Link to problem: https://www.hackerrank.com/challenges/funny-string """ def is_funny_string(s): for i in range(1, len(s)): originalDiff = abs(ord(s[i]) - ord(s[i - 1])) reverseDiff = abs(ord(s[len(s) - i - 1]) - ord(s[len(s) - ...
true
5e75e9bc56b991569a883d04228502e8c81b7cad
JonathanTTSouza/GuessTheNumber
/main.py
1,553
4.21875
4
''' Guess the number program. The objective is to guess a random number from 1 to 100. ''' import random def maingame(): print("Welcome to Guess the number") print("I'm thinking of a random number from 1-100.") print("Try guessing it!\n") random_number = random.randint(1,100) #print(f"(Testing: n...
true
e49f5ca625fc5920b983696915e98294d97e9b5f
rosharma09/PythonFromScratch
/PassList.py
717
4.125
4
# pass list as an arg to a fn # create a function which takes list of numbers as an input and returns the number of even and odd number in the lsit # define a list numberList = [] print(type(numberList)) # ask user to enter the length of the lsit listLength = int(input('Enter the list length: ')) for i in range(0...
true
50ad644f1e4570ba99159ae2da1a983d28c1a8e1
rosharma09/PythonFromScratch
/numpyArray.py
1,064
4.34375
4
from numpy import * # this program is to illusrtate the different ways of creating array using numpy # method 1: using the array function --> we can give the array values and provide the type intArray = array([1,2,3,4] , int) print(intArray) floatArray = array([1,2,3,4] , float) print(floatArray) charArray = arra...
true
aa30ffbd0682e82a4c9a60ddbb45e7d00774b489
6ftunder/open.kattis
/py/Quadrant Selection/quadrant_selection.py
234
4.15625
4
# user inputs two numbers/coordinates (x,y) which tells us which quadrant the point is in x = int(input()) y = int(input()) if x > 0 and y > 0: print(1) elif x < 0 < y: print(2) elif x < 0 > y: print(3) else: print(4)
true
91c86708915f6838f38c0fcd522abe7a49e513df
MateuszSacha/Variables
/first name.py
348
4.4375
4
#Mateusz Sacha #10-09-2014 #exercise 1.1 - Hello World print ("Hello World") #get a name from the user and store it into a variable first_name = input ("please enter you first name") #print out the name stored in the variable first_name print (first_name) #print out the name as part of the message print("hello...
true
3e14d07c77dedaa0ca27bd1f6295d88d4cca9ea9
Maria105/python_lab
/lab7_12.py
319
4.3125
4
#!/usr/bin/env python3 # -*- codding:utf-8 -*- def input_text() -> str: """Input message: """ text = input('enter you text: ') return (text) def remove_spaces(text: str) -> str: """Remove all unnecessary spaces from the string""" return ' '.join (text.split()) print(remove_spaces(input_text()))
true
e266ad7bd05c070b2b7efa411a8005b81e5d6980
eddycaldas/python
/12-Lists-Methods/the-index-method.py
419
4.40625
4
# it returns the first index position of the element in question. the first argument is the element looking for, the second one is the index at where we can to start the search. pizza_toppings = [ 'pineapple', 'pepperoni', 'sausage', 'olive', 'sausage', 'olive' ] print(pizza_toppings.index('pe...
true
dd7369b3182f776031cf5896be7ddbe2b899c21b
eddycaldas/python
/11-Lists-Mutation/the-extend-method.py
459
4.375
4
# extend method adds any amount at the end of a list, it will mutate it. color = ['black', 'red'] print(color) print() color.extend(['blue', 'yellow', 'white']) print(color) print() extra_colors = ['pink', 'green', 'purple'] color.extend(extra_colors) print(color) print() # this methos ( + ) will not mutate them: s...
true
237516a4b16ddf4e5fbc04127e6cfc5b584a5b9d
eddycaldas/python
/08-Control-Flow/the-if-statement.py
1,408
4.59375
5
# # zero or empty string are falsie values, all other numbers are not # if 3: # print('Yes!') # if 0: # print("humm...") # print() # print(bool(0)) # print(bool(-1)) # print(bool("")) # print(bool(" ")) # Define a even_or_odd function that accepts a single integer. # If the integer is even, the function sh...
true
57f0867a7c856dd63d4675f502489a45bbd0e3f9
eddycaldas/python
/08-Control-Flow/nested-if-statements.py
1,746
4.28125
4
ingredient1 = 'pasta' ingredient2 = 'meatballs' if ingredient1 == 'pasta': if ingredient2 == 'meatballs': print('make some pasta with meatballs') else: print('make plain pasta') else: print('I have no recommendation') print() if ingredient1 == 'pasta' and ingredient2 == 'meatballs': p...
true
e74021b6d8ef203951fb3bc32d9e5866b939353e
eddycaldas/python
/07-Strings-Methods/the-find-and-index-methods.py
851
4.3125
4
# browser = "Google Chrome" # print(browser.find("C")) # print(browser.find("Ch")) # print(browser.find("o")) # print('\n') # print(browser.find("R")) # -1 means that the character or string is not # on the original string itself # ----------------------------> # print() # print(browser.find('o', 2)) # print(bro...
true
815153c3097f2cbebd1eb59e6766d227bdcfd70b
Sheikh-A/Python_Lessons
/demonstration_04.py
368
4.34375
4
""" Challenge #4: Create a function that takes length and width and finds the perimeter of a rectangle. Examples: - find_perimeter(6, 7) ➞ 26 - find_perimeter(20, 10) ➞ 60 - find_perimeter(2, 9) ➞ 22 """ def find_perimeter(length, width): return ((2*length) + (2*width)) print(find_perimeter(6,7)) print(find_per...
true
fc5a01f2d8db49961f1aa677509940f1ab87306d
meytala/SheCodes
/lesson4/exercise.py
630
4.15625
4
## functins with STR: #isalnum x='meytal' print(x.isalnum())#checks whether the string consists of alphanumeric characters (no space). y='meytal avgil' print(y.isalnum()) ##there is a space #split print(y.split())#Split the argument into words #replace #returns a copy of the string in which the occurrences of old hav...
true
a3ed486093bd5c6587cc01542c5dae4ae9f46f10
kbrennan711/SoftDesSp15
/toolbox/word_frequency_analysis/frequency.py
1,960
4.46875
4
""" Kelly Brennan Software Design Professors Paul Ruvolo and Ben Hill Spring 2015 Analyzes the word frequencies in a book downloaded from Project Gutenberg """ import string def get_word_list(file_name): """ Reads the specified project Gutenberg book. Header comments, punctuation, and whitespace are stripped ...
true
a72169d59cc2a01d2b1b914e5f9972c05f669510
saijadam/PythonTraining
/Day2_Collections/listdemo.py
352
4.125
4
#List - Mutable list1 = [1,2,3,1,5] #so that I can add, remove, etc list1.append(6) sum=0 for item in list1: sum=sum+item #comment #TO COMMENT MULTIPLE LINES - CTRL+/ print("Sum of list: ",sum) #list duplicate of occurances here 2, only ONE occueanc of 1 print(list1.count(1)) #Data type conversion print("conver...
true
251f24c743bb0d13124d917bac1c6c403ad5ab5d
andrewviren/Udacity_Programming_for_Data_Science
/Part 4/match_flower_name.py
542
4.15625
4
# Write your code here flower_dict = {} def file_to_dict(filename): with open(filename) as f: for line in f: #print(line[3:].rstrip()) flower_dict[line[0]]=line[3:].rstrip() file_to_dict("flowers.txt") # HINT: create a function to ask for user's first and last name user_input = ...
true
a52cb5d452339e373045b1a218c1853bb4ea3e61
DavidNovo/ExplorationsWithPython
/ExploratonsInPythonGUI.py
1,685
4.28125
4
# tkinter and tcl # making windows # lesson 39 of beginning python # lesson 40 making buttons # lesson 41 tkinter event handling from tkinter import * # making a Window class # this class is for creating the window class Window(Frame): # defining the initialize method # this is run first by container def ...
true
dfd43aeb7478e6e4401e7a8a551ef1b2dec5d1ad
1aaronscott/Sprint-Challenge--Graphs
/graph.py
2,273
4.15625
4
""" Simple graph implementation """ from util import Stack, Queue # These may come in handy class Graph: """Represent a graph as a dictionary of rooms.""" def __init__(self): self.rooms = {} def add_room(self, room): """ Add a room to the graph. """ # create a d...
true
8404bf0fe83e56c17a18ad1a9ba0eeec0d7cf3b1
iampaavan/Pure_Python
/Exercise-77.py
307
4.15625
4
import sys """Write a Python program to get the command-line arguments (name of the script, the number of arguments, arguments) passed to a script.""" print(f"This is the path of the script: {sys.argv[0]}") print(f"Number of arguments: {len(sys.argv)}") print(f"List of arguments: {str(sys.argv)}")
true
6d435a78210841598cc4f66f182b0d1cb871793d
iampaavan/Pure_Python
/Exercise-96.py
564
4.1875
4
"""Write a Python program to check if a string is numeric.""" def check_string_numeric(string): """return if string is numeric or not""" try: i = float(string) except (ValueError, TypeError): print(f"String is not numeric") else: print(f"String {i} is numeric") print(f"*************...
true
3cee29d8ee596d508122d7e4d1349b6e226f148e
iampaavan/Pure_Python
/Exercise-95.py
260
4.21875
4
"""Write a Python program to convert a byte string to a list of integers.""" def byte_str_list_integers(string): """return list of integers.""" my_list = list(string) return my_list print(f"List of integers: {byte_str_list_integers(b'Abc')}")
true
1ae7da4a80ff13e6e38a6f1ef9ec8c092208002d
iampaavan/Pure_Python
/Exercise-15.py
494
4.3125
4
from datetime import date """Write a Python program to calculate number of days between two dates.""" first_date = date(2014, 7, 2) last_date = date(2014, 7, 11) delta = last_date - first_date print(f"First Date: {first_date}") print(f"Second Date: {last_date}") print(f'******************************************...
true
9b279f74643634d02aae4969267a3fee44e10a78
iampaavan/Pure_Python
/Exercise-4.py
372
4.3125
4
from math import pi """Write a Python program which accepts the radius of a circle from the user and compute the area.""" def radius(): """Calculate the radius""" r = int(input(f"Enter the radius of the circle:")) Area = pi * (r * r) return f"Area of the circle is: {Area}" c = radius() print(c) pri...
true
c35a1b8ecdab55a9c6a3dcabc2bdbd241a5e93f5
iampaavan/Pure_Python
/Exercise-28.py
291
4.21875
4
"""Write a Python program to concatenate all elements in a list into a string and return it.""" def concatenate(my_list): """Return a string.""" output = '' for i in my_list: string = str(i) output += string return output print(concatenate([1, 2, 3, 4, 5]))
true
d8b11d176fb47a44390c72b979370931cf9f6ce8
mtrunkatova/Engeton-projects
/Project2.py
2,521
4.25
4
def welcoming(): print("WELCOME TO TIC TAC TOE") print("GAME RULES:") print("Each player can place one mark (or stone) per turn on the 3x3 grid") print("The WINNER is who succeeds in placing three of their marks in a") print("* horizontal,\n* vertical or\n* diagonal row\nLet's start the game") def ...
true
e53fe6f2b910c285b7851783b61c4d7939638b71
manoznp/LearnPython-Challenge
/DAY3/list.py
1,519
4.34375
4
#list names = ['raju', 'manoj'] length_names = len(names) print("Length of the array name is {}".format(length_names)) names.append("saroj") length_names = len(names) print("Length of the array name is {}".format(length_names)) print(names) names.insert(1, "sudeep") print("After inserting sudeep at position second:...
true
6db5f977cc64e90e243d62f3b882c7d77371a86f
Williano/Python-Scripts
/turtle_user_shape/turtle_user_shape.py
2,734
4.1875
4
import turtle window = turtle.Screen() window.setup() window.title("Draw User Shape") window.bgcolor("purple") mat = turtle.Turtle() mat.shape("turtle") mat.color("black") mat.pensize(3) mat.speed(12) drawing = True while drawing: mat.penup() SQUARE = 1 TRIANGLE = 2 QUIT = 0 shape_choice = i...
true
830802e627fe7aaed1057d4ed66ccadf532bf357
tanpv/awesome-blockchain
/algorithm_python/move_zeros_to_end.py
378
4.25
4
""" Write an algorithm that takes an array and moves all of the zeros to the end, preserving the order of the other elements. move_zeros([false, 1, 0, 1, 2, 0, 1, 3, "a"]) returns => [false, 1, 1, 2, 1, 3, "a", 0, 0] The time complexity of the below algorithm is O(n). """ input_list = [false, 1, 0, 1, 2, 0...
true
048ab8c2e21afc334d5cd093b47e7633f3530520
ravenusmc/algorithms
/HackerRank/algorithms/diagonal_diff.py
938
4.1875
4
# Given a square matrix, calculate the absolute difference between the sums of its diagonals. # For example, the square matrix arr is shown below: # URL https://www.hackerrank.com/challenges/diagonal-difference/problem?h_r=next-challenge&h_v=zen # Rank: 1,670,172 arr = [ [1, 2, 3], [4, 5, 6], [9, 8, 9] ] # arr = [ #...
true
c4bbc4e04d3ab14ecb92baad254d46959fc4329e
Sandeep0001/PythonTraining
/PythonPractice/SetConcept.py
2,742
4.34375
4
#Set: is not order based #it stores different type of data like list and tuple #it performs different mathematical operations #does not store duplicate elements #define a set: use {} s1 = {100, "Tom", 12.33, True} s2 = {1,1,2,2,3,3,} print(s2) #Output: {1, 2, 3} print(s1) #Output: {True, 1...
true
c4bd3a327087bdc0795e06d4c4125f93ed315255
chaita18/Python
/Programms/check_multiply_by_16.py
233
4.1875
4
#!C:/Users/R4J/AppData/Local/Programs/Python/Python37-32 num = eval(input("Enter number to check if it is multiply by 16 : ")) if (num&15)==0 : print("The number is multiple of 16") else : print("The number is not multiple of 16")
true
bc8069602e13e364e7ad656ed67b04f81f45f9ab
chaita18/Python
/Programms/check_multiple_by_any_number.py
298
4.1875
4
#!C:/Users/R4J/AppData/Local/Programs/Python/Python37-32 num = eval(input("Enter number : ")) multiplier = eval(input("Enter multiplier : ")) if (num&multiplier-1)==0 : print("The number %d is multiple of %d"%(num,multiplier)) else : print("The number %d is not multiple of %d"%(num,multiplier))
true
a20e4cd321b23d2b35abbe8233fca1c1e52cc410
TechnologyTherapist/BasicPython
/02_var_datatype.py
396
4.15625
4
# innilize a value of data types a=10 b='''hi am akash iam good boy''' c=44.4 d=True e=None # Now print the varaible value print(a) print(b) print(c) print(d) print(e) #now using type function to find data type of varaible print(type(a)) print(type(b)) print(type(c)) print(type(d)) print(type(e)) #now i use how to fi...
true
18281b137fad3eae028f4888a19b066627403125
axeMaltesse/Python-related
/Learning-Python/anti_vowel_v2.py
395
4.15625
4
#definition def anti_vowel(text): #value to hold new string b = '' #for loop to chceck single letter for a in range(len(text)): #if the letter is in that string, do nothing; continue if (text[a] in "aeiouAEIOU"): continue #add to the string else: b...
true
0156518036d2d08de0d6a6635c3a9ecf5146bf6d
lovit/text_embedding
/text_embedding/.ipynb_checkpoints/fasttext-checkpoint.py
688
4.125
4
def subword_tokenizer(term, min_n=3, max_n=6): """ :param term: str String to be tokenized :param min_n: int Minimum length of subword. Default is min_n = 3 :param max_n: int Minimum length of subword. Default is max_n = 6 It returns subwords: list of str It cont...
true
af90f9d14f0800526910d3c2c3fbb9356f3f564b
RaphaelPereira88/weather-report
/weather.py
2,445
4.125
4
import requests API_ROOT = 'https://www.metaweather.com' API_LOCATION = '/api/location/search/?query=' API_WEATHER = '/api/location/' # + woeid def fetch_location(query): return requests.get(API_ROOT + API_LOCATION + query).json() # convert data from json text to python dictionary accordint to u...
true
b84ab2f45e8a33db98518c3b888f6447ac46040a
goosegoosegoosegoose/springboard
/python-ds-practice/33_sum_range/sum_range.py
922
4.125
4
def sum_range(nums, start=0, end=None): """Return sum of numbers from start...end. - start: where to start (if not provided, start at list start) - end: where to stop (include this index) (if not provided, go through end) >>> nums = [1, 2, 3, 4] >>> sum_range(nums) 10 >>>...
true
c8eff632a0146b35ed1c97c43501956c63ae8046
goosegoosegoosegoose/springboard
/python-syntax/in_range.py
572
4.34375
4
def in_range(nums, lowest, highest): """Print numbers inside range. - nums: list of numbers - lowest: lowest number to print - highest: highest number to print For example: in_range([10, 20, 30, 40], 15, 30) should print: 20 fits 30 fits """ nums.sort() nums_r...
true
912382a53ecbdf760a14c7b372c14df45d558f42
ly989264/Python_COMP9021
/Week2/lab_1_1_Temperature_conversion_tables.py
418
4.28125
4
''' Prints out a conversion table of temperatures from Celsius to Fahrenheit degrees, the former ranging from 0 to 100 in steps of 10. ''' # Insert your code here start_celsius=0 end_celsius=100 step=10 print('Celsius\tFahrenheit') for item in range(start_celsius,end_celsius+step,step): celsius=item fahrenheit=int(...
true
4ece48f5629219360d3cd195c0242f4e67805104
imscs21/myuniv
/1학기/programming/basic/파이썬/파이썬 과제/11/slidingpuzzle.py
2,053
4.125
4
# Sliding Puzzle import random import math def get_number(size): num = input("Type the number you want to move (Type 0 to quit): ") while not (num.isdigit() and 0 <= int(num) <= size * size - 1): num = input("Type the number you want to move (Type 0 to quit): ") return int(num) def create_board(nu...
true
a41d8b1e58f7c92013a67d53fdf9aee4c169c07d
foqiao/A01027086_1510
/lab_09/factorial.py
1,301
4.15625
4
import time """ timer function store the procedures needed for time consumes during factorial calculations happened on two different methods. """ def timer(func): def wrapper_timer(*args, **kwargs): start_time = time.perf_counter() value = func(*args, **kwargs) end_time = time.perf_counter(...
true
3166baaa4c08d4d7eca67acd85aa03d7dd6b253c
amshekar/python-mania
/day2/Classself.py
812
4.15625
4
students = [] class Student: school_name="UPS" #constructor self is equal to this in other languages def __init__(self,name,student_id=332): self.name=name self.student_id=student_id students.append(self) # constructor to get rid of returning student object memory reference when we prin...
true
427bef40fca68167da9a854640161e0078177702
yung-pietro/learn-python-the-hard-way
/EXERCISES/ex40.py
2,301
4.71875
5
# You can think of a module as a specialized dictionary, where I can store code # and access it with the . operator # Similarly, a Class is a way of taking a grouping of functions and data and place # them in a similar container so as to access with the . (dot) operator # The difference being, a module is used once, ...
true
b62110eca69bd06a29dac605b378d4a26e527f02
0x0584/cp
/nizar-and-grades.py
724
4.125
4
# File: nizar-and-grades.py # Author: Anas # # Created: <2019-07-10 Wed 09:08:32> # Updated: <2019-07-11 Thu 22:01:51> # # Thoughts: I was wrong! the idea is to give a count of how many grades # are between min and max # # D. #247588 def find_best(grades): unique = list(set(sort...
true
44dd93465f283d91d89d3a02b12a0c9dae91bb9f
irrlicht-anders/learning_python
/number_posneg.py
419
4.5625
5
# Program checks wether the number is negative # or not and displays an approbiate message # ------------------------------------------------ # added additional line whicht checks wether the # input is zero OR negative num = input("Please enter a postive or negative number! ") a = int(num) #convert from string to int ...
true
a4ca15cb046c26c2c539eadf741c63aa44eb43c8
rubenhortas/shows_manager
/application/utils/time_handler.py
647
4.375
4
def print_time(seconds): """ __print_time(num_secs) Prints the time taken by the program to complete the moving task. Arguments: seconds: (int) Time taken by the program in seconds.s """ string_time = "" hours = int(seconds / 3600) if hours > 0: seconds = seconds(3...
true
aa72775b408ea78214f4e9f7f3e85c6bde6a397e
bobmitch/pythonrt
/polynomials.py
1,095
4.125
4
# Newton's method for polynomials import copy def poly_diff(poly): """ Differentiate a polynomial. """ newlist = copy.deepcopy(poly) for term in newlist: term[0] *= term[1] term[1] -= 1 return newlist def poly_apply(poly, x): """ Apply a ...
true