blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string | is_english bool |
|---|---|---|---|---|---|---|---|
e72216a516cffe0cd78432f118de9d5fb6441a47 | kai-ca/Kai-Python-works | /LAB09/datastructlab/stackmodule.py | 1,658 | 4.21875 | 4 | """We implement a Stack data structure.
Stack is a LIFO = Last In First Out data
structure, like a atack of plates. The last
plate you put on the stack is the first plate
that will be removed.
Tip: Print out all the test files in the tests
directory and then get to work on the metods,
one by one.
Use your Stack... | true |
0da353feebc2597c645b088385db28f6f023235e | ramakrishna1994/SEM2 | /NS/Assg1/d_5_Decryption_Procedure_code.py | 2,803 | 4.28125 | 4 | '''
Author : Saradhi Ramakrishna
Roll No : 2017H1030081H
M.E Computer Science , BITS PILANI HYDERABAD CAMPUS
Description : Takes Cipher text as input and gives the Plain text as output
Input - 1.Key
2.Cipher Text
Output - Decrypted Plain Text
S... | true |
acebf175ac269144ba81c7aa9db35a84ae3dcb91 | Nuria788/Aso_Python | /for.py | 615 | 4.3125 | 4 | #Ciclo repetitivo FOR
#Siempre hace uso de una varible para determinar
# las veces que debe de repetirse el ciclo.
#A veces esta variable aumenta dentro del mimo
# ciclo para llegar al final.
# RANGE es una función predeterminada de Python.
#Siempre lleva : al final.
#Siempre comienza a contar desde el 0 cero.
#fo... | false |
761cfb3ca383146a744b8919598e46cfe7216cba | Gongzi-Zhang/Code | /Python/iterator.py | 850 | 4.625 | 5 | '''
Iterable is a sequence of data, one can iterate over using a loop.
An iterator is an object adhering to the iterator portocol.
Basically this means that it has a "next" method, which, when called
returns the next item in the sequence, and when there's nothing to
return, raise the StopIteration exception.
'''
'''
Wh... | true |
7fcf3dc50b38d8c01e7c3fc6760d650328578114 | Gongzi-Zhang/Code | /Python/dict.py | 923 | 4.34375 | 4 | #!/usr/bin/python
'''
Dictionaries are indexed by a key, which can be any 'immutable' value
'''
phone_nos = {"home" : "988988988",
"office" : "0803332222",
"integer": 25}
print phone_nos[0]
# KeyError: 0
print phone_nos['home']
# 988988988
# Dictionaries can also be created from lists of... | false |
0aaa40fdb013ee3cc2b10000709f9fcc7241c476 | vrrohan/Topcoder | /easy/day11/srm740/getaccepted.py | 2,810 | 4.4375 | 4 | """
Problem Statement for GetAccepted
Problem Statement
For this task we have created a simple automated system. It was supposed to ask you a question by giving you a String question.
You would have returned a String with the answer, and that would be all. Here is the entire conversation the way we planned it:
"Do ... | true |
e26ca389a503da8b04371fbbff9c187cd809b81d | cleiveliu/code-archive | /code-20190223/1plus1is2/runoob_c_100/11.py | 585 | 4.21875 | 4 | """
题目:古典问题(兔子生崽):有一对兔子,从出生后第3个月起每个月都生一对兔子,
小兔子长到第三个月后每个月又生一对兔子,假如兔子都不死,问每个月的兔子总数为多少?(输出前40个月即可)
"""
def print_fib_nums(n):
if n == 1:
print([1])
return [1]
elif n == 2:
print([1, 1])
return [1, 1]
else:
res = [1, 1]
for i in range(2, n):
res.ap... | false |
2fe7c4f1acffb9dbd5a1e8b005adbdb871bace1f | MoisesSanchez2020/CS-101-PYTHON | /cs-python/w02/team02_2.py | 1,352 | 4.40625 | 4 | """
File: teach02_stretch_sample.py
Author: Brother Burton
Purpose: Practice formatting strings.
This program also contains a way to implement the stretch challenges.
"""
print("Please enter the following information:")
print()
# Ask for the basic information
first = input("First name: ")
last = input("Last name: ... | true |
34abc2ab48a1065cb7f0055b1b0489654a406ed0 | MoisesSanchez2020/CS-101-PYTHON | /w04/team04.py | 2,862 | 4.28125 | 4 | """
File: teach04_sample.py
Author: Brother Burton
Purpose: Calculate the speed of a falling object using the formula:
v(t) = sqrt(mg/c) * (1 - exp((-sqrt(mgc)/m)*t))
"""
import math
# while you don't _have to_, it's considered good practice to import libraries
# at the top of your program, so that others know exac... | true |
b0bcfd87202ae144fbf263229c4fe94efebb6072 | MoisesSanchez2020/CS-101-PYTHON | /w10/checkpoint.py | 917 | 4.3125 | 4 | # Create line break between the terminal and the program.
print()
# Explain use of program to user.
print('Please enter the items of the shopping list (type: quit to finish):')
print()
# Create empty shopping list.
shop_list = []
# Define empty variable for loop.
item = None
# Populate shop_list with user input:
wh... | true |
e2a8d0f69d84f49228e816676adc8c6506905696 | vpdeepak/PirpleAssignments | /AdvancedLoops/main.py | 1,104 | 4.28125 | 4 | """
This is the solution for the Homework #6: Advanced Loops
"""
print("Assignment on Advanced Loops")
def DrawBoard(rows, columns):
result = False
if(rows < 70 and columns < 235):
result = True
for row in range(rows):
if(row % 2 == 0):
for column in range(columns... | true |
6948f7fae7e5042b299b5953d967a2159c9ed999 | damani-14/supplementary-materials | /Python_Exercises/Chapter03/CH03_05.py | 543 | 4.15625 | 4 | # program to calculate the order costs for the "Konditorei Coffee Shop"
# cost = 10.50/lb + shipping
# shipping = 0.86/lb + 1.50 fixed overhead cost
import math
def main():
print("")
print("This program will calculate the total cost (10.50/lb) for your coffee plus shipping (0.86/lb + 1.50 fixed).")
print... | true |
2bd6df777921168b3b76c52becaad87f6fe7ab70 | damani-14/supplementary-materials | /Python_Exercises/Chapter03/CH03_17.py | 958 | 4.3125 | 4 | # bespoke algorithm for calculating the square root of n using the "guess-and-check" approach
# Newton's method of estimating the square root, where:
# sqrt = (guess + (x/guess))/2
# guess(init) = x/2
import math
def main():
print("")
print("This program will estimate the square root of a value 'x' using 'n'"... | true |
c8ce4ca5959e673f92c28944bb53d3058329f4c5 | damani-14/supplementary-materials | /Python_Exercises/Chapter03/CH03_06.py | 555 | 4.21875 | 4 | # program which calculates the slope of a line given x,y coordinates of two user provided points
import math
def main():
print("")
print("This program will calculate ths slope of a non-vertical line between two points.")
print("")
x1,y1 = eval(input("Enter the coordinates of POINT 1 separated by a co... | true |
ec940e4973e310100d24207050f870e66b0543b1 | damani-14/supplementary-materials | /Python_Exercises/Chapter05/CH05_01.py | 800 | 4.53125 | 5 | # CH05_01: Use the built in string formatting methods to re-write the provided date converting program p. 147
#-----------------------------------------------------------------------------------------------------------------------
# dateconvert2.py
# Converts day month and year numbers into two date formats
def mai... | true |
22a1797bf0d139c56371968d6ba26eb7f176ed81 | damani-14/supplementary-materials | /Python_Exercises/Chapter08/CH08_01.py | 400 | 4.25 | 4 | # CH08_01: Wite a program that computes and outputs the nth Fibonacci number where n is a user defined value
#----------------------------------------------------------------------------------------------------------------------
def main():
a, b = 1,1
n = eval(input("Enter the length of the Fibonacci sequence... | true |
37c43ced0891ada8ca9d7b2d01df59b9ba96113c | JacksonJ01/List-Operations | /Operations.py | 2,338 | 4.28125 | 4 | # Jackson J.
# 2/10/20
# List Operations with numbers
from ListMethodsFile import *
print("Hello user, today we're going to do some tricks with Lists"
"\nFor that I'm going to need your help"
"\nOne number at a time please")
# This loop will get all five values needed for the methods in the other file t... | true |
2a54f5959a20c597b8250b63a2e3852066193204 | tstennett/Year9DesignCS4-PythonTS | /StringExample.py | 984 | 4.5 | 4 | #This file will go through the basics of string manipulation
#Strings are collections of characters
#Strings are enclosed in "" or ''
#"Paul"
#"Paul is cool"
#"Paul is cool!"
#Two things we need to talk about when we think of strings
#index - always starts at 0
#length
#example
# 0123 012345
#"Paul" ... | true |
cae88fdf277cf60c97b82bac80aea1729728ffdd | juanchuletas/Python_dev | /objects.py | 825 | 4.21875 | 4 | #!/usr/bin/python
# In python everything is an object
# a variable is a reference to an object
# each object has an identity or an ID
x = 1
print(type(x))
print(id(x))
#####################
# class 'int'
# 139113568
####################
# number, string, tuple -> inmutable
# list, dictionary -> mutable
x = 1
y = 1
... | true |
a4f2833e1539560e32481e855419cce224d5a0b4 | CameronOBrien95/cp1404practicals | /prac_05/emails.py | 474 | 4.25 | 4 | """
CP1404/CP5632 Practical
Email to name dictionary
"""
email_name = {}
email = input("Email: ")
valid = False
while email != "":
name = email.split("@")[0]
name = name.replace(".", " ").title()
choice = input("Is your name {}? (Y/n)".format(name)).upper()
if choice != 'Y':
name = input("What ... | false |
005f3298cad9d70f22201532a895541eee04f730 | smohorzhevskyi/Python | /Second_homework_4.py | 991 | 4.21875 | 4 | """
Напишите функцию, которая принимает список строк в качестве аргумента и возвращает отфильтрованный список,
который содержит только строки, которые являются палиндромами.
Например: Аргументы: words = ["radar", "device", "level", "program", "kayak", "river", "racecar"]
Функция должна вернуть... | false |
6e0dc99e9239f6ecc6e2cfb18c2aa899277aff3a | smohorzhevskyi/Python | /Second_homework_3.py | 856 | 4.1875 | 4 | """
Напишите функцию, которая принимает 2 списка в качестве аргументов и возвращает список кортежей,
отсортированный по значению второго элемента в кортеже. Например:
Аргументы:
weekdays = ['Sunday', 'Saturday', 'Friday', 'Thursday', 'Wednesday','Tuesday', 'Monday']
days = [7, 6, 5, 4, 3, 2, 1].
Фун... | false |
056aa02e58696d83b7e75f8cadad3339e09096ed | goodGopher/HWforTensorPython | /DZ4to11032021/prog4_deliting_elements.py | 823 | 4.125 | 4 | """Removing duplicate elements in list.
Functions:
list_reading(my_list):
Allows to read list from keyboard.
remove_copies(m_list):
Removing duplicate elements in list.
main():
Organize entering and clearing of list.
"""
import checks
def remove_copies(m_list):
"""Removing du... | true |
64b15b4ed5ed67df6e7f912891491dbc6576230c | adiiitiii/IF-else | /alphabet digit or special char???.py | 233 | 4.125 | 4 | ch=input("enter any character")
if ch>"a" and ch<"z" or ch>"A" and ch<"Z" :
print("the character is an alphabet")
elif ch[0].isdigit():
print("the character is a digit")
else:
print("the character is a special character") | true |
a84e87ca3ec6379c4c7582862ed4ff48f4cbee24 | 121710308016/asignment4 | /10_balanced_brackets.py | 2,396 | 4.15625 | 4 | """
You're given a string s consisting solely of "(" and ")".
Return whether the parentheses are balanced.
Constraints
Example 1
Input
s = "()"
Output
True
Example 2
Input
s = "()()"
Output
True
Example 3
Input
s = ")("
Output
False
Example 4
Input
s = ""
Output
True
Exampl... | true |
746a47a541ca0da03832a24b02ef340be66659ec | src053/PythonComputerScience | /chap3/ladderAngle.py | 891 | 4.5 | 4 | # This program will determine the length of the ladder required to
# reach a height on a house when you have that height and the angle of the ladder
import math
def main():
# Program description
print("This program will find the height a ladder will need to be when given two inputs")
print("1) The height of the ho... | true |
326c7997a605b2a681185f98f76b309ae2548e58 | src053/PythonComputerScience | /chap5/avFile.py | 602 | 4.28125 | 4 | #program that will count the number of words in a sentence from within a file
def main():
#get the name of file
fname = input("Please enter the name of the file: ")
#open the file
infile = open(fname, "r")
#read in file
read = infile.read()
#split the sentence into a list
split = read.split()
#count the l... | true |
e200b43b7d728635cf1581cf5eb4fcde4729bff6 | src053/PythonComputerScience | /chap3/slope.py | 985 | 4.3125 | 4 | # This program will calculate the slope of to points on a graph
# User will be required to input for var's x1, x2, y1, y2
import math
def slope(x1, x2, y1, y2):
return round((y2 - y1)/(x2 - x1)) #Calculate and return the slope
def distance(x1, x2, y1, y2):
return round(math.sqrt(((x2 - x1) ** 2) + ((y2 - y1) ** 2))... | true |
90873ee519d41e877adbe3037d7fcd9b5e0b7e96 | src053/PythonComputerScience | /chap3/easter.py | 467 | 4.125 | 4 | # This program will take the year a user inputs and output the value of easter
def main():
print("This program will figure out the epact for any given year")
year = eval(input("Input the year you would like to know the epact of: "))
#Equation to figure out integer division of C
C = year//100
#Equation to figur... | true |
26870cc55f6e78c2d25cc09b9119491abdef8434 | src053/PythonComputerScience | /chap2/convert.py | 331 | 4.28125 | 4 | #A program to convert Celsius temps to Fahrenheit
def main():
print("This program will convert celsius to farenheit")
count = 0
while(count < 5):
celsius = eval(input("What is the Celsuis temperature? "))
fahrenheit = 9/5 * celsius + 32
print("The temperature is", fahrenheit, "degree Fahrenheit.")
count +... | true |
f40123af7ffca03d3d4184aa3fcf131f7f8f2ce4 | Kdk22/PythonLearning | /PythonApplication3/exception_handling.py | 2,688 | 4.21875 | 4 | # ref: https://docs.python.org/3/tutorial/errors.html
while True:
try:
x = int(input('Please enter a number: '))
break
except ValueError:
print('Ooops ! THat was no valid number. Try agian..')
''' If the error type matches then only in displays message.
If the error t... | true |
bb52036b8bf49eb4af098c7f2025fce8080316d8 | Kdk22/PythonLearning | /PythonApplication3/class_var_and_instance_var.py | 1,005 | 4.5625 | 5 |
class foo:
x='orginal class'
c1,c2 = foo(), foo()
''' THis is creating the multiple objects of
same as
c1 = foo()
c2 = foo()
and these objects can access class variable (or name)
'''
print('Output of c1.x: ', c1.x)
print('Output of c2.x: ', c2.x)
'''
Here if you change the c1 instance, and i... | true |
b6417cda68e6efe3792e317980cbbdb923a5cb63 | vohrakunal/python-problems | /level2prob4.py | 806 | 4.375 | 4 | '''
In this task, we would like for you to appreciate the usefulness of the groupby() function of itertools . To read more about this function, Check this out .
You are given a string . Suppose a character '' occurs consecutively times in the string. Replace these consecutive occurrences of the character '' with in ... | true |
61d217ee89bf72920f370c96b6554d675a4c035e | steveiaco/COMP354-Team-E | /Functions/pi.py | 1,320 | 4.125 | 4 | # Goal: Calculate pi to the power of a given variable x
# Author: Ali
from Functions.constants import get_pi
# Pie Function
# Using Table Method
# I have basically created a global variable for PIE and its power
PIE = get_pi()
# the index (n) of the dictionary represent PIE**(10**n)
PIE_Dictionary = {
-5: 1.000... | true |
2dd449e8b85f1814e6c857a1e411936f21ea6c09 | verjavec/guessing_game | /game.py | 1,217 | 4.25 | 4 | """A number-guessing game."""
import random
# Put your code here
# Greet the player
name = input("Please enter your name: ")
print (f'Hello {name}!')
#choose a random number
numbertoguess = random.randrange(1,100)
print(numbertoguess)
keep_guessing = True
num_guesses = 0
#repeat this part until random number equal... | true |
946d079c682179d1e5b09bfeed6ae36a23045eae | inwk6312winter2019/week4labsubmissions-deepakkumarseku | /lab5/task4.py | 762 | 4.34375 | 4 | import turtle
class rectangle():
"""Represents a rectangle.
attributes: width, height.
"""
class circle():
"""Represents a circle.
attributes: radius.
"""
radius=50
def draw_rect(r):
""" Draws a rectangle with given width and height using turtle"""
for i in ... | true |
8f2e39d178be9670253ca98d275cc549226b6971 | williamstein/480_HW2 | /simple_alg.py | 1,050 | 4.15625 | 4 | print "Hello"
import math
#computes the probability of the binomial function in the specified range inclusive
#min, max are the values for the range
#n is the total population
#p is the success probability
def binom_range(min, max, n, p):
if(min > max):
raise Exception("Please pass a valid range")
if(min < 0):
... | true |
5bc42f93d4da19adc21bc675f5cfa6aec78411a7 | tianxiongWang/codewars | /sum.py | 484 | 4.15625 | 4 |
# >Given two integers a and b, which can be positive or negative, find the sum of all the numbers between including them too and return it. If the two numbers are equal return a or b.
# 其实就是把a到b之间的数求和,太简单了
def get_sum(a,b):
if a == b:
return a
if a < b:
sum = 0
for num in range(a, b+1... | true |
32699826b747b0009a4313fb427fda5a4ac7ef79 | Kallol-A/python-scripting-edureka | /Module 3/Case1/commavalues.py | 641 | 4.1875 | 4 | #Write a program that calculates and prints the value according to the given formula:
#Q = Square root of [(2 * C * D)/H]
#Following are the fixed values of C and H: C is 50. H is 30.
#D is the variable whose values should be input to your program in a comma- separated sequence.
#Let us assume the following comma s... | true |
8c89eb33be9a01050fd6f4929d8ed287ed5dd2aa | sdn0303/algorithm-training | /Palindrome.py | 259 | 4.25 | 4 | # -*- coding:utf-8 -*-
# 回文かどうかを判定する
def palindrome(string):
if string == string[::-1]:
print('True')
else:
print('False')
string1 = 'abcdefgfedcba'
string2 = 'asifjvbh'
palindrome(string1)
palindrome(string2)
| false |
126d10961d3e699b353863fa96ea055c43fa46d2 | Elvis2597/Sorting_Algorithms | /MergeSort.py | 692 | 4.1875 | 4 | #Time Complexity = O(nlogn)
#Function to merge to array
def merge(a,l,r):
nl=len(l)
nr=len(r)
i=0
j=0
k=0
while (i<nl and j<nr):
if l[i]<=r[j]:
a[k]=l[i]
i+=1
else:
a[k]=r[j]
j+=1
k+=1
while (i<nl):
a[k]=l[i]
... | false |
58a0e3ca5ac367b7b994450b49fc7fc3a6c664ad | Alainfou/python_tools | /prime_list.py | 2,134 | 4.1875 | 4 | #!/usr/bin/python
import math
import sys
import getopt
print "\n\tHey, that's personal! That's my very, very personal tool for listing prime numbers! Please get out of here! =(\n"
dat_prime_list = [2,3]
def its_prime (p):
s = int(math.sqrt(p))+1
for i in dat_prime_list :
if (p%i) =... | true |
2a378d9c0099652c3f74f22fa67311636d6d477a | geraldo1993/CodeAcademyPython | /Strings & Console Output/String methods.py | 614 | 4.4375 | 4 | '''Great work! Now that we know how to store strings, let's see how we can change them using string methods.
String methods let you perform specific tasks for strings.
We'll focus on four string methods:
len()
lower()
upper()
str()
Let's start with len(), which gets the length (the number of characters) of a string!... | true |
d3b8a54fca1ec8f724ec1a2de1a81f952c0368d7 | ohwowitsjit/WK_1 | /2.py | 201 | 4.125 | 4 | num_1 = int(input("Enter the first number: "));
num_2= int(input("Enter the first number: "));
product=0;
for i in range(0, num_2):
product=product+num_1;
print("Product is:", str(product)); | true |
2db6a8ca529a72823ce4e7ba45cfcb050ff830bd | puneet672003/SchoolWork | /PracticalQuestions/06_question.py | 358 | 4.28125 | 4 | # Write a Python program to pass a string to a function and count how many vowels present in the string.
def count_vowels(string):
vowels = ["a" ,"e", "i", "o", "u"]
count = 0
for char in string:
if char.lower() in vowels:
count += 1
return count
print(f"Total vowels : ", c... | true |
6647ec2418ab875585ed562ceeea49a6bd1c9746 | puneet672003/SchoolWork | /PracticalQuestions/03_question.py | 411 | 4.40625 | 4 | # Write a python program to pass list to a function and double the odd values and half
# even values of a list and display list element after changing.
def halfEven_doubleOdd(arr):
for i in range(len(arr)):
if arr[i] % 2 == 0:
arr[i] = arr[i]/2
else :
arr[i] = arr[i]*2
... | true |
d1fff6ff6f5f6c089029a521907eb1fe14a9680c | erin-koen/Whiteboard-Pairing | /CountingVotes/model_solution/solution.py | 1,377 | 4.28125 | 4 | # input => array of strings
# output => one string
# conditions => The string that's returned is the one that shows up most frequently in the array. If there's a tie, it's the one that shows up most frequently in the array and comes last alphabetically
# sample input => input: ['veronica', 'mary', 'alex', 'james', 'ma... | true |
4c051300bade9b496dcb31f81376b704a82f84eb | fionnmcguire1/LanguageLearning | /PythonTraining/Python27/BattleShip_medium.py | 1,815 | 4.1875 | 4 | '''
Author: Fionn Mcguire
Date: 26-11-2017
Description:
Given an 2D board, count how many battleships are in it. The battleships are represented with 'X's, empty slots are represented with '.'s. You may assume the following rules:
You receive a valid board, made of only battleships or empty slots.
Battleships ... | true |
1e20b0f6ffd29554ce2e1fe5551abf3b9c839f01 | boerz-coding/cs107_Boer_Zhang | /pair_programming/PP7/exercise_2.py | 858 | 4.25 | 4 | """
Pair Programming Assignment #7
Collaborators: Ryan Liu, Blake Bullwinkel, Zhufeng Kang, Boer Zhang
Forward mode on f(x) = x**r
"""
# Define a simple function
def my_pow(x, r):
f = x**r
f_prime = (r)*x**(r-1)
output = (f, f_prime)
return output
# Implement a closure
def outer(r):
def inner(x, s... | false |
a6d0f86a9c77d54bec821e91a665522357466cf5 | Dallas-Marshall/CP1404 | /prac_01/electricity_bill_estimator.py | 719 | 4.15625 | 4 | # Electricity Costs
TARIFF_11 = 0.244618
TARIFF_31 = 0.136928
electricity_cost = 0
# Define Menu:
MENU = """Please select tariff;
Tariff(11)
Tariff(31)"""
# Display Menu
print(MENU)
# Ask user to select menu option
user_choice = int(input(">>> "))
# Define relevant electricity cost
if user_choice == 31:
electri... | true |
306684db850ddb2a45b4b554a8a4f940b9322151 | EtienneBauscher/Classes | /student.py | 1,970 | 4.1875 | 4 | """'student.py' is a program that computes the following:
1. The average score of a student's grades.
2. It tests whether a student is a male or a female.
The program utilises a class called Student
The class hosts various fucntions for the computation of the needed outcomes.
"""
class Student(object):
""... | true |
2d327cbc6d7edc81198880b6a5663e0166ef54d2 | crazy-bruce/algorithm | /data_structure/queue.py | 1,078 | 4.1875 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
# @Time: 2021/1/12 下午2:10
# @Author: Bruce Chen
# @Site:
# @File: queue.py
# @Software: PyCharm
class Queue(object):
def __init__(self, size):
self.queue = [0 for i in range(size)]
self.rear = 0
self.front = 0
self.size = size
def... | false |
532d90e13e03f6af7ef54e45544688a5ef934009 | ghostassault/AutomateTheBoringWithPython | /Ch7/RegEx.gyp | 2,277 | 4.375 | 4 | #The search() method will return a match object of the first matched text in a searched string
#1 Matching Multiple groups with the pipe
import re
heroR = re.compile(r'Batman|Tina Fey')
mo1 = heroR.search('Batman and Tina Fey.')
print(mo1.group())
#2 Optional Matching with the Question Mark
batRe = re.compile(r'Bat(... | true |
db7cd6a5237bdfca4a0622c10b1cdd3ddb430bf8 | jinshanpu/lx | /python/func.py | 280 | 4.125 | 4 | print "the prog knows which number is bigger"
a=int(raw_input("Number a:"))
b=int(raw_input("Number b:"))
def theMax(a, b=0):
'''Prints the maximun of two numbers.
the two values must be integers'''
if a>b:
return a
else:
return b
print theMax(a, b)
print theMax.__doc__
| true |
9f96445ed9e96509427feb05dfc2ba262c5171d8 | javirodriguezzz/als-labs | /tribonacci.py | 1,455 | 4.21875 | 4 | """
En la sucesión de Tribonacci, cada elemento
es la suma de los tres anteriores, y se empieza
por 0, 1, 1.
In the Tribonacci succesion, each element is the sum
of the three previous instances, and it always
starts with 0, 1, 1.
"""
def tribonacci_iter(n):
def tribonacci(n):
"""
Calcular la sucesi... | false |
dc8668bc96298bb2172e39038df5ffcfeacd568c | botnaysard/askPython | /forLoops.py | 614 | 4.28125 | 4 | # LESSON
city = ['Tokyo', 'NYC', 'Toronto', 'Philadelphia', 'Ottawa', 'London', 'Shanghai']
print("List of cities:\n")
for x in city:
print("City" + x)
print("\n")
num = [1,2,3,4,5,6,7,8,9,10]
print("Multiplications:")
for x in num:
y = x * (x - 1)
print(str(x) + " x " + str(x - 1) + " = " +str(y))
# ... | false |
15c7e77fbbb4a9dd3b253db741681ccb25e6657c | botnaysard/askPython | /nestedLoops.py | 576 | 4.25 | 4 | # LESSON
persons = ["John", "Marissa", "Pete", "Dayton"]
restaurants = ["Mucho Burrito", "McDonald's", "Dominos", "Poop Station"]
for p in persons:
for r in restaurants:
print(p + " eats at " + r)
# EXERCISES
# print every tic tac toe position
vert = ["a", "b", "c"]
hori = ["1", "2", "3"]
for v in ver... | false |
e2e6f661dece58eb23e84de878e866878d54d295 | franklinharvey/CU-CSCI-1300-Fall-2015 | /Assignment 3/Problem1.py | 251 | 4.125 | 4 | #Franklin Harvey
#Assignment 3
#Problem 1
#TA: Amber
fullName = raw_input("What is your name in the format Last, First Middle? ")
comma = fullName.find(",")
lastName = fullName[0:comma]
#print lastName
print fullName [comma + 2:len(fullName)] + " " + lastName | true |
1398a66b86aca613a6dbb7ba5c534615e14348cc | ShreyasAmbre/python_practice | /PythonPracticeQuestion2.0/PythonProgram_2.3.py | 432 | 4.1875 | 4 | # WAP to add 'ing' at the end of a given string (length should be at least 3). If the given
# string already ends with 'ing' then add 'ly' instead. If the string length of the given string is less than 3,
# leave it unchanged.
s = "playing"
ls = list(s)
if len(s) > 3:
estr = "ing"
ostr = s[-3:]
if estr == ... | true |
305d22b7d4094bfe69f613bc6a11cac088cd51f0 | ShreyasAmbre/python_practice | /IntroToPython/Numpy/Basic Numpy.py | 773 | 4.375 | 4 | # Basic of Numpy, creating array using numpy
# numpy is faster then list because it store data in continous manner
# array() method is built-in in numpy yo create the numpy object, we can pass any array like object such as
# list & tuple
import numpy
# Basic Numpy Array
arr = numpy.array([12, "12", False, "Shreyas", 1... | true |
2421994d28a7d4df0684dfcc759c7e14f098b1c5 | worldbo/Effective_Python | /chapter2/19.py | 1,305 | 4.125 | 4 | # page44 第十九条
def remainder(number, divisor):
return number % divisor
assert remainder(20, 7) == 6
assert remainder(20, 7) == remainder(20, divisor=7) == remainder(number=20, divisor=7) == remainder(divisor=7,
num... | false |
2a473790322470554dc4e9abcd1a0ed09f77ec89 | VAMSIPYLA/python-practice | /if_elif.py | 437 | 4.21875 | 4 | #If n is odd, print Weird
#If n is even and in the inclusive range of 2 to 5, print Not Weird
#If n is even and in the inclusive range of 6 to 20, print Weird
#If n is even and greater than 20 , print Not Weird
N = int(input())
if N % 2 == 1:
print("Weird")
elif N % 2 == 0 and N in range(1, 6):
print("Not ... | false |
db2d38e26b8302c89dc54311773c5d38bdfd35d4 | N8Brooks/schrute_farms_algos | /pseudorandom.py | 1,064 | 4.125 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Sun Mar 1 09:35:06 2020
@author: nathan
"""
from random import randrange
from math import isqrt
def is_prime(n):
# return if it is 2 or 3
if n < 4:
return n > 1
# cut down on iteration checking 2s and 3s
if n % 2 == 0 or n % 3 ==... | false |
0ac484f4a9ab8dd8b0b3de4a0fb6da2a095b1471 | sizips0418/memorizing_gittest | /math_python.py | 2,960 | 4.34375 | 4 | # # # # # # factorial in math package
# # # # # from math import factorial
# # # # # fact = factorial(5)
# # # # # print(fact)
# # # # # # use recursive function when solving factorial
# # # # # def factorial(n):
# # # # # if n == 1:
# # # # # return 1
# # # # # return n * factorial(n-1)
# # # # # pri... | false |
290f44cf617673bc0203df18a99141e36e701a9d | rudrashishbose/PythonBible | /emailSlicer.py | 346 | 4.125 | 4 | # -*- coding: utf-8 -*-
"""
Created on Wed Jun 24 19:24:24 2020
@author: Desktop
"""
email_id = input("enter your email id: ")
username = email_id[0:email_id.index("@"):1]
domain_name = email_id[email_id.index("@")+1:]
output = "Your username is {} and your domain name is {}"
print(output.for... | true |
9eae76c78fdce03ce5285d1ad9bc32f87acd6da4 | rudrashishbose/PythonBible | /BabyTalkSimulator.py | 391 | 4.25 | 4 | #import random as rand
from random import choice
questions = ["Why is the sky blue?: ","Why is water wet?: ", "Why is the earth round?: "]
#answer = input(questions[rand.randint(0,2)]).strip().capitalize() #this is one way
answer = input(choice(questions)).strip().capitalize()
while (answer != "Just because!"):
... | false |
4a43883591df60bf17aaa26b91aa6fdadf470f6e | safin777/ddad-internship-Safin777 | /factorial.py | 391 | 4.21875 | 4 | def factorial(n):
factorial=1
if n<0 :
print("Factorial does not exits for value less than 0")
elif n == 0 :
print("The factorial of 0 is 1")
elif 0<n<10 :
for i in range(1,n+1):
factorial=factorial*i
print("The factorial of",n,"is",factorial)
else:
print("The input number is greater than 10")
... | true |
48f7a90dfc5a7e933d00ad2b69806418992baf48 | jillianhou8/CS61A | /labs/lab01/lab01.py | 1,192 | 4.15625 | 4 |
""
"Lab 1: Expressions and Control Structures"""
# Coding Practice
def repeated(f, n, x):
"""Returns the result of composing f n times on x.
>>> def square(x):
... return x * x
...
>>> repeated(square, 2, 3) # square(square(3)), or 3 ** 4
81
>>> repeated(square, 1, 4) # square(4)
16
>>> repeated(squar... | true |
2ae557b4da917c5273c5a79b86618bd97805134e | antGulati/number_patterns | /narssistic numbers/narcissistic_number_list_python.py | 887 | 4.28125 | 4 | # program to take a long integer N from the user and print all the narcissistic number between one and the given number
# narcissistic numbers are those whose sum of individual digits each raised to the power of the number of digits gives the orignal number
import math
def digitcount(num):
return int(math.log(num,10... | true |
488db0e00a310b5c45987ccbdf3171ccb6d875fb | clickykeyboard/SEM-2-OOP | /OOP/Week 08/assignment/employee.py | 2,941 | 4.34375 | 4 | class Employee:
def __init__(self, name, id, department, job_title):
self.name = name
self.id = id
self.department = department
self.job_title = job_title
employee_1 = Employee("Ahmed", "12345", "Management", "Manager")
employee_2 = Employee("Abbas", "54321", "Creative Team", "Desi... | true |
48a341c581e8b042d226bfc9016ba6a752bdde77 | ARPIT443/Python | /8Jun-problem5.py | 328 | 4.125 | 4 | import datetime
now = datetime.datetime.now().hour
name=input('Enter your name')
if now in range(0,12):
print('Hello'+name+',Good Morning..!')
elif now in range(12,18):
print('Hello'+name+',Good Afternoon..!')
elif now in range(18,22):
print('Hello'+name+',Good Evening..!')
else:
print('Hello'+name+',Good Nig... | false |
ef24c44d58052f1cba4008a7449b61fc123da0f1 | ARPIT443/Python | /problem6.py | 881 | 4.125 | 4 | option = '''
Select operation you want to perform--->>
1.Show contents of single file :
2.Show contents of multiple file :
3.cat -n command :
4.cat -E command :
'''
print(option)
choice=input()
if choice == '1':
fname=input('Name of file :')
f=open(fname,'r')
print(f.read())
f.close()
elif choice == '2':
n... | true |
9a6cd9211feb8dc010e44af0e55eeecc592bbc1d | Benjamin1118/cs-module-project-recursive-sorting | /src/searching/searching.py | 1,160 | 4.3125 | 4 | # TO-DO: Implement a recursive implementation of binary search
def binary_search(arr, target, start, end):
# Your code here
#find a midpoint start search there
#check if start < end first
if start > end:
return -1
mid = (start + end) // 2
if arr[mid] == target:
return mid
# c... | true |
5a58d0e43b93f4ea82b39b3fb181f89458b5369b | nabepa/coding-test | /Searching/bisect_library.py | 549 | 4.125 | 4 | # Count the number of frequencies of elements whose value is between [left, right] in a sorted array
from bisect import bisect_left, bisect_right
def count_by_range(array, left_val, right_val):
right_idx = bisect_right(array, right_val)
left_idx = bisect_left(array, left_val)
return right_idx - left_idx
... | true |
1bb30d2a451e8f528b364789d3b07537f364f4f5 | Hallessandro/GeradorScriptPython | /gerarTagCustom.py | 719 | 4.21875 | 4 | instituicao = input("Digite a sigla da instituicao: ")
numTarefa = input('Digite o número da tarefa: ')
print("""/* INICIO CUSTOMIZACAO ESPECIFICA '{instituicao}' - TAREFA '{numTarefa}' */""".format(instituicao=instituicao, numTarefa=numTarefa))
print("""/* FIM CUSTOMIZACAO ESPECIFICA '{instituicao}' - TAREFA '{numTare... | false |
3a12122d4e65fd58d473244fe50a9de3a1339b27 | austinjhunt/dailycodingproblem | /dcp2.py | 1,924 | 4.125 | 4 | #This problem was asked by Uber.
#Given an array of integers, return a new array such that each element at index i of the new array is the product of all the numbers in the original array except the one at i.
#For example, if our input was [1, 2, 3, 4, 5], the expected output would be [120, 60, 40, 30, 24]. If our in... | true |
18e5a15a489628f3c1a1e8d2a6e5b99ce66ddeeb | DrDavxr/email-text-finder | /mainPackage/extension_detector.py | 320 | 4.40625 | 4 | '''
This module finds the extension of the file selected by the user.
'''
def find_extension(filename):
'''
Finds the extension of a given file.
input: filename
output: file extension
'''
filename_list = filename.split('/')
extension = filename_list[-1].split('.')[-1]
return extension
| true |
e009fa6b516388eb7018d208ee2325196c7909ba | sonisidhant/CST8333-Python-Project | /calc.py | 2,170 | 4.1875 | 4 | ######################
# calc.py
# By Sidhant Soni
# October 24, 2018
######################
# Declaring variables and assigning user input
a = input('Enter First Number: ');
b = input('Enter Second Number: ');
print('\n')
# Converting user input string to integer
firstN = int(a);
secondN = int(b);
# Making the lis... | true |
702f5ca9c7b730ac315b0fc6072e4bee0216824f | decadevs/use-cases-python-oluwasayo01 | /instance_methods.py | 1,277 | 4.3125 | 4 | # Document at least 3 use cases of instance methods
class User():
def __init__(self, username = None):
self.__username = username
def setUsername(self, x):
self.__username = x
def getUsername(self):
return(self.__username)
Steve = User('steve1')
print('Before setting:', Steve.getUsername())
Stev... | true |
abad3a169e74dd4e19cbc6877567eb39a0bdb683 | AthenaTsai/Python | /python_notes/OOP/class.py | 904 | 4.5625 | 5 | # Class: object-oriented programming, inheritance
class Parent: # parent class, class is a structure, start with uppercase
def __init__(self, name, age, ht=168): # self tells the function is for which class
self.name = name
self.age = age
self.ht = ht
print('this is the parent clas... | true |
0750e02ab7a6e963ea1a1191d1def0e52a60f856 | sourcery-ai-bot/Estudos | /PYTHON/Python-Estudos/motorcycles.py | 1,814 | 4.28125 | 4 | # ALTERANDO, ACRESCENTANDO E REMOVENDO ITENS DE UMA LISTA
motorcycles = ['honda', 'yamaha', 'suzuki']
# ALTERANDO UM ITEM DE UMA LISTA
print(motorcycles)
motorcycles[0] = 'ducati'
print(motorcycles)
# ACRESCENTANDO ELEMENTOS EM UMA LISTA
# CONCATENANDO ELEMENTOS NO FINAL DE UMA LISTA
motorcycles = ['honda', 'yamaha'... | false |
1383c2f21b5c3d55f153a21394baf6805a9c308f | max180643/Pre-Programming-61 | /Onsite/Week-3/Monday/Custom Sign 2.0.py | 1,153 | 4.15625 | 4 | """Custom Sign"""
def main():
"""Main Function"""
size = int(input())
text = input()
text1 = text[:size - 2]
align = input()
if align == "Left":
print("*" * size)
print("*%s*" % (" " * (size - 2)))
print("*%s*" % (text1.ljust(size - 2)))
print("*%s*" % ... | false |
a48f0730061352526c030c3ac66845e48fd213a8 | thelmuth/ProfessorProjectPrograms110 | /calculations/pizza.py | 1,003 | 4.25 | 4 | """
*****************************************************************************
FILE: pizza.py
AUTHOR: Professors
ASSIGNMENT: Calculations
DESCRIPTION: Professors' program for Pizza problem.
*****************************************************************************
"""
import math
d... | true |
ba433e81b15fbe40ae03d9f2425ebc0de5ba6ba1 | tamalesimon/CS1101----uni | /Unit 3_conditionals/nested_made_easy.py | 379 | 4.375 | 4 | number_of_days_worked = 30
if number_of_days_worked != 30:
print("HOW MANY DAYS DID YOU WORK?")
else:
if number_of_days_worked <30:
print("YOU WORKED LESS DAYS")
else:
print("YOU WORKED A MONTH")
number_of_days_worked = 30
if number_of_days_worked != 30 and number_of_days_worked <30:
... | false |
350c2b4dc2d213524d7d35754e8d1d908d2dc118 | tamalesimon/CS1101----uni | /unit 7/discussion.py | 461 | 4.46875 | 4 | country = 'Uganda', 'Kenya', 'Norway', 'South Africa', #defining a tuple
capital = ['Kampala', 'Nairobi', 'Oslo', 'Joburg'] #defining a list
#using zip
country_capital = list(zip(country, capital))
print(country_capital) #printing out a list of tuples
for index in enumerate(country_capital):
print(index)
my_ca... | false |
9dd0b3f60eb6ed3e167b001035da7cb07630a480 | Jaffacakeee/Python | /Python_Bible/Section 5 - The ABCs/hello_you.py | 437 | 4.125 | 4 | # Ask user for name
name = input("What is your name? ")
# Ask user for age
age = input("What is your age? ")
# Ask user for city
city = input ("What city do you live in? ")
# Ask user for what they love
love = input("What do you love? ")
# Build the structure of the sentence
string = "Your name is {} and you are {}... | true |
df6b0634ce5825b8369d78f7f0c75ba6b6c19e17 | FrMiMoAl/tareas | /calificaciones.py | 804 | 4.1875 | 4 | nota = input("nota: ")
nota = int(nota)
if nota >= 1 and nota <= 10 :
print("La nota es correcta")
if nota >= 9 and nota <= 10 :
print("La nota es A")
print ("Exelente sigue asi")
if nota >= 7 and nota <= 8 :
print("La nota es B")
print("Estuviste mu... | false |
d3906ba829aecd6d2d665ba33306ebcafcb39f26 | Virtual-Uni/Discover-Python | /Exams/15.11.2020/Solutions/Mueem/Exam1/Task6.py | 549 | 4.25 | 4 | """
6. Task
Your code should calculate the average mark of students in a dictionary as key/value pairs.
Key represents the name of the student, whereas value represents marks_list from last few exams.
"""
marks_dictionary = {
'Hasan': [10, 5, 20],
'Sakir': [10, 10, 14],
'Hanif': [20, 15, 10],
'Saiful': [20, 20, 20]
}
... | true |
119b1ca27fc2a33b201c4f635e37fa8c7d77d4e6 | Virtual-Uni/Discover-Python | /Exams/15.11.2020/Solutions/Mueem/Exam1/Task4.py | 422 | 4.3125 | 4 | """
4. Task
Your provided code section should find a meaning of a word from a dictionary containing
key/value pairs of word: value.
line.
"""
input_word = input('Enter a word(Passed/Failed/Other) = ')
dictionary = {'Passed':'You have practiced at home.', 'Failed': 'You was not serious.',
'Other': 'Write your own meanin... | true |
58d38c4e908813e76d824039e7921e3dbfe91bb2 | marvin939/projecteuler-python | /problem 9 - special pythagorean triplet/problem9.py | 1,347 | 4.34375 | 4 | '''
A Pythagorean triplet is a set of three natural numbers, a < b < c, for which,
a^2 + b^2 = c^2
For example, 3^2 + 4^2 = 9 + 16 = 25 = 5^2.
There exists exactly one Pythagorean triplet for which a + b + c = 1000.
Find the product abc.
'''
from math import sqrt, floor, ceil
a = 1
b = None
c = None
P = 1000 # Pe... | true |
b068813edb18ee50949c41b70ba6047a906ea794 | marvin939/projecteuler-python | /problem 1 - multiples of 3 and 5/problem1.py | 402 | 4.25 | 4 | """
If we list all the natural numbers below 10 that are multiples of 3 or 5, we get
3, 5, 6 and 9. The sum of these multiples is 23.
Find the sum of all the multiples of 3 or 5 below 1000.
"""
x = 1
sum35 = 0
while x < 1000: # below 10
addToSum = False
if x % 3 == 0 or x % 5 == 0:
sum35 += x
... | true |
1855ba6951647a66912cde9b70e1574cef006706 | ZryletTC/CMPTGCS-20 | /labs/lab02/lab02Funcs.py | 2,281 | 4.1875 | 4 | # lab02Funcs.py Define a few sample functions in Python
# T. Pennebaker for CMPTGCS 20, Spring 2016
def perimRect(length,width):
"""
Compute perimiter of rectangle
>>> perimRect(2,3)
10
>>> perimRect(4, 2.5)
13.0
>>> perimRect(3, 3)
12
>>>
"""
return 2*(length+width)
def areaRec... | true |
86a7139693f7997f4b0b0018f298bb45fbbd4126 | shivapk/Programming-Leetcode | /Python/Trees/checkGraphisaTreecolorsGraphds[n,n].py | 2,218 | 4.21875 | 4 | #say given graph is a valid tree or not.An undirected graph is tree if it has following properties.
#1) There is no cycle.
#2) The graph is connected.
#Time: O(n) where n is the number of vertices..as number of edges will be n-1.
#space: O(n) where n is number of vertices
# keep track of parent in case of undirected gr... | true |
f95f64cfdb3c2aa61700e311d79610d79262d1e8 | TheDiegoFrade/python_crash_course_2nd_ed | /input_while_loops.py | 1,515 | 4.125 | 4 | #number = input("Enter a number, and I'll tell you if it's even or odd: ")
#number = int(number)
#if number % 2 == 0:
# print(f"\nThe number {number} is even.")
#else:
# print(f"\nThe number {number} is odd.")
current_number = 1
while current_number <= 5:
print(current_number)
current_number += 1
#prompt = "... | true |
d34f14cf5ffa70b9d4bacf51ef4a41e8c41d533c | TheDiegoFrade/python_crash_course_2nd_ed | /python_poll.py | 1,020 | 4.15625 | 4 | responses = {}
# Set a flag to indicate that polling is active.
polling_active = True
while polling_active:
# Prompt for the person's name and response.
name = input("\nWhat is your name? ")
response = input("Which are your favorite tacos? ")
# Store the response in the dictionary.
responses['name']... | true |
f740acd2ff5d494434ef64d91baed730e754f779 | Izydorczak/learn_python | /gdi_buffalo_2015/class2/functions_continued.py | 1,899 | 4.78125 | 5 | """
filename: functions_continued.py
author: wendyjan
This file shows more about functions.
"""
def say_hi():
print "Hello World!"
def say_hi_personally(person):
print "Hello " + person + "!"
def add_together(a, b):
return a + b
def calculate_y(m, x, b):
return m * x + b
def add_together_many(... | true |
0f8919198cf24d822e3a6324042480f5f4ba34fb | Izydorczak/learn_python | /gdi_buffalo_2015/class2/sample_library.py | 1,468 | 4.3125 | 4 | """
filename: sample_library.py
author: wendyjan
Small start to our own library to write letters in Turtle.
"""
import turtle
def print_w(t, start_x, start_y):
"""Draws an uppercase 'W' in Turtle.
Args:
t (turtle.Turtle): used to draw letter.
start_x (int): starting x coordinate at lower lef... | false |
c2f2744f17073e94b26f0c01f33dfd4750a65007 | shaneapen/LeetCode-Search | /src/utils.py | 1,643 | 4.34375 | 4 | def parse_args(argv):
"""Parse Alfred Arguments
Args:
argv: A list of arguments, in which there are only two
items, i.e., [mode, {query}].
The 1st item determines the search mode, there are
two options:
1) search by `topic`
2) search ... | true |
70c91c40394ae59ca2973541bd8a4d73da98b0c3 | skilstak/code-dot-org-python | /mymod.py | 1,758 | 4.25 | 4 | """Example module to contain methods, functions and variables for reuse.
This file gets loaded as a module (sometimes also called a library) when
you call `import mymod` in your scripts.
"""
import codestudio
class Zombie(codestudio.Artist):
"""An Artist with a propensity for brains and drawing squares.
Wh... | true |
9fe708eb8f839f215dc21fdc2296253970e02055 | lamida/algorithms-drills | /others/array_mountain.py | 930 | 4.25 | 4 | # https://leetcode.com/explore/learn/card/fun-with-arrays/527/searching-for-items-in-an-array/3251/
from typing import List
class Solution:
def validMountainArray(self, arr: List[int]) -> bool:
if len(arr) < 3:
return False
i = 1
j = 0
stage = "start" # up then down
... | false |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.