blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
483dfbcd3693bb16dbdb617c812a6eac5eacdcd7
dcryptOG/pyclass-notes
/9-built-infunctions/2-built-func-hw.py
2,153
4.15625
4
# Built-in Functions Test # For this test, you should use built-in functions and be able to write the requested functions in one line. # Problem 1 # Use map() to create a function which finds the length of each word in the phrase (broken by spaces) and returns the values in a list. # The function will have an input ...
true
810b6d03d9bc622dd166324958e4213ed86d13a8
dcryptOG/pyclass-notes
/3Statments/2_if_elseif_else.py
1,281
4.34375
4
# ======================================================= #! if, elif, else Statements # * CONTROL FLOW = use logic for async code execution # elif and else statements, which allow us to tell the computer: # if case1: # perform action1 # elif case2: # perform action2 # else: # perform action3 if True: ...
true
15968bc019404dcdf37235069ab465d6fd3fca37
abbeyperini/DC_Learning_Python
/Week1/Day4/Day4A2.py
443
4.46875
4
# Assignment: Write a program which finds the largest element in the array words = ["apple", "banana", "orange", "apricot", "supercalifragilisticexpialidocious"] numbers = [1, 4, 23, 103, 567, 1432, 40523, 1000000] def find_largest(array): length = 0 item = "" for n in array: if len(str(n)) > le...
true
34b2f8d4b927027a075463d51974ccd34c2a6e10
hunterruns/Project
/proj03/proj03.py
1,178
4.25
4
# Name: Hunter # Date: 6/12/2017 """ proj 03: Guessing Game 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 use...
true
d69904660072c40bc9262fa745ec213034c50241
zhweiliu/learn_leetcode
/Top Interview Questions Easy Collection/Linked List/Merge Two Sorted Lists/solution.py
1,694
4.25
4
from typing import Tuple ''' Merge two sorted linked lists and return it as a sorted list. The list should be made by splicing together the nodes of the first two lists. Constraints: - The number of nodes in both lists is in the range [0, 50]. - -100 <= Node.val <= 100 - Both l1 and l2 are sorted in non-d...
true
36cf62ebb2c03821fb3c2fa279ea27c242811d8a
zhweiliu/learn_leetcode
/Top Interview Questions Easy Collection/Strings/Reverse String/solution.py
823
4.5
4
from typing import List ''' Write a function that reverses a string. The input string is given as an array of characters s. Example 1: Input: s = ["h","e","l","l","o"] Output: ["o","l","l","e","h"] Example 2: Input: s = ["H","a","n","n","a","h"] Output: ["h","a","n","n","a","H"] Follow up: Do not allocate ext...
true
498de0cff673823a8cf86583e35ce151430bc5b0
zhweiliu/learn_leetcode
/Top Interview Questions Easy Collection/Dynamic Programming/Best Time to Buy and Sell Stock/solution.py
1,455
4.125
4
from typing import List ''' You are given an array prices where prices[i] is the price of a given stock on the ith day. You want to maximize your profit by choosing a single day to buy one stock and choosing a different day \ in the future to sell that stock. Return the maximum profit you can achieve from this trans...
true
8e3b843a4f3a1e062ae855ed7d9b4a156bdbf42a
tommymag/CodeGuild
/python/phone_number.py
786
4.375
4
def pretty_print(phone_number): return "({}){} - {}".format(phone_number[0:3], phone_number[3:6], phone_number[6:]) phone_number = input('Please enter an all digits phone number. ') print(pretty_print(phone_number)) # # Lab: Fancy Phone Numbers # ###### Delivery Method: Prompt Only # ##### Goal # Write a sm...
true
4282740cccc1be82217a72dc8c122e7b5570cb86
harite/game-hack
/Misc Python Exercises/py1.py
725
4.5
4
from sys import argv #Imports the modules to allow the file to take arguments script, filename = argv #defines the argument as a string prompt = "test:" #sets the prompt txt = open(filename) #Opens the file specified in the argument via line 3 print "Here's your file %r:" % filename #Statement, %r to substitute inste...
true
0a540249daf51ad06257137a8ee0a7e79ab2c028
alexyin2/Linear-Regression_Python_Not_Using_sklearn
/L2Regularization.py
1,416
4.125
4
import numpy as np import matplotlib.pyplot as plt """ L2 Regularization is a way of providing data being highly affected by outliers. We add squared magnitude of weigths times a constant to our cost function. This is because large weights may be a sign of overfitting. L2 Regularization is also called "Ridge Regress...
true
bfcf71df2e0d088ac9390c06fdd979611f1559cf
joshurbandavis/Project-Euler-Problems
/Problem1.py
229
4.28125
4
#!/usr/bin/env python """Problem 1: Find the sum of all multiples of 3 or 5 between 0 and 1000 Solved in python""" counter = 0 for x in range (0,1000): if x%3 == 0 or x%5 == 0: counter = counter + x print counter
true
684b104df1d8cc8b4e4fef44f8c06e83ec9acd45
ShrawanSai/DS-and-Algos-with-python-and-Java
/LinkedLists/seperate_odd_and_even.py
1,917
4.1875
4
class Node: def __init__(self, data): self.data = data self.next = None class LinkedList: def __init__(self): self.head = None self.count = 0 def append(self,data): new_node = Node(data) if self.head is None: self.head = new_n...
true
41c95b42f006ab6ae9b81c9a4c430c8b8ab13a5b
ShreyaRawal97/data-structures
/Linked Lists/Max_Sum_Subarray.py
1,611
4.34375
4
#find and return largest sum in a contiguous subarray within input array #KODANE'S ALGORITHM - the maximum subarray problem is the task of finding #the contiguous subarray within a one-dimensional array of numbers which #has the largest sum. """ O element array - if there is no element present in array then we can say...
true
76bfac88cec841875c5a8db59a23b8bdc0961bb3
ParkerCS/ch18-19-exceptions-and-recursions-nsachs
/recursion_problem_set.py
2,512
4.125
4
''' - Personal investment Create a single recursive function (or more if you wish), which can answer the first three questions below. For each question, make an appropriate call to the function. (5pts each) ''' #1. You have $10000 on a high interest credit card with an APR of 20.0% (calculated MONTHLY, so MPR is APR...
true
a67d420a766a00ec0810c310439988a9c0fc4505
niavivek/D10
/numbered_lines.py
705
4.15625
4
#!/usr/bin/env python3 """Function to write line numbers to a file""" import math def numbered_lines(filename): write_file(read_file(filename)) def read_file(filename): list_lines = [] with open(filename,"r") as read_file: for lines in read_file: lines = lines.strip() list_lines += lines.split("\n") retur...
true
afb13f26fb67cfb2c59f1704858638a7adf62b4a
Syssos/Holberton_School
/holbertonschool-higher_level_programming/0x0A-python-inheritance/11-square.py
1,808
4.15625
4
#!/usr/bin/python3 class BaseGeometry: def integer_validator(self, name, value): """ Function that validated value for name Arguments: name (str): name string value (int): value to validate Returns: None """ if type(value) is not int: ...
true
7f19d79f83e74756d31a16e1605e7105fcb8ce0b
jprajapat888/Python-Files
/Example 2 Python Break.py
436
4.4375
4
# The program below takes inputs from the user and calculates the sum until the user enters a negative number. # When the user enters negative a number, the break statement is executed which terminates the loop. sum = 0 # boolean expression is True while True: n = input("Enter a number: ") n = float(n) # Con...
true
e13b3a957f3778b57131d168426d302fbc23e1f9
jprajapat888/Python-Files
/Python Program to Find the Square Root.py
265
4.46875
4
#Python Program to calculate the square root #Note: change this value for a different result num = 8 # To take the input from the user # num = float(input('Enter a numbers: ')) num_sqrt = num ** 0.5 print("The Sqaure root of %0.3f is %0.3f" %(num ,num_sqrt))
true
767e6900f4abb2c048e425a85e0d7eca130b8c58
Airmagic/Lab-1-new
/camelCase.py
824
4.3125
4
#found python code help from stackoverflow #Showing the name of the program print('Camel Casing a sentence') # getting the sentence from user sentence = input('Write a short sentence to camelCase :') # converting the sentence all into lowercase lowercase = sentence.lower() # making all the first letter of word upper...
true
fc4b653d39d90fa378bb0b545b7663f701b5ecb0
dfeusse/2018_practice
/dailyPython/05_may/31_countingArrayElements.py
698
4.25
4
''' Write a function that takes an array and counts the number of each unique element present. count(['james', 'james', 'john']) #=> { 'james' => 2, 'john' => 1} ''' def count(array): #your code here outputDict = {} for i in array: if i not in list( outputDict.keys() ): outputDict[i] = 1 e...
true
9633f3f420cab004965178873349b26356b8a380
dfeusse/2018_practice
/dailyPython/06_june/16_roundUp5.py
593
4.21875
4
''' Round to the next multiple of 5. Given an integer as input, can you round it to the next (meaning, "higher") 5? Examples: input: output: 0 -> 0 2 -> 5 3 -> 5 12 -> 15 21 -> 25 30 -> 30 -2 -> 0 -5 -> -5 etc. Input may be any positive or negative integer (including 0). You can...
true
c51f358b13d04606b0096ffa7062ffb1cae62491
dfeusse/2018_practice
/dailyPython/07_july/26_countingDups.py
1,208
4.28125
4
''' Counting Duplicates Count the number of Duplicates Write a function that will return the count of distinct case-insensitive alphabetic characters and numeric digits that occur more than once in the input string. The input string can be assumed to contain only alphabets (both uppercase and lowercase) and numeric dig...
true
fb73339f7683baf3a1d083b511799c8064310e09
dfeusse/2018_practice
/dailyPython/07_july/03_sumOfSequence.py
758
4.3125
4
''' Your task is to make function, which returns the sum of a sequence of integers. The sequence is defined by 3 non-negative values: begin, end, step. If begin value is greater than the end, function should returns 0 ''' def sequence_sum(begin_number, end_number, step): startingNum = begin_number; nums = [] while...
true
3639245b44c8c691441bc9f9d7b0381170529489
dfeusse/2018_practice
/dailyPython/08_august/03_divisors.py
886
4.15625
4
''' Find the divisors! Create a function named divisors/Divisors that takes an integer n > 1 and returns an array with all of the integer's divisors(except for 1 and the number itself), from smallest to largest. If the number is prime return the string '(integer) is prime' (null in C#) (use Either String a in Haskell a...
true
8c84b7a5f28bb826d60d132a80bb0fd02b2a016b
dfeusse/2018_practice
/dailyPython/07_july/27_pigLatin.py
813
4.34375
4
''' imple Pig Latin Move the first letter of each word to the end of it, then add "ay" to the end of the word. Leave punctuation marks untouched. Examples pig_it('Pig latin is cool') # igPay atinlay siay oolcay pig_it('Hello world !') # elloHay orldWay ! ''' def pig_it(text): # loop through each word # slice the...
true
dca07c49ef843725a93b3178f9ff20b42aff5ffc
dfeusse/2018_practice
/dailyPython/05_may/09_descOrder.py
754
4.21875
4
''' Your task is to make a function that can take any non-negative integer as a argument and return it with its digits in descending order. Essentially, rearrange the digits to create the highest possible number. Examples: Input: 21445 Output: 54421 Input: 145263 Output: 654321 Input: 1254859723 Output: 9875543221...
true
1ab382088fb0752627746e4c28f5147482e57214
dfeusse/2018_practice
/dailyPython/06_june/21_highestLowest.py
569
4.21875
4
''' Highest and Lowest In this little assignment you are given a string of space separated numbers, and have to return the highest and lowest number. Example: high_and_low("1 2 3 4 5") # return "5 1" high_and_low("1 2 -3 4 5") # return "5 -3" high_and_low("1 9 3 4 -5") # return "9 -5" ''' def high_and_low(string): ...
true
9a342ace56cd9f19f7d4fbcbb290df31630013ab
dfeusse/2018_practice
/dailyPython/07_july/23_scrambled.py
781
4.125
4
''' Scramblies Complete the function scramble(str1, str2) that returns true if a portion of str1 characters can be rearranged to match str2, otherwise returns false. Notes: Only lower case letters will be used (a-z). No punctuation or digits will be included. Performance needs to be considered Examples scramble('rkqo...
true
295dfb3f4151ec114a6825854422243fd5b0f0d6
dfeusse/2018_practice
/dailyPython/07_july/26_firstNonRepeating.py
1,196
4.21875
4
''' Write a function named firstNonRepeatingLetter that takes a string input, and returns the first character that is not repeated anywhere in the string. For example, if given the input 'stress', the function should return 't', since the letter t only occurs once in the string, and occurs first in the string. As a...
true
cdc560c33d0d9ef2dd9c210dca683d35c0b27004
dfeusse/2018_practice
/dailyPython/07_july/05_vowelCount.py
442
4.1875
4
''' Vowel Count Return the number (count) of vowels in the given string. We will consider a, e, i, o, and u as vowels for this Kata. The input string will only consist of lower case letters and/or spaces. ''' def getCount(inputStr): vowels = list('aeiou') num_vowels = 0 for i in inputStr: if i in vowels: num_...
true
67ec226662c56c93fe5f0176cfb1380003385afc
amruth153/Python-projects
/K means/Assignment_2.py
2,943
4.1875
4
#Name: Amruth Kanakaraj #Student ID: 201547293 """ Implement a simplified version of k-means algorithm using Python to cluster a toy dataset comprising five data points into two clusters. More specifically, consider the following dataset comprising five data points (2-dimensional) {(0; 0); (1; 0); (1; 1); (0; 1)...
true
6a71e7762b77de162b2a868178c2b003c459529c
bhuvan21/C2Renderer
/Vector3.py
2,825
4.25
4
'''Contains the Vector3 Class, a helper class for working with vectors with 3 components''' from math import sqrt # the Vector3 class can be initialised with 3 separate values, or an array of 3 values class Vector3(): def __init__(self, a=0, b=0, c=0, full=[0, 0, 0]): if full == [0, 0, 0]: sel...
true
6ad069ca0e91a74bd5469a5b396594fa5e780944
NRKEngineering/PythonScripts
/oddOrEven.py
485
4.34375
4
# Odd or Even # This program asks the user for a number and # determines if that number is odd or even # get a number from the user number = input("Please enter a number: ") # See if even if int(number) % 2 is 0: print ("Number is even") # If even is it divisable by four if int(number) % 4 is 0...
true
b6824bdeb579a4eddf70f10033645ba89f83d0fb
MayKeziah/CSC110
/inclasswk3.py
747
4.53125
5
#Keziah May #04/17/18 #In class activity: Week 3 #Goal: prove understanding of splitting strings def main(): #Explain the goal of the program print("This program demonstrates splitting strings.\n") #Assign string to variable "mystring". mystring = 'This is a line.\n This is a separate line.' pri...
true
ffad27d374046a8be3bb17f146ce3ec28b1049d3
omrawal/Studbud-Prep
/Week 4/Stack Intermediate/q11.py
1,639
4.15625
4
# reverse a stack without using loops # idea is store values in function calls untill stack is empty # insert at bottom of stack class Stack(object): def __init__(self): self.stack = [] def push(self, x): self.stack.append(x) def pop(self): if(len(self.stack) == 0): ...
true
64dbc0adf1fcac24acf522c310bf119f158a5ffa
pm0n3s/Python
/python1/python/multiples_sum_average.py
738
4.40625
4
'''Multiples Part I - Write code that prints all the odd numbers from 1 to 1000. Use the for loop and don't use a list to do this exercise.''' for i in range (1, 1001): if i % 2 == 1: print i '''Part II - Create another program that prints all the multiples of 5 from 5 to 1,000,000.''' for i in range(5, ...
true
6cdb0f55518aecfeb0834848796b14bcb7d1d49e
kajkap/Day_of_the_squirrel
/remember_number_game.py
1,564
4.15625
4
import random import time import os def initial_print(): """Function prints the game instruction.""" os.system('clear') print(""" *** Remember telephone number! Write it down in the same format (divided into 3-digits blocks)*** """) def generate_number(): """Function generates 9 random ...
true
592993959bec9722c6273a79ed0bb989102e55b4
vineetwani/PythonDevelopment
/ListAndSetBasics.py
1,056
4.15625
4
#Define a list, set #Output of Function listBasics: # <class 'list'> # [['Punit', 79], ['Vineet', 66]] # ['Punit', 'Vineet'] # [79, 66] def listBasics(): #l1=list() Can define like this as well l1=[] print(type(l1)) l1.insert(0,["Vineet",66]) l1.insert(0,["Punit",79]) ...
true
55b51dae6e3344553d0aa227a2d20710c00b49b4
frontsidebus/automating-the-boring-stuff
/exercise2-13.py
202
4.1875
4
print('This is a for loop: ') for number in range(1, 11): print(int(number)) print('This is a while loop: ') number = 1 while number <= 10: print(int(number)) number = (number + 1)
true
bb5af9c8070b4b6c3a97ae26e56ce7bb5a0a9e40
jacindaz/data_structures
/other_practice/doubly_linked_list.py
373
4.40625
4
def reverse_doubly_linked_list(linked_list): print('hi!') # Traverse a linked list # Remove duplicates from a linked list # Get the kth to last element from a linked list # Delete a node from a linked list # Add two linked lists from left to right # e.g. 1->2->3 + 8->7 => 321+78 = 399 # Add two linked lists from ...
true
08609793a8c7c3b33c76f72e1899bce2fd0fd217
arstepanyan/Notes
/programming/elements_prog_interview/10_heaps/1_merge_sorted_files.py
1,138
4.3125
4
''' Write a program that takes as input a set of sorted sequences and computes the union of these sequences as a sorted sequence. For example, if the input is [3, 5, 7], [0, 6], and [0, 6, 28], then the output is [0, 0, 3, 5, 6, 6, 7, 28]. ''' import heapq def merge_sorted_arrays(sorted_lists): min_heap = [] i...
true
5d7eb4e1f78d56817c6fcbf896731e6b3989030d
arstepanyan/Notes
/programming/elements_prog_interview/5_arrays/9_enumerate_all_primes_to_n.py
980
4.375
4
""" Write a program that takes an integer argument and returns all the primes between 1 and that integer. For example, if the input is 18, you should return [2,3,5,7,11,13,17]. A natural number is called a prime if it is bigger than 1 and has no divisors other than 1 and itself. """ # Time = O(n log log n) Explanatio...
true
632ce36a32bd89143ba0e061706eacecde9c980a
arstepanyan/Notes
/programming/elements_prog_interview/13_sorting/1_intersection_of_two_sorted_arrays.py
1,767
4.1875
4
# write a program which takes as input two sorted arrays, and returns a new array containing elements that are present # in both of the input array. The input arrays may have duplicate entries, but the returned array should be free of duplicates. # O(m + n) time complexity, as adding an element to a set is O(1) def in...
true
ae53c9325b923096e981af98f3a76c17dd9f9439
mdolmen/daily_coding_problem
/029-rain-between-walls/solution.py
1,129
4.34375
4
#!/usr/bin/env python3 # You are given an array of non-negative integers that represents a # two-dimensional elevation map where each element is unit-width wall and the # integer is the height. Suppose it will rain and all spots between two walls get # filled up. # # Compute how many units of water remain trapped on ...
true
3c5debecd8059514f58c29eda2a2778718f60b3b
fanying2015/code_learning_python
/Battleship.py
1,862
4.3125
4
# Battle Ship Game """ In this project a simplified, one-player version of the classic board game Battleship will be built! In this version of the game, there will be a single ship hidden in a random location on a 5x5 grid. The player will have 4 guesses to try to sink the ship.""" # generate an empty board from rand...
true
afd166b6ab62403e018c4e5617026d531c1eeb74
chao813/Leetcode-Practice
/345ReverseVowels.py
603
4.25
4
"""Write a function that takes a string as input and reverse only the vowels of a string. Example 1: Given s = "hello", return "holle". Example 2: Given s = "leetcode", return "leotcede". Note: The vowels does not include the letter "y".""" def reverseVowels(s): vowel = ['a','e','i','o','u'] vowel_lst = [] ...
true
0d7db3a2a83a9cec8a3407b98b99f9b953778589
prdmkumar7/PythonProjects
/rolling_dice.py
656
4.53125
5
#importing module for random number generation import random #range of the values of a dice min_val = 1 max_val = 6 #to loop the rolling through user input roll_again = "yes" #loop while roll_again == "yes" or roll_again == "y": print("Rolling The Dices...") print("The Value is :") #g...
true
64b5c8a44c92b0c3ec02fa688a09c4c183438723
nuwa0422/p2pu-python-101
/02. Expressions/exercise-2.3.py
285
4.1875
4
# Exercise 2.3 # # Write a program to prompt the user for hours and rate per hour to compute # gross pay # # Enter Hours: 35 # Enter Rate: 2.75 # Pay: 96.25 # hours = int(raw_input('Enter Hours: ')) rate = float(raw_input('Enter Rate: ')) pay = hours * rate print 'Pay: ' + str(pay)
true
351e16b3026c0248060a8e98f5fb3c93a42cb777
jcehowell1/learn_python
/ms_challenge_01.py
994
4.40625
4
# This program is to complete the first challenge for Create your first Python program # the output will be similar to the following sample output: # Today's date? # Thursday # Breakfast calories? # 100 # Lunch calories? # 200 # Dinner calories? # 300 # Snack calories? # 400 # Calorie content for Thursday: 1000 #Start ...
true
32683e32d25edcbf2eb5d559857dca9b8060e6cb
gouravkmar/codeWith-hacktoberfest
/python/Bunny_Prisoners_plates.py
2,354
4.4375
4
'''You need to pass a message to the bunny prisoners, but to avoid detection, the code you agreed to use is... obscure, to say the least. The bunnies are given food on standard-issue prison plates that are stamped with the numbers 0-9 for easier sorting, and you need to combine sets of plates to create the numbers in t...
true
430f471a548fc1f66baf3c99102b4df4395fdd41
naveenkonam/my_projects
/areaofcircle.py
333
4.21875
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Mon Oct 19 10:38:26 2020 @author: konam """ import math def area_cir(r): return (math.pi*(r**2)) n = eval(input('Please enter the radius to claculate the area of circle: ')) A = area_cir(n) print("The area of the cirle with radius {0} is {1}".forma...
true
5b6241f28bec3bfa8407bb0770939d2348cf0227
akniels/Data_Structures
/Project_2/Problem_4.py
1,666
4.15625
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Sun Sep 13 11:15:19 2020 @author: akniels1 """ from time import time class Group(object): def __init__(self, _name): self.name = _name self.groups = [] self.users = [] def add_group(self, group): self.groups.append...
true
3be7933c6114435c0357da694ddade72663cd26f
akniels/Data_Structures
/Project_1/P0/Task1.py
1,052
4.125
4
#!/usr/bin/env python3 """ 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 1: How many...
true
a45f4b26afa16e28eb158b79b763290fd17636f2
akniels/Data_Structures
/Project_1/P0/Task4.py
2,089
4.25
4
#!/usr/bin/env python3 """ 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 tele...
true
ff3e08a2ef01b158bf2756cfa03d3c179e5686c2
arshmohd/daily_coding_problem
/problems/49/problem_49.py
624
4.15625
4
def coding_problem_49(arr): """ Given an array of numbers, find the maximum sum of any contiguous subarray of the array. For example, given the array [34, -50, 42, 14, -5, 86], the maximum sum would be 137, since we would take elements 42, 14, -5, and 86. Given the array [-5, -1, -8, -9], the maximum su...
true
db439e7a13dbee158a48e5534ee536afe79e2c9d
arshmohd/daily_coding_problem
/problems/44/solution_44.py
1,137
4.15625
4
def coding_problem_44(arr): """ We can determine how "out of order" an array A is by counting the number of inversions it has. Two elements A[i] and A[j] form an inversion if A[i] > A[j] but i < j. That is, a smaller element appears after a larger element. Given an array, count the number of inversions ...
true
59a9f50b583e7381ead51af49389a6e9c43aa706
alexmaclean23/Python-Learning-Track
/04-Floats/Floats.py
611
4.15625
4
# Declaration of a few floats x = 7.0 y = 21.0 z = 45.0 # Basic math operations using floats addInt = x + z subtractInt = z - y multiplyInt = x * y divideInt = y / x modInt = z % x powerInt = y ** z everythingInt = (y ** 7) / ((z + y) - (-(y * x))) # Printing of the math calculations print(addInt) print(subtractInt) ...
true
700acbeebbdeb5bf8961a1f2cfc6d928ec14a341
alexmaclean23/Python-Learning-Track
/16-ForLoops/ForLoops.py
478
4.25
4
# Declaration of various data types myList = [1, 2, 3, 4, 5] myString = "Hello" # For loop to print integers in list for integers in myList: print(integers) print() # For loop to print letters in String for letters in myString: print(letters) print() # For loop to print dash for each integer in list for in...
true
ba031a215ffc6315bfe9b79f81827a3269b9f7d3
alexmaclean23/Python-Learning-Track
/17-WhileLoops/WhileLoops.py
225
4.15625
4
# Declaration if an integer variable myNum = 0 # While loops that increment and prints nyNum up to 5 while (myNum <= 5): print(f"myNum is currently {myNum}") myNum += 1 else: print("myNum is no longer in range.")
true
04ab40e25129d568f6a2e322a18a8705d555d406
alexmaclean23/Python-Learning-Track
/33-AdvancedModules/AdvancedModules.py
1,673
4.125
4
print() print("####################################################") print() # Example of the counter module from collections import Counter myList = [1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 4, 4, 4] print(Counter(myList)) sentence = "this this sentence is is is iterable iterable" words = sentence.split() prin...
true
f84b3855120007e952476bb535e16921c9ff2104
abulho/Python_Coding_Practice
/max_profit.py
1,323
4.25
4
''' Suppose we could access yesterday's stock prices as a list, where: The indices are the time in minutes past trade opening time, which was 9:30am local time. The values are the price in dollars of Apple stock at that time. So if the stock cost $500 at 10:30am, stock_prices_yesterday[60] = 500. Write an efficient f...
true
d68757f8517c27a7fa0bd9bb03c68517a251c63c
zarim/Caesar-Cipher
/P1216.py
2,614
4.125
4
#Zari McFadden = 1/27/17 #P1216 - Caesar Cipher #Write a program that prompts a user for a string and an encryption key. #The encryption key is the cipher shift amount. Your program will function as #both an Caesar Cipher encrypter and decrypter. def main(): #define main A...
true
532e2c325f68a7701e16b091f4814f2ee4ab2819
kongmingpuzi/python_classes_homework
/第二次上机作业/problem_2.py
512
4.125
4
name=input('Please input the account name') passwprd='8'*8 for i in range(3): if i==0: input_passwprd=input('Please input the account passwprd') else: input_passwprd=input('The wrong password!\nPlease input the account passwprd again.') if input_passwprd==passwprd: print('You...
true
6fbbc3fae2250d7f1b64058da14f1776fe24c881
SridharPy/MyPython
/SQL/SQLLite.py
889
4.28125
4
import sqlite3 # The connection sqlite3.connect : lite.db db file is created if it doesn't exist else will connect if exists def create_table(): conn = sqlite3.connect("lite.db") cur = conn.cursor() cur.execute("CREATE TABLE IF NOT EXISTS Store (Item text, Quantity integer, Price real )") conn.commit()...
true
9fe89bc4d058c9c152ecd46e86b3dde08b9c7c85
thecodesanctuary/python-study-group
/assessment/assessment_1/princess/4.py
238
4.25
4
#This program converts inputed weight from KG to Pounds print("Conversion from Kilograms to Pounds\n \n") KG=float(input("Enter the Weight in Kilograms: ")) Pound = round(float(KG*2.2),2) print(f"\nThe Weight in Pounds is {Pound} lb")
true
c0d161a5c277d6f68fdd118fa8a00a3ec9da19b2
thecodesanctuary/python-study-group
/assessment/assessment_1/princess/1A.py
258
4.25
4
#This program converts temperature from Fahrehnheit to Celsius print('Conversion from Fahrenheit to Celsius \n') Fahrehn=int(input('Enter the temperature in Fahrehnheit: ')) Cel=round((Fahrehn-32)* 5/9, 2) print('\n The temperature in Celsius is ', Cel)
true
80c5b9239794b18991a07413cccdd52b069236d0
SZTankWang/dataStructure_2020Spring
/recitation3/Recitation3 Python Files/binary_search.py
2,288
4.15625
4
import random def binary_search_rec(x, sorted_list): # this function uses binary search to determine whether an ordered array # contains a specified value. # return True if value x is in the list # return False if value x is not in the list # If you need, you can use a helper function. # TO DO ...
true
f0286e3a80e564b81998480c8b2461d04ccde93c
SZTankWang/dataStructure_2020Spring
/recitation12/python files/union_intersection.py
1,553
4.21875
4
def union(l1, l2): """ :param l1: List[Int] -- the first python list :param l2: List[Int] -- the second python list Return a new python list of the union of l1 and l2. Order of elements in the output list doesn’t matter. Use python built in dictionary for this questi...
true
648bc1fef43834198aa01b1c84e83120ac56d303
raghukrishnamoorthy/Python-Cookbook
/02_Strings and Text/04_matching_and_searching_for_text_patterns.py
662
4.28125
4
text = 'yeah, but no, but yeah, but no, but yeah' print(text == 'yeah') print(text.startswith('yeah')) print(text.endswith('no')) print(text.find('no')) # For complicated matching use regex text1 = '11/27/2012' text2 = 'Nov 27, 2012' import re if re.match(r'\d+/\d+/\d+', text1): print('yes', text1) else: ...
true
13f9b86121d4ed355faba46d67e885ac2ad811ce
cmullis-it/KatakanaPractice
/kataGUI.py
1,473
4.125
4
# GUI Practice for the application import tkinter as tk import kataPairs #messing with Fonts import tkinter.font as font # Create the master window, and name "Kat.Pract." master = tk.Tk() master.title("Katakana Practice") ###### # Messing with Font Size myFont = font.Font(size=30) # Placeholders for the prompt/ co...
true
e7a51b4c84405c51d0bc7799213b6ec912036c3d
afrokoder/skywaywok
/order_entry.py
1,170
4.15625
4
import time import datetime from menu import menu from datetime import date #Welcome Screen print("Hello and welcome to SkyWay Wok!") time.sleep(1) print("\n\n") print("Today's date and time: ", datetime.datetime.now()) time.sleep(1) #Display list of available items #menus = ["bread","toast","eggs","muffins"] pr...
true
015a1da9b88778d9302acb4fbf69b60531d2d2c5
mycodestiny/100-days-of-code
/Day 3/Projects/even or odd.py
236
4.46875
4
#the purpose of this project states determine whether or not a number is odd or even. #while True number = int(input("What is your number?\n")) if number % 2 == 0: print("This number is even") else: print("This number is odd")
true
23044c15636580b54c2ed945b49fa9d010baa4d7
justincruz97/DataStructures-and-Algos
/LinkedLists/reverse_LL.py
811
4.5
4
from LinkedList import * ## reversing a linked list def reverse_linked_list(L): prev = None # this will be assigned as the new next curr = L # this is the node we are reassigning next next = None # this is the next node we wil work on while (curr != None): # store the next value next = curr.nex...
true
9b1fe89b45bfb105171c935e6f60d42d70fe8b67
justincruz97/DataStructures-and-Algos
/Sorting/selection_sort.py
440
4.125
4
# Selection sort, continuing finding small elements and adding it in order def selection_sort(arr): length = len(arr) for index in range(0, length): current_min = index for index2 in range(index, length): if (arr[index2] < arr[current_min]): current_min = index2 temp = arr[current_min] ...
true
4cbfa3c511fd5f73407251373c9ab9d241e73379
annamalo/py4e
/Exercises/ex_05_01/smallest.py
422
4.1875
4
smallest = None print('Before:', smallest) for itervar in [3, 41, 12, 9, 74, 15]: if smallest is None or itervar < smallest: smallest = itervar print('Loop:', itervar, smallest) print('Smallest:', smallest) def min(values): smallest = None for value in values: if smallest is None or va...
true
09c3a9cdc222b71a69ba60ebbe6a0e6e50133579
Anaisdg/Class_Resources
/UT_Work/Week_3_Python/Comprehensions.py
570
4.5
4
# -*- coding: UTF-8 -*- #create name input names = input("List 5 people that you know") splitnames = names.split() #create comprehension so that all items in list are lowercased lowernames = [names.lower() for names in splitnames] #create comprehension so that all items in list are capitalized capitalizednames = [nam...
true
43bd7130931ef987c6e0568d54444c15d9beb1cc
sudharsanansr/randomProblems
/secondLargest.py
245
4.15625
4
#find the second largest number in the given array arr = [12,4,2,51,34,54,345] largest = 0; second_largest = 0; for i in range(len(arr)): if arr[i] > largest: second_largest = largest largest = arr[i] print(second_largest)
true
9ece4acb90fc64465ef6a37fc7ad27fb17071a80
victenna/Math
/Quadratic_equation.py
1,022
4.34375
4
# quadratic equation # A program that computes the real roots of a quadratic equation. # Illustrates use of the math library. # Note: this program crashes if the equation has no real roots. import math # Makes the math library available. import turtle t=turtle.Turtle() wn=turtle.Screen() wn.bgcolor(...
true
ef4f72eceea4450dfb0ce77e3dcd39841433c536
nicholask98/CS-Dojo---Python-Tutotial--5-For-loop-Challenge
/main.py
235
4.1875
4
# Can you compute all multiples of 3, and 5 # That are less than 100? list_100 = list(range(1, 100)) list_multiples = [] for i in list_100: if i % 3 == 0 or i % 5 == 0: list_multiples.append(i) print(list_multiples)
true
a1a34376a29d5d5361a352eef1f2a1b0f31687ee
blip-lorist/python-the-hard-way
/ex6.py
1,259
4.28125
4
# Sets 'x' variable to a string with a format character that # takes an integer x = "There are %d types of people." % 10 # Sets 'binary' variable to a string binary = "binary" # Sets 'do_not' variable to a string do_not = "don't" # Sets 'y' variable to a string containing two string format characters y = "Those who kno...
true
35f952e031ba36520064dda00037eb434687427b
saligramdalchand/python_code_practice
/chapter3/cube_root using binary method.py
1,128
4.25
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Fri Jun 29 19:03:41 2018 @author: dc """ '''this program is for finding the cube root of integer either negative or positive''' '''this program is telling me things that i done wrong in the program of getting square root of the negative integer.. very usef...
true
ba2760fd6c61f1047e2c4a2abf577a1fa81c0e2e
saligramdalchand/python_code_practice
/chapter3/square root of negative integer.py
1,730
4.3125
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Fri Jun 29 18:10:38 2018 @author: dc """ #this is the finding of the square root of the number which is a negative integer number = float(input('please provide the interger number of which you want to get square root\n')) low = min(0,number) #these are ju...
true
6a8a53bb241aebe4018784e262aeb259d6eb49c2
saligramdalchand/python_code_practice
/chapter3/magical program.py
1,514
4.15625
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Fri Jul 6 09:48:06 2018 @author: dc """ #import time #this is a megical program that is going to print the value same as the user low = 0 high = 100 magical_number = (low+high)/2 character = ' ' checker = ' ' print ('Please think of a number between 0 an...
true
ae88663c89ed61c663ebe7d19edb439d82b54a91
zola-jane/MyCP1404Workshops
/Workshop5/lottery_generator.py
814
4.1875
4
""" This program asks the user how many quick picks they wish to generate. The program then generates that many lines of output. Each line consists of siz random numbers between 1 and 45 Each line should not contain any repeated number. Each line of numbers should be displayed in ascending order. """ def main(): ...
true
4b0667fbce2322865c6bb6a590fad10680fb5179
SakshiKhandare/Leetcode
/sqrt.py
730
4.28125
4
''' Given a non-negative integer x, compute and return the square root of x. Since the return type is an integer, the decimal digits are truncated, and only the integer part of the result is returned. Example: Input: x = 8 Output: 2 Explanation: The square root of 8 is 2.82842..., and since the decimal part is trunca...
true
93149ead3fab3596c0c3185126c7404252776a1d
SakshiKhandare/Leetcode
/divide_int.py
720
4.125
4
''' Given two integers dividend and divisor, divide two integers without using multiplication, division, and mod operator. Return the quotient after dividing dividend by divisor. Example: Input: dividend = 10, divisor = 3 Output: 3 Explanation: 10/3 = truncate(3.33333..) = 3. ''' import math class Solution: def d...
true
95218d56ab350cb642398be49d5c77e90440ab65
ihatetoast/lpthw
/python-class/class1_ifelif_cont.py
805
4.21875
4
health = 49 strHealth = str(health) print "A vicious warg is chasing you." print "Options:" print "1 - hide in the cave" print "2 - Climb a tree" input_value = raw_input("Enter choice: ") if input_value == "1": print "You hide in a cave." print "The warg finds you and injures your leg with his claws." health = hea...
true
6e0d8d2efca6586150389aaab19f9098c304e111
belushkin/Guess-the-number
/game.py
1,856
4.1875
4
# template for "Guess the number" mini-project # input will come from buttons and an input field # all output for the game will be printed in the console import simplegui import random import math # initialize global variables used in your code secret_number = 0 num_range = 100 guess_left = 7 def init(): global ...
true
5039fdabafb4517156c15150c5c69395647cb6bf
sherly75/python1
/intro3.py
1,904
4.3125
4
values =['a','b','c'] #values.append(1) #values.append(2) #values.append(3) values.extend([1,2,3]) print(values) print(values[2]) #deleting a value : del array_name[index] del values[1] print(values) #values.append(['d','e','f']) values.extend(['d','e','f']) print(values) #['d','e','f'] is one single elem...
true
678819346fc645b0cf0326ba95be403e491e9c01
buglenka/python-exercises
/FindReplace.py
2,555
4.46875
4
#!/usr/local/bin/python3.7 """Find And Replace in String To some string S, we will perform some replacement operations that replace groups of letters with new ones (not necessarily the same size). Each replacement operation has 3 parameters: a starting index i, a source word x and a target word y. The rule is tha...
true
0a38e961cddf6582e569c10475027e9573f8c1f4
buglenka/python-exercises
/TrappingWater.py
1,149
4.125
4
#!/usr/local/bin/python3.7 """Trapping Rain Water Given n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it is able to trap after raining. Example: Input: [0,1,0,2,1,0,1,3,2,1,2,1] Output: 6 """ from typing import List def trap(height: List[int]) -> ...
true
9bce4d77b4e1ff65794552c1d282240b4bffde78
buglenka/python-exercises
/ValidPalindrome.py
791
4.375
4
#!/usr/local/bin/python3.7 """Valid Palindrome Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases. Note: For the purpose of this problem, we define empty string as valid palindrome. Example 1: Input: "A man, a plan, a canal: Panama" Output: true Example 2: ...
true
ce54f35f9200d9c664bc1488d4bff5e62edba522
davidjb90/bicycle-project
/bicycle.py
2,281
4.34375
4
##This is the final 'model the bicycle industry' project in unit 1 ### Create the Bicycle Class import random class Bicycle: def __init__(self, manufacturer, model, weight, cost): self.manufacturer = manufacturer self.model = model self.weight = weight self.cost = cost ...
true
e96b588092e27565c1bbf0ed760148a48abe97b6
radhika2303/PPL_assignments
/assignment5/exception.py
1,948
4.3125
4
#1.NORMAL TRY-EXCEPT BLOCK IS IMPLEMENTED HERE print("Exception 1: (try-except block)\n") i = int(input("Enter 1st number :\n")) j = int(input("Enter 2nd number :\n")) try: k = i/j print(k) except: print("You divided by 0") print("No error shown because the exception was handled") #2.EXCEPTION FOR ZeroDivision E...
true
34801085f50cd1dd516bc64b8bffb544878932cf
saurav1066/python_assignment2
/10.py
812
4.46875
4
""" Write a function that takes camel-cased strings (i.e. ThisIsCamelCased), and converts them to snake case (i.e. this_is_camel_cased). Modify the function by adding an argument, separator, so it will also convert to the kebab case (i.e.this-is-camel-case) as well. """ import re def snake_cased_separator(string_...
true
bc97b5f762b360688f9f0bf662baf9965b3e67ea
marisha-g/INF200-2019
/src/marisha_gnanaseelan_ex/ex02/file_stats.py
1,002
4.3125
4
# -*- coding: utf-8 -*- __author__ = 'Marisha Gnanaseelan' __email__ = 'magn@nmbu.no' def char_counts(textfilename): """ This function opens and reads a given file with utf-8 encoding. It also counts how often each character code (0–255) occurs in the string and return the result as a list or tuple. ...
true
c8f22e2c0385bf7a4ff0c8344f24a995a92988e7
nachiket8188/Python-practice
/CSV Module.py
693
4.1875
4
import csv # with open('new_names.csv','r') as f: # csv_reader = csv.reader(f) # print(csv_reader) # this is an iterable object. Hence, the loop below. # next(csv_reader) # # for line in csv_reader: # # print(line) # with open('new_names.csv', 'w') as new_file: # csv_writer = csv.w...
true
f0654b773eebb8c9455020b77937b2e0018f2a00
JishnuSaseendran/Recursive_Lab
/task 21_22_Anand-Python Practice Book/3. Modules/9.py
299
4.28125
4
''' Problem 9: Write a regular expression to validate a phone number. ''' import re def val_mob_no(num): list=re.findall('\d{1,10}',num) print list if len(list[0])==10: print 'Your mobile number is valid' else: print 'sorry! Your mobile number is not valid' val_mob_no('9846131311')
true
63b856b7578497ba92e1f29eaa0e41f049e21899
Ron-Chang/MyNotebook
/Coding/Python/PyMoondra/Threading/demo_5_lock.py
1,355
4.21875
4
# lock 變數上鎖, lock variabl # 應用在多線程執行時有機會存取同一變數 # apply to multi-thread which might access or share the same variable # we can lock it until the processing tread has finished import threading # def adding_2(): # global x # lock.acquire() # for i in range(COUNT): # x += 2 # lock.release() # # e...
true
78e4f68240f7e24c6d7c3e78507ed927be5edef4
Ron-Chang/MyNotebook
/Coding/Python/Ron/Trials_and_Materials/Hello_world->elloHay_orldway.py
1,071
4.25
4
""" Move the first letter of each word to the end of it, then "ay" to the end of the word. Leave punctuation marks untouched. pig_it('Pig latin is cool') # igPay atinlay siay oolcay pig_it('Hello world !') # elloHay orldway !""" from string import punctuation def pig_it(text): sentence = text.split(" ") re...
true