blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
dcf82c1d994f980388094411e11da0c36af8b939
BhagyashreeKarale/function
/output2.py
1,629
4.28125
4
# def primeorNot(num): # if num > 1:#it will only take numbers more then 1,not even 1 # for i in range(2,num):#all the numbers from 2 to the given number.i.e in this case 406 # if (num % i) == 0: # print(num,"is not a prime number") # print(i,"times",num//i,"...
true
ab111b6810f7652e3f3b52e2eb1934971f8484c9
BhagyashreeKarale/function
/palindrome.py
622
4.375
4
# Write a Python function that checks whether a passed string is palindrome or not. def palindromecheck(string): rlist=(string[::-1]) if rlist == string: print("It is a palidrome") else: print("It isn't a palidrome") # another one for palidrome: def palidromecheck2(string): left_pos = 0 ...
true
fa78625e9347e095937a81f272cfd909fc52a231
DanielFernandoYepezVelez/Fundamentos-Python
/18-EjerciciosComfenalco/04-DecisionesLogicasCuartaClase/07-NumeroMayor.py
528
4.25
4
numeroUno = float(input('Ingrese Un Numero Uno: ')) numeroDos = float(input('Ingrese Un Numero Dos: ')) numeroTres = float(input('Ingrese Un Numero Tres: ')) print('') if numeroUno > numeroDos and numeroUno > numeroTres: print(f'El Numero Mayor Es: {numeroUno}') elif numeroDos > numeroUno and numeroDos > numeroTre...
false
8adc894f3d9f759ba556e3f5038e058aff0b357e
DanielFernandoYepezVelez/Fundamentos-Python
/03-Operadores/07-FuncionesNumeros.py
988
4.15625
4
SEPARADOR = '-----------------------' def suma(a = 0, b = 0): print(a + b) print('\nSuma => ') suma(5.1, 4.9) suma(2.999, 33) suma(3) print(f'{SEPARADOR}\n') def resta(a = 0, b = 0): print(a - b) print('Resta => ') resta(12.2, .2) resta(5, 10) resta(5) print(f'{SEPARADOR}\n') def producto(a = 0, b = 0): ...
false
d924bc7e14da2270ea730ebcef771abbe9cd065f
DanielFernandoYepezVelez/Fundamentos-Python
/11-Diccionarios/04-MasMetodos.py
944
4.15625
4
SEPARADOR = '--------------------' jugador = {} print(jugador) print(f'{SEPARADOR}\n') """ Para Agregar Un Nuevo Jugador Al Diccionario Vacio """ jugador['nombre'] = 'Danielito Fernandito' jugador['puntaje'] = 0 print(jugador) print(f'{SEPARADOR}\n') # Incrementando El Puntaje jugador['puntaje'] = 110 print(jugado...
false
72871b67dd71410aedb185651c2764a1397aa5f0
DorotaNowak/machine-learning
/simple-linear-regression/simple_linear_regression.py
1,057
4.15625
4
# Simple linear regression import numpy as np import pandas as pd import matplotlib.pyplot as plt dataset = pd.read_csv('Salary_Data.csv') # print(dataset.head()) X = dataset.iloc[:,:-1].values y = dataset.iloc[:,1].values from sklearn.model_selection import train_test_split X_train, X_test, y_train, y_t...
true
b10395a36be87b043ed18ad3973f2ae4eeb955ca
tdominic1186/ATBS
/Chapter 2/question13while.py
214
4.28125
4
""" 13. Write a short program that prints the numbers 1 to 10 using a for loop. Then write an equivalent program that prints the numbers 1 to 10 using a while loop. """ i = 1 while i < 11: print(i) i += 1
true
e168e246982a5e6861163b33e13510592705ae44
adivis/PythonProg
/prob_5.py
1,233
4.1875
4
""" Problem Statement:- You are given few sentences as a list (Python list of sentences). Take a query string as an input from the user. You have to pull out the sentences matching this query inputted by the user in decreasing order of relevance after converting every word in the query and the sentence to lowercase. Mo...
true
5122893d898726377da5c2910fca3575eeb09348
my-xh/DesignPattern
/01创建型模式/05原型模式/克隆模式.py
1,036
4.34375
4
from copy import copy, deepcopy class Clone: """克隆的基类""" def clone(self): """浅拷贝""" return copy(self) def deep_clone(self): """深拷贝""" return deepcopy(self) class Person(Clone): """人""" def __init__(self, name, age): self.__name = name self.__age...
false
add5d0a107fddbb992a75b508eda4f0d9b2e5b55
my-xh/DesignPattern
/01创建型模式/01工厂方法/简单工厂模式.py
1,214
4.15625
4
from abc import ABCMeta, abstractmethod class Coffee(metaclass=ABCMeta): """咖啡""" def __init__(self, name): self.__name = name @property def name(self): return self.__name @abstractmethod def get_taste(self): pass class LatteCoffee(Coffee): """拿铁咖啡""" def ...
false
764a3d777da00681901ef7251ac5c2925d57576c
kazamari/Stepik
/course_568/2.245_repetition coding.py
687
4.375
4
''' Encoding of repeats is carried as the following: s = 'aaaabbсaa' is converted into 'a4b2с1a2', that is, the groups of the same characters of the input string are replaced by the symbol and the number of its repetitions in this string. Write a program that reads a line from the file corresponding to the string, com...
true
9a34599d4bab721fd842873a090fe7ab2eb559ea
kazamari/Stepik
/course_431/3.2_Math functions.py
853
4.28125
4
''' Напишите функцию f(x), принимающую дробное число x и возвращающую значение следующей функции, определённой на всей числовой прямой:   f(x)=⎧⎩⎨⎪⎪1−(x+2)2,−x2,(x−2)2+1,при x≤−2при −2<x≤2при 2<x Требуется реализовать только функцию, решение не должно осуществлять операций ввода-вывода. Sample Input 1: 4.5 Samp...
false
16b4c66261f6057635577382f87f38df85f3c289
kazamari/Stepik
/course_568/2.316_re-occurrence-of-a-symbol.py
2,386
4.625
5
''' In this problem, we will look how to implement re-occurrence of a symbol using regular expressions. We may use the three various constructions to implement the repeat: 1. Wildcards { }, inside which we can place the minimum/maximum number of repeats that we are satisfied with, or the exact number of repeats tha...
true
6afb4c76020ade8c19294dbd36574926ed37223f
kazamari/Stepik
/course_568/2.325_message-encoding.py
578
4.46875
4
''' We will be dealing with a trivial example of message encoding, where the mapping of original symbols to the "code" is simply taking the ASCII value of the symbol. For example, the "code" version of the letter 'A' would be 65. You will be given as input a string of any length consisting of any possible ASCII charac...
true
7a09b5c4a6616f296b64ef2f9797799193fdc167
ZacharyLasky/Algorithms
/recipe_batches/recipe_batches.py
956
4.125
4
#!/usr/bin/python import math def recipe_batches(recipe, ingredients): min_batch = None for ingredient in recipe: if ingredient in ingredients: batches = ingredients[ingredient] // recipe[ingredient] if min_batch is None: min_batch = batches else: ...
true
29a00d5c563dc100b8e3e07fd813b23838961cff
Nyajur/python-pill
/18 exponent_again.py
572
4.125
4
base = float(input("Please enter a number: ")) exponential = float(input("Pleae enter a power to raise to: ")) def raiser(): return base**exponential print(raiser()) def raiser(): base = float(input("Please enter a number: ")) exponential = float(input("Pleae enter a power to raise to: ")) return base*...
true
eaa3e22cabb29391f6aaf4531f8b76e7d465c321
xlaw-ash/VSLearn-Python
/PythonBasics/comprehensions.py
1,624
4.90625
5
# for loops have some special uses with List Comprehensions # Make a list of letters in greeting string. greeting = 'Hello World!' letters = [] for letter in greeting: letters.append(letter) print(letters) letters = [] # Above 3 statements can be combined in a single line. letters = [letter for letter in greeting]...
true
8aac407392e79b9f910e117562de31c5dd678d7a
xlaw-ash/VSLearn-Python
/PythonBasics/booleans.py
2,490
4.625
5
# Booleans have only two values. Either True or False. # Booleans are used for conditions. yes = True no = False print(yes) print(type(yes)) # Booleans are mostly used with logical operators. There are three main logical operators. # 'and' operator between two conditions returns True only when both conditions are True...
true
d4701afadc306985d744bdc1b613fd1a5330fd4b
kehillah-coding-2020/ppic04-ForresterAlex
/set_d.py
1,748
4.5625
5
#!/usr/bin/env python3 # # pp. 148, 151 # """ 4.36 Modify the frequency chart function to draw wide bars instead of lines. """ """ 4.37* Modify the frequency chart function so that the range of the x axis is not tightly bound to the number of data items in the list but rather uses some minimum and maximum values. "...
true
679e5e6734b9f3fa577e914c7b6ca3655dfc3884
StefanoskiZoran/Python-Learning
/Practise provided by Ben/Clock Calculator by Me.py
1,210
4.125
4
""" Request the amount of seconds via keyboard, turn the seconds into months/days/years/decades etc. """ def main(): seconds_request = int(input(f'Please input your desired seconds: ')) minute_result = 0 hour_result = 0 day_result = 0 month_result = 0 year_result = 0 decade_result = 0 ...
true
8d57357f8a8dd14248f31e1478f1ce51918bf617
jaredjk/FunWithFunctions
/FunWithFunctions.py
482
4.125
4
# for i in range(1,2001): # if i%2 !=0: # print "Number is {}. This is an odd Nnumber".format(i) # else: # print "Number is {}. This is an even Nnumber".format(i) def multiply(arr,num): for i in range(len(arr)): arr[i] *= num return arr a = [2,4,10,15] b = multiply(a,5) ...
false
254aa0ded80bba9f1cefcf1bee130276579604a6
KitsuneNoctus/makeschool
/site/public/courses/CS-1.2/src/PlaylistLinkedList-StarterCode/main.py
1,584
4.5
4
from Playlist import Playlist playlist = Playlist() while True: # Prints welcome message and options menu print(''' Welcome to Playlist Maker 🎶 ===================================== Options: 1: View playlist 2: To add a new song to playlist 3: To remove a song from playlist 4: ...
true
f3c543fb60d13114cd3e3b1b80176cae8c1f4d6b
KitsuneNoctus/makeschool
/site/public/courses/CS-2.2/Challenges/Solutions/challenge_1/src/vertex.py
1,155
4.25
4
class Vertex(object): """ Vertex Class A helper class for the Graph class that defines vertices and vertex neighbors. """ def __init__(self, vertex_id): """Initialize a vertex and its neighbors. neighbors: set of vertices adjacent to self, stored in a dictionary with k...
true
54433cda9ab97c3b60023dd046cc7aafc1f06908
KitsuneNoctus/makeschool
/site/public/courses/CS-2.1/Code/prefixtreenode.py
2,797
4.40625
4
#!python3 class PrefixTreeNode: """PrefixTreeNode: A node for use in a prefix tree that stores a single character from a string and a structure of children nodes below it, which associates the next character in a string to the next node along its path from the tree's root node to a terminal nod...
true
484d28af9a47fbb40976d28da8fe83b6f7391613
mattester/moocPython
/步骤二:python函数与模块/day20/文件的读取.py
1,120
4.125
4
def read_file(): """读取文件""" file_name = 'test2.txt' #保存文件的名字 #使用绝对路径 file_path = 'D:\\pythontest\\python基础知识\\步骤二\\day20\\test2.txt' #使用普通方式打开文件 f = open(file_name,encoding="utf-8") ''' 读取文件内容()所有 rest = f.read() 关闭 print(rest) 读取指定文件内容 rest = f.read(8) print(res...
false
6e332a122b6c6a83a49e2bdcc66aaba3bfb8a191
MayankMaheshwar/DS-and-Algo-solving
/hypersonic2.py
585
4.125
4
""" 1) Given an array nums containing n distinct numbers in the range [0, n], return the only number in the range that is missing from the array. Input: nums = [3,0,1] Output: 2 Explanation: n = 3 since there are 3 numbers, so all numbers are in the range [0,3]. 2 is the missing number in the range since it does not a...
true
a1fcaf556a09f43581122e608c1995ec37bbc260
nrkavya/python-training
/1.py
308
4.375
4
#Create a program to compare three numbers and find the bigger numbers no1 = int(input("Enter no1")) no2= int(input ("Enter no2")) no3 = int(input("enter no3")) if(no1>no2 and no1>no3): print("no1 is greatest") elif(no2>no1 and no2>no3): print("no2 is greatest") else: print("no3 is greatest")
true
60308a1f2aa94fa65c89ca7461b1ec664a7beba5
riceh3/210CT-CW
/binary_search.py
1,358
4.15625
4
def binary_search(entry): # Divide and Conquer """ Search through input for values within the given high & low parameters """ length = len(entry) middle = length/2 # Find the middle value in the list middle = int(middle) if entry[middle] == low or entry[mid...
true
352df6ef19d9ae8f85443aaf9a811a585e57bf37
lazywhitecat/Pratical
/Prac_03/temperatures.py
1,130
4.21875
4
def main(): #temperature conversion system determine_temperature_type = input('Enter your temperature type in celsius(c) or fahrenheit(f):') while True: if determine_temperature_type == 'c': celsius_value = float(input('Enter your celsius number:')) fahrenheit = convert_celsi...
false
cf981cdb74758f85e6e9801b94a2394911268a0a
LizzieDeng/kalman_fliter_analysis
/docs/cornell CS class/lesson 21. Object-Oriented Design/demos/point.py
1,932
4.21875
4
""" A module with a simple Point3 class. This module has a simpler version of the Point class. The primary purpose of this module is to show off the built-in methods __str__ and __repr___ Author: Walker White (wmw2) Date: October 20, 2019 """ import math class Point3(object): """ A class to represent a p...
true
d52820228570073946ec653e69322c7d30a2d315
LizzieDeng/kalman_fliter_analysis
/docs/cornell CS class/Lesson 28. Generators/demos/filterer.py
1,139
4.1875
4
""" Module to demonstrate the idea behind filter This module implements the filter function. It also has several support functions to show how you can leverage it to process data. You may want to run this one in the Python Tutor for full effect. Author: Walker M. White (wmw2) Date: May 24, 2019 """ def filter(f,...
true
c1478e4316bf8c3c4c764d4192dcb54b7d1140fa
LizzieDeng/kalman_fliter_analysis
/docs/cornell CS class/lesson 17. Recursion/demos/com.py
1,950
4.53125
5
""" A recursive function adding commas to integers. These functions show the why the choice of division at the recursive step matters. Author: Walker M. White (wmw2) Date: October 10, 2018 """ import sys # Allow us to go really deep #sys.setrecursionlimit(999999999) # COMMAFY FUNCTIONS def commafy(s): """ ...
true
0ff7c36732279dd198f5034931b84041c0ac45d4
LizzieDeng/kalman_fliter_analysis
/docs/cornell CS class/lesson 16. For-Loops/demos/mut.py
906
4.40625
4
""" Module to demonstrate how to modify a list in a for-loop. This function does not use the accumulator pattern, because we are not trying to make a new list. Instead, we wish to modify the original list. Note that you should never modify the list you are looping over (this is bad practice). So we loop over the ran...
true
e633be9b864b2ae81f2275718708f73f9aff44e6
LizzieDeng/kalman_fliter_analysis
/docs/cornell CS class/lesson 26. While-Loops/demos/newton.py
1,256
4.40625
4
""" A module to show while-loops and numerical computations. This is one of the most powerful uses of a while loop: using it to run a computation until it converges. There are a lot of algorithms from Calculus and Numerical Analysis that work this way. Author: Walker M. White Date: April 15, 2019 """ def sqrt(c,...
true
cb35550231866abfbadca029a1c91a125a2e9e2f
gunishj/python_async_multiprocessing
/AsyncIO/implementing_asyncio.py
1,157
4.5625
5
import asyncio import time def sync_f(): print('one', end=' ') time.sleep(1) # I'm simulating an expensive task like working with an external resource. I want it to wait for 1 sec print('two', end=' ') # ASYNCHRONOUS async def async_f(): print('one', end=' ') await asyncio.sleep(1) print('two',...
true
d0b10155a5fea50e349d21c7ad7167f747d58ce8
Regenyi/python
/simplecalc.py
1,026
4.34375
4
#Regényi Ádám / CC , Python 1st SI Assignment while True: nr1 = input("Enter a number (or a letter to exit:) ") if nr1.isdigit(): nr1int = int(nr1) else: exit() list1 = ["+", "-", "*", "/"] operation = input("Enter an operation (+, -, *, /) : ") while operation not in list1...
false
0fcd16dcfa157c95f8ff55b16fb8e8f687a96e62
Regenyi/python
/Thonny_continue.py
729
4.15625
4
menu = """-- Calculator Menu -- 0. Quit 1. Add two numbers 2. Subtract two numbers 3. Multiply two numbers 4. Divide two numbers""" selection = None while selection != 0: print(menu) selection = int(input("Select an option: ")) if selection not in range(5): print("Invalid option: %d" % selection)...
true
fa669ab56fb32241a23d3f9d00857001571cb2b2
Regenyi/python
/sorting.py
1,608
4.1875
4
#Sorting algo - RA CC Python SI1 A3 import re #getting the number from the user: input_numbers = [] input_numbers = input("\nTell me positive integers that you want to sort, by separting them with a coma (so for example: 10,2,45):\n\n") #exception handler for wrong format: while True: if (len(input_numbers)<6 or...
true
a3c4170dbc8d48142cf7f8319ba45775e1956886
Tij99/compsci-jmss-2016
/triangleXs.py
384
4.28125
4
# Write a program to print out an isosceles triangle of Xs # rewrite the program to work for an arbitrary number of rows (ie the user can # enter the required number of rows) def triangle(height): for i in range(height): spaces = height - i - 1 xs = 2 * i + 1 print("-" * spaces + "|" * xs ...
true
d289d24ab9aee8fe7b75a91d8282d06f9e5a5740
VitorSchweighofer/exertec
/Exercicio4/exercicio 4/exe6.py
531
4.15625
4
numero1 = int(input('Digite o numero inferior aqui: ')) numero2 = int(input("Digite o numero superior aqui: ")) divisores = 0 if (numero1>numero2): print('O suposto limite inferior está maior que o superior') for divisor in range(numero1, numero2+1): if (divisor == 2): print('2') if (divisor == 3): prin...
false
f8ac9454b1333d1fce5f4f43c2d3b54731b979b7
ArthurkaX/W3SCHOOL-learning
/Python basic P1/Ex_3.py
286
4.40625
4
# Write a Python program to display the current date and time import datetime print('first variant:') print('current date & time is:') print(datetime.datetime.now()) now = datetime.datetime.now print('second variant:') print('{0:%Y-%m-%d %H:%M:%S}'.format(datetime.datetime.now()))
true
d5fac45dfae4e162546dd53c4a2b3bd154bcc4a3
ArthurkaX/W3SCHOOL-learning
/Python basic P1/Ex_1.py
514
4.25
4
# Write a Python program to print the following string in a specific format some_txt = 'Twinkle, twinkle, little star, How I wonder what you are! Up above the world so high, Like a diamond in the sky. Twinkle, twinkle, little star, How I wonder what you are' x = 0 for a in some_txt: if a.isupper() == True and a ...
true
50426db78b533ce033a059f1157c9f0d44123146
rishabhchopra1096/Python_Crash_Course_Code
/Chapter_9_Classes/Dog.py
800
4.21875
4
class Dog(object): """A simple attempt to model a dog.""" def __init__(self,name,age): """Initialize name and age attribute""" self.name=name self.age=age def sit(self): """Simulate a dog sitting in response to a command""" print(self.name.title()+" is now sitting.")...
true
91b3c0eace34899e1e0f2c1e40853ace87382362
rishabhchopra1096/Python_Crash_Course_Code
/Chapter_3_Intoducing_Lists/bicyclesIntroToLists.py
1,152
4.625
5
#In Python, square brackets indicate a list, and individual elements in the list are separated by commas. bicycles = ['trek', 'cannondale', 'redline', 'specialized'] print(bicycles) #Because this isnt the output you want your users to see, lets learn how to access the individual items in a list. #To access an ele- ment...
true
0ba59210ae47c36fd6abeab0670ead59fef062f7
rishabhchopra1096/Python_Crash_Course_Code
/Chapter_3_Intoducing_Lists/untitled folder/3-3.py
462
4.46875
4
# 3-3. Your Own List: Think of your favorite mode of # transportation, such as a motorcycle or a car, and # make a list that stores several examples. Use your # list to print a series of statements about these items, # such as “I would like to own a Honda motorcycle.” cars = ['audi' , 'bmw' , 'mercedes'] print("I wou...
true
d88e288cffdaf538374ae33bc2f91b3410b3b143
rishabhchopra1096/Python_Crash_Course_Code
/Chapter_9_Classes/electric_car.py
2,219
4.46875
4
class Car(object): """A simple attempt to represent a car""" def __init__(self,make,model,year): """Initialize attributes to describe a car""" self.make=make self.model=model self.year=year self.odometer_reading=0 def get_descriptive_name(self): """Return a ...
true
d11e007939ad611f6f34dbf43ef9949442310658
rishabhchopra1096/Python_Crash_Course_Code
/Chapter_7_User_Input_And_While_Loop/Practice2/4.rollercoaster.py
209
4.15625
4
height = raw_input("How tall are you , in inches? ") height = int(height) if height >= 36: print("\nYou're tall enought to ride!") else: print("You will be able to ride when you're a little older.")
true
68b3d1a63e3df0f1f75e4fc83af3a3dd2b29f093
rishabhchopra1096/Python_Crash_Course_Code
/Chapter_3_Intoducing_Lists/untitled folder/3-2Greetings.py
477
4.25
4
# 3-2. Greetings: Start with the list you used in Exercise 3-1, but instead of just printing each persons name, # print a message to them. The text of each message should be the same, but each message should be personalized # with the persons name. friend_list=['manan','samarth','rohan','rishi'] print ("Hello, "+frien...
true
3389a5cd1051d2edcf6125b7adb4452d591f0726
rishabhchopra1096/Python_Crash_Course_Code
/Chapter_9_Classes/practice2/9-6.IceCreamStand.py
1,332
4.21875
4
class Restaurant(): """An attempt to model a restaurant""" def __init__(self,restaurant_name,cuisine_type): """Initializing name and age attributes""" self.name = restaurant_name self.cuisine = cuisine_type def describe_restaurant(self): # Describes the restaurant name...
true
9a707f3c487622e2c8caa16d2d8ca8c4d7507911
rishabhchopra1096/Python_Crash_Course_Code
/Chapter_8_Functions/practice2/16.profile.py
989
4.53125
5
# Sometimes you'll want to accept an arbitary number of # argument but you won't know ahead of time # what kind of information will be passed to the # function. # Write a function that accepts as many key-value pairs as the # calling statement provides. # Example : Building user profiles. # You're sure that you'll ge...
true
c9349dd22148f7f878bb1be59820cc8e1b6ddcd5
rishabhchopra1096/Python_Crash_Course_Code
/Chapter_10_File_And_Exceptions/10-6.Addition.py
1,950
4.15625
4
while True: try: first_number = raw_input("Give me two numbers and i will add them." + "\nEnter 'quit' to quit program anytime."+ "\nFirst Number: ") if first_number == 'quit': break else: first_number = int(first_number) second_number ...
true
f2d74a5bea40e74454c884bfefb8ec99d9b9d276
rishabhchopra1096/Python_Crash_Course_Code
/Chapter_5_If_Statements/banned_users_CheckWhetherAValueIsInAList.py
986
4.125
4
print "Checking whether a value is not in a list " # Other times, its important to know if a value does not appear in a list. # You can use the keyword not in this situation. For example, consider a # list of users who are banned from commenting in a forum. You can check whether # a user has been banned before allo...
true
d41a8dd0a5d9aa2cd89cfc6d11ee9c75b1c31dbb
TetyanaLi/hillel_python
/LEVEL_1/LESSON_4/lesson4-1.py
782
4.21875
4
#1. В первый день спортсмен пробежал `x` километров, # а затем он каждый день увеличивал пробег на 10% от предыдущего значения. # По данному числу `y` определите номер дня, на который пробег спортсмена составит не менее `y` километров. #Программа получает на вход числа `x` и `y` и должна вывести одно число - номер дня....
false
5beb2bb5627236220420ff6078a2c7d299b9b140
TetyanaLi/hillel_python
/LEVEL_1/LESSON_11/lesson 11-3.py
1,340
4.46875
4
#3. Написать функцию которая вернет самое длинное слово в строке: # longest_word("What makes a good man") -> makes #x = input('Введите действительное число с двумя знаками после десятичной точки: ') some_list = 'What makes a good man' def longest_word(some_list): elements = some_list.split() new_list = [] ...
false
a994791a052a4abfb6a9a54e89d6c88d58224e4b
herzenuni/herzenuni-sem3-assignment4-191217-AnnGoga
/treemin.py
713
4.15625
4
def minimum_three_mpy(*args): if len(args) < 3: print("minimum_three_mpy : 3 arguments minimum") return None try: mpy = args[0] * args[1] * args[2] counter = 0 for i in range(len(args)): for j in range(i + 1, len(args)): for k in range(j + 1, len(args)): counter += 1 new_mpy = ...
false
aae8f905c66d6d76f3413fe0c3c93baca99e2acb
GabrielReira/Python-Exercises
/42 - Números ordenados.py
575
4.125
4
all_values = [] n = int(input('Quantos valores você deseja digitar? ')) for i in range(n): value = int(input('Digite um valor: ')) # Se for o primeiro item ou se for maior que o último valor. if (i == 0) or (value > all_values[-1]): all_values.append(value) # Se estiver entre os itens do...
false
35adb2b17002fca26b19cf9b8b7c05c7a5862f44
0x420x42Rodriguez/100-Days-of-Code
/Day 4/RockPaperScissors.py
1,506
4.375
4
import random rock = ''' _______ ---' ____) (_____) (_____) (____) ---.__(___) ''' paper = ''' _______ ---' ____)____ ______) _______) _______) ---.__________) ''' scissors = ''' _______ ---' ____)____ ______) __________) (____) ...
false
7d900b9d8a49c9f3b4753b7c8effd72764ddbbf6
sweenejp/learning-and-practice
/treehouse/python-beginner/monty_python_tickets.py
1,349
4.15625
4
SERVICE_CHARGE = 2 TICKET_PRICE = 10 tickets_remaining = 100 def calculate_price(number_of_tickets): # $2 service charge per transaction return (number_of_tickets * TICKET_PRICE) + SERVICE_CHARGE while tickets_remaining > 0: print("There are only {} tickets remaining!\nBuy now to secure your spot for th...
true
8b69c22357ef25ddca9167989f2337674fe78784
sweenejp/learning-and-practice
/practicepythondotorg/exercise_14.py
692
4.1875
4
# Write a program (function!) that takes a list and returns a new list that contains all the # elements of the first list minus all the duplicates. # # Extras: # # Write two different functions to do this - one using a loop and constructing a list, # and another using sets. Go back and do Exercise 5 using sets, and wri...
true
cb066d54e563da61e1c97f7621ac4ac43c42e3e1
sweenejp/learning-and-practice
/treehouse/python-beginner/team.py
1,286
4.21875
4
# TODO Create an empty list to maintain the player names player_names = [] # TODO Ask the user if they'd like to add players to the list. wants_to_add = input("Would you like to add a player to the team?\nYes/no: ") # If the user answers "Yes", let them type in a name and add it to the list. while wants_to_add.lower...
true
28301a007b829871cd518834994588e9f088b53b
Kinosa777/Lits-Python
/convert_n_to_m.py
1,377
4.21875
4
def convert_n_to_m(x, n, m): """Converts a number in n-based system into a number in m-based system.""" def convert_n_to_dec(x): """Converts a n-based number into decimal. No int(num, base) function for number conversion is used.""" if n == 10: return x elif n == 1: ...
true
7298c7eca57f058c10682bcdfffb19a25c863293
leisurexi/python-study
/03/listtuple.py
1,697
4.125
4
# author: leisurexi # date: 2021-01-11 23:25 # 列表和元组示例,列表和元素都是一个可以放置任意数据类型的有序集合 # 列表是动态的,长度大小不固定,可以随意地添加、删除或者改变元素 lists = [1, 2, 3, "hello"] lists[2] = 20 lists.append(5) print(f'列表添加和修改元素后: {lists}') lists.remove(1) print(f'列表删除元素后: {lists}') # -1 代表最后一个元素,-2 代表倒数第二个元素以此类推 print(f'列表负数索引: {lists[-1]}') # 切片包前不包后 prin...
false
235fdaa0a8994a442342fd0521db8ffaebbdbd10
tohkev/Module-5-Hwk
/loopy_loops.py
671
4.125
4
if __name__ == '__main__': pokemon = ('pikachu', 'charmander', 'bulbasaur') print(pokemon[1]) starter1 = pokemon[0] starter2 = pokemon[1] starter3 = pokemon[2] print(starter1, starter2, starter3) name_tuple = tuple('Kevin') print(name_tuple) is_there_i = 'i' in name_tuple pri...
false
3aecd3afc0558b00aa683aeb245b1e2876f78706
hazim/Treehouse---Python-Basic
/check_please.py
519
4.21875
4
import math def split_check(total, number_of_people): # we want to round up the number in order to make sure that the person paying is not paying the extra out of their own pocket return math.ceil(total_due / split_among) try: total_due = float(input("What is the total? \n")) split_among = int(input("How many ...
true
c593de4528944eecdd6c30ddeb1d1ccc27517dec
Three-Y/MyPythonLearning
/ibbie_16_列表.py
2,048
4.1875
4
""" 列表(list,相当于java中的数组) 格式:变量名=["hhh","xxx","jjj","aaa"] 索引值从0开始 可以存放不同类型的数据,但是通常存放类型相同的数据 """ """创建列表""" name_list = ["hhh", "jjj", "jjj", "aaa"] print(name_list) """根据索引取值""" name_list[2] # name_list[4] # IndexError: list index out of range print(name_list[2]) """根据内容取索引""" name_list.index("aaa") # na...
false
84a49f93c9e05a35e7ae543e8b03dc7f9cb0a8ce
Three-Y/MyPythonLearning
/ibbie_32_父类的公有属性和方法.py
825
4.34375
4
""" 父类的公有属性和方法 子类可以调用父类的公有属性和方法 子类对象也可以调用父类的公有属性和方法 可以通过父类的公有方法,在子类间接调用父类的私有属性和方法 """ class A: def __init__(self): self.a = "父类公有属性" self.__b = "父类的私有属性" def test(self): print("父类公有方法") print("父类的公有方法中调用父类的私有属性和方法:") print(self.__b) self.__test2() ...
false
5839e093920e86c0a2f9fa7449540a2552311a06
Three-Y/MyPythonLearning
/ibbie_36_多态.py
461
4.125
4
""" 多态 不同的子类对象,调用相同的父类方法,产生不同的结果(同java,略) """ class Animal: def eat(self): print("吃东西") class Dog(Animal): def eat(self): print("狗狗吃骨头") class Cat(Animal): def eat(self): print("猫猫吃鱼") class Master: def feed(self,animal): animal.eat() cat = Cat() dog = Dog()...
false
7f4dd8521d12aa3d208fa4c51d507d84b304de6b
mtaziz/python_projects
/Basic Rock Paper Scissors Game (CLI).py
1,945
4.25
4
import random # Welcome text print("ROCK PAPER SCISSORS") # Game variables ties = 0 wins = 0 losses = 0 # Gameloop while True: # Displaying game data. print("%s Wins, %s Loses, %s Ties" % (wins, losses, ties)) # Loop for player choice. while True: print("Enter any one: (r)ock (p)aper (s)ciss...
true
5af7a4ac6b300fee0b1e86a4eb14378eb9243279
cgscreamer/UdemyProjects
/Python/dictionaries.py
671
4.1875
4
fruit = {"orange": "a sweet, orange, citrus fruit", "apple": "good for making cider", "lemon": "a sour, yellow citrus fruit", "grape": "a small, sweet fruit growing in bunches", "lime": "a sour, green citrus fruit"} #To add to a dictionary fruit["pear"] = "an odd shaped apple" #To ...
true
fa82962cae016363dee794c962553a62b8a4fdc8
andyhou2000/exercises
/chapter-6/ex_6_5.py
1,129
4.125
4
# Programming Exercise 6-5 # # Program to total the value of numbers in a text file. # The program takes no user input, but requires a text file with numbers, one per line, # which it opens, reads line by line, and totals the numbers in a variable, # then displays the total on the screen. # Define the main ...
true
5bd4a64c40de41eb21d95ec08c4ce5ba06d351b8
andyhou2000/exercises
/chapter-4/ex-4-5.py
2,173
4.46875
4
# Programming Exercise 4-5 # # Program to compute total and average monthly rainfall over a span of years. # This program gets a number of years from a user, # then uses nested loops to prompt for rainfall for each month in each year # and calculate the total and the average monthly rainfall, # then displays the ...
true
80c8bb6fa0068c40e7417af66c9230ec5945fcfc
andyhou2000/exercises
/chapter-2/ex-2-5.py
797
4.59375
5
# Programming Exercise 2-5 # # Program to calculate distances traveled over time at a speed. # This program uses no input. # It will calculate the distance traveled for 6, 10 and 15 hours at a constant speed, # then display all the results on the screen. # Variables to hold the three distances. # be sure to in...
true
ddc8b5c1c688595eb24cdebc4d594fa50faa04c6
impradeeparya/python-getting-started
/tree/SymetricTree.py
2,042
4.21875
4
# Definition for a binary tree node. class TreeNode(object): def __init__(self, val=0, left=None, right=None): self.val = val self.left = left self.right = right class Solution: def is_child_symmetric(self, children): is_symmetric = True left_index = 0 right_ind...
true
a145bda0848c345599343ef6abee82d44a11ba41
chanchalkumawat/Learn-Python-Hardway
/ex4of46.py
351
4.15625
4
#Write a function that takes a character (i.e. a string of length 1) and returns True if it is a vowel, False otherwise. def check(c): if c=='a'or c=='A' or c=='e' or c=='E' or c=='i' or c=='I' or c=='o' or c=='O' or c=='u' or c=='U': return True else: return False z=raw_input("Enter the charact...
true
40586a96dad88b27a9819cead81a91bb838a5442
liweichen8/Python
/104Reverse_reversed.py
363
4.28125
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Thu Jul 30 22:59:19 2020 @author: liweichen """ def reverse_reversed(items): for i in range(len(items)): if type(items[i])==list: #print(items[i]) item=reverse_reversed(items[i]) items[i]=item #p...
false
7278e5b16a928c6764dde79d296d30e063352e93
taylorperkins/foobar
/test/test_solar_doomsday.py
1,916
4.125
4
import unittest from utils import print_time from logic.solar_doomsday import answer class TestSolarDoomsday(unittest.TestCase): """Challenge 1 Solar Doomsday ============== Who would've guessed? Doomsday devices take a LOT of power. Commander Lambda wants to supplement the LAMBCHOP's quantum an...
true
f227f9eeb846c6faf3f4b36e0b7d0930837adf59
sahaj2005/pythonLearning
/pythonlearning2.py
379
4.25
4
#string str1='hello world' str2="this is good boy " print(str1) print(str2) #index my_str="My name is jhon" print(my_str[0]) print(my_str[-1]) print(my_str[1:5]) print(len(my_str)) print(my_str.lower()) print(my_str.upper()) #replace str2="My name is saju" print(str2.replace('s','S')) print(str2.count('a')) str3="...
false
719d9d0e1b3548a2b791779d09693228e0824ab7
prof-paradox/project-euler
/7.py
520
4.125
4
''' Calculates the 10001st prime number ''' import math def isPrime(num): if num % 2 == 0: return False for i in range(3, round(math.sqrt(num)) + 1, 2): if num % i == 0: return False return True natural_no = 3 prime_count = 1 # initial count for 2 max_prime = 2...
true
db37990f15e0b9eaeab5dacf38b1adf87735b416
rawsashimi1604/Qns_Leetcode
/leetcode_py/valid-parentheses.py
834
4.125
4
class Solution: def isValid(self, s: str) -> bool: stack = [] lookup = { "}": "{", ")": "(", "]": "[" } for p in s: if p in lookup.values(): stack.append(p) # Must make sure that stack exists, so that there...
true
df38b1d404b01498a368916adb754a496f354c1e
callumr1/Programming_1_Pracs
/Prac 4/number_list.py
681
4.15625
4
def main(): numbers = [] print("Please input 5 numbers") for count in range(1, 6): num = int(input("Enter number {}: ".format(count))) numbers.append(num) average = calc_average(numbers) print_numbers(numbers, average) def calc_average(numbers): average = sum(numbers) / len(nu...
true
c543270a6ffa5c251551c3cc3eb2082e013a2e0e
CRUZEAAKASH/PyCharmProjects
/section3_StringsAndPrint/String Methods.py
1,469
4.5
4
""" len() and str() practice: 1.create a variable and assign it the string "Python" 2.create another variable and assign it the length of the string assigned to the variable in step 1 3.create a variable and use string slicing and len() to assign it the length of the slice "yth" from the string assigned to the variabl...
true
15d758afcd551443056c912accd5a639b0d150c2
CRUZEAAKASH/PyCharmProjects
/section4_ConditionalsAndFlowControl/BooleanOperatorProblems.py
1,605
4.625
5
""" and, or, and not: 1.create a variable and set it equal to True using a statement containing an "and" Boolean operator 2.create a variable and set it equal to False using a statement containing an "and" Boolean operator 3.create a variable and set it equal to True using a statement containing an "or" Boolean operato...
true
cafc90b922a9c73f77e2ff2d3020c8563e93d60b
CRUZEAAKASH/PyCharmProjects
/section14_RegularExpressions/findAll.py
215
4.15625
4
import re pattern = r"eggs" String = "We have eggs in our string. eggs just eggstoeggs count the presence of eggs in the string" print(re.findall(pattern, String)) print(re.findall(pattern, String).__len__())
true
f5b2f41977280c6920d18c3736071647b38f0786
CRUZEAAKASH/PyCharmProjects
/section5_Functions/FunctionsProblems.py
2,525
4.875
5
""" Single parameter and zero parameter functions: 1.define a function that takes no parameters and prints a string 2.create a variable and assign it the value 5 3.create a function that takes a single parameter and prints it 4.call the function you created in step 1 5.call the function you created in step 3 with the v...
true
1a07035dcb4f3909b26f5b0aa1d1b4af20192866
CRUZEAAKASH/PyCharmProjects
/section15_Tkinter/TkinterMessageBox.py
340
4.125
4
from tkinter import Tk from tkinter import messagebox window = Tk() messagebox.showinfo("title", "You are seeing message box") response = messagebox.askquestion("Question 1", "Do you love Coffee?") if (response == 'yes'): print("Here are your coffee loverrr!!!!!!!!!!!!!!!!!") else: print("What do you love???"...
true
ef26690eccdd553f9a81cd1b9daa6f5c9e02cb93
chithracmenon/AutomateBoringStuff
/ch7_date_detection.py
1,743
4.71875
5
"""Date Detection Write a regular expression that can detect dates in the DD/MM/YYYY format. Assume that the days range from 01 to 31, the months range from 01 to 12, and the years range from 1000 to 2999. Note that if the day or month is a single digit, it’ll have a leading zero. The regular expression doesn’t have t...
true
4a891d4030805ca7bab9a9b2538d3c2084cd3114
JaneNjeri/python_crash_course
/factorial.py
235
4.3125
4
def factorial(num): if num == 0: return 1 else: return num * factorial(num - 1) print("Please enter a number to recieve its factorial.") num = int(input() ) print (factorial(num)) # good recursion practice
true
cde34a198a2699acfbae74f87e49c60b43fb85bd
annisa-nur/wintersnowhite
/exception.py
2,550
4.1875
4
# Program ini meminta pengguna memasukkan dua angka untuk operasi pembagian # Program menampilkan pesan jika terjadi eksepsi def main(): # [1] Tuliskan statement try/except # Pada body klausa try: # - Minta dua angka ke pengguna # - Lakukan pembagian # Pada body klausa except untuk Va...
false
da211a279fca121ab5531e59190dc9d0c4198a5c
annisa-nur/wintersnowhite
/processingrecord.py
1,698
4.25
4
# Program ini menambahkan record nilai mahasiswa # ke file nilai_mahasiswa.txt def main(): # [1] Minta pengguna berapa banyak record yang ingin dimasukkan jmlRec = int(input("Berapa banyak record nilai mahasiswa yang ingin Anda tambahkan? ")) # [2] Buka file dengan statement with, minta input mas...
false
ac74ba0fde939786aca05fff2648c368f46db4ef
miaha15/Programming-coursework
/Week 5 Question 1.py
974
4.34375
4
''' Premade list is given to the function A for loop is used to step through the list As it steps through each value of the list, it appends the list called TempList If the current element is GREATER than the next element of the list then it will check if everything stored in the TempList upto current element is longer...
true
9067db5d36f43f7d225c98628272ab067ac8dbd9
yerol89/100_Days_Of_Coding_With_Python
/1. Day_1_Working With Variables to Manage Data/Day1.py
861
4.1875
4
print("Day 1 - String Manipulation") print("String Concatenation is done with the '+' sign.") print("New lines can be created with a backslash.") print("Hello" + " " + "Everyone") print("Hello Python\nHello 100 Days of Coding") print("Hello" + " " + input("What is your name?\n")) name = input("What is your name? ") pri...
true
5e5d664cba8f82e045f025a763a3825d5342b0dd
msausville/ToolBox-Pickling
/counter.py
2,030
4.40625
4
""" A program that stores and updates a counter using a Python pickle file""" from os.path import exists import sys from pickle import dump, load def update_counter(file_name, reset=False): """ Updates a counter stored in the file 'file_name' A new counter will be created and initialized to 1 if none exists...
true
737c4183d9b77db804165e51af24f8a051e31ec9
maumneto/IntroductionComputerScience
/CodeClasses/FunctionsCode/cod1.py
286
4.28125
4
# O módulo Math possui um conjunto de funções import math num1 = int(input('Digite um valor numérico: ')) res = math.sqrt(num1) # nesta linha o código principal irá parar para executar a função math no sistema de módulos do python! print(f'A raiz quadrada de {num1} é {res}')
false
4b2011ee272cdbf2b8b093786a392f0752a5a7cd
maumneto/IntroductionComputerScience
/CodeClasses/SequentialCodes/cod7.py
566
4.125
4
""" Escreva um programa que pede os seguintes dados: • Valor do salário de um funcionário • Aumento em porcentagem Depois mostre o valor do aumento e o salário com aumento arredondados para duas casas decimais """ # entrada de dados salario = float(input("Digite o salario: ")) aumento = float(input("Digite a porcentage...
false
2b47b550001583c7a0f60d8b2022051796d39ad5
utkpython/utkpython.github.io
/session3/simulation.py
733
4.3125
4
# modeling the idea that "students getting ahead in life" # some start off in a higher spot # some have more skill, some less from random import randint import matplotlib.pyplot as plt def rand_walk(numSteps, position, skill): '''Returns a random walk list of size numSteps + 1. position is the starting pos...
true
1ae5d1eb7c5408cedc29486dbe1ee36a2a0df77c
joyvai/Python-
/stopwatch.py
1,615
4.28125
4
# stopwatch.py - A simple stopwatch program. # The stopwatch program will need to use the current time, so you will want to # import the time module. Your program should also print some brief instruc- # tions to the user before calling input() , so the timer can begin after the user # presses enter . Then the code will...
true
4cb0e6419406286e87f84ece09c9baff8bd3cb5b
joyvai/Python-
/leapYear.py
590
4.15625
4
""" if (year is not divisible by 4) then (it is a common year) else if (year is not divisible by 100) then (it is a leap year) else if (year is not divisible by 400) then (it is a common year) """ def is_leap_year2(year): if year % 4 == 0: return True elif year % 100 == 1 : return False elif year % 400 =...
false
530fe5b55fe23ad17ac63c31fd7ccba2c2371a27
aaronBurns59/3rd-year-functions-python
/printList.py
404
4.40625
4
def printList(l): for x in l: print(x) list1 = [0,1,2,3,4,5,6,7,8,9,10] list2 = ['apple', 'orange', 'banana', 'pear', 'kiwi'] list3 = [0.1,2.0,3.3,4.5,8.5] choice = 0 while choice <= 0 or choice > 3: choice = int(input("Enter which list you want 1, 2 or 3: ")) if choice == 1: list = list1 elif ...
false
c643875b3f5b48f71f59b6b43c6ba0e4186aaa86
arrayatsabitah/mongga
/modul.py
1,620
4.1875
4
# suatu objek dikatakan class jika punya atribut __init__ class orang: def __init__(self, nama, umur): #init tu ngejelasin tentang saya (self) self.nama = nama self.umur = umur # kayak buat ngenalin diri sendiri def jalan(self): print('orang jalan') def makan(self): ...
false
7412acf2022c4a9509ddd22859ba8f85422abf57
fobbytommy/Algorithm-Practice
/10_week_2/nth_largest.py
386
4.34375
4
# Given an array, return the Nth-largest element from python_modules import bubble_sort def nth_largest(arr, n): list_length = len(arr) if n <= 0 or list_length < n: return None sorted_arr = arr bubble_sort.bubble_sort(sorted_arr) return sorted_arr[list_length - n] arr = [23, 32, -2 , 6 ,2 ,7, 10, 3, 10, ...
true