blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
e31e1faec48a064176ad9dba34ed13ba8d263272
SaratM34/CSEE5590-490-Python-and-DL-SP2018
/Python Lab Assignment 1/Source/Q2.py
771
4.4375
4
# Taking input from the user list1 = input("Enter Sentence: ").split(" ") # Function for evaluating the sentence def give_sentence(list1): # Declaring empty list list2 = [] #Print middle words in a sentence print("Middle Words of the Sentence are: "+list1[len(list1)//2], list1[(len(list1)//2)+1]) ...
true
b66e53fcea2e0232c032ed701e780a9846377322
ashiifi/basic-encryption
/encryption.py
2,527
4.40625
4
""" Basic Encryption Project: encryption(S,n) takes in a string and a number. It then moves each letter in the string n amount of times through the alphabet. In this way, 'encrypting' the string then decryption(W) takes in the encrypted string with the n at the end of it. like "helloworld1" """ def encryption(S, n): ...
true
b2a7a14ccf32ece134f0d20b577fc3fcb6b4a132
brittCommit/lab_word_count
/wordcount.py
831
4.21875
4
# put your code here. import sys def get_word_count(file_name): """Will return word count of a given text file. user will enter python3 wordcount.py 'anytextfilehere' on the command line to run the code """ text_file = open(sys.argv[1]) word_count = {} special_charac...
true
b8397d36b580077337a794991bf083c2003222a6
EgorKurito/little_projects
/NumberGame.py
1,228
4.1875
4
import random # главная функция игры def game(): # генерация случайного числа от 1 до 10 secret_num = random.randint(1, 10) # Список чисел пользователя guesses = [] while len(guesses) < 3: # проверка того, что пользователь ввел число try: # считывание числа пользовател...
false
22f8f3f61f63a9c1a0c174761c56bfd621a4c915
AnabellJimenez/SQL_python_script
/data_display.py
1,395
4.34375
4
import sqlite3 '''Python file to enter sql code into command line and generate a csv file with the information from the: fertility SQL DB ''' from Database_model import Database import requests import csv #open sqlite3 connection def db_open(filename): return sqlite3.connect(filename) #close sqlite3 connection def ...
true
f95eb88f8b5ae743155b8d3b55389c6d8686cfe2
ravisjoshi/python_snippets
/Array/SearchInsertPosition.py
801
4.15625
4
""" 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. You may assume no duplicates in the array. Input: [1,3,5,6], 5 / Output: 2 Input: [1,3,5,6], 2 / Output: 1 Input: [1,3,5,6], 7 / Output: 4 Input: [1,3,5,6]...
true
0334ea3d2d970823df4f5b66f1cfc5855d972206
ravisjoshi/python_snippets
/Basics-3/ConstructTheRectangle.py
2,118
4.15625
4
""" For a web developer, it is very important to know how to design a web page's size. So, given a specific rectangular web page’s area, your job by now is to design a rectangular web page, whose length L and width W satisfy the following requirements: 1. The area of the rectangular web page you designed must equal to ...
true
272a9925a7e7c9fa671779a87354cac682c8e379
ravisjoshi/python_snippets
/Strings/validateParenthesis.py
1,217
4.40625
4
""" Given a string containing only three types of characters: '(', ')' and '*', write a function to check whether this string is valid. We define the validity of a string by these rules: Any left parenthesis '(' must have a corresponding right parenthesis ')'. Any right parenthesis ')' must have a correspondin...
true
3a2ab445be28e3da8491cc57473ba43252435d4a
ravisjoshi/python_snippets
/Strings/LongestUncommonSubsequenceI.py
1,496
4.21875
4
""" Given two strings, you need to find the longest uncommon subsequence of this two strings. The longest uncommon subsequence is defined as the longest subsequence of one of these strings and this subsequence should not be any subsequence of the other string. A subsequence is a sequence that can be derived from one se...
true
dc52061454014fea26d67bd88c9c4a34f5bdd17c
ravisjoshi/python_snippets
/DataStructure/sorting/quickSort.py
854
4.1875
4
""" Quick Sort: https://en.wikipedia.org/wiki/Quicksort Ref: https://www.youtube.com/watch?v=1Mx5pEeTp3A https://www.youtube.com/watch?v=RFyLsF9y83c """ from random import randint def quick_sort(arr): if len(arr) <= 1: return arr left, equal, right = [], [], [] pivot = arr[randint(0, len(arr)-1)] fo...
true
03670d974ef18610084e94c1e19573c55e060cdc
ravisjoshi/python_snippets
/DataStructure/StackAndQueue/MaximumElement.py
1,417
4.3125
4
""" You have an empty sequence, and you will be given N queries. Each query is one of these three types: 1 -Push the element x into the stack. 2 -Delete the element present at the top of the stack. 3 -Print the maximum element in the stack. Input Format: The first line of input contains an integer N. The next line...
true
848696aadc4c2889406f5b2f1c61c47adb09f41d
ravisjoshi/python_snippets
/ProjectEuler/Basics-0/009-SpecialPythagoreanTriplet.py
540
4.46875
4
""" A Pythagorean triplet is a set of three natural numbers, a < b < c, for which, a^2 + b^2 = c^2 For example, 3^2 + 4^2 = 9 + 16 = 25 = 5^2. There exists exactly one Pythagorean triplet for which a + b + c = 1000. Find the product abc. """ def pythagoreanTriplet(num): for a in range(1, num//2): for b in ...
true
24b03adda55bc74c4365e93ecf529f3cc1c4453d
ravisjoshi/python_snippets
/Permutation-Combination/PermutationAndCombination.py
879
4.3125
4
""" "My fruit salad is a combination of apples, grapes and bananas" We don't care what order the fruits are in, they could also be "bananas, grapes and apples" or "grapes, apples and bananas", its the same fruit salad. "The combination to the safe is 472". Now we do care about the order. "724" won't work, nor will "247...
true
c90e7d6f56a990f373775438722f91d821f1ff1f
ravisjoshi/python_snippets
/Basics-2/NumberOfDaysBetweenTwoDates.py
815
4.21875
4
""" Write a program to count the number of days between two dates. The two dates are given as strings, their format is YYYY-MM-DD as shown in the examples. Input: date1 = "2019-06-29", date2 = "2019-06-30" / Output: 1 Input: date1 = "2020-01-15", date2 = "2019-12-31" / Output: 15 Constraints: The given dates are ...
true
228e9868f9142aec935642cae53376452d296029
monreyes/SelWebDriver
/PythonProj1/Sec3-UnderstandingVariablesAndDataTypes/319-StringMethods-Part2/string-methods2.py
404
4.3125
4
""" Examples to show available string methods in python """ # Replace Method a = "1abc2abc3abc4abc" print(a.replace('abc', 'ABC')) #print(a.upper()) # another way to convert if all is need to upper case (or a.lower if all needed to be in lower case) # Sub-Strings # starting index is inclusive # Ending index is exclus...
true
902b77933c6d369a13fa8963737cde0a22c0d01b
monreyes/SelWebDriver
/PythonProj1/Sec3-UnderstandingVariablesAndDataTypes/314-Numbers-ExponentiationAndModulo/numbers_operations.py
427
4.28125
4
# This is a one line comment # Exponentiation exponents = 10**2 print(exponents) """ this is a multi line comment modulo - returns the remainder """ a=100 b=3 remainder = a % b print("Getting the modulo of " + str(a)+ " % "+ str(b) + " is just like getting the remainder integer when " + str(a) +"...
true
e0e58817c9c9c0f193702530713de5bdc9755ec9
monreyes/SelWebDriver
/PythonProj1/Sec3-UnderstandingVariablesAndDataTypes/321-StringsFormating/strings_formatting.py
314
4.25
4
""" Examples to show how string formatting works in python """ city = "nyc" dine = "alingdosya" event = "show" #dine = "alingdosya" print("Welcome to "+city+" and enjoy the "+event+", dont forget to eat at "+dine ) print("Welcome to %s and enjoy the %s, dont forget to eat at %s" % (city,event,dine))
false
ddb4a47288b73951542d6c1aa3854b7c3846cf9c
DysphoricUnicorn/CodingChallenges
/extra_char_finder.py
1,630
4.3125
4
""" This is my solution to the interview question at https://www.careercup.com/question?id=5101712088498176 The exercise was to write a script that, when given two strings that are the same except that one string has an extra character, prints out that character. """ import sys def find_extra_char(longer_string, shor...
true
6a563dbae7b8cf7a46621ba9013275c2856ffc95
pratikmallya/interview_questions
/sorting/insertion_sort.py
1,011
4.34375
4
""" Insertion Sort Pick lowest element, push it to the front of the list This will be an in-place sort. Why? Because that's a little more complicated. """ import unittest from random import sample from copy import deepcopy class TestAlg(unittest.TestCase): def test_case_1(self): v = [10, 9, 8, 7, 6, 5, ...
true
4206e176b23841534c80170b24ca94ee87170c1a
navnathsatre/Python-pyCharm
/BasicOprations.py
580
4.25
4
num1=int(input("Enter the value for num1 ")) num2=int(input("Enter the value for num2 ")) #num1=568 #num2=64 add=num1+num2 multi=num1*num2 sub=num1-num2 div=num1/num2 pow=num1**num2 """print("addition of num1 and num2 is:-",add) print("multiplication of num1 and num2 is:-",multi) print("substraction of num1 ...
true
147560dd844918b281b381aedec10aac292711e6
navnathsatre/Python-pyCharm
/pyFunc_3.py
301
4.1875
4
# Factorial of number # 5! = 5*4*3*2*1 #1! = 0 #0! = 0 def iterFactorial(num): result = 1 for item in range(1, num+1): result = result*item return result n = int(input("Enter the number: ")) out = iterFactorial(n) print("Factorial of {} is {} ".format(n, out))
true
dc8d1e68476d077ab36ca4aece654e6ac5ef63bb
RyanLongRoad/Records
/Test scores.py
745
4.15625
4
#Ryan Cox #29/01/15 #Store and display students test scores #Blue print class studentMarks: def __init__(self): self.testScore = "-" self.studentName = "-" #main program def create_record(): new_studentMarks = studentMarks def enter_enformation(): studentMarks...
true
3cdcc8c5f51e8b0813fad7ad93b09331af801b9a
tamkevindo97/Runestone-Academy-Exercises
/longest_word_dict.py
456
4.28125
4
import string def longest_word(text): text.translate(str.maketrans('', '', string.punctuation)) list_text = list(text.split()) dictionary = {} for aChar in list_text: dictionary.update({aChar: len(aChar)}) max_key = max(dictionary, key=dictionary.get) print(dictionary) r...
true
cf714d1796d56fe211f62161b158821164121c43
Rajat986/Python-Learning
/nnum.py
232
4.125
4
a=[] n=int(input("Enter number of elements:")) for i in range(n): b=int(input("Enter element:")) a.append(b) l=a[0] #print(a[0]) for i in range(n): if (l<a[i]): l=a[i] print("Largest element is:",l)
false
08f8761330af9c9dccb0ed64557e1b45516b2bc4
PacktPublishing/Learn-Python-Programming-Second-Edition
/Chapter01/ch1/scopes3.py
450
4.21875
4
# Local, Enclosing and Global def enclosing_func(): m = 13 def local(): # m doesn't belong to the scope defined by the local # function so Python will keep looking into the next # enclosing scope. This time m is found in the enclosing # scope print(m, 'printing from th...
true
ac9ea2d72c9ff6c204e1da79909827b6dee8edce
shdx8/dtwrhs
/D01/lat1.py
376
4.28125
4
# Buat list untuk menampung nama-nama teman my_friends = ["Anggun", "Dian", "Agung", "Adi", "Adam"] # Tampilkan isi list my_friends dengan nomer indeks 3 print ("Isi my_friends indeks ke-3 adalah: {}".format(my_friends[3])) print() # Tampilkan semua daftar teman print ("Semua teman: {} ada orang".format(len(my_friends...
false
d19cb3e849ab5d6e7d43843a000d24992e0a3b22
llewyn-jh/codingdojang
/calculate_trigonometric_function.py
1,046
4.28125
4
"""Calculate cosine and sine funtions in person""" import math def calculate_trigonometric_function(radian_x: float) -> float: """This function refer to Taylor's theorm. A remainder for cos or sin at radian_x follows Cauchy's remainder. The function has 2 steps. Step1 get a degree of Taylor polynomial...
true
e78bb6f14e5aa6a3fc8e765ac206b458bcaa2fb3
sirobhushanamsreenath/DataStructures
/Stacks/stack.py
1,026
4.21875
4
# Implementation of stack data structure using linkedlist class Node: def __init__(self, data=None, next=None): self.next = next self.data = data def has_next(self): return self.next != None class Stack: def __init__(self, top=None): self.top = top def print_stack(s...
true
c33c1e6d9251779cf6f7f8484d8e431575e8d1fa
ronshuvy/IntroToCS-Course-Projects
/Ex2 - Math/shapes.py
1,529
4.46875
4
# FILE : shapes.py # WRITER : Ron Shuvy , ronshuvy , 206330193 # EXERCISE : intro2cs1 2019 import math def shape_area(): """ Calculates the area of a circle/rectangle/triangle (Input from user) :return: the area of a shape :rtype: float """ def circle_area(r): """ Calculate...
true
e3a613de2b32756b5a6bad7846b1db69cd134bab
SonnyTosco/HTML-Assignments
/Python/sonnytosco_pythonoop_bike.py
1,603
4.3125
4
class Bike(object): def __init__(self, price,max_speed): self.price=price self.max_speed=max_speed self.miles=0 print "Created a new bike" def displayInfo(self): print "Bike's price:"+ str(self.price) print "Bike's max speed:"+str(self.max_speed)+'mph' pri...
true
13ff32648e515107376972672ac74737c6670379
HanaAuana/PyWorld
/DNA.py
2,807
4.21875
4
#Michael Lim CS431 Fall 2013 import random # A class to hold a binary string representing the DNA of an organism class DNA(): #Takes an int representing the number of genes, and possibly an existing genotype to use def __init__(self, numGenes, existingGenes): self.numGenes = numGenes #If a g...
true
697f05adc3fd045a5d8b4757ba1ceae1a92de41c
DrewStanger/pset7-houses
/import.py
1,595
4.375
4
from sys import argv, exit from cs50 import SQL import csv # gives access to the db. db = SQL("sqlite:///students.db") # Import CSV file as a command line arg if len(argv) != 2: # incorrect number print error and exit print(f"Error there should be 1 argv, you have {argv}") exit(1) # assume CSV file e...
true
b982d5403b5334baa6e3ec0af46dee88ac765ead
royanusree17/royanusree
/for-3.py
240
4.15625
4
numbers = [1,2,3,4,5,6,7,8,9] odd_count=0 even_count=0 for a in numbers: if a % 2: odd_count+=1 else: even_count+=1 print("total even numbers is:",even_count) print("total odd numbers is:",odd_count)
false
0606a46baee937e230d7ae503a69c4724957c3d0
elaineli/ElaineHomework
/Justin/hw2.py
834
4.125
4
ages = { "Peter": 10, "Isabel": 11, "Anna": 9, "Thomas": 10, "Bob": 10, "Joseph": 11, "Maria": 12, "Gabriel": 10, } # 1 find the number of students numstudents = len(ages) print(numstudents) # 2 receives ages and returns average def averageAge(ages): sum = 0 for i in ages.values(): sum += i lengt...
true
8e472f11b1d5e9c6d3cec5500c8fb2229f3a6641
Kakadiyaraj/Leetcode-Solutions
/singalString.py
539
4.21875
4
#Write a program that reads names of two python files and strips the extension. The filenames are then concatenated to form a single string. The program then prints 'True' if the newly generated string is a palindrome, or prints 'False' otherwise. name1 = input('Enter a first file name : ') name2 = input('Enter a seco...
true
55a870349405f243b9a7b6fad1a4a27c82d9017a
rohitgit7/Ethans_Python
/Class4_[13-10-2018]/dictionary.py
2,117
4.40625
4
#Dictionary is a collection which is unordered, changeable and indexed data = { 'name' : 'Rohit', 'roll_no' : 20, #will be overriden by last key value 'city' : 'Pune', 'roll_no' : 34, 2 : 234} #dict() is a constructor too print data print "type(data)", type(data) data['name'] = 'India' data['call'] = 12345...
true
a8c836841bb5422473a60ffdee9b09f1be7e49ac
rohitgit7/Ethans_Python
/Class12_[01-12-2018]/regex.py
567
4.15625
4
import re #match() checks for a match only at the beginning of the string #while search() checks for a match anywhere in the string var = "This is a regex with is repeated" a = re.match(r'(.*) is (.*)',var) s = re.search(r'(.*) is (.*)',var) print a print a.group() print a.group(1) print a.group(2) print s.group() p...
false
7c9ce41e8653586ddd1e030039f58924447fc038
rohitgit7/Ethans_Python
/Class5_[14-10-2018]/Conditions.py
596
4.15625
4
#0 = False #non-zero are True name1 = raw_input("Enter name1:") name2 = raw_input("Enter name2:") if name1 != name2: print "Names are not same" elif name1=='Rohit': print "Name is Rohit" else: print "Names are same" stud = {1:{'Name':'Prakash','boy':True,'girl':False}, 2:{'Name':'Pooja','boy':False,'girl':True}}...
false
afe039a8f713e6a13372d2de91ec8c0d972a3d6d
gwlilabmit/Ram_Y_complex
/msa/msas_with_bad_scores/daca/base_complement.py
1,870
4.3125
4
#sequence = raw_input("Enter the sequence you'd like the complement of: \n") #seqtype = raw_input("Is this DNA or RNA? \n") sequence = '' seqtype = 'DNA' def seqcomplement(sequence, seqtype): complement = '' for i in range(len(sequence)): char = sequence[i] if char == 'A' or char == 'a': if 'R' in seqtype o...
true
5eead0bd31ab85a27925a22a450abc5eeff8f689
gayathrib17/pythonpractice
/IdentifyNumber.py
1,356
4.40625
4
# Program to input from user and validate while True: try: # try is used to catch any errors for the input validation into float num = int(input("Please input a integer between -9999 and 9999: ")) except ValueError: # ValueError is raised when we are attempting to convert a non numeric string into floa...
true
1110b8b86c71d30e8e220e005cc60ac2c3ce546a
oscarhuang1212/Leecode
/LeetCode#073_Set_Matrix_Zeroes.py
2,350
4.15625
4
# File name: LeetCode#73_Set_Matrix_Zeroes.py # Author: Oscar Huang # Description: Given a m x n matrix, if an element is 0, set its entire row and column to 0. Do it in-place. # # Example 1: # Input: # [ # [1,1,1], # [1,0,1], # [1,1,1] # ] # Outp...
true
2392192820c230c919b684c3d2d9ba92b8ca4d59
Gt-gih/holbertonschool-higher_level_programming
/0x07-python-test_driven_development/0-add_integer.py
594
4.25
4
#!/usr/bin/python3 """ Module with function that add two integers """ def add_integer(a, b=98): """Function that add two numbers Raises: TypeError: a parameter must be integer type TypeError: b parameter must be integer type Args: a (int): The first parameter. b (int):...
true
3b5f8c3e6f1bd65ba15d4af55840ef50afae0ffe
Gt-gih/holbertonschool-higher_level_programming
/0x04-python-more_data_structures/2-uniq_add.py
362
4.1875
4
#!/usr/bin/python3 def uniq_add(my_list=[]): # new list new_list = [] for element in my_list: # checking element not exist in list 🔄 if element not in new_list: new_list.append(element) result = 0 # adding each element in list into result 🔴 for item in new_list: ...
true
5396b8418cf7c78edbd8f764607077eb23fbf556
jaseela65/python_newPrgm
/create an empty list,set,tuple,dictionary.py
1,200
4.21875
4
# Python program to make an empty list a=[] print("values of a:",a) print(" \Type of a :",type(a)) print("Length of a :",len(a)) #output values of a: [] Type of a : <class 'list'> Length of a : 0 .......................................................... # Python program to make an empty tuple ...
false
e047b0eeda1e934eebcef822d70a9403f30f7eec
ngchrbn/DS-Roadmap
/DS Code/1. Programming/Python/Projects/banking_system.py
1,217
4.28125
4
""" Banking System using OOP: ==> Holds details about a user ==> Has a function to show user details ==> Child class : Bank ==> Stores details about the account balance ==> Stores details about the amount ==> Allows for deposits, withdrawals, and view balance """ class User: def __init__(self, name, age, gender...
true
99b2328f91fc4677b052733546c480604cbcf4c2
RaadUH/RBARNETTCIS2348
/homework_1.py
752
4.125
4
#Raad Barnett 1231583 current_date = input("Enter the current date in (mm/dd/yyyy)") date_of_birth = input("Enter the date of birth in (mm/dd/yyyy)") cur_month = int(current_date.split("/")[0]) cur_day = int(current_date.split("/")[1]) cur_year = int(current_date.split("/")[2]) birth_month = int(date_of_birth.split("...
false
cb217a8a547a07eb1c02e065e9a0db8416ffd117
shaniajain/hello-world
/ShaniaJainLab3.py
2,792
4.15625
4
############################################################################### # CS 21A Python Programming: Lab #3 # Name: Shania Jain # Description: Password Verification Program # Filename: ShaniaJainLab3.py # Date: 07/25/17 ############################################################################### def main()...
true
0f504d31e78ec4dd3ed8bd52d3fe690a9475fbc0
fg885436fg/python
/main/1/ifelse.py
344
4.25
4
height = float(input('please enter your height: ')); weight = float(input('please enter your weight: ')); bmi = weight / (height * height); if bmi < 18.5: print("过轻") elif 18.5 <= bmi <= 25: print("正常") elif 25 <= bmi <= 28: print("过重") elif 28 <= bmi <= 32: print("肥胖") elif bmi > 32: print("严重肥胖")
false
15312026ea5140058f5d609559994b23a4bfaaaa
JackShang94/BasicStudy
/DeepDiveIntoPython/Day02/Strings.py
1,578
4.34375
4
# string formatting ## method 1 text = 'Hello' text2 = 'World' print('%s' % text) print('...%s...%s' % (text,text2)) ## method 2 text = 'Hello' print(f'...{text}...') ## method 3 text = 'Hello' print('...{:s}...'.format(text)) print('{}'.format(text)) print('{},{}'.format('one','two','three')) ## different paramet...
false
ce0198d5caa2eb033fb1b4c40198232063d0de38
asiftandel96/Python-Implementation
/LambdaFunctions.py
2,580
4.40625
4
""" Python Lambda Functions/Anonymous Functions.Anonymous function are those function which are without name.""" # Defining a Normal functions. def addition_num(a, b): c = a * b print(c) addition_num(2, 42) # Using A Lambda # Syntax lambda arguments:expression # Note-(Lambda Function can take si...
true
b2b8e0d4fdf58e5da673a45d4ce894de37e3aec0
rp927/05-Python-Programming
/question_9.py
221
4.34375
4
'''Celsius to Fahrenheit''' '''User input''' celsius = int(input("Enter a temperature to convert to fahrenheit:")) '''Output''' print(F"{celsius} degrees celsius is equal to {(9/5)*celsius + 32:.2f} degrees fahrenheit")
false
413f32f1367a8cbf5183add9771d598e630f9534
amarinas/algo
/chapter_1_fundamentals/leapyear.py
484
4.21875
4
# write a function that determines whether a given year is a leap year # if the year is divisible by four, its a leap year # unless its divisible by 100 # if it is divisible by 400 than it is def leapyear(year): if year % 4 == 0: print "it is a leap year" elif year % 100 ==0: print "not a leap...
true
ef06ee1de6b838599b98c1bab5883c595086f514
amarinas/algo
/Hack_rank_algo/writefunction.py
304
4.1875
4
#Determine if a year is a leap yesar def is_leap(year): leap = False #condition for a leap year if year % 4 == 0 and year % 400 == 0 or year % 100 != 0: return True #return leap if the above condition is false return leap year = int(raw_input()) print is_leap(year)
true
9554a30f82c858f0aacab04102ba43a7f7057f02
amarinas/algo
/random_algo_exercise/strings_integers.py
208
4.15625
4
# Read a string,S , and print its integer value; if S cannot be converted to an integer, print Bad String import sys S = raw_input().strip() try: print(int(S)) except ValueError: print("Bad String")
true
096abdbc6c7a049bbfbc7c8afc516bad0ec5d022
amarinas/algo
/PlatformAlgo/reversing.py
474
4.65625
5
#Given an array X of multiple values (e.g. [-3,5,1,3,2,10]), write a program that reverses the values in the array. Once your program is done X should be in the reserved order. Do this without creating a temporary array. Also, do NOT use the reverse method but find a way to reverse the values in the array (HINT: swa...
true
f9bd0cca25a8e163eb84c490e44fc305f3e1dc85
amarinas/algo
/PlatformAlgo/square_value.py
477
4.21875
4
#Given an array x (e.g. [1,5, 10, -2]), create an algorithm (sets of instructions) that squares each value in the array. When the program is done x should have values that have been squared (e.g. [1, 25, 100, 4]). You're not to use any of the pre-built function in Javascript. You could for example square the value b...
true
7f90da219ab5807749f17964bdd7b1ff78b3c1eb
amarinas/algo
/random_algo_exercise/arrays_day7.py
302
4.125
4
# Given an array, A, of N integers, print A's elements in reverse order as a single line of space-separated numbers. from __future__ import print_function import sys n = int(raw_input().strip()) arr = map(int,raw_input().strip().split(' ')) arr.reverse() for num in arr: print(num + " ", end='')
true
113abd3f4d90aa0b95d135b2b7928b6400738fa1
amarinas/algo
/PlatformAlgo/iterate_array.py
394
4.3125
4
#Given an array X say [1,3,5,7,9,13], write a program that would iterate through each member of the array and print each value on the screen. Being able to loop through each member of the array is extremely important. Do this over and over (under 2 minutes) before moving on to the next algorithm challenge. def Itera...
true
a06208c839a3331629c2116f667e73a693dc62a9
chyidl/chyidlTutorial
/root/os/DSAA/DataStructuresAndAlgorithms/python/sort_selection_array_implement.py
1,878
4.34375
4
#! /usr/bin/env python3 # -*- coding: utf-8 -*- # # sort_selection_array_implement.py # python # # 🎂"Here's to the crazy ones. The misfits. The rebels. # The troublemakers. The round pegs in the square holes. # The ones who see things differently. They're not found # of rules. And they have no respect for the status q...
true
3b2d4f6855512f17e98d393348cdf39f855ab739
lstobie/CP1404_practicals
/prac_03/ASCII.py
612
4.125
4
def main(): LOWER_LIMIT = 33 UPPER_LIMIT = 127 char = input("Enter a character: ") print("The ASCII code for {} is {}".format(char, ord(char))) cord = int(input("Enter a number between {} and {}: ".format(LOWER_LIMIT, UPPER_LIMIT))) if LOWER_LIMIT <= cord <= UPPER_LIMIT: print("The chara...
true
fa831333ccba3c9f683f4388160af0e640655d1b
bluisalima/Solyd-Python
/aula5.py
548
4.28125
4
''' Exercício - Aula 5: Faça um programa que leia a quantidade de pessoas que serão convidadas para uma festa. Após isso o programa irá perguntar o nome de todas as pessoas e colocar numa lista de convidados. Imprima todos os nomes da lista. ''' numero_convidados = input("Número de pessoas convidadas: ") convidados = ...
false
f607d1a6bb37486172a511d848657e146b3b104d
lzl813/Python_dataming
/python01/02/02.py
412
4.25
4
#创建列表 a = list("abc") print(a) #替换指定序列 a[1] = "5" print(a) #删除一个序列 del a[1] print(a) #追加 a.append("def") print(a) #链表的添加 a.extend(a) print(a) #链表的插入 a.insert(2,"kf") print(a) #删除指定序列的对象 a.pop(2) print(a) #链表的复制 s = a.copy() print(s) #链表的反转 s2 = a.reverse() print(s2) #链表排序 s3 = [2, 3, 4, 0] s3.sort() print(s3)
false
967bb21482280ffe1eff1b09ee403dcaac27858d
alexpsimone/other-practice
/repls/anagram_finder.py
2,072
4.1875
4
# anagram finder # write a function that takes two strings and returns whether or not they are anagrams # abc cab -> true # abc abc -> true # abc abd -> False # '' '' -> True # abc1 1abc -> True # abcd abc -> False # numbers and letters, no spaces, any length strings def anagram(x, y): # if the stri...
true
bb40fb86a454d0617480ae24c842a1cd91ca9c7c
erijones/phs
/python/intro/prime_finder.py
1,815
4.40625
4
#!/usr/bin/python3 # This program runs as ./prime_finder (with correct permissions), but # incorrectly! The program's goal is to list the prime numbers below a certain # number using the Sieve of Eratosthenes, discovered around 200 BC. # Run the file, and mess around with the testing area below. Debug and # troublesho...
true
4885d8d60b7b2245f2bc4c8d398a66e26a5620e9
noehoro/Python-Data-Structures-and-Algorithms
/Recursion/recursiveMultiply.py
349
4.15625
4
def iterative_multiply(x, y): results = 0 for i in range(y): results += x return results def recursive_multiply(x, y): # This cuts down on the total number of # recursive calls: if y == 0: return 0 return x + recursive_multiply(x, y - 1) x = 500 y = 2000 print(x * y) pri...
true
9ea9de95112cbcf5d0c6dc1e87833c67b9602bf1
prince6635/expert-python-programming
/syntax_best_practices/coroutines.py
2,417
4.1875
4
""" Coroutines: A coroutine is a function that can be suspended and resumed, and can have multiple entry points. For example, each coroutine consumes or produces data, then pauses until other data are passed along. PEP 342 that initiated the new behavior of generators also provides a full example on ho...
true
297be99001229c022c8cdeb10122df55491d401c
zackbrienza/fantasy-football
/sorting.py
1,399
4.1875
4
#Scott Dickson #Practice writing sorting algorithms import random #Also as expected def quicksort(arr): n = len(arr) if n == 1 or n == 0: return arr elif n == 2: return arr if arr[1] > arr[0] else [arr[1],arr[0]] else: splitter = arr[random.randrange(n)] right = [] ...
false
98aefb8c8ae08939ef877e268bfc10a54a0be896
alancyao/fun-times
/Algorithms/reverse_contiguous_subset_to_sort.py
794
4.21875
4
#!/usr/bin/env python3 """ Problem description: You have an array of n distinct integers. Determine whether it is possible to sort the array by reversing exactly one contiguous segment of the array. For example, 1 [4 3 2] 5 => 1 [2 3 4] 5. """ """ Some variables for testing """ possible = [1, 2, 6, 5, 4, 3, 7, 8] imp...
true
0e0bbc7c9d542fe1967d7b1fdd36cda4548bf5f7
nicklambson/pcap
/class/subclass2.py
460
4.28125
4
class A: def __init__(self): self.a = 1 class B(A): def __init__(self): # super().__init__() A.__init__(self) # self.a = 2 self.b = 3 # use super() to access the methods of the parent class # or A.__init__(self) # use super().__init__() to initialize from the parent cla...
true
3123e526b96d7aa2d5eaaa3e22bc676e127f9307
nicklambson/pcap
/exceptions/which_exception.py
419
4.125
4
''' try: raise Exception except: print("c") except BaseException: print("a") except Exception: print("b") ''' # error: default except: must be last try: raise Exception except BaseException: print("a") except Exception: print("b") except: print("c") # a try: raise Exception excep...
true
e616966a28dbd8bbd905ecba525b13c87ce2980d
deelm7478/CTI110
/P4T2_BugCollector_MathewDeel.py
602
4.3125
4
# Collects and displays the number of bugs collected. # 10/15/18 # CTI-110 P4T2 - Bug Collector # Mathew Deel # def main(): #Initialize the accumulator total = 0 #Get the bugs collected for each day. for day in range(1, 6): #Prompt user for amount of bugs that day print('E...
true
f91daa21904b1c8272e2eaa69f2b416cd7942870
deelm7478/CTI110
/P4T1a_Deel.py
852
4.21875
4
# A program that draws both a square and a triangle # 10/23/18 # CTI-110 P4T1a: Shapes # Mathew Deel # def main(): #Import function import turtle #Specify shapes and playground win = turtle.Screen() s = turtle.Turtle() t = turtle.Turtle() #Specify pen characteristics for tr...
false
9583849c3077e5aeefc86c503f69043286d0edf9
amit70/Python-Interview-Examples
/isPower2.py
481
4.28125
4
#Given an integer, write a function to determine if it is a power of two. def isPower(n): # Base case if (n <= 1): return True # Try all numbers from 2 to sqrt(n) # as base for x in range(2, (int)(math.sqrt(n)) + 1): p = x # Keep multiplying p with x while # is sm...
true
9155292ee252ccbf0682cca7df6a321f227d0d34
kylebejel/Vigenere-Cipher
/vigenere.py
663
4.125
4
def encrypt(message, key): alph = ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"] key_index = 0 new_message = "" for ch in message: new_ch = alph[(alph.index(ch) + (26 - alph.index(key[key_index])))%26] ...
false
134d690ef5727cce192900151ddb83c8d67b73b8
jananee009/DataStructures_And_Algorithms
/Arrays_And_Strings/ReverseString.py
1,183
4.6875
5
# Implement a program to reverse a string. # Follow up: Write a function to reverse an array of characters in place. "In place" means "without creating a new string in memory." def reverseString(inputStr): reversed = "" for i in range(len(inputStr)-1,-1,-1): reversed = reversed + inputStr[i] return reversed de...
true
d8c39538141f5d4065f9a6c89a0b438d66648a9e
jananee009/DataStructures_And_Algorithms
/Arrays_And_Strings/ReplaceAllSpaces.py
749
4.4375
4
# Write a method to replace all spaces in a string with '%20'. Assume that the string has sufficient space at the end of the string to hold the additional characters # and that you are given the true length of the string. # E.g. Input: "Mr John Smith ", 13 # Output: "Mr%20John%20Smith" def replaceAllSpaces(inpu...
true
f90911ff384b918a697fd987bf4e12b814bbc92c
jananee009/DataStructures_And_Algorithms
/Miscellaneous/Parentheticals.py
1,984
4.125
4
# Write a function that, given a sentence, , finds the position of an opening parenthesis and the corresponding closing parenthesis. # Source: https://www.interviewcake.com/question/python/matching-parens?utm_source=weekly_email&__s=ibuidbvzaa2i67rfb2mc # Approach: 1. Process the string character by character. # We c...
true
89167fe59613bc1eba62d18d09deea19c0bad38f
jananee009/DataStructures_And_Algorithms
/Stacks_And_Queues/Stack.py
1,046
4.25
4
# Write a program to implement a stack (LIFO). Implement the operations : push, pop, peek. class Stack: def __init__(self): self.stack = [] def isEmpty(self): if(len(self.stack)==0): return True else: return False def push(self,element): self.stack.append(element) def pop(self): if(len(self.stac...
true
383821bb30931d9e849a4d0f14c9291eb5c799a8
AndyFlower/PythonFullstackLearnNote
/projects/day10/02 函数的参数.py
1,700
4.125
4
# 形参角度 # 万能参数 def eat(a,b,c,d): print('我请你吃:%s %s %s %s' %(a,b,c,d)) eat('西红柿','黄瓜','葡萄','黄桃') # 急需一种形参,可以接受所有的实参 # 万能参数 *args 约定俗称 args # * 函数定义时, *代表聚合 它将所有的位置参数聚合成一个元祖 赋值给args def eat(*args): print(args) print('我请你吃:%s %s %s %s %s ' %args) eat('西红柿','黄瓜','葡萄','黄桃','红提') # 写一个函数 计算传入的所...
false
95c1d47ade4d105851b29eb1bbacf6231d188fbd
GuND0Wn151/Python_OOP
/13_MagicMethods_1.py
1,670
4.4375
4
#C0d3 n0=13 #made By GuND0Wn151 """ there are some methods in python class Magic methods in Python are the special methods which add "magic" to your class. Magic methods are not meant to be invoked directly by you, but the invocation happens internally from the class on a certain action. """ ...
true
53f18b79d98cfc5fb94bc561d54248cb33c62165
GuND0Wn151/Python_OOP
/10_Getter.py
609
4.28125
4
#C0d3 n0=10 #made By GuND0Wn151 ''' The getattr() method retu the value of the named attribute of an object. If not found, it returns the default value provided to the function. ''' class person: legs=2 hands=2 hair_color='black' def __init__(self,a): self.name=a person1=person("k...
true
28719c5fed80810c43c3376758b82f851f56a05b
DAVIDMIGWI/python
/lesson 3b.py
399
4.15625
4
a = 40 b = 50 c = 500 if a > b: print("A is greater than B") if a > c: print("A is also greater than C") else: print("A is not greater than C") if c > b: print("C is the largest") else: print("A is the largest") else: if b...
true
b84c082c91b1a246fc6160ac1649c39b9a2c97eb
DAVIDMIGWI/python
/lesson 5d. lists in tuples.py
394
4.46875
4
# applying conditional statements in decision making in list/tuples supermarkets = ["naivas", "Carrefour", "turkeys", "nakumatt","quickmat"] for supermarket in supermarkets: print(supermarket) if supermarket == "quickmat": print("ill shop there today") elif supermarket == "naivas": print("...
false
369d0f3e749c5419d5e40d9e41f3db3a43c946b7
jmmiddour/Old-CS-TK
/CS00_Intro_to_Python_1/src/05_lists.py
1,707
4.625
5
# For the exercise, # look up the methods and functions that are available for use with Python lists. # An array can only have one data type, list can have multiple data types. # If you want to add to an array you have to create a new array twice the size of # the one you have, taking up more space. # You need to use...
true
2589aa703538ead00de18c0b828a84f27aeb16c1
jmmiddour/Old-CS-TK
/CS00_Intro_to_Python_1/src/14_cal.py
2,934
4.59375
5
""" The Python standard library's 'calendar' module allows you to render a calendar to your terminal. https://docs.python.org/3.6/library/calendar.html Write a program that accepts user input of the form `14_cal.py [month] [year]` and does the following: - If the user doesn't specify any input, your program should ...
true
d86a00d4050862b4e14da77ed994e90595b5e40a
Paahn/practice_python
/reverse_word_order.py
265
4.34375
4
# 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. a = input("Gimme a string containing multiple words:\n") b = a.split(' ') print(b[::-1])
true
7588d9c2400c665eb0be8ca319c3dc17f03ec568
Paahn/practice_python
/guessing_game.py
997
4.375
4
# Generate a random number between 1 and 9 (including 1 and 9). # Ask the user to guess the number, then tell them whether they guessed too low, # too high, or exactly right. # Keep the game going until the user types “exit” # Keep track of how many guesses the user has taken, and when the game ends, print this out...
true
47717a3918ae9d4522508d3125763b31c3298a4d
elenaozdemir/Python_bootcamp
/Week 1/Day Two/Practicing with lists & functions.py
747
4.53125
5
# practicing with lists and functions # EXAMPLE: Define a function that returns a list of even numbers # between A and B (inclusive) def find_events(A,B): # make an empty list to return to something evens = [] for nums in range (A,B+1): #inclusive if (nums % 2 == 0): evens.append(nums) ...
true
185226e028f27439fa159136cfef3be1d36bad86
darthols/mooc_Python-3
/w1/turtle_fractal.py
825
4.25
4
#!/usr/bin/env python3 # coding: utf8 """ Fractale """ import turtle def left_triangle(length): for i in range(3): turtle.forward(length) turtle.left(120) def fractal_side(length, fractal): if fractal == 0: turtle.forward(length) else: length3 = length / 3. fract...
false
4c5a3b9f23c9910631860938ce17e86c87a31939
SBenkhelfaSparta/eng89_python_basics
/string_casting_concatenation.py
1,567
4.34375
4
# using and managing strings # strings casting # string concatenation # Casting methods # Single and double quotes single_quotes = 'These are single quotes and working perfectly fine!' double_quotes = "These are double quotes also working fine" # print(single_quotes) # print(double_quotes) # concatenation # firs...
true
a8f4d513d0b552b70b9baa5767a2ddad07bb0629
marnyansky/codewars-puzzles-python
/stepik-python-advanced-2021/chapter04_03_unit406261_step10_Pascals_triangle.py
2,254
4.28125
4
""" https://stepik.org/lesson/416753/step/10?thread=solutions&unit=406261 Треугольник Паскаля — бесконечная таблица биномиальных коэффициентов, имеющая треугольную форму. В этом треугольнике на вершине и по бокам стоят единицы. Каждое число равно сумме двух расположенных над ним чисел. 0: 1 1: 1 1 2: 1 2 1 ...
false
95a2ee3b58d7fdf3e0bcc499b37b7bfa59a286b6
Ms-Noxolo/Predict-Team-7
/EskomFunctions/function3.py
591
4.375
4
def date_parser(dates): """ This function returns a list of strings where each element in the returned list contains only the date Example ------- Input: ['2019-11-29 12:50:54', '2019-11-29 12:46:53', '2019-11-29 12:46:10'] Output: ['2019-11-29', '2019-...
true
813a5288fc26121aee0081f4b9ab131a2190e321
aprabhu84/PythonBasics
/Methods and Functions/Level 1/03_Makes_Twenty.py
473
4.15625
4
#MAKES TWENTY: # -- Given two integers, # -- return True if the sum of the integers is 20 # -- or if one of the integers is 20. # -- If not, return False #makes_twenty(20,10) --> True #makes_twenty(12,8) --> True #makes_twenty(2,3) --> False def makes_twenty(number1, number2): int_num1 = int(number1) ...
true
f751e02345f05a8f287ff20671542153c6e88cac
aprabhu84/PythonBasics
/Methods and Functions/Level 2/02_Paper_Doll.py
394
4.15625
4
# PAPER DOLL: Given a string, return a string where for every character in the original there are three characters # paper_doll('Hello') --> 'HHHeeellllllooo' # paper_doll('Mississippi') --> 'MMMiiissssssiiippppppiii' def paper_doll(someString): resultString = "" for pos in range(0,len(someString)): ...
true
4bb645c2831bb073979233c99e028cb59ff39c39
oratusxd/Python-Curso_em_Video
/Mundo_1/Aula7/desafio8.py
354
4.125
4
''' Escreva um programa que leia valor em metros e exiba convetido em centímetros e em milímetros ''' metro = float (input('Coloque o valor em metros: ')) km = metro/1000 hm = metro/100 dam = metro/10 dm = metro*10 cm = metro*100 mm = metro*1000 print(f'{metro} metros medirá:\n{km}km, {hm} hm , {dam} dam\n{d...
false
46be0a96d81cb8c48dc94ab9a2883c6ffdbaddd8
Aleksandraboy/basics
/nesting.py
2,894
4.5
4
# 03/20/21 # 1. A List of Lists # 2. A List of Dictionary # 3. A List in a Dictionary # 4. A Dictionary in a Dictionary print('*** 1. A List of Lists***') countries = ['usa', 'russia', 'spain', 'france'] cities = ['new york', 'moscow', 'barcelona', 'paris'] companies = ['level up', 'abc company', 'ola company'] custo...
true
0f0d4aca3a404655fe2e0e226e831b65d8d18307
XDA-7/boids
/src/vector.py
1,912
4.25
4
"""Vector module""" from math import sqrt, sin, cos class Vector: """2D Vector with operations useful to the program""" def __init__(self, x: float, y: float): self.x_val = x self.y_val = y def __add__(self, other: 'Vector'): return Vector(self.x_val + other.x_val, self.y_val + oth...
false
20127e1855c3307e7b25812eccb46818d7db4609
JoseVteEsteve/Lists
/LI_03.py
289
4.1875
4
#given a list of numbers, find and print all the elements that are greater than the previous element. list = [1,3,7,9,2,4,11,10,8,5,14,16] n = len(list) max = 0 for i in range(n): if list[i] > list[i - 1]: print(str(list[i]) + " is greater than " + str(list[i - 1]))
true
340ae067444d465b6f62d6e512544c76e494130a
sagardspeed2/PythonMiniprojects
/pattern/32123/pattern.py
427
4.15625
4
num = int(input("enter numbers of rows")) # for i in range(1,num+1): # for j in range (1,num-i+1): # print(end=" ") # for j in range (i,0,-1): # print(j,end="") # for j in range (2,i+1): # print(j,end="") # print() for i in range(1, num+1): for j in range(1, num-i+1): pri...
false
4b7f4c2120a385d0387838a7aaf034044be7a790
DUDA18/ProgISD20202-1
/Maria_Eduarda/aula 3/aula3.py
826
4.25
4
import math #Importando Math print("Python") #Declarando variaveis varString="maria" p,l=9,4 escolha=True variavel=list() #printando type e variavel na tela print(varString) print(type(variavel)) print(type(varString)) print(type(p)) print(str(p) + "top" + str(escolha)) #Captando informações e usando a biblioteca m...
false