blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
80a38cc5fe4eaed23f91e6271dd8758f4c785c71
natiawhitehead/-MasterInterview_Udemy
/LeetCode/_101_symmetric_tree.py
738
4.1875
4
# Given the root of a binary tree, check whether it is a mirror of itself(i.e., symmetric around its center). class TreeNode: def __init__(self, val=0, left=None, right=None): self.val = val self.left = left self.right = right class Solution: def isSymmetric(self, root: TreeNod...
true
6be9e0b732088ad32c419657343320e43987a889
dtepie1/pythonteachingcode
/4 DB in Python/MySQL Demo/P2M3DeniseTepie.py
639
4.1875
4
list_of = ['cat', 'goat', 'turtle'] def list_o_matic(): if user_input in list_of: list_of.remove(user_input) return print("animals left, one died: ", user_input, "was removed") elif user_input == "": return print("animals left, one was popped: ", user_input, "was popped", list_of.pop()) elif (user_i...
true
3536da8a706dd7489865a67f9cc5165b160a3cc0
AlecGoldstein123/April-Create-Task
/FINALGAME.py
2,967
4.1875
4
import random print("""You have stolen a car to go on the high speed thrill of your life. The police want to catch you and chasing you down! Survive the pursuit and keep the car.""") print() #variables milesTraveled = 0 thirst = 0 carHeat = 0 policeTraveled = -20 soda = 3 done = False gasStation = 0 #start main loop...
true
c811faa7772ef098f0d11c71f8dc5cb6f46c60ca
adamcasey/Interview-Prep-With-Python
/reverse_vowels_string.py
2,335
4.125
4
''' Leetcode: 345 Reverse Vowels In A String: Runtime: 80 ms, faster than 23.75% of Python3 online submissions for Reverse Vowels of a String. Memory Usage: 13.8 MB, less than 93.33% of Python3 online submissions for Reverse Vowels of a String. Write a function that takes a string as input and reverse only the vow...
true
bf0b9fc4903010fbbefcfee39c1ba093c310eb50
adamcasey/Interview-Prep-With-Python
/remove_element_SLL.py
2,473
4.15625
4
''' Remove all elements from a linked list of integers that have value val. Example: Input: 1->2->6->3->4->5->6, val = 6 Output: 1->2->3->4->5 Before writing any code, it's good to make a list of edge cases that we need to consider. This is so that we can be certain that we're not overlooking anything while coming up...
true
addcaaa9d0db598c92c81fc62c6857834e25c185
qiang-cynthia/Think_Python
/ex1_2_3.py
293
4.28125
4
# How many miles are there in 10 kilometers? kilometers = int(input('Kilometers: ')) print(f'How many miles in {kilometers} kilometers?') kilometers_per_mile = 1.61 kilometers_to_miles = round(kilometers / kilometers_per_mile, 2) print('The result is {} miles.'.format(kilometers_to_miles))
true
9c3081dae5d04ca79c4e3c9d5210f864683c970b
JLodewijk/Data-analysis-with-Python-2020
/part02-e10_extract_numbers/src/extract_numbers.py
620
4.25
4
#!/usr/bin/env python3 def extract_numbers(s): extracted_numbers = [] splitted_string = s.split() for word in splitted_string: # First try converting into int, if error then: try: extracted_numbers.append(int(word)) except: # Convert to float, else pass the...
true
792f834793fd8b4885de8477398f29f44130c566
Nirmit-bansal/Python-Assignment-of-Coursera
/ass6.py
1,078
4.375
4
#Write a program to prompt the user for hours and rate per hour using input to compute gross pay. # Pay should be the normal rate for hours up to 40 and time-and-a-half for the hourly rate for all hours worked above 40 hours. #Put the logic to do the computation of pay in a function called computepay() and use the f...
true
2a51c3b527c16158ad01a813d9f9241bd97f9257
phuclhv/Project-Euler
/67-PathsumII.py
1,080
4.25
4
''' Visualization with the 2D array index 00 10 11 20 21 22 30 31 32 33 40 41 42 43 44 Dynamic Programming Approach: We can see that as we go from the bottom to the top, we can choose to the highest value to be optimal maxValue is the 2D array to hold that purpose, the formula is ...
true
10a475e74b4d2057bfa1cc76452d9999d8704519
KristianMSchmidt/Algorithms-specialization-stanford-
/Course_3/week1_prims_algorithm/week1_scheduling.py
2,542
4.375
4
def make_list_from_data(): """ Reads data from txt-file and returns list of 10.000 tuples (job_weight, job_length) """ fh = open('data.txt') data = fh.read() data_lines = data.split('\n') data_lines = data_lines[1:-1] job_info = [] for line in data_lines: job = line.split()...
true
ca6e092a172287c81ccecea88e7e7e173947edcb
bayley-millar/CourseWork
/150/Lab4/changeparam.py
203
4.15625
4
def change_param(x): x = "goodbye" x= "hello" change_param(x) print x #output was just a straight hello. The assignment of x is changed #near the end of the program so it will use that assignment.
true
ec811ebe669c114f71dc987a23f18af4e788451d
bayley-millar/CourseWork
/150/Lab7/doctest_ex.py
771
4.125
4
def compare(a, b): """ returns 1 if a>b, 0 if a equals b, and -1 if a<b >>> compare(5, 4) 1 >>> compare(7, 7) 0 >>> compare(2, 3) -1 >>> compare(42, 1) 1 """ if a > b: print "1" elif a == b: print "0" elif a < b: print "-1" if __name__ == ...
true
571e977095d0fb7bbc64ef8235563c7426a13c34
cvhs-cs-2017/sem2-exam1-coneofshame
/Function.py
484
4.46875
4
"""Define a function that will take a parameter, n, and triple it and return the result""" def triple(n): n = n *3 return n print(triple(8)) """Write a program that will prompt the user for an input value (n) and print the result of 3n by calling the function defined above. Make sure you include the necess...
true
adb9756421dca6046466cad0dcc7dfc83247a21b
DanJamRod/codingbat
/list-2/big_diff.py
329
4.125
4
def big_diff(nums): """ Given an array length 1 or more of ints, return the difference between the largest and smallest values in the array. Note: the built-in min(v1, v2) and max(v1, v2) functions return the smaller or larger of two values. """ nums.sort() return nums[-1]-nums[0] print(big_diff([10, 3...
true
4961752f4972bd67588316c7254d52b72456342e
asad521/Machine-Learning-Data-Analysis
/Python Introduction/Python Simple Math Operation.py
777
4.3125
4
# This is second Tutorial. # Simple Path operation. print(3434-5) print(232+23) print(11*11) print(26/5) # For devision of floating points. Answer in floating points. print(26//5) # Round-off the floating point print(4**2) # For sqaure print(round(5**.5, 3)) print(33%3) #Modolus is zero print(32%3)#Modolus is zero # ...
true
908de9ce46a8e7568038d0570a872a667c2e42ff
aditineemkar/Python
/c98.py
282
4.25
4
def countWordsFromFile(): fileName=input('Name of the file: ') numberOfWords=0 f=open(fileName, "r") for i in f: words=i.split() numberOfWords=numberOfWords+len(words) print("Number of words: " + str(numberOfWords)) countWordsFromFile()
true
a4417d21fb99a429e6bbbd6c26847388d439c099
Chaluka/Algorithms
/Sorting/radix_sort_v2.py
2,333
4.25
4
""" This implementation use linked list count array to do the counting sort Given a list of integers, count sort convert each integer into a given base and do the sorting. """ __author__ = "Chaluka Salgado" __date__ = "18/10/2020" import math import random import time from typing import List, T...
true
e466a2bba073cc6f8f95d35a2d76ce5515377283
Abhishek-Chilekar/letsUpgrade
/Ass1/power.py
330
4.15625
4
while True: number = int(input("Enter the number ")) power = int(input("Enter the power ")) result = 1 for i in range(0,power): result = result * number print(f'{number} ^ {power} is {result}') choice = input("Want to continue ? (y/n) : ").lower() if(choice == 'y'): ...
true
afe61d063266bbd7e0251670e6971825a87d872f
bankoja/UnitTwo
/Unit 2.py
1,564
4.3125
4
#James Bankole 9/15/16 #This program calculates the compound and simple interest, displays them, and then calculates and displays the # difference between the two. #Introduce the program. print("This program calculates and compares compound and simple interest.") #Define the variables that the user is prompted to inp...
true
cf0f0ef1aba52c44f612e071d129e84000b2cde9
VibhorSaini88/Python-Assignment
/Assignment14.py
1,488
4.28125
4
#(Q.1)- Write a Python program to read last n lines of a file. c = -1 f = open('test.txt','r') content = f.readlines() n = int(input("Enter the number of lines: ")) while c >=-n: print(content[c],end="") c = c - 1 f.close() #(Q.2)- Write a Python program to count the frequency of words in a file. with open('...
true
667d4458728ed0e0e734b362719cc27f43c85d7b
hannesSimonsson/advent_of_code_2020
/day3/day3_2.py
1,530
4.15625
4
''' --- Part Two --- Time to check the rest of the slopes - you need to minimize the probability of a sudden arboreal stop, after all. Determine the number of trees you would encounter if, for each of the following slopes, you start at the top-left corner and traverse the map all the way to the bottom: - Right 1, do...
true
fc7851cbcf89a6ae5f93e2fa258a7df2ad05708b
Ghasak/Coding_Problems
/coding_problems/src/P10_CheatSheet_python_Practice.py
2,843
4.125
4
print("Hello world") msg = "Hello World" # Concatenation firstname = 'albert' lastname = 'einstein' fullname = firstname + ' ' +lastname print(fullname) #lists bikes = ['trek','redline','giant'] first_bike = bikes[0] last_bike = bikes [-1] print(first_bike, last_bike) for bike in bikes: print(bike, end = ' ') ...
true
b077b4ae71d7bb5634a9059f58fa476eaae7b1de
SalveDavid/Ejercicios_Mentoria
/Ejercicio2_Final.py
2,425
4.21875
4
# Write a function to read a file with employees details. # This is a file separated by ";", named empleados.txt which contains the names of the columns in the first line # like this: # - employee_code # - name # - lastname # - address # - age # - start_date # - salary # - position # - department # This file could co...
true
0cc77a4358bf9ed98140c19b715ed5dfa4ccab93
arod0214/python_intro_projects
/First Letter of Each Line in a File.py
564
4.53125
5
# Write a program that asks the user for the name of a text file, and then prints to the screen the first character of each line in that file. If the line is blank, print an empty line. # Hint: First get your program to pass Tests 1 and 2, which do not have blank lines in the file. Then add in the code to handle blank...
true
543633cf657e89c466addce6191b3c80144c65bd
arod0214/python_intro_projects
/Replacing Text.py
545
4.3125
4
##Write a program that asks the user for the name of an input file and the name of an output file. ##Your program should replace all occurrences of "NY" in the input file text with "New York", ##all occurrences of "NJ" with "New Jersey", andall occurrences of "CT" with "Connecticut" ##and write the results to the outpu...
true
3ee0e560716cd21a10a07ad38bf36e8cb68f208d
arod0214/python_intro_projects
/Writing Your Name in a Box.py
353
4.40625
4
# Use turtle graphics to write your name to the screen, surrounded by a box or polygon. You may write your name in "cursive" by moving the turtle, or may use the write() command to have it printed to the graphics screen. import turtle win = turtle.Screen() x = turtle.Turtle() for i in range(4): x.forward(100) ...
true
44f216b230539e52a20830f4ebd20d208b407653
arod0214/python_intro_projects
/Commands for a Turtle.py
1,985
4.53125
5
# The program turtleString.py takes a string as input and uses that string to control what the turtle draws on the screen (inspired by code.org's graph paper programming). Currently, the program processes the following commands: # 'F': moves the turtle forward # 'L': turns the turtle 90 degrees to the left # 'R': turn...
true
2baa82a1a37e2b61d7f80c3fa49de413fbb0efc5
bismanaeem/pythonAssignmentsForBeginners
/Qno8Palindrome String.py
498
4.28125
4
# -*- coding: utf-8 -*- """ Created on Mon Jul 15 10:04:48 2019 @author: Bisma Naeem """ #Qno 8 #Check whether the string entered by the user is a palindrome or not str1 = input("please enter a string to check whether its a PALINDROME or not:") def Palindrome_Str(str1): str2 = str1[::-1] print(s...
true
838455f1b4b70bdcda9185026ffbc0572b682cf9
sumoward/programming-test
/integer_list.py
1,393
4.125
4
""" Write a function that finds an integer in a list of unsorted integers that appears only once. Use the following as the list of integers: [23, 901, 78, 1927, 56, 92, 567, 987, 12, 9, 45, 1936, 76, 39, 82, 43, 78, 901, 56, 23, 92, 43, 1927, 39, 9, 45, ...
true
04128195c40ef7c6e86a7230f9d3b78f6361f4c0
miltonjdaz/learning_py
/single_scripts/Car_Driver.py
1,050
4.28125
4
# Author: Milton D'az # File: Car_Driver.py # # A program tells you the make, model, year, and odometer of a car class Car: """This class returns all the values needed to produce the correct output""" def __init__(self, make, model, year, odometerReading): self.make = make self.model = model self.year = year ...
true
96d92223e387db5b1dae84314fc252f415fc1d9b
BrianSekwakwa/python-3
/Dictionaries/dictionaries.py
2,463
4.6875
5
# // DICTIONARIES # / they are data structures that consists of key value pairs # / Keys to describe our data and values to represent the data # / Example # instructor = { # "name": "colt", # "owns_dog": True, # "num_courses": 4, # "favorite_language": "python", # "is_halarious": False, # 44: "my favorit...
true
4e3c50b908e56abb04ecb470c4de25bd94ecff93
BrianSekwakwa/python-3
/Debugging And Error Handling/debug.py
1,201
4.125
4
# // Common Python Errors # SyntaxError - wrong syntax python cannot understand # NameError - When a variable is not defined # TypeError - Operation applied to the wrong type # IndexError - When you try to access an item in list with the wrong index # ValueError - Built-in function that receives the right type of argu...
true
5e601a1fe4e829fa697e0b280dd9812c21a60f6d
svrswetha/Python
/calci.py
1,349
4.28125
4
"""Calculator""" """ Perform basic calculations with 2 numbers""" """Addition""" def add(number1, number2): return number1 + number2 """Subtraction""" def sub(number1, number2): return number1 - number2 """Multiplication""" def mul(number1, number2): return number1 * number2 """Division""" def div(number1, n...
true
0e62bc19f4877b1a147a3aa8568fd05f1d04c967
trevorlangston/cci
/questions/4/4-6.py
644
4.125
4
def find_successor(node): pass if __name__ == "__main__": pass """ if node.right: # A node can either be the left child or the right child of it's parent. # If it is the left child, then the node's right child must be greater then # the node, and less than the node's parent. If it is the right ch...
true
0a1f4deefcd3833f44d3bdfad7f24ab426397f83
hypergamer93/dice-roller
/diceRoller v1.0.py
641
4.21875
4
import random amount = 1 dice = 4 choice = "" def diceRoller(amount, dice): try: choice = int(input("How many dice would you like to roll? :")) except ValueError: print("That is not a number") else: amount = choice try: choice = int(input("What is the hightst num...
true
7ab54b74426e0f9aab4d59cd2c4e48a78fac75c7
mouniqa/python
/fibonacci.py
382
4.21875
4
# prints fiboncci sereis up to n n=int(input('Enter the number upto which fibonacci series will be printed.\n\tn = ')) fib_list = [1,1] a=1 b=1 print(a,b,end=' ') def fibonacci(a,b): if(a+b<=n): fib_list.append(a+b) print(a+b,end=' ') fibonacci(b,a+b) else: print() return...
true
0aa71024b7ee699c1795ff70846e992c675c18df
bkiselgof/real_python
/exceptions.py
2,237
4.125
4
''' Table of Contents Exceptions versus Syntax Errors Raising an Exception The AssertionError Exception The try and except Block: Handling Exceptions The else Clause Cleaning Up After Using finally Summing Up ''' x = 10 if x > 5: raise Exception('x should not exceed 5. The value of x was: {}'.format(x)) #The Ass...
true
c02a4621a2650eafaf93dcd5a68475dfbb67fa11
VardgesDavtyan19931208/homework
/area_of_circle.py
287
4.21875
4
name = input("Hello, what`s your name?: ") print("Nice to meet you, " + name + "! Just insert the radius of circle and I will show its area") radius = input("Input the radius: ") import math area_of_circle = 3.14 * (float(radius)**2) print("Area of circle is " + str(area_of_circle))
true
948d7407c741dd1eb1060cf7799f0040025201da
Levronsky/Form_and_print_receipt
/receipt.py
1,247
4.15625
4
PRODUCTS = [ # for example ['apples', 100], ['swiss cheese', 1500], ['red fish', 450], ['cold smoked grouped', 12400], ] def create_formatted_receipt(products): '''Form a check for printing. The function argument is a shopping list, consisting of the product name and price. As a r...
true
c5df488a43974c685470e7e577c6d6c4c12011c5
apurvashekhar/UC_Berkely_X442.3
/apurva.shekhar_X442.3_Assignment_10.py
2,885
4.28125
4
#Write a simple Rectangle class. It should do the following: #Accepts length and width as parameters when creating a new instance #Has a perimeter method that returns the perimeter of the rectangle #Has an area method that returns the area of the rectangle #Don't worry about coordinates or negative val...
true
d4d9a08490a1e9b91eaf7fa267c33cceedf8db51
vaibhavboliya/DSA-Programming-Problems
/Geeksforgeeks/graphs/Print adjacency list.py
1,792
4.46875
4
# URL: https://practice.geeksforgeeks.org/problems/print-adjacency-list-1587115620/0 # Given the adjacency list of a bidirectional graph. Your task is to return the adjacency list for each vertex. # Example 1: # Input: # v E # Output: # 0-> 1-> 4 # 1-> 0-> 2-> 3-> 4 # 2-> 1-> 3 # 3-> 1-> 2-> 4 # 4-> 0-> 1-> 3 # Expla...
true
d426fd0708145f0f17b8c36484582b9901e6b739
vaibhavboliya/DSA-Programming-Problems
/Geeksforgeeks/graphs/Count The Path.py
2,143
4.125
4
# URL: https://practice.geeksforgeeks.org/problems/count-the-paths4332/1 # Given a directed acyclic graph(DAG) with n nodes labeled from 0 to n-1. # Given edges, s and d ,count the number of ways to reach from s to d. # There is a directed Edge from vertex edges[i][0] to the vertex edges[i][1]. # Example: # Input...
true
b00a91810b58860f16548fdd71efa5c7ab97c8ad
brainyfarm/FreeCodeCamp-algorithms-Python-
/where_do_i_belong.py
662
4.3125
4
""" Return the lowest index at which a value (second argument) should be inserted into an array (first argument) once it has been sorted. The returned value should be a number. For example, getIndexToIns([1,2,3,4], 1.5) should return 1 because it is greater than 1 (index 0), but less than 2 (index 1). Likewise, ge...
true
a25e3886fe037d840f77e005fac0da0f37d6933b
brainyfarm/FreeCodeCamp-algorithms-Python-
/caesars_cipher.py
1,054
4.28125
4
# -*- coding: utf-8 -*- """ One of the simplest and most widely known ciphers is a Caesar cipher, also known as a shift cipher. In a shift cipher the meanings of the letters are shifted by some set amount. A common modern use is the ROT13 cipher, where the values of the letters are shifted by 13 places. Thus 'A' ↔ '...
true
ae2cd291b89ef17cb4f3085b2260af00491271e6
shoriwe-upb/ejercicios-en-clase
/2.1.1 Diseno de algoritmos/altura_cometa.py
418
4.3125
4
from math import sin, pi # a is the known angle and c is the lower leg of the triangle def calculate_height(a, c): third_angle = (90 - a) * pi / 180 a = a * pi / 180 height = sin(a) / (sin(third_angle) / c) return height def main(): a = float(input("Angle: ")) c = float(input("Leg: ")) ...
true
142e61b5320c81d6d158390b7f63455a53381c09
Mahaprasad003/python_learning
/Chapter 5_dictionary&sets/02_dictionary_methods.py
576
4.125
4
mydict = { 'harry': 'Coder', 'mp': 'Noob', 'marks': [1,3,4], 'anotherdict' : {'Mp': 'Player'} } print(mydict.keys()) # prints the keys of the dictionaries print(type(mydict.keys())) print(mydict.values()) # prints the values of the dictionaries print(mydict.items()) # prints the (key, value) of the di...
true
b1f14e3cf7933dd865839b148d4f578d99e46c60
ALI-ZIA-KHAN/Python-Basic-Concepts
/sin cos tan.py
626
4.21875
4
from math import * def main(): trig=(input("What do you want to calculate sine,cosine or tangent?")) if (trig=="sine"): a=eval(input("What is the angle measure")) result = sin(radians(a)) print("The answer is" +" "+ str(round(result,3))) elif (trig == "cosine"): a = eval(input("What is the ...
true
84074efa8f49e0eb64d528a68006f25e8788232a
irvinhi/Study
/w3resource/e4.py
234
4.375
4
#Write a Python program which accepts the radius of a circle from the user and compute the area. Go to the editor #Sample Output : #r = 1.1 #Area = 3.8013271108436504 import math r = float(input()) area = math.pi * r * r print(area)
true
5f94640ce253c625dab9f60cd18f2eab059a9a3a
JohnByrneJames/SpartaGlobalRepo
/Python-Files/Revision-Files/lists.py
1,683
4.65625
5
# Data Collection # In Java they use Arrays / However in Python lists are same as arrays # Both serve same purpose of storing data # Good at managing data - Access data in order - it gives us option to add, remove data (mutable) # Syntax of list [ a list ] square brackets (tuples) and {dictionary - key:value} # Tuple...
true
3dc86b2cd3c3889152f1fcfdefff38a4ba4d6371
JohnByrneJames/SpartaGlobalRepo
/Python-Files/Revision-Files/control_flow.py
1,904
4.625
5
# What is control flow # Conditional statements and loops # IF, ELSE, ELIF, FOR LOOP, WHILE LOOP weather = "snowy" conditional_weather = "rainy" # Do a comparison to see if the value "sunny" is inside the weather variable # This is a conditional block of code, if "sunny" then display "Lets go to.." # If it is not "s...
true
309eca25054e1e87dd2d89f705d1fe3dd2687a44
alifa2try/Python-How-To-Program
/CHAPTER THREE/Palindrome.py
1,142
4.15625
4
# Palindrome Program # Exercise 3.4 Deitel How To Program ''' A palindrome is a number or a text phrase that reads the same backwards or forwards. For example, each of the following five-digit integers is a palindrome: 12321, 55555, 45554 and 11611. Write a program that reads in a five-digit integer and determin...
true
806b516e7aeb89e45a433cc25df3d636bb9c54cd
alifa2try/Python-How-To-Program
/CHAPTER FOUR/PerfectNumbers.py
966
4.1875
4
''' PerfectNumbers Program Author: Faisal Ali Garba ( Malware Analyst ), Date: 29/11/2017 An integer number is said to be a perfect number if the sum of its factors, including 1 (but not the number itself), is equal to the number. For example, 6 is a perfect number, because 6 = 1 + 2 + 3. Write a function perfect...
true
a97638db8dcf2b096534e15e44519084264c2899
makhabatmaksatbekova/Python_exercises
/exercise_13.py
851
4.5
4
""" Write a program that asks the user how many Fibonnaci numbers to generate and then generates them. Take this opportunity to think about how you can use functions. Make sure to ask the user to enter the number of numbers in the sequence to generate. (Hint: The Fibonnaci seqence is a sequence of num...
true
9b13795fe810e107949be4fb73b9975ae5f6f1c6
tijesu24/StartNG-Python-2-User-details-
/SNG py2.py
2,546
4.125
4
# -*- coding: utf-8 -*- """ Created on Fri Apr 3 20:39:45 2020 @author: Tijesunimi.Adebiyi """ import random import string def get_password(firstname,lastname): #Generate random password for the user joining the #first 2 letters of the first name and last 2 letters of #the last name with a random strin...
true
f3e44844dcdd73d3333091d39bf84a716938c842
I-AM-FRANKENSTEIN/Rock-Paper-Scissors-Game
/RockPaperScissors.py
2,297
4.25
4
import random def userChoice(): # userChoice()is the function for choosing Rock/Paper/Scissors from the user player_choice=input("Enter your choice:- ") while not (player_choice=="rock" or player_choice=="paper" or player_choice=="scissors"): print("Enter your choice again") ...
true
181ee6460bfcae69cd0dbd4d2b59204d46ecc9b8
iSmashButtons/pyProJrDev
/oddOrEven/oddOrEven.py
896
4.375
4
#!/usr/bin/python3 # ____ _____ ______ # / __ \/ ___// ____/ A Python script by Dennis Chaves # / / / /\__ \/ / github.com/ismashbuttons # / /_/ /___/ / /___ dennis@dennischaves.xyz # /_____//____/\____/ # # Odd or Even # Welcome a user then ask them for a number between 1 ...
true
0fd12685504c635cae5622a362902b5762128c77
anr4u/python-deep-Learning
/ICP1/String_replace.py
211
4.59375
5
# User input input_string = input("Enter the String:") # Replacing python with pythons in the given the given string print("Replaced string 'python' with 'pythons':", input_string.replace("python", "pythons"))
true
88889e0a3085ebed3d0990e1fd660f56f6b91160
anr4u/python-deep-Learning
/ICP1/String_reverse.py
639
4.25
4
from random import randint # function to delete given number of characters from the string and to reverse the remaining string def reverse_string(str): new_string= "" for x in range(0, int(num)): pos = randint(0, len(str) - 1) new_string += str[pos] str = str[:pos] + str[pos + 1:] ...
true
fb309bff60b5dd262716c86e1092a7414f68d42a
mloumeau/Data-Structure-Tutorial
/pythonFiles/stackSolution.py
950
4.125
4
def isValid(s): #Our stack is an array data type that we will treat as a stack stack = [] #Dictionary to detect closing brackets mapping = {")": "(", "}": "{", "]": "["} for char in s: #If closing bracket found if char in mapping: #If stack is not empty, remove last eleme...
true
66df1f51ed264fa1f8f9a1dd58b800c5c81d0722
encloudme/python
/generator.py
1,194
4.625
5
""" Demonstrate the functionality of Generators in Python """ """ Below is an example of simple generator, which is a function that acts as an iterator The value of previous invocation is remembered and only next value is returned ---> "ON DEMAND" The use of "yield" instead of "return" makes below functio...
true
b6a0ffc5a32b99fef3d24224c3eb85936c78aa24
Yeshu076/Python-Bootcamp
/Day7.py
925
4.3125
4
# Q1. Create a function getting two integer inputs from user and perform basic mathematical operations def math(num1, num2): print("Addition of two numbers", num1 + num2) print("Subtraction of two numbers", num1 - num2) print("Multiplication of two numbers", num1 * num2) print("Division of two nu...
true
cc3e9c1c41d06640d11bf6998bc59152af4790b1
Vignesh-Durairaj/Python-Exercises
/euler/problem_0009.py
978
4.25
4
# Special Pythagorean triplet # A Pythagorean triplet is a set of three natural numbers, a < b < c, for which, # # a2 + b2 = c2 # For example, 32 + 42 = 9 + 16 = 25 = 52. # # There exists exactly one Pythagorean triplet for which a + b + c = 1000. # Find the product abc. """ Solution Approach ================= * Usin...
true
7d9c24f557292edbe3673af5890a240b9630c46f
Vignesh-Durairaj/Python-Exercises
/sololearn/data_hiding.py
2,758
4.15625
4
""" Data Hiding A key part of object-oriented programming is encapsulation, which involves packaging of related variables and functions into a single easy-to-use object - an instance of a class. A related concept is data hiding, which states that implementation details of a class should be hidden, and a clean standard...
true
6a7fab211a9b80ea5ece3bc81018fe281bc2666c
Vignesh-Durairaj/Python-Exercises
/euler/problem_0038.py
1,580
4.40625
4
# Pandigital multiples # # Take the number 192 and multiply it by each of 1, 2, and 3: # # 192 x 1 = 192 # 192 x 2 = 384 # 192 x 3 = 576 # By concatenating each product we get the 1 to 9 pandigital, 192384576. We will call 192384576 the concatenated product # of 192 and (1,2,3) # # The same can be achieved by starting ...
true
2a7bafe7740c795dec2cec0b0105941f4550b1db
Vignesh-Durairaj/Python-Exercises
/euler/problem_0001.py
480
4.25
4
# Multiples of 3 and 5 # 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. import sys def main(): args = sys.argv if len(args) == 2 and args[1].isdigit(): par...
true
76547c2ac1b3f8f4dc016785b141a7d10873afd8
AkshatDobriyal/algos
/quick_select/quick_select.py
1,494
4.28125
4
def partition(array, start, end): """ Perform Partition Operation on array a. Time Complexity: O(nLogn) Auxiliary Space: O(n) :param a: Iterable of elements :param start: pivot value for array :param end: right limit of array :return: return i value for function, used in partitioning of ...
true
ef6c8ae3bda0e2126efe95ca7eba026fa90e9b44
AkshatDobriyal/algos
/radix_sort/radix_sort.py
1,313
4.21875
4
# Following is the implementation of Radix Sort. def radix_sort(arr, radix=10): """ :param arr: Iterable of elements to sort. :param radix: Base of input numbers :return: Sorted list of input. Time complexity: O(d * (n + b)) where, n is the size of input list. b is base of represent...
true
a0e9d153b39d280390d49fd55a12376b3ef3e407
cronologi/practice
/exercises/arrays_and_strings/is_unique.py
344
4.15625
4
# Implement an algorithm to determine if a string has all unique characters. What if you cannot use additional data structures? def is_unique(string): temp_dict = {} for char in string: if char in temp_dict: return False temp_dict[char] = None return True state = is_unique("Da...
true
deed940b8e94cc3b91c79e8907e2a7b6a507c224
rizniyarasheed/python
/oops/methodoverriding.py
610
4.1875
4
class Parent: def mobile(self): print("nokia 5520") class Child(Parent): def mobile(self): print("iph 11") obj=Child() obj.mobile() #object class #default class Parent: def mobile(self): print("nokia 5520") c=Parent() print(c) #o/p==><__main__.Parent object at 0x000001F4F73D9400>...
true
70e74f06d3b2baf32e6631a2991b7a82c31df971
sunintb/Programming-Computation
/quicksortAndVisualizeWorldCities/cityInfoQuicksort/city.py
996
4.3125
4
# Sunint Bindra # February 20, 2019 # city.py # lab3cs1 # This program is a class for the city function that allows taking in information about a city/location and then # modifying it to create a string of specific information # Creates a class named Body class City: # Defines parameters that will be used, mo...
true
3e81944c4d7b29e57a39d5e0eb459459c647dda5
jeyk333/Core-Python
/lists.py
2,125
4.5
4
# A list is a collection which is ordered and changeable. In Python lists are written with square brackets. # Allow duplicate values # Different ways to create a list nums1 = [1, 2, 3, 4, 5] nums2 = list((1, 2, 3, 4, 5)) # Using constructor print(nums1) # prints - [1, 2, 3, 4, 5] print(nums2) # prints - [1, 2, 3, 4,...
true
9ac294ac0b03f14293476cf38136329536da8ca6
AndanteKim/AP_Archive
/Undergrad_research(Machine Learning) Project/Machine Learning_undergraduate research project/lab1-part1/scope.py
2,277
4.5
4
#!/usr/bin/env python ################################################################# # Scope is a term used to describe where a variable can be used # # If you try to use a variable before you have declared it, the # # computer doesn't know what you're talking about # ##############################################...
true
e8c13dd3c05ccfbff6f6b2cdf1317b75168687a8
AndanteKim/AP_Archive
/Undergrad_research(Machine Learning) Project/Machine Learning_undergraduate research project/lab1-part1/conditional_execution.py
1,515
4.21875
4
#!/usr/bin/env python ######################################################################################### ## Below are examples of control flow statements. ## Try to figure out what this script will print before running it. ########################################################################################...
true
22582ac41bd226f7d8b49c2293440347e9ecec87
prafful/python_numpy_scipy_june2020
/016 python_filoio.py
1,795
4.25
4
""" File IO 1. Open the file in specific mode 2. Receive the file handle. 3. Use file handle for file operations (red, write, change, delete) 4. Close the file handle. """ print("Opening the file: ") fh = open("001 hello_world.py", "r" ) print(fh) print(fh.mode + " " + fh.name) print("File is open: " + str(not(fh.clo...
true
c2e60c8039ea9bc9f3a85fbd2addc0a6b5bc3c93
tradaviahe1982/Data-Structure-and-Algorithms-in-Python
/Arrays/Arrays.py
736
4.125
4
# Arrays arr = [1,2,3,4,5] # Random Indexing -> O(1) complexity if we know index of # item to get fromm array print(arr[1]) # Insert item at given index # Complexity O(N) to add item at given index arr[1] = 200 # print(arr[1]) # print all items in array for num in arr: print(num) # print all items in array usi...
true
59fd0b07f15c476dd91a925795b9d6c5f219938b
Naman-12911/HackerRank-30-days-code
/5 day of HackerRank.py
648
4.15625
4
#TASK #Given an integer, , print its first multiples. Each multiple (where ) should be printed on a new line in the form: n x i = result. #Input Format #A single integer, . #Output Format #Print lines of output; each line (where ) contains the of in the form: #n x i = result. #Sample Input #2 ...
true
3501ba649005ab768d72ed62656ef77fc8bfa7df
cademccu/cs152
/programs/A3.py
1,464
4.125
4
# Great Circle Distances between geographic points # import the math functions we need. from math import radians, acos, sin, cos, fabs def convert(num): return radians(num[0]), radians(num[1]) def lawOfCosines(geo1, geo2): # The geographic coordinates are tuples with latitude and longitude values # convert ...
true
5c74a6e5e20aa3ac5bd4b9d7899f85511c61de7b
jeonghoonkang/python_study
/ds_reference.py
534
4.15625
4
#Simple reference example# print 'Simple Assignment' shopping_list=['apple', 'banana', 'mango', 'strawberry'] mylist = shopping_list del shopping_list[0] print 'Shopping list is', shopping_list #['banana', 'mango', 'strawberry'] print 'My list is', mylist #['banana', 'mango', 'strawberry'] pri...
true
a33a9c27f06f09138f0d73d5cdc002d68a215857
mezgoodle/algoritms-kpi
/First_lab/first.py
851
4.125
4
# Input array arr = list(map(int, input().split(', '))) arr_even = list() arr_odd = list() def check_elements(arr): for element in arr: if element % 2 == 0: arr_even.append(element) else: arr_odd.append(element) # # Function to do insertion sort def insertionSort(arr): ...
true
993e8c1fdcb0e62d0373ee6e5afb5d14b69730cd
nitsas/py3algs
/py3algs/algorithms/binary_exponentiation.py
1,597
4.75
5
""" Exponentiate quickly, using the binary exponentiation algorithm. Also known as exponentiation by squaring, or square-and-multiply. Author: Christos Nitsas (nitsas) (chrisnitsas) Language: Python 3(.4) Date: October, 2014 """ __all__ = ['binary_exponentiation', 'power'] def binary_exponentiation(nu...
true
133b843ec5c634611540a821727e79c31d0dc120
decchu14/Defang_IP_Address
/defang_ip_address.py
513
4.1875
4
# To convert an IP address to a defanged IP address, we need to replace “.” with “[.]”. During coding interviews, a standard problem for changing an IP address is that you receive a valid IP address, you must return a defanged version of that IP address. def ip_address_func(ip_address): new_address = " " split_...
true
ead2eec9da98e33a73528377f99e024baafba500
iabhigupta/python
/python-antiVowel/antiVowel.py
302
4.59375
5
def anti_vowel(text): new_text = "" # this is a variable to hold the new text without vowels for letter in text: if letter not in ('aeiouAEIOU'): # check if letter is not a vowel new_text += letter # if letter is not a vowel add it to new_text return new_text
true
34a1c91be894339c5226cb36c211b009be2240e9
iabhigupta/python
/python-advanced/3/3_2.py
2,088
4.21875
4
import sqlite3 con = sqlite3.connect("test2.db") cur = con.cursor() cur.execute("drop table department") cur.execute("create table department(id integer primary key,name text)") cur.execute("insert into department values(1,'automation')") cur.execute("insert into department values(2,'finance')") cur.execute("insert...
true
b868e78bc01ea56cca554d6ba427aea55714cfd4
kevin-reaves/LeetCode
/215 - Kth Largest Element.py
501
4.15625
4
""" Find the kth largest element in an unsorted array. Note that it is the kth largest element in the sorted order, not the kth distinct element. For example, Given [3,2,1,5,6,4] and k = 2, return 5. Note: You may assume k is always valid, 1 ≤ k ≤ array's length. """ from random import shuffle class Solution(object)...
true
8f50ffed4c3a7b86aaca918ef245be33e0d6372e
kevin-reaves/LeetCode
/231 - Power of Two
451
4.15625
4
#!/usr/bin/python """ Given an integer, write a function to determine if it is a power of two. """ class Solution: def isPowerOfTwo(self, n): if n <= 0: return False # 4 is a power of 2, 6 is not. 6 / 2 = 3, 3 / 2 = decimal while n % 2 == 0: n = n / 2 ret...
true
0aeec11b076c076020063f1cf6d90f7bc0669c13
db302/git_ads
/Ex1/insertionsort.py
1,176
4.28125
4
#!/usr/bin/python3 def swap(a, b): """ >>> swap(1, 2) (2, 1) """ temp = a a = b b = temp del temp return a, b def insertionsort(lst): """ Sort list using the Insertion Sort algorithm. >>> insertionsort([24, 6, 12, 32, 18]) [6, 12, 18, 24, 32] >>> insertionsort...
true
729dd1350f6518c68732f0756f856131b4e12b0c
sobotadom/Python_problems
/random_number_guess.py
965
4.125
4
import random __author__ = 'Dom' """ 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 whe...
true
5fcb50dada3a3675de350d5bb0903bc2660ec9e8
Suhaiz/first
/language fundamentals/prime while range.py
306
4.15625
4
maxi=int(input("enter the maximum integer\t")) possibleprime=2 while possibleprime<maxi+1: isprime=True num=2 while num<possibleprime: if possibleprime%num==0: isprime=False break num+=1 if isprime: print(possibleprime) possibleprime+=1
true
17818cdb97377edebad9fa5db69130867ce5cb20
Suhaiz/first
/try_and_exception/exception.py
1,595
4.15625
4
##whenever there is an abnormal condition # no1=int(input("enter any no")) # no2=int(input("enter second no")) # try: # res=no1/no2 # print("res=",res) # except: # print("exception occured") # # print("i have one database connection") # ################################################# # # no1=int(input("...
true
1cebc524b3982111313ee03b85a615ba276f726a
Murgowt/CodeBase
/Freelancing/Exam.py
609
4.1875
4
#Function to calculate tax and then output the tip and the toal bill def calculateTipAndDisplayTotalBill(foodBill): #Calculating the tip as 20% of the cost of food tip = foodBill * 0.20 #Calculating the total bill including the cost of food and tip total = foodBill + tip #Displaying the output ...
true
24db34af329cd6b96fee20e9c2ce4abc76298606
rsoderberg/Online-Studying
/Georgia Institute of Technology/CS1301xII - Computing in Python II/3.3.10CodingProblem.py
544
4.125
4
mystery_int = 5 #Write a program that will print the times table for the #value given by mystery_int. The times table should print a #two-column table of the products of every combination of #two numbers from 1 through mystery_int. Separate consecutive #numbers with either spaces or tabs, whichever you prefer. #For e...
true
0e8c2799d4727b9d3b715d1a7b12c767ac79b075
abdlalisalmi/42-AI-bootcamp
/python/module00/ex03/count.py
960
4.375
4
from string import punctuation def text_analyzer(*text): """ This function counts the number of upper characters, lower characters, punctuation and spaces in a given text.""" if len(text) > 1: print("ERROR") return elif len(text) == 1: text = list(text)[0] elif len(text) == 0:...
true
eb34eda8ffb9ef37490ae4bab6d70723c8b7ab69
blhwong/algos_py
/grokking/bitwise_xor/complement_of_base_10/main.py
911
4.1875
4
""" Problem Statement # Every non-negative integer N has a binary representation, for example, 8 can be represented as “1000” in binary and 7 as “0111” in binary. The complement of a binary representation is the number in binary that we get when we change every 1 to a 0 and every 0 to a 1. For example, the binary comp...
true
cf7d2c343b93925b510101c213a0de2a5ed140b8
blhwong/algos_py
/grokking/subsets/permutations/main.py
1,025
4.125
4
""" Problem Statement # Given a set of distinct numbers, find all of its permutations. Permutation is defined as the re-arranging of the elements of the set. For example, {1, 2, 3} has the following six permutations: {1, 2, 3} {1, 3, 2} {2, 1, 3} {2, 3, 1} {3, 1, 2} {3, 2, 1} If a set has ‘n’ distinct elements it wil...
true
789d7974ced7e1876bb0493a9f3a937f3706867b
blhwong/algos_py
/grokking_dp/longest_common_substring/longest_alternating_subsequence/main.py
1,362
4.40625
4
""" Problem Statement Given a number sequence, find the length of its Longest Alternating Subsequence (LAS). A subsequence is considered alternating if its elements are in alternating order. A three element sequence (a1, a2, a3) will be an alternating sequence if its elements hold one of the following conditions: {a1...
true
2939c7cbab8230a9f9177dbff7d12bde167b169a
blhwong/algos_py
/grokking/topological_sort_graph/all_tasks_scheduling_order/main.py
2,026
4.375
4
""" Problem Statement # There are ‘N’ tasks, labeled from ‘0’ to ‘N-1’. Each task can have some prerequisite tasks which need to be completed before it can be scheduled. Given the number of tasks and a list of prerequisite pairs, write a method to print all possible ordering of tasks meeting all prerequisites. Example...
true
10f9d9662d404241ebc36e7dbaeec81b32d1f8c7
Imrani-15/Tuple
/Accessing of tuple.py
284
4.5
4
# Accessing tuple with indexing tuple = tuple('banana') print("\nAccessing tuple with indexing:") print(tuple) # Tuple unpacking tuple1 = ("grapes","apple","orange") # This line unpack values of tuple1 a, b, c = tuple1 print("\nvalues after unpacking:") print(a) print(b) print(c)
true
4a2ef000161c98b187b38b11de8e0dd3e1d3ee76
mobilerobotp4/Leet_code_solution
/89_Gray_code.py
958
4.15625
4
''' The gray code is a binary numeral system where two successive values differ in only one bit. Given a non-negative integer n representing the total number of bits in the code, print the sequence of gray code. A gray code sequence must begin with 0. Example 1: Input: 2 Output: [0,1,3,2] Explanation: 00 - 0 01 - 1 ...
true
b0ec5e5eed3ccb8d7818d71c7fcdff650c5a3b42
zgarzella/CS1
/Lesson 3 Practice/nursery.py
322
4.28125
4
# Zack Garzella # Nursery Rhyme # This program will take a nursery rhyme from the user and make all the... # ... letters other than the first of each word are capitalized. nursery = input("Enter a Nursery Rhyme: ") nursery = nursery.title() print (nursery.swapcase()) input("\n\nPress the enter key to ...
true
10e414f05d8414b1444f42a6d137301361932e89
zgarzella/CS1
/Lesson 2 Problems/foods.py
279
4.1875
4
# Zack Garzella # Favorite Foods # The purpose is to output the user's favorite foods food1 = input("Please enter favorite food: ") food2 = input("Please enter another favorite food: ") print ("You should try " + food1 + food2) input("\n\nPress the enter key to exit.")
true