blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
326e583f3999886edca90c916a7727ec9c1b560f
ankitkumarbrur/information_security_assignment
/3. ceaserCipher.py
1,830
4.21875
4
from collections import defaultdict def frequencyAttack(S): # calculating the length of string & converting the string to uppercase to avoid any snag in frequency attack N, S = (len(S), S.upper()) # List to store the top plain texts plaintext = [] # storing the english letters in th...
true
1a09925dc5cd1400ece9e0427f3bc7be796a3750
majurski/Softuni_Fundamentals
/Functions - Exercise/6-Password-generator.py
632
4.1875
4
def pass_check(text): digits = 0 letter = 0 val_pass = True if len(text) < 6 or len(text) > 10: print(f"Password must be between 6 and 10 characters") val_pass = False for i in text: if i.isdigit(): digits += 1 if i.isalpha(): letter += 1 ...
true
0b23a79d3ca6126b1063364ad0c7b6b64291c75f
Yihhao/python-1000-day
/Day-19/Day-19-start/main.py
1,079
4.1875
4
from turtle import Turtle, Screen import random is_race_on = False screen = Screen() screen.setup(width=500, height=400) user_bet = screen.textinput(title='Make your bet', prompt='Which turtle will win the race? Enter a color: ') color = ['red', 'orange', 'yellow', 'green', 'blue', 'purple'] y_position = [-70, -40, -1...
true
f241f12a331822445db8151ecb397adccee239e2
MichaelBlackwell/SortingAlgoritms
/quickSort.py
973
4.125
4
# Quick Sort # Complexity O(nlogn) for best cases # O(n^2) for average and worst cases def quickSort(inputList): less = [] pivotList = [] more = [] if len(inputList) <= 1: return inputList else: pivot = inputList[0] for i in inputList: if i < pivot: ...
true
5b622a7474cf14a82e340e32ee70a7f385ca2b6c
natepaxton/DiscreteMath
/project_7.py
2,241
4.4375
4
""" The purpose of this program is to perform a binary search within a randomly generated list of integers between 0 and 200. The program will first generate a list of integers using the random generator from project 5, and will sort the list using the insert sort from project 6. Binary searches can only be perform...
true
ba06aeed3043b065a80bd3a4cd219a45325a04c9
djschor/2-SI206Assignments
/sample_db_example.py
2,220
4.3125
4
import sqlite3 conn = sqlite3.connect('music2.db') #makes a connection to the database stored in the #file music.sqlite3 in the current directory, if file doesn't exist, it's created cur = conn.cursor() #cursor is like a file handle that we can se to perform operations on the data stored in the datanase/ calling cur...
true
de19cdc9f55ca301d7e2326e5061e75790ef2cfd
dipen7520/Internship-Akash-Technolabs
/Day-3_Task-3_15 basic_tasks/pract_08_smallest_num.py
314
4.15625
4
number = [] for i in range(1, 3): number.append(int(input(f'Enter the number{i}: '))) if number[0] == number[1]: print(f'{number[0]} and {number[1]} are equal.') elif number[0] > number[1]: print(f'{number[1]} is smaller than {number[0]}.') else: print(f'{number[0]} is smaller than {number[1]}.')
true
a2786297357e1b2bc2461352cffdf735b9c4cc07
gjwei/leetcode-python
/medium/Construct BinaryTreefromInorderandPostorderTraversal.py
1,443
4.125
4
#!/usr/bin/env python # -*- coding: utf-8 -*- """ created by gjwei on 3/25/17 """ # Definition for a binary tree node. # class TreeNode(object): # def __init__(self, x): # self.val = x # self.left = None # # self.right = None from TreeNode import TreeNode class Solution(object): ...
true
88377d4777541d8dba8154fa9baf30dfa02f2a94
gjwei/leetcode-python
/easy/Multiply Strings.py
1,082
4.1875
4
#!/usr/bin/env python # -*- coding: utf-8 -*- """ created by gjwei on 6/1/17 """ """ Given two non-negative integers num1 and num2 represented as strings, return the product of num1 and num2. Note: The length of both num1 and num2 is < 110. Both num1 and num2 contains only digits 0-9. Both num1 and num2 does no...
true
8d8be21db87436ddd8c5fa86c2bda740b006d415
miguelcoria94/AA-Week-17-Python
/range.py
1,223
4.21875
4
print('THREE CASES FOR RANGE') print('A) End Value') # STEP 1: Change the zero in the range to 10 # Notice how "10" is not included in the output for i in range(10): print(i) print('B) Start & End Values') # STEP 2: Code a `for` loop to print numbers 5 through 9 for i in range(5,10): print(i) print...
true
5bd15e45e2299ff7aa3c6a770dca00680200fad9
KevinKupervaser/path_to_glory
/sumseriesavg.py
370
4.1875
4
import math def sumseriesavg(): n = eval(input("How many numbers you want to enter: ")) x = 0 sum = 0 for i in range(n): num = eval(input("Please enter a number: ")) sum += num print("The sum of the amount of numbers is: ", sum) print("The average of this ser...
true
fc743b487be49e660e07bae6b1f702d694425d25
dplyakin/likbez
/algorithms/search.py
652
4.1875
4
"""Search algorithms examples""" def binary_search(source, target): """Binary Search.""" head = 0 tail = len(source) - 1 while head <= tail: mid = (head + tail) // 2 print(f"check {mid} element") value = source[mid] if value > target: tail = mid - 1 ...
true
3220865845138d69ec007418c8fe5f8e4a6dfdf3
Preethikoneti/pychallenges
/InterviewCake/02question.py
1,679
4.125
4
# You have a list of integers, and for each index you want to find the product of every integer except the integer at that index. # Write a function get_products_of_all_ints_except_at_index() that takes a list of integers and returns a list of the products. # # For example, given: # # [1, 7, 3, 4] # # your functio...
true
58a713308555a9e588a06ed87bed6d13e54b2b57
osamudio/python-scripts
/fibonacci_2.py
303
4.1875
4
def fib(n: int) -> None: """ prints the Fibonacci sequence of the first n numbers """ a, b = 0, 1 for _ in range(n): print(a, end=' ') a, b = b, a+b print() return if __name__ == "__main__": n = int(input("please, enter a number: ")) fib(n)
true
5cb0ebf439bd62bb46158e3e94f8be78b8694eb2
mftoy/early_python_studies
/assignment7_1.py
250
4.21875
4
# Use words.txt as the file name fname = input("Enter file name: ") try: fh = open(fname) except: print('Error! Worng file name:',fname) quit() for line in fh: line = line.rstrip() line = line.upper() print(line)
true
df4ec99e18a72b9b81e7c963eb0403df57a17a15
hirara20701/Python
/practice 7.py
247
4.15625
4
'''Create a program that computes for the BMI of a person''' '''Input -> weight, height bmi = 703 * weight/(height * height)''' w = eval(input("Enter weight(kg): ")) h = eval(input("Enter height(m): ")) bmi =(w / (h * h)) print (bmi)
true
a792cb50555f6c54e794c52be11069df9a77bfa5
abcs-ab/Algorithms
/quick_sort.py
2,386
4.3125
4
#!/usr/bin/env python3 """Python quick sort implementation with a comparisons counter. Sorts in place, returns comparisons number. Pivot selection can be done in 4 ways: Always take the first element. Always take the last element. Choose median of 3 elements (first, last and the middle one). Random choice. First 2 m...
true
de087ccadf474dab0b67377d9d9177c477e18752
abcs-ab/Algorithms
/merge_sort.py
2,478
4.1875
4
#!/usr/bin/env python3 """Merge sort implementation with inversions counter. Max inversions number can be defined as n(n-1)/2 where n is a n-element array. """ def merge_sort(alist, inplace=False, print_inv=True, inversions=[0], reset_inv=True): """Merge sort implementation with inversions counter. :param al...
true
a033d6d2d492e64b1d3b14fc0699ca0ace8c7819
Santigio/Daily_Coding
/Calculator/calculator.py
1,139
4.1875
4
Run = True Exit = False while Run: button = int(input("Press 1(add), 2(subtract), 3(divide), 4(multiply)")) User_input = int(input("Enter a number ")) User_input1 = int(input("Enter another number ")) def Addition(user1, user2): return user1 + user2 def Subtration(user1, user2): ...
true
6c02e785a307f4cfc4afe19b6aeb2e7ed4de52ff
conor1982/Python_Module
/plot.py
2,216
4.3125
4
#Conor O'Riordan #Task 8 #Program that displays the plot of functions f(x) = x, g(x) = x^2, h(x) = x^3 #in the range of [0,4] on one set of axes #Matplotlib for plotting #Numpy for arrays import matplotlib.pyplot as plt import numpy as np #variable using Numpy to create an array #Similar to list, last value not inclu...
true
64eb18cb3920698601e94b3426cc97af161c335a
rams4automation/SeleniumPython
/Collections/Set.py
428
4.25
4
thisset = {"apple", "banana", "cherry"} print(thisset) for x in thisset: print(x) # ***************** Access Items if "banana" in thisset: print("banana" in thisset) # ************** Add Items adset= {"apple", "banana", "cherry"} adset.add("Test") print(adset) # ***************** Update Items upset= {...
true
8f06c4da36c95a94ad302cf43b8002a190df4a80
SlickChris95/practicePython
/exercise15.py
604
4.25
4
""" Write a program (using functions!) that asks the user for a long string containing multiple words. Print back to the user the same string, except with the words in backwards order. For example, say I type the string: My name is Michele Then I would see the string: Michele is name My shown back to me. """ de...
true
0ed4fabdc713bfe8004c4f0da3966a4abe383852
abhibalani/data-structures-python
/data_structures/stack.py
1,469
4.375
4
"""Stack implementation in Python""" class Stack: """Class for stack and its methods""" def __init__(self): """Initialize the top of stack to none""" self.top = None def push(self, node): """ Method to push a node into a stack :param node: Node to be pushed ...
true
ab6aa091df7630bf3799053ebce2dcaeab79b6a1
alfozaav/Software_Engineering
/Algorithms/QuickSort.py
470
4.1875
4
# QuickSort in Python def quicksort(arr): if len(arr) < 2: return arr #Base case arrays with 0 or 1 elements are already sorted else: pivot = arr[0] less = [ i for i in arr[1:] if i <= pivot ] #Sub-array of all elementes less than pivot greater = [ i for i in arr[1:] if i > pi...
true
c0184233fc4d65c73110cbe014fed13d705ebd2a
sabdj2020/CSEE-5590---Python-DeepLearning
/ICP3/Class_Emp.py
1,531
4.28125
4
# create class emplyee class employee: emp_count = 0 salary_total = 0 # create the constructor for this class and give attributes value to objects def __init__(self, n, f, s, d): self.name = n self.family = f self.salary = s self.department = d employee.emp_count = em...
true
007496134f811b7a3f7c81fa7b94c687ff02c751
immortal3/Matrix_Inversion
/Main.py
1,273
4.28125
4
""" Program : program gets input of dynamic matrix from user and first it checks for matrix is invertible or not. If matrix is invertible and then it try's to find inverse with RREF algorithms Name : Patel Dipkumar p. Roll No. : 201501070 for LA_Code_Submission_1 Warning : In som...
true
e424bc5b6522bfae9daa47e960f60e419519c22b
steveyttt/python
/flow/if-else-elif/if-elif-else.py
352
4.1875
4
print("enter a name") name = input() #If runs ONCE to check a condition and then performs an action if name == "alice": print('Hi ' + str(name)) elif name == "bobby": print('Hi Bobby, not Hi Alice') elif name == "jimmy": print('Hi jimmy, not Hi Alice') else: print("I dont like you, you are not Alice") ...
true
78459a630f5ee5cc394337519767513df3ef6242
Meenal-goel/assignment_13
/excp.py
2,343
4.375
4
#1.- Name and handle the exception occured in the following program: a=3 try: if a<4: a=a/(a-3) print(a) except Exception as er : print("Name of exception occured is :",er) print("\n") print("*"*25) print("\n") #2- Name and handle the exception occurred in the following program: l=[1,2,3] tr...
true
c0e46b9f2ee0b2fc24d9225a4f41350660153187
dhruvbaid/Project-Euler
/055 - lychrelNumbers.py
1,432
4.1875
4
""" Lychrel Numbers: if we take a number, reverse it, and add the two, we obtian a new number. If we do this repeatedly, sometimes, we end up with a palindrome. If we can never obtain a palindrome, however, the original number is called a Lychrel Number. How many Lychrel Numbers are there below 10,000? Assumptio...
true
2e3da8863fa91f2061d3289f9e8685ffcf182272
tqsclass/edX
/6001x/ps6/finger-exercise.py
2,742
4.125
4
class Queue(object): def __init__(self): self.queue = [] def insert(self,e): self.queue.append(e) #print self.queue def remove(self): if len(self.queue) > 0: e = self.queue[0] del self.queue[0] #print self.queue return e ...
true
57d354ad199b829b0d1131d59c35f32d05e37eac
raj-savaj/MCA
/Python/FinadAll_Ex.py
254
4.21875
4
import re str="The rain in Spain" ##x = re.findall("ai",str) ## ##print(x) #return the List if not match return empty # ~ The Search() Function x = re.search("S",str,re.I); if x : print("Pattern Found") else: print("Not Found")
true
b47b9ab39f79a8e3299c25ef62cf5757839c962e
wardmike/Data-Structures
/Trees/Binary Tree/check_symmetry.py
920
4.28125
4
from tree_node import TreeNode class BinaryTree: # takes two nodes (one for each side of the tree) & recursively calls opposite sides on each # the tree is symmetric if each left from node1 equals a right from node2 and vice versa def isSymmetricRecursive(self, node1: TreeNode, node2: TreeNode) -> bool: ...
true
1ec84c448a4f0c10619c9fe031791de5dfc0cda1
karthika-onebill/python_basics_assignments
/Day1_Assignments/qn11.py
436
4.375
4
# program to print characters at the odd positions first followed by even position characters Input: SOFTWARE Output:OTAESFWR (with and without slice operator) s = "SOFTWARE" # with using slice operator print(s[1:len(s):2]+s[0:len(s):2]) res_odd = "" res_even = "" # without using slice operator for i in range...
true
05dc40f5ef44af0ac34da86d47212157d097c78f
karthika-onebill/python_basics_assignments
/Day2_Assignments/qn1.py
1,132
4.25
4
''' 1) Given an integer,n, perform the following conditional actions: If n is odd, print Weird If n is even and in the inclusive range of 2 to 5, print Not Weird If n is even and in the inclusive range of 6 to 10 , print Weird If n is even and greater than 20 , print Not...
true
c78b0feac93531a61de28148a078c2d3cbddcade
r0ckburn/d_r0ck
/The Modern Python 3 Bootcamp/7 - Guessing Game Mini Project/v2_guessing_game.py
556
4.28125
4
''' starter code ''' import random random_number = random.randint(1,10) # numbers 1-10 # handle user guesses # if the guess correct, tell them they won # otherwise tell them if they are too high or too low # BONUS - let them play again if they want! ''' my code ''' guess = '' while guess != random_number: gu...
true
8fbbb4f84e5776ed71c2d1a5ef1824766112772a
r0ckburn/d_r0ck
/The Modern Python 3 Bootcamp/4 - Boolean and Conditional Logic/getting_user_input.py
562
4.40625
4
# there is a built-in function in Python called "input" that will prompt the user and store the result to a variable name = input("Enter your name here: ") print(name) # you can combine the variable that an end user input something to with a string data = input("What's your favorite color?") print("You said ...
true
f8597697abb74520f782cf91ed5ad66f109bcfc1
r0ckburn/d_r0ck
/The Modern Python 3 Bootcamp/6 - Loops/for_loops_quizzes.py
641
4.34375
4
# what numbers does the following range generate? # range(5,10) print(5,6,7,8,9) # what numbers does the following range generate? # range(3) print(0,1,2) # what is printed out after the following code? # nums = range(1,5) # print(nums) range(1,5) # what numbers does the following range generate? ...
true
66468308d722571298827e4be8077a6b44e803a3
r0ckburn/d_r0ck
/The Modern Python 3 Bootcamp/2 - Numbers and Math/math_quizzes.py
1,405
4.5
4
# How can we add parenthesis to the following expression to make it equal 100? # 1 + 9 * 10 print((1+9)*10) # putting the parenthesis around the 1+9 equations equals 10, which when multiplied by 10 = 100 # What is the result of the following expression? # 2 + 10 * 5 + 3 * 2 print(58) # multiplications occur ...
true
6deace0a5fe8fc79db596281577960d1b9ced540
Jacobo-Arias/Ordenamiento
/counting_sort.py
1,292
4.125
4
# Counting sort in Python programming def countingSort(array): size = len(array) output = [0] * size # Initialize count array count = [0] * size*2 # Store the count of each elements in count array for i in range(0, size): count[array[i]] += 1 # Store the cummulative count fo...
true
a793ee88d44635868f823faa3153e703f71daf05
Inkozi/School
/AI/HelloWorld.py
882
4.1875
4
## ##HOMEWORK # 1 ## ## NAME = CHARLES STEVENSON ## DATE = AUGUST 25, 2016 ## CLASS = Artificial Intelligence TR 8 - 9:20 ## ## ## Description: ## This is the first homework assignment ## where I read a file into a priority queue ## and then outputed to the console by sorting ## the integers using the priority ...
true
652603e6c06ecf9f05d507a0d4607d701fdd4fb9
ruben-lou/design-patterns
/behavioural-patterns/strategy.py
976
4.125
4
import types class Strategy: """The Strategy Pattern class""" def __init__(self, function=None): self.name = "Default Strategy" # If a reference to a function is provided, replace the execute() method with the given function if function: self.execute = types.MethodType(fun...
true
528c81f911302dd6ddea96f0d7738eb967b8fbb9
justiniansiah/10.009-Digital-Word
/Week 8/HW03_Numerical Differentiation.py
728
4.21875
4
from math import * import math #return only the derivative value without rounding #your return value is a float, which is the approximate value of the derivative #Tutor will compute the approximate error based on your return value class Diff(object): def __init__(self,f,h=1E-4): self.f = f self.h =...
true
b3df16f0d17b6d56abfffc73b0de4b1c443b5f12
justiniansiah/10.009-Digital-Word
/00 Finals/2014/2014_Q1.4.py
2,503
4.1875
4
'''Develop a Python class to represent polylines. A polyline is a piecewise linear curve - one can think of it as a series of connected line segments. The polyline class will build upon the two classes below, which represents points and vectors.''' import math class Point2D: def __init__(self, x, y): sel...
true
bddc65022b3e0200140d277f2f3c94f75cfe5690
Persifer/Machine_Learning_Training
/first_algorithm/first_ml_code.py
2,750
4.34375
4
#preloaded dataset that contains information about terrains and prices in Boston from sklearn.datasets import load_boston from sklearn.linear_model import LinearRegression from sklearn.metrics import mean_absolute_error from sklearn.model_selection import train_test_split # the regressor is an algorithm which has, as ...
true
dd9b9f4cfec95542607537b68edc13418fdb4fc3
Naohiro2g/robruzzo_Raspberry-Pi-Projects
/pi-servo.py
2,781
4.21875
4
# Use Raspberry Pi to control Servo Motor motion # Tutorial URL: http://osoyoo.com/?p=937 import RPi.GPIO as GPIO import time import os GPIO.setwarnings(False) # Set the layout for the pin declaration GPIO.setmode(GPIO.BOARD) # The Raspberry Pi pin 11(GPIO 18) connect to servo signal line(yellow wire) # Pin 11 send P...
true
bcbbdc25716defff358f949d7e4be011d9833aa3
SimpleLogic96/cs_problem_sets
/a07_definite_loop/a07_clock.py
2,724
4.21875
4
#Pt II: Simple Clock #Time formatter def format_time(current_hour, current_min): #if current minute is greater than 60 if(current_min > 60): current_hour += 1 current_min = current_min - 60 #if current minute is equal to 60 elif(current_min == 60): current_hour += 1 current_min = 0 #if current minute is...
true
0d81e12471342954d05f0926606c9053d9fba2d4
shinji-python/TaxCalculator
/TaxCalculator.py
849
4.21875
4
def tax_calculator(amount,tax_rate): tax_amount= str(round(amount + (tax_rate*amount),2)) print('Your value including tax is: $',tax_amount) def input_value(): amount = int(input('What is your value amount?')) return amount def input_tax(): tax = float(input('What is your tax rate?')) return t...
true
3d0b170cd47bdeb9a9af3533fe302db476d35bac
brandonlyon24/Python-Projects
/python_if.py
960
4.125
4
num1 = 12 key = False if num1 == 12: if key: print('num1 is equal to 12 and they have the key') else: print('num1 is equal to 12 and they do not have the key') elif num1 < 12: print('num1 is less than 12') else: print('num1 is not equal to 12') a = 100 b = 50 if a > b: p...
true
275f20aa39213a166b62af5bb1ac9db5007ad192
Daredevil2117/DSA_GFG
/Sorting/Gfg Learning/05. Merge Function of Merge Sort.py
1,049
4.28125
4
''' Given three indices low mid and high and an array elements in array from low to mid are sorted and mid+1 to high are sorted. sort these elements from low to high together. ''' def MergeFunction(arr,low,mid,high): n1=mid-low+1;n2=high-mid # Counting number of sorted elements in both the part le...
true
667cc5de2a100c1fe23d3a5cb63b414d78c160e0
Rahul-Kumar-Tiwari/Hactoberfest2020-1
/NumGuessGame.py
1,377
4.15625
4
# Guess_a_number #Script of a game that asks the player to guess the number in specific number of attempts. import random print("What is your name?") #Asking player to enter name. name = str(input()) #Taking input from player. print("Hey " + name + ",I was thinking of a number between 1 to 20.Can you guess it???") ...
true
c61868881bca8ad83ebca3bd0a497651bba16d08
bluezzyy/LearnPython
/Codes/ex18.py
761
4.40625
4
# -*- coding: utf-8 -*- # Exercise 18: Names, Variables, Code, Functions # 名称,变量,代码,函数 # Learn Python the Hard Way ---- 第二天 # Date: 2017/01/05 9:40 am # this one is like your script with argv def print_two(*args): # 多个参数的第一种方法 arg1, arg2 = args print "arg1 : %r, arg2: %r" %(arg1, arg2) # ok, that *args is actual...
true
429438621d712c5cbf86ef9df83ac2c049a97731
adrianlievano/unscramble_problems_bigO_exercises
/Task4.py
1,316
4.15625
4
""" Read file into texts and calls. It's ok if you don't understand how to read files. """ import csv with open('texts.csv', 'r') as f: reader = csv.reader(f) texts = list(reader) with open('calls.csv', 'r') as f: reader = csv.reader(f) calls = list(reader) """ TASK 4: The telephone company want to i...
true
77f3a8dd014e0de07cf9464cd3ae4ff3e497b99c
Hemapriya485/guvi
/Factorial.py
236
4.125
4
def factorial_of_n(n): fact=1 for x in range(1,n+1): fact=fact*x return fact print("Enter a number:") n=int(input()) print(n) factorial=factorial_of_n(n) print("Factorial of "+str(n)+" is "+str(factorial))
true
95e69bbe5455875784486479d901b129ba018019
hansknecht/PythonSandbox
/PythonSandbox/sqlroot.py
594
4.375
4
#!/usr/bin/env python3 def sqrt(input_s): ''' Compute square root using the method of Heron of Alexandria. Args: x: The number of which the square root is to be computed Returns: The square root of x. Raises: ValueErro: if x is negative. ''' if input_s < 0: ra...
true
f2177c1468c610c224a98d9bfbe6b746d8684844
rasareachan/text-adventure
/feminism1.py
2,142
4.1875
4
name = input("Insert strong, independent name (aka your name bc you're a strong, independent woman)\n") print("Welcome " + name + "! This your life.\n\nYour mom wants you to be a doctor, but you've always wanted to be an engineer.\n") q1 = input("Do you a: 'listen to your mom' or b: 'pursue your dreams'? (Please only...
true
bc0a1a22dbebe78ed7e2df192f9d056390e46da8
ggdecapia/raindrops
/raindrops.py
569
4.40625
4
def convert(number): # initialize string output variable string_output = "" # check if number is a multiple of 3 if number % 3 == 0: string_output = "Pling" # check if number is a multiple of 5 if number % 5 == 0: string_output = string_output + "Plang" # check if number...
true
307bcd423f522f6b799843bace5306ece9d95a1b
zimindkp/pythoneclipse
/PythonCode/src/Exercises/palindrome.py
853
4.4375
4
# K Parekh Feb 2021 # Check if a string or number is a palindrome #function to check if number is prime def isPalindrome(n): # Reverse the string # We create a slice of the string that starts at the end and moves backwards # ::-1 means start at end of string, and end at position 0 (the start), move w...
true
f18eaa34cbb4b2dfb3d04aafdac81d4665c7678a
HassanBahati/python-sandbox
/strings.py
973
4.4375
4
''' strings in python are surrounded by either single or double quotation marks. lets look at string formatting and some string methods ''' name = 'joe' age = 37 #concatenate print('Hello, my name is ' + name + ' and I am ' + str(age)) #string formatting #f-string print(f'My name is {name} and i am {age}') #str...
true
cd25867ac252dfc56aacf55f0fa823bca17a9834
WinterDing/leetcode
/69-Sqrt(x).py
668
4.21875
4
""" Questions: Implement int sqrt(int x). Compute and return the square root of x. x is guaranteed to be a non-negative integer. Example 1: Input: 4 Output: 2 Example 2: Input: 8 Output: 2 """ class Solution: def mySqrt(self, x): """ :type x: int :rtype: int """ ...
true
47ce39f555faa2fcfdb9866fad5333739300dbd6
mairiigomez/Practice-Challenges
/practicando_classes.py
1,215
4.25
4
class Vehicles: """Modeling a vehicle maximun speed and milage""" def __init__(self, name, max_speed, mileage): self.name = name self.max_speed = max_speed self.mileage = mileage self.color = 'White' def description_vehicle(self): print(f"color: {self.color}, ve...
true
59235210a401b8b57c005854e7339c0e1b1d3c2c
mairiigomez/Practice-Challenges
/student_calification.py
1,492
4.3125
4
"""Give 3 notes of one student, all of them in the same line split() storage them in the appropriate variable *variable: can storage many values in a list Convert all the elements to float with the map function and storage to a list storage to a super dictionary , with the name as a key and the score as values The...
true
78fbcc0e9227a8fe2b0d0dfea64b1be8774392c4
aseemang/Python-Tutorial-projects
/Building_a_Guessing_Game.py
620
4.125
4
secret_word = "giraffe" guess = "" guess_count = 0 guess_limit = 3 out_of_guesses = False #must use while loop to continuously ask person to guess word until they get it right while guess != secret_word and not(out_of_guesses): if guess_count < guess_limit: guess = input("Enter Guess: ") ...
true
00042ff379871170397cc9fdd5520b4346a7be04
AbrarAlzubaidi/amman-python-401d7
/class-10/demo/stack_and_queue/stack_and_queue/queue.py
562
4.125
4
from stack_and_queue.node import Node class Queue: """ a class that implements the Queue Data structure """ def __init__(self): self.front = None self.rear = None def enqueue(self, value): node=Node(value) if not self.rear: self.front = node ...
true
f4aca8b8bf8f6422d55b1d3de39837c43de9822e
annthurium/practice
/warmup_problems.py
1,552
4.1875
4
def factorial(n): """Returns n!""" if n <= 1: return n else: return n * factorial(n - 1) print factorial(5) # output a string in reverse def reverse_string(string): """takes a string as input, returns reversed string as output""" return string[-1::-1] print reverse_string('pool') reversed_string = [] def r...
true
9cfe2b4ff8ff04d87a9448633bc5ab8e3adbddda
sunilvarma9697/Code-Basics
/Generator.py
302
4.125
4
#Generator = it is used to create your own iterator and it is special type of functtion and it does not returns single value. #yield keyword is used rather than return. def Topten(): n = 1 while n <= 10: sq = n * n yield sq n += 1 values = Topten() for i in values: print(i)
true
7f58c1581d33b024b6debdaa5252e9ca895287f9
sunilvarma9697/Code-Basics
/Dictionary.py
495
4.34375
4
#Dictionary - Dictionarys are used to store data in keys:values. #Dictionary is a collection which is ordered. thisdict = { "brand": "Ford", "model": "Mustang", "year": 1964 } print(thisdict["brand"]) thisdict = { "brand": "Ford", "model": "Mustang", "year": 1964, "year": 2020 } print(this...
true
0bfaba8c91042f8013741cf20227a724c6ee6139
williamife/portfolio
/prime_or_not.py
459
4.25
4
#5. Write a program that asks a user for a number and then tests whether it is prime or not and prints out... # “The number is prime” or “The number is not prime”. number = int(input("Enter a number: ")) if number > 1: for i in range(2,number): if (number % i) == 0: print(number, "is not a pri...
true
df4fafdd59859214bcfe659e7b590723311dd950
The-Bioinformatics-Group/gbg-python-user-group
/examples/return_or_not_return.py
496
4.25
4
#!/usr/bin/python # Example of functions that returns a value, prints or don't return a value. # 1. Define the functions # Do the calcultation but return nothing. def return_nothing(x): y = x + 1 # Do the calculation print the value but return nothing. def print_no_return(x): x = x + 1 print x # Do the calcula...
true
75dae321701c250673475b187ad8019d5600bbd4
jabhij/MITx-6.00.1x-PYTHON
/Week-4/Prob4h.py
2,054
4.1875
4
def compChooseWord(hand, wordList, n): """ Given a hand and a wordList, find the word that gives the maximum value score, and return it. This word should be calculated by considering all the words in the wordList. If no words in the wordList can be made from the hand, return None. hand: ...
true
ed919c956673ad96c51ed96bebe41c95831e6afb
PetraGuy/CMEECourseWork
/Week2/Code/lc2.py
1,727
4.53125
5
#!usr/bin/python """Chapter 5 Practicals, modify lc2.py, Petra Guy Writing list comprehensions and for loops to extract elements from a list""" __author__ = "Petra Guy, pg5117@ic.ac.uk" __version__ = "2.7" #imports #constants #functions # Average UK Rainfall (mm) for 1910 by month # http://www.metoffice.gov.uk...
true
85ebc00234881e48c7cde853facb44fde20c77f4
alecheil/exercises
/chapter-3/exercise-3-1.py
1,387
4.59375
5
# Programming Exercise 3-1 # # Program to display the name of a week day from its number. # This program prompts a user for the number (1 to 7) # and uses it to choose the name of a weekday # to display on the screen. # Variables to hold the day of the week and the name of the day. # Be sure to initialize the ...
true
dafefe8765271ca7bcfd81ac6a4b5852818dae88
vladislav-karamfilov/Python-Playground
/HackBulgaria-Programming-101-with-Python-Course/week01/First-Steps/number_to_list_of_digits.py
500
4.1875
4
""" Implement a function, called to_digits(n), which takes an integer n and returns a list, containing the digits of n. """ def to_digits(n): if n < 0: n = -n elif n == 0: return [0] digits = [] while n != 0: digits.append(n % 10) n //= 10 digits.reverse() ...
true
ca66044405a497e119b19a137de3372c1eb33c9d
flyingsl0ths/Python-OOP-Examples
/Property Decorators/PartSix.py
1,829
4.1875
4
# Python Object-Oriented Programming: Property Decorators - Getters, Setters, and Deleters import random class Employee(object): # self is the first argument a class always takes # self refers to the instance of said object # self is used for accessing fields or methods(functions) within a class def...
true
6cce75ecdad0efc8af93748e312a579064bda760
angelguevara24/cyberbootcamp
/Lectures/Week 10 - Python 2/Day 2/Activities/09-Ins_OSWalk/OSWalk.py
1,259
4.25
4
# import the os library to use later import os folder_path = os.path.join("Resources", "DiaryEntries") # The os.walk() function is used to navigate through a collection of folders/files # This function returns three values for each step it takes: root, dirs, and files for root, dirs, files in os.walk(folder_path): ...
true
aa64619e392f839e9b7a13990d4c8dbec83486a6
angelguevara24/cyberbootcamp
/Lectures/Week 9 - Python 1/Day 2/Activities/02-Ins_SimpleConditionals/SimpleConditionals.py
682
4.1875
4
x = 1 y = 10 # == evaluates to True if the two values are equal if (x == 1): print("x is equal to 1") # != evaluates to True if the two values are NOT equal to each other if (y != 1): print("y is not equal to 1") # Checks if one value is less than another if (x < y): print("x is less than y") # Checks t...
true
5bc1ec7112c5155cf7e578f386ad8e79a6589c78
angelguevara24/cyberbootcamp
/Lectures/Week 9 - Python 1/Day 3/Activities/01-Stu_InventoryCollector/Solved/inventory_collector.py
1,253
4.4375
4
# Create an empty dictionary, called inventory inventory = {} # Ask the user how many items they have in their inventory # Convert to integer since input's value is a string item_count = int(input("How many items do you have in your inventory? ")) # Use `range` and `for` to loop over each number up to the inventory n...
true
03c63c2749e52cd1524c7e86b1d0e52e59fa9620
angelguevara24/cyberbootcamp
/Lectures/Week 9 - Python 1/Day 2/Activities/12-Par_KidInCandyStore/Solved/KidInCandyStore.py
942
4.4375
4
# The list of candies to print to the screen candyList = ["Snickers", "Kit Kat", "Sour Patch Kids", "Juicy Fruit", "Swedish Fish", "Skittles", "Hershey Bar", "Skittles", "Starbursts", "M&Ms"] # The amount of candy the user will be allowed to choose allowance = 5 # Create an empty list to store all the ca...
true
0ff40b513f0791cdfd009addbd8961b550f57115
intheltif/TechTalentSouth
/data_science/python/module_2/assignments/q4.py
657
4.46875
4
""" Exercise 4 of Module 2. Slices a provided list into three equal chunks and reverses each list. Author: Evert Ball Date: July 7th, 2020 """ import math def main(): """ The main entry point into the program. """ sampleList = [11, 45, 8, 23, 14, 12, 78, 45, 89] newList = splitList(sampleList, 3...
true
911e42419a5b6ea30c851acdb87ac6621db2bbbd
intheltif/TechTalentSouth
/data_science/python/module_6/group_exercise_2.py
1,048
4.25
4
""" Group Exercise 2 from the Jupyter Notebooks for GS Jackson's TTS Data Science course. Finds all files in the given directory from command line argument and prints them to the screen in a sorted order. Author: Evert Ball Date: 20 July 2020 """ import sys import os def main(): " The main entry point into the p...
true
70ed26405395b580f7b8c0d14bc280dd293a9816
limjiayi/Project_Euler
/euler_problem001.py
303
4.21875
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. total = 0 num = 0 while num < 1000: if num % 3 == 0 or num % 5 == 0: total += num num += 1 print(total)
true
2000b6df1aed2237596fb07e992f1d2e9bd31334
rjshk013/pythonlearning
/fib2.py
568
4.15625
4
# Enter number of terms needed #0,1,1,2,3,5.... n=int(input("Enter the terms? ")) first=0 #first element series second=1 #second elementseries if n<=0: print("Please enter positive integet greater than 0") elif n == 1:...
true
e69a498a216a0388533c4552652ee76aac3c80db
JustineTang10/python-class
/1-10-2021.py
1,386
4.125
4
def secret_number(): import random goalnumber = random.randint(1, 50) numberoftries = 0 while True: chosennumber = int(input("What number (from 1-50) would you like to choose? ")) if chosennumber > 50 or chosennumber < 1: print("Invalid option, try again") elif chosennumber == goalnumber: ...
true
c9ffabfb4745082b275f3b7e49ca5cc1aabdd80f
brunobord/wthr
/wthr.py
2,607
4.3125
4
#!/usr/bin/env python """wthr is a Python script for checking the weather from the command line. """ from urllib2 import urlopen import json from xml.etree.ElementTree import XML as parse_xml from sys import argv class Wthr: """Main Wthr class. Computes location and sends weather information to the ...
true
9faeac4e3000acc4c12feb209d9b842d38e719be
Brupez/Text-Adventure-Game
/textAdventure.py
1,093
4.15625
4
while True: answer = input("Would you like to play? (yes/no) ") #take answer and show it with lowercase letters and strip the text behind (yes or no) if answer.lower().strip() == "yes": answer = input("\nYou see a person asking for help, it seems he is injured, would you like to help him?\n"...
true
c8fefc38670bd237ea1eeeecc5469087add08b9e
deepashreeKedia/Solutions
/secret_number
698
4.1875
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Wed Feb 14 15:50:57 2018 @author: deep """ # Paste your code into this box print("Please think of a number between 0 and 100!") low = 0 high = 100 while True: guess = (low + high) // 2 print("Is your secret number {}?".format(guess)) ans = i...
true
8be3499871065c922a316b067795ab9317e423f4
Carra1g/Cooking_time_calculator
/cooking_times.py
2,082
4.125
4
#Cooking times #user the app again def again(): again_input = str(input("Do you need to run the app again: y/n: ")) for choice_input in again_input: #convers input to lower for error handling. if choice_input.lower() == "y": time_helper() else: choice_i...
true
b587c5942dda335394d1acc387bac76dc721320e
ArnoldNawezi/StringSolution
/String.py
484
4.59375
5
string = input(str("Enter a string here: ")) # Getting a string from the user def reverse(string): # defining a function str = "" # for i in string: # Using the loop to define every sing element of the string str = i + str ...
true
8b6aea319e2abacd4831472da3733f4aa70f6e75
olashayor/class_code
/operator2.py
750
4.21875
4
x = {1,2,3,4,5} y = {6,7,2,8,9} z = x and y print("z = ", z) name = "J" if len(name) < 3: print("\nname must not be less than 3 letters") elif len(name) > 15: print("\nname must be maximum of 15 letter") else: print("\nname is good to go") name = "Jacob olatunde felix" if len(name) < 3: print("\nname...
true
a4d4f7ca5a3b2b6503d4461ebd89cc4bd8a0f3fa
MunafHajir/Learning
/close-to-perfection.py
1,387
4.15625
4
""" Geek likes this girl Garima from his neighborhood, and wants to impress her so that she may go on a date with him. Garima is a Perfectionist and likes only PERFECT things .This makes Geek really nervous, and so Geek asks for your Help.! Geek has baked a cake for Garima, which is basically an array of Numbers. Garim...
true
b96096c122cf1f88b194efc99741e21fe5833356
Sen2k9/Algorithm-and-Problem-Solving
/leetcode_problems/401_Binary_Watch.py
2,099
4.125
4
""" A binary watch has 4 LEDs on the top which represent the hours (0-11), and the 6 LEDs on the bottom represent the minutes (0-59). Each LED represents a zero or one, with the least significant bit on the right. For example, the above binary watch reads "3:25". Given a non-negative integer n which represents the n...
true
9e792bf0c28eaaa1619282d8885c51fa4bea960a
Sen2k9/Algorithm-and-Problem-Solving
/CTCI/2.8_Loop_Detection.py
887
4.15625
4
""" Given a circular linked list, implement an algorithm that returns the node at the beginning of the loop. DEFINITION Circular linked list: A (corrupt) linked list in which a node's next pointer points to an earlier node, so as to make a loop in the linked list. """ from collections import defaultdict class Node: ...
true
63f28e4fb1802ab7ef5554827a8acc07bb3d7f60
Sen2k9/Algorithm-and-Problem-Solving
/leetcode_problems/1189_Maximum_Number_of_Balloons.py
2,349
4.125
4
""" Given a string text, you want to use the characters of text to form as many instances of the word "balloon" as possible. You can use each character in text at most once. Return the maximum number of instances that can be formed. Example 1: Input: text = "nlaebolko" Output: 1 Example 2: Input: text = "loonbalxb...
true
a2ce90d03831f7e1c7d77d76f0a1799ae16b595d
Sen2k9/Algorithm-and-Problem-Solving
/leetcode_problems/763_Partition_Labels.py
1,343
4.15625
4
""" A string S of lowercase English letters is given. We want to partition this string into as many parts as possible so that each letter appears in at most one part, and return a list of integers representing the size of these parts. Example 1: Input: S = "ababcbacadefegdehijhklij" Output: [9,7,8] Explanation: The p...
true
b4058074b0317f3bb63ff86e68cf469afc8c2ca9
Sen2k9/Algorithm-and-Problem-Solving
/leetcode_problems/374_Guess_Number_Higher_or_Lower.py
1,144
4.40625
4
""" We are playing the Guess Game. The game is as follows: I pick a number from 1 to n. You have to guess which number I picked. Every time you guess wrong, I'll tell you whether the number is higher or lower. You call a pre-defined API guess(int num) which returns 3 possible results (-1, 1, or 0): -1 : My number i...
true
166f024552faabbc9506483ed80316ea7d3858d0
Sen2k9/Algorithm-and-Problem-Solving
/leetcode_problems/371_Sum_of_Two_Integers.py
839
4.125
4
""" Calculate the sum of two integers a and b, but you are not allowed to use the operator + and -. Example 1: Input: a = 1, b = 2 Output: 3 Example 2: Input: a = -2, b = 3 Output: 1 """ class Solution: def getSum(self, a: int, b: int): while b: #print(bin(a), bin(b)) tmp = a ^...
true
8cf78e66be8fe091c0e2aaa46cfa1bf69a6c8efe
Sen2k9/Algorithm-and-Problem-Solving
/leetcode_problems/55_Jump_Game.py
2,059
4.1875
4
""" Given an array of non-negative integers, you are initially positioned at the first index of the array. Each element in the array represents your maximum jump length at that position. Determine if you are able to reach the last index. Example 1: Input: nums = [2,3,1,1,4] Output: true Explanation: Jump 1 step fro...
true
2af13aae0daec47f7f828a0a16ddf57a590adf22
Sen2k9/Algorithm-and-Problem-Solving
/leetcode_problems/205_Isomorphic_Strings.py
1,479
4.125
4
""" Given two strings s and t, determine if they are isomorphic. Two strings are isomorphic if the characters in s can be replaced to get t. All occurrences of a character must be replaced with another character while preserving the order of characters. No two characters may map to the same character but a character ...
true
5ca5ce3bb5456537334320122fd2f7af94237724
Sen2k9/Algorithm-and-Problem-Solving
/leetcode_problems/893_Groups_of_Special_Equivalent_Strings.py
2,040
4.15625
4
""" You are given an array A of strings. A move onto S consists of swapping any two even indexed characters of S, or any two odd indexed characters of S. Two strings S and T are special-equivalent if after any number of moves onto S, S == T. For example, S = "zzxy" and T = "xyzz" are special-equivalent because we ma...
true
94bb330be10118b3d98761b53f17fe206f9aaa8f
Sen2k9/Algorithm-and-Problem-Solving
/leetcode_problems/1042_Flower_Planting_With_No_Adjacent.py
2,183
4.3125
4
""" You have N gardens, labelled 1 to N. In each garden, you want to plant one of 4 types of flowers. paths[i] = [x, y] describes the existence of a bidirectional path from garden x to garden y. Also, there is no garden that has more than 3 paths coming into or leaving it. Your task is to choose a flower type for e...
true
3d3e94cb76e19cd5c0af047333b87b09c3da5687
Tanmay53/cohort_3
/submissions/sm_110_mihir/week_13/day_4/check_superset.py
203
4.15625
4
set1={1,2,3,10} set2={1,2,3,4,5,6} flag=True for item in set1: if item not in set2: print("set2 is not a superset of set1") flag=False if flag: print("set2 is a superset of set1")
true