blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
0d57a53bcb7165dc4d122e213a2a43e9fb208f4b
spoonsandhangers/tablesTablesTables
/table1.py
1,454
4.375
4
""" Creating tables in Tkinter. There is no table widget but we can use a function from ttk called treeview. You must import ttk from tkinter Then add a Frame to the root window. Create a Treeview object with the correct number of columns (see other attributes) Create a list of headings for the columns iterate throug...
true
e64e382a1de818cf5d47d3e4af81e0395c5bf769
anuj0721/100-days-of-code
/code/python/day-1/FactorialRecursion.py
246
4.1875
4
def fact(n): if (n < 0): return "not available/exist." elif (n == 1 or n == 0): return 1 else: return n*fact(n-1) num = int(input("Enter a number: ")) f = fact(num) print("factorial of",num,"is ",f)
true
84e1af8bef6874e22dc74fd31f75913736989c88
anuj0721/100-days-of-code
/code/python/day-52/minimum_element_of_main_list_that_is_max_of_other_list.py
1,084
4.1875
4
main_list = [number for number in input("Enter Main list values separated by space: ").split()] list_i = int(input("How many other list you want to enter: ")) for value in range(1,list_i+1): globals()['my_list%s' %value] = [number for number in input("Enter values separated by space: ").split()] #find maximum elem...
true
9f45e0268108c93f6e2b3fb5d323943300db1617
anuj0721/100-days-of-code
/code/python/day-60/print_stars_in_D_shape.py
491
4.3125
4
rows = int(input("How many rows?: ")) if rows <= 0: raise ValueError("Rows can not be negative or zero") cols = int(input("How many columns?: ")) if cols <= 0: raise ValueError("Columns can not be negative or zero") for row in range(0,rows): for col in range(0,cols): if (((row != 0 and row != rows-...
true
add852bf6dbf84eb3087e565e6b2f2f2229369c6
t0futac0/ICTPRG-Python
/Selection/selectionQ2.py
331
4.125
4
## Write a program that asks the user for their year of birth, ## Checks if they are of legal drinking age ## and tells the user to come into the bar. age_verification = int(input("What is your year of birth? ")) if age_verification >= 2002: print("Do a U-Turn!") else: print("Please come straight through to...
true
d48fff9caca448449499ef613502d239c110ef09
t0futac0/ICTPRG-Python
/String Manipulation/Python String Manipulation.py
349
4.46875
4
#Python String Manipulation #Write a program that asks the user for their full name, splits it up into words and outputs each word on a new line. #For names with 2 words (eg, 'Fred Frank') this would output Fred, then frank on two lines. full_name = input("Please enter your full name ") name_list = full_name.split() ...
true
99cd74851c03956263024aa1aa6003a492698a9b
trentwoodbury/anagram_finder
/AnagramChecker.py
1,012
4.21875
4
from collections import Counter class AnagramChecker: ''' This is a class that is able to efficiently check if two words are anagrams. ''' def __init__(self): self.words_are_anagrams = None def check_if_words_are_anagram(self, word_1, word_2): ''' Checks if word_1 and word...
true
d071703773d8586c8f9547d4397f05f179f7e862
jttyeung/hackbright
/cs-data-struct-2/sorting.py
2,247
4.4375
4
#Sorting def bubble_sort(lst): """Returns a sorted list using a optimized bubble sort algorithm i.e. using a variable to track if there hasn't been a swap. >>> bubble_sort([3, 5, 7, 2, 4, 1]) [1, 2, 3, 4, 5, 7] """ sorted_list = [] for i in range(len(lst) - 1): for j in r...
true
011419b7055a1fcb8738998c5cd373eb115eb824
wchen308/practice_algo
/largest_factor.py
234
4.25
4
import math def largest_factor(n): """ Return the largest factor of n that is smaller than n """ div = 2 while div <= math.sqrt(n): if n % div == 0: return n / div else: div += 1 return 1 print(largest_factor(13))
true
36058b7dcd271f8672f7265e559935c47c065d7d
Flooorent/review
/cs/leetcode/array/merge_intervals.py
1,244
4.125
4
""" 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]] Explanation: Since intervals [1,3] and [2,6] overlaps, merge them into [1,6]. Example 2: Input: [[1,4],[4,5]] Output: [[1,5]] Explanation: Intervals [1,4] and [4,5] are...
true
f76fbc46587b2c5c14f7eefcbe1a1f5da3218f05
khcal1/Python-Basics
/Dinner Party.py
1,649
4.65625
5
'''This program displays the uses of List Start by inviting three people to a dinner party''' import os import sys import random guest_list = ['Socrates', 'King Tutt', 'Bas'] for guest in guest_list: print("{}, Welcome to the party.".format(guest)) '''One person cannot make it to the party. Delete that...
true
3866457894ea4ef4cc1586c71fead89ff192a3e6
pranaysapkale007/Python
/Basic_Python_Code/Basic Codes/Prime Number.py
239
4.1875
4
# number which is only divisible to itself # 2, 3, 5, 7, 15, 29 number = 3 flag = False for i in range(2, number): if number % i == 0: flag = True if flag: print("Number is not prime") else: print("Number is prime")
true
36390b2bd3234a89c3d601e26fb3b65ebe76f748
iftikhar1995/Python-DesignPatterns
/Creational/Builder/ComputerBuilder/SubObjects/hard_disk.py
895
4.25
4
class HardDisk: """ HardDisk of a computer """ def __init__(self, capacity: str) -> None: self.__capacity = capacity def capacity(self) -> str: """ A helper function that will return the capacity of the hard disk. :return: The capacity of the hard disk. :rt...
true
dc1f8e95e109b452741be9c9e55eb5d2bb286cfd
khinthetnwektn/Python-Class
/Function/doc.py
622
4.28125
4
def paper(): ''' 1. There will ve situations where your program has to interest with the user. For example, you would want to take some results back.''' ''' 2. There will be situations where your program has to interest with the user. For example, you would want to take some results back. ''' print(paper.__doc__)...
true
6372e0d8949a79d7142020d7ccbbd6fe222e8e15
vasimkachhi/Python_Code_Sneppets
/webCrawlingbs4.py
1,992
4.125
4
""" This code crawls two sites and extracts tables and its content using beautiful soup and urllib2 Crawling or web scrapping example 1) http://zevross.com/blog/2014/05/16/using-the-python-library-beautifulsoup-to-extract-data-from-a-webpage-applied-to-world-cup-rankings/ 2) https://en.wikipedia.org/wik...
true
6c41734cd5f2e23ee52c2152d3676ff0bb00a42e
durgeshtrivedi/Python
/FlowControl.py
586
4.40625
4
# -*- coding: utf-8 -*- #%% def flowControl(): name = input("what is your name") age = int(input("whats your age,{}".format(name))) if age > 18: print("You have the rights for voting") else: print("Come after {}".format(18 - age)) if 16 <= age <= 65: prin...
true
023a932e90e2c2bfcb8f60916bf3f876d6031a8f
ygkoumas/algorithms
/match-game/__main__.py
1,820
4.21875
4
# Simulate a card game called "match" between two computer players using N packs of cards. # The cards being shuffled. # Cards are revealed one by one from the top of the pile. # The matching condition can be the face value of the card, the suit, or both. # When two matching cards are played sequentially, a player is c...
true
a09dd584e8e71badeaba7b5473bea545db030e26
niuonas/DataStructuresPython
/Range.py
795
4.71875
5
#Sequence representing an arithmetic progression of integers #Range determines what arguments mean by counting them # range(stop) - only one element # range(start,stop) - two elements # range(start,stop,step) - three elements range(5) #the value provided as argument is the end of the range but is not included ...
true
922d2a3006bf9c2a159dd9ebce4f127c1e0e5984
RBazelais/coding-dojo
/Python/python_fundementals/StringAndList.py
1,698
4.28125
4
''' Find and replace print the position of the first instance of the word "day". Then create a new string where the word "day" is replaced with the word "month". ''' words = "It's thanksgiving day. It's my birthday,too!" str1 = words.replace("day", "month") #print str1 #Min and Max #Print the min and max values in a...
true
2eb391025229727a3c28bc4ccc37d389eff8c234
Masheenist/Python
/lesson_code/ex42_Is-A_Has-A_Objects_and_Classes/ex42.py
2,010
4.21875
4
# Make a class named Animal that is-a(n) object class Animal(object): pass # Make a class named Dog that is-a(n) Animal class Dog(Animal): def __init__(self, name): # from self, get the name attribute and set it to name self.name = name # Make a class named Cat that is-a(n) Animal class Cat(A...
true
b1dce264796bd68b9397b48e5b7a4685827f0745
Masheenist/Python
/lesson_code/ex20_Functions_and_Files/ex20.py
1,119
4.25
4
# get argv from sys module from sys import argv # have argv unpack to argument variables script, input_file = argv # fxn takes an open(ed) file as arg & reads it and prints def print_all(f): print(f.read()) # seek(0) moves to 0 byte (first byte) in the file def rewind(f): f.seek(0) # readline() reads one...
true
d99f911cf8714289dc500c1f0712f705a7bd34a4
Masheenist/Python
/lesson_code/ex44_Inheritance_vs_Composition/ex44b.py
681
4.65625
5
# OVERRIDE EXPLICITLY # ============================================================================= # The problem with having functions called implicitly is sometimes you want # the child to behave differently. # In this case we want to override the function in the child, thereby replacing # the functionality. To do...
true
17bbdd091df55ce376ba30b2412d3a25e3f3d885
jonathangray92/universe-simulator
/vector.py
2,100
4.34375
4
""" This module contains a 2d Vector class that can be used to represent a point in 2d space. Simple vector mathemetics is implemented. """ class Vector(object): """ 2d vectors can represent position, velocity, etc. """ ################# # Magic Methods # ################# def __init__(self, x, y): """ Vect...
true
30fb93535b4d03784f87e40067091aa9c3349b93
rudyredhat/PyEssTrainingLL
/Ch06/06_01/constructor.py
1,637
4.34375
4
#!/usr/bin/env python3 class Animal: # here is the class constructor # special method name with __init__ = with acts as an initializer or constructor def __init__(self, type, name, sound): # self is the first argument, that whats makes it a obj method # we have **kwargs and we can set the default valu...
true
0b65a0a5a1d3446f7156ed36d54c86653f637119
brentshermana/CompetativeProgramming
/src/puzzles/InterviewKickstart/dynamic_programming/count-ways-to-reach-nth-stair.py
721
4.25
4
# a person can take some number of stairs for each step. Count # the number of ways to reach the nth step # there is 1 way to reach the first stair # there are two ways to reach the second stair # there are 111 12 21 three ways to reach the third stair # to formulate this as a table, if we are at step i, which we can...
true
b4186605cdbb29642bd68ee3731379c18b9d770f
brentshermana/CompetativeProgramming
/src/puzzles/leetcode/leetcode_binarytreelongestconsecutivesequence/__init__.py
1,618
4.1875
4
# Given a binary tree, find the length of the longest consecutive sequence path. # # The path refers to any sequence of nodes from some starting node to any node in the tree along the parent-child connections. The longest consecutive path need to be from parent to child (cannot be the reverse). # # Example 1: # # Input...
true
7427a978ff9bcd065cdc21e70ada6a14f5b823e5
khinthandarkyaw98/Python_Practice
/random_permutation.py
681
4.15625
4
""" A permutation refers to an arrangement of elements. e.g. [3,2, 1] is a permutaion of [1, 2, 3] and vice-versa. The numpy random module provides two methods for this: shuffle() and permutation(). """ # shuffling arrays # shuffle() from numpy import random import numpy as np arr = np.array([1, 2, 3, ...
true
d24a450b4b9645e09fdf19d679997d9c83e03e2c
khinthandarkyaw98/Python_Practice
/python_tuto_functions.py
1,472
4.4375
4
# creating a function def my_func(): print("Hello") my_func() # pass an argument def my_function(fname): print(fname + "Refsnes") my_function('Emil') # pass two arguments def my_function(fname, lname): print(fname + " " + lname) my_function('Emil', 'Refsnes') """ if you do not know how many ...
true
ac13bb44dc4a015f00fd70bddc3f9bff608dafaf
khinthandarkyaw98/Python_Practice
/python_tuto_file.py
1,721
4.34375
4
# file # open('filename','mode') # opening a file f = open('file.txt') # open a file and read as a text f = open('file.txt', 'rt') # read the file f = open('file.txt', 'r') print(f.read()) # read only parts of the file f = open('file.txt', 'r') print(f.read(5)) # return the first characters of the ...
true
a5115410d54da81229153b78e33b869795ffcb46
khinthandarkyaw98/Python_Practice
/multiple_regression.py
2,281
4.5
4
# predict the CO2 emission of a car based on # the size of the engine. but # with multiple regression we can throw in more variables, # like the weight of the car, to make the prediction more accurate. import pandas # the pandas module allows us to read csv files # and return a DataFrame object df = pand...
true
f287078bdad6f01d1f61cab2b3167ba0538a5d26
khinthandarkyaw98/Python_Practice
/numpy_summation.py
703
4.3125
4
# add() is done between two elements : return an array # sum([]) happens over n elements : return an element import numpy as np arr1 = np.array([1, 2, 3]) arr2 = np.array([4, 5, 6]) newarr = np.add(arr1, arr2) print("add():", newarr) newarr = np.sum([arr1, arr2]) # note that sum([]) print("sum(): ...
true
4dae3e9211206ce3f4fc3b3633d13cd2054c57f2
ahmed-gamal97/Problem-Solving
/leetcode/Reverse Integer.py
569
4.15625
4
# Given a 32-bit signed integer, reverse digits of an integer. # Example 1: # Input: 123 # Output: 321 # Example 2: # Input: -123 #Output: -321 # Example 3: # Input: 120 # Output: 21 def reverse(x: int) -> int: result = [] sum = 0 is_neg = 0 if x < 1: x = x * -1 is_neg ...
true
67dad33c948cb704c1e09c22299aac2e5bf53eaf
AMAN123956/Python-Daily-Learning
/Day1/main.py
560
4.4375
4
# Print Function print(): # example: print("Hello World!!!") # " " > Tells that it is not a code but it is a string # String Manipulation # You can create a new line using '\n' print("Hello World!\n Myself Aman Dixit!") # String Concatenation print("Hello"+"Aman") # Input Function #example name=input("What is your na...
true
91f1517d926936c6e0e54c8685e23db3a754ee45
AMAN123956/Python-Daily-Learning
/Day10/docstringmain.py
478
4.25
4
#Docstring # ================================================================= # Uses: # 1.Can Also be used as multiline-comment # 2.Are a way to create a little bit of documentation for our function # 3.Comes after function definition #example def format_name(f_name,l_name): '''Take a first and last name and for...
true
8c2fe6dee7e6dbe4dd64751f7c9ce02241923856
AMAN123956/Python-Daily-Learning
/Day4/lists.py
407
4.3125
4
# Python Lists # ========================================================================= # Are like array #Example fruits=["Aman","Abhishek","Virat"] # We can use index as negative values print(fruits[-1]) # it will return Last Value of the List #Appending items to the end of list # Syntax: name_of_list.append("it...
true
7ba10a012f50f3b2e86b97b31570f1090637c288
CAVIND46016/Project-Euler
/Problem4.py
592
4.125
4
#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. def check_Palindrome(_num): return str(_num) == str(_num)[::-1]; def main(): product = 0; listPa...
true
9869e6edbef66fbf51646c8311167180acca98e6
kandarp29/python
/py20.py
407
4.15625
4
ojjus = [] b = input("number of elements in the list") b = int(b) for i in range(0,b): c = input("Insert list elements = ") ojjus.append(c) print("Your list is " ,ojjus) def sorting(a): for j in range(0,b): if a == ojjus[j]: print("your element is in the list ") else:...
true
6da8b025d3ebd4523aac45174c9145a71ff20996
jessidepp17/hort503
/assignments/A02/ex06.py
1,094
4.40625
4
# define variables types_of_people = 10 # x is a variable that ouputs a string with embedded variable x = f"There are {types_of_people} types of people." # more variables and their values binary = "binary" do_not = "don't" # y is another sting with embedded variables y = f"Those who know {binary} and those who {do_not...
true
204113bb64e0651f3d3d725f85c6b500cfd8b4d8
YashikaNavin/Numpy
/2.NumpyArray.py
855
4.4375
4
import numpy as np # Creating numpy array # 1st way:- create a list and then provide that list as argument in array() mylist=[1,2,3,4,5] a=np.array(mylist) print(a) # 2nd way:- directly pass the list as an argument within the array() b=np.array([6.5,7.2,8.6,9,10]) print(b) # Creating one more numpy array ...
true
6bfdecf7ceb2e8cb56bfe700e9fc297d4e0db764
smitacloud/Python3Demos
/02AD/01Collections_container/enum_demo.py
1,377
4.28125
4
''' Another useful collection is the enum object. It is available in the enum module, in Python 3.4 and up (also available as a backport in PyPI named enum34.) Enums (enumerated type) are basically a way to organize various things. Let’s consider the User namedtuple. It had a type field. The problem is, the typ...
true
244e325d5a0e7a09b4803dad17bb82ccf4de5a3e
smitacloud/Python3Demos
/02AD/03Sequence_Operation/generator_object.py
610
4.53125
5
#Generator-Object : Generator functions return a generator object. Generator objects are used either by calling the next method on the generator object or using the generator object in a “for in” loop (as shown in the above program). # A Python program to demonstrate use of # generator object with next() # A ge...
true
6f301ecfb26f2282a3af41eecbeb60d0ddfc18de
smitacloud/Python3Demos
/loopsAndConditions/Armstrong.py
752
4.53125
5
''' A positive integer is called an Armstrong number of order n if abcd... = an + bn + cn + dn + ... In case of an Armstrong number of 3 digits, the sum of cubes of each digits is equal to the number itself. For example: 153 = 1*1*1 + 5*5*5 + 3*3*3 // 153 is an Armstrong number. ''' # Python program to c...
true
042f57686f14c99820de9f91218d3a7ff4b994e5
katel85/Labs-pands
/labsweek07/quizB.py
726
4.28125
4
# the with statement will automatically close the file # when it is finished with it with open("test-b.txt", "w") as f: data = f.write("test b\n") # returns the number of chars written print (data) #with open("test-b.txt", "w") as f2: # open file again # data = f2.write("another line\n") # print (data) ...
true
261280bfba8cf9a15f3168a46132b3fc46068910
katel85/Labs-pands
/labsweek06/week06-functions/Menudisplay.py
716
4.28125
4
# Write a program that will keep displaying menu until the user chooses to quit. Call a function for A called do add() # call a function for V if the user chooses to view called do view(). # Catherine Leddy def displaymenu () : print("what would you like to do?") print("\t(a) Add a new student") print("\t(v) Vi...
true
53d6088de5a24a7a52af91768dc30bf34a58ce5e
katel85/Labs-pands
/labsweek02/Lab2.2/hello2.py
787
4.25
4
# ask for name and set up for reading out name in response to prompt # Kate Leddy name= input('What is your name') print ('Hello ' + name) #first pose the question this is the input # In order to save the answer to the question it must be saved as "name " = input age= int(input('Hey what is your age?:')) newNumber...
true
b4d45800e40d2fc5e1c661aacb32960a63ded9a4
shayroy/ChamplainVR
/Week 7/Class1/Class_review.py
902
4.3125
4
class Shape: colour = "" # colour is an attribute of Shape # Constructor def __init__(self, input_colour): # variable colour that we input # how do we set the colour to the input_colour. We have to use Self.colour = input_colour self.colour = input_colour # if we want shape to do so...
true
faad8b7f53bde558d0c5f720dc7d5a2cc41b3cad
shayroy/ChamplainVR
/Assignments/Order_System_Team/Input_From_User.py
2,290
4.125
4
from Item import Item from Order import Order answer_string = "" users_new_order = Order() while answer_string != "FIN": answer_string = input("\nWhat do you want to do next?"+ "\n\tTo add a new item to your order type 'ADD'"+ "\n\tTo delete any item from your or...
true
380772852b0996806e2594b22a2af4e08efdc47a
shayroy/ChamplainVR
/Week 10/Class1/TestDir.py
484
4.28125
4
import os dirname = "TestDir" def create_dir_if_not_existing(name): """Checks the existance of a directory and creates it if necessary.""" if not os.path.isdir(name): # if not statement is negation of if statement. # can also use and add another part, such as another if not os.mkdir(name) ...
true
95e1950dc090d4fa0d7caa575ea2fcad4115d91b
shayroy/ChamplainVR
/Week 3/Class 1/review strings.py
451
4.34375
4
#Uppercase, Titlecase, lowercase, length and replacement are important. #for length "The Length of the string is x". #for replacement, he would like us to change all "!" to ".". myString = input(">") print(myString.upper()) print(myString.title()) print(myString.lower()) print(">the length of the entered string is " + ...
true
56ba88a7773b328e42b979090c850a25865a4db9
shayroy/ChamplainVR
/Week 5/Class1/iterate_over_list.py
602
4.375
4
# see printing all keys and values slide #for x in countries: # print(x) # # to print keys, values and items (which prints both keys and values): countries = {'us': 'USA', 'fr': 'France', 'uk': 'United Kingdom'} for k, v in countries: print(k,v) print ("------------") for i in count...
true
69e99ef3541c8affa35caba01b26ff8454bbb1fb
saikumargu/EDA
/Functions.py
1,234
4.3125
4
#Functions def square(num): out = num**2 return(out) square square(7) square(9) q = square(4) print("Square of number is "+str(q)) def factorial(n): if n>1: return n*factorial(n-1) else: return n fact = factorial(5) print(fact) def factorial(n): if n>1: ...
true
d1ce9a494bac48ded881380bfaf3ba9479f27298
deeprane1/Basics
/setexer.py
889
4.5625
5
#Sets - Exercise #1. Check if ‘Eric’ and ‘John’ exist in friends #2. combine or add the two sets #3. Find names that are in both sets #4. find names that are only in friends #5. Show only the names who only appear in one of the lists #6. Create a new cars-list without duplicates friends = {'John','Michael',...
true
7c0b21f3e2d15be9b90b025696abb5379ee11627
thulethi/grokking-algorithms
/python/selection_sort.py
445
4.25
4
# Sort an array from smallest to largest def find_smallest(arr): smallest = arr[0] smallest_index = 0 for i in range(1, len(arr)): if arr[i] < smallest: smallest = arr[i] smallest_index = i return smallest_index def selection_sort(arr): new_arr = [] for i in range(len(arr)): smallest_...
true
ad520839492f31eaf65efc14bbcb2b36c219bf02
reazwrahman/DataStructureAndAlgorithmProblems
/search and sort algorithms/selection_sort.py
1,065
4.1875
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Wed Apr 1 17:04:56 2020 @author: Reaz selection sort algorithm Documentation: We start by assuming that the first element is the smallest one. Then we look for something smaller in the list. If we find a smaller number we swap it with our assumed val...
true
0591afafec2c5e60f43e9972ecedca6a0ba5f4c2
Hieumoon/C4E_Homework
/Session05/Homework/Homework5_exercise3.py
319
4.375
4
# Write a Python function that draws a square, named draw_square, takes 2 arguments: length and color, where length is the length of its side and color is the color of its bound (line color) import turtle def draw_square(length,colorr): color(colorr) for i in range(4): forward(length) left(90)
true
05ea50b9397485c4184faa0d2deda49a799eff84
gagemm1/Machine-Learning-Experimentation
/Regression/Simple Linear Regression/your work.py
2,197
4.375
4
""" simple linear regression: y = b(0) + b(1)*x(1) just like the equation for a slope y = mx + b just keep in mind which is the dependent/independent variables """ #first we'll pre-process the data just like we did before # Importing the libraries import numpy as np import matplotlib.pyplot as plt import...
true
35d749186a281eb328afd537249683d56b2be334
SummerGautier/sorting-algorithms
/bubblesort.py
1,908
4.21875
4
#Description: Recursive and Iterative Bubble Sort Implementations #Author: Summer Gautier #Date: May 10th 2020 import unittest #Recursive def recursiveSort(listOfItems:list, size: int)-> list: if(size == 1): return listOfItems #do a single pass of the bubble sort algorithm for index,item in enumer...
true
7a71d9c7da2476f52ca1f6070bbfb5449945ba1e
JOYFLOWERS/joyflowers.github.io
/github unit 1/Mod 5/sierra_python_module04-master orig/1_function_basics.py
1,655
4.4375
4
# Function Basics # function # A function is a named series of statements. # function definition # A function definition consists of the new function's name and a block of statements. # function call # A function call is an invocation of the function's name, causing the function's statements to exec...
true
1f61dc59136c46a693da96873504486e6a95b767
JOYFLOWERS/joyflowers.github.io
/github_unit_1/Mod_4/collz.py
797
4.5625
5
# Joy Flowers # 09/24/19 # This program shows the Collatz sequence. If the number is even, # divide it by 2 (no remainder) and if it is odd, multiply by 3 and add 1. # Also, make sure that only an integer is entered. while True: try: number = int(input('Enter number: ')) break except ValueError...
true
3ff95f1a91d0cc957e4f43c1eadee7552b12bf5d
sruthinamburi/K2-Foundations
/selectionsort.py
417
4.21875
4
#sorts a list in ascending order using selection sort strategy list = [6,2,1,4,6,0] length = len(list) def selectionsort(list): for i in range (0, length-1): minval = i for j in range(i+1, length): if list[j] < list[minval]: minval = j if minval!=...
true
e7a553e8a77ddb5963c6d7e71fdaf4c7f82b42af
zhanggiene/LeetCode
/88.py
843
4.21875
4
#merge sorted array ''' the trick is to sort from behind. [1,2,3,0,0,0] sort from behind so that there will always be spaces [3,4,5] ''' class Solution: def merge(self, nums1: List[int], m: int, nums2: List[int], n: int) -> None: """ Do not return anything, modify nums1 in-place instead. ...
true
e54852934ecb9d757819bbdf4fd8f46d92d36426
maydhak/project-euler
/028.py
1,258
4.25
4
""" Starting with the number 1 and moving to the right in a clockwise direction a 5 by 5 spiral is formed as follows: 21 22 23 24 25 20 7 8 9 10 19 6 1 2 11 18 5 4 3 12 17 16 15 14 13 It can be verified that the sum of the numbers on the diagonals is 101. What is the sum of the numbers on the diagonals in a...
true
01257b2968f85147cc8809e6a1fd387340bd42a8
maydhak/project-euler
/009.py
1,007
4.1875
4
""" Problem 9: A Pythagorean triplet is a set of three natural numbers, a < b < c, for which, a^2 + b^2 = c^2 For example, 3^2 + 4^2 = 9 + 16 = 25 = 5^2. There exists exactly one Pythagorean triplet for which a + b + c = 1000. Find the product abc. """ """ Before writing the solution, here is what I came up with: ...
true
8eccdb60130b928fc5639bb141425c10c6da70f9
maydhak/project-euler
/019.py
2,022
4.21875
4
""" You are given the following information, but you may prefer to do some research for yourself. - 1 Jan 1900 was a Monday. - Thirty days has September, April, June and November. All the rest have thirty-one, Saving February alone, Which has twenty-eight, rain or shine. And on leap years, twenty-nine. - A leap year o...
true
fc1bdcfb3d3a14ba0c31a005ef9cc5870cbd6e7c
jhoncbox/PythonPractice
/Bootcamp/Regular Expressions -re/regularExpressions.py
2,863
4.375
4
import re # example with searching patterns using re.search() patterns = ['term1','term2'] text = 'this is a string with term1, and term1, but not the other term' for pattern in patterns: print('searching for "%s" in: \n"%s"' % (pattern, text),) # check for match if re.search(pattern, text): prin...
true
1136b377930e250ef2d9e8233e3a71e81130c9a0
nukarajusundeep/myhackerrank
/Forked_Solutions/Indeed_Prime_Codesprint/ultimate_question.py
1,670
4.46875
4
""" 42 is the answer to "The Ultimate Question of Life, The Universe, and Everything". But what The Ultimate Question really is? We may never know! Given three integers, a, b, and c, insert two operators between them so that the following equation is true: a (operator1) b (operator2) c = 42. You may only use the ad...
true
c601f6260a9263573713d4c14c39a535da8f3d52
EasterGeorge/PythonGames
/madlibs.py
698
4.4375
4
"""" The program will first prompt the user for a series of inputs a la Mad Libs. For example, a singular noun, an adjective, etc. Then, once all the information has been inputted, the program will take that data and place them into a premade story template. You’ll need prompts for user input, and to then print out th...
true
6f80000495ab222d1e73fd054f9793862992b09f
khang-le/unit4-05
/U4_05.py
729
4.25
4
#!/usr/bin/env python3 # Created by: Khang Le # Created on: Sep 2019 # This program does some calculation def main(): # comment su = 0 user_input = input("Enter how many time u want to add numbers: ") print("") # process & output try: user_number = int(user_input) for loop...
true
b8bf4db6efd89d3b3e44af0324263683f6094b10
zsannacsengeri/Happines-calculator
/Happiness_calculator.py
2,898
4.125
4
print("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~") print("This program is going to calculate your happiness!") print("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~") print("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~") print("You should go though 7 questions.\nPlease select 1, 2 or 3 for answer...
true
344f6de3fc5a30b875e2c016b8bb4a3680c8367b
hirenpat/Python
/problem_set_1/ps1c.py
1,240
4.1875
4
#ps1c starting_salary = float(input('Enter the starting salary: ')) saving_rate = 0 total_cost = 1000000 semi_annual_raise = 0.07 portion_down_payment = 0.25*total_cost monthly_salary = starting_salary/12 r = 0.04 number_of_months = 0 total_salary = 0 while number_of_months < 36: if number_of_months % 6 == 0: ...
true
16939702bb50a76028cc8a7130d0a27b81fa585a
declanohara123/Weekly-Tasks
/Integer/Interger.py
370
4.375
4
# file where if you input a number, the program halves it if it is even, but tripples itand adds one if the number is odd a = int(input("Please enter a positive integer: ")) b = int (2) print (a , end=' ') while a > 1: if a % b == 0: a /= 2 print (a, end=' ') else: a = (a * 3) + ...
true
272677d325e0890413ce815d4dd57a7330e272ab
bunshue/vcs
/_4.python/test00_syntax3_set.py
2,385
4.21875
4
set1 = {"green", "red", "blue", "red"} # Create a set print(set1) set2 = set([7, 1, 2, 23, 2, 4, 5]) # Create a set from a list print(set2) print("Is red in set1?", "red" in set1) print("length is", len(set2)) # Use function len print("max is", max(set2)) # Use max print("min is", min(set2)) # Use min print("sum is"...
true
87b85139e726c696a6ba31f6f48f45d59cbfd9b1
bunshue/vcs
/_4.python/_example/word_count/CountOccurrenceOfWordsFromFile.py
1,111
4.125
4
print('統計英文單詞出現的次數') # Count each word in the line def processLine(line, wordCounts): line = replacePunctuations(line) # Replace punctuations with space words = line.split() # Get words from each line for word in words: if word in wordCounts: wordCounts[word] += 1 else: ...
true
7c8398aea4cbb08cea8b4dab14015a529b502fca
bunshue/vcs
/_4.python/__code/tkinter-complete-main/2 layout/2_4_place.py
1,506
4.25
4
import tkinter as tk from tkinter import ttk # window window = tk.Tk() window.title('Place') window.geometry('400x600') def button1_click(): print('你按了Button 1') def button2_click(): print('你按了Button 2') # widgets label1 = ttk.Label(window, text = 'Label 1', background = 'red') label2 = ttk.Label(window, t...
true
83d4e602122ee0e6739c0cf7da40f4be20d9987d
bunshue/vcs
/_4.python/__old/turtle/turtle05.py
1,618
4.1875
4
import turtle def drawShape(sides, length): #畫多邊形 angle = 360.0 / sides for side in range(sides): turtle.forward(length) turtle.right(angle) def moveTurtle(x, y): turtle.penup() turtle.goto(x, y) turtle.pendown() def drawSquare(length): #畫正方形 drawShape(4, length) d...
true
30807fcce80097c000a86deebc2e42d7cd8be82a
ramoso5628/CTI110
/P5T2_ FeetToInches_OctavioRamos.py
550
4.3125
4
# Feet to Inches # 9 July 2019 # CTI-110 P55T2- Feet to Inches # Octavio Ramos # One foot equals 12 inches. # Write a program that will take a number of feet as an arguement and returns the number in inches # The user will be prompted to add the number in feet and the result will display in inches. inches_pe...
true
3603e8d09abd206f6466342826bdf1a9a31505f9
sulaiman666/Learning
/Language/Python/Input_Name.py
304
4.375
4
name = input("Enter your name: ") # If you want to take input from user you can use input function age = int(input("Enter your age: ")) # If you want a specific type of input from user you need to declare input fucntion as an integer print("Your name is:", name) print("Your age is:", age, "years old")
true
bacc9c68453826669e10d5a78270b9067996ccec
BramWarrick/Movie_Database
/media.py
1,284
4.375
4
# Lesson 3.4: Make Classes # Mini-Project: Movies Website # In this file, you will define the class Movie. You could do this # directly in entertainment_center.py but many developers keep their # class definitions separate from the rest of their code. This also # gives you practice importing Python files. import webb...
true
7fcb3486f0cf81f8bd5634494af8c86b3f8eb7f5
Sakshi2000-hash/Python-Dictionary
/UI.py
2,009
4.1875
4
import tkinter from tkinter import * from tkinter import messagebox import json data = json.load(open("data.json")) window = Tk() window.title("Find Your Words Here!") def search(): val = word_value.get() val = val.lower() if val in data: display_text.insert(END,data[val]) ...
true
d2122d9b06ae294a210c17cd9fdb01a924931855
yamendrasinganjude/200244525045_ybs
/day1.1/kidsAgeCheckAllowedOrNot.py
245
4.1875
4
''' its simple kids school eg: if kids between 8 to 12 then they are allowed otherwise not allowed ''' num = int(input("enter ur age:")) if num >= 8 and num <= 12: print("Welcome, U r allowed....") else: print("U r not allowed....")
true
9b231303febda81772454967e97fa2d156d3dd60
yamendrasinganjude/200244525045_ybs
/day8/LambdaSquCube.py
330
4.25
4
''' 5. Write a Python program to square and cube every number in a given list of integers using Lambda. ''' lst = list(map(int, input().split())) print("List :\n", lst) squareList = list(map(lambda x: x*x, lst)) print("Square Of List :\n", squareList) cubeList = list(map(lambda x: x**3, lst)) print("Cube of List :\n",...
true
4487065cbefc89779baad509f1ca5901556b3682
Ripsnorter/edX--6.00.1x-CompSci-2013
/L6_Problem_02.py
605
4.15625
4
''' L6 Problem 2 ------------ Write a procedure called oddTuples, which takes a tuple as input, and returns a new tuple as output, where every other element of the input tuple is copied, starting with the first one. So if test is the tuple ('I', 'am', 'a', 'test', 'tuple'), then evaluating oddTuples on this input wo...
true
e22751d4d5f9f513b0ca93d77c1ca404f6c8447e
DrBuddyO1/UT-MCC-VIRT-DATA-PT-08-2021-U-B
/Module-3_Python_Fundamentals/1/04-Ins_List/Solved/lists.py
606
4.3125
4
# Create a variable and set it as an List myList = ["Jesse","Tarana",5] # Adds an element onto the end of a List myList.append("Matt") # Returns the index of the first object with a matching value # Changes a specified element within an List at the given index myList[0] # Returns the length of the List # Remov...
true
8598d58efd83583615f0a13fd4874c6b2a43010d
Rui-FMF/FP
/Aula04/dates.py
1,923
4.28125
4
# This function checks if year is a leap year. # It is wrong: 1900 was a common year! def isLeapYear(year): return (year%4 == 0 and year%100 != 0 ) or (year%100 == 0 and year%400 == 0) # A table with the days in each month (on a common year). # For example: MONTHDAYS[3] is the number of days in March. MONTHDAYS =...
true
d30e421050f8d9b28da2626d1eb51929d0baca53
jayala-29/python-challenges
/advCalc2.py
2,832
4.15625
4
# function descriptor: advCalc2() # advanced calculator that supports addition, subtraction, multiplication, and division # note: input from user does NOT use spaces # part 2 of building PEMDAS-based calculator # this represents parsing an expression as an algorithm # for operations in general, we go ...
true
80b5f2c9d94be3af52a17ceab18881721189aa39
clc80/cs-module-project-iterative-sorting
/src/searching/searching.py
1,237
4.34375
4
def linear_search(arr, target): # Your code here for i in range(len(arr)): if target == arr[i]: return i return -1 # not found # Write an iterative implementation of Binary Search def binary_search(arr, target): # Your code here first = 0 last = (len(arr) - 1) found ...
true
527b524f5cc2cea6f5bd02f801e5d22328e9ea48
arpit-omprakash/CipherX
/cipherx/__main__.py
2,922
4.25
4
doc_string = """ Encrypt or Decrypt a provided file. The program takes in one file as an input, encrypts (or decrypts) it and saves the output as another file. ----------------------------------------------- The following cipher options are supported till now: 1 = Caesar Cipher 2 = ROT 13 Cipher ----------------------...
true
0a079e932af4e80b238c922685a6c154b4e7492e
aafreen22/launchpad-assignments
/pgm5.py
418
4.40625
4
# this program asks the user for a string and displays it in reverse order str = input("Enter a string:: ") list = str.split() #converts the string to a list rev = list[::-1] #reverses the list resu = "" for val in rev: resu = resu + " " + val #creates a string from the reverse of the list res = resu[1::] #removes fir...
true
e73be53c5870878ab396263b03b34d3c76d8c556
suku19/python-associate-example
/module/random_module.py
2,196
4.625
5
from random import random, seed ''' The most general function named random() (not to be confused with the module’s name) produces a float number x coming from the range (0.0, 1.0) –in other words: (0.0 <= x < 1.0). ''' print("random():::") for i in range(5): print(random()) ''' Pseudo-random number ge...
true
b64199ff0017c04675488835f4b3a7d512d1faad
suku19/python-associate-example
/functions/function_intro.py
660
4.25
4
# Write Fibonacci series up to n def fib(n): """Print a Fibonacci series up ro n.""" a, b = 0, 1 while a < n: print(a, end=' ') a, b = b, a + b print() # Now call the function we just defined: fib(2000) def fib2(n): # return Fibonacci series up to n """Return...
true
ca608aab3d7a8fc4161c7254b51356a83a3d1552
lei-hsia/LeetCode
/341.FlattenNestedList_iterator.py
1,426
4.125
4
''' This is the interface that allows for creating nestedIterator you should not implement it, or speculate about its implementation ''' class NestedIngeter(object): def isInteger(self): ''' @return True if this NestedIngeter holds a single integer, rathen than a nested list. :rtype ...
true
0294a624b7a356f40544aafdfce80e1300b1876e
asheemchhetri/pythonClass
/Section 1/zip.py
875
4.71875
5
# >>> Zip: We use zip to combine multiple iterables into a single iterator, which is very helpful when we iterate through in a loop by expansion. # Returns a list of tuple # Note: Iterators can only be use ONCE, to save memory by only generating the iterators as we need them, rahter storing them in memory country = ['I...
true
f420a0c862dc51af92029904ff52f55734c9a439
Chupalika/Kaleo
/tools/integersearch.py
1,350
4.21875
4
#!/usr/bin/python #This tool searches for an integer value in a binary file by converting both to binary and comparing substrings of the binary file to the target binary #Argument 1: binary file name #Argument 2: target integer value from __future__ import division import sys #Converting a byte to binary apparently...
true
7c98cf3aeb49691a438392fe1f24da5bb23846f3
satishhirugadge/BOOTCAMP_DAY11-12
/Task1_Question4.py
316
4.34375
4
# 4. Write a program to print the value given # by the user by using both Python 2.x and Python 3.x Version. user1=input("Hey, What is your name???") print(user1) age1=int(input("What is your age???")) print(age1) # way to run on the python 2. # user2=raw_input("Hey, What is your name???") # print(user1)
true
f75d793ce584968faf5e83be54ef74398a557516
IvanovskyOrtega/project-euler-solutions
/solutions/004_largest_palindrome_product.py
1,414
4.34375
4
"""Solution to Project Euler Problem 4.""" def is_palindrome(n: int) -> bool: """is_palindrome. This function determines if a given integer number is a palindrome or not. Arguments --------- n : int The number to check if is palindrome. Returns ------- bool : `True` if i...
true
54cbc490ae7023113e2692f86ba55c45e15f7fc6
Mahendra522/4Fire
/python/printInReverse.py
367
4.5
4
# Python program to print elements in the Reverse order array = [0]*30 n = 0 n = int(input("Enter number of elements you wanted to insert: ")) print("\n") print("Enter each number one by one: \n") for i in range(n): array[i] = int(input()) print("Printing Elements in the reverse order: \n") for i in reverse...
true
9d59fc835a3bf9bdb7c16f90e953a3e75974734d
Cjeb24/CreditCardCheck
/creditcardcheck.py
1,741
4.15625
4
#credit card validation program number = [] creditCard=str(input("please enter your credit card number(13-16 digits):")) number.append(creditCard) sumEven = 0 sumodd = 0 # Return True if the card number is valid def isValid(number): sumOfDoubleEvenPlace(number) sumOfOddPlace(number) prefixMatched(...
true
fea36651929c097b6376e4476b499d1f430ca623
RebeccaML/Practice
/Python/Games/rockPaperScissors.py
1,041
4.34375
4
# Project from https://www.udemy.com/the-modern-python3-bootcamp/ # Two player version print("Let's play 'Rock, Paper, Scissors!'") player1_choice = input("Enter Player 1's choice: ") player2_choice = input("Enter Player 2's choice: ") if player1_choice == player2_choice: print(f"Both players chose {player1_choi...
true
c123931ce12e35f08c0a0de438f63521c407d6f7
RebeccaML/Practice
/Python/Basic/addingReport.py
1,133
4.1875
4
# Create a function to add numbers input by the user. # Accepts one argument which determines whether numbers and total are printed ("A") # or just the total is printed ("T") # Exits the function and displays output once user enters Q to quit # Call twice; once using "A" and once using "T" # This would be better if the...
true
ac18a69c5373de6eb081f5d0090d72a8d1f4fa8d
qanm237/q_assessment
/question2.py
310
4.34375
4
def lastele(n): return n[-1] #find the last element def sort (tuples): return sorted(tuples, key=lastele)#sort with key stated as based on last element lt=input("enter the list of tuple: ") #input of tuples in a list print("the sorted list of tuple is :") #output print(sort(lt))
true