blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
91b435e4c6afda99270bec91eae519bcb8a09cf8
amolsmarathe/python_programs_and_solutions
/2-Basic_NextConceptsAndNumpy/4-LocalGlobalVariables.py
1,522
4.40625
4
# Local- defined inside the function # Global- defined outside the function # Global can always be accessed inside function, given that same variable is not defined inside function, however, # local variable cannot be accessed outside the function # Local and global variables are different # 'global'-Global variable ...
true
30a9464d99def27837a31aa58c3dc01a4e494ce6
amolsmarathe/python_programs_and_solutions
/3-ObjectOriented/5-Polymorphism-3&4-MethodOverload&Override.py
1,439
4.71875
5
# Method Overload (within same class): 2 methods exist with same name but different number of args # - NOT supported as it is in python,we CANNOT have 2methods with same name in python. But there is a similar concept # - In python,we define method with arg=None &while creating an object,it will get default value No...
true
d90b0446da8f2201d5bc0ac0bed1b15dca86eefd
qikuta/python_programs
/text_to_ascii.py
760
4.5
4
# Quentin Ikuta # August 7, 2022 # This program takes input from user, anything from a-z, A-Z, or 0-9 -- # converts the input into ASCII code, then finally prints the original input and ASCII code. # ask user for input user_string = input("please enter anything a-z, A-Z, and/or 0-9:") # iterate through each character...
true
2b3cb34f4d91c43bd4713619e0adbd53dbd6f17e
ICANDIGITAL/crash_course_python
/chapter_7/restaurant_seating.py
230
4.1875
4
seating = input("How many people are in your dinner group? ") seating = int(seating) if seating >= 8: print("You'll have to wait for a table of " + str(seating) + ".") else: print("There is currently a table available.")
true
d415802c81d337356a85c4c0f94ca993fbcb1d7d
ICANDIGITAL/crash_course_python
/chapter_8/unchanged_magicians.py
421
4.125
4
def show_magicians(magicians): """Displays the name of each magicians in a list.""" for magician in magicians: print(magician.title()) magical = ['aalto simo', 'al baker', 'alessandro cagliostro', 'paul daniels'] def make_great(tricks): """Modifies the original function by adding a message.""" ...
true
be760a2488631c90a135637a524a857ee1bfc7d3
Divyansh-coder/python_challenge_1
/area_of_circle.py
244
4.5625
5
#import math to use pi value import math #take radius as (real number)input from user radius = float(input("Enter the radius of the circle: ")) #print area of circle print("The area of the circle with radius",radius,"is :",math.pi*radius**2)
true
7a287ab16b4fa019dc5190951f5f6268ae9d6d0b
Mannuel25/Mini-Store-Project
/items_in_file.py
657
4.34375
4
def no_of_items_in_file(): """ Displays the total number of items in the file :return: None """ filename = 'myStore.txt' # open original file to read its contents open_file = open(filename,'r') description = open_file.readline() # make a variable to count the number of items ...
true
2e93d1859265eb0f7f53a7a34c2458c8201acc20
xiaofeixiawang/cs101
/lesson5/problem-set2.py
1,744
4.1875
4
1. # Write a procedure, shift, which takes as its input a lowercase letter, # a-z and returns the next letter in the alphabet after it, with 'a' # following 'z'. def shift(letter): if letter=='z': return 'a' return chr(ord(letter)+1) print shift('a') #>>> b print shift('n') #>>> o print shift('z') #...
true
e424eb0df975b287825768065921bdac8473c72d
RaisuFire/ExProject
/leetCode/Medium/Rotate Image.py
758
4.125
4
from copy import deepcopy class Solution(object): def rotate(self, matrix): """ :type matrix: List[List[int]] :rtype: void Do not return anything, modify matrix in-place instead. """ c = deepcopy(matrix) for i in range(len(matrix)): matrix[i] = [c[j][i]...
true
aeca2a9b20564854381cba2a7478f5cfbb266201
sumitdba10/learnpython3thehardway
/ex11.py
1,108
4.25
4
print("How old are you?", end=' ') age = input() print("How tall are you in inches?",end=' ') height = input() print("How much do you weigh in lbs?",end=' ') weight = input() # end=' ' at the end of each print line. This tells print to not end the line with a newline character and go to the next line. print(f"So, you'...
true
f1169d8cfd40df1dcf07287ffaab636bb51f28db
sumitdba10/learnpython3thehardway
/ex20.py
1,856
4.5625
5
# from sys package, we are importing argument variables module from sys import argv import os # asigning two variables to argv module script,input_file = argv # defining a function to read all content of a file def print_all(f): print(f.read()) # defining a function to reset pointer to 0 position def rewind(f): ...
true
6ff3500c81ed429be175c5610a853c2e0f98a728
sumitdba10/learnpython3thehardway
/ex23.py
1,738
4.5625
5
# importing sys package import sys #assigning three variables to argv (argument variable) module # script : this whole program as .py # encoding : variable to define encoding e.g. unicode - utf8/utf16/utf32 or ASCII etcself. #error : to store errors script,encoding, errors = sys.argv # defining a function with 3 argu...
true
c640eccb766d3be16d513516ca9b3bb7499df39e
Sophorth/mypython_exercise
/ex11.py
569
4.4375
4
print " " print " ------Start Exercise 11, Asking Question ------" print " " print "What is your name: ", name = raw_input() print "How tall are you: ", height = raw_input() print "How old are you: ", age = raw_input() print "You name is %s and your are %s inches tall and you are %s" % (name, height, age) # We can do...
true
9fb33802cd8348fc3fa37be0c0bc61e81bfb683c
nojronatron/PythonPlayarea
/PycharmProjects/Chapter4Explorations/Heros_Inventory.py
1,366
4.25
4
__author__ = 'Blue' # Hero's Inventory # Demonstrates tuple creation # Create an empty Tuple inventory = () # Treat the tuple as a condition if not inventory: print("You are empty-handed.") # create a tuple with some items inventory = ("sword", "armor", "shield", "healing p...
true
aca33cc8e9e6394ba986c45caf8d3eb96f8e367c
nojronatron/PythonPlayarea
/PycharmProjects/Chapter 4 Exercizes/Word_Jumble_Game.py
1,319
4.25
4
# -------------------------------------------------# # Title: Chapter 4: Word Jumble Game # Author: Jon Rumsey # Date: 3-May-2015 # Desc: Computer picks a random word from a list and jumbles it # User is asked to guess the word. # 1. Create sequence of words # 2. Pick one word randomly from the seque...
true
56321bc2ea255b211551506b56bc2e255cdcd34d
rahuldevyadav/Portfolio-PYTHON
/gui/program2.py
436
4.375
4
#In this program we will create frame #size of widget #and putting button on it from tkinter import * root= Tk() frame = Frame(root, width=300,height =200) # ONCE WE DEFINE BUTTON WIDTH AND HEIGHT IS DEFAULT button = Button(frame,text='Button1') button.pack() frame.pack() # # frame2 = Frame(root,width=300,height =20...
true
8a80887a2d41386d9f9097abc97c08298076757d
learnPythonGit/pythonGitRepo
/Assignments/20200413_Control_Flow/secondLargeNumSaurav.py
998
4.40625
4
# .................................... # Python Assignment : # Date : 15/04/2020 : # Developer : Saurav Kumar : # Topic : Find Second Largest Num : # Git Branch: D15042020saurav : # ................................... # Compare two number and fi...
true
636a447d89387773056d4e81c6a7519cea3675dd
TCIrose/watchlist
/app/models/movie.py
1,124
4.125
4
class Movie: ''' Movie class to define Movie Objects ''' def __init__(self, id, title, overview, poster, vote_average, vote_count): ''' Args: 1. Title - The name of the movie 2. Overview - A short description on the movie 3. image- The poster image for the movie ...
true
4b11b5f80610aa514338426c0b0262b20c81aa3c
Cretis/Triangle567
/TestTriangle.py
2,667
4.15625
4
# -*- coding: utf-8 -*- """ Updated Jan 21, 2018 The primary goal of this file is to demonstrate a simple unittest implementation @author: jrr @author: rk """ import unittest from Triangle import classifyTriangle # This code implements the unit test functionality # https://docs.python.org/3/library/unittest.html h...
true
7cbea7f0bd0645048484806489ed71c2c6e580b7
wonpyo/Python
/Basic/VariableScope.py
1,207
4.3125
4
# Variables can only reach the area in which they are defined, which is called scope. Think of it as the area of code where variables can be used. # Python supports global variables (usable in the entire program) and local variables. # By default, all variables declared in a function are local variables. To access a g...
true
25209b004ddb4eae65d34e63235622fa9fa44a3d
wonpyo/Python
/Basic/MethodOverloading.py
1,019
4.4375
4
# Several ways to call a method (method overloading) # In Python you can define a method in such a way that there are multiple ways to call it. # Given a single method or function, we can specify the number of parameters ourself. # Depending on the function definition, it can be called with zero, one, two or more para...
true
a2cfdf0723538af644a2eee5372069785bdc048e
wonpyo/Python
/Basic/Threading.py
1,526
4.53125
5
""" A thread is an operating system process with different features than a normal process: 1. Threads exist as a subset of a process 2. Threads share memory and resources 3. Processes have a different address space in memory When would you use threading? Usually when you want a function to occur at the same time as yo...
true
50a126e7540a343ff18cbe16262324bf091cc0a4
cameron-teed/ICS3U-3-08-PY
/leap-year.py
548
4.34375
4
#!/usr/bin/env python3 # Created by: Cameron Teed # Created on: Oct 2019 # This is program finds out if it's a leap year def main(): # calculates if it is a leap year # variables leap_year = " is not" # input year = int(input("What is the year: ")) # process # output if year % 4 ==...
true
50cdfe6dd5d6826a19477bbd440f7b1af507619e
ElleDennis/build-a-blog
/crypto/helpers.py
1,276
4.4375
4
def alphabet_position(letter): """alphabet_position receives single letter string & returns 0-based numerical position in alphabet of that letter.""" alphabetL = "abcdefghijklmnopqrstuvwxyz" alphabetU = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" letter = letter.lower() if letter in alphabetL: retu...
true
e1a296cfe2eb437daad088ff4070a689872bb03e
ishaik0714/MyPythonCode
/Strings_Prog.py
1,232
4.375
4
mult_str = """This is a multi line string, this can have data in multiple lines and can be printed in multiple lines !""" print(mult_str) # The Multi-line string can be in either in three single quotes or three double quotes. st1 = "Hello" st2 = "World!" print (st1+st2) # String Concatenation str1 = "Hello Worl...
true
8698aa545749d13a550704ba005888e0fbb0001f
syedsouban/PyEditor
/PyEditor.py
1,690
4.15625
4
import sys print("Welcome to Python 2 Text Editor") condition = True while condition == True: print("""What do you want to do: 1. Creating a new file 2. Writing to a saved file 3. Viewing a saved file 4. Exit """) choice=eval(input("Enter your choice: ")) if choic...
true
d44ab2f4b12fbeb112faceddf889d477f0c796b2
sunil830/PracticePerfect
/ListOverlap.py
1,315
4.25
4
""" Author: Sunil Krishnan Date: 17-Apr-2016 Name: ListOverlap.py Reference: http://www.practicepython.org/exercise/2014/03/05/05-list-overlap.html Problem Statement: Take two lists, say for example these two: a = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89] b = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13...
true
b2c0f4d56af52930fb94356d565dc2a7822acd3b
KennethTBarrett/cs-module-project-iterative-sorting
/src/iterative_sorting/iterative_sorting.py
2,050
4.40625
4
# TO-DO: Complete the selection_sort() function below def selection_sort(arr): # loop through n elements for i in range(0, len(arr) - 1): cur_index = i smallest_index = cur_index # TO-DO: find next smallest element # For loop, in range of untouched indexes. for index in r...
true
e8ca51cc2ec589c50b304d5e8b25d04fc9670cc8
Cbkhare/Challenges
/Fb_beautiful_strings.py
2,140
4.15625
4
#In case data is passed as a parameter from sys import argv import string from operator import itemgetter file_name = argv[1] fp = open(file_name,'r+') contents = [line.strip('\n') for line in fp] #print (contents) alphas = list(string.ascii_lowercase) #Else use this list(map(chr, range(97, 123))) #print ...
true
fd331cd98a5383c06c45605f4a736462cfd78502
Cbkhare/Challenges
/remove_char_crct.py
1,073
4.21875
4
#In case data is passed as a parameter from sys import argv, getsizeof #from operator import itemgetter #import re #import math #from itertools import permutations #from string import ascii_uppercase file_name = argv[1] fp = open(file_name,'r+') contents = [line.strip('\n').split(', ') for line in fp] for item i...
true
8a4d50a0c008157298bfbd1c818f8192a48b9d5f
Cbkhare/Challenges
/swap_case.py
878
4.15625
4
#In case data is passed as a parameter from sys import argv, getsizeof #from operator import itemgetter #import re #import math #from itertools import permutations #from string import ascii_uppercase file_name = argv[1] fp = open(file_name,'r+') contents = [line.strip('\n') for line in fp] for item in contents: ...
true
920d2ff4b74ff86352851e8435f0a9761c649392
Cbkhare/Challenges
/multiply_list.py
1,233
4.15625
4
#In case data is passed as a parameter from sys import argv #from string import ascii_uppercase file_name = argv[1] fp = open(file_name,'r+') contents = [ line.strip('\n').split('|') for line in fp] #print (contents) for item in contents: part1 = list(item[0].split(' ')) part1.remove('') part2 = list(...
true
0ea75af0aeb9c2bea86f5c8e95f9ca942344e8a9
Cbkhare/Challenges
/HackerRank_Numpy_Transpose_Flatten.py
1,424
4.125
4
from sys import stdin as Si, maxsize as m import numpy as np class Solution: pass if __name__=='__main__': n,m = map(int,Si.readline().split()) N = np.array([],int) for i in range(n): N = np.append(N,list(map(int,Si.readline().split())),axis=0) N.shape = (n,m) #Note:- #To appe...
true
0c747667e925a98008c91f87dedbd34c2ab10e83
Cbkhare/Challenges
/str_permutations.py
1,087
4.3125
4
#In case data is passed as a parameter from sys import argv from itertools import permutations #from string import ascii_uppercase file_name = argv[1] fp = open(file_name,'r+') contents = [line.strip('\n') for line in fp] #print (contents) for item in contents: #print (item) p_tups= sorted(permutations(i...
true
ac2ffaa848aee4feacc96c124fa6ca0e6f4480e6
PutkisDude/Developing-Python-Applications
/week3/3_2_nameDay.py
490
4.25
4
#Author Lauri Putkonen #User enters a weekday number and the program tells the name of the day. import calendar day = int(input("Number of the day: ")) -1 print(calendar.day_name[day]) # Could also make a list and print from it but there is inbuilt module in python to do same thing # weekdays = ["Monday", "Tuedsday...
true
7a32efcdfaf7edef3e3ffaffabbeed9bed255bd3
mkgmels73/Bertelsmann-Scholarship-Data-Track
/Python challenge/39_random_password.py
1,389
4.40625
4
#While generating a password by selecting random characters usually creates one that is relatively secure, it also generally gives a password that is difficult to memorize. As an alternative, some systems construct a password by taking two English words and concatenating them. While this password may not be as secure, ...
true
12b45b29d942aec593b21161d8f6c4c6409722f2
kimfucious/pythonic_algocasts
/solutions/matrix.py
1,501
4.53125
5
# --- Directions # Write a function that accepts an integer, n, and returns a n x n spiral matrix. # --- Examples # matrix(2) # [[1, 2], # [4, 3]] # matrix(3) # [[1, 2, 3], # [8, 9, 4], # [7, 6, 5]] # matrix(4) # [[1, 2, 3, 4], # [12, 13, 14, 5], # [11, 16, 15, 6], # [10, 9,...
true
dca708d0b43e4adea6e69b7ec9611e919310a472
kimfucious/pythonic_algocasts
/exercises/reversestring.py
273
4.375
4
# --- Directions # Given a string, return a new string with the reversed order of characters # --- Examples # reverse('apple') # returns 'leppa' # reverse('hello') # returns 'olleh' # reverse('Greetings!') # returns '!sgniteerG' def reverse(string): pass
true
b93be8d587df03aa1ef86361067b3ae45c42e861
kimfucious/pythonic_algocasts
/solutions/levelwidth.py
510
4.15625
4
# --- Directions # Given the root node of a tree, return a list where each element is the width # of the tree at each level. # --- Example # Given: # 0 # / | \ # 1 2 3 # | | # 4 5 # Answer: [1, 3, 2] def level_width(root): widths = [0] l = [root, "end"] while len(l) > 1: nod...
true
fdc8646c69a3c4eb44cd016b4d1708ca77acef07
kimfucious/pythonic_algocasts
/solutions/palindrome.py
410
4.40625
4
# --- Directions # Given a string, return True if the string is a palindrome or False if it is # not. Palindromes are strings that form the same word if it is reversed. *Do* # include spaces and punctuation in determining if the string is a palindrome. # --- Examples: # palindrome("abba") # returns True # palindro...
true
7484096aff7b568bf17f4bc683de3a538807ce52
kimfucious/pythonic_algocasts
/solutions/capitalize.py
1,010
4.4375
4
# --- Directions # Write a function that accepts a string. The function should capitalize the # first letter of each word in the string then return the capitalized string. # --- Examples # capitalize('a short sentence') --> 'A Short Sentence' # capitalize('a lazy fox') --> 'A Lazy Fox' # capitalize('look, it is ...
true
6744b752c094cf71d347868859037e6256cdb4e8
didomadresma/ebay_web_crawler
/ServiceTools/Switcher.py
978
4.28125
4
#!/usr/bin/env python3 __author__ = 'papermakkusu' class Switch(object): """ Simple imitation of Switch case tool in Python. Used for visual simplification """ value = None def __new__(class_, value): """ Assigns given value to class variable on class creation :return: ...
true
e7d5d7e1c7a2d766c49de8e0009482ad488a3a63
Priktopic/python-dsa
/str_manipualtion/replace_string_"FOO"_"OOF".py
1,052
4.3125
4
""" If a string has "FOO", it will get replaced with "OOF". However, this might create new instances of "FOO". Write a program that goes through a string as many times as required to replace each instances of "FOO" with "OOF". Eg - In "FOOOOOOPLE", 1st time it will become "OOFOOOOPLE". Again we have "FOO", so the 2nd ...
true
57899dbcf24323514b453e3b1a9de5bc01379c8c
Priktopic/python-dsa
/linkedlist/largest_sum_of_ele.py
1,149
4.4375
4
''' You have been given an array containg numbers. Find and return the largest sum in a contiguous subarray within the input array. Example 1: arr= [1, 2, 3, -4, 6] The largest sum is 8, which is the sum of all elements of the array. Example 2: arr = [1, 2, -5, -4, 1, 6] The largest sum is 7, which is the sum of th...
true
17e30a414fdf6bf310fa229ddede6b7dd23551bc
Priktopic/python-dsa
/str_manipualtion/rmv_digits_replace_others_with_#.py
350
4.25
4
""" consider a string that will have digits in that, we need to remove all the not digits and replace the digits with # """ def replace_digits(s): s1 = "" for i in s: if i.isdigit(): s1 += i return(re.sub('[0-9]','#',s1)) # modified string which is after replacing the # with digits re...
true
153687f5a58296d127d14789c96ce8843eb236a0
dylanly/Python-Practice
/best_friends.py
386
4.25
4
list_friends = ['Ken', 'Mikey', 'Mitchell', 'Micow'] print("Below you can see all my best friends!\n") for friend in list_friends: print(friend) if 'Drew' not in list_friends: print("\n:O \nDrew is not in my friends list!!\n") list_friends.append('Drew') for friend in list_friends: print...
true
7014390c7d7031113d04ac773ee1dec33950aeea
KKobuszewski/pwzn
/tasks/zaj2/zadanie1.py
1,623
4.15625
4
# -*- coding: utf-8 -*- def xrange(start=0, stop=None, step=None): """ Funkcja która działa jak funkcja range (wbudowana i z poprzednich zajęć) która działa dla liczb całkowitych. """ #print(args,stop,step) x = start if step is None: step = 1 if stop is None: stop = st...
true
91023ff23cf97b09c25c2fe53f787aa764c8ca69
clark-ethan9595/CS108
/lab05/song.py
1,076
4.375
4
''' A program to specify verses, container, and desired food/beverage. Fall 2014 Lab 05 @author Ethan Clark (elc3) ''' #Prompt user for their own version of the song lyrics verses = int(input('Please give number of verses for song:')) container = input('Please give a container for your food/beverage:') substance = inp...
true
8bcb5e719f1148779689d7d80422c468257a9f0f
clark-ethan9595/CS108
/lab02/einstein.py
729
4.21875
4
''' Variables and Expessions September 11, 2014 Lab 02 @author Ethan and Mollie (elc3 and mfh6) ''' #Ask user for a three digit number. number = int(input('Give a three digit number where the first and last digits are more than 2 apart : ')) #Get the reverse of the user entered number. rev_number = (number//1)%10 * 1...
true
2ab3022ae0ea51d58964fffd5887dbd5f1812974
huajianmao/pyleet
/solutions/a0056mergeintervals.py
1,085
4.21875
4
# -*- coding: utf-8 -*- ################################################ # # URL: # ===== # https://leetcode.com/problems/merge-intervals/ # # DESC: # ===== # Given a collection of intervals, merge all overlapping intervals. # # Example 1: # Input: [[1,3],[2,6],[8,10],[15,18]] # Output: [[1,6],[8,10],[15,18]] # Explan...
true
cd72d43f6a973cf8d0bb3b522e9226dc7f8eef76
ACES-DYPCOE/Data-Structure
/Searching and Sorting/Python/merge_sort.py
1,939
4.125
4
''' Merge Sort is a Divide and Conquer algorithm. It divides input array in two halves, calls itself for the two halves and then merges the two sorted halves.The merge() function is used for merging two halves. The merge(arr, l, m, r) is key process that assumes that arr[l..m] and arr[m+1..r] are sorted and merges ...
true
aad803d232b8bb4e205cd3b0cac8233f228b44d3
ACES-DYPCOE/Data-Structure
/Searching and Sorting/Python/shell_sort.py
1,254
4.15625
4
#Shell sort algorithm using python #Shell sort algorithm is an improved form of insertion sort algorithm as it compares elements separated by a gap of several position. #In Shell sort algorithm, the elements in an array are sorted in multiple passes and in each pass, data are taken with smaller and smaller gap sizes....
true
f5cf5e85ffd22f6a59d4d1c1f183b2b668f82e29
faizanzafar40/Intro-to-Programming-in-Python
/2. Practice Programs/6. if_statement.py
298
4.1875
4
""" here I am using 'if' statement to make decisions based on user age """ age = int(input("Enter your age:")) if(age >= 18): print("You can watch R-Rated movies!") elif(age > 13 and age <= 17): print("You can watch PG-13 movies!") else: print("You should only watch Cartoon Network")
true
c56354bd9e49655c5f7f4a4c8f009ee7c13b7272
razi-rais/toy-crypto
/rsa.py
1,457
4.1875
4
# Toy RSA algo from rsaKeyGen import gen_keypair # Pick two primes, i.e. 13, 7. Try substituting different small primes prime1 = 13 prime2 = 7 # Their product is your modulus number modulus = prime1 * prime2 print "Take prime numbers %d, %d make composite number to use as modulus: %d" % (prime1, prime2, modulus) prin...
true
bc60a2c690b7f7e51f086f92258a7e9bc14ff466
raoliver/Self-Taught-Python
/Part II/Chapter 14.py
997
4.21875
4
##More OOP class Rectangle(): recs = []#class variable def __init__(self, w, l): self.width = w#Instance variable self.len = l self.recs.append((self.width, self.len))#Appends the object to the list recs def print_size(self): print("""{} by {}""".format(self.width, self.le...
true
7633a1fedf0957e1577ffcae5d1b35fc894a3b34
knmarvel/backend-katas-functions-loops
/main.py
2,253
4.25
4
#!/usr/bin/env python import sys import math """Implements math functions without using operators except for '+' and '-' """ __author__ = "github.com/knmavel" def add(x, y): added = x + y return added def multiply(x, y): multiplied = 0 if x >= 0 and y >= 0: for counter in range(y): ...
true
e2755d36a518efc21f5c479c4c3f32a54408eade
behind-the-data/ccp
/chap2/name.py
534
4.3125
4
name = "ada lovelace" print(name.title()) # the title() method returns titlecased STRING. # All below are optional # Only Capital letters print(name.upper()) # Only Lower letters print(name.lower()) ## Concatenation ## first_name = "ada" last_name = "lovelace" full_name = first_name + " " + last_name print(full_n...
true
2d29f47c7b91c33feac52f38bf0168ac6918d821
jcol27/project-euler
/41.py
1,674
4.3125
4
import math import itertools ''' We shall say that an n-digit number is pandigital if it makes use of all the digits 1 to n exactly once. For example, 2143 is a 4-digit pandigital and is also prime. What is the largest n-digit pandigital prime that exists? Can use itertools similar to previous problem. We can use t...
true
5c4fc548e88cada634ce1e2c84bf0fa494d6b6a8
mparkash22/learning
/pythonfordatascience/raise.py
538
4.1875
4
#raise the value1 to value2 def raise_both(value1, value2): #function header """Raise value1 to the power of value 2 and vice versa""" #docstring new_value1= value1 ** value2 #function body new_value2= value2 ** value1 new_tuple = (new_value1, new_value2) return new_tuple #we c...
true
aec15d1708777d5cccc103aa309fab48491fb53c
jesuarezt/datacamp_learning
/python_career_machine_learning_scientist/04_tree_based_models_in_python/classification_and_regression_tree/02_entropy.py
1,607
4.125
4
#Using entropy as a criterion # #In this exercise, you'll train a classification tree on the Wisconsin Breast Cancer dataset using entropy as an information criterion. #You'll do so using all the 30 features in the dataset, which is split into 80% train and 20% test. ## ##X_train as well as the array of labels y_tr...
true
a5b6035fb3d38ef3459cfd842e230bbfb2148583
jesuarezt/datacamp_learning
/python_career_machine_learning_scientist/06_clustering_analysis_in_python/03_kmeans_clustering/01_example_kmeans.py
1,881
4.1875
4
#K-means clustering: first exercise # #This exercise will familiarize you with the usage of k-means clustering on a dataset. Let us use the Comic Con dataset and check how k-means clustering works on it. # #Recall the two steps of k-means clustering: # # Define cluster centers through kmeans() function. It has...
true
5ca2cf2b0365dd45d8f5ff5dc17b8e21d6ab751f
remichartier/002_CodingPractice
/001_Python/20210829_1659_UdacityBSTPractice/BinarySearchTreePractice_v00.py
1,210
4.25
4
"""BST Practice Now try implementing a BST on your own. You'll use the same Node class as before: class Node(object): def __init__(self, value): self.value = value self.left = None self.right = None This time, you'll implement search() and insert(). You should rewrite search() and not use yo...
true
c7f1a592ba1dc81f24bc3097fbde5f0784eecd35
remichartier/002_CodingPractice
/001_Python/20210818_2350_UdacityQuickSortAlgo/QuickSorAlgoPivotLast_v01.py
1,305
4.1875
4
"""Implement quick sort in Python. Input a list. Output a sorted list.""" # Note : method always starting with last element as pivot def quicksort(array): # quick sort with pivot # Then quick sort left_side of pivot and quick_sort right side of pivot # Then combine left_array + Pivot + Right Array # b...
true
d975dee37afc80c487f6ff0b1723697f340b2448
ZeroDestru/aula-1-semestre
/aulas/oitavo3.py
1,764
4.125
4
import turtle myPen = turtle.Turtle() myPen.tracer(5) myPen.speed(5) myPen.color("blue") # This function draws a box by drawing each side of the square and using the fill function def box(intDim): myPen.begin_fill() # 0 deg. myPen.forward(intDim) myPen.left(90) # 90 deg. myPen....
true
92f0837d2b94b72d013e7cb41d72ef7f5c78fdf8
HYnam/MyPyTutor
/W2_Input.py
1,110
4.375
4
""" Input and Output Variables are used to store data for later use in a program. For example, the statement word = 'cats' assigns the string 'cats' to the variable word. We can then use the value stored in the variable in an expression. For example, sentence = 'I like ' + word + '!' will assign the string 'I like cat...
true
c21a9037c094373b18800d86a8a5c64ea1beb0f7
HYnam/MyPyTutor
/W6_range.py
711
4.53125
5
""" Using Range The built-in function range returns an iterable sequence of numbers. Write a function sum_range(start, end) which uses range to return the sum of the numbers from start up to, but not including, end. (Including start but excluding end is the default behaviour of range.) Write a fun...
true
0fbe09ab6841a44123707d905ee14be14e03fc53
HYnam/MyPyTutor
/W12_recursive_base2dec.py
354
4.125
4
""" Recursively Converting a List of Digits to a Number Write a recursive function base2dec(digits, base) that takes the list of digits in the given base and returns the corresponding base 10 number. """ def base2dec(digits, base): if len(digits) == 1: return digits[0] else: return digits[-1] + ...
true
8dc081fad4227c0456266c0eab5ae3fcf5ed4d36
HYnam/MyPyTutor
/W7_except_raise.py
1,736
4.5625
5
""" Raising an Exception In the previous problem, you used a try/except statement to catch an exception. This problem deals with the opposite situation: raising an exception in the first place. One common situation in which you will want to raise an exception is where you need to indicate that some precond...
true
dc68b3a0f41f752b188744d0e1b0cdb547682b11
HYnam/MyPyTutor
/W3_if_vowels.py
1,070
4.5
4
""" If Statements Using Else In the previous question, we used an if statement to run code when a condition was True. Often, we want to do something if the condition is False as well. We can achieve this using else: if condition: code_if_true [code_if_true...] else: code_if_false ...
true
edb7cb3c4ee6562817d60924828836e66eed9011
PraveshKunwar/python-calculator
/Volumes/rcc.py
410
4.125
4
import math def rccCalc(): print(""" Please give me radius and height! Example: 9 10 9 would be radius and 10 would be height! """) takeSplitInput = input().split() if len(takeSplitInput) > 2 or len(takeSplitInput) < 2: print("Please give me two numbers only to work with!") value...
true
32321cdb22a57d52a55354adc67bdf020828a8e1
nitinaggarwal1986/learnpythonthehardway
/ex20a.py
1,317
4.375
4
# import the argv to call arguments at the script call from sys module. from sys import argv # Asking user to pass the file name as an argument. script, input_file = argv # To define a function to print the whole file passed into function as # a parameter f. def print_all(f): print f.read() # To define a rewind fu...
true
8872d33049899b976831cea4e01e8fc73f88ebef
bvsbrk/Learn-Python
/Basics/using_super_keyword.py
684
4.46875
4
class Animal: name = "animal" """ Here animal class have variable name with value animal Child class that is dog have variable name with value dog So usually child class overrides super class so from child class If we see the value of name is dog To get the value of super class we use 'sup...
true
7ae4858f192bbbc1540e1fb3d8a3831e6a04f6e9
CodeItISR/Python
/Youtube/data_types.py
979
4.59375
5
# KEY : VALUE - to get a value need to access it like a list with the key # key can be string or int or float, but it need to be uniqe # Creating an dictionary dictionary = {1: 2 ,"B": "hello" , "C" : 5.2} # Adding a Key "D" with value awesome dictionary["D"] = "awesome" print(dictionary["D"]) # Print the dictionary ...
true
a1c2a407f9e3c3bac070a84390674c519ca8ed63
scidam/algos
/algorithms/sorting/bubble.py
1,446
4.21875
4
__author__ = "Dmitry E. Kislov" __created__ = "29.06.2018" __email__ = "kislov@easydan.com" def bubble_sort(array, order='asc'): """Bubble sorting algorithm. This is a bit smart implementation of the bubble sorting algoritm. It stops if obtained sequence is already ordered. **Parameters** :...
true
30cf241927d7fb24f62b6ec3afd4952e05d01032
KrisztianS/pallida-basic-exam-trial
/namefromemail/name_from_email.py
512
4.40625
4
# Create a function that takes email address as input in the following format: # firstName.lastName@exam.com # and returns a string that represents the user name in the following format: # last_name first_name # example: "elek.viz@exam.com" for this input the output should be: "Viz Elek" # accents does not matter emai...
true
b3561a5180fc2c219f1b7fa97a663de9ea0be793
Whitatt/Python-Projects
/Database1.py
1,057
4.25
4
import sqlite3 conn = sqlite3.connect('database1.db') with conn: cur = conn.cursor() #Below I have created a table of file list cur.execute("CREATE TABLE IF NOT EXISTS tbl_filelist(ID INTEGER PRIMARY KEY AUTOINCREMENT, \ col_items TEXT)") # in the file list, i have created a column of items. ...
true
7d32b260a8251dfe0bd111e615f8c84975d7102c
zarkle/code_challenges
/codility/interviewing_io/prechallenge2.py
2,097
4.1875
4
""" Mary has N candies. The i-th candy is of a type represented by an interger T[i]. Mary's parents told her to share the candies with her brother. She must give him exactly half the candies. Fortunately, the number of candies N is even. After giving away half the candies, Mary will eat the remaining ones. She loves...
true
ba81db6eb0340d66bc8151f3616069d4d6a994a0
zarkle/code_challenges
/dsa/recursion/homework_solution.py
2,026
4.3125
4
def fact(n): """ Returns factorial of n (n!). Note use of recursion """ # BASE CASE! if n == 0: return 1 # Recursion! else: return n * fact(n-1) def rec_sum(n): """ Problem 1 Write a recursive function which takes an integer and computes the cumulative ...
true
84ba5a4f2a1b9761148d8ec7c803bb7732f3e75a
zarkle/code_challenges
/fcc_pyalgo/07_minesweeper.py
1,491
4.5
4
""" Write a function that wil take 3 arguments: - bombs = list of bomb locations - rows - columns mine_sweeper([[0,0], [1,2]], 3, 4) translates to: - bomb at row index 0, column index 0 - bomb at row index 1, column index 2 - 3 rows (0, 1, 2) - 4 columns (0, 1, 2, 3) [2 bomb location coordinates in a 3x4 matrix] we s...
true
c2a5429480d3c26fefd305b728e27c8fe7824ebf
zarkle/code_challenges
/hackerrank/16_tree_postorder_trav.py
783
4.21875
4
# https://www.hackerrank.com/challenges/tree-postorder-traversal/problem """ Node is defined as self.left (the left child of the node) self.right (the right child of the node) self.info (the value of the node) """ def postOrder(root): #Write your code here traverse = '' def _walk(node=None): ...
true
7624dfe6435e1575121da552c169df512f974c24
rxu17/physics_simulations
/monte_carlo/toy_monte_carlo/GluonAngle.py
1,025
4.1875
4
# Rixing Xu # # This program displays the accept and reject method - generate a value x with a pdf(x) as the gaussian distribution. # Then generate a y value where if it is greater than the pdf(x), we reject that x, otherwise we accept it # Physically, the gluon is emitted from the quark at an angle # Assumptions:...
true
c6be4757dcfe28f09cee4360444ede6068058a8b
omarMahmood05/python_giraffe_yt
/Python Basics/13 Dictionaries.py
786
4.40625
4
# Dict. in python is just like dicts in real life. You give a word and then assign a meaning to it. Like key -> An instrument used to open someting speciftc. # In python we do almost the same give a key and then a value to it. For eg Jan -> January monthConversions = { "Jan": "January", "Feb": "February",...
true
2935d9e5617f497d5eb145bc473650ab021d996a
huangqiank/Algorithm
/leetcode/sorting/sort_color.py
1,112
4.21875
4
# Given an array with n objects colored red, # white or blue, sort them in-place  # so that objects of the same color are adjacent, # with the colors in the order red, white and blue. # Here, we will use the integers # 0, 1, and 2 to represent the color red, white, and blue respectively. # Note: You are not suppose to ...
true
317f0783b9e840b41f9d422896475d5d76949889
huangqiank/Algorithm
/leetcode/tree/binary_tree_level_order_traversal2.py
1,205
4.15625
4
##Given a binary tree, return the bottom-up level order traversal of its nodes' values. # (ie, from left to right, level by level from leaf to root). ##For example: ##Given binary tree [3,9,20,null,null,15,7], ## 3 ## / \ ## 9 20 ## / \ ## 15 7 ##return its bottom-up level order traversal as: ##[ ## [1...
true
f07911a813545ba8213b8500356406cd1a3fb8af
Hyeongseock/EulerProject
/Problem004.py
1,832
4.15625
4
''' Largest palindrome product Problem 4 ''' ''' English version A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 × 99. Find the largest palindrome made from the product of two 3-digit numbers. ''' #Make empty list to add number number_lis...
true
88021e789e0602fff3527af5edd82e2db4e5376c
omolea/BYUI_CS101
/week_02/team_activity.py
2,155
4.15625
4
""" Jacob Padgett W02 Team Activity: Bro Brian Wilson """ First_name = input("What is you first name: ") Last_name = input("What is you last name: ") Email_Address = input("What is you email: ") Phone_Number = input("What is you number: ") Job_Title = input("What is you job: ") ID_Number = input("What is you id: ") H...
true
c3f197930c850ca43bc7c7339d1ab7482ea218bc
shoel-uddin/Digital-Crafts-Classes
/programming102/exercises/list_exercises.py
1,555
4.375
4
#Exercise 1 # Create a program that has a list of at least 3 of your favorite # foods in order and assign that list to a variable named "favorite_foods". # print out the value of your favorite food by accessing by it's index. # print out the last item on the list as well. favorite_foods = ["Pizza", "Pasta", "Byriani"...
true
28c51e037e37d5567b59afb6abb3cbdf40f9e64b
Eccie-K/pycharm-projects
/looping.py
445
4.28125
4
#looping - repeating a task a number of times # types of loops: For loop and while loop # modcom.co.ke/datascience counter = 1 # beginning of the loop while counter <= 10: # you can count from any value print("hello", counter) counter = counter +1 # incrementing z = 9 while z >= -9: print("you", z) ...
true
d1bbfae6e3467c8557852939faf5cdd1daa1f2ca
Robock/problem_solving
/interview_code_14.py
1,127
4.125
4
#Given a non-finite stream of characters, output an "A" if the characters "xxx" are found in exactly that sequence. #If the characters "xyx" are found instead, output a "B". #Do not re-process characters so as to output both an “A” and a “B” when processing the same input. For example: #1. The following input xx...
true
c7b7a3f789e1481bdd819b815820bebefddb6582
ashwin-pajankar/Python-Bootcamp
/Section09/08fact.py
225
4.3125
4
num = int(input("Please enter an integer: ")) fact = 1 if num == 0: print("Factorial of 0 is 1.") else: for i in range (1, num+1): fact = fact * i print("The factorial of {0} is {1}.".format(num, fact))
true
718ebb2daf0753bcaeeef1bfc6c226f320000859
zenvin/ImpraticalPythonProjects
/chapter_1/pig_latin_ch1.py
926
4.125
4
## This program will take a word and turn it into pig latin. import sys import random ##get input VOWELS = 'aeiouy' while True: word = input("Type a word and get its pig Latin translation: ") if word[0] in VOWELS: pig_Latin = word + 'way' else: pig_Latin = word[1:] + word[0] + 'ay' p...
true
d436073bd316bd56c8c9958785e0bb18476944a7
Soundaryachinnu/python_script
/classobj.py
1,360
4.125
4
#!/usr/bin/python class Parent: # define parent class parentAttr = 100 def __init__(self): print "Calling parent constructor" def parentMethod(self): print 'Calling parent method' def setAttr(self, attr): Parent.parentAttr = attr def getAttr(self): print "Parent attribu...
true
f60b812a06af2b1a20d6f8c609c5c06492fe3f8c
Arsal-Sheikh/Dungeon-Escape---CS-30-Final
/gamemap.py
2,604
4.25
4
class Dungeon: def __init__(self, name, riddle, answer): """Creates a dungeon Args: name (string): The name of the dungeon riddle (string): The riddle to solve the dungeon answer (string): The answer to the riddle """ self.name = name self...
true
d9736075107c9ca1f288291a0109789e658d00c1
1ekrem/python
/CrashCourse/chapter10/tiy103.py
1,962
4.375
4
''' 10-3. Guest: Write a program that prompts the user for their name. When they respond, write their name to a file called guest.txt. 10-4. Guest Book: Write a while loop that prompts users for their name. When they enter their name, print a greeting to the screen and add a line recording their visit in a file called...
true
9a6a512989a683662cb0947cc5b7ad2d3ba903e7
1ekrem/python
/CrashCourse/chapter8/tiy86.py
2,533
4.75
5
""" 8-6. City Names: Write a function called city_country() that takes in the name of a city and its country. The function should return a string formatted like this: "Santiago, Chile" Call your function with at least three city-country pairs, and print the value that’s returned. """ def city_country(cityName, country...
true
38f7a26fd5f45b93c1d1ed6669bd362a55e2f641
1ekrem/python
/CrashCourse/chapter8/tiy89.py
1,670
4.46875
4
"""8-9. Magicians: Make a list of magician’s names. Pass the list to a function called show_magicians(), which prints the name of each magician in the list.""" def show_magicians(magicians): for name in magicians: print(name) names = ['Ekrem', 'Daria', 'Pupsik'] show_magicians(names) """8-10. ...
true
8b816e4924d13dad093ea03f4967cae78eb494d5
Lyonidas/python_practice
/Challenge-4.py
1,759
4.1875
4
# Preston Hudson 11/21/19 Challenge 4 Written in Python #1. Write a function that takes a number as input and returns that number squared. def f(x): """ returns x squared :param x: int. :return: int sum of x squared """ return x ** 2 z = f(4) print(z) #2. Create a function that accepts a str...
true
ceb3a00d884b1ee19687364f03d1755e7932c43d
Lyonidas/python_practice
/Challenge-6.py
1,652
4.1875
4
# Preston Hudson 11/25/19 Challenge 6 Written in Python #1. Print every character in the string "Camus". author = "Camus" print(author[0]) print(author[1]) print(author[2]) print(author[3]) print(author[4]) #2. Write a program that collects two strings from the user, inserts them into a string and prints a new strin...
true
76178534554fa030e42e9f7a2d23db151b282b09
jcalahan/ilikepy
/004-functions.py
311
4.15625
4
# This module explores the definition and invocation of a Python function. PI = 3.1459 def volume(h, r): value = PI * h * (r * r) return value height = 42 radius = 2.0 vol = volume(height, radius) print "Volume of a cylinder with height of %s and radius of %s is %s" \ % (height, radius, vol)
true
2b409cfeb923e07db625a46cf4a357cc627d5a20
niranjan2822/Interview1
/count Even and Odd numbers in a List.py
1,827
4.53125
5
# count Even and Odd numbers in a List ''' Given a list of numbers, write a Python program to count Even and Odd numbers in a List. Example: Input: list1 = [2, 7, 5, 64, 14] Output: Even = 3, odd = 2 Input: list2 = [12, 14, 95, 3] Output: Even = 2, odd = 2 ''' # Example 1: count Even and Odd numbers from given li...
true