blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
16cdcaddcaa3162c6c3ec44cbef68371870c1440
jmschp/mosh-complete-python-course
/05 Data Structures/05 Adding or Removing .py
995
4.40625
4
# 05 Adding or Removing Items letters = ["a", "b", "c", "d", "e", "f", "g"] print(letters) # Add an item to the end of the list letters.append("h") print(letters) # Add item at a specific position using the method insert() # first argumet position of the list, second argument iem to add letters.insert(2, "-") print(...
true
599b6271a868d0c764884bc36f8cf907f7680824
jmschp/mosh-complete-python-course
/05 Data Structures/20 Dictionary Comprehensions.py
539
4.46875
4
# 20 Dictionary Comprehensions # Dict comprehensions can be used to create dictionaries from arbitrary key and value expressions # In addition, dict comprehensions can be used to create dictionaries from arbitrary key and value expressions: # {x: x**2 for x in (2, 4, 6)} # {2: 4, 4: 16, 6: 36} # When the keys are sim...
true
5340a74241aa2a6fe8a92acf7566078942d84591
jmschp/mosh-complete-python-course
/05 Data Structures/15 Tuples.py
764
4.375
4
# 15 Tuples # Tuples are basiclly read only lists, can not be change points = (1, 2, 3) # with paretesis it is a Tuple print(type(points)) points_1 = (1, 2, 3, 4, 5) + (6, 7, 8, 9) # Concateante a tuple print(points_1) points_2 = (1, 2, 3, 4, 5) * 3 # multiply a tuple print(points_2) text_tuple = tuple("Hello Worl...
true
0c36b2c32211b4ee440b88544f48764e6222689c
jmschp/mosh-complete-python-course
/06 Exceptions/03 Handling Different Exceptions.py
848
4.25
4
# 03 Handling Different Exceptions try: # try block age = int(input("Age: ")) xfactor = 10 / age # If age is 0 (a numeric value) this line will produce an error "ZeroDivisionError". We cann not divide a number by zero. except (ValueError, ZeroDivisionError): # Better than add the another execption block below ...
true
88971e217952309ef95a9cabb4f2f1de140864e9
pedroceciliocn/python_work
/Chapter_8_Functions/User_album_8_8.py
676
4.1875
4
def make_album(artist_name, title, number_of_songs=None): """Return a dictionary of informations about an album.""" album = {'artist': artist_name, 'title': title} if number_of_songs: album['number_of_songs'] = number_of_songs return album while True: print("\nPlease tell me the album informations:") print("(en...
true
61bb731c7437d09c2686259cce47e3a57a222983
pedroceciliocn/python_work
/Chapter_10_Files_and_Exceptions/10_10/Commom_words.py
580
4.4375
4
def count_common_words(filename): """Count the approximate number of words in a file.""" try: with open(filename, encoding='utf-8') as f: contents = f.read() except FileNotFoundError: print(f"Sorry, the file {filename} does not exist.") else: words = contents#.split() num_comm_words = words.count('the ')...
true
c032f73d9b2fdf6934d73bde381db9b756ed7b00
pedroceciliocn/python_work
/Chapter_7_input_and_while/Movie_tickets_7_5.py
557
4.15625
4
prompt = "\nTell me your age: " prompt += "\nOr type 'quit' to end the program. " active = True while active: message = input(prompt) if message == 'quit': #removing 'quit' from the last message active = False else: message = int(message) if message < 3: print(f"So you have less than 3 years old? Your ti...
true
327ae5989342b6b6d69d764a436fc70cf39a225f
WealthCreating/options-pricing
/src/monte_carlo/parameters.py
2,114
4.375
4
"""Represents parameters used in Monte Carlo calculations.""" from abc import ABC, abstractmethod class Parameters(ABC): """ Base class for all parameters used in Monte Carlo calculations. Each parameter is a function (can be constant) of time. """ @abstractmethod def integral(self, time1, ...
true
62fb4a4ea5c61ed9c76cd8ee4a20be7d42c98bdc
jbcodeforce/python-code
/algorithms/binarySearch.py
898
4.21875
4
""" Binary search works on sorted arrays. Binary search begins by comparing the middle element of the array with the target value. If the target value matches the middle element, its position in the array is returned. If the target value is less than the middle element, the search continues in the lower half of the arr...
true
d002186a126926a785cf383f3074e44f0200c94e
jbcodeforce/python-code
/web_data/parseXml.py
719
4.34375
4
# The program will prompt for a URL, read the XML data from that URL using urllib # and then parse and extract the comment counts from the XML data, compute the sum # of the numbers in the file. import xml.etree.ElementTree as ET import urllib.request url=input("Enter location: <http://python-data.dr-chuck.net/com...
true
5ae39e2fb4d4acd6d411779f67d2ca15a377a234
bhupendpatil/Practice
/Python/CheckiO/Elementary/The end of other.py
1,478
4.625
5
""" For language training our Robots want to learn about suffixes. In this task, you are given a set of words in lower case. Check whether there is a pair of words, such that one word is the end of another (a suffix of another). For example: {"hi", "hello", "lo"} -- "lo" is the end of "hello", so the result is True. ...
true
38c32de5f20b49de1d6031acabf3d4073c7a5b39
bhupendpatil/Practice
/Python/CheckiO/Elementary/Three Words.py
1,410
4.21875
4
""" Let's teach the Robots to distinguish words and numbers. You are given a string with words and numbers separated by whitespaces (one space). The words contains only letters. You should check if the string contains three words in succession. For example, the string "start 5 one two three 7 end" contains three words...
true
76151c75bf3f2cb27ced457a15cc8668cae02cb0
bhupendpatil/Practice
/Python/CheckiO/Elementary/Days Between.py
1,208
4.46875
4
""" How old are you in number of days? It's easy to calculate - just subtract your birthday from today. We could make this a real challenge though and count the difference between any dates. You are given two dates as tuples with three numbers - year, month and day. For example: 19 April 1982 will be (1982, 4, 19). You...
true
c64a42b69605373cc0f96e586bfdb4771d37bf17
bhupendpatil/Practice
/Python/CheckiO/Elementary/Secret Message.py
1,128
4.8125
5
""" You are given a chunk of text. Gather all capital letters in one word in the order that they appear in the text. For example: text = "How are you? Eh, ok. Low or Lower? Ohhh.", if we collect all of the capital letters, we get the message "HELLO". Input: A text as a string (unicode). Output: The secret message as...
true
ed7592c1e0d01ca87f75368cc22050043d5f22c3
manjesh41/project3
/main.py
257
4.375
4
''' 1 Write a Python function to find the Max of three numbers ''' def maximum (a,b,c): if a>b>c: print(f"{a} is the maximum number") elif b>c>a: print(f'{b} is the maxmum number') else: print(f'{c} is the maximum number') return maximum(10,20,40)
true
696c0d40fd40fc94edbbf2fe7088ec7d10d88adf
moabdelmoez/road_to_pythonista
/Tips and Tricks/5- Zip.py
454
4.125
4
names = ['Peter Parker', 'Clark Kent', 'Wade Wilson', 'Bruce Wayne'] heroes = ['Spiderman', 'Superman', 'Deadpool', 'Batman'] ##for index, name in enumerate(names): ## hero = heroes[index] ## print(f'{name} is actually {hero}') #by using zip function ##for name, hero in zip(nam...
true
9169d2e3ec71f7e537240f69fdcdd3459f411eca
yument7/PyLearn
/PycClass/ClassOperateReloadTest.py
841
4.15625
4
# !/usr/bin/python3 # --coding=utf-8-- class Fruit: def __init__(self,price = 0): self.price = price def __add__(self, other): return self.price + other.price def __gt__(self, other): if self.price > other.price: flag = True else: ...
true
c36875b838914db00e8622e17ce763e2d800dbae
madhusudhankonda/python-first-steps
/basics/calculators.py
545
4.25
4
number_1 = 10 number_2 = 20 # sum of two numbers print(number_1 + number_2) sum = number_1 + number_2 # print("The sum of two numbers is: "+sum) # concatenation of strings -> adding them print("The sum of two numbers is: ", sum) # product of two numbers # subtract the two numbers # remainder of the division # % s...
true
f1faf3535795e64295e1ebb63a8dd04ed11f7cac
vijaykumar0210/My_sample_works
/simple pay calculation.py
659
4.25
4
name = input("enter name of the employee: ") #enter details of the employees details hrs = float(input("enter hours ")) #if the hours worked by the employee is more than 40 the rate will increase for remaining hours above 40 rate = float(input("enter rate ")) print("total hours worked by"+name,hrs) print("total r...
true
5d15aa1a160fe1a4f8c37a8cc3af6945884223ee
willtownes/python
/ProjectEuler/0007.py
541
4.21875
4
''' By listing the first six prime numbers: 2, 3, 5, 7, 11, and 13, we can see that the 6th prime is 13. What is the 10 001st prime number? ''' def listprimes(n): '''returns a list of the first n prime numbers''' primes = [2] counter = 3 while len(primes)<n: if True in [counter%k == 0 for k in ...
true
3e627f4241cd3a401a0755699b948ae20bac3ea4
willtownes/python
/ProjectEuler/0025.py
836
4.15625
4
''' What is the first term in the Fibonacci sequence to contain 1000 digits? ''' def fib(): '''returns a generator that yields fibonacci tuples (index,value[-2],value[-1]). index tells how many items into the sequence it has progressed''' f1,f2 = 1,1 while True: yield f1,f2 f1,f2 = f2,(...
true
efdf5065f54dda57bb072637622af9961dea3436
anup-en/Python
/Leap_year.py
222
4.28125
4
print('Program to check wheather the year is Leap year') a=int(input("Enter a year:")) if((a%4==0 and a%100!=0) or (a%400==0)): print('Entered year is a leap year.') else: print('Entered year is NOT a leap year.')
true
caa81549f7433051f10fddc82ca07ce34ce2a9bd
VeraBobrova/PY-111
/Tasks/b1_binary_search.py
665
4.21875
4
from typing import Sequence, Optional def binary_search(elem: int, arr: Sequence) -> Optional[int]: """ Performs binary search of given element inside of array :param elem: element to be found :param arr: array where element is to be found :return: Index of element if it's presented in the arr, N...
true
97bebc10fba912fd1ae0d345df701d10edab618e
Vivi-yd/cs1531-viv-tuts-19T1
/tut05/rectangledemo.py
751
4.21875
4
class Rectangle: # define constructor to initialise attribute def __init__(self, width, length): # specify private attribute self._width = width self._length = length # defining accessor and mutator methods to access and set private fields def get_width(self): return sel...
true
928d05126529fb0c63f3a766e355fb357ddae219
arthurliang/leetcode
/pythonversion/PopulatingNextRightPointersinEachNode/Solution.py
2,358
4.1875
4
# Given a binary tree # # struct TreeLinkNode { # TreeLinkNode *left; # TreeLinkNode *right; # TreeLinkNode *next; # } # Populate each next pointer to point to its next right node. If there is no next right node, # the next pointer should be set to NULL. # # Initially, all next pointers are se...
true
3f272b658eafeac586bd407b16faa7eec636ab7f
arthurliang/leetcode
/pythonversion/BinaryTreePostorderTraversal/Solution.py
1,363
4.125
4
# Given a binary tree, return the postorder traversal of its nodes' values. # # For example: # Given binary tree {1,#,2,3}, # 1 # \ # 2 # / # 3 # return [3,2,1]. # # Note: Recursive solution is trivial, could you do it iteratively? # Definition for a binary tree node # class TreeNode: # def __i...
true
527c1c218d6440778bf0de72d883f6f3d72d695c
uq-courtois/digitalanalytics-snippets
/whileloop.py
1,149
4.21875
4
number = 0 while number < 5: # As long as the value of number is smaller than 5, the loop continues) print(number) # We print the current value of number at the beginning of each loop number = number + 1 # We add one to the current value of number at the end of each loop print("Loop ended. Final value of 'numbe...
true
dae26e1d876eb78effa3916a967c9244b791478c
zabdulmanea/100DaysOfCode
/day22_saudidevorg.py
983
4.65625
5
# Python Dictionaries - Part 1 # Create a Dictionary # 1. create an empty dictionary thisdict = {} print(thisdict) # 2. create a nonempty dictionary thisdict = { "brand": "ford", "model": "Mustang", "year": "1964" } print(thisdict) # Accessing Items # 1. access a value using [] model = thisdict["model"]...
true
fd4d2c5382216e65865b0d2142268c571a6875f5
zabdulmanea/100DaysOfCode
/day65_saudidevorg.py
485
4.15625
4
# Python String Formatting - PART 1 # String format() # Q: Add a placeholder where you want to display the price. price = 50 txt = "The price is {} dollars" print(txt.format(price)) # Q: Format the price to be displayed as a number with two decimals. txt = "The price is {:.2f} dollars" print(txt.format(price)) # Mu...
true
63f4a24a1a7a9523292f3cc99bf875ac4af9cd66
zabdulmanea/100DaysOfCode
/day21_saudidevorg.py
965
4.46875
4
# Python Sets - Part 2 # create a set thisset = {"apple", "banana", "cherry"} print(thisset) # Get the Length of a Set print(len(thisset)) # Remove Item # 1. remove an item from the set, using remove() thisset.remove("banana") print(thisset) # remove an item doesn't exist in the set # thisset.remove("orange") # Key...
true
9f60dc2f83a59e60eb2c2f4ef430951bf286da29
zabdulmanea/100DaysOfCode
/day20_saudidevorg.py
1,167
4.65625
5
# Python Sets # Set {} # 1. create an empty set thisset = {} print("- An empty list:", thisset) print("---------------------------------------------") # 2. create a set # sets contain unordered items fruits_set = {"apple", "banana", "cherry"} print("- Fruits set:", fruits_set) print("---------------------------------...
true
13aef695d44ae6fbce59c5954fc819593b3d5728
xubiaosunny/myCode
/checkio/home/date-and-time-converter.py
2,328
4.5
4
""" Computer date and time format consists only of numbers, for example: 21.05.2018 16:30 Humans prefer to see something like this: 21 May 2018 year, 16 hours 30 minutes Your task is simple - convert the input date and time from computer format into a "human" format. ![](https://d17mnqrx9pmt3e.cloudfront.net/media/mis...
true
49501eb633bb91552ec49dc9588f4c9c6460e7d3
xubiaosunny/myCode
/checkio/electronic-station/words-order.py
2,498
4.15625
4
""" You have a text and a list of words. You need to check if the words in a list appear in the same order as in the given text. Cases you should expect while solving this challenge: a word from the list is not in the text - your function should return False; any word can appear more than once in a text - use only th...
true
1274a2247c08b12cde0c8a0d523a21ce25997512
xubiaosunny/myCode
/checkio/mine/cut-sentence.py
1,836
4.46875
4
""" Your task in this mission is to truncate a sentence to a length, that does not exceed a given number of characters. If the given sentence already is short enough you don't have to do anything to it, but if it needs to be truncated the omission must be indicated by concatenating an ellipsis ("...") to the end of th...
true
e6df10fac18b93bad0021d863badaf46d8f368c2
ThomasMorrissey/Chapter_4
/count(challenge1).py
510
4.125
4
#! bin/usr/python# # Program Name: Count.py # Date Written: 10-21-2014 # Author: Thomas Morrissey print(""" Welcome to Count! Today, You will tell me what number to begin with, to end with and what number to count by(like 2,4,6,8,10, etc.) """) StartNumber=int(input("What number do you wish to beign with? "...
true
0009eac5d59e641b62d2e3fdec2781f69961bdac
tristankingsley/mathprojects
/ProgrammingSet2.py
1,538
4.125
4
# This function takes the range of the list inputted # and assigns it to its own dictionary. It then makes a set of the range # and assigns it to another dictionary. Lastly, it returns a boolean comparing # the dictionaries lengths. If our function is one to one, then both dictionaries # will have the same length. ...
true
76077e578d04b3b4a86a6c63ef5048a71a2825ad
blakexcosta/Unit3_Python_Chapter7
/main.py
2,320
4.40625
4
def main(): print("hello") # Chapter 7 strings # strings are a collection data type in python # furthermore, they are also considered ordered collections # getting length of string text = "How much wood could a woodchuck chuck, if a woodchuck could chuck wood?" print(len(text)) # we can...
true
e412e748f576b63361b31f4c2fd5b511515708c4
jayz25/MiniProjects-And-CP
/CP/Competetive Programming And DSA/DS/detectRemoveLoop.py
1,507
4.21875
4
#Explaination : https://iq.opengenus.org/detect-and-remove-loop-in-linked-list/ #Code source : https://www.codesdope.com/blog/article/detect-and-remove-loop-in-a-linked-list/ class ListNode: def __init__(self, x): self.val = x self.next = None def removeLoop(head: ListNode): # Initialize ptr1 and p...
true
914b9c24b847854a03748c7a883415c276b87da3
akhil-maker/Sorting-Algorithms
/Python/SelectionSort.py
811
4.1875
4
# Python program for implementation of Selection Sort def selectnsort(a): # Traverse through all array elements for i in range(len(a)): # Find the minimum element in remaining # unsorted array min_idx = i for j in range(len(a)): if a[min_idx] < a[j]: ...
true
f8123ee79fa4229039da27139bafa1c58e5d5324
vamsiarisetti/PythonPractice
/Vowels.py
722
4.21875
4
# function will display vowels present in the word def getVowelsFromWord(word:str) -> set: vowels = set('aeiou') return vowels.intersection(set(word)) def search4Letters(phrase:str, letters:str='aeiou') -> set : """ returns set of letters found in phrase """ return set(letters).intersection(set(phras...
true
02a3875f15f0ce2e9d71a8359ef8d32ef29bcd8d
Pythoner-Waqas/Backup
/C vs Python/py prog/6.py
207
4.375
4
#This program calculates the factorial number = int(input("Please enter number to calculate factorial ")) result = 1 while (number>1): result *= number number -= 1 print ("Factorial is ", result)
true
401529b1d774f64034baef3da86887d7d6a99f8c
deargopinath/data-science-python
/assignments/deep-dive/q3.py
325
4.28125
4
# 3. # Weather forecasting organization wants to show is it day or night. # So write a program for such organization to find whether is it dark outside or not. # Hint: Use time module. import datetime HH = datetime.datetime.now().hour if (HH < 6) or (HH > 18): print ("Dark outside") else: print ("Bright outs...
true
ee8d0a2287302fe5ed1aa882598be91069b4fc52
deargopinath/data-science-python
/assignments/deep-dive/q14.py
475
4.15625
4
# 14. # Write a program that accepts a sentence and calculate the and lower case letters. # Suppose the following input is supplied to the program: # Hello world! # Then, the output should be: # UPPER CASE 1 # LOWER CASE 9 sentence = input("Enter the sentence:\n") upperCase = 0 lowerCase = 0 for word in sentence: ...
true
b42cc6519e2aa7d9b329a25d3dd47f0cdcd28c87
rohanwarange/Tcs-Ninja
/program9.py
565
4.21875
4
### -*- coding: utf-8 -*- ##""" ##Created on Tue Jul 6 10:23:02 2021 ## ##@author: ROHAN ##""" ## ##Question ## ##1. Using a method, pass two variables and find the sum of two numbers. ## ##Test case: ## ##Number 1 – 20 ## ##Number 2 – 20.38 ## ##Sum = 40.38 ## ##There were a total of 4 test cases. Once you compile 3...
true
80a20af468f0a5d51f4d9101910e26a76aafd38b
abhishekmishragithub/Test-Sample---Temp
/2nd_largest.py
813
4.25
4
def get_second_largest_element(array): """Return the second largest number from the array""" arr_size = len(array) if arr_size < 2: # print("Invalid Input: Array with atleast size 2 is required ") return -1 largest = second_largest = -214748364802 for value in range(arr_size): ...
true
ad280428bb996caccbb064c02728124451cefcdf
nooras/Algorithm-Series
/1.LinearSearch.py
1,063
4.15625
4
# Linear Search # Date : 19/10/2020 ''' Linear search is used on a collections of items. It relies on the technique of traversing a list from start to end by exploring properties of all the elements that are found on the way. For example, consider an array of integers of size . You should find and print the positio...
true
7696ca6ebe2518fbff9c17accc4fdf661c9f6e51
Abhijeet198/Python-Program
/52.Print all permutations with given repetition number of characters of a given string.py
382
4.15625
4
#52.Print all permutations with given repetition number of #characters of a given string from itertools import product def all_repeat(str1,rno): chars = list(str1) results = [] for c in product(chars,repeat = rno): results.append(c) return results print(all_repeat('xyz',3)) pri...
true
6531b41f3f1b04f5d935d50ae6a4333dcb72182b
swiderep/costs_manager
/displayMenu.py
1,057
4.1875
4
import functions # enter display menu def displayMenu(): print("Display by:") print("1. Due date") print("2. Amount") print("3. Back to main menu") displayChoice() def displayChoice(): while True: try: displayMenuChoice = int(input("Select option from above: ")) ...
true
0f5be15c2c4278b2abff5aa524252be8f33edb99
maxwell-ihcc/QualityAssurance-Maxwell-IHCC
/Python/Day 1 Python Notes/Day 4 Python Notes.py
1,474
4.4375
4
#Day 4 Notes #Maxwell Floyd 9/23/19 #This program uses a loop to display a table of numbers and their squares # Print the numbers and their squares # for variable in [value1, value2, etc.] # Statement # Statement # 1. Must separate values with commas. # 2. List - Comma separated sequence of...
true
1b2be3d90191b5a09e0d569ec099ce2a0931469a
sysnad/LearnPythonTheHardWay
/ex8.py
740
4.3125
4
#We're using a formatter that creates the output of raw data if we were to used %s #we it would represent them as strings formatter = "%r %r %r %r" # formatter = "%s %s %s %s" #the following prints out integers as they appeaer print formatter % (1, 2, 3, 4) #now we print out strings as they appear includin...
true
af1eb43f368b0ed33c420f5457f2c4f2444cff34
sumit123123/Python
/Chapter 2/P-S.py
828
4.15625
4
# Q-1 Write a python program to add two numbers # Num_1 = int(input("Enter the number 1")) # Num_2 = int(input("Enter the number 2")) # print(Num_1+Num_2) # Q-2 Write a python program to find remainder when a number is divide by 2 # Num1 = int(input("Enter the number\n")) # print(Num1/2) # Q-3 Check the type of...
true
33b70ddc926b58596e3a7a774953ded402708061
sumit123123/Python
/Practise Problem/PS_02.py
1,458
4.40625
4
""" Q-1 Write a Python program to print the following 'here document' Q-2 Write a Python program to calculate number of days between two dates Q-3 Write a Python program to get the volume of a sphere with radius 6. V = 4/3 πr³ Q-4 Write a Python program to get the difference between a given number and 17, if the nu...
true
5793dd412cd8b0d223442b479b984cf96ba931b0
Matthew-J-Walsh/UtilityFunctionWebapp
/dankmemestheteacher.py
359
4.125
4
def distance_from_zero(n): if type(n) == int or type(n) == float: return abs(n) else: return "Nope" original = raw_input("input a number:") try: n = int(original) print(n) n = distance_from_zero(n) print(n) except: print("input a number idiot") #x = x ^ 2 #return...
true
6daa3d71b6c8e39ad42cdca207185fa699593463
heerapatil/PythonAssignment
/assignment20.py
228
4.625
5
#20. Ask the user for a string and print out whether this string is a palindrome or not string="madam" if string==string[::-1]: print"It is a palindrome" else: print "It is not a palindrome" '''output: It is a palindrome '''
true
ecb0eeed21facd55327293c1716440cf3abec2e8
Danuminthar/PythonOnlineTraining
/Calculator/Calculator.py
522
4.40625
4
#!#/usr/bin/python3 #Calculator while 2: first_num=float(input("Enter The First Number: ")) operator =input ("Enter the operator: ") second_num=float(input("Enter the Second Number: ")) if operator=="+": result=first_num+second_num elif operator=="-": result=first_num-second_num ...
true
173bda1a470e4e1612c4cc31083b6adfdec02cd3
krishnanunni-pr/Pyrhon-Django
/EXAM/exam.py
408
4.15625
4
#create a function with arguments and return type which find sum of prime numbers between 1 - 50? def sumprime(x,y): sum = 0 for num in range(x,y+1): if num > 1: for i in range(2, num): if (num % i) == 0: break else: sum = sum...
true
3e9526912ccb8a7343c158df780c2eb0c15c4250
krishnanunni-pr/Pyrhon-Django
/asessment/assesment2/palindrome.py
392
4.3125
4
# def check_palindrome(str): # reverse = str[::-1] # check=1 # if(str!=reverse): # check=0 # return check # def check_palindrome(str): reverse=str[::-1] check=1 if(str!=reverse): check=0 return check str = input("Enter the string: ") check= check_palindrome(str) if(chec...
true
d06e30b78dcf1c83e2bf187523c53b65f2782f0c
an4p/python_learning
/homework06/hw06_04extra.py
1,995
4.46875
4
departments = {'Developers': 10, 'QA': 5, 'Admins': 2, 'DevOps': 2, 'Security': 1, 'BA': 2, 'HR': 1, 'OfficeManager': 1, 'HelpDesk': 1, 'Support': 2} print("The current list of the departments: ") for dep in departments: print(dep) while True: print("\n* For exit type 'Exit'. \n* T...
true
6e8aa27bacb34e5ad52cb58371f8288ac2641030
an4p/python_learning
/homework_03/hw03_03.py
625
4.15625
4
while (True): print("Type 'quit' to exit") phrase = input("Your message: ") if phrase == "quit": break elif phrase == "Hello" or phrase == "Hi": print("Hi! How's it going?") elif phrase == "What is your name?": print("I don't have a name :(") elif phrase == ("I am tired"...
true
b5b4ced1cfa3ab027d8f4683ef429665cad6ee26
Rhadow/leetcode
/lintcode/Easy/085_Insert_Node_in_a_Binary_Search_Tree.py
1,275
4.1875
4
""" Definition of TreeNode: class TreeNode: def __init__(self, val): self.val = val self.left, self.right = None, None """ class Solution: """ @param root: The root of the binary search tree. @param node: insert this node into the binary search tree. @return: The root of the new bina...
true
57dc475faa94d20364f2ea8a1d62707b5f89750d
santosh-bitra/PythonLearning
/Level-1/level1.3.py
369
4.21875
4
#Program to switch numbers of the assigned variables a,b = input("a is"), input("b is") print('a is ', a and b) print('b is ', a or b) #This can also be simply made to run in the following. #The base example was to exchange the glass of milk with the cup of coffee #Which is possible by introducing an extra variable ...
true
63314b14042d14d05a5782dc1372b23d8cc84e5b
jarvis-1805/DSAwithPYTHON
/Conditionals and Loops/Check_number.py
618
4.28125
4
''' Check number Given an integer n, find if n is positive, negative or 0. If n is positive, print "Positive" If n is negative, print "Negative" And if n is equal to 0, print "Zero". Input Format : Integer n Output Format : "Positive" or "Negative" or "Zero" (without double quotes) Constraints : 1 <= n <= 100 Samp...
true
f7acaf49d300839fa6d0612addc35b7024054497
jarvis-1805/DSAwithPYTHON
/Priority Queues/Priority Queues/K_Largest_Elements.py
1,051
4.1875
4
''' K Largest Elements You are given with an integer k and an array of integers that contain numbers in random order. Write a program to find k largest numbers from given array. You need to save them in an array and return it. Time complexity should be O(nlogk) and space complexity should be not more than O(k). Order ...
true
46a62cfbea59c66325e44edab14cb9efec949885
jarvis-1805/DSAwithPYTHON
/Recursions/Recursions 2/mergeSort.py
1,243
4.3125
4
''' Merge Sort Code Sort an array A using Merge Sort. Change in the input array itself. So no need to return or print anything. Input format : Line 1 : Integer n i.e. Array size Line 2 : Array elements (separated by space) Output format : Array elements in increasing order (separated by space) Constraints : 1 <= n ...
true
e5190ec3bd3b9b134f1350b116000b4d612e6f2e
jarvis-1805/DSAwithPYTHON
/Stacks and Queues/Queues/Reverse_the_First_K_Elements_in_the_Queue.py
2,305
4.125
4
''' Reverse the First K Elements in the Queue For a given queue containing all integer data, reverse the first K elements. You have been required to make the desired change in the input queue itself. Input Format : The first line of input would contain two integers N and K, separated by a single space. They denote th...
true
e63082038fa2c3d2be606d7f6d0fdefb013cab53
jarvis-1805/DSAwithPYTHON
/Introduction to Python/Find_average_Marks.py
517
4.25
4
''' Find average Marks Write a program to input marks of three tests of a student (all integers). Then calculate and print the average of all test marks. Input format : 3 Test marks (in different lines) Output format : Average Sample Input 1 : 3 4 6 Sample Output 1 : 4.333333333333333 Sample Input 2 : 5 10 5...
true
3c8667231597af744f91a78750a958dc0719be17
jarvis-1805/DSAwithPYTHON
/Linked List/Linked_List_2/Merge_Sort.py
2,818
4.15625
4
''' Code : Merge Sort Given a singly linked list of integers, sort it using 'Merge Sort.' Note : No need to print the list, it has already been taken care. Only return the new head to the list. Input format : The first line contains an Integer 't' which denotes the number of test cases or queries to be run. Then the ...
true
7c7fe292f6a536cf72e35fd4000d407f11cb13a0
MichaelJWest/Python-Exercises
/ex6.py
836
4.21875
4
# puts 10 into the sentence where %d is x = "There are %d types of people." % 10 # sets variable binary to a string that says binary binary = "binary" # sets another variable do_not = "don't" # puts the two variables into the sentence binary and do_not inseperate places y = "Those who know %s and those who %s." % (bina...
true
bab830e7fa55d72add72490082223cc4e48961fa
callous4567/UoE-Projects
/2nd Year Miscellanies/error2.py
221
4.15625
4
""" Check whether a given number appears as entry in a list of integers. """ mynum = 3 numbers = list(range(10)) print(numbers) for n in numbers: if n == mynum: print(("Found my number: {}").format(mynum))
true
115388e51933b24517e385a7c26bec16036b7ce0
callous4567/UoE-Projects
/2nd Year Miscellanies - Continued/RadiusCalculator.py
2,762
4.40625
4
# Hello Folks! Here's my radius calculator! # The goal is to get the volume in mm^-3 and output in metres & millimetres! # First let's import math. import math import cmath import random import sys import time def timeDelay(t): print() for c in t: sys.stdout.write(c) sys.stdout.flush() ...
true
bcc157321933e3e230f1c1dbf04cdf66c13e2996
Akash-kakkar/Python-DS
/Day5/PyDS_Day5.py
1,043
4.21875
4
# Why encapsulation is important? How you can implement it in python? # '''# Encapsulation is one of the fundamental concepts in object-oriented programming (OOP). It describes the idea of wrapping data and the methods that work on data within one unit. This puts restrictions on accessing variables and methods directl...
true
a661685fb149dd5b8817e0f5474e4616ce8ebb97
Hilal-Ataman/PythonTurk-shAlHub-Homework-21.12.2020
/Homework1.1.py
804
4.28125
4
# -*- coding: utf-8 -*- """ Created on Wed Dec 23 21:13:30 2020 @author: hp """ """Homework-1 Take 5 values from the user and write a program that prints the values you get on the screen. Print the type of values you received in this program on the screen. When using print functions, do not forget to u...
true
254147f81330d31444e305f1ab3013ddc4fc1d02
yaronke/myPython
/ex.py
287
4.25
4
# Write a program that takes a list of numbers # (for example, a = [5, 10, 15, 20, 25]) and makes a new list # of only the first and last elements of the given list. # For practice, write this code inside a function. my_list = [1,3,5,7,9,11,13] new_list = my_list[0,6] print(new_list)
true
e3130f3bb540ca0185cf91833de7b42492b5159e
MrVJPman/IBM-Data-Science-Professional-Certificate
/Course 4-Python for Data Science and AI/Week 3/loops.py
1,451
4.4375
4
#Write a for loop the prints out all the element between -5 and 5 using the range function. for number in range(-5, 6): print(number) #Print the elements of the following list: Genres=[ 'rock', 'R&B', 'Soundtrack', 'R&B', 'soul', 'pop'] #Make sure you follow Python conventions. Genres=[ 'rock', 'R&B', 'Sound...
true
7c56ecc88d2404a9e71fcfe95f94452c14aec395
rasheedalhazmi/CS5590PDL
/ICP1/SourceCode/calculation.py
206
4.125
4
# Take an input from User num1 = input("Enter first number: ") num2 = input("Enter second number: ") # Add num1 to num2 result = int(num1) + int(num2) # Print calculation print("\nTotal is: %d" % result)
true
3d45a765152ebfdfee3903c372435e1e2b691a9e
halendarc/Fall-2019-Projects
/calc.py
2,227
4.34375
4
while True: import math def add(x,y): #defines the addition function to add two numbers together. result = x+y return result num1 = input("Enter the first number, or 'quit' to quit: ") if num1 == "quit": break else: num1 = float(num1) num2 = fl...
true
e2ab0e597f626115478390e4ac8eed23c4569111
Alantrivandrum/Python_projects
/Greet.py
440
4.15625
4
name = input("Please enter your name ") def greet(): print("Hello " + name) print("How are you? ") greeting = input("If your are fine type 'Y' else type 'N' ") if greeting == "Y" or greeting == "y": print("That's great to hear! :) ") elif greeting == "N" or greeting == "n": ...
true
dc99b5e17488d9423b594c37579774852a1e2de6
MohammedJouhar/Automate-the-boring-stuff-with-Python
/birthday.py
771
4.5625
5
# this code helps to maintian birthday day tracker, code asked user ask to input name and this will search in the dictionaries we created # if thier name not available this will add to the dictionaries birthday = {'jouhar': '13th March', 'zebu': '20th September', 'fathima': '11th Jan'} while True: print('Type you...
true
2b359c4c995f662e8a2d541b86d09bc2de4b4c97
Abdl-Azeez/_Intern_Task
/DigiAssessment.py
1,564
4.125
4
# First Task in Section 2 def Task1(): for i in range (1,100): #range 1 to 100 is used in order to make the loop start from 1 and not 0 if ((i%5==0) or (i%3==0)): print (i) # Second Task in Section 2 def findHCF(num, arr): #Find the HCF using the Euclidean Algorithm ...
true
a4a4b1ccdc1bc48b2a7391f343b61f18fbd159dc
Auraiporn/School_Projects
/CS4800_Concepts_of_Programming_Languages/Python/BubbleSort.py
1,274
4.375
4
#use bubble sort to swap elements if they are in wrong order def bubbleSort(list): #go over through all array elements for i in range(len(list) - 1): #last i element is in place for j in range(0, len(list) - i - 1): #move through the array and swap if the element found is greater ...
true
72a77f84809cc2c77a0f019d14d6cbb854a20e29
PlamediD/Python
/bubbleSort.py
853
4.375
4
def bubble(unsortedList): count=0 indexing_length = len(unsortedList) - 1 sorted = False #Create variable of sorted and set it equal to false while not sorted: #Repeat until sorted = True sorted = True # Break the while loop whenever we have gone through all the values for i...
true
83688a8ea2301a49219b1a06db1622b7472da18d
monicaihli/tenn-share_2019
/B_Preprocessing/B5_python_full-nltk-prep.py
2,227
4.28125
4
import string # adds some string manipulation functionality from nltk.tokenize import word_tokenize # breaks text up into lists of words from nltk.corpus import stopwords # removes unimportant words from text from nltk import PorterStemmer # converts words to a stemmed form (with the ending broken off) from nltk.stem ...
true
24831d7019b5cbc49b55b38b04ec8cd6ce18a30b
imaaduddin/100-Days-Of-Python
/Day 4: Randomization And Python Lists/Day-4-Who's-Paying-Exercise.py
1,267
4.40625
4
# Who's Paying # Instructions # You are going to write a program which will select a random name from a list of names. The person selected will have to pay for everybody's food bill. # Important: You are not allowed to use the choice() function. # Line 8 splits the string names_string into individual names and puts t...
true
9f5eed3230d753a749e881b5396319a563ead0c4
akhileshbangera/data_science_oracle
/Data engineering/Find the running median/using_insort.py
860
4.5625
5
#Bisect algorithm is used to find a position in list where an element needs to be inserted to keep the list sorted. from bisect import insort #method to find the median of a sorted list def cal_median(num_list): list_len = len(num_list) mid_point = int(list_len/2) # if the Odd length list if list_len...
true
20246d819d87896f0b894e6556d4c2193ab60e6e
ksmalimba/holbertonschool-higher_level_programming
/0x0B-python-input_output/4-append_write.py
288
4.3125
4
#!/usr/bin/python3 """ This file contains function that appends a string at the end of a text file and returns number of characters added """ def append_write(filename="", text=""): with open(filename, mode="a", encoding="utf-8") as myFile: return (myFile.write(str(text)))
true
c3fb19709cb89f141bb86b966c345373b5640545
ChuanLiu0316/21-393
/server/model/calculator.py
1,226
4.1875
4
def calculate(weight, height, gender, age): ''' This function compute the calorie(kcal), protein(g), fat(g), carbonhydrate(g) needed for a person in one day based on his/her weight(kg), height(cm), gender, and age(years). ''' # calorie needed to stay alive print "in calculate" if gender ...
true
9811552a76940b0e893f0b7bfc49d8a15316dc36
catechnix/python_1
/operator_overload.py
670
4.15625
4
### __repr__: used by repr() used by str() if __str__ is not defined formal representation useful for debugging __str__: used by str(), print(), and format() nice/informal representation __init__ __bool_ __byte__ operator overloading: In python, it is possible to define how instances of a certain class i...
true
4e9a1761266b233757158c0db232021e9858bbfd
JefferySchons/Coms104
/lab04/lab4_checkpoint2.py
227
4.21875
4
#the function def area_of_circle(radius): area=3.14*radius*radius return area #the script radius=input("radius of cylinder:") height=input("height of cylinder:") circle_area=area_of_circle(radius)*height print circle_area
true
0df08a830ac6ba41acd8872473d29b33a69d0459
nahaza/pythonTraining
/ua/univer/HW04/ch08ProgTrain02.py
618
4.15625
4
# 2. Sum of Digits in a String # Write a program that asks the user to enter a series of single-digit numbers with nothing # separating them. The program should display the sum of all the single digit numbers in the # string. For example, if the user enters 2514, the method should return 12, which is the sum # of 2, 5,...
true
d9ddb65e3b1739e76a62bb19649c654c9937551b
nahaza/pythonTraining
/ua/univer/HW04/ch08AlgTrain04.py
233
4.21875
4
# 4. Write a loop that counts the number of lowercase characters that appear in the string # referenced by mystring. count = 0 myString = "fgJJK kKfd TG dfkhdk" for x in myString: if x.islower(): count += 1 print(count)
true
41feb58986754d148f4eb79e78b5d3ffa87697c7
nahaza/pythonTraining
/ua/univer/HW07/ch11ProgTrain03/customer.py
1,427
4.4375
4
# # 3. Person and Customer Classes # # Write a class named Person with data attributes for a person’s name, address, and telephone number. Next, write a class named Customer that is a subclass of the Person class. # # The Customer class should have a data attribute for a customer number, and a Boolean # # data attribu...
true
2754e5d025188f4078148546c3fc5e7a7cea9fb0
nahaza/pythonTraining
/ua/univer/HW04/ch08ProgTrain11.py
757
4.28125
4
# 11. Word Separator # Write a program that accepts as input a sentence in which all of the words are run together, # but the first character of each word is uppercase. Convert the sentence to a string in which # the words are separated by spaces, and only the first word starts with an uppercase letter. For # example t...
true
a755a03d23cd5b5a16803e4aea7d7bbc94136596
nahaza/pythonTraining
/ua/univer/HW08/ch13AlgTrain02.py
542
4.1875
4
# 2. Assume self.label1 and self.label2 reference two Label widgets. Write code that # packs the two widgets so they are positioned as far left as possible inside their parent # widget. import tkinter class My_GUI: def __init__(self): self.main_window = tkinter.Tk() self.label1 = tkinter.Label(sel...
true
20c1c45af1ecb0e2ef5d6dff6261e8af7d8d6803
nahaza/pythonTraining
/ua/univer/HW05/ch09AlgTrain09.py
325
4.3125
4
# 9. Assume each of the variables set1 and set2 references a set. Write code that creates # another set containing the elements that appear in set2 but not in set1, and assigns # the resulting set to the variable set3. set1 = set([1, 2, 3, 4, 5, 6]) set2 = set([2, 4, 6, 7, 8, 9]) set3 = set2.difference(set1) print(s...
true
830cf03f4c960f45452c098da2963f1f56beb1a9
nahaza/pythonTraining
/ua/univer/HW04/ch06ProgTrain12.py
2,196
4.5625
5
# 12. Average Steps Taken # A Personal Fitness Tracker is a wearable device that tracks your physical activity, calories # burned, heart rate, sleeping patterns, and so on. One common physical activity that most # of these devices track is the number of steps you take each day. # If you have downloaded this book’s sour...
true
090bce541c8e30455ffee6e30f3602f1b59d3cf2
nahaza/pythonTraining
/ua/univer/HW04/ch08AlgTrain01.py
332
4.375
4
# 1. Assume choice references a string. The following if statement determines whether # choice is equal to ‘Y’ or ‘y’: # if choice == 'Y' or choice == 'y': # Rewrite this statement so it only makes one comparison, and does not use the or # operator. (Hint: use either the upper or lower methods.) if choice.lower() == ...
true
4b2cf67d954625b0d6c37d0fe77f9a9ba5bacb07
nahaza/pythonTraining
/ua/univer/HW06/ch10ProgTrain02/__main__.py
1,488
4.625
5
# 2. Car Class # Write a class named Car that has the following data attributes: # • _ _year_model (for the car’s year model) # • _ _make (for the make of the car) # • _ _speed (for the car’s current speed) # The Car class should have an _ _init_ _ method that accepts the car’s year model and # make as arguments. These...
true
aaa472a8bc6115cdd8ac8a727ec7cc81f2d3f5b3
nahaza/pythonTraining
/ua/univer/HW06/ch10ProgTrain09/game.py
2,268
4.375
4
# 9. Trivia Game # In this programming exercise, you will create a simple trivia game for two players. The program will work like this: # • Starting with player 1, each player gets a turn at answering 5 trivia questions. (There # should be a total of 10 questions.) When a question is displayed, 4 possible answers are ...
true
69de9b1c442fbaa849f72f32f3fbbd345e86eba5
nahaza/pythonTraining
/ua/univer/HW04/ch12ProgTrain07.py
492
4.34375
4
# 7. Recursive Power Method # Design a function that uses recursion to raise a number to a power. The function should # accept two arguments: the number to be raised, and the exponent. Assume the exponent is # a nonnegative integer. def main(): num = int(input("Enter a number: ")) power = int(input("Enter a po...
true
f30325c537c5bf58feaa1b19fc8c3b8ed615329c
nahaza/pythonTraining
/ua/univer/HW02/ch05AlgTrain07.py
268
4.15625
4
# 7. The following statement calls a function named half, which returns a value that is # half that of the argument. (Assume the number variable references a float value.) # Write code for the function. # result = half(number) def half(number): return number / 2
true