blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
c9dadcd37ac16013e6a9c23aa3afe411bacd400e
jhuang09/GWC-2018
/Data Science/attack.py
2,488
4.34375
4
# This project checks to see if your password is a strong one # It works with longer passwords, but not really short ones. # That's because since each letter is considered a word in the dictionary.txt file, # any password that contains just letters will be considered as a word/not a strong password. # To alleviate ...
true
32c4a398d4cc157611fb6827fce531ecbb82f431
GeraldShin/PythonSandbox
/OnlineCode.py
1,851
4.28125
4
#This will be snippets of useful code you find online that you can copy+paste when needed. #Emoji Package #I don't know when this will ever be helpful, but there is an Emoji package in Python. $ pip install emoji from emoji import emojize print(emojize(":thumbs_up:")) #thumbs up emoji, check notes for more. #List ...
true
9e304793cd98bac00cc967be51c1c3da49dd8639
Isaac-D-Dawson/Homework-Uploads
/PyCheckIO/ReverseEveryAscending.py
2,396
4.46875
4
# Create and return a new iterable that contains the same elements as the argument iterable items, but with the reversed order of the elements inside every maximal strictly ascending sublist. This function should not modify the contents of the original iterable. # Input: Iterable # Output: Iterable # Precondition: I...
true
b440d0252e9ed8a9bc3f84b569a31f819225302a
Isaac-D-Dawson/Homework-Uploads
/PyCheckIO/DateTimeConverter.py
1,685
4.5
4
# Computer date and time format consists only of numbers, for example: 21.05.2018 16:30 # Humans prefer to see something like this: 21 May 2018 year, 16 hours 30 minutes # Your task is simple - convert the input date and time from computer format into a "human" format. # example # Input: Date and time as a string # ...
true
239f81592f5c85411d53ced66e13b7ec94218b97
Isaac-D-Dawson/Homework-Uploads
/PyCheckIO/MedianOfThree.py
1,536
4.375
4
# Given an iterable of ints , create and return a new iterable whose first two elements are the same as in items, after which each element equals the median of the three elements in the original list ending in that position. # Wait...You don't know what the "median" is? Go check out the separate "Median" mission on Ch...
true
f4fc59d24310afd8a4fb778ad743d194cc0c1e2a
Isaac-D-Dawson/Homework-Uploads
/PyCheckIO/MorseDecoder.py
2,122
4.125
4
# Your task is to decrypt the secret message using the Morse code. # The message will consist of words with 3 spaces between them and 1 space between each letter of each word. # If the decrypted text starts with a letter then you'll have to print this letter in uppercase. # example # Input: The secret message. # Out...
true
50deb4603696cf2de54543fdc813df491944525c
BerkeleyPlatte/competitiveCode
/weird_string_case.py
958
4.4375
4
#Write a function toWeirdCase (weirdcase in Ruby) that accepts a string, and returns the same string with all even indexed characters in each word upper cased, and all odd #indexed characters in each word lower cased. The indexing just explained is zero based, so the zero-ith index is even, therefore that character sh...
true
89708757e3ec29b31feef559b24ff8b3a336c6e5
gab-umich/24pts
/fraction.py
1,979
4.1875
4
from math import gcd # START OF CLASS DEFINITION # EVERYTHING IS PUBLIC class Fraction: """A simple class that supports integers and four operations.""" numerator = 1 denominator = 1 # Do not modify the __init__ function at all! def __init__(self, nu, de): """Assign numerator and denominat...
true
1fb18bf77b33d4e911364ff771b8ea1bb11c20cc
Luoxsh6/CMEECourseWork
/Week2/code/tuple.py
980
4.5625
5
#!/usr/bin/env python """Practical of tuple with list comprehension""" __author__ = 'Xiaosheng Luo (xiaosheng.luo18@imperial.ac.uk)' __version__ = '0.0.1' birds = (('Passerculus sandwichensis', 'Savannah sparrow', 18.7), ('Delichon urbica', 'House martin', 19), ('Junco phaeonotus', 'Yellow-eyed junc...
true
8e11531642b2dfb6460f5240499eba2c1fd7e8d9
YuvalSK/curexc
/cod.py
1,872
4.3125
4
import exrates import datetime import sys def inputdate(date_text): '''function that inputs a date, and verified if the date is in a vaild format, else return False ''' try: datetime.datetime.strptime(date_text, '%Y-%m-%d') return True except ValueError: ...
true
1114c211c01850695d172cab82d0d544640e2f91
AdarshRise/Python-Nil-to-Hill
/1. Nil/6. Function.py
1,618
4.53125
5
# Creating Function # function are created using def def fun(): print(" function got created ") def fun2(x): print("value of x is :",x) # a bit complex use of function def fun3(x): x=x*x print("value of x*x is ",x) # above code will execute from here x=2 fun() fun2(x) fun3(x) print(x) # the valu...
true
a9917be09fdd70e78780145231214f1bc833ef95
mpwesthuizen/eng57_python
/dictionairies/dictionairies.py
1,292
4.46875
4
# Dictionairies # definitions # a dictionary is a data structure, like a list, but organised with a key and not indexes # They are organised with key: 'value' pairs # for example 'zebra': "an african wild animal that looks like a horse but has stripes on its body." # this means you can search data using keys, rather ...
true
c0901965ca658c1eb3a7c93624513527f4559564
Mayank-Chandra/LinkedList
/LinkedLIst.py
1,135
4.28125
4
class Node: def __init__(self,data): self.data=data self.next=None class LinkedList: def __init__(self): self.head=None def push(self,new_data): new_node=Node(new_data) new_node.next=self.head self.head=new_node def insertAfter(self,prev_node,new_data): ...
true
461085bffe23b8dd9873de328d4a859beb12e3ab
jcjc2019/edX-MIT6.00.1x-IntroToComputerScience-ProgrammingUsingPython
/Program2-ndigits.py
405
4.125
4
# below is the function to count the number of digits in a number def ndigits(x): # when x is more than 0 if x > 0: #change type to string, count the length of the string return len(str(int(x))) # when x is less than 0 elif x < 0: #get the absolute value, change type to string, a...
true
8952a219e349498121e00fc45c06c53b19e92b65
earl-grey-cucumber/Algorithm
/353-Design-Snake-Game/solution.py
1,815
4.1875
4
class SnakeGame(object): def __init__(self, width,height,food): """ Initialize your data structure here. @param width - screen width @param height - screen height @param food - A list of food positions E.g food = [[1,1], [1,0]] means the first food is positioned at ...
true
0b4692180343e2d59f6eecc315b8886072b07dd9
Laxaria/LearningPyth3
/PracticePython/Fibonacci.py
987
4.5625
5
# Write a program that asks the user how many Fibonnaci numbers to generate and then generates them. # Take this opportunity to think about how you can use functions. Make sure to ask the user to enter the number # of numbers in the sequence to generate. # (Hint: The Fibonnaci seqence is a sequence of numbers where t...
true
6d288b804d2b5cc07008fd53cf4ff7352052e458
MelindaD589/Programming-Foundations-Fundamentals
/practice.py
448
4.125
4
# Chapter 1 print("Hello world!") # Chapter 2 # Exercise 1 name = input("Hi, what's your name? ") age = int(input("How old are you? ")) if (age < 13): print("You're too young to register", name) else: print("Feel free to join", name) # Exercise 2 print("Hello world!") print("Goodbye world!") # Exer...
true
fc7376086c6c59f67ab1009af30a49a5491079f1
debdutgoswami/python-beginners-makaut
/day-6/ascendingdescending.py
344
4.34375
4
dictionary = {"Name": "Debdut","Roll": "114", "Dept.": "CSE"} ascending = dict(sorted(dictionary.items(), key=lambda x: x[1])) descending = dict(sorted(dictionary.items(), key=lambda x: x[1], reverse=True)) print("the dictionary in ascending order of values is",ascending) print("the dictionary in descending order o...
true
9b2e6ada5318d7eecc9797368fa73b53fef11943
MikeWooster/reformat-money
/reformat_money/arguments.py
1,405
4.125
4
class Argument: """Parses a python argument as string. All whitespace before and after the argument text itself is stripped off and saved for later reformatting. """ def __init__(self, original: str): original.lstrip() start = 0 end = len(original) - 1 while orig...
true
8b2aadc3171527ad7c2880ee3d5167cd0542ba85
edu-athensoft/ceit4101python
/stem1400_modules/module_4_function/func1_define/function_3.py
392
4.15625
4
""" function - without returned value - with returned value """ def showmenu(): print("egg") print("chicken") print("fries") print("coke") print("dessert") return "OK" # call it and lost returned value showmenu() print() print(showmenu()) print() # call it and keep returned value isdone = s...
true
7a13ea84858a0824e09630477fe3861eb26571ae
edu-athensoft/ceit4101python
/stem1400_modules/module_12_oop/oop_06_instance/s5_add_attribute/instance_attribute_2.py
593
4.46875
4
""" Adding attributes to an object """ # defining a class class Cat: def __init__(self, name, age): self.name = name self.age = age # self.color does not exist. def sleep(self): print('sleep() is called') def eat(self): print('eat() is called') # def antimeth...
true
420933e86e4ecad7a1108f09fcbf2531af0ee7df
edu-athensoft/ceit4101python
/stem1400_modules/module_6_datatype/m6_6_dictionary/dictionary_func_03_len.py
1,458
4.125
4
# len() # How len() works with tuples, lists and range? testList = [] print(testList, 'length is', len(testList)) testList = [1, 2, 3] print(testList, 'length is', len(testList)) testTuple = (1, 2, 3) print(testTuple, 'length is', len(testTuple)) testRange = range(1, 10) print('Length of', testRange, 'is', len(test...
true
abf7b2cfe1d7d7c171855ca4dad7e57f6fd6943d
edu-athensoft/ceit4101python
/evaluate/evaluate_3_project/python1_beginner/guessing_number/guessing_number_v1.py
1,689
4.25
4
""" Guessing number version 1.0 problems: 1. how to generate a random number/integer within a given range 2. how to validate the number and make it within your upper and lower bound 3. comparing your current number with the answer case #1: too small case #2: too big case #3: bingo 4. max 5 times failed...
true
5378ef0faa41bacd228ee02bc616d4fc74fd8bfb
edu-athensoft/ceit4101python
/stem1400_modules/module_6_datatype/m6_6_dictionary/dictionary_func_04_sorted.py
1,380
4.375
4
# sorted() # sorted(iterable[, key][, reverse]) # sorted() Parameters # sorted() takes two three parameters: # # iterable - sequence (string, tuple, list) or collection (set, dictionary, frozen set) or any iterator # reverse (Optional) - If true, the sorted list is reversed (or sorted in Descending order) # key (Opti...
true
4fbf6cc6d51892c9a80e5d4266be5ad184d5ff30
edu-athensoft/ceit4101python
/stem1400_modules/module_6_datatype/m6_7_array/array_3_search.py
571
4.21875
4
""" Searching element in a Array """ import array # initializing array with array values # initializes array with signed integers arr = array.array('i', [1, 2, 3, 1, 2, 5]) # printing original array print("The new created array is : ", end="") for i in range(0, 6): print(arr[i], end=" ") print("\r") # using in...
true
c1fe6f37a7e4522a78a2e1d2922bdb6102636941
edu-athensoft/ceit4101python
/stem1400_modules/module_10_gui/s04_widgets/s0401_label/label_7_justify.py
1,117
4.1875
4
""" Tkinter place a label widget justify=left|center(default)|right """ from tkinter import * root = Tk() root.title('Python GUI - Label justify') root.geometry("{}x{}+200+240".format(640, 480)) root.configure(bg='#ddddff') # create a label widget label1 = Label(root, text='Tkinter Label 1', hei...
true
845282c41034ea8dd5595f6d9f41bc9dff50bfee
edu-athensoft/ceit4101python
/stem1400_modules/module_9_datetime/s93_strptime/s3_strptime/datetime_17_strptime.py
420
4.1875
4
""" datetime module Python format datetime Python has strftime() and strptime() methods to handle this. The strptime() method creates a datetime object from a given string (representing date and time) """ from datetime import datetime date_string = "21 June, 2018" print("date_string =", date_string) date_object =...
true
7b97eec2bef56c7cdfc4577d5838ba2d7c1cd4b3
edu-athensoft/ceit4101python
/stem1471_projects/p00_file_csv_processor_2/csv_append_row.py
824
4.25
4
""" csv processor append a row In this example, we first define the data that we want to append to the CSV file, which is a list of values representing a new row of data. We then open the CSV file in append mode by specifying 'a' as the file mode. This allows us to append data to the end of the file rather than over...
true
9ba6f0b0303c1287bfc28a289e4afe878b85cd34
edu-athensoft/ceit4101python
/stem1400_modules/module_12_oop/oop_09_inheritance/s10_super/demo1_super_single/super_init_2c.py
736
4.375
4
""" super and init child overrides init() of parent and use its own init() child has its own property: age parent has a property: name child cannot inherit parent's property due to overriding, properties defined in parent do not take effect to child. """ class Parent: def __init__(self, name): print('P...
true
ba671e89c9244cd5969667d0f9aca6bec71a825d
edu-athensoft/ceit4101python
/stem1400_modules/module_12_oop/oop_09_inheritance/s10_super/demo1_super_single/super_init_2e.py
672
4.21875
4
""" super and init child overrides init() of parent and use its own init() child has its own property: age parent has a property: name child inherit parent's property by super(), child init() must accept all parameters the order of parameter matters """ class Parent: def __init__(self, name): print('P...
true
aaba8ca8136fbb564b3c3a6869e57ec0be0b0fbf
edu-athensoft/ceit4101python
/stem1400_modules/module_6_datatype/m6_4_string/string_demo/string_1_capitalize.py
761
4.46875
4
""" string method - capitalize() string.capitalize() return a new string """ # case 1. capitalize a sentence str1 = "pyThOn is AWesome." result = str1.capitalize() print(f"old string: {str1}") print(f"new string: {result}") print() # case 2. capitalize two sentence str1 = "pyThOn is AWesome. pyThOn is AWesome." ...
true
e8beb53f159933978745cec0d453798992e3c514
edu-athensoft/ceit4101python
/stem1400_modules/module_12_oop/oop_11_classmember/s01_class_attribute/demo_4_add_property.py
482
4.25
4
""" adding properties by assignment """ class Tool: count = 0 def __init__(self, name): self.name = name Tool.count += 1 # test tool1 = Tool("hammer") print(f'{tool1.count} tool(s) is(are) created.') print() tool1.count = 99 print(f'The instance tool1 has extra property: count') print(f'{t...
true
c958faae61b8d8a3f1a85cba789bbf87d87a1388
edu-athensoft/ceit4101python
/stem1400_modules/module_6_datatype/m6_7_array/array_2_add_2.py
347
4.34375
4
""" Python array Adding Elements to a Array append() extend() source: """ import array as arr numbers = arr.array('i', [1, 2, 3]) numbers.append(4) print(numbers) # Output: array('i', [1, 2, 3, 4]) # extend() appends iterable to the end of the array numbers.extend([5, 6, 7]) print(numbers) # Output: array('...
true
4a5ca15f00ebf97484032636a9bf7a10458bc914
edu-athensoft/ceit4101python
/stem1400_modules/module_10_gui/s04_widgets/s0401_label/label_1_create.py
342
4.3125
4
""" Tkinter place a label widget Label(parent_object, options,...) using pack() layout ref: #1 """ from tkinter import * root = Tk() root.title('Python GUI - Text Label') root.geometry("{}x{}+200+240".format(640, 480)) # create a label widget label1 = Label(root, text='Tkinter Label') # show on screen label1.pa...
true
4543ea3f1dc6e723d7dfc265b3fe856dc787f186
edu-athensoft/ceit4101python
/stem1400_modules/module_14_regex/s3_re/regex_9_search.py
266
4.1875
4
""" regex """ import re mystr = "Python is fun" pattern = r'\APython' # check if 'Python' is at the beginning match = re.search(pattern, mystr) print(match, type(match)) if match: print("pattern found inside the string") else: print("pattern not found")
true
0d3f250ba8d881ab75e3f043e905ec3425424496
edu-athensoft/ceit4101python
/evaluate/evaluate_2_quiz/stem1401_python1/quiz313/q6.py
1,290
4.4375
4
""" Quiz 313 q6 A computer game company is developing a 3A-level role-playing game. The character you are controlling will receive equipment items of different tiers while adventuring in the big world. The system will display different background and text colors according to the level of the item to distinguish them. ...
true
92d6114c1a38dc82151a67729905a625ef3f18ff
Mart1nDimtrov/Math-Adventures-with-Python
/01. Drawing Polygons with the Turtle Module/triangle.py
373
4.53125
5
# exerCise 1-3: tri anD tri again # Write a triangle() # function that will draw a triangle of a given “side length.” from turtle import * # encapsulate with a function def triangle(sidelength=100): # use a for loop for i in range(3): forward(sidelength) right(120) # set speed and shape shape...
true
e8b911a5f1a2d7b8569d3636cc5bcc2b1d5382a1
BH909303/py4e
/ex6_1.py
490
4.1875
4
''' py4e, Chapter 6, Exercise 1: Write a while loop that starts at the last character in the string and works its way backwards to the first character in the string, printing each letter on a separate line, except backwards. William Kerley, 21.02.20 ''' fruit = 'banana' index = len(fruit)-1 #set...
true
ceedc4cf9059a26d9544f553148abac5a5d39d2a
AccentsAMillion/Python
/Ten Real World Applications/Python Basics/Functions and Conditionals/PrintReturnFunction.py
396
4.15625
4
# -*- coding: utf-8 -*- """ Created on Mon Mar 30 09:28:25 2020 @author: Chris """ #To create functions in python it starts with def function(): # Division (/) Function calculating the sum of myList taking in 3 parameters def mean(myList): print("Function mean started!") the_mean = sum(myList) / len(myList) ...
true
cb12aca17df00ff174aa59c48f720b77c23e9026
andrei-chirilov/ICS3U-assignment-05b-Python
/reverse.py
406
4.1875
4
#!/usr/bin/env python3 # Created by: Andrei Chirilov # Created on: November 2019 # This program reverses a digit import math def main(): number = int(input("Enter a number: ")) result = "" if number == 0: print(0) exit(0) while number != 0: result += str(number % 10) ...
true
9ca29631af7bc11b2128efe122862904346a05ec
oscarmrt/holbertonschool-higher_level_programming
/0x01-python-if_else_loops_functions/8-uppercase.py
241
4.28125
4
#!/usr/bin/python3 def uppercase(str): for characters in str: if ord(characters) >= 97 and ord(characters) <= 122: characters = chr(ord(characters) - 32) print('{:s}'.format(characters), end='') print('')
true
d03cc6651d511fefa6af2adea4aa722df253f99d
gauthamikuravi/Python_challenges
/Leetcode/shift_zeros.py
1,106
4.21875
4
####################################################### #Write a program to do the following:Given an array of random numbers, push all the zeros of a given array to the start of the array. # The order of all other elements should be same. #Example #1: Input: {1, 2, 0, 4, 3, 0, 5, 0} #Output: {0, 0, 0, 1, 2,...
true
53a16f0432aa40c042ddb70f4bfc0b09a97227dc
sk1z0phr3n1k/Projects
/python projects/mbox.py
1,483
4.15625
4
# Author: Mark Griffiths # Course: CSC 121 # Assignment: Lab: Lists (Part 2) # Description: mbox module # The mbox format is a standards-based email file format # where many emails are put in a single file def get_mbox_username(line): """ Get mbox email username Parse username from the start of an email ...
true
320fba2a5627ea67e99b54abfae6315115e5c74b
Jamieleb/python
/challenges/prime_checker.py
685
4.34375
4
import math def is_prime(num): ''' Checks if the number given as an argument is prime. ''' #first checks that the number is not even, 1 or 0 (or negative). if num < 2 or num > 2 and not num % 2: return False #checks if all odd numbers up to the sqrt of num are a factor of num for x in range(3, int(math.sq...
true
80ae08b7bf04d23b557a34f0dcd409c04b7e942a
2ptO/code-garage
/icake/q26.py
541
4.59375
5
# Write a function to reverse a string in-place # Python strings are immutable. So convert string # into list of characters and join them back after # reversing. def reverse_text(text): """ Reverse a string in place """ if not text: raise ValueError("Text is empty or None") start = 0 ...
true
908b37ef23e23156396a33582721faa92f816ddc
Akshaypokley/PYCHAMP
/src/SetConcepts.py
2,816
4.25
4
"""Set A set is a collection which is unordered and unindexed. In Python sets are written with curly brackets.""" setex={'java','python',True,False,45,2.3} print(setex) """Access Items You cannot access items in a set by referring to an index, since sets are unordered the items has no index. But you can loop through ...
true
b7c9deb2e1fd40b3b79343e8afd5f1978ffcb0ae
ayoblvck/Startng-Backend
/Python task 1.py
225
4.5625
5
# a Python program to find the Area of a Circle using its radius import math radius = float(input('Please enter the radius of the circle: ')) area = math.pi * radius * radius print ("Area of the circle is:%.2f= " %area)
true
b6dd55f61795983858f76cbd06978865722c9850
isolis1210/HW2-Python
/calculator.py
1,487
4.5
4
def calculator(): #These lines take inputed values from the user and store them in variables number_1 = float(float(input('Please enter the first number: '))) number_2 = float(float(input('Please enter the second number: '))) operation = input('Please type in the math operation you would like to complet...
true
32a429bae97a0678517dff15dbce80bbd25ee46a
NSNCareers/DataScience
/Dir_OOP/classVariables.py
1,374
4.3125
4
# Class variables are those shared by all instances of a class class Employee: raise_amount = 10.04 gmail = '@gmail.com' yahoo = '@yahoo.com' num_of_employees = 0 def __init__( self, fistName, lastName, gender, pay): self.first = fistName self.last = lastName self.ge...
true
e69539f58ab8f159c826d552d852c08cd79a022f
Developirv/PythonLab1
/exercise-5.py
512
4.25
4
# DELIVERABLE LAB 03/05/2019 5/6 # exercise-05 Fibonacci sequence for first 50 terms # Write the code that: # 1. Calculates and prints the first 50 terms of the fibonacci sequence. f = 1 current = 1 former = 0 for term in range (50): if term == 0: print(f"term: {term} / number: 0") elif term == 1: prin...
true
91bcd6886a825494f0013eb115ee3f8ac5871ec8
LialinMaxim/Toweya
/league_table.py
2,866
4.21875
4
""" The LeagueTable class tracks the score of each player in a league. After each game, the player records their score with the record_result function. The player's rank in the league is calculated using the following logic: * The player with the highest score is ranked first (rank 1). The player with the lowest score...
true
91e32dc173b88a2cbdb441627633957137064961
kunaljha5/python_learn_101
/scripts/pyhton_list_operations_remove_pop_insert_append_sort.py
1,554
4.25
4
# https://www.hackerrank.com/challenges/python-lists/problem #Consider a list (list = []). You can perform the following commands: # insert i e: Insert integer at position. # print: Print the list. # remove e: Delete the first occurrence of integer. # append e: Insert integer at the end of the list. # ...
true
7d180da0bcf7f111d1d306897566ec129cd5ef0e
mebsahle/data-structure-and-algorithms
/sorting-algorithms/pancakeSort.py
882
4.125
4
# Python code of Pancake Sorting Algorithm def maxNum(arr, size): num = 0 for index in range(0, size+1): if arr[index] > arr[num] : num = index return num def flipArr(arr, index): begin = 0 while begin < index : temp = arr[begin] ...
true
0bb65cb9b5d9e6b30d70b2613cc224cb39c24d5e
balanalina/Formal-Languages-and-Compiler-Design
/Scanner/symbol_table/linked_list.py
1,973
4.21875
4
# class for a Node class Node: def __init__(self, val=None): self.val = val # holds the value of the node self.nextNode = None # holds the next node # implementation of a singly linked list class LinkedList: def __init__(self, head=None): self.headNode = head self.size = 0 ...
true
b63fd63b6a381fd59a4e1f0eb1fef04bdc7886d7
HurricaneSKC/Practice
/Ifelseproblem.py
535
4.28125
4
# Basic problem utilising if and elif statements # Take the users age input and determine what level of education the user should be in age = int(input("Enter your age: ")) # Handle under 5's if age < 5: print("Too young for school") # If the age is 5 Go to Kindergarten elif age == 5: print ("Go to Kindergar...
true
56ff2ec0d608fe22ec4c4a8acf6d0f7789e61f91
HurricaneSKC/Practice
/FunctionEquation.py
614
4.1875
4
# Problem 10: Create an equation solver, functions # solve for x # x + 4 = 9 # x will always be the first value recieved and you will only deal with addition # Create a function that takes an input equation as a string to solve for x as above example def string_function(equation): # separate the function using the s...
true
c3bd0685bcceacb2bee2ae1cc40bb24aff0cd71c
benjdj6/Hackerrank
/DataStructures/LinkedList/ReverseDoublyLinkedList.py
533
4.125
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 """ de...
true
d2cb42f27bc8a03906e7f19d28a0bc75467053a3
Harshad06/Python_programs
/py-programs/args-kwargs.py
442
4.28125
4
# args/kwargs allows python functions to accept # arbitary/unspecified amount of arguments & keyword arguments. # Arguments def print_args(*args): print(f"These are my arguments : {args}") print_args([1,2,3],(20,30),{'key': 4}, 'abc') #--------------------------------------------------- # Keyword Arguments def...
true
1b504b774f87f662641549baee8860ea34fd6fa7
Harshad06/Python_programs
/useful-functions/accumulate.py
389
4.1875
4
""" accumulate() function > accumulate() belongs to “itertools” module > accumulate() returns a iterator containing the intermediate results. > The last number of the iterator returned is operation value of the list. """ import itertools import operator n = [1,2,3,5,10] print(list(itertools.accumulate(n, op...
true
e34ed0465a5fd22c905826be81eda95e1bba69d4
Harshad06/Python_programs
/PANDAS/joinsIdenticalData.py
740
4.21875
4
import pandas as pd df1 = pd.DataFrame([1,1], columns=['col_A'] ) #print("DataFrame #1: \n", df1) df2 = pd.DataFrame([1,1,1], columns=['col_A'] ) #print("DataFrame #2: \n", df2) df3 = pd.merge(df1, df2, on='col_A', how='inner') print("DataFrame after inner join: \n", df3) # Output: 2x3 --> 6 times it will be ...
true
6824c7f37caca3e464bfacb3da444a075808cf09
Harshad06/Python_programs
/string programs/longestString.py
454
4.59375
5
# Python3 code to demonstrate working of # Longest String in list # using loop # initialize list test_list = ['gfg', 'is', 'best', 'for', 'geeks'] # printing original list print("The original list : " + str(test_list)) # Longest String in list using loop max_len = -1 for element in test_list: if len(element) > max...
true
4360b4921820bf5519f4a23e9300e51cf5a667d8
Robbie-Wadud/-CS-4200-Project-3
/List Comprehension Finding Jones.py
483
4.21875
4
# -*- coding: utf-8 -*- """ Created on Wed Oct 7 20:22:17 2020 @author: Robbi """ print('Let\'s find the last name "Jones" within a list of tuples') #Creating the list (firstName, lastName) names = [('Robbie', 'Wadud'),('Matt', 'Jones'),('Lebron', 'James'),('Sarah', 'Jones'),('Serena', 'Williams'),('Ashle...
true
fdca2f44051851ad10fb9ac34b4edf16afe46cb7
sharmasourab93/JustPython
/tests/pytest/pytest_101/pytest_calculator_example/calculator.py
1,470
4.3125
4
""" Python: Pytest Pytest 101 Learning pytest with Examples Calculator Class's PyTest File test_calculator.py """ from numbers import Number from sys import exit class CalculatorError(Exception): """An Exception class for calculator.""" class Calculator: """A Terrible Calculator.""...
true
1be1e0530d028553e0099989161dc24ebc3e1d41
sharmasourab93/JustPython
/decorators/decorator_example_4.py
612
4.3125
4
""" Python: Decorator Pattern In Python A Decorator Example 4 Using Decorators with Parameter Source: Geeksforgeeks.org """ def decorator_fun(func): print("Inside Decorator") def inner(*args): print("Inside inner Function") print("Decorated the Function") p...
true
937df73a2265bef32d2ba32ca222c47c8db247b9
sharmasourab93/JustPython
/decorators/decorator_example_10.py
950
4.21875
4
""" Python: Decorator Pattern in Python A Decorator Example 10 Func tools & Wrappers Source: dev.to (https://dev.to/apcelent/python-decorator-tutorial-with-example-529f) """ from functools import wraps def wrapped_decorator(func): """Wrapped Decorator Docstring""" """ f...
true
d5320085808347ab18124a1886072b5b9cfdbe0f
sharmasourab93/JustPython
/oop/oop_iter_vs_next.py
947
4.375
4
""" Python: iter Vs next in Python Class """ class PowTwo: """Class to implement an iterator of powers of two""" def __init__(self, max=0): self.max = max def __iter__(self): self.n = 0 return self def __next__(self): if self.n <= self.max: ...
true
332349a979045aa438f80f293690460e34ba8e19
NicholasDowell/Matrix-Calculator
/Matrix.py
2,856
4.375
4
# This will be the fundamental matrix that is used for Matrix Operations # it stores a 2d grid of values # 11 # To DO: Restrict the methods so that they will not resize the matrix when they shouldnt # CONVENTION is [ROW][COLUMN] BE CAREFUL class Matrix: def __init__(self, rows, columns): self._d...
true
971383f0baa1427023b3884f19d11c9d1f590055
AGKirby/InClassGit
/calc.py
1,014
4.1875
4
def calc(): # get user input try: num1 = int(input("Please enter the first number: ")) # get a number from the user num2 = int(input("Please enter the second number: ")) # get a number from the user except: # if the user did not enter an integer print("Invalid input: integer expecte...
true
2a09f466b0eb647e577bf0835a4d55e4cbae1792
iambillal/inf1340_2015_asst1
/exercise2.py
1,212
4.46875
4
def name_that_shape(): """ For a given number of sides in a regular polygon, returns the shape name Inputs: user input 3-10 Expected Outputs: triangle, quadrilateral, pentagon, hexagon, heptagon, octagon, nonagon, decagon. Errors: 0,1,2, any number greater than 10 and any other string """ ...
true
3674c62c670327d324a08a2bb13a6cc111b9b973
mischelay2001/WTCIS115
/PythonProjects/CIS115PythonProjects/Lab4Problem4.py
1,143
4.34375
4
__author__ = 'Michele' #How to test either a string or numeric #Initial age question and valid entry test age = int(input('Enter the child\'s age: ')) BooleanValidAge = age <= 200 #Is age entry valid while BooleanValidAge == False: print('Invalid entry. Please re-enter a valid age for the child.') ag...
true
2c330237b90116e7f55075a360f4290fe334d533
mischelay2001/WTCIS115
/PythonProjects/CIS115PythonProjects/Lab9Problem3.py
2,927
4.375
4
__author__ = 'Michele Johnson' # Write a program to play the rock-paper-scissors game. # A single player is playing against the computer. # In the main function, ask the user to choose rock, paper or scissors. # Then randomly pick a choice for the computer. # Pass the choices of the player and the computer to ...
true
ba9e9753af0ce41ee2b220db1dc202677a8d73e7
mischelay2001/WTCIS115
/PythonProjects/CIS115PythonProjects/Lab5Problem1.py
1,570
4.25
4
__author__ = 'Michele' print('It is time to select your health plan for the year.') print('You will need to select from the table below:') print('') print('Health Plan Code Coverage Premium') print('E Employee Only $40') print('S ...
true
c3bec77407894ad0425a6c44b57733ff67beb1d7
EtienneBrJ/holbertonschool-higher_level_programming
/0x0C-python-almost_a_circle/models/square.py
2,210
4.21875
4
#!/usr/bin/python3 """ Module Square """ from models.rectangle import Rectangle class Square(Rectangle): """ Square class inherits from Rectangle """ def __init__(self, size, x=0, y=0, id=None): """ Initialize an instance square from the class Rectangle. """ super().__init__(size, ...
true
366b54996d3152ac7bee13e218f167480699acd8
rutujak24/crioTryout
/swapCase.py
707
4.4375
4
You are given a string and your task is to swap cases. In other words, convert all lowercase letters to uppercase letters and vice versa. '''For Example: Www.HackerRank.com → wWW.hACKERrANK.COM Pythonist 2 → pYTHONIST 2 Input Format A single line containing a string . Constraints Output Format Print the modifie...
true
b585acc6820a2a013d1dacf883fc961d618f78a3
mlarva/projecteuler
/Project1.py
743
4.1875
4
#If we list all 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. def multipleFinder(min, max, *multiples): multiplesSet = set() if min >= max: print("Minimum is not smaller than ma...
true
b1953a6b8652ea8744c6ca9c935a7ec9d04ac4b6
MikeCullimore/project-euler
/project_euler_problem_0001.py
2,131
4.3125
4
""" project_euler_problem_0001.py Worked solution to problem 1 from Project Euler: https://projecteuler.net/problem=1 Problem title: Multiples of 3 and 5 Problem: if we list all 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...
true
256b3cf6e6919388e85f3e16fd025c4fc1c3b688
suspectpart/misc
/cellular_automaton/cellular_automaton.py
1,787
4.28125
4
#!/usr/bin/python ''' Implementation of the Elementary Cellular Automaton For an explanation of the Elementary Cellular Automaton, read here: http://mathworld.wolfram.com/ElementaryCellularAutomaton.html The script takes three parameters: - A generation zero as a starting pattern, e.g. 1 or 101 or 1110111 - A rul...
true
86cf4cb652c0c62011f157bfd98259d7a092d005
anaruzz/holbertonschool-machine_learning
/math/0x06-multivariate_prob/0-mean_cov.py
564
4.125
4
#!/usr/bin/env python3 """ A function that calculates the mean and covariance of a data set """ import numpy as np def mean_cov(X): """ Returns mean of the data set and covariance matrix of the data set """ if type(X) is not np.ndarray or len(X.shape) != 2: raise TypeError("X must be a 2D ...
true
3a904d372a32c4d10dbf04e2e0f8653bf6c0d995
anaruzz/holbertonschool-machine_learning
/math/0x00-linear_algebra/3-flip_me_over.py
398
4.15625
4
#!/usr/bin/env python3 """ Script that returns the transpose of a 2D matrix """ def matrix_transpose(matrix): """ function that returns the transpose of a 2D matrix, """ i = 0 new = [[0 for i in range(len(matrix))] for j in range(len(matrix[i]))] for i in range(len(matrix)): for j ...
true
5ebd7f954d1ebf345d87d7cb8afa11bfbb9846a8
whatarthurcodes/Swedish-Test
/swedishtest.py
1,843
4.125
4
import sys import random import csv def swedishtest(): word_bank = select_module() lang = choose_lang() questions(word_bank, lang) def select_module(): file_found = False while file_found is False: try: module_choice = raw_input('Enter the file name. ex. module1.csv \n') module = open(module_choi...
true
28a5ceae1d0b29e00c0a7e657c5ea9f3ce3ab08f
mlawan/lpthw
/ex30/ex30.py
518
4.15625
4
people = 30 cars = 40 trucks = 40 if cars > people or trucks < cars: print("We should take the cars") elif cars< people: print("We should not take the cars") else: print(" We cant decide.") if trucks > cars and cars == trucks: print("Thats too much of trucks") elif trucks <cars: print("Maybe we c...
true
0a3c8d459722962a4cf49d524456b76d2069fc9a
python4kidsproblems/Operators
/comparison_operators.py
1,266
4.28125
4
# Comarison Operators Practice Problems # How to use this file: # Copy this to your python (.py) file, and write your code in the given space ################################### Q1 ################################### # Write a program that asks the user, # # "Are you older th...
true
fc09bc969303a4bddf367fc3748ffb53e20e7ba0
rsurpur20/ComputerScienceHonors
/Classwork/convertor.py
1,114
4.25
4
# convert dollars to other currencies import math import random # # dollars=float(input("Dollars to convert: \n $")) #gets the input of how many dollars, the user wants to convert # # yen=dollars*111.47 #the conversion # euro=dollars*.86 # peso=dollars*37.9 # yuan=dollars*6.87 # # print("$"+str(dollars) + " in yen is"...
true
111c5346ca6f32e8f25608a1d2cf2ea143056ed6
rsurpur20/ComputerScienceHonors
/minesweeper/minesweepergame.py
2,394
4.25
4
# https://snakify.org/en/lessons/two_dimensional_lists_arrays/ #Daniel helped me,and I understand import random widthinput=int(input("width?\n"))+2 #number or colomns heightinput=int(input("height ?\n"))+2 #number of rows bombsinput=int(input("number of bombs?\n"))#number of bombs width=[] height=[] # j=[] # # for x in...
true
bac4234eb3635e084517cab020e5b8761e77967f
joelstanner/codeeval
/python_solutions/HAPPY_NUMBERS/happy_numbers.py
1,485
4.3125
4
""" A happy number is defined by the following process. Starting with any positive integer, replace the number by the sum of the squares of its digits, and repeat the process until the number equals 1 (where it will stay), or it loops endlessly in a cycle which does not include 1. Those numbers for which this process e...
true
9668ba9aad876675efe26dc644d08c3f8cb049a1
joelstanner/codeeval
/python_solutions/NUMBER_PAIRS/NUMBER_PAIRS.py
2,563
4.3125
4
""" You are given a sorted array of positive integers and a number 'X'. Print out all pairs of numbers whose sum is equal to X. Print out only unique pairs and the pairs should be in ascending order INPUT SAMPLE: Your program should accept as its first argument a filename. This file will contain a comma separated lis...
true
a73717e0842d17d44f275aeafba71950e88e5b55
joelstanner/codeeval
/python_solutions/PENULTIMATE_WORD/PENULTIMATE_WORD.py
583
4.4375
4
""" Write a program which finds the next-to-last word in a string. INPUT SAMPLE: Your program should accept as its first argument a path to a filename. Input example is the following: some line with text another line Each line has more than one word. OUTPUT SAMPLE: Print the next-to-last word in the following way...
true
0dc79dcc5c3b026ad10e1328ed2ef84a12514fb1
joelstanner/codeeval
/python_solutions/UNIQUE_ELEMENTS/unique_elements.py
809
4.4375
4
""" You are given a sorted list of numbers with duplicates. Print out the sorted list with duplicates removed. INPUT SAMPLE: File containing a list of sorted integers, comma delimited, one per line. E.g. 1,1,1,2,2,3,3,4,4 2,3,4,5,5 OUTPUT SAMPLE: Print out the sorted list with duplicates removed, one per line. E.g...
true
3b9c14de993878342e89d659c501c39b27078042
joelstanner/codeeval
/python_solutions/SIMPLE_SORTING/SIMPLE_SORTING.py
873
4.53125
5
""" Write a program which sorts numbers. INPUT SAMPLE: Your program should accept as its first argument a path to a filename. Input example is the following 70.920 -38.797 14.354 99.323 90.374 7.581 -37.507 -3.263 40.079 27.999 65.213 -55.552 OUTPUT SAMPLE: Print sorted numbers in the following way. Please note, t...
true
66a16d29f30d44d93ca5f219d6d51752633364e2
jDavidZapata/Algorithms
/AlgorithmsInPython/stack.py
329
4.125
4
# Stack implementation in Python stack = [] # Add elements into stack stack.append('a') stack.append('b') stack.append('c') print('Stack') print(stack) # Popping elements from stack print('\nAfter popping an element from the stack:') print(stack.pop()) print(stack) print('\nStack after elements are poped:') prin...
true
b6a6ac69c4730e0f7ee4e2bf889271812d5f168d
ogrudko/leetcode_problems
/easy/count_prime.py
804
4.15625
4
''' Problem: Count the number of prime numbers less than a non-negative number, n. Example 1: Input: n = 10 Output: 4 Explanation: There are 4 prime numbers less than 10, they are 2, 3, 5, 7. Example 2: Input: n = 0 Output: 0 Example 3: Input: n = 1 Output: 0 Constraints: 0 <= n <= 5000000 ''' # Solution class ...
true
a7745492208033ac49f8d0285ff7c141eed19a70
gatherworkshops/programming
/_courses/tkinter2/assets/zip/pythonchallenges-solutions/eventsdemo.py
2,908
4.21875
4
import tkinter import random FRUIT_OPTIONS = ["Orange", "Apple", "Banana", "Pear", "Jalapeno"] window = tkinter.Tk() # prints "hello" in the developer console def say_hello(event): name = name_entry.get() if len(name) > 0: print("Hello, " + name + "!") else: print("Hello random stranger...
true
d6eb76e86a7c77ce7f875289e87562990ed2bd58
karramsos/CipherPython
/caesarCipher.py
1,799
4.46875
4
#!/usr/bin/env python3 # The Caesar Cipher # Note that first you will need to download the pyperclip.py module and # place this file in the same directory (that is, folder) as the caesarCipher.py file. # http://inventwithpython.com/hacking (BSD Licensed) # Sukhvinder Singh | karramsos@gmail.com | @karramsos import py...
true
2ea42b749ee8320df5a7eda34a07e3bc683101b3
40168316/PythonTicketApplication
/TicketApplication.py
2,257
4.375
4
TICKET_PRICE = 10 SERVICE_CHARGE = 2 tickets_remaining = 100 # Create a function that calculates the cost of tickets def calculate_cost_of_tickets(num_tickets): # Add the service charge return (num_tickets * TICKET_PRICE) + SERVICE_CHARGE # Run this code continuously until we run out of tickets wh...
true
b49ea3e976180eecf26802fe0a6a198ce6e914fb
aabidshaikh86/Python
/Day3 B32.py
1,119
4.125
4
#!/usr/bin/env python # coding: utf-8 # In[2]: fullname = 'abid sheikh' print(fullname ) # In[ ]: # Req: correct the name format above by using the string method. # In[3]: print(fullname.title()) # Titlecase ---> first Letter of the word will be capital # In[ ]: # In[ ]: # Req: I want all the name ...
true
626aea1dbd007cc33e1c79e6fa7a35848f313cc5
aabidshaikh86/Python
/Day7 B32.py
1,888
4.375
4
#!/usr/bin/env python # coding: utf-8 # In[ ]: list Continuation : # In[ ]: # In[1]: cars = ['benz','toyota','maruti','audi','bnw'] # In[ ]: ## Organising the list datatype # In[ ]: req : i want to organise the data in the alphabetical order !!! A to Z # In[ ]: Two different approcahes : 1...
true
8d778b4cf8872d0c928d6a55933fcdfa86d0847d
Jasmine582/guess_number
/main.py
468
4.125
4
import random random_number = random.randrange(100) correct_guess = False while not correct_guess: user_input = input("Guess a number between 0 and 100:") try: number = int(user_input) if number == random_number: correct_guess = True elif number > random_number: print("You guessed too hig...
true
f8390e1a672802dd30b581fb71a50b1a2d3fbcd5
kristopher-merolla/Dojo-Week-3
/python_stack/python_fundamentals/type_list.py
1,418
4.46875
4
# Write a program that takes a list and prints a message for each element in the list, based on that element's data type. # Your program input will always be a list. For each item in the list, test its data type. If the item is a string, concatenate it onto a new string. If it is a number, add it to a running sum. At ...
true
3caf05cc3eb9cee2e9e0d7ad2ef9882a32a8668d
niteeshmittal/Training
/python/basic/Directory.py
1,490
4.125
4
#Directory try: fo = open("phonenum.txt") #print("phonenum.txt exists. We are good to go.") except IOError as e: if (e.args[1] == "No such file or directory"): #print("File doesn't exists. Creating a phonenum.txt.") fo = open("phonenum.txt", "w") finally: fo.close() opt = input("1 for store and 2 for read: ")...
true
3dde22d71aab3f343ef9f0aa6707e7b6a9220a61
rjcmarkelz/python_the_hard_way
/functional_python/chp1_1.py
1,619
4.15625
4
# chapter 1 of functional python book def sum(seq): if len(seq) == 0: return 0 return seq[0] + sum(seq[1:]) sum([1, 2, 3, 4, 1]) sum([1]) # recursive def until(n, filter_func, v): if v == n: return [] if filter_func(v): return [v] + until(n, filter_func, v+1) else: ...
true