blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
bb50b8feabc4e027222ed347042d5cefdf0e64da
abtripathi/data_structures_and_algorithms
/problems_and_solutions/arrays/Duplicate-Number_solution.py
1,449
4.15625
4
# Solution ''' Notice carefully that 1. All the elements of the array are always non-negative 2. If array length = n, then elements would start from 0 to (n-2), i.e. Natural numbers 0,1,2,3,4,5...(n-2) 3. There is only SINGLE element which is present twice. Therefore let's find the sum of all elements (current_sum) of...
true
26d6e211c524aae3668176e7f54638f589b9226c
nicholasrokosz/python-crash-course
/Ch. 15/random_walk.py
945
4.25
4
from random import choice class RandomWalk: """Generates random walks.""" def __init__(self, num_points=5000): """Initializes walk attributes.""" self.num_points = num_points # Walks start at (0, 0). self.x_values = [0] self.y_values = [0] def fill_walk(self): """Calculate all the points in a walk.""...
true
6405fb18f932d4ef96807f2dc65b04401f32e5be
nicholasrokosz/python-crash-course
/Ch. 10/favorite_number.py
467
4.125
4
import json def get_fav_num(): """Asks a user for their favorite number and stores the value in a .json file.""" fav_num = input("What is your favorite number? ") filename = 'fav_num.json' with open(filename, 'w') as f: json.dump(fav_num, f) def print_fav_num(): """Retrieves user's favoite number and prints ...
true
da5a646c0a2caecadb60485bf3d02d8c0661960b
nicholasrokosz/python-crash-course
/Ch. 8/user_albums.py
572
4.25
4
def make_album(artist, album, no_of_songs=None): album_info = {'artist': artist, 'album': album} if no_of_songs: album_info['no_of_songs'] = no_of_songs return album_info while True: artist_name = input("Enter the artist's name: ") album_title = input("Enter the album title: ") no_of_songs = input("Enter the n...
true
af5ab9aad7b047b9e9d061e22ab7afe7e64a4b01
mumarkhan999/UdacityPythonCoursePracticeFiles
/9_exponestial.py
347
4.5
4
#claculating power of a number #this can be done easily by using ** operator #for example 2 ** 3 = 8 print("Assuming that both number and power will be +ve\n") num = int(input("Enter a number:\n")) power = int(input("Enter power:\n")) result = num for i in range(1,power): result = result * num print(result) input("...
true
a6fc7a95a15f7c98ff59850c70a05fdb028a784f
mumarkhan999/UdacityPythonCoursePracticeFiles
/8_multi_mulTable.py
208
4.25
4
#printing multiple multiplication table num = int(input("Enter a number:\n")) for i in range (1, (num+1)): print("Multiplication Table of",i) for j in range(1,11): print(i,"x",j,"=",i*j)
true
162b0739cda0d6fba65049b474bc72fecf547f3d
dodgeviper/coursera_algorithms_ucsandeigo
/course1_algorithmic_toolbox/week4/assignment/problem_4.py
2,492
4.21875
4
# Uses python3 """How close a data is to being sorted An inversion of sequence a0, a1, .. an-1 is a pair of indices 0<= i < j< n such that ai < aj. The number of inversion of a sequence in some sense measures how close the sequence is to being sorted. For example, a sorted (in non-decreasing order) sequence contains n...
true
8c41e6813d5e137bf3acbe883b08d269d9cb7d7b
Smellly/weighted_training
/BinaryTree.py
1,813
4.25
4
# simple binary tree # in this implementation, a node is inserted between an existing node and the root import sys class BinaryTree(): def __init__(self,rootid): self.left = None self.right = None self.rootid = rootid def getLeftChild(self): return self.left def getRightChild(s...
true
a5f8cf2de38a252d3e9c9510368419e5a763cf74
TheFibonacciEffect/interviewer-hell
/squares/odds.py
1,215
4.28125
4
""" Determines whether a given integer is a perfect square, without using sqrt() or multiplication. This works because the square of a natural number, n, is the sum of the first n consecutive odd natural numbers. Various itertools functions are used to generate a lazy iterable of odd numbers and a running sum of them,...
true
959fc6191262d8026e7825e50d80eddb08d6a609
OliValur/Forritunar-fangi-1
/20agust.py
2,173
4.28125
4
import math # m_str = input('Input m: ') # do not change this line # # change m_str to a float # # remember you need c # # e = # m_float = float(m_str) # c = 300000000**2 # e = m_float*c # print("e =", e) # do not change this line) # Einstein's famous equation states that the energy in an object at rest equals i...
true
0837151d119a5496b00d63ae431b891e405d11cb
Shubham1744/Python_Basics_To_Advance
/Divide/Prog1.py
249
4.15625
4
#Program to divide two numbers def Divide(No1,No2): if No2 == 0 : return -1 return No1/No2; No1 = float(input("Enter First Number :")) No2 = float(input("Enter Second Number :")) iAns = Divide(No1,No2) print("Division is :",iAns);
true
c35d93f5359f710db0bb6d3db7f4c8af1724b1e9
umberahmed/hangman-
/index.py
586
4.25
4
# This program will run the game hangman # random module will be used to generate random word from words list import random # list of words to use in game list_of_words = ["chicken", "apple", "juice", "carrot", "hangman", "program", "success", "hackbright"] # display dashes for player to see how many letters are in...
true
a462d5adc2feb9f2658701a8c2035c231595f81e
kristinejosami/first-git-project
/python/numberguessing_challenge.py
911
4.3125
4
''' Create a program that: Chooses a number between 1 to 100 Takes a users guess and tells them if they are correct or not Bonus: Tell the user if their guess was lower or higher than the computer's number ''' print('Number Guessing Challenge') guess=int(input('This is a number guessing Challenge. Please enter your ...
true
b9310befbc4a399a8c239f22a1bc06f7286fedee
pawan9489/PythonTraining
/Chapter-2/4.Sets.py
1,504
4.375
4
# Set is a collection which is unordered and unindexed. No duplicate members. fruits = {'apple', 'banana', 'apple', 'cherry'} print(type(fruits)) print(fruits) print() # Set Constructor # set() - empty set # set(iterable) - New set initialized with iterable items s = set([1,2,3,2,1]) print(s) print() # No Indexing - ...
true
ca7b96d6389b50e8637507cce32274991e792144
SK7here/learning-challenge-season-2
/Kailash_Work/Other_Programs/Sets.py
1,360
4.25
4
#Sets remove duplicates Text = input("Enter a statement(with some redundant words of same case)") #Splitting the statement into individual words and removing redundant words Text = (set(Text.split())) print(Text) #Creating 2 sets print("\nCreating 2 sets") a = set(["Jake", "John", "Eric"]) print("Set 1 ...
true
0164661e3480ce4df1f2140c07034b3bb75a6c3b
SK7here/learning-challenge-season-2
/Kailash_Work/Arithmetic/Calculator.py
1,779
4.125
4
#This function adds two numbers def add(x , y): return x + y #This function subtracts two numbers def sub(x , y): return x - y #This function multiplies two numbers def mul(x , y): return x * y #This function divides two numbers def div(x , y): return x / y #Flag variable used for ca...
true
4e8b2c18ebf0d7793c7be7dc2830842f26535ab1
githubfun/LPTHW
/PythonTheHardWay/ex14-ec.py
1,061
4.25
4
# Modified for Exercise 14 Extra Credit: # - Change the 'prompt' to something else. # - Add another argument and use it. from sys import argv script, user_name, company_name = argv prompt = 'Please answer: ' print "Hi %s from %s! I'm the %s script." % (user_name, company_name, script) print "I'd like to ask you a few...
true
c8176ae9af68ecc082863620472e9fe440300668
githubfun/LPTHW
/PythonTheHardWay/ex03.py
1,688
4.1875
4
# The first line of executable code prints a statment (the stuff contained between the quotes) to the screen. print "I will now count my chickens:" # Next we print the word "Hens" followed by a space, then the result of the formula, which is analyzed 25 + (30 / 6) print "Hens", 25 + 30 / 6 # Line 7 prints right below ...
true
6db17e91e654e5229ccad28166264478673839d9
abrosen/classroom
/itp/spring2020/booleanExpressions.py
427
4.1875
4
print(3 > 7) print(6 == 6) print(6 != 6) weather = "sunny" temperature = 91 haveBoots = False goingToTheBeach = True if weather == "raining": print("Bring an umbrella") print(weather == "raining" and temperature < 60) if weather == "raining" and temperature < 60: print("Bring a raincoat") if (weather == "rain...
true
8f4b21a601c7e3a2da6c26971c7c7bb982d4a242
hashncrash/IS211_Assignment13
/recursion.py
2,230
4.625
5
#!/usr/bin/env python # -*- coding: utf-8 -*- """Week 14 Assignment - Recursion""" def fibonnaci(n): """Returns the nth element in the Fibonnaci sequence. Args: n (int): Number representing the nth element in a sequence. Returns: int: The number that is the given nth element in the fibonna...
true
8d1de591706470db3bbcf26374ff958f393e85f7
tungnc2012/learning-python
/if-else-elif.py
275
4.21875
4
name = input("Please enter your username ") if len(name) <= 5: print("Your name is too short.") elif len(name) == 8: # print("Your name is 8 characters.") pass elif len(name) >= 8: print("Your name is 8 or more characters.") else: print("Your name is short.")
true
7de4e99e276c3e0ba73fc82112b55f7ee8190d5c
ayazzy/Plotter
/searches.py
1,673
4.1875
4
''' This module has two functions. Linear Search --> does a linear search when given a collection and a target. Binary Search --> does a binary search when given a collection and a target. output for both functions are two element tuples. Written by: Ayaz Vural Student Number: 20105817 Date: March 22nd 2019 ''' def lin...
true
a4b22a4a32ffa1afb1508d232388d6bc759e0485
avi651/PythonBasics
/ProgrammeWorkFlow/Tabs.py
233
4.125
4
name = input("Please enter your name: ") age = int(input("Hi old are you, {0}? ".format(name))) #Adding type cast print(age) if age > 18: print("You are old enough to vote") else: print("Please come back in {0}".format(18 - age))
true
9b2f359901f6a835563e878a9f103dec0b110a86
nguiaSoren/Snake-game
/scoreboard.py
1,123
4.3125
4
from turtle import Turtle FONT = ("Arial", 24, "normal") # class Scoreboard(Turtle): def __init__(self): super().__init__() # Set initials score to 0 self.score = 0 # Set colot to white self.color("white") # Hide the turtle, we wonly want to see the text self...
true
ddfe13cbff04a326ed196b20beb8f1414364b086
luzperdomo92/test_python
/hello.py
209
4.25
4
name = input("enter your name: ") if len(name) < 3: print("name must be al least 3 characters") elif len(name) > 20: print("name can be a maximun 50 characteres") else: print("name looks good!")
true
450b68eb2689957ce61da69333d6a0588820339d
GTVanitha/PracticePython
/bday_dict.py
1,003
4.34375
4
birthdays = { 'Vanitha' : '05/05/90', 'Som' : '02/04/84', 'Vino' : '08/08/91' } def b_days(): print "Welcome to birthday dictionary! We know the birthdays of:" names = birthdays.keys() print ',\n'.join(names) whose = raw_input("Who's birthday do you wa...
true
4c71d1fa592e3c54844946aa62e8eb4f7c69f95f
Aravindan-C/LearningPython
/LearnSet.py
535
4.3125
4
__author__ = 'aravindan' """A set is used to contain an unordered collection of objects,To create a set use the set() function and supply a sequence of items such as follows""" s= set([3,5,9,10,10,11]) # create a set of unique numbers t=set("Hello") # create a set of unique characters u=set("abcde") """set...
true
c21762ec2545a3836c039837ec782c8828044fca
jkusita/Python3-Practice-Projects
/count_vowels.py
1,833
4.25
4
# Count Vowels – Enter a string and the program counts the number of vowels in the text. For added complexity have it report a sum of each vowel found. vowel_list = ["a", "e", "i", "o", "u"] vowel_count = 0 # Change this so it adds all the values of the keys in the new dictionary. vowel_count_found = {"a": 0, "e": 0, ...
true
2487fdd78e971f078f6844a2fa5bb0cd031b0d71
Dunkaburk/gruprog_1
/grundlaggande_programvareutveckling/week2/src/samples/MathMethods.py
751
4.25
4
# package samples # math is the python API for numerical calculations from math import * def math_program(): f_val = 2.1 print(f"Square root {sqrt(f_val)}") print(f"Square {pow(f_val, 2)}") print(f"Floor {floor(f_val)}") print(f"Ceil {ceil(f_val)}") print(f"Round {round(f_val)}") # etc. ...
true
1b54c0d17ea896a12aa2a20779416e0bac85d066
Dunkaburk/gruprog_1
/grundlaggande_programvareutveckling/week3_tantan/src/exercises/Ex4MedianKthSmallest.py
901
4.15625
4
# package exercises # # Even more list methods, possibly even trickier # def median_kth_smallest_program(): list1 = [9, 3, 0, 1, 3, -2] # print(not is_sorted(list1)) # Is sorted in increasing order? No not yet! # sort(list1) # Sort in increasing order, original order lost! print(list1 == [-2, 0...
true
16acd854ef3b668e05578fd5efff2b5c2a6f88f4
Dunkaburk/gruprog_1
/grundlaggande_programvareutveckling/Week1Exercises/Week1Exercises/week1/src/exercises/Ex2EasterSunday.py
1,705
4.3125
4
# package exercises # Program to calculate easter Sunday for some year (1900-2099) # https://en.wikipedia.org/wiki/Computus (we use a variation of # Gauss algorithm, scroll down article, don't need to understand in detail) # # To check your result: http://www.wheniseastersunday.com/ # # See: # - LogicalAnd...
true
fd550e115ac526fe5ac6bc9543278a7d852325b6
anthonysim/Python
/Intro_to_Programming_Python/pres.py
444
4.5
4
""" US Presidents Takes the names, sorts the order by first name, then by last name. From there, the last name is placed in front of the first name, then printed """ def main(): names = [("Lyndon, Johnson"), ("John, Kennedy"), ("Andrew, Johnson")] names.sort(key=lambda name: name.split()[0]) names.sor...
true
c1dceb57ede0b3eb1f1fe5fe658fe283116d68f3
pythonic-shk/Euler-Problems
/euler1.py
229
4.34375
4
n = input("Enter n: ") multiples = [] for i in range(int(n)): if i%3 == 0 or i%5 == 0: multiples.append(i) print("Multiples of 3 or 5 or both are ",multiples) print("Sum of Multiples of ",n," Numbers is ",sum(multiples))
true
7468f255b87e3b4aa495e372b44aba87ff2928d1
tengrommel/go_live
/machine_learning_go/01_gathering_and_organizating_data/gopher_style/python_ex/myprogram.py
449
4.3125
4
import pandas as pd ''' It is true that, very quickly, we can write some Python code to parse this CSV and output the maximum value from the integer column without even knowing what types are in the data: ''' # Define column names cols = [ 'integercolumn', 'stringcolumn' ] # Read in the CSV with pandas. data...
true
e863fd0cfe96478d6550b426d675de6cfc84c08a
kami71539/Python-programs-4
/Program 19 Printing even and odd number in the given range.py
515
4.28125
4
#To print even numbers from low to high number. low=int(input("Enter the lower limit: ")) high=int(input("ENter the higher limit: ")) for i in range(low,high): if(i%2==0): print(i,end=" ") print("") for i in range(low,high): if(i%2!=0): print(i,end=" ") #Printing odd numbers ...
true
61bef90211ffd18868427d3059e8ab8dee3fefde
kami71539/Python-programs-4
/Program 25 Printing text after specific lines.py
303
4.15625
4
#Printing text after specific lines. text=str(input("Enter Text: ")) text_number=int(input("Enter number of text you'd like to print; ")) line_number=1 for i in range(0,text_number): print(text) for j in range(0,line_number): print("1") line_number=line_number+1 print(text)
true
38658702ed937a7ba65fd1d478a371e4c6d5e789
kami71539/Python-programs-4
/Program 42 Finding LCM and HCF using recursion.py
259
4.25
4
#To find the HCF and LCM of a number using recursion. def HCF(x,y): if x%y==0: return y else: return HCF(y,x%y) x=int(input("")) y=int(input("")) hcf=HCF(x,y) lcm=(x*y)/hcf print("The HCF is",hcf,". The LCM is",lcm)
true
6f2ac1ae18a208e032f7f1db77f64710f3b9bd00
kami71539/Python-programs-4
/Program 15 Exponents.py
221
4.375
4
print(2**3) def exponents(base,power): i=1 for index in range(power): i=i*base return i a=int(input("")) b=int(input("")) print(a, "raised to the power of" ,b,"would give us", exponents(a,b))
true
e80d7d475ddcf65eddd08d77aa4c2c03f965dfb9
kami71539/Python-programs-4
/Program 35 To count the uppercase and lowercase characters in the given string. unresolved.py
458
4.125
4
#To count the uppercase and lowercase characters in the given string. string=input("") j='a' lower=0 upper=0 space=0 for i in string: for j in range(65,92): if chr(j) in i: upper=upper+1 elif j==" ": space=space+1 for j in range(97,123): if chr(j) in ...
true
84650242ab531d3a0755452b8c6eb4476e0a710c
dncnwtts/project-euler
/1.py
582
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. def multiples(n,k): multiples = [] i = 1 while i < n: if k*i < n: multiples.append(k*i) i += 1 else: return m...
true
e047b285aa5bf1b187187c52a22fae191836ed0f
chubaezeks/Learn-Python-the-Hard-Way
/ex19.py
1,804
4.3125
4
#Here we defined the function by two (not sure what to call them) def cheese_and_crackers (cheese_count, boxes_of_crackers): print "You have %d cheese!" % cheese_count print "You have %d boxes of crackers!" % boxes_of_crackers print "Man that's enough for a party!" print "Get a blanket.\n" #We take tha...
true
965cd05ce217b1b5d27cefb89b62935dc250a692
hmkthor/play
/play_006.py
590
4.40625
4
""" Change a Range of Item Values To change the value of items within a specific range, define a list with the new values, and refer to the range of index numbers where you want to insert the new values: """ thislist = ["apple", "banana", "cherry", "orange", "kiwi", "mango"] thislist[1:3] = ["blackcurrant", "watermel...
true
359ce1c69a952d51fd9024adade90be51e6ebb00
LiuPengPython/algorithms
/algorithms/strings/is_rotated.py
324
4.3125
4
""" Given two strings s1 and s2, determine if s2 is a rotated version of s1. For example, is_rotated("hello", "llohe") returns True is_rotated("hello", "helol") returns False accepts two strings returns bool """ def is_rotated(s1, s2): if len(s1) == len(s2): return s2 in s1 + s1 else: return F...
true
b1a9fee52ca6eae1ee380a0d95491d735c7360bd
jeantardelli/wargameRepo
/wargame/designpatterns/strategies_traditional.py
1,633
4.15625
4
"""strategies_traditional Example to show one way of implementing different design pattern strategies in Python. The example shown here resembles a 'traditional' implementation in Python (traditional = the one you may implement in languages like C++). For a more Pythonic approach, see the file strategies_pythonic.py...
true
93b2af4c8f1a23483747d04ea3902c644b581543
jeantardelli/wargameRepo
/wargame/performance-study/pool_example.py
1,201
4.375
4
"""pool_example Shows a trivial example on how to use various methods of the class Pool. """ import multiprocessing def get_result(num): """Trivial function used in multiprocessing example""" process_name = multiprocessing.current_process().name print("Current process: {0} - Input number: {1}".format(proc...
true
d37a677d52bcb30328947235f0198a9447ddeb34
jeantardelli/wargameRepo
/wargame/GUI/simple_application_2.py
1,025
4.125
4
"""simple_application_2 A 'Hello World' GUI application OOP using Tkinter module. """ import sys if sys.version_info < (3, 0): from Tkinter import Tk, Label, Button, LEFT, RIGHT else: from tkinter import Tk, Label, Button, LEFT, RIGHT class MyGame: def __init__(self, mainwin): """Simple Tkinter G...
true
c72fb1953ee65169041fa399508fbd5204986270
yeti98/LearnPy
/src/basic/TypeOfVar.py
978
4.125
4
#IMMUTABLE: int, ## Immutable vs immutable var #Case3: # default parameter for append_list() is empty list lst []. but it is a mutable variable. Let's see what happen with the following codes: def append_list(item, lst=[]): lst.append(item) return lst print(append_list("item 1")) # ['item 1'] print(append...
true
0243e8d54259a3cecd9e84443bae674a66f090f7
amandamurray2021/Programming-Semester-One
/labs/week06-functions/menu2.py
801
4.34375
4
# Q3 # This program uses the function from student.py. # It keeps displaying the menu until the user picks Q. # If the user chooses a, then call a function called doAdd (). # If the user chooses v, then call a function called doView (). def displayMenu (): print ("What would you like to do?") print ("\t (a) Ad...
true
2df05235e11b4f969f147ffa6dcde19ceb0c0dec
VB-Cloudboy/PythonCodes
/10-Tuples/02_Access-Tuple.py
403
4.125
4
mytuple = (100,200,300,400,500,600,700,800,900) #1. Print specific postion of the tuples starting from Right print(mytuple[2]) print(mytuple[4]) print(mytuple[5]) #2. Print specific postion of the tuples starting from Left print(mytuple[-3]) print(mytuple[-5]) print(mytuple[-4]) #3. Slicing (Start: Stop: Stepsize) ...
true
8c326cefac9c979874f8a03334934c685a88c953
forthing/leetcode-share
/python/152 Maximum Product Subarray.py
813
4.21875
4
''' Find the contiguous subarray within an array (containing at least one number) which has the largest product. For example, given the array [2,3,-2,4], the contiguous subarray [2,3] has the largest product = 6. ''' class Solution(object): def maxProduct(self, nums): """ :type nums: Lis...
true
88ddaec1c09a46fac173c4b520c6253b59aad09b
kmair/Graduate-Research
/PYOMO_exercises_w_soln/exercises/Python/fcn_soln.py
1,248
4.40625
4
## Write a function that takes in a list of numbers and *prints* the value of the largest number. Be sure to test your function. def print_max_value(nums): print("The max value is: ") print(max(nums)) ## Write a function that takes a list of numbers and *returns* the largest number def max_value(nums): return ...
true
82d3e7c695fbab62b222781240a1865cfe877151
Kaushalendra-the-real-1/Python-assignment
/Q2.py
779
4.125
4
# class Person: # def __init__(self): # print("Hello Reader ... ") # class Male(Person): # def get_gender(self): # print("I am from Male Class") # class Female(Person): # def get_gender(self): # print("I am from Female Class") # Obj = Female() # Obj.get_gender() # -----------------...
true
e33a070506458cacbf4d52304982c491f2c9980d
xynicole/Python-Course-Work
/lab/435/ZeroDivideValue.py
595
4.25
4
def main(): print("This program will divide two numbers of your choosing for as long as you like\n") divisorStr = input("Input a divisor: ") while divisorStr: dividendStr = input("Input a dividend: ") try: divisor = int(divisorStr) dividend = int(dividendStr) print (dividend ...
true
240868c7fb1cf39a3db78c9c5912d7dc93c79e45
SamuelMontanez/Shopping_List
/shopping_list.py
2,127
4.1875
4
import os shopping_list = [] def clear_screen(): os.system("cls" if os.name == "nt" else "clear") def show_help(): clear_screen() print("What should we pick up at the store?") print(""" Enter 'DONE' to stop adding items. Enter 'HELP' for this help. Enter 'SHOW' to see your current list. Ente...
true
ec8887453eaa5f263665f651338a470b4b8c5f7c
lura00/guess_the_number
/main.py
915
4.15625
4
from random import randint from game1 import number_game def show_menu(): print("\n===========================================") print("| Welcome |") print("| Do you want to play a game? |") print("| 1. Enter the number game |") print("| ...
true
18a73e6c8cd9289ce5ba0fd1006dc2ce400e375f
LehlohonoloMopeli/level_0_coding_challenge
/task_3.py
350
4.1875
4
def hello(name): """ Description: Accepts the name of an individual and prints "Hello ..." where the ellipsis represents the name of the individual. type(output) : str """ if type(name) == str: result = print("Hello " + name + "!") return result else: ...
true
9d07cb1bbb8e780c193dbb19c6c0ef4b83cb7914
unfo/exercism-python
/bob/bob.py
723
4.25
4
def hey(sentence): """ Bob is a lackadaisical teenager. In conversation, his responses are very limited. Bob answers 'Sure.' if you ask him a question. He answers 'Whoa, chill out!' if you yell at him. He says 'Fine. Be that way!' if you address him without actually saying anything. He answers 'Whatever.' to any...
true
be97e8da8f3733fbb6c0a2e8abb0b950a11181c4
fitzcn/oojhs-code
/loops/printingThroughLoops.py
313
4.125
4
""" Below the first 12 numbers in the Fibonacci Sequence are declared in an array list (fibSeq). Part 1, Use a loop to print each of the 12 numbers. Part 2, use a loop to print each of the 12 numbers on the same line. """ fibSeq = ["1","1","2","3","5","8","13","21","34","55","89","144"] #part 1 #part 2
true
d190cf17e29502fd451ff812f68414fef94eeec9
aysin/Python-Projects
/ex32.py
538
4.65625
5
#creating list while doing loops the_count = [1, 2, 3, 4, 5] fruits = ['apple', 'oranges', 'pears', 'apricots'] change = [1, 'pennies', 2, 'dimes', 3, 'quarters'] #this first kind of for loop goes through a list for n in the_count: print "This is count %d." % n #same as above for n in fruits: print "A fruit type ...
true
cde03d01900ffa7f01f5f80e4bfc869454ac8116
AshTiwari/Python-Guide
/OOPS/OOPS_Abstract_Class_and_Method.py
720
4.5625
5
#abstract classes # ABC- Abstract Base Class and abstractmethod from abc import ABC, abstractmethod print('abstract method is the method user must implement in the child class.') print('abstract method cannot be instantiated outside child class.') print('\n\n') class parent(ABC): def __init__(self): pass...
true
94555b4909e244e1e8e9e23bb97ad48b81308118
jinliangXX/LeetCode
/380. Insert Delete GetRandom O(1)/solution.py
1,462
4.1875
4
import random class RandomizedSet(object): def __init__(self): """ Initialize your data structure here. """ self.result = list() self.index = dict() def insert(self, val): """ Inserts a value to the set. Returns true if the set did not already contain ...
true
076a40fc02b0791eedaae92747394f46170a9678
prathyusak/pythonBasics
/errors.py
2,720
4.21875
4
#Syntax Errors and Exceptions #while True print('Hello world') => syntax error #ZeroDivisionError =>10 * (1/0) #NameError => 4 + spam*3 #TypeError => '2' + 2 ################# # Handling Exceptions import sys def this_fails(): x = 1/0 while True: try: x = int(input("Please enter a number: ")) t...
true
57e443004e07c95bc99217d700e6b4f40f5c8a5f
yamaz420/PythonIntro-LOLcodeAndShit
/pythonLOL/vtp.py
2,378
4.125
4
from utils import Utils class VocabularyTrainingProgram: words = [ Word("hus", "house") Word("bil", "car") ] def show_menu(self): choice = None while choice !=5: print( ''' 1. Add a new word 2. Shuffle the words i...
true
4f55c17a043ee6a78b76220c8c25240a21b8195c
yamaz420/PythonIntro-LOLcodeAndShit
/pythonLOL/IfAndLoops.py
1,881
4.15625
4
#-----------!!!INDENTATION!!!----------- # age = int(input("What is your age?")) # if age >= 20: # print("You are grown up, you can go to Systemet!") # else: # print("you are to young for systemet...") # if age >= 20: # if age >= 30: # print("Allright, you can go to systemet for me, i hate sho...
true
421a3a05798ec7bfdfd104994e220ffb9f2613f7
Tornike-Skhulukhia/IBSU_Masters_Files
/code_files/__PYTHON__/lecture_2/two.py
1,401
4.1875
4
def are_on_same_side(check_p_1, check_p_2, point_1, point_2): ''' returns True, if check points are on the same side of a line formed by connecting point_1 and point_2 arguments: 1. check_p_1 - tuple with x and y coordinates of check point 1 2. check_p_2 - tuple with x and y coor...
true
0fdc190bda0f1af4caf7354f380ce94134c70c78
cizamihigo/guess_game_Python
/GuessTheGame.py
2,703
4.21875
4
print("Welcome To Guess: The Game") print("You can guess which word is that one: ") def check_guess(guess, answer): global score Still = True attempt = 0 var = 2 global NuQuest while Still and attempt < 3 : if guess.lower() == answer.lower() : print("\nCorrect Answer " + ans...
true
0ebfa784abeddd768186f99209602dd7ef870e56
feleHaile/my-isc-work
/python_work_RW/6-input-output.py
1,745
4.3125
4
print print "Input/Output Exercise" print # part 1 - opening weather.csv file with open ('weather.csv', 'r') as rain: # opens the file as 'read-only' data = rain.read() # calls out the file under variable rain and reads it print data # prints the data # part 2 - reading the file line by line with open ('weather....
true
a40fd3e7668b013a356cfa8559e993e770cc7231
feleHaile/my-isc-work
/python_work_RW/13-numpy-calculations.py
2,314
4.3125
4
print print "Calculations and Operations on Numpy Arrays Exercise" print import numpy as np # importing the numpy library, with shortcut of np # part 1 - array calculations a = np.array([range(4), range(10,14)]) # creating an array 2x4 with ranges b = np.array([2, -1, 1, 0]) # creating an array from a list # multip...
true
12f3789e81a69e4daa75f9497dd94f382f5f0153
zamunda68/python
/main.py
507
4.21875
4
# Python variable function example # Basic example of the print() function with new line between the words print("Hello \n Marin") print("Bye!") # Example of .islower method which returns true if letters in the variable value are lower txt = "hello world" # the variable and its value txt.islower() # using the .islow...
true
1ef4a7869a5048f6d66fbdb56203fa2f0198fb22
zamunda68/python
/dictionaries.py
1,116
4.75
5
""" Dictionary is a special structure, which allows us to store information in what is called key value pairs (KVP). You can create one KVP and when you want to access specific information inside of the dictionary, you can just refer to it by its key """ # Similar to actual dictionary, the word is the key and the mea...
true
a95b3e4a2102e76c1a6b4932d6053a66b9593d5d
b-zhang93/CS50-Intro-to-Computer-Science-Harvard-Problem-Sets
/pset6 - Intro to Python/caesar/caesar.py
1,022
4.21875
4
from cs50 import get_string from cs50 import get_int from sys import argv # check for CLA to be in order and return error message if so if len(argv) != 2: print("Usage: ./caesar key k") exit(1) # checks for integer and positive elif not argv[1].isdigit(): print("Usage: ./caesar key k") exit(1) # defi...
true
c891f23d90e49fa066d06e90fd5ad2d45c9afd7d
gmarler/courseware-tnl
/labs/py3/decorators/memoize.py
1,122
4.1875
4
''' Your job in this lab is to implement a decorator called "memoize". This decorator is already applied to the functions f, g, and h below. You just need to write it. HINT: The wrapper function only needs to accept non-keyword arguments (i.e., *args). You don't need to accept keyword arguments in this lab. (That is m...
true
3f7a247198d94307902d20edec5016511a4343e6
kpetrone1/kpetrone1
/s7hw_mysqrt_final.py
1,348
4.4375
4
#23 Sept 2016 (Homework following Session 7) #While a few adjustments have been made, the majority of the following code has been sourced from a blog titled "Random Thoughts" by Estevan Pequeno at https://epequeno.wordpress.com/2011/01/04/solutions-7-3/. #function to test Newton's method vs. math.sqrt() to find squar...
true
92297bb3778093c35679b32b2a1ffd22a3339403
harsh52/Assignments-competitive_coding
/Algo_practice/LeetCode/Decode_Ways.py
1,874
4.1875
4
''' A message containing letters from A-Z can be encoded into numbers using the following mapping: 'A' -> "1" 'B' -> "2" ... 'Z' -> "26" To decode an encoded message, all the digits must be grouped then mapped back into letters using the reverse of the mapping above (there may be multiple ways). For example, "11106" c...
true
28f0e5637cd7ca7d5b47451e27e6e1d0ac7db093
zlatnizmaj/GUI-app
/OOP/OOP-03-Variables.py
642
4.40625
4
# In python programming, we have three types of variables, # They are: 1. Class variable 2. Instance variable 3. Global variable # Class variable class Test(): class_var = "Class Variable" class_var2 = "Class Variable2" # print(class_var) --> error, not defined x = Test() print(x.class_var) print(x.class_var2...
true
1e45cfd30735bc93f3341bb6bfdec05603fa77fc
pravsp/problem_solving
/Python/BinaryTree/solution/invert.py
1,025
4.125
4
'''Invert a binary tree.''' import __init__ from binarytree import BinaryTree from treenode import TreeNode from util.btutil import BinaryTreeUtil # class TreeNode: # def __init__(self, val=0, left=None, right=None): # self.val = val # self.left = left # self.right = right class Invert: ...
true
b6ff3bb38beaea248d13389d5246d449e8e8bf8a
Arushi96/Python
/Radical- Python Assignment Solutions/Loops and Conditions/Question 3.py
367
4.15625
4
#Assignment Questions #Q: Write a program which calculates the summation of first N numbers except those which are divisible by 3 or 7. n = int(input ("Enter the number till which you want to find summation: ")) s=0 i=0 while i<=n: if (i%3==0)or(i%7==0): #print(i) i+=1 continue else: ...
true
35025370621c265eff6d02c68d4284525634f5e1
mtjhartley/codingdojo
/dojoassignments/python/fundamentals/find_characters.py
568
4.21875
4
""" Write a program that takes a list of strings and a string containing a single character, and prints a new list of all the strings containing that character. Here's an example: # input word_list = ['hello','world','my','name','is','Anna'] char = 'o' # output new_list = ['hello','world'] """ def find_characters(lst...
true
ac0c500a62196c5bf29fe013f86a82946fdb65b2
mtjhartley/codingdojo
/dojoassignments/python/fundamentals/list_example.py
854
4.28125
4
fruits = ['apple', 'banana', 'orange'] vegetables = ['corn', 'bok choy', 'lettuce'] fruits_and_vegetables = fruits + vegetables print fruits_and_vegetables salad = 3 * vegetables print salad print vegetables[0] #corn print vegetables[1] #bok choy print vegetables[2] #lettuce vegetables.append('spinach') print veget...
true
3389a2cb84c667ada3e41ec096592cfdbf6c2e07
mtjhartley/codingdojo
/dojoassignments/python/fundamentals/compare_array.py
2,432
4.3125
4
""" Write a program that compares two lists and prints a message depending on if the inputs are identical or not. Your program should be able to accept and compare two lists: list_one and list_two. If both lists are identical print "The lists are the same". If they are not identical print "The lists are not the same...
true
19aa6ef97da6fdbb4a2a11fd2e66060d8a04f72e
nmarriotti/PythonTutorials
/readfile.py
659
4.125
4
################################################################################ # TITLE: Reading files in Python # DESCRIPTION: Open a text file and read the contents of it. ################################################################################ def main(): # Call the openFile method and pass it F...
true
85d84d9c937233fb243c2a67a482c84d778bb60b
nicolas-huber/reddit-dailyprogrammer
/unusualBases.py
1,734
4.3125
4
# Decimal to "Base Fib" - "Base Fib" to Decimal Converter # challenge url: "https://www.reddit.com/r/dailyprogrammer/comments/5196fi/20160905_challenge_282_easy_unusual_bases/" # Base Fib: use (1) or don't use (0) a Fibonacci Number to create any positive integer # example: # 13 8 5 3 2 1 1 # 1 0 0 ...
true
b0b353eb1b6e426d235a046850ba74aea627d7a2
LJ-Godfrey/Learn-to-code
/Encryption-101/encryption_project/encrypt.py
1,178
4.25
4
# This file contains various encryption methods, for use in an encryption / decryption program def caesar(string): res = str() for letter in string: if letter.lower() >= 'a' and letter.lower() <= 'm': res += chr(ord(letter) + 13) elif letter.lower() >= 'n' and letter.lower() <= 'z':...
true
fd1f0836c9c89a66ff6a555f48577538e398f026
Moby5/myleetcode
/python/671_Second_Minimum_Node_In_a_Binary_Tree.py
2,525
4.125
4
#!/usr/bin/env python # coding=utf-8 """ @File: 671_Second_Minimum_Node_In_a_Binary_Tree.py @Desc: @Author: Abby Mo @Date Created: 2018-3-10 """ """ Given a non-empty special binary tree consisting of nodes with the non-negative value, where each node in this tree has exactly two or zero sub-node...
true
b76d2e373ea53f6ef7498888b0a80365bc48ec38
Moby5/myleetcode
/python/532_K-diff_Pairs_in_an_Array.py
2,592
4.125
4
#!/usr/bin/env python # coding=utf-8 """ LeetCode 532. K-diff Pairs in an Array Given an array of integers and an integer k, you need to find the number of unique k-diff pairs in the array. Here a k-diff pair is defined as an integer pair (i, j), where i and j are both numbers in the array and their absolute differen...
true
bd4619b0c4c69fddaa93c8e896a89873c74e245a
Moby5/myleetcode
/python/414_Third_Maximum_Number.py
2,199
4.15625
4
#!/usr/bin/env python # coding=utf-8 """ http://bookshadow.com/weblog/2016/10/09/leetcode-third-maximum-number/ 414. Third Maximum Number Given a non-empty array of integers, return the third maximum number in this array. If it does not exist, return the maximum number. The time complexity must be in O(n). Example ...
true
a3f0ed60542ab8174c23174d1a48c8e2273b9e50
Moby5/myleetcode
/python/640_Solve_the_Equation.py
2,492
4.3125
4
#!/usr/bin/env python # coding=utf-8 # 566_reshape_the_matrix.py """ http://bookshadow.com/weblog/2017/07/09/leetcode-solve-the-equation/ LeetCode 640. Solve the Equation Solve a given equation and return the value of x in the form of string "x=#value". The equation contains only '+', '-' operation, the variable x a...
true
549ae44ba1517ca134e2677a63cc3fe5cfb5f205
joaoribas35/distance_calculator
/app/services/calculate_distance.py
943
4.34375
4
import haversine as hs def calculate_distance(coordinates): """ Will calculate the distance from Saint Basil's Cathedral and the address provided by client usind Haversine python lib. Saint Basil's Cathedral is used as an approximation to define whether the provided address is located inside the MKAD Moscow Ring ...
true
536bf2470f47c6353bc674b6c1efd668f8c03473
nonbinaryprogrammer/python-poet
/sentence_generator.py
787
4.15625
4
import random from datetime import datetime from dictionary import Words #initializes the dictionary so that we can use the words words = Words(); #makes the random number generator more random random.seed(datetime.now) #gets 3 random numbers between 0 and the length of each list of words random1 = random.randint(0, ...
true
5ac31df1a7457d4431e7c8fbdc1892bf02d393d0
qtdwzAdam/leet_code
/py/back/work_405.py
1,282
4.53125
5
# -*- coding: utf-8 -*- ######################################################################### # Author : Adam # Email : zju_duwangze@163.com # File Name : work_405.py # Created on : 2019-08-30 15:26:20 # Last Modified : 2019-08-30 15:29:47 # Description : # Given an integer, write an algori...
true
4b3ce42dde5e951efe9620bfce24c01f380715e7
gauravtatke/codetinkering
/leetcode/LC110_balanced_bintree.py
2,087
4.3125
4
# Given a binary tree, determine if it is height-balanced. # For this problem, a height-balanced binary tree is defined as: # a binary tree in which the depth of the two subtrees of every node never differ by more than 1. # Example 1: # Given the following tree [3,9,20,null,null,15,7]: # 3 # / \ # 9 20 ...
true
32a89094e2c55e2a5b13cf4a52a1cf6ef7206894
gauravtatke/codetinkering
/leetcode/LC98_validate_BST.py
798
4.21875
4
# Given a binary tree, determine if it is a valid binary search tree (BST). # # Assume a BST is defined as follows: # # The left subtree of a node contains only nodes with keys less than the node's key. # The right subtree of a node contains only nodes with keys greater than the node's key. # Both the left ...
true
996e3858f7eb3c4a8de569db426c2f9cdd5fd71a
gauravtatke/codetinkering
/dsnalgo/firstnonrepeatcharinstring.py
1,292
4.15625
4
#!/usr/bin/env python3 # Given a string, find the first non-repeating character in it. For # example, if the input string is “GeeksforGeeks”, then output should be # ‘f’ and if input string is “GeeksQuiz”, then output should be ‘G’. def findNonRepeatChar(stri): chlist = [0 for ch in range(256)] for ch in str...
true
c106671082f8f393f73ebad1a355929e142cfdc6
gauravtatke/codetinkering
/leetcode/LC345_reverse_vowelsof_string.py
739
4.28125
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): lstr = list(s) i = 0 j = len(...
true
0d37f87ebde2412443f7fefbf53705ac0f03b019
gauravtatke/codetinkering
/dsnalgo/lengthoflongestpalindrome.py
2,308
4.1875
4
#!/usr/bin/env python3 # Given a linked list, the task is to complete the function maxPalindrome which # returns an integer denoting the length of the longest palindrome list that # exist in the given linked list. # # Examples: # # Input : List = 2->3->7->3->2->12->24 # Output : 5 # The longest palindrome list is 2-...
true
8d9bb6926f1bd85ef8da53778229913d6ac4bc86
gauravtatke/codetinkering
/dsnalgo/sort_pile_of_cards.py
1,047
4.125
4
#!/usr/bin/env python3 # We have N cards with each card numbered from 1 to N. All cards are randomly shuffled. We are allowed only operation moveCard(n) which moves the card with value n to the top of the pile. You are required to find out the minimum number of moveCard() operations required to sort the cards in incre...
true
a783b4053b012143e18b6a8bd4335a8b84b5d031
gauravtatke/codetinkering
/leetcode/LC433_min_gene_mut.py
2,495
4.15625
4
# A gene string can be represented by an 8-character long string, with choices from "A", "C", "G", "T". # Suppose we need to investigate about a mutation (mutation from "start" to "end"), where ONE mutation is defined as ONE single character changed in the gene string. # For example, "AACCGGTT" -> "AACCGGTA" is 1 mutat...
true
ffe24156489d5063ee564b1b5c558585363a7944
directornicm/python
/Project_4.py
572
4.28125
4
# To calculate leap year: # A leap year is a year which is divisible by 4 but ... # if it is divisible by 100, it must be divisible by 400. # indentation matters - take care of it year = int(input("Give the year to be checked for leap year")) if year % 4 == 0: if year % 100 == 0: if year % 400 ==...
true
67eb2e0043b1c1d63395df0de8f4e39a98930a7e
luthraG/ds-algo-war
/general-practice/17_09_2019/p16.py
996
4.1875
4
''' Given a non-empty string check if it can be constructed by taking a substring of it and appending multiple copies of the substring together. You may assume the given string consists of lowercase English letters only and its length will not exceed 10000. Example 1: Input: "abab" Output: ...
true
bd48564a03e15ec4c6f2d287ec3b651947418118
luthraG/ds-algo-war
/general-practice/20_08_2019/p1.py
861
4.125
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 10 Million. from timeit import default_timer as timer if __name__ == '__main__': start = timer() number = 1000 # Since...
true