blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
42716bcb27499c2079a9eda6925d9ae969217adf
tme5/PythonCodes
/CoriolisAssignments/pyScripts/33_file_semordnilap.py
1,780
4.53125
5
#!/usr/bin/python ''' Date: 19-06-2019 Created By: TusharM 33) According to Wikipedia, a semordnilap is a word or phrase that spells a different word or phrase backwards. ("Semordnilap" is itself "palindromes" spelled backwards.) Write a semordnilap recogniser that accepts a file name (pointing to a list of wor...
true
9801097af0d4a761dc1f96039b2cf86cac257c26
tme5/PythonCodes
/CoriolisAssignments/pyScripts/21_char_freq.py
1,200
4.40625
4
#!/usr/bin/python ''' Date: 18-06-2019 Created By: TusharM 21) Write a function char_freq() that takes a string and builds a frequency listing of the characters contained in it. Represent the frequency listing as a Python dictionary. Try it with something like char_freq("abbabcbdbabdbdbabababcbcbab"). ''' def...
true
f869321ad3d5a053c4e10c8c0e84c83d25b33974
tme5/PythonCodes
/CoriolisAssignments/pyScripts/30_translate_to_swedish.py
1,031
4.15625
4
#!/usr/bin/python # -*- coding: latin-1 -*- ''' Date: 19-06-2019 Created By: TusharM 30) Represent a small bilingual lexicon as a Python dictionary in the following fashion {"merry":"god", "christmas":"jul", "and":"och", "happy":gott", "new":"nytt", "year":"r"} and use it to translate your Christmas cards from E...
true
46bcbbe3a779b19a3c021be114ebb33846785e49
thien-truong/learn-python-the-hard-way
/ex15.py
617
4.21875
4
from sys import argv script, filename = argv # A file must be opened before it can be read/print txt = open(filename) print "Here's your file {}:".format(filename) # You can give a file a command (or a function/method) by using the . (dot or period), # the name of the command, and parameteres. print txt.read() # ca...
true
8a745e216a89e5a3f6c9d4111ea2bc38d37e4eb7
thien-truong/learn-python-the-hard-way
/ex18.py
1,209
4.59375
5
# Fuctions: name the pieces of code the way ravirables name strings and numbers. # They take arguments the way your scripts take argv # They let you make "tiny commands" # this one is like your scripts with argv # this function is called "print_two", inside the () are arguments/parameters # This is like your script...
true
4a98b19419c953a3b12a1df262c3674a6b3a8967
kahuroA/Python_Practice
/holiday.py
1,167
4.53125
5
"""#Assuming you have a list containing holidays holidays=['february 14', 'may 1', 'june 1', 'october 20'] #initialized a list with holiday names that match the holidays list holiday_name=['Valentines', 'Labour Day', 'Mashujaa'] #prompt user to enter month and date month_date=input('enter month name and date') #check i...
true
ec3010b56ca544f4910d38d6bf5c5dc8e61ff30e
l-ejs-l/Python-Bootcamp-Udemy
/Lambdas/filter.py
883
4.15625
4
# filter(function, iterable) # returns a filter object of the original collection # can be turned into a iterator num_list = [1, 2, 3, 4, 5, 6] evens = list(filter(lambda x: x % 2 == 0, num_list)) print(evens) users = [ {"username": "Samuel", "tweets": ["IO love cake", "IO love cookies"]}, {"username": "Kat...
true
c59e167d00e927e6ca41268b9490b3eb6722ad3d
l-ejs-l/Python-Bootcamp-Udemy
/Iterators-Generators/generator.py
410
4.1875
4
# A generator is returned by a generator function # Instead of return it yields (return | yield) # Can be return multiple times, not just 1 like in a normal function def count_up_to(max_val): count = 1 while count <= max_val: yield count count += 1 # counter now is a generator and i can call...
true
d3b10c9fdd390fdf8068c1e343da8c334c034437
l-ejs-l/Python-Bootcamp-Udemy
/Lambdas/zip.py
437
4.4375
4
# zip(iterable, iterable) # Make an iterator that agregate elements from each of the iterables. # Returns an iterator of tuples, where the i'th tuple contains the i'th element from each of the of the argument # sequences or iterables. # The iterator stops when the shortest input iterable is exhausted first_zip = zip([...
true
fae187d17f928d0791df8d0f4f7d5f678d09c5cd
AnanyaRao/Python
/tryp10.py
224
4.28125
4
def factorial(num): fact=1; i=1; for i in range(i,num+1): fact=fact*i; return fact; num=int(input('Enter the number:')) fact=factorial(num); print('The factorial of the number is:',fact)
true
bf5ca4a2000a7d1ffa895ec758308b80ef1cb93a
calwoo/ppl-notes
/wengert/basic.py
1,831
4.25
4
""" Really basic implementation of a Wengert list """ # Wengert lists are lists of tuples (z, g, (y1,...)) where # z = output argument # g = operation # (y1,...) = input arguments test = [ ("z1", "add", ["x1", "x1"]), ("z2", "add", ["z1", "x2"]), ("f", "square", ["z2"])] # Hash table to...
true
936ce5e1d8181e03d394ba350ef26c10ee575bb6
sonias747/Python-Exercises
/Pizza-Combinations.py
1,614
4.15625
4
''' On any given day, a pizza company offers the choice of a certain number of toppings for its pizzas. Depending on the day, it provides a fixed number of toppings with its standard pizzas. Write a program that prompts the user (the manager) for the number of possible toppings and the number of toppings offered on th...
true
62021b456a4f6fbaeed24422fa09429698a7459d
ethanschreur/python-syntax
/words.py
346
4.34375
4
def print_upper_words(my_list, must_start_with): '''for every string in my_list, print that string in all uppercase letters''' for word in my_list: word = word.upper() if word[0] in must_start_with or word[0].lower() in must_start_with: print(word) print_upper_words(['ello', 'hey', '...
true
b5887edb1d489421105fe45ca7032fb136c479df
KenMatsumoto-Spark/100-days-python
/day-19-start/main.py
1,614
4.28125
4
from turtle import Turtle, Screen import random screen = Screen() # # def move_forwards(): # tim.forward(10) # # # def move_backwards(): # tim.backward(10) # # # def rotate_clockwise(): # tim.right(10) # # # def rotate_c_clockwise(): # tim.left(10) # # # def clear(): # tim.penup() # tim.clear(...
true
c56d992234d558fd0b0b49aa6029d6d287e90f2a
ARSimmons/IntroToPython
/Students/Dave Fugelso/Session 2/ack.py
2,766
4.25
4
''' Dave Fugelso Python Course homework Session 2 Oct. 9 The Ackermann function, A(m, n), is defined: A(m, n) = n+1 if m = 0 A(m-1, 1) if m > 0 and n = 0 A(m-1, A(m, n-1)) if m > 0 and n > 0. See http://en.wikipedia.org/wiki/Ackermann_funciton Create a new module called ack.py in...
true
688ede91119829d5ec4b75452ef18a5a29d6bd29
akidescent/GWC2019
/numberWhile.py
1,018
4.25
4
#imports the ability to get a random number (we will learn more about this later!) from random import * #Generates a random integer. aRandomNumber = randint(1, 20) #set variable aRandomNumber to random integer (1-20) #can initialize any variable # For Testing: print(aRandomNumber) numGuesses = 0 while True: #set a ...
true
42f6e8a1a8cbd172c92d6ba4ad7a115ac3982bb7
EugeneStill/PythonCodeChallenges
/open_the_lock.py
2,132
4.125
4
import unittest import collections # https://www.geeksforgeeks.org/deque-in-python/ class OpenTheLock(unittest.TestCase): """ You have a lock in front of you with 4 circular wheels. Each wheel has 10 slots: '0' through '9'. The wheels can rotate freely and wrap around: for example we can turn '9' to be '0...
true
3ea411d749f483c8fd5c63ad0ac7fd8a5c8c0a01
EugeneStill/PythonCodeChallenges
/rotting_oranges.py
2,767
4.125
4
import unittest from collections import deque class OrangesRotting(unittest.TestCase): """ You are given an m x n grid where each cell can have one of three values: 0 representing an empty cell, 1 representing a fresh orange, or 2 representing a rotten orange. Every minute, any fresh orange t...
true
59a8864a5f317ead31eb8d93246776eed2342fec
EugeneStill/PythonCodeChallenges
/word_break_dp.py
1,621
4.125
4
import unittest class WordBreak(unittest.TestCase): """ Given a string s and a dictionary of strings wordDict, return true if s can be segmented into a space-separated sequence of one or more dictionary words. Note that the same word in the dictionary may be reused multiple times in the segmentation....
true
26d1d171bfa5feab074dd6dafef2335befbc4ca7
EugeneStill/PythonCodeChallenges
/unique_paths.py
2,367
4.28125
4
import unittest import math class UniquePaths(unittest.TestCase): """ There is a robot on an m x n grid. The robot is initially located at the top-left corner (i.e., grid[0][0]). The robot tries to move to the bottom-right corner (i.e., grid[m - 1][n - 1]). The robot can only move either down or right ...
true
fdd5987f684a90e78ba5622fd37919c43951bd20
EugeneStill/PythonCodeChallenges
/course_prerequisites.py
2,711
4.34375
4
import unittest import collections class CoursePrereqs(unittest.TestCase): """ There are a total of num_courses courses you have to take, labeled from 0 to num_courses - 1. You are given an array prerequisites where prerequisites[i] = [ai, bi] meaning that you must take course bi first if you want to t...
true
57d16b965de6e4f82979f42656042af956145410
EugeneStill/PythonCodeChallenges
/reverse_polish_notation.py
2,516
4.21875
4
import unittest import operator class ReversePolishNotation(unittest.TestCase): """ AKA Polish postfix notation or simply postfix notation The valid operators are '+', '-', '*', and '/'. Each operand may be an integer or another expression. The division between two integers always truncates toward ...
true
47656bdd5d6b6f46cb957f38ecc32184198f9829
MariamBilal/python
/List.py
1,008
4.65625
5
# Making and Printing list my_list = ['fish','dog','cat','horse','frog','fox','parrot','goat'] print(my_list) #Using Individual Values from a List for i in my_list: print(i) #Accessing elements in a List print(my_list[0]) #To title the the items in list. print(my_list[2].title()) #To print last character from t...
true
4bc82f2bdf496610241ad272ee9f76b69713c51d
codilty-in/math-series
/codewars/src/highest_bi_prime.py
1,100
4.1875
4
"""Module to solve https://www.codewars.com/kata/highest-number-with-two-prime-factors.""" def highest_biPrimefac(p1, p2, end): """Return a list with the highest number with prime factors p1 and p2, the exponent for the smaller prime and the exponent for the larger prime.""" given_primes = set([p1, p2]) ...
true
d20b15088e93c670f2ddd84ec8d2b78ad0d63199
codilty-in/math-series
/codewars/src/surrounding_prime.py
1,328
4.25
4
def eratosthenes_step2(n): """Return all primes up to and including n if n is a prime Since we know primes can't be even, we iterate in steps of 2.""" if n >= 2: yield 2 multiples = set() for i in range(3, n+1, 2): if i not in multiples: yield i multiples.updat...
true
7a291a64dea198b5050b83dc70f5e30bcf8876f5
codilty-in/math-series
/codewars/src/nthfib.py
524
4.1875
4
"""This module solves kata https://www.codewars.com/kata/n-th-fibonacci.""" def original_solution(n): """Return the nth fibonacci number.""" if n == 1: return 0 a, b = 0, 1 for i in range(1, n - 1): a, b = b, (a + b) return b #better solution def nth_fib(n): """Return the nth f...
true
9b4a1f7ef0879176a70ee0324c49914d24c76c80
achiengcindy/Lists
/append.py
347
4.375
4
# define a list of programming languages languages = ['java', 'python', 'perl', 'ruby', 'c#'] # append c languages.append('c') print(languages) # Output : ['java', 'python' ,'perl', 'ruby', 'c#', 'c'] # try something cool to find the last item, # use **negative index** to find the value of the last item print(language...
true
d7a0d968a0b1155703ec27009f4c673bab32416f
johnmcneil/w3schools-python-tutorials
/2021-02-09.py
2,405
4.40625
4
# casting to specify the data type x = str(3) y = int(3) z = float(3) # use type() to get the data type of a variable print(x) print(type(x)) print(y) print(type(y)) print(z) print(type(z)) # you can use single or double quotes # variables # variable names are case-sensitive. # must start with a letter or the u...
true
df2a11b4b05eb2a086825a7a996347f0f56a75ee
johnmcneil/w3schools-python-tutorials
/2021-03-05.py
1,466
4.65625
5
# regexp # for regular expressions, python has the built-in package re import re txt = "The rain in Spain" x = re.search("^The.*Spain$", txt) print(x) # regex functions # findall() - returns a list of all matches x = re.findall("ai", txt) print(x) x = re.findall("sdkj", txt) print(x) # search() - returns a match ob...
true
c31786c6ad2645c08348c68592c2e95c1b924be9
krishnakesari/Python-Fund
/Operators.py
1,296
4.15625
4
# Division (/), Integer Division (//), Remainder (%), Exponent (**), Unary Negative (-), Unary Positive (+) y = 5 x = 3 z = x % y z = -z print(f'result is {z}') # Bitwise operator (& | ^ << >>) x = 0x0a y = 0x02 z = x << y print(f'(hex) x is {x:02x}, y is {y:02x}, z is {z:02x}') print(f'(bin) x is {x:08b}, y is ...
true
4e0088bb25588855455f58537abbabb1769b2459
ETDelaney/automate-the-boring-stuff
/05-01-guess-the-number.py
1,343
4.21875
4
# a game for guessing a number import random num_of_chances = 5 secret_number = random.randint(1,20) #print(secret_number) print('Hello, what is your name?') name = input() print('Well, ' + name + ', I am thinking of a number between 0 and 20.') print('Can you guess the number? I will give you ' + str(num_of_chance...
true
8d37af2dc7cf5fba984f7c35f343c6741a30653e
rustybailey/Project-Euler
/pe20.py
425
4.15625
4
""" n! means n * (n - 1) * ... * 3 * 2 * 1 For example, 10! = 10 * 9 * ... 3 * 2 * 1 = 3628800, and the sum of the digits in the number 10! is 3 + 6 + 2 + 8 + 8 + 0 + 0 = 27. Find the sum of the digits in the number 100! """ import math def sumFactorial(n): num = math.factorial(n) total = 0 whil...
true
b495c945cfed8db9787f8d9fab4e3c02a5232dfb
shagunsingh92/PythonExercises
/FaultyCalculator.py
1,122
4.53125
5
import operator '''Exercise: My_faulty_computer this calculator will give correct computational result for all the numbers except [45*3 = 555, 56+9=77 56/6=4] ''' def my_faulty(): allowed_operator = {'+': operator.add, '-': operator.sub, '*': operator.mul, '/': operator.truediv} # ask the user for an input ...
true
3302de8bad34c27c4ed7216b5d4b9fb786979c6c
allenc8046/CTI110
/P4HW4_Chris Allen.py
356
4.21875
4
import turtle redCross = turtle.Screen() x = turtle.Turtle() x.color("red") # set x turtle color x.pensize(3) # set x turtle width print("It's a red cross!") print () # use a for loop for redCross in range (4): x.forward(150) x.left(90) x.forward(150) x.left(90) ...
true
00129adf4cbb2fda2215c499ba7392ca17e90b10
rafaelalmeida2909/Python-Data-Structures
/Linked Queue.py
2,268
4.28125
4
class Node: """Class to represent a node in Python3""" def __init__(self, data): self.data = data # Node value self.next = None # Next node class LinkedQueue: """Class to represent a Linked Queue(without priority) in Python3""" def __init__(self): self._front = None # The ...
true
b314cc818cdf04d37dbc36fae60f5f0ca354182e
divineunited/casear_cipher
/casear_cipher.py
2,649
4.125
4
def casear(message, n, encrypt=True): '''This casear encryption allows for undercase and capital letters. Pass a message to encrypt or decrypt, n number of positions (must be less than 26) where n will add to the alphabet for encryption and subtract for decryption, and optional encrypt=False to allow for decryption...
true
7c4f5a725fb49a86333809956941866f45d0effb
MeghaSajeev26/Luminar-Python
/Advance Python/Test/pgm5.py
448
4.4375
4
#5. What is method overriding give an example using Books class? #Same method and same arguments --- child class's method overrides parent class's method class Books: def details(self): print("Book name is Alchemist") def read(self): print("Book is with Megha") class Read_by(Books): def rea...
true
9f9a506baa32ca4d7f7c69ed5d66eac431d0c37f
MeghaSajeev26/Luminar-Python
/Looping/for loop/demo6.py
212
4.21875
4
#check whether a number is prime or not num=int(input("enter a number")) flag=0 for i in range(2,num): if(num%i==0): flag=1 if(flag>0): print(num,"is not a prime") else: print(num,"is prime")
true
05984d56459fb9738b27f9bc1fe070ede6d948ea
uttam-kr/PYTHON
/Basic_oops.py
1,042
4.1875
4
#!/usr/bin/python #method - function inside classes class Employee(): #How to initialize attribute #init method def __init__(self, employee_name, employee_age, employee_weight, employee_height): print('constructor called') #('init method or constructor called') ---->This __init__ method called constructor self...
true
49f4d48bc9ccc29332f76af833fefa0383defea3
fadhilahm/edx
/NYUxFCSPRG1/codes/week7-functions/lectures/palindrome_checker.py
631
4.15625
4
def main(): # ask for user input user_input = input("Please enter a sentence:\n") # sterilize sentence user_input = sterilize(user_input) # check if normal equals reversed verdict = "is a palindrome" if user_input == user_input[::-1] else "is not a palindrome" # render result print("Y...
true
cd1f058045cc9414ca8d8f2d5ed0e7f0d4ef231d
suiody/Algorithms-and-Data-Structures
/Data Structures/Circular Linked List.py
1,248
4.125
4
""" * Author: Mohamed Marzouk * -------------------------------------- * Circular Linked List [Singly Circular] * -------------------------------------- * Time Complixty: * Search: O(N) * Insert at Head/Tail: O(1) * Insert at Pos: O(N) * Deletion Head/Tail: O(1) * Deletion [middle / pos]: O(N) * Spa...
true
16c3c7b2302a7fd892b67a00b09d41e058a3cff5
sula678/python-note
/basic/if-elif-else.py
233
4.125
4
if 3 > 5: print "Oh! 3 is bigger than 5!" elif 4 > 5: print "Oh! 4 is bigger than 5!" elif 5 > 5: print "Oh! 5 is bigger than 5!" elif 6 > 5: print "Of course, 6 is bigger than 5!" else: print "There is no case!"
true
e707b084c1932e484b5023eae4052fc606332c3c
mreboland/pythonListsLooped
/firstNumbers.py
878
4.78125
5
# Python's range() function makes it easy to generate a series of numbers for value in range(1, 5): # The below prints 1 to 4 because python starts at the first value you give it, and stops at the second value and does not include it. print(value) # To count to 5 for value in range(1, 6): print(value) ...
true
8a9b9a790d09aa9e7710b48b67575553224a497b
EvheniiTkachuk/Lessons
/Lesson24/task1.py
949
4.15625
4
# Write a program that reads in a sequence of characters and prints # them in reverse order, using your implementation of Stack. class MyStack: def __init__(self): self.array = [] def push(self, item): self.array.append(item) def pop(self): return self.array.pop() ...
true
d69a710becdd434773d15def23dbe71e3c426b75
EvheniiTkachuk/Lessons
/Lesson24/task3_2.py
1,856
4.125
4
# Extend the Queue to include a method called get_from_stack that # searches and returns an element e from a queue. Any other element must # remain in the queue respecting their order. Consider the case in which the element # is not found - raise ValueError with proper info Message class Queue: def __init_...
true
02ffe7089ad2b5c05246949bf9731c73130e3ebd
EvheniiTkachuk/Lessons
/Lesson24/task2.py
1,596
4.15625
4
# Write a program that reads in a sequence of characters, # and determines whether it's parentheses, braces, and curly brackets are "balanced." class MyStack: def __init__(self): self.array = [] def push(self, item): self.array.append(item) def pop(self): return sel...
true
7191a0743560cc83b9522c6fae2f5bdffb721bc0
EvheniiTkachuk/Lessons
/Lesson5/task1.py
460
4.125
4
# #The greatest number # Write a Python program to get the largest number from a list of random numbers with the length of 10 # Constraints: use only while loop and random module to generate numbers from random import randint as rand s = [] i = 1 while i <= 10: s.append(rand((10**9), (10**10) - 1)) ...
true
9a9f02d7d36150749820c11ad1815e1939c21fad
kookoowaa/Repository
/SNU/Python/코딩의 기술/zip 활용 (병렬).py
774
4.34375
4
### 병렬에서 루프문 보다는 zip 활용 names = ['Cecilia', 'Lise', 'Marie'] letters = [len(n) for n in names] longest_name = None max_letters = 0 # 루프문 활용 for i in range(len(names)): count = letters[i] if count > max_letters: longest_name = names[i] max_letters = count print(longest_name) print(max_letters) #...
true
fb57296132ee3c28d5940f746bbc1496e566c946
nidhi988/THE-SPARK-FOUNDATION
/task3.py
2,329
4.34375
4
#!/usr/bin/env python # coding: utf-8 # # Task 3: Predicting optimum number of clusters and representing it visually. # ## Author: Nidhi Lohani # We are using Kmeans clustering algorithm to get clusters. This is unsupervised algorithm. K defines the number of pre defined clusters that need to be created in the proce...
true
65d2ba3d984567002d83f04bbf0fa42ded16a5bb
dineshneela/class-98
/file.py
678
4.125
4
# program to read and open a file. #>>> f= open("test.txt") #>>> f.read() #'test filllles' #>>> f= open("test.txt") #>>> filelines=f.readlines() #>>> for line in filelines: #... print(line) #... #test filllles. somettttthing else # program to split the words in a string. #>>> introstring="my name is Di...
true
1a7c48054418adef604c72fa24c62904e6a41525
Oli-4ction/pythonprojects
/dectobinconv.py
556
4.15625
4
"""************************* Decimal to binary converter *************************""" #function def function(): #intialize variables number = 0 intermediateResult = 0 remainder = [] number = int(input("Enter your decimal number: ")) base = int(input("Choose the number format: ")) ...
true
cd0e31fec220f4c3e9a04262de709ed86c91e37f
posguy99/comp644-fall2020
/L3-12.py
270
4.125
4
# Create a while loop that will repetitively ask for a number. # If the number entered is 9999 stop the loop. while True: answer = int(input('Enter a number, 9999 to end: ')) if answer == 9999: break else: print('Your number was: ', answer)
true
266855d66e3b769f19350e5fa22af81c7b367811
stfuanu/Python
/basic/facto.py
268
4.125
4
num = input("Enter a number: ") num = int(num) x = 1 if num < 0: print("Factorial doesn't exist for -ve numbers") elif num == 0: print("Factorial of 0 is 1") else: for i in range(1,num + 1): x = x*i print("Factorial of",num,"is",x)
true
3ab084579276659c14fca1a6421903dc47227b27
jrngpar/PracticePython
/15 reverse word order.py
1,273
4.28125
4
#reverse word order #ask for a long string with multiple words #print it back with the words in backwards order #remove spaces? Maybe print back with words in reverse #2 functions, one to reverse order of words, one to reverse letters in words? #Can call both functions to reverse order and letters if wanted def rever...
true
1341c50fd7e58931c55c79478479d0b29deb0787
MrazTevin/100-days-of-Python-Challenges
/SolveQuiz1.py
695
4.15625
4
# function to determine leap year in the gregorian calendar # if a year is leap year, return Boolean true, otherwise return false # if the year can be evenly divided by 4, it's a leap year, unless: The year can be evenly divided by 100 it is# not a leap year,unless the year is also divisible by 400, then its a leap yea...
true
82573c7abbdd044e489e75c4b53f7840c10873ae
rdstroede-matc/pythonprogrammingscripts
/week5-files.py
978
4.28125
4
#!/usr/bin/env python3 """ Name: Ryan Stroede Email: rdstroede@madisoncollege.edu Description: Week 5 Files Assignment """ #1 with open("/etc/passwd", "r") as hFile: strFile = hFile.read() print(strFile) print("Type:",type(strFile)) print("Length:",len(strFile)) print("The len() function counts the numb...
true
1bdfad55963a5ca778fc06d402edc95abcf8fb16
stak21/DailyCoding
/codewarsCodeChallenge/5-anagram.py
1,300
4.28125
4
# Anagram # Requirements: # Write a function that returns a list of all the possible anagrams # given a word and a list of words to create the anagram with # Input: # 'abba', ['baab', 'abcd', 'baba', 'asaa'] => ['baab, 'baba'] # Process: # Thoughts - I would need to create every permutation of the given word...
true
aaad26766dbaf3819cebe370c7f5117283fd1630
HarithaPS21/Luminar_Python
/python_fundamentals/flow_of_controls/iterating_statements/while_loop.py
339
4.15625
4
# loop - to run a block of statements repeatedly # while loop -run a set of statements repeatedly until the condition becomes false #Syntax # while condition: # code # inc/dec operator a=0 while a<=10: print("hello") # prints "hello" 11 times a+=1 print("\nwhile decrement example") i=10 while i>0: ...
true
85b7319bc24340a96ce0e3a97791d6eee2643c32
Syconia/Harrow-CS13
/Stacks.py
1,611
4.125
4
# Stack class class Stack(): # Put in a list and set a limit. If limit is less than 0, it's basically infinitely large def __init__(self, List, INTlimit): self.Values = List if INTlimit < 0: INTlimit = 99999 self.Limit = INTlimit # Set up pointer. It's set by list in...
true
c353be9014cb341a5a04e1f55ef53661f88175ef
JoshTheBlack/Project-Euler-Solutions
/075.py
1,584
4.125
4
# coding=utf-8 '''It turns out that 12 cm is the smallest length of wire that can be bent to form an integer sided right angle triangle in exactly one way, but there are many more examples. 12 cm: (3,4,5) 24 cm: (6,8,10) 30 cm: (5,12,13) 36 cm: (9,12,15) 40 cm: (8,15,17) 48 cm: (12,16,20) In contrast, some lengths of...
true
c8509d347b9d8dce353f1e40f9ba2a1c4d3df4f2
RaviC19/Dictionaries_Python
/more_methods.py
625
4.375
4
# pop - removes the key-value pair from the dictionary that matches the key you enter d = dict(a=1, b=2, c=3) d.pop("a") print(d) # {'b': 2, 'c': 3} # popitem - removes and returns the last element (key, value) pair in a dictionary e = dict(a=1, b=2, c=3, d=4, e=5) e.popitem() print(e) # {'a': 1, 'b': 2, 'c': 3, 'd'...
true
44291c2c7fe818202a9d424139eba73e90dfd5ce
Jwbeiisk/daily-coding-problem
/mar-2021/Mar15.py
1,643
4.4375
4
#!/usr/bin/env python3 """ 15th Mar 2021. #558: Medium This problem was asked by Google. The area of a circle is defined as πr^2. Estimate π to 3 decimal places using a Monte Carlo method. Hint: The basic equation of a circle is x^2 + y^2 = r^2. """ """ Solution: We sample random points that would appear in the f...
true
f2c376ba14e0c328cc64f9985d080d4968a57431
Jwbeiisk/daily-coding-problem
/mar-2021/Mar10.py
1,667
4.5
4
#!/usr/bin/env python3 """ 10th Mar 2021. #553: Medium This problem was asked by Google. You are given an N by M 2D matrix of lowercase letters. Determine the minimum number of columns that can be removed to ensure that each row is ordered from top to bottom lexicographically. That is, the letter at each column is ...
true
14b70002c95cdd503190e523f840b543a272f481
Jwbeiisk/daily-coding-problem
/feb-2021/Feb17.py
1,784
4.40625
4
#!/usr/bin/env python3 """ 17th Feb 2021. #532: Medium This problem was asked by Google. On our special chessboard, two bishops attack each other if they share the same diagonal. This includes bishops that have another bishop located between them, i.e. bishops can attack through pieces. You are given N bishops, re...
true
f98b5090fbc532098ebbcd8026efae383bfcc507
Jwbeiisk/daily-coding-problem
/jan-2021/Jan30.py
1,092
4.34375
4
#!/usr/bin/env python3 """ 30th Jan 2021. #514: Medium This problem was asked by Microsoft. Given an unsorted array of integers, find the length of the longest consecutive elements sequence. For example, given [100, 4, 200, 1, 3, 2], the longest consecutive element sequence is [1, 2, 3, 4]. Return its length: 4. ...
true
e08c9f11aab1e0131d5f37feeb01f6475ae6ec23
Jwbeiisk/daily-coding-problem
/feb-2021/Feb22.py
1,107
4.3125
4
#!/usr/bin/env python3 """ 22th Feb 2021. #537: Easy This problem was asked by Apple. A Collatz sequence in mathematics can be defined as follows. Starting with any positive integer: if n is even, the next number in the sequence is n / 2 if n is odd, the next number in the sequence is 3n + 1 It is conjectu...
true
e72f31942b3077b838ec289bffcf5a22526eea40
priyakrisv/priya-m
/set17.py
400
4.1875
4
print("Enter 'x' for exit."); string1=input("enter first string to swap:"); if(string1=='x'): exit() string2=input("enter second string to swap:"); print("\nBoth string before swap:"); print("first string=",string1); print("second string=",string2); temp=string1; string1=string2; string2=temp; print("\nBoth string afte...
true
39959d08343f4ca027e3150e4a29186675a8ab2d
ramshaarshad/Algorithms
/number_swap.py
305
4.21875
4
''' Swap the value of two int variables without using a third variable ''' def number_swap(x,y): print x,y x = x+y y = x-y x = x-y print x,y number_swap(5.1,6.3) def number_swap_bit(x,y): print x,y x = x^y y = x^y x = x^y print x,y print '\n' number_swap_bit(5,6)
true
50ea487c9c3dd452fc4ed94cd86b223554b7afc2
rajivpaulsingh/python-codingbat
/List-2.py
2,799
4.5
4
# count_evens """ Return the number of even ints in the given array. Note: the % "mod" operator computes the remainder, e.g. 5 % 2 is 1. count_evens([2, 1, 2, 3, 4]) → 3 count_evens([2, 2, 0]) → 3 count_evens([1, 3, 5]) → 0 """ def count_evens(nums): count = 0 for element in nums: if element % 2 == 0: ...
true
4404e39852e74e7ca1ad170550b02fd3b09f76dd
wilsonbow/CP1404
/Prac03/gopher_population_simulator.py
1,190
4.5
4
""" This program will simulate the population of gophers over a ten year period. """ import random BIRTH_RATE_MIN = 10 # 10% BIRTH_RATE_MAX = 20 # 20% DEATH_RATE_MIN = 5 # 5% DEATH_RATE_MAX = 25 # 25% YEARS = 10 print("Welcome to the Gopher Population Simulator!") # Calculate births and deaths def gopher_births(po...
true
c1c268aa78f389abc625b582e37ba9316f36a849
AlfredPianist/holbertonschool-higher_level_programming
/0x06-python-classes/100-singly_linked_list.py
2,885
4.3125
4
#!/usr/bin/python3 # -*- coding: utf-8 -*- """100-singly_linked_list A Node class storing integers, and a Singly Linked List class implementing a sorted insertion. """ class Node: """A Node class. Stores a number and a type Node. Attributes: __data (int): The size of the square. __next_node (...
true
e62c99e0a88f67778b9573559d2de096255a3e2d
AlfredPianist/holbertonschool-higher_level_programming
/0x0B-python-input_output/2-append_write.py
479
4.28125
4
#!/usr/bin/python3 # -*- coding: utf-8 -*- """2-append_write This module has the function write_file which writes a text to a file. """ def append_write(filename="", text=""): """Writes some text to a file. Args: filename (str): The file name to be opened and read. text (str): The text to be ...
true
c51da4549dc5effcf1187071aaa8a55fbdd2be74
Herrj3026/CTI110
/P3HW2_DistanceTraveled_HerrJordan.py
888
4.34375
4
# # A program to do a basic calcuation of how far you travled # 6/22/2021 # CTI-110 P3HW2 - DistanceTraveled # Jordan Herr # #section for the inputs car_speed = float(input("Please enter car speed: ")) time_travled = float(input("Please enter distance travled: ")) #math section for the calculations dis_...
true
3cec4c83350a40b81dc8e58910b57ce3e5c5428d
SBrman/Project-Eular
/4.py
792
4.1875
4
#! python3 """ Largest palindrome product Problem 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 isPalindrome(num): num = str(...
true
9af7f0f7a29798891798048deea3137e95eca3f4
Jimmyopot/JimmyLeetcodeDev
/Easy/reverse_int.py
2,193
4.15625
4
''' - Given a signed 32-bit integer x, return x with its digits reversed. If reversing x causes the value to go outside the signed 32-bit integer range [-231, 231 - 1], then return 0. Assume the environment does not allow you to store 64-bit integers (signed or unsigned). ''' # soln 1 class Solution(object): ...
true
399cb2a542e995969b17089d75fb73b1018dc706
dspec12/real_python
/part1/chp05/invest.py
923
4.375
4
#!/usr/bin/env python3 ''' Write a script invest.py that will track the growing amount of an investment over time. This script includes an invest() function that takes three inputs: the initial investment amount, the annual compounding rate, and the total number of years to invest. So, the first line of the functio...
true
665ba4de4b55bc221d03af876d0c17a9d3b6e602
dspec12/real_python
/part1/chp05/5-2.py
928
4.46875
4
#!/usr/bin/env python3 #Write a for loop that prints out the integers 2 through 10, each on a new line, by using the range() function for n in range(2, 11): print("n = ", n) print("Loop Finished") """ Use a while loop that prints out the integers 2 through 10 (Hint: you'll need to create a new integer first; ther...
true
1e6aba46347bc53f8abe7a864d239759a1fd6f91
Coryf65/Python-Basics
/PythonBasics.py
807
4.1875
4
#Python uses Snake Case for naming conventions first_name = "Ada" last_name = "Lovelace" print("Hello," + first_name + " ") print(first_name + " " + last_name + " is an awesome person!") # print() automatically adds spaces print("These", "will be joined", "together by spaces!") # Python will save vars like JS kinda...
true
6338ec300caac0b9eeb18103ec9d35d12bb5d61b
mohsin-siddiqui/python_practice
/lpth_exercise/MyRandomPrograms/areaOfCircle.py
238
4.21875
4
pi = 22/7 R = input("Please Enter the Radius of the Circle(in meter):\n") # R stands for Radius of the circle A = pi * float(R) ** 2 # A stands for Area of the circle print("The required Area of the circle is :",round(A),"square-meters")
true
41c9edbb34832ccd2fc656a366bd89103b171e67
arl9kin/Python_data
/Tasks/file_function_questions.py
2,256
4.25
4
''' Question 1 Create a function that will calculate the sum of two numbers. Call it sum_two. ''' # def sum_two(a, b): # c = a + b # print (c) # sum_two (3,4) ''' Question 2 Write a function that performs multiplication of two arguments. By default the function should multiply the first argument by 2. Call it...
true
348dc81dd001a621ab8fe2f5cf970a86981f6294
letugade/Code-Club-UWCSEA
/Python/Lesson01/Lesson01.py
508
4.21875
4
# Printing print("Hello world") # Variables a = 3 # Printing variables print("The value of a is", a) # User input name = input("What is your name? ") print("Hello", name) # Conditional statements if name == "Bob": print("Your name is Bob") elif name == "John": print("Your name is John") else: print("Your name is...
true
d8fd66f43d8a296a435c9bc94d0c79a67249abc9
rmwenzel/project_euler
/p1/p1.py
286
4.15625
4
#!usr/bin/python import numpy as np def sum_multiples(n): """Sum multiples of 3 or 5 that are < n.""" def f(x): return x if (x % 3 == 0 or x % 5 == 0) else 0 return sum(np.array(list(map(f, np.arange(1, n))))) if __name__ == "__main__": sum_multiples(1000)
true
5bc2ead9259f699053de317c62b911bc86f75e3f
vivek-x-jha/Python-Concepts
/lessons/cs14_decorators_args.py
713
4.3125
4
""" Python Tutorial: Decorators With Arguments https://youtu.be/KlBPCzcQNU8 """ def prefix_decorator(prefix): def decorator_function(original_function): def wrapper_function(*args, **kwargs): print(prefix, 'Executed Before', original_function.__name__) result = original_function(*a...
true
564cb1318d466a5eeb2fbe7a7825380de3227322
prasannakumar2495/QA-Master
/pythonPractice/samplePractice/IFcondition.py
786
4.3125
4
''' Created on 25-Dec-2018 @author: prasannakumar ''' number = False string = False if number or string: print('either of the above statements are true') else: print('neither of the above statements are true') if number: print('either of the above statements are true') elif not(string) and number: p...
true
ea1f557a5eee486e0afd435d1eb339dd40caad0e
sis00337/BCIT-CST-Term-1-Programming-Methods
/02. Three Short Functions/create_name.py
891
4.375
4
""" Author: Min Soo Hwang Github ID: Delivery_KiKi """ import random import string def create_name(length): """ Check if length of a name is less than or equal to 0. :param length: an integer that indicates the length of a name :return: the result of the function named create_random_name """ ...
true
9e80ca85c78c6ccba160eb3ce0a7e60ab1e49392
DavidAlen123/Radius-of-a-circle
/Radius of a circle.py
255
4.25
4
# -*- coding: utf-8 -*- """ Created on Tue May 11 07:15:17 2021 @author: DAVID ALEN """ from math import pi r = float(input ("Input the radius of the circle : ")) print ("The area of the circle with radius " + str(r) + " is: " + str(pi * r**2))
true
100cf26661e730aa38efa2852aaa63e87067bac4
4anajnaz/Devops-python
/largestnumber.py
460
4.375
4
#Python program to find largest number try: num1= input("Enter first number") num2= input("Enter second number"); num3= input("Enter third number"); if (num1>num2) and (num1>num3): largest = num1 elif (num2>num1) and (num2>num3): largest = num2 else: largest =...
true
126fac3aba52940e7c6d68b6469b33a3687ec2fb
aaron-lee/mathmodule
/from math import constant.py
257
4.15625
4
from math import pi #importing only the pi constant from the module def circumference(radius): circum = 2*pi*radius #circumference formula return circum print("The circumference of circle with radius 20 is %f" % circumference(20))
true
1eba38a72a5777e42e51f82ad189db3764ca7689
teamneem/pythonclass
/Projects/proj02.py
2,144
4.65625
5
#/**************************************************************************** # Section ? # Computer Project #2 #****************************************************************************/ #Program to draw a pentagon import turtle import math print 'This program will draw a congruent pentagon. Th...
true
99c3e82a14d1eb3a0fa1419a10d07812937784a0
caiopetreanu/PythonMachineLearningForTradingCourseCodes
/_py/01-01_to_01-03/14_numpy_arrays_random_values.py
1,172
4.125
4
""" Generating random numbers. """ import numpy import numpy as np def run(): # generate an array full of random numbers, uniformly sampled from [0.0, 1.0) print("pass in a size tuple", np.random.random((5, 4))) # pass in a size tuple print("function arguments (not a tuple)", np.random.rand(5, 4)) # func...
true
7c8cb97e1b50b85c8a7d5ec746a2b6c58bfee416
chav-aniket/cs1531
/labs/20T1-cs1531-lab05/encapsulate.py
695
4.5
4
''' Lab05 Exercise 7 ''' import datetime class Student: ''' Creates a student object with name, birth year and class age method ''' def __init__(self, firstName, lastName, birth_year): self.name = firstName + " " + lastName self.birth_year = birth_year def age(self): ''...
true
c961c1845e80e88496fefbb12ff75ab957c59e1a
mdadil98/Python_Assignment
/21.py
323
4.53125
5
# Python3 program to print all numbers # between 1 to N in reverse order # Recursive function to print # from N to 1 def PrintReverseOrder(N): for i in range(N, 0, -1): print(i, end=" ") # Driver code if __name__ == '__main__': N = 5; PrintReverseOrder(N); # This code is contributed by 29AjayKum...
true
bd7b188ddcb0026ce6c83a6ac7323b441ccc42a5
brohum10/python_code
/daniel_liang/chapter06/6.12.py
1,190
4.40625
4
#Defining the function 'printChars' def printChars(ch1, ch2, numberPerLine): #y is a variable storing the count of #elements printed on the screen #as we have to print only a given number of characters per line y=0 #Running a for loop #'ord' function returns the ASCII value o...
true
7bbecf05287d5a11f158524c18c01143f42d534c
MantaXXX/python
/6- while/6-1.py
205
4.28125
4
# For a given integer N, print all the squares of positive integers where the square is less than or equal to N, in ascending order. n = int(input()) i = 1 while i**2 <= n: print(i**2, end=' ') i += 1
true
4a902e6c95a8b980fbcf6ca3193bbc2af259988c
MantaXXX/python
/3- if else /3.A.py
392
4.15625
4
# Given three integers. Determine how many of them are equal to each other. The program must print one of the numbers: 3 (if all are same), 2 (if two of them are equal to each other and the third one is different) or 0 (if all numbers are different). a = int(input()) b = int(input()) c = int(input()) if a == b == c: ...
true
6c8b2745c7e34271a007e2ecaaf634938cd3b851
johnmarcampbell/concord
/concord/member.py
956
4.25
4
class Member(object): """This object represents one member of congress""" def __init__(self, last_name='', first_name='', middle_name='', bioguide_id='', birth_year='', death_year='', appointments=[]): """Set some values""" self.last_name = last_name self.first_name = first_nam...
true
62cd51f8869cda6893e815f3508fc07b61f7e91f
andelgado53/interviewProblems
/order_three_colors.py
971
4.15625
4
# Problem Statement: # You are given n balls. Each of these balls are of one the three colors: Red, Green and Blue. # They are arranged randomly in a line. Your task is to rearrange them such that all # balls of the same color are together and their collective color groups are in this order: # Red balls first, Green...
true
e5376089499f5bce5631b85ee1581a57451f0cb2
andelgado53/interviewProblems
/zig_zag_conversion.py
2,140
4.15625
4
import pprint # The string "PAYPALISHIRING" is written in a zigzag pattern on a given number of rows like this: # (you may want to display this pattern in a fixed font for better legibility) # # P A H N # A P L S I I G # Y I R # And then read line by line: "PAHNAPLSIIGYIR" # # Write the code that will take a ...
true
a9ca7660d5daf407247efa3219bde5714591e492
sanket-qp/IK
/4-Trees/invert_binary_tree.py
1,141
4.3125
4
""" You are given root node of a binary tree T. You need to modify that tree in place, transform it into the mirror image of the initial tree T. https://medium.com/@theodoreyoong/coding-short-inverting-a-binary-tree-in-python-f178e50e4dac ______8______ / \ 1 __16 ...
true
df7b73944b7b1d4676d64edafeb1c3cbc976d483
sanket-qp/IK
/3-Recursion/power.py
1,109
4.1875
4
""" The problem statement is straight forward. Given a base 'a' and an exponent 'b'. Your task is to find a^b. The value could be large enough. So, calculate a^b % 1000000007. Approach: keep dividing the exponent by two pow(2, 8) will be handled as follows 2x2x2x2 x 2x2x2x2 ...
true