blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
b8bd7096aa800ba40dfd70bdcb94e63c47b78043
niranjan2822/Interview1
/program to print odd numbers in a List.py
1,328
4.53125
5
# program to print odd numbers in a List ''' Example: Input: list1 = [2, 7, 5, 64, 14] Output: [7, 5] Input: list2 = [12, 14, 95, 3, 73] Output: [95, 3, 73] ''' # Using for loop : Iterate each element in the list using for loop and check if num % 2 != 0. # If the condition satisfies, then only print the number. # ...
true
8a0fcc9d999434e6952ca9bb6c5d2d2f2ca36e6c
niranjan2822/Interview1
/Uncommon elements in Lists of List.py
2,104
4.5
4
# Uncommon elements in Lists of List ''' Input: The original list 1 : [[1, 2], [3, 4], [5, 6]] output : [[3, 4], [5, 7], [1, 2]] # The uncommon of two lists is : [[5, 6], [5, 7]] ''' # Method 1 : Naive Method # This is the simplest method to achieve this task and uses the brute force approach of executing a loop a...
true
6fc03e029814d1e7f48e0c65921d19a276c15b06
CHilke1/Tasks-11-3-2015
/Fibonacci2.py
586
4.125
4
class Fibonacci(object): def __init__(self, start, max): self.start = start self.max = max def fibonacci(self, max): if max == 0 or max == 1: return max else: return self.fibonacci(max - 1) + self.fibonacci(max - 2) def printfib(self, start, max): for i in range(start, max): print("Fibonac...
true
e0ec66c76e6f734caf5262867aac6245414ba8e9
bvo773/PythonFun
/tutorialspy/basic/listPy.py
557
4.40625
4
# (Datatype) List - A container that stores ordered sequence of objects(values). Can be modified. # listName = [object1, object2, object3] def printFruits(fruits): for fruit in fruits: print(fruit) print("\n") fruits = ["Apple", "Orange", "Strawberry"] fruits[0] #Accessing a list fruits[1] = "Mango"...
true
575a0095523dd275b7e6a5f89266f4feae0afdbb
UCD-pbio-rclub/Pithon_JohnD
/July_18_2018/Problem_1.py
803
4.125
4
# Problem 1 # Write a function that reports the number of sequences in a fasta file import string import re import glob def fastaCount(): files = glob.glob('*') filename = input('Enter the name of the fasta file if unsure, enter ls for \ current directory listings: ') if filename == 'ls': for i in...
true
402fbd754c53584ec8400f07a3c697f5c07e1b94
Atul-Bhatt/Advanced-Python
/itertools.py
1,304
4.28125
4
# advanced iterator functions in ther itertools package import itertools def testFunction(x): if x > 40: return False return True def main(): # TODO: cycle iterator can be used to cycle over a collection names = ["John", "Casey", "Nile"] cycle_names = itertools.cycle(names) print(nex...
true
0a2ec74b681d34d78fff26dad5ee7599e538e590
weida8/Practice
/TreeConvert.py
2,460
4.15625
4
# File: TreeConvert.py # Description: HW 9 # Student's Name: Wei-Da Pan # Student's UT EID: wp3479 # Course Name: CS 313E # Unique Number: 50595 # # Date Created: 11/19/15 # Date Last Modified: 11/20/15 #class that create a binary tree class BinaryTree(object): def __init__(self, initVal): ...
true
55e3fdb3e74b84f64e6bfc288f4a68b43001a38b
CharlieRider/project_euler
/problem4/problem4.py
960
4.40625
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 is_numeric_palindrome(n): str_n = str(n) if len(str(n)) % 2 == 0: first_split_reve...
true
e3b2ea406823f0843bf6abb13b4acc0f8f07843a
sabinzero/various-py
/operations/main.py
254
4.1875
4
a=input("enter first number: ") b=input("enter second number: ") c=input("enter third number: ") S=a+b+c print "sum of the numbers = %d" % S P=a*b*c print "product of the numbers = %d" % P A=(a+b+c)/3 print "average of the numbers = %f" % A
true
a090f50bee3b3f2a57726d560582ae0e97524071
sabinzero/various-py
/prime number/main.py
210
4.15625
4
from math import sqrt num = input("enter number: ") x = int(sqrt(num)) for i in range(2, x + 1): if num % i == 0: print "number is not prime" exit(0) print "number is prime"
true
1d4dbbd05c87e7e6c175bf0c3950f6f9d444f3ed
KKrishnendu1998/NUMERICAL_METHODS_ASSIGNEMENT
/fibonacci_module.py
566
4.28125
4
'''it is a module to print first n fibonacci numbers creator : Krishnendu Maji ''' def fibonacci(n): # defining the function to print 1st n fibonacci numbers# a = 0 #the value of 1st number# b = 1 #the value of second number# i = 0 print('first '+str(n)+' ...
true
170f02f6857b192722fb5a7aa1682ca982ff0444
neelesh98965/code-freak
/python/Red Devil/FizzBuzz.py
538
4.3125
4
""" Write a function called fizz_buzz that takes a number. 1. If the number is divisible by 3, it should return “Fizz”. 2. If it is divisible by 5, it should return “Buzz”. 3. If it is divisible by both 3 and 5, it should return “FizzBuzz”. 4. Otherwise, it should return the same number. """ def fizz_buzz(n):...
true
9705a09929ca2aeb3b1547f5560b7f8bb8e3aa13
NeilNjae/szyfrow
/szyfrow/support/text_prettify.py
2,075
4.3125
4
"""Various functions for prettifying text, useful when cipher routines generate strings of letters without spaces. """ import string from szyfrow.support.segment import segment from szyfrow.support.utilities import cat, lcat, sanitise def prettify(text, width=100): """Segment a text into words, then pack into li...
true
d9ef06541e511a83aefdc6cb947720a5414079d1
keitho18/tkinter_freecodecamp_course
/tkinter_tutorials/grid.py
437
4.125
4
from tkinter import * root = Tk() #Creating a label widget myLabel1 = Label(root, text="Hello World") myLabel2 = Label(root, text="My name is Keith") #Putting the widgets into the GUI using the grid coordinates #If there are empty grid cells, then the GUI will skip them when the GUI is displayed myLabel1.g...
true
454b50d9a8b007d16f4f52d8f7d446e450a71275
hubbm-bbm101/lab5-exercise-solution-b2210356106
/Exercise3.py
440
4.21875
4
import random number = random.randint(0, 20) guess = 0 print("A random number is generated between 0 and 20. Please type your guess.") while guess != number: guess = int(input("Your guess = ")) if guess < number: print("Please increase your guess and try again.") elif guess > number: ...
true
5380f0cbaeddd4b3e88654b829628255db3c1109
Cayce2514/Python
/collatz.py
812
4.21875
4
def getNumber(): global number while number == 0: try: number = int(input("Please enter a number: ")) except ValueError: print("That doesn't seem to be a number, please enter a number") return number def collatz(number): if (number % 2 == 1): print('You picked an ...
true
8271197763e942373597f67a4cf3ab3131e01085
boini-ramesh408/week1_fellowship_peograms
/algoriths/BubbleSort.py
402
4.1875
4
from com.bridgelabz.python.utility.pythonUtil import bubble_sort list=[]#to take run time values in sorting first take one emply list and add the elements to the empty list try: num=int(input("enter the number")) for i in range(0,num): element = int(input()) list.append(element) bubbl...
true
4d7a37c3c1fa3ab8e02e8c046af3c2b006b66a9f
diparai/IS211_Assignment4
/sort_compare.py
2,389
4.1875
4
import argparse # other imports go here import time import random def get_me_random_list(n): """Generate list of n elements in random order :params: n: Number of elements in the list :returns: A list with n elements in random order """ a_list = list(range(n)) random.shuffle(a_list) ret...
true
eabb73a4092281f19c17ab551327848bcf523dc5
kahei-li/python_revision
/days-calculator/time-till-deadline.py
514
4.15625
4
from datetime import datetime user_input = input("enter your goal with a deadline separated by colon. e.g. goal:dd/mm/yyyy\n") input_list = user_input.split(":") goal = input_list[0] deadline = input_list[1] print(input_list) deadline_date = datetime.datetime.strptime(deadline, "%d/%m/%Y") # converting input date in...
true
7908203039fd811602f482efc1a9153a39d855f7
Mjk29/CS_100_H03
/Python Files/9_14_16/MattKehoe_HW01.py
1,026
4.1875
4
flowers= ['rose', 'bougainvillea','yucca', 'marigold', 'daylilly', 'lilly of the valley'] print ('potato' in flowers) thorny = flowers[:3] poisonous = flowers[-1] dangerous = thorny + poisonous print (dangerous) print (poisonous) print ( thorny) print ( flowers) xpoint = [0,10,6,7] ypoint = [0,10,6,8] radiu...
true
8804d6c08269a6939b6739d5bd6821e937735b33
asimonia/datastructures-algorithms
/Recursion/listsum.py
428
4.1875
4
""" A recursive algorithm must have a base case. A recursive algorithm must change its state and move toward the base case. A recursive algorithm must call itself, recursively. """ def listsum(numList): theSum = 0 for i in numList: theSum = theSum + i return theSum def listsum2(numList): """Recurisve version of...
true
8df137c1bf7a5a3cd1c5009006b31f3af7b91fcf
Dinu28/Python3
/Lesson9.py
256
4.125
4
#!/usr/bin/env python #File operations ################################### #Find a word in the file fil=open("test1.txt","r") buff=fil.read() word=raw_input("Enter a word to search:") if(word in buff): print("Yes,Found it!") else: print("Not Found!")
true
fffc9f5427e0bc5d91fa09b44a6c0e13ef77cf0c
somesh-paidlewar/Basic_Python_Program
/make_a_triangle.py
673
4.5
4
#To draw a Triangle with three points as input with mouse from graphics import * win = GraphWin('Make a Triangle',600,600) win.setCoords(0.0,0.0,10.0,10.0) message = Text(Point(5,0.5), 'Click any three points to draw a Triangle') message.draw(win) #Get and draw three vertices of the Triangle p1 = win.getMouse() p1....
true
2a134c9eb2849803e9b6265b619288a47511652f
kanika011/Python-Code-Questions
/IsomorphicStrings.py
1,145
4.125
4
#Isomorphic strings #Given two strings s and t, determine if they are isomorphic. #Two strings are isomorphic if the characters in s can be replaced to get t. #All occurrences of a character must be replaced with another character while preserving the order of characters. No two characters may map to the same charact...
true
b2fce549968e6dfcb39beaf39acbcc7ed0481a90
somenbg/algorithm
/binary_search_recursive.py
920
4.21875
4
def binary_search_recursive(list_to_search: list, start_index: int, end_index: int, element_to_search: int): ''' Usage: list = [1,2,3,4,5,6] binary_search_recursive(list, 0, len(list1)-1, 1) Output: "Element '1' is at index '0'" ''' if start_index <=...
true
39113ba692269c24d4eaf98ee6d54fe100b75365
mworrall1101/code-from-school
/summer16/Week09/string_stuff.py
427
4.15625
4
# string_stuff.py # # # # B. Bird - 06/28/2016 S = ' Pear, Raspberry, Peach ' #The .split() method of a string splits the string #by the provided separator and returns a list #of the resulting tokens. for token in S.split(','): print("Token: '%s'"%token) #The .strip() method of a string removes all lead...
true
4553c0b52c2f8fd2721499a87a8c64872bef1c8d
agustashd/Automate-the-boring-stuff
/ch4/commaCode.py
977
4.1875
4
''' Write a function that takes a list value as an argument and returns a string with all the items separated by a comma and a space, with and inserted before the last item. For example, passing the previous spam list to the function would return 'apples, bananas, tofu, and cats'. But your function should be able to ...
true
1144eb1687350bcfbfa25102e7de4636da85d61d
sahilsoni1/geekindian
/shutil/rotatingfile.py
1,156
4.125
4
import os,shutil import time def make_version_path(path,version): """ it gives version for log file """ if version == 0: return path else: return path +"."+str(version) def rotate(path,version): """ The rotate function uses a technique common in recursive functions """ old_path =make_version_path(pat...
true
ce54ffffe84ab5c19a06282eda2c062c0586b4d3
LukeBriggsDev/GCSE-Code-Tasks
/p02.1/even_squares.py
584
4.1875
4
""" Problem: The function even_squares takes in a number. If the number is: * even - print out the number squared * odd - print out the number Tests: >>> even_squares(20) 400 >>> even_squares(9) 9 >>> even_squares(8) 64 >>> even_squares(73) 73 """ # This code tests your solutio...
true
42078806e06e85ff312f658f360bee67090a6494
LukeBriggsDev/GCSE-Code-Tasks
/p02.2/palindrome.py
1,177
4.6875
5
""" Problem: A palindrome is a word that is spelt the same forwards as it is backwards, such as "racecar" or "mum". The function 'is_palindrome' should test whether a word is a palindrome or not and print either "Palindrome" or "Non-palindrome" The function should be case-insensitive, so "Ra...
true
639636ad47e0e10703c90b1e623421743a3ba33c
LukeBriggsDev/GCSE-Code-Tasks
/p03.1a/more_nines.py
613
4.15625
4
""" Problem: The function print_nines takes an input, n, and should then print the first n terms in the 9 times table, exactly as in the nines problem. Test: >>> print_nines(2) 1 x 9 = 9 2 x 9 = 18 >>> print_nines(7) 1 x 9 = 9 2 x 9 = 18 3 x 9 = 27 4 x 9 = 36 5 x 9 = 4...
true
9f2d951b4fbb73d2239d1117f33a336b71fffc76
LukeBriggsDev/GCSE-Code-Tasks
/p02.4/most_frequent.py
905
4.3125
4
""" Problem: Given a list of integers, nums, and two integers, a and b, we would like to find out which one occurs most frequently in our list. If either a or b appears more often, print that number. If neither appears at all, print "Neither". If they appear the same number of times, print "Ti...
true
15af75b362e2f496104423ac33660cc60e009582
LukeBriggsDev/GCSE-Code-Tasks
/p03.1x/triangles.py
599
4.15625
4
""" Problem: The triangle numbers are: 1, 3, 6, 10, 15, 21, 28, ... They are generated by starting at 0 and going up by 1, then adding one more to the difference each time. The function triangle_numbers takes an integer n, and should then print the nth triangle number. Tests: >>> trian...
true
f357f7ba592e69d95b90dac903f458d673707915
Nhlaka10/Finance-calculators
/finance_calculators.py
2,440
4.25
4
# Use import math to use math functions import math # Display the statement below so the user can know their options print( """Please choose either \'Investment\' or \'Boond\' from the menu below to proceed:\n\nInvestment - to calculate the amount of interest you will earn on intrest.\nBond ...
true
544922a19e4b926da2a05630f73d9362ec470a3c
ionuttdt/ASC
/lab1/task2.py
942
4.1875
4
""" Basic thread handling exercise: Use the Thread class to create and run more than 10 threads which print their name and a random number they receive as argument. The number of threads must be received from the command line. e.g. Hello, I'm Thread-96 and I received the number 42 """ from random im...
true
a6f759f475a64cf716cad64148a52785e5903344
mdemiral19/Python-By-Example
/Challenge 043.py
771
4.5
4
'''Challenge 043: Ask which direction the user wants to count (up or down). If they select up, then ask them for the top number nd then count from 1 to that number. If they select down, ask them to enter a number below 20 and then count down from 20 to that number. If they entered something other than up or down, displ...
true
5b011da48b6b1b24690a9a3f5afd7dc59b4b54ff
mdemiral19/Python-By-Example
/Challenge 034.py
975
4.3125
4
'''Challenge 034: Display the following message: " 1) Square 2) Triangle Enter a number: " If the user enters 1, then it should ask them for the length of one of ts sides and display the area. If they select 2, it should ask for the base andheight of the trianlge and display the area. If they type in anything else, ...
true
c084467ce703925b8d6f6ba47507bc60170bd0b0
mdemiral19/Python-By-Example
/Challenge 032.py
443
4.28125
4
'''Challenge 032: Ask for the radius and the depth of a cylinder and work out the total volume (circle area*depth) rounded to three decimal places.''' import math radius = float(input('Please enter the radius of a cylinder, preferably in cm: ')) depth = float(input('Please enter the depth of a cylinder, preferably in ...
true
43782231cb4e7c72c50cade19c0a019443e6b0c2
mulualem04/ISD-practical-7
/ISD practical7Q5.py
334
4.25
4
def count_spaces(userinput): # function definition spaces = 0 for char in userinput : if char == " " : spaces = spaces + 1 # increment return spaces # the function returns the space between words userinput = input("Enter a string: ") print(count_spaces(userinput)) # Call the function w...
true
83ec58ac871dd5136c3e2f26b273c38da989da71
cff874460349/tct
/res/gui/moveCircle.py
1,380
4.25
4
# use a Tkinter canvas to draw a circle, move it with the arrow keys try: # Python2 import Tkinter as tk except ImportError: # Python3 import tkinter as tk class MyApp(tk.Tk): def __init__(self): tk.Tk.__init__(self) self.title("move circle with arrow keys") # create a can...
true
176b9967b350927dec77cbce6c7cdcbc26cf85e6
monica141/lecture4
/classes2.py
886
4.28125
4
class Flight: #creating a new class with the innit method def __init__(self, origin, destination, duration): self.origin = origin self.destination = destination self.duration = duration #printing the information of the flight #we take self to know the object we are operating wi...
true
992564ad8cbb1880feee3ea651ee605530691294
KyleRichVA/sea-c45-python
/hw/hw13/trigram.py
1,954
4.28125
4
""" Short Program That Generates Over 100 Words Of A Moby Dick Style Story Using Trigrams. """ import random # get the file used to create the trigram file = open("mobydick.txt", "r") # take the text and store in memory line by line lines = [] for line in file: lines.append(file.readline()) file.close() # Used to...
true
1cc335521cf917c62a4d914afe3390215c19acff
RyanAVelasco/Jaoventure.net_Exercises
/Chapter_7.py
2,678
4.34375
4
import random print(""" === 7.1: Exercises with classes === Use the python documentation on classes at https://docs.python.org/3/tutorial/classes.html to solve the following exercises. 1. Implement a class named "Rectangle" to store the coordinates of a rectangle given by (x1, y1) and (x2, y2). 2. Implement the clas...
true
a506b8fc0cc4b443bf6fffaf64de0840b7cc0af0
Yushgoel/Python
/agefinder.py
290
4.125
4
from datetime import datetime now = datetime.now() print now date_of_birth = raw_input("Please enter your date of birth in DD-MM-YYYY.") #date_of_birth = int(date_of_birth) birth_year = date_of_birth.year current_year = now.year age = current_year - birth_year print "age = " + age
true
14d8c42d50341ba093681093f0679d6426cbc8cd
Yushgoel/Python
/ctrsumavg.py
239
4.15625
4
n = raw_input("How many numbers do you want to enter?") n = int(n) count = 0 sums = 0 while count < n: num = raw_input("Please enter a number.") num = int(num) sums = sums + num count = count + 1 avg = sums / n print sums print avg
true
0dc6f4e34e40bdc59ed515a5349ce6a3c558d181
shashankgupta2810/Train-Ticket
/Book_train_ticket.py
1,514
4.125
4
class Train(): # create a class # def init function and pass the variable what you required to book the ticket like train name , soucre ,seats, etc. def __init__(self,train_name,train_no,source,destination,status,seats,seatNo): self.seats=seats self.train_no=train_no self.train_name= ...
true
b99e7805a06f924b0edbce4113bc4bcd2b8c4a45
nirajkvinit/python3-study
/dive-into-python3/ch3/setcompr.py
546
4.5625
5
# Set comprehensions a_set = set(range(10)) print(a_set) print({x ** 2 for x in a_set}) print({x for x in a_set if x % 2 == 0}) print({2**x for x in range(10)}) ''' 1. Set comprehensions can take a set as input. This set comprehension calculates the squares of the set of numbers from 0 to 9 . 2. Like list comprehension...
true
65373d7f63b195850dc94333f6520941c9a8bb5e
shay-d16/Python-Projects
/4. Advanced Python Concepts/os_and_open_method.py
1,103
4.125
4
# Make sure to import os so that Python will have the ability to use # and access whatever method we're using import os # Make sure that when you call on a class and you want to access # it's methods within the class, you have mention the class first, # then put a period, then the method. EX: print(os.getcwd()) def...
true
23e1259ea3b50551b6f76dd2ffef23674635780d
shay-d16/Python-Projects
/5. Object-Oriented Programming/parent_class_child_instances.py
2,889
4.5625
5
# Python 3.9.4 # # Author: Shalondra Rossiter # # Purpose: More on 'parent' and 'child' classes # ## PARENT CLASS class Organism: name = "Unknown" species = "Unknown" legs = 0 arms = 0 dna = "Sequence A" origin = "Unknown" carbon_based = True # Now that you've defined this class and set...
true
ef3e2f58e52b8fd1c8855d36ba46a7899121a6aa
shay-d16/Python-Projects
/5. Object-Oriented Programming/polymorphism_submission_assignment.py
1,888
4.34375
4
# Python 3.9.4 # # Author: Shalondra Rossiter # # Purpose: Complete and submit this assignment given to me by the # Tech Academy # # Requirements: Create two classes that inherit from another class # 1. Each child should have at least two of their own attributes # 2. The parent class should have at least one method (f...
true
6119b3691c83d69b0000ea78f73f6ef01aac41e5
rajkumargithub/pythonexercises
/forloop.py
204
4.1875
4
#cheerleading program word = raw_input("who do you go for? ") for letter in word: call = "Gimme a " + letter + "!" print letter + "!" print call print "What does that spell?" print word + "!"
true
a2b2dd7fe076d007f6fac4de31341cc1324b5453
mukasama/portfolio
/Python Codes/lab 10.py
1,659
4.25
4
class Clock(object): def __init__(self,hours=0,minutes=0,seconds=0): h = hours m = minutes s = seconds ''' hours is the number of hours minutes is the number of minutes seconds is the number of seconds ''' self.hours = hours ...
true
9355b32a5516f3857b35be5d74781167bb9e0f3b
bobby-palko/100-days-of-python
/07/main.py
1,568
4.3125
4
from art import logo # Alphabet list to use for our cipher alphabet = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'] # Sweet ASCII art print(logo) is_finished = False def caesar(text, shift, direction): # Cut down large shift ...
true
711991ea38eb5526374a935c5dbc8ed13e54dd64
AyebakuroOruwori/Python-Kids-Projects
/Comparing Dataset Entries-Storing Data in Variables.py
2,145
4.28125
4
#We would be using our knowledge abount booleans and comparison to compare the data of two students from a collection of grade submissions. #We'll kick it off by saving the id, average grade, and recent test score in variables for each of the two student entries. #Let's start saving the data for the first student ent...
true
e9cd0a70a1fd8d694a59377a57f0dab0f9ca53cf
mirzatuzovic/ORS-PA-18-Homework05
/task4.py
666
4.25
4
""" =================== TASK 4 ==================== * Name: Can String Be Float * * Write a script that will take integer number as * user input and return the product of digits. * The script should be able to handle incorrect * input, as well as the negative integer numbers. * * Note: Please describe in details p...
true
fb713e764b44c44aa5d91bd92d99c079ba4de8e2
NBakalov19/SoftUni_Python_Fundamentals
/01.Python_Intro_Functions_And_Debugging/newHome.py
1,233
4.1875
4
import math flowers_type = input() flowers_count = int(input()) budget = int(input()) flowers = { "Roses": 5, "Dahlias": 3.8, "Tulips": 2.8, "Narcissus": 3, "Gladiolus": 2.5 } money_needed = flowers_count * flowers[flowers_type] discount = 0 if flowers_type == 'Roses' and flow...
true
3366b1aa278766d24fd285173d621674bcd78c57
umangbhatia786/PythonPractise
/GeeksForGeeks/Strings/replace_occurences.py
248
4.28125
4
#Python Program to replace all occurrences of string with another def replace_occurrences(input_str, word, replace_with): return input_str.replace(word, replace_with) my_str = 'geeksforgeeks' print(replace_occurrences(my_str,'geeks','abcd'))
true
39bfcad28fc2da53c90e9b3ae748400ce0d4c526
umangbhatia786/PythonPractise
/GeeksForGeeks/Strings/get_uncommon_words.py
486
4.46875
4
#Python Code get list of uncommon words from 2 different strings def get_uncommon_words(input_str1, input_str2): '''Function that uses List Comprehension to get uncommon words out of two strings''' word_list_1 = input_str1.split(' ') word_list_2 = input_str2.split(' ') return [word for word in word_li...
true
977be7873ecfb430347dd0502e047f728b692e8c
umangbhatia786/PythonPractise
/GeeksForGeeks/List/second_largest.py
250
4.125
4
#Python Program to find 2nd Largest num input_list = [1,5,3,6,8,7,10] def get_second_largest(int_list): sorted_list = sorted(int_list) return sorted_list[-2] print(f'Second largest number in given list is {get_second_largest(input_list)}')
true
e7e09e72227e2aa8b496af46e1e02440c0cc8eed
umangbhatia786/PythonPractise
/General/FormatString.py
224
4.3125
4
#Method from python 2 --> 3.5 str1 = 'My name is {} and age is {}'.format('Umang', 26) print(str1) #Method from python 3.5+ # f strings name = 'Cheems' age = 26 str2 = f'My name is {name} and age is {age}' print(str2)
true
8038c7618f323f8a5dd8f47e0228e4eabea1dd20
xettrisomeman/pythonsurvival
/generatorspy/theproblem.py
1,346
4.6875
5
#lets focus on generators #generator is special functions which yields one value at a time #generator gives iterator #we need syntax that generates one item at a time , then #"yiels" a value , and waits to be called again, saving #state information #this is called generators a special case of iterator, #We need a wa...
true
d72c60c547025346f483a3b17ba2a18c2917aeed
xettrisomeman/pythonsurvival
/listcompre/usingcompre.py
552
4.59375
5
#now using list comprehension #list comprehension is shortcut #it consists of two pats within brackets []. #the first part is the value to be produced ,for example ,i. #second part of list comprehension is the for statement header. # syntax : [value for_statement_header] #example old_list = [1,2,3] #take each eleme...
true
52017324a577c708e9f4398a07225f1bcc558249
xhmmss/python2.7_exercise
/codewars/Highest_and_Lowest.py
898
4.15625
4
# In this little assignment you are given a string of space separated numbers, and have to return the highest and lowest number. # Example: # high_and_low("1 2 3 4 5") # return "5 1" # high_and_low("1 2 -3 4 5") # return "5 -3" # high_and_low("1 9 3 4 -5") # return "9 -5" # Notes: # All numbers are valid Int32, no ...
true
0755152309220626c10382ed0db8b8441e025135
xhmmss/python2.7_exercise
/codewars/Bit_Counting.py
410
4.15625
4
# Write a function that takes an integer as input, and returns the number of bits that are equal to one in the binary representation of that number. You can guarantee that input is non-negative. # Example: The binary representation of 1234 is 10011010010, so the function should return 5 in this case def countBits(n):...
true
44306f1c153fc23eae0df5070e49b8e704a1191f
deenababu92/-Python-Basics-Conditional-Loops
/assigntment 1 Python Basics, Conditional Loops.py
999
4.1875
4
#!/usr/bin/env python # coding: utf-8 # In[1]: """1.Write a program which will find all such numbers which are divisible by 7 but are not a multiple of 5, between 2000 and 3200 (both included). The numbers obtained should be printed in a comma-separated sequence on a single line.""" n=[] for i in range(2000,3201): ...
true
3c0578cca5584c4cbc44002976132d01fc3b14e7
sharifh530/Learn-Python
/Beginner/Data types/12.list_slicing.py
357
4.40625
4
# List slicing is also work as a string slicing li = ["work", 5, "dinner", True] print(li) # Reverse print(li[::-1]) # String is immutable but list is not immutable we can change the values of list li[0] = "sleep" print(li) # Copy list li1 = li[:] li1[1] = "work" print(li) print(li1) # modify list li1 = li ...
true
a890d305695336c1d5d8bd65a8fcd5659dd10d41
nampng/self-study
/python/CTCI/Chapter1/p1-7.py
576
4.3125
4
# 1.7 Rotate Matrix # Given an image represented by an N x N matrix, where each pixel in the image is # represented by an integer, write a method to rotate the image by 90 degrees. # Can you do this in place? # Super uneligant. Must optimize and also find a way to do it in place. def Rotate(image): array = [] ...
true
65c7ab612f9546a57e475e8c93fe9feadf4eb33d
cbohara/python_cookbook
/data_struct_and_algos/counter.py
788
4.375
4
#!/usr/local/bin/python3 from collections import Counter # determine the most frequent occuring item in a sequence words = [ 'look', 'into', 'my', 'eyes', 'look', 'into', 'my', 'eyes', 'the', 'eyes', 'the', 'eyes', 'the', 'eyes', 'not', 'around', 'the', 'eyes', "don't", 'look', 'around', 'the', 'eyes', 'lo...
true
a590ad2c64004662cceed2b509b6b55ce885ddc9
joncurrier/generations
/3-Django/app/recipes/utils.py
2,816
4.21875
4
def format_duration(duration): """ Format a timedelta to be human-readable. Argument Format example < 1 minute "55 seconds" < 5 minutes "3 minutes" OR "3 minutes and 15 seconds" < 1 hour "17 minutes" else "2 hours and 14 minutes" """ if durati...
true
c98a68b64296f59da92b4cf1d1ee7c3700f82318
sadsfae/misc-scripts
/python/hugs.py
1,295
4.25
4
#!/usr/bin/env python # everybody needs hugs, track it using a dictionary # simple exercise to use python dictionary import sys # create blank dictionary of hug logistics huglist = {} # assign people needing hugs as keys huglist['wizard'] = 5 huglist['panda'] = 1 huglist['koala'] = 2 huglist['tiger'] = 0 huglist['mo...
true
8c999f21b38fd1147e85a451ad278e2664a06a3b
midnightkali/w3resource.com-python-exercises
/Excercise Solutions/question-2.py
617
4.40625
4
''' 2. Write a Python program to create a function that takes one argument, and that argument will be multiplied with an unknown given number. Sample Output: Double the number of 15 = 30 Triple the number of 15 = 45 Quadruple the number of 15 = 60 Quintuple the number 15 = 75 ''' def compute(num): return lambda nu...
true
6787185c9fcaeacccc3cac1e620f4d64cfbe6927
wchamber01/Algorithms
/stock_prices/stock_prices.py
970
4.125
4
#!/usr/bin/python import argparse def find_max_profit(prices): #find highest_value in list highest_value = max(prices[1:]) # print(highest_value) #find lowest_value in list that occurs before the highest value for i in prices: temp_arr = prices.index(highest_value) # print(temp_arr) lowes...
true
b2cf3c5d25e600356f1340baf4724f39bef92a8f
365cent/calculate_pi_with_turtle_py
/calculatePi.py
2,845
4.5625
5
""" References: https://stackoverflow.com/questions/37472761/filling-rectangles-with-colors-in-python-using-turtle https://www.blog.pythonlibrary.org/2012/08/06/python-using-turtles-for-drawing/ https://docs.python.org/3/library/turtle.html https://developer.apple.com/design/human-interface-guidelines/ios/visual-design...
true
f9f764c303cca5872cea4f868abcc073a979e9e5
tberhanu/all_trainings
/9_training/transpose*_matrix.py
1,502
4.75
5
""" Given a matrix A, return the transpose of A. The transpose of a matrix is the matrix flipped over it's main diagonal, switching the row and column indices of the matrix. Example 1: Input: [[1,2,3],[4,5,6],[7,8,9]] Output: [[1,4,7],[2,5,8],[3,6,9]] Example 2: Input: [[1,2,3],[4,5,6]] Output: [[1,4],[2,5],[3,6]] ...
true
d1ca4df1ebd74bf0e64444d1ede451425d783520
tberhanu/all_trainings
/9_training/921_add-parenthesis.py
1,607
4.34375
4
""" Given a string S of '(' and ')' parentheses, we add the minimum number of parentheses ( '(' or ')', and in any positions ) so that the resulting parentheses string is valid. Formally, a parentheses string is valid if and only if: It is the empty string, or It can be written as AB (A concatenated with B), where A ...
true
ccef15befdc8373f187d0be2b6fd3e205057e65b
tberhanu/all_trainings
/8_training/monotonic_array.py
1,193
4.1875
4
""" An array is monotonic if it is either monotone increasing or monotone decreasing. An array A is monotone increasing if for all i <= j, A[i] <= A[j]. An array A is monotone decreasing if for all i <= j, A[i] >= A[j]. Return true if and only if the given array A is monotonic. Example 1: Input: [1,2,2,3] Output...
true
98976e9dbd53034092cdad20f46cec9573ed5769
tberhanu/all_trainings
/revision_1_to_7/13_array_flattening.py
352
4.1875
4
""" 13. Given a nested array, return a flattened version of it. Ex. [1, 2, [3, [4, 5], 6]] ---> [1, 2, 3, 4, 5, 6] """ from collections.abc import Iterable def flatten(arr): for a in arr: if isinstance(a, Iterable): yield from flatten(a) else: yield a print(list(f...
true
1531e733cc5859b5be70b6b606c2c75488411c77
tberhanu/all_trainings
/9_training/73_set_matrix_zeroes.py
997
4.28125
4
""" Given a m x n matrix, if an element is 0, set its entire row and column to 0. Do it in-place. Example 1: Input: [ [1,1,1], [1,0,1], [1,1,1] ] Output: [ [1,0,1], [0,0,0], [1,0,1] ] Example 2: Input: [ [0,1,2,0], [3,4,5,2], [1,3,1,5] ] Output: [ [0,0,0,0], [0,4,5,0], [0,3,1,0] ] Follow up: ...
true
7c6c0c78a813ec102b63072b31057cd5e909bbc6
tberhanu/all_trainings
/3_training/qn3_shortest_route.py
1,658
4.1875
4
#!/usr/bin/env python3 import networkx as nx import matplotlib.pyplot as plt def shortest_path(network, name1, name2): """shortest_path(network, name1, name2) --> a function taking a NETWORK and output and array of Strings as a shortest path from name1 to name2 --> Need to install networkx, and inbuilt py...
true
a42a1b8a508f5dad31c13eac7d6f4d605896155e
Marist-CMPT120-FA19/-Kathryn-McCullough--Project-10-
/censor.py
1,494
4.28125
4
#name: Kathryn McCullough #email: kathryn.mccullough1@marist.edu #description: This program references a file with words and a separate #file with a phrase and censors those words from the first into a third file. #goes through characters and replaces all letters with * #plus censores word with comma will still have ...
true
71a4d5d390639160838813bc0ff468853b248ddd
jjmaldonis/Data-Structures-Code
/pythoncrashcourse/intsertion.py
869
4.25
4
#if you import this module you can type help(insertion) and it will give you the help info below """ insertion sort script that demonstrates implementation of insertion sort. """ import random def insertion(l): """ implements insertion sort pass it a list, list will be modified in plase """ pri...
true
8ff7e379b9a79d6c8094165e0ab6a9fb089d753a
jtwray/Intro-Python-I
/src/07_slices.py
1,789
4.625
5
""" Python exposes a terse and intuitive syntax for performing slicing on lists and strings. This makes it easy to reference only a portion of a list or string. This Stack Overflow answer provides a brief but thorough overview: https://stackoverflow.com/a/509295 Use Python's slice syntax to achieve the following: "...
true
7a6b08c52a1f57f07dc3c6be620b3df74620fa64
wsullivan17/Cashier
/Cashier.py
1,678
4.125
4
#Automated cashier program #Willard Sullivan, 2020 #total cost of items total = 0 done = "" from users import users_dict, pwds_dict from items import items_dict, cost_dict print("Welcome to the Automated Cashier Program. ") go = input("Type the Enter key to continue. ") while go != "": go = input("Type the E...
true
1e2b7e6f44c7fba2e1aa916481a50a4dc86e5195
maianhtrnguyen/Assignment-2
/Assignment/PythonLearningProject1-master/helloWorld.py
1,675
4.1875
4
# Install the package Pillow: pip install pillow from PIL import Image # The documentation is here, # https://pillow.readthedocs.io/en/stable/reference/Image.html# # please just look at the Image Module and Image Class section # Read about this module/class and its relevant information, but dont worry about other cl...
true
21939208c9d75a5e10e77f874041e111051d7be2
AtieDag/Project-Euler
/Problem14.py
572
4.125
4
# The following iterative sequence is defined for the set of positive integers: from functools import lru_cache @lru_cache(maxsize=100) def collatz_sequence(n, terms=0): terms += 1 if n == 1: return terms # n is even if n % 2 == 0: return collatz_sequence(n / 2, terms) # n is odd ...
true
e2e3884345256a114aa8fe57fd10fd8ce388e679
RisingLight/Python_Practice
/Challenge questions/TejaSreeChand/wordscramb challenge3 .py
1,349
4.25
4
import random import os def shuf(string): ltemp=string[1:len(string)-1] # taking only the mid part { change it into string[0:len(string)] for a full words shuffle ltemp=list(ltemp) # convert the word into alphabet list eg: "hey" -> ["h","e","y"] random.shuffle(ltemp) # ...
true
b4839a749136a1cace5be79885b0e72098fab39f
vansh1999/Python_core_and_advanced
/functions/decorators.py
2,034
4.59375
5
''' Decorators in Python A decorator is a design pattern in Python that allows a user to add new functionality to an existing object without modifying its structure. Decorators are usually called before the definition of a function you want to decorate. Functions in Python are first class citizens. This means that t...
true
35435a318e2262d5b7fce50deae1fd3fa82aad48
vansh1999/Python_core_and_advanced
/sequencedatatype/tuples/tuple.py
715
4.125
4
# declare a tuple colors = ("r" , "b" , "g") print(colors) # tuple packaging - # Python Tuple packing is the term for packing a sequence of values into a tuple without using parentheses. crl = 1,2,3 print(crl) # tuble unpackaging - a,b,c = crl print(a,b,c) # Crete tuple with single elements tupl1 = ('n') #< --...
true
8b22fc6b4b4f6b3cf28f7c2b3dfc1f03ac301fb4
evroandrew/python_tasks
/task8.py
2,322
4.21875
4
import argparse MSG_INFO = 'To output Fibonacci numbers within the specified range, enter range: ' MSG_ERROR = 'Use any numbers, instead of you entered.' MSG_FIRST_ELEMENT = 'Enter first argument of range: ' MSG_SECOND_ELEMENT = 'Enter second argument of range: ' ERRORS = (argparse.ArgumentError, TypeError, argparse.A...
true
9c9c562ac2a07f66c4d4202ea003f9ed308c0d5a
Praveen-Kumar-Bairagi/Python_Logical_Quetions
/ifelse_python/char.py
413
4.25
4
char=str(input("enter the char")) if char>="a" and char<="z" or char<"A" and char<="Z": print("it is char") number=float(input("enter the number")) if number>=0 and number<=200: print("it is digit") specialchar=input("enter the specialchar") if specialchar!=char and specialchar!=number: ...
true
c0a95dfdf5d086724bbb96875598facac45618fd
eliseoarivera/cs50transfer
/intro-python/day-one/ageCheck.py
485
4.28125
4
age = input("How old are you?") """if age >= "18": print("You're old enough to vote!") else: print("You're not old enough to vote.")""" age = input("How old are you?") # Read this as "Set age equal to whatever string the user types." age = int(age) # We reassign the variable information here. # In essence, "Set...
true
56bd713a364a7abd0657341e45f71b57e2a611ef
eliseoarivera/cs50transfer
/intro-python/day-one/functions.py
1,551
4.4375
4
"""def shout(name): name = name.upper() return "HELLO " + name + "!" print(shout("Britney"))""" """def costForDisney(adults, children, days): adult_cost = adults * 100 print("Calculated adult cost at " + str(adult_cost)) child_cost = children * 90 print("Calculated child cost at " + str(child_cost)) dail...
true
a8803c9a755d33efa0a111eae2b80cc2573803de
tcraven96/Cracking-the-Coding-Interview
/Cracking the Coding Interview/Question1-1.py
798
4.1875
4
# Implement an algorithm to determine if each string has all unique characters. # What if you cannot use additional data structures? import unittest # Goes through string, replaces element found once with "" so that duplicates are not replaced. # Will return if duplicate characters are found in the string. def unique...
true
f5bc910e44639ae828c56017c5f659e8c02c370c
LizaShengelia/100-Days-of-Code--Python
/Day10.Project.py
1,278
4.3125
4
from art import logo #add def add(n1, n2): return n1 + n2 #subtract def subtract(n1, n2): return n1 - n2 #multiply def multiply(n1, n2): return n1 * n2 #divide def divide(n1, n2): return n1 / n2 operations = { "+": add, "-": subtract, "*": multiply, "/": divide } def calculator(): print(log...
true
df6c4c6355a62b8545bb50779b624a3ad6ce8a3c
ermanh/dailycoding
/20200715_inversion_count.py
2,116
4.1875
4
''' 2020-07-15 [from dailycodingproblems.com #44] We can determine how "out of order" an array A is by counting the number of inversions it has. Two elements A[i] and A[j] form an inversion if A[i] > A[j] but i < j. That is, a smaller element appears after a larger element. Given an array, count the number of inver...
true
89a63d37c1520e8a2e2adeb42a92fbf0214cf72a
ermanh/dailycoding
/20200706_balanced_brackets.py
1,509
4.25
4
''' 2020-07-06 [from dailycodingproblem.com #27] Given a string of round, curly, and square open and closing brackets, return whether the brackets are balanced (well-formed). For example, given the string "([])[]({})", you should return true. Given the string "([)]" or "((()", you should return false. ''' def balan...
true
f06e6cb2349160b53b3897dee89b9a8620b47a4a
ermanh/dailycoding
/20200727_line_breaks.py
1,604
4.25
4
''' 2020-07-27 [from dailycodingproblem.com #57] Given a string s and an integer k, break up the string into multiple lines such that each line has a length of k or less. You must break it up so that words don't break across lines. Each line has to have the maximum possible amount of words. If there's no way to bre...
true
d6a249c5f49bae6495eeaaf2fe118286fe9f55e5
cartoonshow57/SmallPythonPrograms
/multiples_of_num.py
386
4.46875
4
"""This program takes a positive integer and returns a list that contains first five multiples of that number""" def list_of_multiples(num1): lst = [] for i in range(1, 6): multiple = num1 * i lst.append(multiple) return lst num = int(input("Enter a positive number: ")) print("The first...
true
de55a87bc414dc26a65f9b12d350550779446579
cartoonshow57/SmallPythonPrograms
/nested_loop.py
252
4.25
4
# A dummy program for how a nested loop works print("Nested loop example") print("-------------------------------") for i in range(1, 4, 1): for j in range(1, 1001, 999): print(format(i * j, "8d"), end="") print() print("EOP") input()
true
5cf128f4cb83571f291b8d6981914cb0106c372a
cartoonshow57/SmallPythonPrograms
/sum_of_array.py
392
4.21875
4
# This program prints the sum of all the elements in an array def sum_of_array(arr1): total = sum(list(arr1)) return total arr = [] n = int(input("Enter the number of elements in the array: ")) for i in range(n): arr.append(int(input("Enter no. in array: "))) print("The given array is,", arr) print("...
true