blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
a91f4bfd2f64fb7edd7402f530750c361f12ccad
lmhbali16/algorithms
/ds_class/reverse_linkedlist.py
871
4.1875
4
''' Given a singly linked list, we would like to traverse the elements of the list in reverse order. You are only allowed to use O(1) extra space, but this time you are allowed to modify the list you are traversing. Give an O(n) time algorithm. ''' class Node: value = None next = None def reverse_linkedlist(...
true
bc2c386c4d4ebb8faa08d36db2224fe035338871
brettjbush/adventofcode
/2016/day02/day02_2.py
2,952
4.125
4
#!/usr/bin/python """ --- Part Two --- You finally arrive at the bathroom (it's a several minute walk from the lobby so visitors can behold the many fancy conference rooms and water coolers on this floor) and go to punch in the code. Much to your bladder's dismay, the keypad is not at all like you imagined it. Instead...
true
3f61528984edd34b56089cb42baf1672b63b61bc
jw56578/learn-python
/lesson3_functions.py
893
4.4375
4
import datetime # copy and paste the below code 3 more times and print a different name # a function is a group of code that needs to be called multipl times # put the code in a function called printName so you don't have to keep typing the same code over and over # call the function in place of where the duplicate co...
true
2cd6234b044d42ef4cb0b418d4918a113aa35150
polancof1182/CTI110
/P3LAB_PolancoDelaRosa.py
913
4.15625
4
# CTI-110 # P3TLAB-Debugging # Francicso PolancoDelaRosa # 6/21/2018 def main(): # This program takes a number grade and outputs a letter grade. # system uses 10-point grading scale A_score = 90 B_score = 80 C_score = 70 D_score = 60 F_score = 50 score = int(input('Enter a nu...
true
642b969ea1602a3ec8ce277dc9c70e4ecadaf817
TiredOfThisAll/Epam-hometsks
/task_5/task_5_ex_3.py
978
4.25
4
""" Create function sum_geometric_elements, determining the sum of the first elements of a decreasing geometric progression of real numbers with a given initial element of a progression `a` and a given progression step `t`, while the last element must be greater than a given `lim`. `an` is calculated by the formula (an...
true
c1270a670156d7e931e9abd5b5b83c07d7d0cf45
TiredOfThisAll/Epam-hometsks
/task_9/task_9_ex_2.py
852
4.4375
4
""" Write a function that checks whether a string is a palindrome or not. Return 'True' if it is a palindrome, else 'False'. Note: Usage of reversing functions is required. Raise ValueError in case of wrong data type To check your implementation you can use strings from here (https://en.wikipedia.org/wiki/Palindrome#...
true
5c375468236c672ff6aeb1782282206600108197
dooran/Aaron-s-Rep
/main2.19.py
2,091
4.34375
4
#Manuel Duran 1584885 #input the number so cups of lemon juice, water and agave nectar cups_lemon_juice = float(input('Enter amount of lemon juice (in cups):\n')) cups_water = float(input('Enter amount of water (in cups):\n')) cups_agave_nectar = float(input('Enter amount of agave nectar (in cups):\n')) # input th...
true
614c4157f947e294c7b1fd451b11517866aff7e8
CosmoSt4r/exercism-python
/easy/prime-factors/prime_factors.py
809
4.15625
4
""" Solution to Prime Factors task on Exercism https://exercism.org/tracks/python/exercises/prime-factors """ def is_prime(value: int) -> bool: """Check if value is prime""" if value == 1: return False if value <= 0: raise ValueError("Value must be greater than zero") for i in range(...
true
82f7fdb214f3dfea2dc1741721c84ead57626c08
fehringj/Python-Coding-Exercises
/MyQueue.py
1,591
4.40625
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Tue Sep 3 10:13:17 2019 @author: Jenny """ # Requires Stack.py from Stack import * new_stack = Stack() old_stack = Stack() class MyQueue: """Implementation of a queue that is comprised of two stacks""" def size(self): r...
true
7a1a837e9ecd484294d547d4aff4676242d04c2a
AprajitaChhawi/365DaysOfCode.JANUARY
/Day 14 merge two sorted list.py
2,187
4.125
4
#User function Template for python3 ''' Function to merge two sorted lists in one using constant space. Function Arguments: head_a and head_b (head reference of both the sorted lists) Return Type: head of the obtained list after merger. { # Node Class class Node: def __init__(self, data): # data -> ...
true
6dc622886e68061531b5f8a2fbd6a9367a1af767
Saurabh9520/python-programs
/largest palindr.py
1,282
4.25
4
def isPalindrome(n): # Find the appropriate divisor # to extract the leading digit divisor = 1 while (int(n / divisor) >= 10): divisor *= 10 while (n != 0): leading = int(n / divisor) trailing = n % 10 # If first and last digits are ...
true
4cd4d0c0e2af76e507dbf7ea9c9a967ea9122a18
isaacMullen/Class-Projects
/my first game..py
562
4.21875
4
x = 67 print ('''Welcome to my game... You will be asked to choose a number between 1 and 100, The computer has also chosen a number between 1 and 100. The object of this game is to eventually reach the same number as the computer. using simple information you will be provided with in the form of <,>,=.''') num1 =...
true
dc625928f7ee963d49758b929564870304259e1c
AshwinShanbhag/Coursera_PythonCode
/Coursera Assignment 8.4_new.py
692
4.46875
4
"""8.4) Open the file 'romeo.txt' and read it line by line. For each line, split the line into a list of words using the split() method. The program should build a list of words. For each word on each line check to see if the word is already in the list and if not append it to the list. When the program completes, ...
true
16cb42d79ada5f327ca8ff3bb0e840028dc4d699
DishenMakwana/Python-DS
/Python Data structures/stack2.py
1,003
4.1875
4
from collections import deque class Stack(): def __init__(self): self.stack = deque() def push(self, value): self.stack.append(value) def pop(self): if self.empty(): return 'Stack is empty' return self.stack.pop() def top(self): if self.empty(): ...
true
1e0e064580cae963a11da5e4ab8c147cba83e53e
JaiJun/Codewar
/8 kyu/Is n divisible by x and y.py
551
4.25
4
""" Create a function that checks if a number n is divisible by two numbers x AND y. All inputs are positive, non-zero digits. I think best solution: def is_divisible(n,x,y): return n % x == 0 and n % y == 0 https://www.codewars.com/kata/5545f109004975ea66000086 """ def is_divis...
true
095443c6aa00d7a1cf26144fef51e0e6b3d368da
JaiJun/Codewar
/7 kyu/Unlucky Days.py
1,008
4.21875
4
""" Friday 13th or Black Friday is considered as unlucky day. Calculate how many unlucky days are in the given year. Find the number of Friday 13th in the given year. Input: Year as an integer. Output: Number of Black Fridays in the year as an integer. Examples: unluckyDays(2015) == 3 ...
true
5d5030661faa2593eae476df9f7cbb4d1991ccd5
JaiJun/Codewar
/7 kyu/Mr Martingale.py
2,349
4.28125
4
""" You're in the casino, playing Roulette, going for the "1-18" bets only and desperate to beat the house and so you want to test how effective the Martingale strategy is. You will be given a starting cash balance and an array of binary digits to represent a win or a loss as you play: 0 for loss and 1 for win. You s...
true
bb16544fcbd25a20e61072b7faffd6ac0f6ac114
JaiJun/Codewar
/8 kyu/Is he gonna survive.py
1,260
4.15625
4
""" A hero is on his way to the castle to complete his mission. However, he's been told that the castle is surrounded with a couple of powerful dragons! each dragon takes 2 bullets to be defeated, our hero has no idea how many bullets he should carry. Assuming he's gonna grab a specific given number ...
true
1fa3180c91f2cd3b0d8114ff03bab5b75b71358b
JaiJun/Codewar
/7 kyu/Reverse a Number.py
1,002
4.375
4
""" Given a number, write a function to output its reverse digits. (e.g. given 123 the answer is 321) Numbers should preserve their sign; i.e. a negative number should still be negative when reversed. Examples 123 -> 321 -456 -> -654 1000 -> 1 I think best solution: def reve...
true
a96a4a83a1cf28935c8bff11bbe2e4b3899687fc
JaiJun/Codewar
/7 kyu/Disemvowel Trolls.py
1,149
4.375
4
""" Trolls are attacking your comment section! A common way to deal with this situation is to remove all of the vowels from the trolls' comments, neutralizing the threat. Your task is to write a function that takes a string and return a new string with all vowels removed. For example: the string...
true
776ef7eb8dcecc8c86da50a56cc5d218e6140d9d
JaiJun/Codewar
/7 kyu/Simple string matching.py
2,128
4.3125
4
""" You will be given two strings a and b consisting of lower case letters, but a will have at most one asterix character. The asterix (if any) can be replaced with an arbitrary sequence (possibly empty) of lowercase letters. No other character of string a can be replaced. If it is possible to re...
true
741f0a0e4797077a17a64418ce9175a9ba85ddac
varunpandey0502/skyfi_labs_ml_workshop
/hands-on_introduction/2 - build_your_first_machine_learning_model - exercise.py
1,853
4.1875
4
# -*- coding: utf-8 -*- import pandas as pd #Import the train.csv file sydney_file_path = home_data = #Step 1 - Specify the prediction target #Select the target variable, which corresponds to the sales price. Save this to a new variable called `y`. You'll need to print a list of the columns to find the name of the...
true
29d82ea0cd907107818cbf803a13fc185e16d50d
ishitadate/nsfPython
/Week 9/w9_homework.py
498
4.125
4
print("problem 1") # write a simple example to show how 3 functions of your choice from the math and random libraries work. print("problem 2") # create something that takes command-line imput, does some mathematical calculations with the # number inputted and some other random numbers, and returns something back pri...
true
dffccbd116d9b81b2bd5aa3de049ec7ebef46c56
kavyareddi/level1_python
/program_4_class_inheritance.py
1,015
4.125
4
#program on class inheritance #input : defining classe subclass and thier attributes class Person: # initializing the variables # defining constructor def __init__(self, personName, personAge): self.name = personName self.age = personAge # defining class methods ...
true
e3bb9036ba091d5a066d664368e51b13f0ab7252
KenNyakundi01/Password-Locker
/user.py
1,313
4.3125
4
class User: ''' This is the user class where the user is persisted to disk in a plain file ''' user_list = [] # empty user list def __init__(self, username, password): ''' __init__ method that helps us define properties for our objects Args: username: New us...
true
56bea18d5d3dfe7a2bc3e339cf5bad8577daa060
agatanyc/section_normalization
/mysolution/matching.py
2,971
4.25
4
#!/usr/bin/env python from string import ascii_uppercase # some sections may have numerical ROW names (1-10) and some may have alphanumeric row names (A-Z, AA-DD). Your code should support both def extract_integer(text): """Filters non-digits from text, and parses the result as an integer.""" try: digit...
true
168dc53740de4847cd82a81c34317b4373639a49
cuauhtemocmartinez/python_projects
/Lab 1/CMartinezLab1.py
1,528
4.3125
4
################################################################# # Program Header # Course: CIS 117 Python Programming # Name: Cuauhtemoc Alex Martinez # Description: Lab 1 # Application: Hello World and infomation # Topics: Using Python3 Interpreter and capturing program output # Development Environment: Windo...
true
5a6b854e94c511821e21f7e04e39c28a112f1d96
plushies/py
/rps.py
1,477
4.125
4
from random import randint cont = 'memes' pscore = 0 cscore = 0 print('ROCK PAPER SCISSORS') print('enter \'stop\' to end the game') while cont == 'memes': player = input('rock, paper, or scissors? ') while player != 'rock' and player != 'paper' and player != 'scissors' and player != 'stop': ...
true
59593f705c26af60ea691ed9de128691f39ac493
bmandiya308/python_trunk
/pallendron.py
226
4.28125
4
def reversed(s): rev = s[::-1] return rev input_str = str(input("Please enter string to check pallendrom")) rev = reversed(input_str) if(rev == input_str): print("pallendrom") else: print("Not a pallendromj")
true
0c4c890525138446edcd5578cd431c6d289d92b4
bmandiya308/python_trunk
/dict_order_dic.py
419
4.375
4
# A Python program to demonstrate working of OrderedDict from collections import OrderedDict import string print("This is a Dict:\n") dict_1 =list(range(26)) dict_2 = list(string.ascii_lowercase) d = {dict_1[i]:dict_2[i] for i in range(len(dict_1))} for key, value in d.items(): print(key,value) print("\nThis...
true
3647001cacf70f7b0d550fb80e75ee2d5f114910
RohanDeySarkar/DSA
/sorting_algo/2_insertion_sort/insertionSort.py
370
4.15625
4
def insertionSort(arr): for i in range(1, len(arr)): currentIdx = i while currentIdx > 0 and arr[currentIdx] < arr[currentIdx - 1]: swap(arr, currentIdx, currentIdx - 1) currentIdx -= 1 return arr def swap(arr, idx1, idx2): arr[idx1], arr[idx2] = arr[idx2], arr[idx1]...
true
c9549a896f442252f998a5a784da381dccdee559
requestriya/Python_Basics
/basic60.py
357
4.59375
5
# Write a Python program to check whether a string is numeric. # 1. val = '12345' count = 0 for i in val: if (ord(i)>=48 and ord(i)<=57): count+=1 else: print('has alpha values') break if count == len(val): print('val has only numeric value') # 2. if val.isdigit(): print('its n...
true
c6608f837bf7d38af00ad6af3af1ceba22f0a28f
j3py/cracking_codes
/caesar_cipher.py
2,382
4.15625
4
# Caesar Cipher import pyperclip import cipherrandom def main(): # the string to be encrypted/decrypted message = input('Enter message: ') # whether the program enc or dec mode = input('Type e for encrypt or d for decrypt: ') # every possible symbol that can be enc: SYMBOLS = 'ABCDEFGHIJKLM...
true
44459258bdde077daa7e3ed2775c2f79e19b7d3b
eaglerock1337/realpython
/part1/1.1-1.9/find.py
273
4.125
4
print("AAA".find("a")) name = "Version 2.0" ver = 2.0 print(name.find(str(ver))) string = input("Please enter a string: ") search = input("Please enter a search character: ") print("The result of searching '{}' for '{}' is {}.".format(string, search, string.find(search)))
true
3a13c13c28e5b18fd24578568b3c50e6eb053ca2
rituteval/collatz
/collatz.py
494
4.40625
4
# The number we will perform the collatz operation on. n = int(input("Enter a positive integer:")) # Keep looping until we reach number 1. # Note: This is assumes the collatz conjecture is true. while n != 1: # Print the current value of n. print (n) #Check is n is even. if n % 2 == 0: # If n is e...
true
7ca49776529709e5f0892f41e0c229e1a4548822
tayyabmalik4/pandas_in_python
/14_interpolate_#2_pandas_practical.py
1,737
4.5625
5
# *****************Interpolate function using pandas linbray in python****************** # discuss about-----parameters of interpolate-----------method,axis,limit,inplace,limit_direction,limit_area import pandas as pd inter1=pd.read_csv('F:\\tayyab programming\\machine learning\\pandaswithtayyab\\05_using_write_the...
true
a121eb4f526d1c1d0eddd7c6c40674582afcc825
tayyabmalik4/pandas_in_python
/10_Handling_missing_values_#03_pandas_practical_09.py
2,807
4.59375
5
# ******************************Handling Missing values part 3 using pandas in python***************************** # /////discuss about (dropna(values,method,axis,how,subset,thresh,inplace)) # /////dropna() function basically which colums or rows are exists the empty values and we want to drop this colums or rows tha...
true
344701e7c5b2f5410f4155127c1777969dc50f2a
tayyabmalik4/pandas_in_python
/02_Series_pandas_practical_01.py
2,658
4.15625
4
# ////////series in pandas///////////////// # //////Series is a one dimentional array in pandas # ////// # ****************import the pandas library import pandas as pd # //////checking the version of pandas # /////the verion is 1.3.0 # print(pd.__version__) lst=[1,2,-3,6.2,'data values'] # print(lst) # ********...
true
972166aa22c08efe01fceb483298ecb61c803f2b
ocslegna/hackerrank
/hackerrank/Python/Collections/namedtuple.py
772
4.34375
4
#!/usr/bin/python3 """ Basically, namedtuples are easy to create, lightweight object types. They turn tuples into convenient containers for simple tasks. With namedtuples, you don’t have to use integer indices for accessing members of a tuple. Named tuples are especially useful for assigning field names to result tu...
true
d807e356e346c5348197311aa88aac7ab543af5a
minasel/GEOS636_PAG
/listings/io_wite.py
712
4.125
4
fname = "io_print.txt" #1) open this file in read mode print("Example 1") print("--------------------Start") my_file = open(fname, "r") #print the entire thing print(my_file.read()) #close the file my_file.close() print("--------------------End") #2) print a two lines of the file print("Example 2") print("----------...
true
30d006b121bda4a42bb623f0eab1c9baf3c42dbd
Chaitanya-Raj/PyLearn
/SimpleCalculator.py
650
4.125
4
import os print("Welcome to Simple Calculator") print("1.Addition") print("2.Subtraction") print("3.Multiplication") print("4.Division") print("5.Modulus") print("6.Exponentiation") choice = int(input("Choose an option : ")) print() x = float(input("Enter the first number : ")) y = float(input("Enter the s...
true
c0000e107d0c36eb4f5b5f00fba30a80c3213ba2
samyak1903/Decision_Making
/A4.py
1,021
4.28125
4
'''Q.4- Ask user to enter age, sex ( M or F ), marital status ( Y or N ) and then using following rules print their place of service. 1. if employee is female, then she will work only in urban areas. 2. if employee is a male and age is in between 20 to 40 then he may work in anywhere 3. if employee is male and age is...
true
beae28fba50dbfa69d98aa8ab5201c0a25ac4645
aleksiheikkila/AdventOfCode2019
/day01/The_Tyranny_of_the_Rocket_Equation.py
1,584
4.15625
4
# to find the fuel required for a module, take its mass, divide by three, round down, and subtract 2. def calc_fuel_req(mass: int) -> int: return (mass // 3) - 2 # Unit tests #For a mass of 12, divide by 3 and round down to get 4, then subtract 2 to get 2. #For a mass of 14, dividing by 3 and rounding down still ...
true
f5675d3dfe845e6522c1e418eb3e846720ad250b
ArnabBasak/PythonRepository
/progrms nltk/stop words.py
657
4.1875
4
from nltk.corpus import stopwords from nltk.tokenize import word_tokenize example_sentence = "this is a first sentence written by me in the nltk python." stop_words = set(stopwords.words("english")) print('original sentence is',example_sentence) #print(stop_words) words = word_tokenize(example_sentence) filtered_sente...
true
bdd31b8913b5e2480dada2e1f4092aa4cd251b59
ArnabBasak/PythonRepository
/Python_Programs/PythonCode/Dice_Rolling_Simulator.py
1,969
4.5625
5
""" 1. Dice Rolling Simulator The Goal: Like the title suggests, this project involves writing a program that simulates rolling dice. When the program runs, it will randomly choose a number between 1 and 6. (Or whatever other integer you prefer — the number of sides on the die is up to you.) The program will print ...
true
299a505a01a4b9180c53a461882f5ee26b4b4107
ArnabBasak/PythonRepository
/python programs/posnegnumber.py
282
4.34375
4
number = int(input("enter any number it can be postive negative or 0")) if number == 0: print("the number is nither negative nor postive its 0") elif number>0: print("the numer is postive") elif number<0: print("the number is negative") else: print("invalid input")
true
71bc39777c133295ca95cf2c16b33feae0186086
MxValix/corso_data_science_python
/5nov.py
999
4.375
4
# Test Case 1 # Enter your annual salary: 120000 # Enter the percent of your salary to save, as a decimal: .10 # Enter the cost of your dream home: 1000000 # Number of months: 183 # # Test Case 2 # Enter your annual salary: 80000 # Enter the percent of your salary to save, as a decimal: .15 # Enter the cost of your dre...
true
3e0e0258c387fdcd702a446e0d8f8265ac72ad23
avyuktitech/DXCRepo
/Python_Calculator.py
975
4.3125
4
# This was Sample Python script # Basic Calculator: # This function performs additiion def add(a, b): return a + b # This function performs subtraction def subtract(a, b): return a - b # This function performs multiplication def multiply(a, b): return a * b #This function performs divisi...
true
db14964251ed0383169d71315f0208de6cfe7509
TechbirdsYogendra/DataStructureExercisePython
/recursion.py
525
4.125
4
# This funcion returns factoril of a number. def factorial(n): if n == 0 or n == 1: return 1 elif n < 0: return 0 else: return n * factorial(n-1) n = 5 fact = factorial(n) print(f"Factorial of {n} is {fact}.") # It returns nth numner in Fibonacci series. def fibonacci(n): if ...
true
b5999e8997bb3450f85dc92493c2cab17639a1f6
mmeysenburg/ccla-hpc-workshop
/src/optimizing-python/function-alias/exercise02.py
403
4.15625
4
''' Function alias exercise 2 Convert cartesian coordinates to polar. ''' import math import random # create n cartesian coordinates in the unit square n = 1_000_000 uni = random.uniform cartesians = [(uni(-1, 1), uni(-1, 1)) for i in range(n)] # write code here to create a new list called polars. # the new list sh...
true
f275b55d7ee2ce5aa69e40898b8a846a7033d386
Ahsank01/FullStack-Cyber_Bootcamp
/WEEK_1/Day_1/7_Forwards_Is_Backwards.py
928
4.625
5
#!/usr/bin/env python3 """ The path to the input file will be passed into your program as a command line argument when your program is called. Write a program that receives a single word as input and checks to see if the word is a palindrome (i.e. words that look the same written backwards). """ import sys ...
true
7a00269839623ccf7c805152f61711d543f4a721
Ahsank01/FullStack-Cyber_Bootcamp
/WEEK_1/Day_1/8_Lines.py
829
4.125
4
#!/usr/bin/env python3 """ Your boss handed you a simple task, just replace the "newlines" from the provided file with spaces... (hint - it's not just that simple) """ # Import the 'sys' module import sys def lines(): # Get the name of the file from the command line arguments file_name = sys.arg...
true
8ca87f709db67790f37e7e77d762eb00261d0e0a
PashaKim/Python-Function-for-basic-math-operation
/Basic-Math-Operations.py
653
4.6875
5
#Write the function "arnntetik", taking 3 arguments: #the first 2 - the number, the third - the operation that should be performed on them. #If the third argument is +, add them; If -, then subtract; Multiply; / - divide (the first into the second). In other cases, return the string "Unknown operation" .. print ("Hi. ...
true
6ea19b0d8bdb75aa46b59db78ba90f608ec65047
bosskeangkai/Python-Math-Solving
/max_min.py
1,025
4.15625
4
# input three number and then check what is the max or min number and then finally show on your screen # while loop 5 time # คำสั่ง if เเบบ 1 ทางเลือก # do only if for check # initail max = 0 min = 0 n = 1 # process # while loop check if n <= 5 loop while n <= 5: x = int(input("Enter your X numbe...
true
6f036986207dfaf22e0a7e8af4e71edf12ed478c
MatthewTurk247/Programming-II
/Recursion.py
764
4.375
4
# Recursion: functions calling themselves # Functions calling functions def f(): g() print("f") def g(): print("g") f() # Functions calling themselves def hello(): print("hello") hello() # hello() # helpful uses: searching files # We can control the recursion depth def controlled(level, end_le...
true
e18137c5524499290af0cdbdfdbf4e8a0a0563da
ValentynaGorbachenko/cd2
/ltcd/matrixReshape.py
2,259
4.34375
4
''' In MATLAB, there is a very useful function called 'reshape', which can reshape a matrix into a new one with different size but keep its original data. You're given a matrix represented by a two-dimensional array, and two positive integers r and c representing the row number and column number of the wanted reshaped...
true
7e4b0c59f46428157c01a81fbbcfcbc1d42a9e08
jheyer23/python_gdal
/Functions.py
524
4.21875
4
# Writing functions in Python #Where a block line is more Python code (even another block), and the block head is of the following format: block_keyword block_name(argument1,argument2, ...) Block keywords you already know are "if", "for", and "while". # Functions in python are defined using the block keyword "def", ...
true
bfe48ca69a214ffd51785329ca332be465a99bd1
jheyer23/python_gdal
/Dictionaries.py
984
4.59375
5
# Storing items in dictionary # Different attributes - name, email, phone, etc. # Key value pairs (Key: name, email, phone). Each key has value # Keys need to be unique in a dictionary - cannot duplicate # Values of keys can be any data type customer = { "name": "John", "age": 30, "is_verified": Tru...
true
b28ca5390ed22e9860761f7dcfccf1ff9ca868ac
Neeraj-Palliyali/chegg_python
/test.py
410
4.3125
4
# getting account number accountNo=input("Enter the 8 digit account number:") # try catch for if the input cannot be converted to integer try: account=int(accountNo) # if the length is not equal to 8 if(len(str(account))==8): print("The account number is valid") else: print("Invalid ...
true
e944d86b29c424384cf1e35c2593220107a8d9d1
reggiemccoy/python_code
/tempature/converter.py
305
4.25
4
print("Welcome to my conversion project for measurements") cm = int(input(" please enter in cm: \n")) # making sure the data entered is integer # and then make the text appear on a new line conVertthis =(.39*cm) print(conVertthis) print("inches") foot = (conVertthis/12) print(foot) print("feet")
true
23578f985e19392effd465752c3fe289c0431fe5
reggiemccoy/python_code
/compare/compare_sting_input.py
271
4.25
4
# String compare in Python with input str_input1 = input("Enter First String? ") str_input2 = input("Enter Second String? ") # comparing by == if str_input1 == str_input2: print("First and second strings are same!") else: print("You entered different strings!")
true
a6d5b82a61dda2ff6693d5fac779d175690fc451
duncandill/Age
/age.py
1,306
4.15625
4
def question(): answer = None while answer is None: print ("Welcome to AGE\n please enter your age.") answer = input("How old are you?\nEnter a number from 0 to 99 ") try: answer = int(answer) if answer >99 or answer < 0: answer = None ...
true
39f208f932dfb344b589ee8c69e12432bcde3e8d
arcadecoder/Rosalind-algorithms
/RabbitsandRecurrence.py
838
4.46875
4
def Fibonacci_loop_rabbits(months, offsprings): """ 1. Initially assign 1 parent and one child. This is the first set of offspring. 2. Loop over the number of months (minus 1 - we already had the first month) 3. The child becomes a parent, so given a new value (still 1) 4. The child value is now th...
true
7273758e0cced965db85a7dbc850da8439b45588
varnitmittal/quarantine-coding-revision
/DS/Queue/deque_incomplete.py
1,360
4.15625
4
#Deque implementation class Deque: def __init__(self, *args): self.max = 5 self.deque = [] self.front = -1 self. rear = -1 self.display() def isFull(self): return False def insertFront(self, x): if self.isFull(): print("Can't insert,...
true
f78cc4d4d4456a10f09d870bfd0385f2bc588431
baleshwar-mahto/cse-using-python
/sqplot.py
537
4.34375
4
#python 3 program to plot x^2 and x^3 function on same graph import numpy as np import matplotlib.pyplot as plt from pylab import rcParams rcParams['figure.figsize']=5,3 #figure of the size 5in x 3in x=np.linspace(-1,1,10) y=x**2 y1=x**3 plt.plot(x,y,'r.',label=r'$y=x^2$') plt.plot(x,y1,lw=3,color ='g',label =r'$y=x^...
true
130a86a145641063007d47126c2aab88150a3c76
SHJoon/Algorithms
/arrays/5_reverse.py
496
4.40625
4
# Reverse Array # Given a numerical array, reverse the order of the # values. The reversed array should have the same # length, with existing elements moved to other # indices so that the order of elements is reversed. def reverse_array(lst): for i in range(len(lst) // 2): temp = lst[i] lst[i] = ls...
true
e8b6686ac6ecd5d490688ff33633ca530407f6c0
SHJoon/Algorithms
/arrays/9_rotate_array.py
705
4.15625
4
# Rotate Array # Implement rotateArr(arr, shiftBy) that # accepts array and offset. Shift arr’s values to the # right by that amount. ‘Wrap-around’ any values # that shift off array’s end to the other side, so that # no data is lost. Operate in-place: given # ([1,2,3],1), change the array to [3,1,2]. def rotate_arr(ar...
true
74bb0a85a677c94c0dd5fc5057d4cffb988f51a8
SHJoon/Algorithms
/hackerrank/warmup/2_counting_valleys.py
2,221
4.78125
5
# An avid hiker keeps meticulous records of their hikes. During the last # hike that took exactly steps steps, for every step it was noted if it was an uphill, U, # or a downhill, D step. Hikes always start and end at sea level, and each step up or # down represents a 1 unit change in altitude. We define the following ...
true
b14444421ce6c71b7ad8ba3e72fbc6558e0bcca9
maladeveloper/algos-and-data-structures
/StacksAndQueue/reversing_linked_list.py
1,495
4.25
4
from SingleLinkedList import Linked List ''' Code for reversing a list via both functions was written by me. ''' my_list = LinkedList() my_list.append("M") my_list.append("A") my_list.append("L") my_list.print_list() ##Implementation of reversing a linked list using recursion def reverse_list(prev_node, curr_nod...
true
4ad9e9a083c73a065cd9af7d8f00d56f01971f14
kantel/nodebox-pyobjc
/examples/Extended Application/sklearn/examples/linear_model/plot_ols.py
2,804
4.15625
4
""" ========================================================= Linear Regression Example ========================================================= This example uses the only the first feature of the `diabetes` dataset, in order to illustrate a two-dimensional plot of this regression technique. The straight line can be s...
true
f01c1a88928fec538ea44250e3f0d86eccfce234
erofes/python_learn
/CribLibrary/functions/function_arguments.py
606
4.25
4
def func(a, b, c = 2): # a, b is necessary! c is not necessary return a + b + c print(func(1, 2, 3), func(1, 2), func(a=2, b=3)) # There are ways to use arguments # 6 5 7 def many(*args): # Must take any number of elements, unnamed tuple '''Custom description: Return input arguments''' return args # ...
true
781821bec5003263baf4364df0f0d8d92ae3ce44
jorien-witjas/python-labs
/python_fundamentals-master/07_classes_objects_methods/07_00_planets.py
629
4.21875
4
''' Create a Planet class that models attributes and methods of a planet object. Use the appropriate dunder method to get informative output with print() ''' class Planet(): def __init__(self, name, size, colour): self.name = name self.size = size self.colour = colour Jupiter = Planet("j...
true
3fc8ee0756d2a19b62635047d0d24e0a6f662049
Aetrix27/CS-1.0-Custom-Calculator
/app.py
1,205
4.6875
5
import math def calculate_quadratic(coeff_1, coeff_2, coeff_3): #The formula to calculate the quadratic equation for the positive result given by the square #root is found below, the inputted into the appropriate variable. positive_root=(-coeff_2+math.sqrt((coeff_2**2)-(4*(coeff_1*coeff_3))))/(2*coeff_1) ...
true
644b6ce2a21fb0e390fedb77aef04f12c77cf603
Ben-Lapuhapo/ICS3U-Unit-4-02-Python
/multiplying.py
878
4.125
4
#!/usr/bin/env python3 # Created by: Ben Lapuhapo # Created on: October 2019 # This program shows the factorial of a number def main(): while True: # input sub_answer = 1 total_number = 1 number = input("Input A Positive (+) Number: ") print() try: num...
true
e1db5c5c64dc952b7f9fc40374ab220159b8f67a
X-R4Y-1/me
/week3/exercise3.py
1,323
4.28125
4
"""Week 3, Exercise 3. Steps on the way to making your own guessing game. """ import random def get_number(message): while True: try: answer = input(message) answer = int(answer) return answer except ValueError: pass def advancedGuessingGame(): ...
true
a0839d4e963ddf8b987366f7498c3f09f56df718
lewispark345/p3w
/p3w_01.2b.2.py
878
4.125
4
# A program to perform the following mathematical operations in Python """a. Addition""" """b. Subtraction""" """c. Multiplication""" """d. Division""" print ("# A program to perform the following mathematical operations in Python") print ("a. Addition") print ("b. Subtraction") print ("c. Multiplication") p...
true
520720ba773d6bf68bea065eefe96ce412d6ea6b
rahultc26/python
/stringtypes.py
661
4.15625
4
s0="awesome " print(s0) s="my name is rahul " #using string print(s) s1="""you are awesome because your learning python.. all the best""" #you can take single or double quotes instead print(s1) s2='i am learning python' #using single quotes print(s2) #indexing in strings print(s[0...
true
4391d982f51ae1f6638c866b87c6f6751b72fdd1
AshuHK/Sorting_Visualization
/text_based_sorts/SelectionSort.py
522
4.125
4
from Swap import _swap def selection_sort(unsorted): """ Does an selection sort on a Python list Expected Complexity: O(n^2) (time) and O(1) (space) :param unsorted: unsorted Python list to be sorted """ for i in range(len(unsorted)): # look at each of the remaining values and locate...
true
c11eb267e93ff7f97343c593468f6b346289c137
AshuHK/Sorting_Visualization
/text_based_sorts/Swap.py
541
4.25
4
def _swap(test_list, x, y): """ Conducts a Pythonic swap within a list between two indicies - Note: the order of x and y do not matter as long as both are in an acceptable range [0, len(test_list)] Expected Complexity: O(1) (time and space) :param some_list: Python list of integ...
true
6e29a0b4eb5805051dafdaf5c6dba6501489c298
FE1979/Dragon
/Python_4/is_sorted.py
1,086
4.1875
4
""" check recursively if list is sorted """ def is_sorted(list): sorted = True items = len(list) medium = len(list) // 2 left_list = list[:medium] right_list = list[medium:] if items > 4: #end script when left and right lists have 1 or 2 items if left_list[0] <= left_list[-1] <= right_...
true
b636c8a39b3c5ef41011fea7f2290cd8f64daf1e
FE1979/Dragon
/Python_3/median.py
243
4.15625
4
first_list_len = int(input('Type a lenght of the first list\n')) second_list_len = int(input('Type a lenght of the second list\n')) median = (first_list_len + second_list_len)/2 print('A median of the two merged lists is {}'.format(median))
true
3ec3b48304331486cac681892a9cfdd0974ae0fd
njones777/school_programs
/X&Y.py
2,533
4.25
4
###################################################################################################################### # Name: Noah Jones # Date: 9/13/2021 # Description: program to do simple X & Y coordinate calculations such as midpoint and distance between two points #############################################...
true
c74b685438df1dbae6fadbe9b39846944921b81a
kstack4074/daily_coding
/#9.py
1,212
4.28125
4
''' Given a list of integers, write a function that returns the largest sum of non-adjacent numbers. Numbers can be 0 or negative. For example, [2, 4, 6, 2, 5] should return 13, since we pick 2, 6, and 5. [5, 1, 1, 5] should return 10, since we pick 5 and 5. Follow-up: Can you do this in O(N) time and constant space?...
true
f872c22c73d77b2750d02092aaa396e97e38284b
KyLarson-Research/100Days-21
/day2.py
439
4.1875
4
#Authored by Kyle Larson 9-30 print('Welcome to the tip calculator.') bill =input("What was the total bill?") people = input("How many people to split the bill?") percentage = input("WHat percentatge tip would you like to give?") if int(percentage) < 0 or int(percentage) > 100: print("invalid percentage") else: ...
true
eca17996335c4fa8b1c2de5cc93e7ec170efcc9e
BenRauzi/159.171
/Workshop 3/13.py
255
4.15625
4
words = [] while True: word = input("Enter a word: ") if word.lower() == "end": #.lower() allows any casing from the input, prevents errors in real world scenarios break words.append(word) print("The resulting list is " + str(words))
true
53793985ba1d3bca5dd13c74ae15c1867145fc7d
LuisCastellanosOviedo/python3
/my-python-project/datetime/time-till-deadline.py
609
4.21875
4
from _datetime import datetime user_input =input("enter your goal with a deadline separated by colon \n") input_list = user_input.split(":") goal = input_list[0] deadline = input_list[1] print(input_list) deadline_date = datetime.strptime(deadline, "%d.%m.%Y") today_date = datetime.today() print(deadline_date) pri...
true
ad1f15c1dd06cf6db543de987c669e5b84a9ae8d
LuisCastellanosOviedo/python3
/my-python-project/day9_dictionaries_and_nesting/main.py
505
4.15625
4
first_dic = { "bug": "is a error", "Function": "A piece of code", "Loop": "some repetitive", } # retrieve all elements from the dic print(first_dic) print(f"bug values: {first_dic['bug']}") # Adding new elements to dictionary first_dic["Error"] = "A problem in the code" print(first_dic) # Create and emp...
true
1568cb71199c1ce51eee28205d95429df363a4c9
nishalpattan/DataStructures-Algorithms
/Arrays/twoSum.py
1,021
4.3125
4
def twoNumberSum(array, targetSum): """ Time Complexity : O(n) Space Complexity : O(n) :param array: :param targetSum: :return:[number1, number2] """ hash_map = dict() for num in array: if num in hash_map: return [num, targetSum - num] hash_map[targetSum - num] = num return [] def tw...
true
3f4ed5b3ea1a1c83fa58784590f92c1ca0b983d9
vuthanhdatt/MIT_6.0001
/ps1/ps1b.py
681
4.25
4
annual_salary = int(input('Enter your annual salary:')) portion_saved = float(input('Enter the percent of your salary to save:')) total_cost = int(input('Enter the cost of your house:')) semi_annual_raise = float(input('Enter the semi­annual raise, as a decimal:')) portion_down_payment = .25 current_savings = 0 r = .0...
true
8375c9db42e10ee289459c316ea6f4e33a0756a1
gocersensei/Recursion
/totalTheValues.py
963
4.25
4
## # Total a collection of numbers entered by the user. The user will enter a blank line to # indicate that no further numbers will be entered and the total should be displayed. # ## Total all of the numbers entered by the user until the user enters a blank line # @return the total of the entered values def readAndTota...
true
0a95d47a6764e6390bc7a0463ca0113d1673b2d0
nonamejx/python-design-patterns
/src/factory_method/factory_method.py
1,304
4.53125
5
""" Factory Method Design Pattern. Intent: Provide an interface for creating an object, but let subclasses decide which class to instantiate. """ from __future__ import annotations from abc import ABC, abstractmethod class Transport(ABC): @abstractmethod def deliver(self) -> str: pass class Truc...
true
960bd9b4ab615c14b92f2b0f82f77118e1d3d668
EmAchieng/myPy
/employees.py
716
4.375
4
#creating an instanciated simple classes #classes allow us to logically group our data and functions making it easy to reuse class Employee: #means you just want to skip it pass #each of these will be their own unique instances of the employee class emp_1 = Employee() emp_2 = Employee() #both of these are ...
true
45242b779548b11bdedea095e68ca9f97db33075
bcbc-group/PLSCi7202_2021
/first_python.py
1,660
4.53125
5
#!/usr/local/bin/python3 #testing out python print("Python is fun!") #using variables message = "Python is fun!" print(message) #using the title method name = "suzy strickler" print(name.title()) #using variables in strings first_name = "suzy" last_name = "strickler" full_name = f"{first_name} {last_name}" print(ful...
true
f70ecd164dd2177c16d34a2dd2c671a8a73d4169
sakshambhardwaj523/Python-OOP-Projects
/Assignments/Assignment 3/menu.py
1,649
4.15625
4
""" Stores Menu items for Pizza shop UI. """ import pizza class Menu: """ Stores items for menu creation. """ start_menu = { 1: "Build your own pizza", 2: "Quit" } cheese_menu = { 1: pizza.Ingredient("Parmigiano Reggiano", 4.99), 2: pizza.Ingredient("Fresh Moz...
true
4ee97294e3144d500b4045fcff47fa91599d864a
sakshambhardwaj523/Python-OOP-Projects
/Labs/Lab 2/item.py
2,079
4.15625
4
import abc class Item(abc.ABC): """ Represents an Item that is stored in a Catalogue at the Library. Any class that inherits from this class MUST implement all the @abstractmethods and @abstractclassmethods. """ def __init__(self, title, call_no, author, num_copies): """ Initia...
true
282885f934c239d86252c9f4503fa4174476dbe1
sakshambhardwaj523/Python-OOP-Projects
/Labs/Lab 0/calculator.py
1,565
4.15625
4
"""Demonstrates basics of Python functions.""" def sum(a, b): """ Return sum of two ints. :param a: int :param b: int :return: sum as an int """ return a + b def subtract(a, b): """ Return difference of two ints. :param a: int :param b: int :return: difference as an int...
true
e27c41f9b5045a9f45375f2c41d460a13d52a8de
mosest/11th-Python
/8 - Snowflake Fractal.py
1,054
4.21875
4
#Tara Moses #Assignment 8: Snowflake Fractal #February 4, 2013 #1. Program draws a snowflake fractal depending on the user-specified fractal order. #2. Program fills the snowflake with a certain user-specified color. import turtle,Tkinter order=int(raw_input("What order fractal would you like? ")) snowflake_color=ra...
true
1d4b314ca1f36c9e4b84125bbff659cd4fb014ff
mosest/11th-Python
/6.4 - Divisible by 1 to 16.py
1,895
4.15625
4
#Tara Moses #Assignment 6.4: First Number Divisible by 1, 2, ..., 16 #January 29, 2013 #1. Program tests whether a number is divisible by all numbers 1-16. #2. Program outputs first number that satisfies conditions. print("I'll print the first number that is divisible by every number") print("from 1 to 16.") num_to_...
true
7e74ea4cce76fb0be74df39feb492966119031bf
Juan337492/PythonCalculator
/MyCalc.py
1,131
4.28125
4
#Program name: MyCalc #Lab no: 1 #Description: Input two numbers then select operator #Your name: Juan Rodriguez #Date: 06-13-2021 title = "My Calculator" choice = "y" while (choice == 'y'): num1 = int(input("Enter Number 1: ")) num2 = int(input("Enter Number 2: ")) print("Please select operation to be per...
true
889b5fd7a45c3666c29b8eda1efaec1f366fc960
harperpack/Harper-s-Practice-Repository
/list_practice_4.py
1,278
4.59375
5
# Still practicing with lists, from Python Crash Course locations = ["japan", "korea", "vietnam", "cambodia", "new zealand"] print (locations) print ("\n") # Adjust each item in the list to be capitalized for location in locations: locations.remove(location) location = location.title() locations.insert...
true