blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
0fa5eb00e017567a4be83ed88ffbc2b2bbdd2123
reyllama/leetcode
/Python/#7.py
847
4.15625
4
''' 7. Reverse Integer Given a 32-bit signed integer, reverse digits of an integer. Example 1: Input: 123 Output: 321 Example 2: Input: -123 Output: -321 Example 3: Input: 120 Output: 21 Note: Assume we are dealing with an environment which could only store integers within the 32-bit signed integer range: [−2^3...
true
d7240926fd437fd21e86fe98c928e1946d38cce3
reyllama/leetcode
/Python/#344.py
1,855
4.21875
4
""" 344. Reverse String Write a function that reverses a string. The input string is given as an array of characters char[]. Do not allocate extra space for another array, you must do this by modifying the input array in-place with O(1) extra memory. You may assume all the characters consist of printable ascii char...
true
6996584587d1da1bea89feeac00a77acf8064f01
reyllama/leetcode
/Python/C739.py
1,665
4.1875
4
""" 739. Daily Temperatures Given a list of daily temperatures temperatures, return a list such that, for each day in the input, tells you how many days you would have to wait until a warmer temperature. If there is no future day for which this is possible, put 0 instead. For example, given the list of temperatures t...
true
431b13b9f4000a3db036ff19a64714652560a1c6
HaiyuLYU/UNSW
/COMP9021-Principles-of-Programming/Quizzes/Q6/quiz_6.py
2,948
4.3125
4
# Defines two classes, Point() and Triangle(). # An object for the second class is created by passing named arguments, # point_1, point_2 and point_3, to its constructor. # Such an object can be modified by changing one point, two or three points # thanks to the method change_point_or_points(). # At any stage, the obje...
true
a252aaed19f3ab44a5366ab8022fbfe2787a6987
MattB70/499-Individual-Git-Exercise
/DumbSort.py
1,771
4.15625
4
# Sorting Integers or Strings. # Matthew Borle # September 14, 2021 # Python 2.7.15 while True: input_type = raw_input("Integers or Strings? (Ii/Ss): ") if input_type == "I" or input_type == "i": print "Integers selected" array = raw_input("Input integers seperated by spaces:\n") pri...
true
7057b8a23fbfddadfae7d4e86db3428fae4c405d
yangsg/linux_training_notes
/python3/basic02_syntax/classes/02_a-first-look-at-classes.py
2,324
4.625
5
#// https://docs.python.org/3.6/tutorial/classes.html#a-first-look-at-classes #// 类定义需要先执行才能生效(可以将class 定义放在if 语句块或函数的内部) if True: class ClassInIfBlock(): pass def function(): class ClassInFunction: pass #// 当进入 class definition 时,被当做 local scope的一个新的名字空间(namespace) 就被创建了 #// When a class d...
true
31e193aaaeba31bf82941aa2da1dc1c1c17e58b8
pxue/euler
/problem20.py
2,910
4.1875
4
# Problem20: Factorial digit sum # find sum of factorial of 100! # Python has builtin Math.Factorial function # let's see how that's implemented # From python src code # Divide-and-conquer factorial algorithm # # Based on the formula and psuedo-code provided at: # http://www.luschny.de/math/factorial/binarysplitf...
true
f74dde0261038d46e3ada75c994c31d62ee9dba1
rugbyprof/2143-ObjectOrientedProgramming
/ClassLectures/day01.py
2,090
4.59375
5
import random # simple print! print("hello world") # create a list a = [] # prints the entire list print(a) # adds to the end of the list a.append(3) print(a) # adds to the end of the list a.append(5) print(a) # adds to the end of the list, and python doesn't care # what a list holds. It can a mixture of all ty...
true
165acb2cc72d57f0d8943f97abb0c7ce17f33b42
yangreal1991/my_leetcode_solutions
/0035.search-insert-position/search-insert-position.py
847
4.28125
4
import numpy as np class Solution: def __init__(self): pass def searchInsert(self, nums, target): """Given a sorted array and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in order. Args: nu...
true
d026133e160d8f0b83b5167fb1898c5334147cf4
MattMackreth/BasicsDay1
/02datatypes_strings.py
1,689
4.59375
5
# # Data types # # Computers are stupid # # they don't understand context so we need to be specific with data types # # # We can use type() to check datatypes # # # Strings # # lists of characters bundled together in a specific order # # using index # print('hello') # print(type('hello')) # # # Concatentation of string...
true
701af849fc555f9c802f3d3f60c16569455d8bd6
Vantom16/security_system
/security.py
1,058
4.21875
4
#Creating our Security System # Code output is displayed in command line #First we create a list of known users known_users = ["Alice", "Jane", "David", "Paul", "Eli", "Isme"] while True: print("Hi! My name is Joe") name =input("What is your name?: ").strip().capitalize() #Computer will compare name ...
true
031291a9602fdc584e02649768b0ef0d9fa3d1c4
valievav/Python_programs
/Practice_exercises/training/mini_tasks.py
2,730
4.1875
4
# Related read # https://realpython.com/python-coding-interview-tips/#select-the-right-built-in-function-for-the-job # https://docs.python.org/3/library/functions.html#built-in-functions section_sep = '' # EVEN numbers x = [11,1,3,4,5,6,8,9,10,1,3] even_only = [i for i in x if i %2==0] print(even_only) print(section...
true
9717caa2c2fccc161cd400a18bad6574237374be
valievav/Python_programs
/Practice_exercises/reverse_word_order.py
917
4.375
4
# https://www.practicepython.org/exercise/2014/05/21/15-reverse-word-order.html # Write a program 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 'My name is Michele' -> 'Michele is name My' def reverse_w...
true
70808716d0d3ae632945a34ffc58c57326666ce6
tmetz/ITP195
/notes/ch4.py
2,233
4.1875
4
import math import string #my_utf = ord("h") # Returns integer (ordinal) UTF-8 value of char #my_utf_ch = chr(121) # Returns UTF-8 char #print(my_utf, my_utf_ch) my_str = "This is a test of a string" #print(my_str[:8]) # Print from beginning to 7th char. Does not print the 8th character!!! # Extended slicing: # [sta...
true
28b8a10bc86eb1393dfb88d0d0192c4c4a2a2e18
tmetz/ITP195
/Homework/stack.py
1,332
4.25
4
""" Tammy Metz ITP 195 - Topics In Python HW 4 - due April 9, 2018 Create a python module called "stack" that has methods for popping, pushing, and returning the top of the stack """ class Stack(object): def __init__(self, stack_as_list): self.stack = stack_as_list def is_empty(self): if le...
true
ed02008cb439f9c84cbbc1aa022fa87f9465e1e4
Spookyturbo/PythonCourse
/Week2/Lab3/guessNumber-ariedlinger.py
855
4.28125
4
#Guess My Number #Andrew Riedlinger #January 24th, 2019 # #The computer picks a random number between 1 and 100 #The player tries to guess it and the computer lets #the player know if the guess is too high, too low #or right on the money import random print("\tWelcome to 'Guess My Number'!") print("\nI'm thinking of ...
true
94d88ae01f38050fa8f03842be24da5a3f860ab1
tgoel5884/twoc-python
/Day4/program2.py
542
4.3125
4
a = int(input("Enter the no of tuples you want to add in the list: ")) b = int(input("Enter the no of elements you want to add in each tuple: ")) List = [] for i in range(a): print("Enter the elements in Tuple", i + 1) Tuple = [] for j in range(b): Tuple.append(int(input("Enter the element: "...
true
9cfc335ffe0c53f298a637da72223abb916829c6
Fin-Syn/Python-Beginings
/first_list.py
1,249
4.59375
5
days_of_week = ['Sun', 'Mon', 'Tue', 'Wed', 'Thur', 'Fri', 'Sat'] print (days_of_week [2]) #Changes element in the list days_of_week [0] = 'Sunday' print (days_of_week) #Slices the list, but formats is as stated in the list print (days_of_week [2:5]) #Example nested list, when printing needs to call ...
true
edc76b2b6c2a2926e3a4f9529829661fe5eb2669
Stashare/Bc13_Day2
/missingnumber.py
558
4.21875
4
"""MissingNumber""" def find_missing(a,b): temparr=[] #an array that stores missing numbers temporarily during the loop #and it is assigned to outputarr. outputarr=[0] #output the final result #loop to check whether there is missing numbers for i in b: if i not in a: ...
true
c8b0db36c366681ec0245f0441a2ab8e25d59e82
chelseacx/CP1404
/Practicals/workshop 4/calculating_bmi.py
587
4.15625
4
def get_float_value(variable_name, measurement_unit): while True: try: float_value = float(input("Please enter your {} in {}: ".format(variable_name, measurement_unit))) break except ValueError: print("Invalid value!") return float_value print("Body-mass-i...
true
e8bf766cb61490a70fbc298c790b0aadcaf2b1de
Mrklata/Junior
/tuples.py
766
4.15625
4
def tuple_checker(a, b): unique_a = set(a) - set(b) unique_b = set(b) - set(a) if a == b: return 'tuples are equal' if unique_b != unique_a: return f'tuples are not equal and the unique values are a: {unique_a}, b: {unique_b}' else: return 'tuples are not equal but have t...
true
63ee2a4321f54f09e2c06cccb689b017ad090a6a
MythiliPriyaVL/PySelenium
/venv/ProgramCode/34-ModuleItertools.py
573
4.46875
4
""" Define a function even_or_odd, which takes an integer as input and returns the string even and odd, if the given number is even and odd respectively. Categorise the numbers of list n = [10, 14, 16, 22, 9, 3 , 37] into two groups namely even and odd based on above defined function. Hint : Use groupby method of itert...
true
a81870d539a8fd5de0f7c7514a04bcfd87532f6f
MythiliPriyaVL/PySelenium
/venv/ProgramCode/31.2-TimeDelta.py
1,244
4.28125
4
#Example file for timedelta from datetime import datetime from datetime import date from datetime import time from datetime import timedelta def main(): # basic timedelta print(timedelta(days=365, hours=5, minutes=1)) #Today's date now = datetime.now() print("Today is: ", str(now)) #Today's d...
true
6505d7aa96966839827ac72822be80332f018413
MythiliPriyaVL/PySelenium
/venv/ProgramCode/11-PrimeNumbers.py
668
4.25
4
#5. Print prime numbers below a given number. #Get input from the User and print whether the value is Prime or Not numberInput = int(input("Enter any number, I can print the Prime Numbers below that :")) #Validating the Input value if (numberInput == 1 or numberInput == 2 ): print("There is no Prime Number below "...
true
a6c3a5848f1f16bddcf0f65e0927b6cc7d396eb3
MythiliPriyaVL/PySelenium
/venv/ProgramCode/05-LoginCheck.py
740
4.15625
4
""" Login Testing: 1. User Name and Password are hardcoded in the program 2. User should enter right combination of values to login 3. User can try upto 3 times and the program stops after that. """ #Hardcoded User Name and Password values uN1 = "newUser" uP1 = "09876" #Looping for 3 maximum attempts for x in range(3...
true
1deb4d6cf623e49cff90450de4087c1c5433b18a
demetredevidze/edge-final-project
/final.py
1,377
4.28125
4
# day_1_game.py # [Demetre Devidze] import random rules = "Rules are simple! You get 5 chances to guess a random integer between 0 and 30. " hint1 = "PS, 5 tries is definitely enough! If you play smart you will be able to win the game every single time!" hint2 = "Think about the powers of 2. Two to the power of fiv...
true
26c9f7e383cce71cde211cd35562d951f7c64c54
RAJARANJITH1999/Python-Programs
/even.py
214
4.1875
4
value=int(input("enter the value to check whether even or odd")) if(value%2==0): print(value,"is a even number") else: print(value,"is odd number") print("vaule have been checked successfully")
true
2d2147a5e19328d03bb6105bc77f569881ccfced
RAJARANJITH1999/Python-Programs
/shirt.py
880
4.125
4
white=['M','L'] blue=['M','S'] available=False print("*****search for your color shirt and size it*****") color=input("enter your shirt color") if(color.lower()=='white'): size=input("enter your size") if((size.upper() in white)): print("available") available=True else: print("unavailable"...
true
7346df8393977718803fbe9c33ab377afb56a2c9
wengellen/cs36
/searchRotatedSortedArray.py
554
4.1875
4
# Given an integer array nums sorted in ascending order, and an integer target. # # Suppose that nums is rotated at some pivot unknown to you beforehand (i.e., [0,1,2,4,5,6,7] might become [4,5,6,7,0,1,2]). # # You should search for target in nums and if found return its index, otherwise return -1. # # Example 1: # Inp...
true
0d7662fc3a197bb8d5fb992726c99597bd2a410c
wengellen/cs36
/linkedListPatterns.py
859
4.125
4
class LinkedListNode: def __init__(self, value): self.value = value self.next = None self.prev = None x = LinkedListNode('X') y = LinkedListNode('Y') z = LinkedListNode('Z') x.next = y y.next = z y.prev = x z.prev = y def print_ll_reverse(tail): current = tail while current is n...
true
b743ffa0b4a76bceb5b53afb58b2e3b2106652e9
tsoutonglang/gwc-summer-2017
/your-grave.py
2,059
4.1875
4
start = ''' You wake up strapped to a chair at the bottom of a grave. Your arms are tied behind your back, and your feet are tied to the chair. You look up and see the Riddler standing over you with a shovel in his hand. "You have to play my games to live. It's game over once you get a riddle wrong. Get all three right...
true
1c30b6fff4469000460b9518314899e67004f706
manas-mukherjee/MLTools
/src/tutorials/fluentpython/function_as_objects/TestFunction.py
2,833
4.15625
4
############################################## # Treating a Function Like an Object # ############################################## # Example 5-1 print('\nExample 5-1\n------------\n') def factorial(n): '''Returns n factorial''' return 1 if n<2 else n * factorial(n-1) print(factorial(42)) print(fact...
true
19f26e9acaab20e6ca4c43ab04797cafa9fb6f0f
Sciencethebird/Python
/Numpy/arrange and linspace.py
686
4.125
4
import matplotlib.pyplot as plt import numpy as np import math # arange and linespace both output np array # arange: x1 form [0, 10) increase by 1 x1 = np.arange(0,10,0.1) print(x1) # linespace: x2 belongs to [10, 2] with twenty dots x2 = np.linspace(10,2,50) print('numpy array is converted to a python list \n', l...
true
3ec05fbcb0a83872f6dc2454482e07aca2e52229
zanda8893/Student-Robotics
/.unused/code.py
2,586
4.1875
4
import time import random """ this is a rough first attempt which shouldn't work """ class move(): """ the general movement methods for the robot they are programmed here for easy access and to make it easier when implementing new ideas # TODO: add proper moter commands for starting and stoping to robit ...
true
3b05334d87578f06dbdae53128873bf77f512ef4
ccbrantley/Python_3.30
/Decision Structures and Boolean Logic/Brantley_U3_14.py
645
4.21875
4
weight = 0 height = 0 print('This progam will calculatey your BMI(Body Mass Index).') weight = int(input('Please enter in your weight using a measurement of pounds.')) height = int(input('Please enter in your height using a measurement of inches.')) BMI = weight * 703/height**2 if 18.5 <= BMI <= 25: print('Y...
true
5f5b691d7740a9bb38c7a28cbda880cc6ed2aed6
ccbrantley/Python_3.30
/Repetition Structure/Brantley_U4_8.py
285
4.375
4
number = 0 number_sum = 0 print('Enter positive numbers to sum them together and enter a negative number to stop.') while number >= 0: number = float(input('Enter number: ')) if number >= 0: number_sum += number print('The sum is:', format(number_sum, ',.2f'))
true
449f7ce26696cd4804d5e7796a5d724d9b9c34b8
ashishaaron346/MONTHLY_TASKS_PROJECT
/March_2019_Task2/Beginner_Python_Projects_2/proj13DiceRoll.py
1,520
4.125
4
#!/usr/bin/env python3 # proj13DiceRoll.py - r/BeginnerProjects #13 # https://www.reddit.com/r/beginnerprojects/comments/1j50e7/project_dice_rolling_simulator/ import random, time # Loop until keyboard interrupt while True: try: # Prompt until a positive integer is input for num of sides while True: try: ...
true
72a2dea947e7c91504ad5fa81a035c5c34454128
ashishaaron346/MONTHLY_TASKS_PROJECT
/March_2019_Task1/Beginner_Python_Projects_1/proj02Magic8Ball.py
1,135
4.15625
4
#!/usr/bin/env python3 # proj02Magic8Ball.py - r/BeginnerProjects #2 # https://www.reddit.com/r/beginnerprojects/comments/29aqox/project_magic_8_ball/ import time, random responses = ["Nah.", "Get out of here.", "Could be, who knows man.", "Yes", "Technically your odds aren't zero, but realistically...", "Maybe....
true
04bb9b3d91d0f91b5c9f8b66a9ff301af2983553
daorejuela1/holbertonschool-higher_level_programming
/0x06-python-classes/100-singly_linked_list.py
2,165
4.15625
4
#!/usr/bin/python3 """linked list docstrings. This module demonstrates how to use a linked list with classes. """ class Node(): """This class defines a memory space""" def __init__(self, data, next_node=None): """ corroboares data is int and next node is valid""" if type(data) is not int: ...
true
99b2b7fa1180a5ed800908c4e3e925d19c1f502e
xx-m-h-u-xx/Scientific-Computing-with-AI-TensorFlow-Keras
/GuessNumber.py
562
4.125
4
# Guess the number game. # GuessNumber.py import random num_guesses = 0 user_name = input("Hi: What is your name? ") number = random.randint(1,20) print("Welcome, {}! Guess number between 1 and 20.".format(user_name)) while num_guesses < 6: guess = int(input("Take a guess?")) num_guesses += 1 ...
true
e666d86c38fda89d2434f80db29c44a386020118
fanzou2020/Parsing
/driver.py
1,106
4.25
4
import parser import truth_table inputStr = input('Please enter the proposition:\n') result = parser.parse(inputStr) variables = result["variables"] case = input('1. Given the truth value of variables.\n2. Generate truth table\n') if case == '1': print("The variables are: ", end='') print(variables) s = ...
true
ab534206a4e2293ccf0d1d774aa6d698ddabc870
andersonLoyola/python-repo
/book/exerciseOne.py
634
4.25
4
# Write a program that asks the user to enter a integer and prints two integers, root and pwr, such that 0 < pwr < 6 amd root**pwr is equals to the integer entered by the user number = int(input("Write some number: ")) auxNumber = 1 found = False while auxNumber < number and found == False: auxPower=0 while auxNum...
true
6f1f06ca37ee63633a8b568afd7c15571a019222
marjorienorm/learning_python
/words.py
1,414
4.21875
4
"""Retrieve and print words for a url. usage: python words.py <URL> """ import sys from urllib.request import urlopen def fetch_words(url): """Fetch a list of words form a url. Args: url: The URL of a UTF-8 text document. Returns: A list of strings containing the words from the do...
true
01a55d99f9fbf4b98ec18322393f396480d59f34
Saberg118/CS100
/Tuition_calculator.py
397
4.125
4
# This program will display the projected semester tuition for the next 5 # years if tuition increases by 3% # Initialize tuition = 8000 # Make a table print('Years \t\t Tuition') print('___________________________') #for loop for year in range(1,6): # Calculate tuition tuition *= 1.03 #...
true
404845e4a4a0225a1c712014a3a2730f378e287e
Saberg118/CS100
/budget_calculator_using for loop.py
1,082
4.28125
4
# This program keeps the running total of the expenses of the user # and it will give the feedback wither or not the user stayed on # their proposed budget or if they were over or under it. total = 0.0 # initialize the accumulator # Get the budget amount from the user budget = float(input('Enter your budget ...
true
71b3cd139efaa07ca2bd48ed3e81ffbafb2af00b
Saberg118/CS100
/classroom_percentage.py
858
4.1875
4
# This program calculate the percentage of males and females # in a given class. # Get the number of girl in the class. girls = int(input('How many females are in the class? ')) # Get the number of boys in the class. boys = int(input('How many males are in the class? ')) # Calculate the number of students i...
true
6e11cba06075706d9d8eae9678aaafe941fdb039
cifpfbmoll/practica-3-python-AlfonsLorente
/src/Ex7.py
1,336
4.46875
4
#!/usr/bin/env python3 #encoding: windows-1252 #Pida al usuario tres nmero que sern el da, mes y ao. Comprueba que la fecha introducida es vlida. Por ejemplo: #32/01/2017->Fecha incorrecta #29/02/2017->Fecha incorrecta #30/09/2017->Fecha correcta. import sys if __name__ == "__main__": #declare the variables ...
true
68436256894092a0eae4cb852624edd04e53baa5
avholloway/100DaysOfCode
/day9.py
2,573
4.28125
4
programming_dictionary = { "Bug": "An error in a program that prevents the program from running as expected.", "Function": "A piece of code that you can easily call over and over again." } # 9.1 - grading # ----------------------------------------------------------- def one(): student_scores = { "Harr...
true
794fb4af68bf0683eab6ce717a4de1cf955f007b
russunazar/-.-1-
/number 3.py
459
4.21875
4
x = float(input("перша цифра: ")) y = float(input("друга цифра: ")) operation = input("Operation: ") result = None if operation == "+": result = x + y if operation == "-": result = x - y if operation == "*": result = x * y if operation == "/": result = x / y else:...
true
8e4f94063b10e42d4877fcf11afaaccc00217437
itsmehaanh/nguyenhaanh-c4e34
/Session4/homework/bai4.py
987
4.25
4
print ('''If x = 8, then what is 4(x+3)? 1. 35 2.36 3.40 4.44''') question = { "If x = 8, then what is 4(x+3)?" : { "1" : 35, "2" : 36, "3" : 40, "4" : 44,} } answer = input("Your code:") if answer == "3": print("Bingo!") else: print(":(") print('''Estimate this answer (ex...
true
5df4cabafe46b6606f8712dcd94f62a9bd08c680
hakim-DJZ/HF-Python
/Chapter2/nester/hakim_nester.py
688
4.5
4
"""Example module from chapter 2, Head First Python. The module allows you to print nested lists, by use of recursion. It's named the nester.py module, which provides the print_lol() frunction to print nested lists.""" def print_lol(the_list, indent = False, level=0): """For each item, check if it's a list; if ...
true
b68dbecaada6712ac96438e48a88e462196ceee8
in-tandem/matplotlib_leaning
/simple_graph.py
484
4.125
4
## i am going to plot using simple lists of data ## i am going to label x and y axis ## i am going to add color ## i am adding title to the graph import matplotlib.pyplot as plot print('i am going to draw a simple graph') x_axis = [10, 20, 30, 40, 66, 89] y_axis = [2.2, 1.1, 0, 3, -9, 99] plot.plot(x_axis,y_axis, c...
true
b59d922c989315e331dc682a37a9d48f8bd41ef0
odeyale2016/Pirple_assignment
/card2.py
1,038
4.1875
4
from random import randint, choice def jack_chooses_a_card(suits: dict): """ Program for Card Game """ print(str(randint(1,13)) + " of " + str(choice(suits))) def check_help(): # Instructions for the help multiline_str = """Welcome to Pick a Card Game. To play the game, follow the instructi...
true
801d9ab6b31011ff1783ec489e3d150c5c79f44a
rlowrance/re-local-linear
/x.py
2,216
4.15625
4
'''examples for numpy and pandas''' import numpy as np import pandas as pd # 1D numpy arrays v = np.array([1, 2, 3], dtype=np.float64) # also: np.int64 v.shape # tuple of array dimensions v.ndim # number of dimensions v.size # number of elements for elem in np.nditer(v): # read-only iteration pass for elem...
true
758aea129a19502aeacd16c4a89319a1da897513
jemg2030/Retos-Python-CheckIO
/HOME/EvenTheLast.py
2,110
4.125
4
''' You are given an array of integers. You should find the sum of the integers with even indexes (0th, 2nd, 4th...). Then multiply this summed number and the final element of the array together. Don't forget that the first element has an index of 0. For an empty array, the result will always be 0 (zero). Input: A lis...
true
2614ae144faef13ad3271bf311531cbd671b395e
jemg2030/Retos-Python-CheckIO
/SCIENTIFIC_EXPEDITION/AbsoluteSorting.py
2,639
4.78125
5
''' Let's try some sorting. Here is an array with the specific rules. The array (a list) has various numbers. You should sort it, but sort it by absolute value in ascending order. For example, the sequence (-20, -5, 10, 15) will be sorted like so: (-5, 10, 15, -20). Your function should return the sorted list or tuple...
true
5f47280efff7921b548de8f213f7e6a07b4138b1
jemg2030/Retos-Python-CheckIO
/HOME/BiggerPrice.py
2,824
4.40625
4
''' You have a list with all available products in a store. The data is represented as a list of dicts Your mission here is to find the most expensive products in the list. The number of products we are looking for will be given as the first argument and the list of all products as the second argument. Input: int and...
true
483f162dabdd2310a400cadb2abc8ad26faeac62
Chi10ya/UDEMY_SeleniumWithPython
/Sec8_ClassesObjectOrientedPrg.py
2,934
4.8125
5
""" 8: Classes - Object Oriented Programming 45: Understanding objects / classes 46: Create your own object 47: Create your own methods 48: Inheritance 49: Method Overriding 50: Practice exercise with solution """ # 45: Understanding objects / classes # 46: Create your own object class myCla...
true
4bf52edd8b443fde14901d5522921ac8f599679f
stanisbilly/misc_coding_challenges
/decompress.py
1,981
4.1875
4
''' Decompress a compressed string, formatted as <number>[<string>]. The decompressed string should be <string> written <number> times. Example input: 3[abc]4[ab]c Example output: abcabcabcababababc Number can have more than one digit. For example, 10[a] is allowed, and just means aaaaaaaaaa One repetition can occ...
true
b26f56ad13ac9c603fe51fe969c4ee54b81b4687
bermec/challenges
/challenges_complete/challenge182_easydev10.py
2,146
4.4375
4
''' (Easy): The Column Conundrum Text formatting is big business. Every day we read information in one of several formats. Scientific publications often have their text split into two columns, like this. Websites are often bearing one major column and a sidebar column, such as Reddit itself. Newspapers very often hav...
true
bbc20d6705ef01287e574deca25e2e6c1497b87e
bermec/challenges
/challenge75_easy.py
2,182
4.125
4
''' Everyone on this subreddit is probably somewhat familiar with the C programming language. Today, all of our challenges are C themed! Don't worry, that doesn't mean that you have to solve the challenge in C, you can use whatever language you want. You are going to write a home-work helper tool for high-school stude...
true
f11d708155799e063007143742985ddc376c4d01
AvneetHD/little_projects
/Time Converter.py
524
4.28125
4
def minutes_to_seconds(x): x = int(x) x = x * 60 print('{} seconds.'.format(x)) def hours_to_seconds(x): x = int(x) x = (x * 60) * 60 print('{} seconds'.format(x)) direction = input('Do you want to convert hours to seconds. Y/N.') direction2 = input('Do you want to convert minutes to second...
true
7c7c402f239d4aa58c9f0359fc9e0150d6dd49cd
melbinmathew425/Core_Python
/advpython/oop/quantifiers/rule5.py
213
4.15625
4
import re x="a{1,3}"#its print the group or individualy, when its no of 'a' is in between {1,3} r="aaa abc aaaa cga" matcher=re.finditer(x,r) for match in matcher: print(match.start()) print(match.group())
true
89f0c05070f4b6f6fe4485376461e8b309289a4c
Turjo7/Python-Revision
/car_game.py
688
4.15625
4
command = "" started = False # while command != "quit": while True: command = input("> ").lower() if command == "start": if started: print("The Car Already Started: ") else: started = True print("The Car Started") elif command == "stop": if not ...
true
30cd1ebf47edc12c42c6383e4d84c35326dee8fd
sdmgill/python
/Learning/range_into_list.py
312
4.21875
4
#putting a range into a list print("Here is my range placed into a list:") numbers = list(range(1,6)) print(numbers) #putting a range into a list and grab only even numbers print("\nHere is my even list / range:") even_numbers=list(range(2,11,2)) #start with 2, go to 11(10), increment by 2 print(even_numbers)
true
6afa0ebf1d665a64a0a4a7277b18f1ce442c92cf
sdmgill/python
/Learning/7.1-Input.py
894
4.375
4
message = input("Tell me something and I will repeat it back to you: ") print(message) name = input("Please enter your name: ") print("Hello " + name.title()) # building a prompt over several lines prompt = "This is going to be a very long way of asking " prompt += "you what you name is. So..................." prompt...
true
def46f78814c9ca4e28e153774d8a9d668f78463
fander2468/week2_day2_HW
/lesser_then.py
443
4.34375
4
# Given a list as a parameter,write a function that returns a list of numbers that are less than ten # For example: Say your input parameter to the function is [1,11,14,5,8,9]...Your output should [1,5,8,9] my_list = [1,2,12,14,5,6,77,8,22,3,10,13] def lesser_than_ten(numbers): new_list = [] for number in num...
true
ed8f4819a364d77fdda527f9f6ad69bc45e7b8dd
tyler7771/learning_python
/recursion.py
2,625
4.21875
4
# Write a recursive method, range, that takes a start and an end # and returns an list of all numbers between. If end < start, # you can return the empty list. def range(start, end): if end < start: return [] result = range(start, end - 1) result.insert(len(result), end) return result # print...
true
1df55414bfbee7b20e79850c101f4a18bbdc91b5
abhinavnarra/python
/Python program to remove to every third element until list becomes empty.py
646
4.375
4
# Python program to remove to every third element until list becomes empty def removeThirdNumber(int_list): # list starts with 0 index pos = 3 - 1 index = 0 len_list = (len(int_list)) # breaks out once the list becomes empty while len_list > 0: index = (pos ...
true
018618289d9e3c9d984aef740fa362be4af586c7
abhinavnarra/python
/Demonstrate python program to input ‘n’ employee number and name and to display all employee’s information in ascending order based upon their number - dictionary method.py
716
4.5625
5
#Demonstrate python program to input ‘n’ employee number and name and to display all employee’s information in ascending order based upon their number - dictionary method. dict1={} dict2={} No_of_employees=int(input("Enter No of Employees:"))#enter number of employees to be sorted for i in range(1,No_of_emplo...
true
2f9607ab1c2e61d71cc16ec72e5caaf03fb25de3
szeitlin/interviewprep
/make_anagrams.py
824
4.3125
4
#!/bin/python3 import os # Complete the makeAnagram function below. def make_anagram(a:str, b:str) -> int: """ Count number of characters to delete to make the strings anagrams :param a: a string :param b: another string :return: integer number of characters to delete """ b_list = [y for ...
true
81c57b9e4c681f24c467d8657548fc002739c647
nikointhehood/unix-101
/lesson-1/subject/exercises/exercise-0/biggest.py
820
4.3125
4
#! /usr/bin/python3 import sys # This import allows us to interact with the command line arguments # First, we declare a function which will do the comparison job def biggest(int1, int2): if int1 > int2: print(int1) elif int2 > int1: print(int2) else: print("The integers are equal")...
true
38a378e9ccfc27479b43a229088ff02031a9bad3
bsk17/PYTHONTRAINING1
/databasepack/dbClientdemo.py
2,901
4.4375
4
import sqlite3 # create connection to the db conn = sqlite3.connect("mydb") # for server side programming we have change the connection # line and we have to mention the varchar(size) mycursor = conn.cursor() # function to create the table def createTable(): print("*" * 40) sql = '''create table if not exi...
true
a361f51e6cda567cf1bf3705c2f831bc099e5c50
CCedricYoung/bitesofpy
/263/islands.py
1,293
4.28125
4
def count_islands(grid): """ Input: 2D matrix, each item is [x, y] -> row, col. Output: number of islands, or 0 if found none. Notes: island is denoted by 1, ocean by 0 islands is counted by continuously connected vertically or horizontally by '1's. It's also preferred to check/mark t...
true
be7a281f69933d5a719d3ea23cfa64e2c07786ed
sumitbatwani/python-basics
/lists.py
879
4.25
4
# - List - # names = ["John", "Sarah", "Aman"] # print(names[1:2]) # names[start: exclusion_end] # - Largest number in a list - # numbers = [5, 1, 2, 4, 3] # largest_number = numbers[0] # for item in numbers: # if item > largest_number: # largest_number = item # print(f"largest number = {largest_number}"...
true
bc016336933f66d8ec6af96eb078859b7640ac85
lindaspellman/CSE111
/W10 Handling Exceptions/class_notes.py
821
4.125
4
import math def main(): ## program driver - GOAL: Keep lean ## prompt user for how many circles they have numberOfCircles = int(input("How many circles are we working with? ")) areasList = loopForCircles(numberOfCircles) displayAreas(areasList) ## display each area: separate print statements or a list? def dis...
true
186d3639f0c8109d68ad43f442bc6bc49338550a
Techbanerg/TB-learn-Python
/10_MachineLearning/example_numpy.py
2,359
4.34375
4
# NumPy is the fundamental Python package for scientific computing. It adds the capabilities of N-dimensional arrays, element-by-element operations (broadcasting), core # mathematical operations like linear algebra, and the ability to wrap C/C++/Fortran code.We will cover most of these aspects in this chapter by firs...
true
f944c425973b7e81855743e7804ab96189e84a3a
Techbanerg/TB-learn-Python
/00_Printing/printing.py
1,708
4.34375
4
# This exercise we are going to print single line and multi line comments # The following examples will help you understand the different ways of # printing import pprint from tabulate import tabulate from prettytable import PrettyTable print ("Mary had a little lamb") print ("Its Fleece was white as %s ." % 'sno...
true
b77d9ad34b7ca42a441be75c4ba747a1e68f905a
Techbanerg/TB-learn-Python
/02_DataTypes/List/list_comprehension.py
700
4.34375
4
# This short course breaks down Python list comprehensions for yuo step by step # see how python's comprehensions can be transformed from and to equivalent for loops # so you wil know exactly what's going on behind the scenes # one of the favorite features in Python are list comprehension. # they can seem a bit arcan...
true
9160b2901c50fe7aa9e901598409315daf832b98
sub7ata/Pattern-Programs-in-Python
/pattern12.py
215
4.25
4
""" Example: Enter the number of rows: 5 1 1 2 1 2 3 1 2 3 4 1 2 3 4 5 """ n = int(input("Enter the number of rows: ")) for i in range(1, n + 1): for j in range(1, i + 1): print(j, end=" ") print()
true
3cdfd9358e1fd875787b179dff332289f293304a
ashley-honn/homework2-
/solution1.py
444
4.15625
4
# solutions ##This is for Solution 1 #Titles for cells cell_1 = 'Number' cell_2 = 'Square' cell_3 = 'Cube' space = '20' align = ' ' #This will print titles for all cells print(f'{cell_1 :{align}>{space}}',f'{cell_2 :{align}>{space}}',f'{cell_3 :{align}>{space}}') num = 0 #This will print number, squared, and cube...
true
b34a8ceb62caf8cf858f8cb987890ed60d48fa2f
itchyporcupine/Project-Euler-Solutions
/problems/problem1.py
538
4.28125
4
""" If we list all of the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6, and 9. The sum of these multiples is 23. Find the sum of all the multiples of 3 or 5 below 1000. http://www.projecteuler.net/index.php?section=problems&id=1 """ def problem_1(): print "The sum of all natural numbers...
true
7a8ba86d03fd50adc54e8950c416c4dc466bb251
prepiscak/beatson_rosalind
/id_HAMM/RS/006_Rosalind_HAMM.py
2,367
4.125
4
#!/usr/bin/env python3 ''' Counting Point Mutations Problem Given two strings s and t of equal length, the Hamming distance between s and t, denoted dH(s,t), is the number of corresponding symbols that differ in s and t. Given: Two DNA strings s and t of equal length (not exceeding 1 kbp). Return: The Hamming dista...
true
1f769ec8e3df1f204b67776026c50589b3623163
bhupathirajuravivarma/positive-numbers-in-a-range
/positivenoinrange.py
523
4.3125
4
#positive numbers in lists list1 = [6,-7,5,3,-1] for num in list1: #using membership operator to check if value exists in 'list1'& iterating each element in list. if num>=0: #checking for positive number in list. print(num,end=" ") print("\n") list2=[2,14,-45,3] for num...
true
39169e30f904bb9755256220e758e17e2b2afe67
stoneand2/python-washu-2014
/day2/clock2.py
1,330
4.21875
4
class Clock(): def __init__(self, hours, minutes=00): self.hours = hours # this is an instance variable, able to be accessed anywhere you call self self.minutes = minutes @classmethod #instead of self, the first thing we access is the class itself def at(cls, hours, minutes=00): return cls(hours, minutes...
true
6e948d96919febbb19d304897276e6ab366960d5
ayanakshi/journaldev
/Python-3/basic_examples/float_function.py
617
4.59375
5
# init a string with the value of a number str_to_float = '12.60' # check the type of the variable print('The type of str_to_float is:', type(str_to_float)) # use the float() function str_to_float = float(str_to_float) # now check the type of the variable print('The type of str_to_float is:', type(str_to_float)) print...
true
ecb48a4e1889f6e7a88dfaf1bcea829668c3e6e9
doanthanhnhan/learningPY
/01_fundamentals/04_functions/03_built_in_functions.py
1,051
4.40625
4
# Strings # Search # a_string.find(substring, start, end) random_string = "This is a string" print(random_string.find("is")) # First instance of 'is' occurs at index 2 print(random_string.find("is", 9, 13)) # No instance of 'is' in this range # Replace # a_string.replace(substring_to_be_replace, new_string) a_string...
true
d999f45998e7e623f150f3fcad477524da21ee0a
doanthanhnhan/learningPY
/02_oop/04_polymorphism/06_abstract_base_classes.py
561
4.3125
4
from abc import ABC, abstractmethod class Shape(ABC): # Shape is a child class of ABC @abstractmethod def area(self): pass @abstractmethod def perimeter(self): pass class Square(Shape): def __init__(self, length): self.length = length def area(self): return...
true
e9aba8cf06774f9232d5b242efef69fb799f3e76
doanthanhnhan/learningPY
/01_fundamentals/04_functions/02_function_scope.py
1,561
4.78125
5
# Data Lifecycle # In Python, data created inside the function cannot be used from the outside # unless it is being returned from the function. # Variables in a function are isolated from the rest of the program. When the function ends, # they are released from memory and cannot be recovered. name = "Ned" def func():...
true
6191157eb90cbf6b994c06b80b884695b36e9f01
doanthanhnhan/learningPY
/02_oop/01_classes_and_objects/12_exercise_01.py
490
4.375
4
""" Square Numbers and Return Their Sum Implement a constructor to initialize the values of three properties: x, y, and z. Implement a method, sqSum(), in the Point class which squares x, y, and z and returns their sum. Sample Properties 1, 3, 5 Sample Method Output 35 """ class Point: def __init__(self, x, y, z)...
true
be2d9d9f1ea11a20209c8d2e816452567dd3114b
carolinetm82/MITx-6.00.1x
/Python_week2/week2_pbset2_pb1.py
1,305
4.21875
4
""" Problem 1 - Paying Debt off in a Year Write a program to calculate the credit card balance after one year if a person only pays the minimum monthly payment required by the credit card company each month. The following variables contain values as described below: balance - the outstanding balance on the credit c...
true
69f67048cf25a900a9eb5fa3f444c2c42f0cfb40
sarozzx/Python_practice
/Functions/18.py
205
4.3125
4
# Write a Python program to check whether a given string is number or not # using Lambda. check_number = lambda x:True if x.isnumeric() else False a=str(input("Enter a string ")) print(check_number(a))
true
0743869ff6c47e458db2290981671f555b539794
sarozzx/Python_practice
/Functions/2.py
247
4.125
4
# Write a Python function to sum all the numbers in a list. def sum1(list): return sum(list) list =[] n=int(input("Enter number of items in list")) for i in range(0,n): x=int(input()) list.append(x) print("THe sum is ",sum1(list))
true
971c857b14a11f193b4e814f8844854e587d0b0f
sarozzx/Python_practice
/Data Structures/27.py
430
4.25
4
# Write a Python program to replace the last element in a list with another list. def con_list(list1,list2): list1[-1:]=list2 return list1 list1 =[] n=int(input("Enter number of items in list1")) for i in range(0,n): x=str(input()) list1.append(x) list2 =[] n=int(input("Enter number of items in li...
true
ab919b511392475452595c0610cb72f6ca0525a4
sarozzx/Python_practice
/Functions/9.py
376
4.1875
4
# Write a Python function that takes a number as a parameter and check the # number is prime or not. def prime1(n): if (n==1): return False elif (n==2): return True; else: for x in range(2,n): if(n % x==0): return False return True x=int(input("E...
true
19bcef6d7e895e153eebe00dcd434e88b340058b
sarozzx/Python_practice
/Data Structures/38.py
296
4.21875
4
# Write a Python program to remove a key from a dictionary. dict1 = {} n=int(input("Enter number of items in dictionary")) for i in range(n): x=str(input("key")) y=str(input("value")) dict1[x]=y print(dict1) q=str(input("which key do u wanna remove")) del dict1[q] print(dict1)
true
464c3eecf884c6008379552d1bfe2e151a140b4b
sarozzx/Python_practice
/Functions/5.py
320
4.28125
4
# Write a Python function to calculate the factorial of a number (a non-negative # integer). The function accepts the number as an argument. def facto(x): if(x==0): return 0 if(x==1): return 1 return x*facto(x-1) y=int(input("Enter a number : ")) print("The factorial of ",y,"is",facto(y))
true
1d0d4598b8477da1f94808a2bea06a28e3211a09
sarozzx/Python_practice
/Data Structures/23.py
312
4.28125
4
# Write a Python program to check a list is empty or not. def check_emp(list): if not list: print("it is an empty list") else: print("it is not an empty list") list =[] n=int(input("Enter number of items in list")) for i in range(0,n): x=input() list.append(x) check_emp(list)
true
56e9001a79d3810a3b29fb33e3d37e79d27b7732
starmap0312/refactoring
/dealing_with_generalization/pull_up_constructor_body.py
1,457
4.34375
4
# - if there are identical constructors in subclasses # you can pull up to superclass constructor and call superclass constructor from subclass constructor # - if see common behaviors in normal methods of subclasses, consider to pull them up to superclass # ex. if the common behaviors are in constructors, you need ...
true
fb1b1e73c7d5311e36eb7f1fd8d2cddd9ad9fb7b
starmap0312/refactoring
/simplifying_conditional_expressions/introduce_null_object.py
722
4.15625
4
# - if you have repeated checks for a null value, then replace the null value with a null object # - if one of your conditional cases is a null, use introduce null object # before: use conditionals class Customer(object): # abstract class def getPlan(self): raise NotImplementedError # client has a co...
true