blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
5e5e7df63660f904a45f4350df321e9ce8d600c0
tbeaux18/rosalind
/point_mutation.py
1,127
4.34375
4
#!/usr/bin/env python3 """ @author: Timothy Baker @version: 01/15/2019 Counting Point Mutations Rosalind Input: Standard Input Output: Console """ import sys def hamming_distance(sequence_one, sequence_two): """ Calculates hamming distance between 2 strings Args: sequence_one (str) ...
true
22cfe29daf5a9adca5e908e8c4fda15132536133
sapalamut/homework
/ClassWork_4.py
1,764
4.25
4
# FUNCTIONS # Ex:1 def add_two_numbers(num1, num2): return num1 + num2 result = add_two_numbers(1, 2) print(result) print(add_two_numbers(1, 2)) first = 1 second = 2 third = 3 print(add_two_numbers(first, second), add_two_numbers(second, third)) print('\n') # Ex:2 def print_hello_world(): print("Hello Wolrd") print...
true
5766534c0e915f055d9fdfe3d2451303ddfbc1d7
zs18034pn/ORS-PA-18-Homework07
/task2.py
727
4.375
4
""" =================== TASK 2 ==================== * Name: Recursive Sum * * Write a recursive function that will sum given * list of integer numbers. * * Note: Please describe in details possible cases * in which your solution might not work. * * Use main() function to test your solution. ========================...
true
bbf65e88dffba753cd3ae13fef8d76c2e6439692
CodeBall/Learn-Python-The-Hard-Way
/yanzilu/ex32.py
2,647
4.4375
4
# -*- coding: utf-8 -*- #Exercise 32:Loops and List the_count = [1,2,3,4,5] fruits = ['apples','oranges','pears','banana'] change = [1,'pennies',2,'dimes',3,'quarters'] print "change[0]: ", change[0] print "change[2:5]: ", change[2:5] #this first kind of for-loop goes through a list for number in the_count: print "...
true
7b7ea0f2690579220e1dd50f8151e0214c950ec8
hxsnow10/BrainNN
/SORN/general_model.py
2,398
4.15625
4
'''一个general的RNN 应该定义的计算结构 ''' class RNN(SimpleRecurrent): ''' some abstract model to define structural RNN. abstracts of RNN is dynamic systems, all variables has it's dynamics, \ when in NN some as states some as weights. when NN become more complex, for example biology models, LSTM, multi\ ...
true
14211c899a064cff7330fba2bd74711c4dc0dda6
monkeesuit/Intro-To-Python
/scripts/trialdivision.py
479
4.15625
4
num = int(input('Enter a numer to be check for primality: ')) ceiling = int(pow(num, .5)) + 1 # Get ceiling of sqaure root of number (b/c of how range works for i in range(2, ceiling): if (num % i == 0): # if any number between 2 and ceiling-1 divides num print('{} is composite'.format(num)) ...
true
924e46c90bc31ed5fd44ccc3da128734d006fb1a
martincxx/PythonPlay
/PythonforAstronomers/exercise2.py
356
4.125
4
"""2. Write a function that takes a character (i.e. a string of length 1) and returns True if it is a vowel, False otherwise. 2.1. Use the module re (regular expressions)""" def find_m(word): import re if re.match("[aeiou]$",word.lower()): return True else: return False print find_m("A") ...
true
0902f72d26a0a9cc71e41dfa76f0b5b7e62bf07e
poojan14/Python-Practice
/GeeksForGeeks/Good or Bad string.py
1,378
4.125
4
''' In this problem, a String S is composed of lowercase alphabets and wildcard characters i.e. '?'. Here, '?' can be replaced by any of the lowercase alphabets. Now you have to classify the given String on the basis of following rules: If there are more than 3 consonants together or more than 5 vowels together, the S...
true
def77432cc97bb70a22c8e37b0e237b05f3dbb9e
poojan14/Python-Practice
/Data Structures and File Processing/Heap/Heap_Class.py
2,756
4.25
4
import math class Heap: heap=[] def __init__(self): ''' Objective : To initialize an empty heap. Input parameters : self : Object of class Heap. Output : None ''' #Approach : Heap is an empty list. self.heap=[] def ...
true
617d3cdc74bcc4d7f1cd3489881efb9da784dfcc
bilaer/Algorithm-And-Data-Structure-Practices-in-Python
/heap_sort.py
1,922
4.25
4
#################################### # Heap Sort # # ################################## # # # Max_heapify: O(lgn) # # Build_max_heap: O(n) # # Overall performance is O(nlgn) # # # ########################...
true
1be2eb9e19b8341b6622460623edd22664d8f5f2
pawloxx/CodeWars
/CreditCardValidifier.py
1,340
4.34375
4
""" Make a program that sees if a credit card number is valid or not. Also the program should tell you what type of credit card it is if it is valid. The five things you should consider in your program is: AMEX, Discover, VISA, Master, and Invalid : Discover starts with 6011 and has 16 digits, AMEX starts with 34 or 37...
true
1721135b50b49c0cfb109712ce9355a7695bb438
Jaykb123/jay
/jay1.py
831
4.5
4
print("To check the greater number from the given number!".center(70,'-')) # To take a numbers as an input from the user. first_num = int(input("Enter the first number: ")) second_num = int(input("Enter the second number: ")) third_num = int(input("Enter the third number: ")) # To check among the num...
true
8f711d9c3fd1c55bad77a4a1980c5d6a4bea22c6
tusharpl/python_tutorial
/max_value_function.py
502
4.125
4
# Get the list of values ..here it is student scores student_scores = input("Enter the list of student scores").split() # change str to integer so that calculations can be done for n in range(0, len(student_scores)): student_scores[n] = int(student_scores[n]) print(student_scores) # find max value through iterat...
true
ff508760139b4197b86726ac82a698f82ae8caec
QasimK/Project-Euler-Python
/src/problems/p_1_49/p19.py
2,544
4.28125
4
''' You are given the following information, but you may prefer to do some research for yourself. * 1 Jan 1900 was a Monday. * Thirty days has September, April, June and November. All the rest have thirty-one, Saving February alone, Which has twenty-eight, rain or shine. And on le...
true
b108c2c7de3669c11c6e765d6e213619aa3d91fe
QasimK/Project-Euler-Python
/src/problems/p_1_49/p23.py
2,656
4.125
4
''' A perfect number is a number for which the sum of its proper divisors is exactly equal to the number. For example, the sum of the proper divisors of 28 would be 1 + 2 + 4 + 7 + 14 = 28, which means that 28 is a perfect number. A number n is called deficient if the sum of its proper divisors is less than n and it i...
true
ed0baab15b160004bc09324389f4b13c2a927266
sap218/python
/csm0120/02/lect_02b_hw.py
663
4.125
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Thu Oct 12 11:03:24 2017 @author: sap21 """ ''' An interactive game to exercise what you know about variables, if statements, loops and input/output. Game: Guess the secret number! ● Initialise a variable to hold a secret number of your choice. ● Prompt th...
true
5c773bead4c91bd8a50fb5441f9631cbe9edc027
yurizirkov/PythonOM
/if.py
657
4.125
4
answer = input("Do you want to hear a joke?") #affirmative_responses = ["Yes", "yes", "y"] #negative_responses = ["No", "no", "n"] #if answer.lower() in affirmative_responses: #print("I am against picketing, but I do not know how to show it.") #elif answer.lower() in negative_responses: #print("Fine") #i...
true
b40fa3ed7cfd83a46f24eaa9fbcc05b5ad35dee3
Xigua2011/mu_code
/names.py
278
4.28125
4
name = input("What is your name?") print("Hello", name) if name=="James": print("Your name is James. That is a silly name") elif name=="Richard": print("That is a good name.") elif name=="Anni": print("Thats a stupid name") else: print("I do not know your name")
true
628e319d65d3dd83d540ab326913f2bb62cca265
shivveerq/python
/replacementop.py
430
4.25
4
name="shiva" salary=15000 gf="sunny" print("Hello {0} your salary is {1} and your girlfriend waiting {2}".format(name,salary,gf)) # wint index print("Hello {} your salary is {} and your girlfriend waiting {}".format(name,salary,gf)) print("Hello {x} your salary is {y} and your girlfriend waiting {z}".format(x=na...
true
b4c433ee6ddb5c5f1e04c27963d9b56ce104ce87
pavarotti305/python-training
/while_loop.py
599
4.125
4
print('') print("Use while with modulus this expression for x in xrange(2, 21): is the same as i = 2 while i < 21:") i = 2 while i < 21: print(i) stop10 = i == 10 if i % 2 != 0: break if stop10: break i += 2 print('') print("Same code with for") for x in range(2, 21): if x % 2 =...
true
a37de490c4738e54d1f68f6194af7c2a47c96969
pavarotti305/python-training
/if_else_then.py
2,994
4.4375
4
print('') print('''Here is the structure: if expression: like on this example if var1 is true that means = 1 print the value of true expression statement(s) else: else var1 is false that means = 0 print the value of false expression statement(s)''') truevalue = 1 if truevalue: print("1 - Got a true expression valu...
true
f62f9f153a2b413d32bf07f4cd9e660e4adfcfea
SaurabhRuikar/CdacRepo
/Python and Advanced Analytics/Lab Practice/ConsonantReplace.py
1,176
4.15625
4
''' Q. 1. Given a dictionary of students and their favourite colours: people={'Arham':'Blue','Lisa':'Yellow',''Vinod:'Purple','Jenny':'Pink'} 1. Find out how many students are in the list 2. Change Lisa’s favourite colour 3. Remove 'Jenny' and her favourite colour 4. Sort and print students and their favourite colours ...
true
8ee6a5e0a13f0db31fdae73f1492ba225a6c480d
SaurabhRuikar/CdacRepo
/Python and Advanced Analytics/Advanced Analytics/libraries3.py
1,819
4.125
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Sat Dec 7 17:19:54 2019 @author: student """ import sys import numpy as np def createArange(): r1=int(input("Enter the number of rows for matrix A ")) c1=int(input("Enter the number of column for matrix A ")) m1=r1*c1 a=np.arange(m1).re...
true
14e688e1b7f4f8116a1ac43140a8bb508bcfa392
SaurabhRuikar/CdacRepo
/Python and Advanced Analytics/Database/sqlite3/database.py
2,039
4.21875
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Fri Dec 6 12:27:14 2019 @author: student """ import sqlite3 import sys db=sqlite3.connect('mydb1.db') #Connecting to database if db!=None: print("Connection done") else: print("Connection not done") cursor=db.cursor() #cursor generate some...
true
92799c5dad508dbe76b9a231dc82cfa22e01b7f5
erferguson/CodeWars
/9.13.20/kata.py
1,639
4.15625
4
# 8kyu # This kata is from check py.checkio.org # You are given an array with positive numbers and a number N. # You should find the N-th power of the element in the array with the index N. # If N is outside of the array, then return -1. # Don't forget that the first element has the index 0. # Let's look at a f...
true
1c44e33f725fbc0d5268277482ce1c001c614025
rkidwell2/teachingPython
/HowManyCows.py
1,444
4.21875
4
""" Rosalind Kidwell 6/26/19 This program creates an interactive riddle for the cow game, and is being used to demonstrate python fundamentals for high school students """ import random from time import sleep def cows(): print('') myList = [[0, "? "], [2, "How many? "], [3, "How ma...
true
389b2826c6f9ab6a0ab39423ff8a7c66311f05e7
em0flaming0/Mock-Database
/mock_db.py
1,075
4.34375
4
#!/usr/bin/python #demonstrating basic use of classes and inheritance class Automobile(object): def __init__(self, wheels): self.wheels = wheels #all autmobiles have wheels class Car(Automobile): def __init__(self, make, model, year, color): Automobile.__init__(self, "4") #all Car objects should have 4 whee...
true
6cdc61e07a9a2a52d7c07a5a48570e4f2d80c0ce
aliamjad1/Data-Structure-Fall-2020
/BubbleSorting.py
571
4.28125
4
##It compares every index like [2,1,4,3]-------Firstly 2 compare with 1 bcz of greater 1 is moved towards left and 2 is on right # [1,2,4,3] def bubblesort(list): listed=len(list) isSorted=False while not isSorted: isSorted=True for eachvalue in range(0,listed-1): if list[eac...
true
4a117edd4e73e2a8830804061c0f3e61a7ea4865
trademark152/Data_Mining_USC
/hw5/test.py
1,156
4.15625
4
import re import random def isprime(num): # If given number is greater than 1 if num > 1: # Iterate from 2 to n / 2 for i in range(2, num // 2): # If num is divisible by any number between # 2 and n / 2, it is not prime if (num % i) == 0: retu...
true
8b398401d12c5c9470dabcf3acf682e91aa3520a
RokKrivicic/webdevelopment2
/Homeworks/homework1.py
840
4.21875
4
from smartninja_sql.sqlite import SQLiteDatabase db = SQLiteDatabase("Chinook_Sqlite.sqlite") # all tables in the database db.print_tables(verbose=True) #This database has many tables. Write an SQL command that will print Name # from the table Artist (for all the database entries) db.pretty_print("SELECT Name FROM A...
true
a1675e46df676847b8576ef35a2ef5bf95061fab
Omisw/Python_100_days
/Day 3/leap_year.py
950
4.53125
5
# Day 3 - Third exercise. # Leap Year # Instructions # Write a program that works out whether if a given year is a leap year. A normal year has 365 days, leap years have 366, with an extra day in February. # The reason why we have leap years is really fascinating, this video does it more justice: # This ...
true
93dc5203b837b3ce41dd6df3051f1e8446113245
Omisw/Python_100_days
/Day 10/Calculator/main.py
1,438
4.1875
4
# Day 10 - Final challenge. from art import logo # from replit import clear def add(number_1, number_2): return number_1 + number_2 def subtract(number_1, number_2): return number_1 - number_2 def multiply(number_1, number_2): return number_1 * number_2 def divide(number_1, number_2): return number_1 / numbe...
true
24c5920330ecb18cad06ee63444aa9432ad58dfc
Omisw/Python_100_days
/Day 9/dictionary_in_list.py
1,258
4.5
4
# Day 9 - Second exercise. # Dictionary in List # Instructions # You are going to write a program that adds to a travel_log. You can see a travel_log which is a List that contains 2 Dictionaries. # Write a function that will work with the following line of code on line 21 to add the entry for Russia to the travel_l...
true
498e80a75aa31b4bad5652b9cebc4f0c11dfeb7a
Omisw/Python_100_days
/Day 9/grading_program.py
1,517
4.65625
5
# Day 9 - First exercise. # Instructions # You have access to a database of student_scores in the format of a dictionary. The keys in student_scores are the names of the students and the values are their exam scores. # Write a program that converts their scores to grades. By the end of your program, you should have ...
true
62d5ab70daaf6ea89567f6e2e3903f481401dc29
eddieatkinson/Python101
/guess_num_high_low.py
421
4.25
4
# Guess the number! Gives clues as to whether the guess is too high or too low. secret_number = 5 guess = 2 print "I'm thinking of a number between 1 and 10." while secret_number != guess: print "What's the number?" guess = int(raw_input("> ")) if (guess > secret_number): print "%d is too high. Try again!" % guess...
true
1fb3875553dd99fb89943a9c954029f1d0213877
saddamarbaa/object-oriented-programming-concepts
/Intro OOP1.py
1,187
4.4375
4
# Object Oriented Programming # Class and Object in Python # Robot class class Robot: # instance attribute def __init__(self, name, color, weight): self.name = name self.color = color self.weight = weight # instance method def introduce_self(self): print(...
true
92d3eeecb0efceb24b34a7f87488d3296c7d99de
lelongrvp/Special_Subject_01
/homeword_2/problem3.py
1,856
4.53125
5
# Obtain phone number from user and split it into 3 parts phone_number = input('Enter a phone number using the format XXX-XXX-XXXX: ') split_number = phone_number.split('-') #initializing some control variables weird_character = False # True will stop while loop and display an error count = 0 # Keeps tra...
true
44746aec5d7405051b68ec4f1ead570f57e57ce0
tnovak123/hello-spring
/crypto/caesar.py
567
4.1875
4
from helpers import rotate_character, alphabet_position def encrypt(text, rot): newtext = "" for char in text: if char.isalpha() == True: newtext += rotate_character(char, rot) else: newtext += char return(newtext) def main(): inputtext = "" displace = 0 inputtext...
true
d6c30d2048e7e815b9550b05e2abe1966c7d4332
probuse/prime_numbers
/prime_numbers_.py
810
4.15625
4
def prime_numbers(n): "Generate prime numbers between 0 and n" while isinstance(n, int) and n > 0: prime = [] def is_prime(number): "Tests if number is prime" if number == 1 or number == 0: return False for num in range(2, number): ...
true
2d195bd9e64a571692a80213e75beddf8235052c
ironboxer/leetcode
/python/214.py
983
4.15625
4
""" https://leetcode.com/problems/shortest-palindrome/ Given a string s, you are allowed to convert it to a palindrome by adding characters in front of it. Find and return the shortest palindrome you can find by performing this transformation. Example 1: Input: "aacecaaa" Output: "aaacecaaa" Example 2: Input: "abc...
true
bc509ad8e8375270c803a118c24746d45af97088
ironboxer/leetcode
/python/49.py
1,050
4.1875
4
""" https://leetcode.com/problems/group-anagrams/ Given an array of strings strs, group the anagrams together. You can return the answer in any order. An Anagram is a word or phrase formed by rearranging the letters of a different word or phrase, typically using all the original letters exactly once. Example 1: In...
true
9b79ae5a9eaadcef2a1be81c479ca9675c0d3553
ironboxer/leetcode
/python/231.py
652
4.125
4
""" https://leetcode.com/problems/power-of-two/ Given an integer, write a function to determine if it is a power of two. Example 1: Input: 1 Output: true Explanation: 20 = 1 Example 2: Input: 16 Output: true Explanation: 24 = 16 Example 3: Input: 218 Output: false """ class Solution: def isPowerOfTwo(self,...
true
9e4fc7517fbe8fd3e2f9c68694b0692e5ad0eef4
Steven4869/Simple-Python-Projects
/excercise21.py
434
4.25
4
#Amstrong number print("Welcome to Amstrong number checker, if the number's sum is same as the sum of the cubes of respective digits then it is called Amstrong number") a=int(input("Please enter your number\n")) sum=0 temp=a while(temp >0): b=temp%10 sum+=b **3 temp//=10 if(a==sum): print(a,"is an Amstr...
true
a92a5371ecbf8a8b7e80695f1935ea44606983fb
davidholmes1999/first-project1
/Holmes_numbergenerator.py
892
4.15625
4
#David Holmes #3/9/17 #Number Simulator #Print Statements print("\nWeclome to the number simulator game! You will be seeing how many guesses it takes for you to guess my number!\n") print("\nFirst let me think of a number between 1 and 100\n") print("\nHmmmmmm...\n") import random #Defining Variables ...
true
fd74144669b2dfb6dd3ad08b4ad8f029d817b0d3
Dexmo/pypy
/playground.py
1,126
4.21875
4
values = (1,2,3,4,5) #tuple - immutable, orderly data structure squares = [value**2 for value in range(1,11)] #list comprehension ''' 3 short subprogram for quick work ''' print(max(values)) print(min(values)) print(sum(values)) print(squares) '''---------------------------------------''' for number in range(1, 21): ...
true
956fd0812e6565fa8f6843af933c225e7ae22a7c
emailman/Raspberry_Pi_Heater
/sorted grades/function demo.py
647
4.15625
4
def rectangle_calc(x, y): area = x * y perimeter = 2 * (x + y) return area, perimeter def main(): try: length = float(input("Enter the length of a rectangle: ")) width = float(input("Enter the width of a rectangle: ")) units = input("Enter the units: ") area_, perimet...
true
39028abf4600601082d0c7f24f718739f5e77c3a
queenskid/MyCode
/labs/introfor/forloop2.py
542
4.15625
4
#!/usr/bin/env python3 # 2 seprate list of vendors vendors = ['cisco', 'juniper', 'big_ip', 'f5', 'arista', 'alta3', 'zach', 'stuart'] approved_vendors = ['cisco', 'juniper', 'big_ip'] # for loop going through list of vendors and printing to screen with a conditional statement. for x in vendors: print("\nThe ven...
true
bf40a829a9887f981a48f429835956a807d3cf03
cowsertm1/Python-Assignments
/functions-and-collections.py
2,974
4.6875
5
""" As we saw in class, in Python arguments passed to a function are treatedly differently depending on whether they are a "normal" variable or a collection. In this file we will go over some additional examples so that you get used to this behavior: 1. Write a program that assigns some value to a global variable ca...
true
0b9802a4b4ecc2823db5761773af068cad2d0e56
davifelix5/design-patterns-python
/structurals/adapter/adapter.py
2,102
4.3125
4
""" Serve par ligar duas classes diferentes """ from abc import ABC, abstractmethod class iGameControl(ABC): @abstractmethod def left(self) -> None: pass @abstractmethod def right(self) -> None: pass @abstractmethod def down(self) -> None: pass @abstractmethod def up(self) -> N...
true
7bfd6160f69605ad5009e8baca3c065aa739b1d0
joyrexus/nst
/misc/poset.py
2,638
4.1875
4
''' In NST Sect 14 (p. 57) Halmos gives three examples of partially ordered sets with amusing properties to illustrate the various possibilities in their behavior. Here we aim to define less_than functions for each example. Each function should return a negative value if its first argument is "less than" its second,...
true
8be7ea60b1cd7f0ce2ab030b7d25c63b257a686a
MarcusGraetsch/awsrestart
/Exercise_1_ConvertHourintoSeconds.py
295
4.34375
4
hours = input("How many hours to you want to convert into seconds? ") hours = int(hours) seconds = hours*3600 print("{} hours are {} seconds!".format(hours, seconds)) print("Now with usage of a function") def convert_hours (hrs): sec = hrs * 3600 print(f"{hrs} are {sec}") convert_hours(8)
true
eccc6cac4824435c77a7d706f555976b788e7446
thinkingape46/Full-Stack-Web-Technologies
/Python/regular_expressions.py
798
4.28125
4
# Regular expressions # Import regular expressions import re # mytext = "I am from Earth" # USING REGULAR EXPRESSIONS TO FIND THE MATCH # if re.search("Earth", mytext): # print("MATCH found") # else: # print("MATCH not found") # x = re.search("Earth", mytext) # FIND THE START AND END INDEX OF THE MATCH ...
true
0f76462a6eca506d11f58d6f1314a1a175ddfd5f
AdamJSoftware/iti1120
/assignments/A2/a2_part2_300166171.py
1,935
4.21875
4
# Family name: Adam Jasniewicz # Student number: 300166171 # Course: ITI 1120 # Assignment Number 2 # year 2020 ######################## # Question 2.1 ######################## def min_enclosing_rectangle(radius, x, y): ''' (Number, Number, Number) -> (Number, Number) Description: Calculates the x and ...
true
7f2c16d15d19183ceabdbcd7ea311bc4f4c27838
ph4ge/ost-python
/python1_Lesson06/src/word_frequency.py
456
4.125
4
"""Count the number of different words in a text.""" text = """\ Baa, baa, black sheep, Have you any wool? Yes sir, yes sir, Three bags full; One for the master, And one for the dame, And one for the little boy Who lives down the lane.""" for punc in ",?;.": text = text.replace(punc, "") freq = {} ...
true
17e0981af5496c8fe8a3c05e7d2ef15b2681064e
Benkimeric/number-game
/number_guess.py
863
4.1875
4
import random def main(): global randomNumber randomNumber = random.randrange(1, 101) # print(randomNumber) number = int(input("I have generated a Random number between 1 and 100, please guess it: ")) guess(number) # guess method with while loop to loop when user does not give correct guess def ...
true
63c90181fe378d9bb9093d8395ba0f1f147daf26
shwesinhtay111/Python-Study-Step1
/list.py
1,501
4.53125
5
# Create list my_list = [1, 2, 3] print(my_list) # lists can actually hold different object types my_list = ['A string', 23, 100.22, 'o'] print(my_list) # len() function will tell you how many items are in the sequence of the list print(len(my_list)) # Indexing and Slicing my_list = ['one','two','three',4,5] print(m...
true
723cfd942791ed9266f240781f58118cb30ddea9
shwesinhtay111/Python-Study-Step1
/abstract_class.py
1,280
4.6875
5
# abstract class is one that never expects to be instantiated. For example, we will never have an Animal object, only Dog and Cat objects, although Dogs and Cats are derived from Animals class Animal: def __init__(self, name): # Constructor of the class self.name = name def speak(self): ...
true
3d20fa99eae7df1270b21c6a08bd3cc5d6adb375
ocmadin/molssi_devops
/util.py
694
4.4375
4
""" util.py A file containing utility functions. """ def title_case(sentence): """ Convert a string into title case. Title case means that the first letter of each word is capitalized with all other letter lower case Parameters ---------- sentence : str String to be converted int...
true
12f4625a421f85e40f4ab2700795fceb8e53acad
TLTerry23/CS30practice
/CS_Solutions/Thonnysolutions/3.3.2Area_of_figures.py
791
4.4375
4
# Area Calculator # Put Your Name Here # Put the Date Here choice=input("What do you want to find the area of? Choose 1 for rectangle, 2 for circle, or 3 for triangle.") if choice=='1': rectangle_width=float(input("What is the width of your rectangle?")) rectangle_height=float(input("What is the length of your...
true
a2781049e4ac8d2f94355326498919ad5501cd25
brettmadrid/Algorithms
/recipe_batches/recipe_batches.py
1,409
4.25
4
#!/usr/bin/python import math def recipe_batches(recipe, ingredients): batches = math.inf ''' First check to see if there are enough ingredients to satisfy the recipe requirements ''' if len(recipe) > len(ingredients): return 0 ''' Now check to see if there are enough of each i...
true
f8fa6b77b71bd50acf2cbddeff370e0b2709d3bf
barvaliyavishal/DataStructure
/Cracking the Coding Interview Exercises/Linked Lists/SinglyLinkedList/RemoveDups.py
741
4.3125
4
from LinkedList import LinkedList class RemoveDuplicates: # Remove duplicates Using O(n) def removeDuplicates(self, h): if h is None: return current = h seen = set([current.data]) while current.next: if current.next.data in seen: curren...
true
983b106ab6e4e093ee330866707bd6e35b7df3da
barvaliyavishal/DataStructure
/Cracking the Coding Interview Exercises/Linked Lists/SinglyLinkedList/removeDuplicates.py
766
4.25
4
from LinkedList import LinkedList class RemoveDuplicates: # Remove duplicates Using O(n^2) def removeDuplicates(self, head): if head.data is None: return temp = head while temp.next: start = temp while start.next: if start.next.data ...
true
923aafcb9147d70e62d8512fabb477b5a8365a5e
garciaha/DE_daily_challenges
/2020-08-13/eadibitan.py
1,788
4.15625
4
"""Eadibitan You're creating a conlang called Eadibitan. But you're too lazy to come up with your own phonology, grammar and orthography. So you've decided to automatize the proccess. Write a function that translates an English word into Eadibitan. English syllables should be analysed according to the following rule...
true
85051a8cef826a0fb73dfc66172c8f588dc3433f
garciaha/DE_daily_challenges
/2020-07-09/maximize.py
1,015
4.1875
4
""" Maximize Write a function that makes the first number as large as possible by swapping out its digits for digits in the second number. To illustrate: max_possible(9328, 456) -> 9658 # 9658 is the largest possible number built from swaps from 456. # 3 replaced with 6 and 2 replaced with 5. Each digit in the secon...
true
736a16c6c9f13efd689a4449c5bdaef22d1d96fc
garciaha/DE_daily_challenges
/2020-08-03/unravel.py
641
4.4375
4
"""Unravel all the Possibilities Write a function that takes in a string and returns all possible combinations. Return the final result in alphabetical order. Examples unravel("a[b|c]") -> ["ab", "ac"] Notes Think of each element in every block (e.g. [a|b|c]) as a fork in the road. """ def unravel(string): pas...
true
8cd9783dc602893f32c52a2c4c2e21952662def3
garciaha/DE_daily_challenges
/2020-07-22/connect.py
1,742
4.28125
4
"""Connecting Words Write a function that connects each previous word to the next word by the shared letters. Return the resulting string (removing duplicate characters in the overlap) and the minimum number of shared letters across all pairs of strings. Examples connect(["oven", "envier", "erase", "serious"]) -> ["...
true
79b243b7c8dc4a887e111dac8b620adb5db55420
garciaha/DE_daily_challenges
/2020-09-09/all_explode.py
1,679
4.21875
4
"""Chain Reaction (Part 1) In this challenge you will be given a rectangular list representing a "map" with three types of spaces: - "+" bombs: When activated, their explosion activates any bombs directly above, below, left, or right of the "+" bomb. - "x" bombs: When activated, their explosion activates any bombs p...
true
381007913bcd073e5a1aa745b00ea030fe371b84
sandeepvura/Mathematical-Operators
/main.py
538
4.25
4
print(int(3 * 3 + 3 / 3 - 3)) # b = print(int(a)) **Mathematical Operators** ``` ###Adding two numbers 2 + 2 ### Multiplication 3 * 2 ### Subtraction 4 - 2 ### Division 6 / 3 ### Exponential When you want to raise a number 2 ** 2 = 4 2 ** 3 = 8 ``` ***Note:*** Order of Mathematical operators to execute...
true
44c3662bac6085bd63fcb52a666c2e81e5a683ff
farhadkpx/Python_Codes_Short
/list.py
1,689
4.15625
4
#list # mutable, multiple data type, un-ordered lis = [1,2,3,4,5,6,7,8,9] #nos lis2 = ['atul','manju','rochan'] #strings lis3 = [1,'This',2,'me','there'] #both #create empty list lis4 = [] #empty lis5 = list() #empty #traversl for item in lis: print (item), #slicing print (lis[:],lis[2:3],lis[3:]) #Mutable l...
true
28ec5060a74ff5c0e0f62742317d22266a5f41a2
sadieBoBadie/feb-python-2021
/Week1/Day2/OOP/intro_OOP.py
2,111
4.46875
4
#1. # OOP: # Object Oriented Programming # Style of programming uses a blueprint for modeling data # Blueprint defined by the programmer -- DIY datatypes # -- customize it for your situation # Modularizing # 2: # What is CLASS: # User/Programmer defined data-type # Like a function is a reci...
true
36c9bac791ef0ee4aba78e32851a4fcb6756fafb
Lawlietgit/Python_reviews
/review.py
2,202
4.15625
4
# 4 basic python data types: # string, boolean, int, float # str(), bool(), int(), float() # bool("False") --> True # bool("") --> False # bool(10.2351236) --> True # bool(0.0) --> False # bool(object/[1,2,3]) --> True # bool([]) --> False # bool(None) --> False # FIFO --> queue dat...
true
4fd15d3e74cb6ea719d26bf9f30704f5f7c7de7b
mfcust/sorting
/sorting.py
2,274
4.53125
5
# 1) Run the code in the markdown and write a comment about what happens. # 2) Try to print(sorted(my_list2)) and print(my_list2.sort()). Is there a difference? What do you observe? my_list2 = [1,4,10,9,8,300,20,21,21,46,52] # 3) Let's say you wanted to sort your list but in reverse order. To do this, you ...
true
5b9dff75a516f758e8e8aef83cf89794176b488b
Mukilavan/LinkedList
/prblm.py
880
4.21875
4
#Write a Python program to find the size of a singly linked list. class Node: def __init__(self, data, next=None): self.data = data self.next = next class linkedList: def __init__(self): self.head = None def insert_beg(self, data): node = Node(data, self.head) ...
true
50042e3c7051ee2be4a19e9d4f858a22a7be88f7
clarkjoypesco/pythoncapitalname
/capitalname.py
332
4.25
4
# Write Python code that prints out Clark Joy (with a capital C and J), # given the definition of z below. z = 'xclarkjoy' name1 = z[1:6] name1 = name1.upper() name1 = name1.title() name2 = z[-3:] name2 = name2.upper() name2 = name2.title() print name1 + ' ' + name2 s = "any string" print s[:3] + s[3:] print s...
true
ee8a14b46db017786571c81da934f06a614b3553
Jamsheeda-K/J3L
/notebooks/lutz/supermarket_start.py
1,724
4.3125
4
""" Start with this to implement the supermarket simulator. """ import numpy as np import pandas as pd class Customer: '''a single customer that can move from one state to another''' def __init__(self, id, initial_state): self.id = id self.state = initial_state def __repr__(self): ...
true
7c61f608b0278498c5bac3c8c2833d827754f124
lynnxlmiao/Coursera
/Python for Everybody/Using Database with Python/Assignments/Counting Organizations/emaildb.py
2,686
4.5
4
"""PROBLEM DESCRIPTION: COUNTING ORGANIZATIONS This application will read the mailbox data (mbox.txt) count up the number email messages per organization (i.e. domain name of the email address) using a database with the following schema to maintain the counts: CREATE TABLE Counts (org TEXT, count INTEGER) When you have...
true
9415684dc35e4d73694ef14abe732a7ba32bf301
lenatester100/AlvinAileyDancers
/Helloworld.py
806
4.1875
4
print ("Hello_World") print ("I am sleepy") ''' Go to sleep print ("sleep") Test1=float(input("Please Input the score for Test 1...")) Test2=float(input("Please Input the score for Test 2...")) Test3=float(input("Please Input the score for Test 3...")) average=(Test1+Test2+Test3)/3 print ("The Average of...
true
b719b552170b8128a75a5121ac7578aa51a3e691
Krishan27/assignment
/Task1.py
1,466
4.375
4
# 1. Create three variables in a single a line and assign different # values to them and make sure their data types are different. Like one is # int, another one is float and the last one is a string. a=10 b=10.14 c="Krishan" print(type(a)) print(type(b)) print(type(c)) # 2. Create a variable of value type comple...
true
953ed2c94e19a170fbe076f10339ff79ccda32f7
chaithanyabanu/python_prog
/holiday.py
460
4.21875
4
from datetime import date from datetime import datetime def holiday(day): if day%6==0 or day%5==0: print("hii this is weekend you can enjoy holiday") else: print("come to the office immediately") date_to_check_holiday=input("enter the date required to check") day=int(input("enter the day")) month=int(input("en...
true
91572a07bf2cbe5716b5328c0d4afc34c5f375f8
prince5609/Coding_Bat_problems
/make_bricks.py
1,151
4.5
4
""" QUESTION = We want to make a row of bricks that is goal inches long. We have a number of small bricks (1 inch each) and big bricks (5 inches each). Return True if it is possible to make the goal by choosing from the given bricks. make_bricks(3, 1, 8) → True make_bricks(3, 1, 9) → False make_bricks(3, 2, 10) → True...
true
022d1d89d419686f2ecf256f9e9a67aff141f13b
he44/Practice
/leetcode/35.py
822
4.125
4
""" 35. Search Insert Position Given a sorted array and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in order. """ class Solution: def searchInsert(self, nums, target) -> int: size = len(nums) # no element / smaller than f...
true
158ebdaca82112ce33600ba4f14c92b2c628a2b8
Anjalics0024/GitLearnfile
/ListQuestion/OopsConcept/OopsQ10.py
880
4.3125
4
#Method Overloading :1. Compile time polymorphisam 2.Same method name but different argument 3.No need of more than one class #method(a,b) #method(a,b,c) class student: def __init__(self,m1,m2): self.m1 = m1 self.m2 = m2 def add(self,a= None, b=None, c=None): s = a+b+c return...
true
0cc3fb7a602f1723486a9e3f4f4394e7b4b89f90
zhuxiuwei/LearnPythonTheHardWay
/ex33.py
572
4.3125
4
def addNum(max, step): i = 0 numbers = [] while(i < max): print "At the top i is %d" % i numbers.append(i) i += step print "Numbers now: ", numbers print "At the bottom i is %d" % i return numbers numbers = addNum(10, 2) print "The numbers: ", numbers for num in numbers: print num # below is add point...
true
0249f8cb4fce6702f631c51de53449e0e80b5fde
sidhanshu2003/LetsUpgrade-Python-Batch7
/Python Batch 7 Day 3 Assignment 1.py
700
4.3125
4
# You all are pilots, you have to land a plane, the altitude required for landing a plane is 1000ft, #if less than that tell pilot to land the plane, or it is more than that but less than 5000 ft ask pilot to # come down to 1000ft else if it is more than 5000ft ask pilot to go around and try later! Altitude = inpu...
true
1c5d80a5243fb8636f82ca76f0cb1945d25627ec
ash8454/python-review
/exception-handling-class20.py
1,414
4.375
4
###Exception handling """ The try block lets you test a block of code for errors. The except block lets you handle the error. The finally block lets you execute code, regardless of the result of the try- and except blocks. """ try: print(x) except NameError: print("Variable x is not defined") except: p...
true
0f26b50662decd207ceaf2ce4367b138a9644ee7
saad-ahmed/Udacity-CS-101--Building-a-Search-Engine
/hw_2_6-find_last.py
617
4.3125
4
# Define a procedure, find_last, that takes as input # two strings, a search string and a target string, # and outputs the last position in the search string # where the target string appears, or -1 if there # are no occurences. # # Example: find_last('aaaa', 'a') returns 3 # Make sure your procedure has a return stat...
true
98cfbcf9b135a4851035453a1182acfbb389545f
samicd/coding-challenges
/duplicate_encode.py
738
4.1875
4
""" The goal of this exercise is to convert a string to a new string where each character in the new string is "(" if that character appears only once in the original string, or ")" if that character appears more than once in the original string. Ignore capitalization when determining if a character is a duplicate. ...
true
f52079869f41ba7c7ac004521b99586c6b235dad
Ritella/ProjectEuler
/Euler030.py
955
4.125
4
# Surprisingly there are only three numbers that can be # written as the sum of fourth powers of their digits: # 1634 = 1^4 + 6^4 + 3^4 + 4^4 # 8208 = 8^4 + 2^4 + 0^4 + 8^4 # 9474 = 9^4 + 4^4 + 7^4 + 4^4 # As 1 = 1^4 is not a sum it is not included. # The sum of these numbers is 1634 + 8208 + 9474 = 19316. # Find th...
true
83571a887f9f89107aa9d621c0c2ebcac139fd2e
Ritella/ProjectEuler
/Euler019.py
1,836
4.15625
4
# You are given the following information, # but you may prefer to do some research for yourself. # 1 Jan 1900 was a Monday. # Thirty days has September, # April, June and November. # All the rest have thirty-one, # Saving February alone, # Which has twenty-eight, rain or shine. # And on leap years, twenty-nine. # A l...
true
b284b148982d4c0607e0e0c15ac07641aea81011
ho-kyle/python_portfolio
/081.py
229
4.21875
4
def hypotenuse(): a, b = eval(input('Please enter the lengths of the two shorter sides \ of a right triangle: ')) square_c = a**2 + b**2 c = square_c**0.5 print(f'The length of hypotenuse: {c}') hypotenuse()
true
817a57ad576fcc602e6de0a8daa1a0811f5a6657
chilperic/Python-session-coding
/mutiple.py
868
4.28125
4
#!/usr/bin/env python #This function is using for find the common multiple of two numbers within a certain range def multiple(x,y,m,t): #x is the lower bound the range and y higher bound from sys import argv x, y, m, t= input("Enter the the lower bound of your range: "), input("Enter the the higher bound of your r...
true
228e5e3c7ca9ae56d0b6e0874f592c58cbaadc24
TeknikhogskolanGothenburg/PGBPYH21_Programmering
/sep9/textadventure/game.py
2,467
4.3125
4
from map import the_map from terminal_color import color_print def go(row, col, direction): if direction in the_map[row][col]['exits']: if direction == "north": row -= 1 elif direction == "south": row += 1 elif direction == "east": col += 1 elif ...
true
db64c4552a3eef0658031283a760edc8cf20b3c0
mprzybylak/python2-minefield
/python/getting-started/functions.py
1,568
4.65625
5
# simple no arg function def simple_function(): print 'Hello, function!' simple_function() # simple function with argument def fib(n): a, b = 0, 1 while a < n: print a, a, b = b, a+b fib(10) print '' # example of using documentation string (so-called docstring) def other_function(): """Simple gibbrish print...
true
457c259a8515b806833cf54ccd0c79f8069f874c
surenderpal/Durga
/Regular Expression/quantifiers.py
481
4.125
4
import re matcher=re.finditer('a$','abaabaaab') for m in matcher: print(m.start(),'...',m.group()) # Quantifiers # The number of occurrences # a--> exactly one 'a' # a+-> atleast one 'a' # a*-> any number of a's including zero number also # a?-> atmost one a # either one a or zero number of a's # a{num}-> Ex...
true
2c53a0967ba066ca381cc67d277a4ddcd9b3c4e7
adreena/DataStructures
/Arrays/MaximumSubarray.py
358
4.125
4
''' Given an integer array nums, find the contiguous subarray (containing at least one number) which has the largest sum and return its sum. ''' def maxSubarray(nums): max_sum = float('-inf') current_sum = nums[0] for num in nums[1:]: current_sum = max(current_sum+num, num) max_sum = max(max...
true
855817e03fa062cb755c166042bdb16037aefe5c
IEEE-WIE-VIT/Awesome-DSA
/python/Algorithms/quicksort.py
898
4.28125
4
# Function that swaps places for to indexes (x, y) of the given array (arr) def swap(arr, x, y): tmp = arr[x] arr[x] = arr[y] arr[y] = tmp return arr def partition(arr, first, last): pivot = arr[last] index = first i = first while i < last: if arr[i] <= pivot: # Swap if curr...
true
5d81d3e6f16f4fc1d5c9fcc5ed452becefa95935
IEEE-WIE-VIT/Awesome-DSA
/python/Algorithms/Queue/reverse_k_queue.py
1,231
4.46875
4
# Python3 program to reverse first k # elements of a queue. from queue import Queue # Function to reverse the first K # elements of the Queue def reverseQueueFirstKElements(k, Queue): if (Queue.empty() == True or k > Queue.qsize()): return if (k <= 0): return Stack = [] ...
true
43012784b596503267cd6db2beb45bd19a7d1b0a
cuongnguyen139/Course-Python
/Exercise 3.3: Complete if-structure
262
4.1875
4
num=input("Select a number (1-3):") if num=="1": num="one." print("You selected",num) elif num=="2": num="two." print("You selected",num) elif num=="3": num="three." print("You selected",num) else: print("You selected wrong number.")
true
d99103049b500922d6d7bab8268503ad8190067c
osudduth/Assignments
/assignment1/assignment1.py
1,987
4.1875
4
#!/usr/bin/env python3 #startswith,uppercase,endswith, reverse, ccat # # this will tell you the length of the given string # def length(word): z = 0 for l in word: z = z + 1 return z # # returns true if word begins with beginning otherwise false # def startsWith(word, beginning): for x in r...
true
d0524ae575c3cf1697039a0f783618e247a96d18
TeresaChou/LearningCpp
/A Hsin/donuts.py
222
4.25
4
# this program shows how while loop can be used number = 0 total = 5 while number < total: number += 1 donut = 'donuts' if number > 1 else 'donut' print('I ate', number, donut) print('There are no more donuts')
true