blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
1f78c540f60b806c42790f8ad770486c289a92e3
croguerrero/pythonexercises
/ejerciciospracticafunciones.py
1,642
4.1875
4
def area_rectangulo(base,altura): """ Calcula el area del rectangulo Arg: base y altura (int or float) Return: area(Float) """ if base > 0 and altura > 0: area = base * altura else: print("Los parametos ingresados de base y altura no son los correctos") ...
false
c98bb5bb0e732c435b577a70b9e9b7cc4d3b38e9
croguerrero/pythonexercises
/filterfuncion.py
723
4.125
4
###La funcion filter ## aplica la funcion a todos los elementos de un objeto iterable ##Devuelve un objeto generado de ahiq eu usemos las funcion list() para convertirlo a lista ### Duvuelve los elementos para los cuales aplicar la funcion devuelve un true nums = [49, 57, 62, 147, 2101, 22] print(list(filter(lambd...
false
9ab9a300bdda856d7d05757c6c2916887719c524
croguerrero/pythonexercises
/funcioncompleja.py
2,666
4.125
4
from typing import Container def euclidean_division(x, y): ints = (x == int(x)) and (y == int(y)) if not ints: x = int(x) y = int(y) print("Se tomarán como parámetros la parte entera de los valores introducidos.") if abs(x) >= abs(y): q = x // y r = x % y print("Se ha realizado la ...
false
707330c6a067b20d68b1864052f8114237154a52
croguerrero/pythonexercises
/funcionsorted.py
635
4.46875
4
#### la funcion sorted() ### Ordena los elementos del objeto iterable que indiquemos de acuerdo a la función que pasemos por parámetro #### Como output, devuelve una permutación del objeto iterable ordenado según la función indicada ##Ejercicio: Con la ayuda de las funciones lambda, apliquemos sorted() para ordenar ...
false
c77a6dd6090ddd15e50741841a66cb05e8db771a
shashbhat/Internship_Data_Analytics
/Assignment/Day 1/6.py
387
4.375
4
''' 6. Write a program to accept a number from the user; then display the reverse of the entered number. ''' def reverse_num(num): ''' Reverses a number and returns it. ''' rev = 0 while num != 0: rev = rev * 10 + num % 10 num = num // 10 return rev num = int(input("Enter a numb...
true
4ac7158db07e3d5ce9de5125b646eee70fec24b3
milind1992/CheckIO-python
/Boolean Algebra.py
1,713
4.5
4
OPERATION_NAMES = ("conjunction", "disjunction", "implication", "exclusive", "equivalence") ​ def boolean(x, y, operation): ​ if operation=="conjunction": #"conjunction" denoted x ∧ y, satisfies x ∧ y = 1 if x = y = 1 and x ∧ y = 0 otherwise. return x*y ​ elif operation=="disjunction": #"disjunc...
true
47ad2084d09c9be3ffae5d20f34cac14b96f85e3
CodeAltus/Python-tutorials-for-beginners
/Lesson 3 - Comments, input and operations/lesson3.py
269
4.21875
4
# Taking user input dividend = int(input("Enter dividend: ")) divisor = int(input("Enter divisor: ")) # Calculation quotient = dividend // divisor remainder = dividend % divisor # Output results print("The quotient is", quotient) print("The remainder is", remainder)
true
c86b788a0d4bab42f59fde14c1d3a35b034171a1
GedasLuko/Python
/Chapter 5 2/program52.py
673
4.15625
4
#Gediminas Lukosevicius #October 8th, 2016 © #import random function #build numbers function first #create accumulator #create a count in range of five numbers #specify five numbers greater than ten but less than thirty #create a total for five numbers assignment #display five random numbers and total as specified #bu...
true
1527cdb327c0d59506154813384d32718ceb1864
GedasLuko/Python
/chapter 2/program24.py
587
4.5
4
#Gediminas Lukosevicius #September 1st, 2016 © #This program will convert an improper fraction to a mixed number #Get Numerator #Get Denominator #Convert improper fraction to mixed number #Dislpay the equivalent mixed number with no space either side of the / symbol numerator = int(input('Please enter the numerator: '...
true
53c1bd002b7c652df805e6ea2cd1991746508aef
GedasLuko/Python
/write_numbers.py
510
4.375
4
#Gediminas Lukosevicius #October 24th, 2016 © #This program demonstrates how numbers must be converted to strings before they are written to a text file. def main(): outfile = open('numbers.txt', 'w') num1 = int(input('Enter a number: ')) num2 = int(input('Enter another number: ')) num3 = int(input('...
true
7ab57f62d55657bcba373ca0ab2cfea240039b64
GedasLuko/Python
/Chapter 5/program53/tempconvert.py
490
4.40625
4
#Gediminas Lukosevicius #October 8th, 2016 © #This program will convert temperature from celsius to fahrenheit #and fahrenheit to celsius #write formula for celsius to fahrenheit #display converted celsius temperature in fahrenheit #create function with formula for fahrenheit to celsius conversion #return fahrenheit t...
false
25e2f64d1c80edac30dfb37bf57035cc2b3d1e1d
zsoltkebel/university-code
/python/CS1028/practicals/p2/seasons.py
868
4.25
4
# Author: Zsolt Kébel # Date: 14/10/2020 # The first day of seasons of the year are as follow: # Spring: March 20 # Summer: June 21 # Fall: September 22 # Winter: December 21 # Display the season associated with the date. month = "Mar" date = 23 if month == "Jan" or month == "Feb": print("Winter") elif month ==...
true
c437e2b2397e99a209a6b2273117a443d198e277
gschen/where2go-python-test
/1906101041刘仕豪/第九周练习题/3.py
802
4.125
4
''' 3、 输入三个整数x,y,z,请把这三个数由小到大输出。 ''' # x = int(input("请输入正整数x:")) # y = int(input("请输入正整数y:")) # z = int(input("请输入正整数z:")) # if y>x and y>z and z>x: # x1 = y # y1 = z # z1 = x # elif y>x and y>z and x>z: # x1 = y # y1 = x # z1 = z # elif x>z and z>y: # y1 = z # z1 = y # x1 = x # eli...
false
60b40f345a12dac59f986ec76fbf76bc787a9ff3
gschen/where2go-python-test
/1906101001周茂林/第16周20191215/力扣-1.py
503
4.25
4
''' 给你一个单链表的引用结点 head。链表中每个结点的值不是 0 就是 1。已知此链表是一个整数数字的二进制表示形式。 请你返回该链表所表示数字的 十进制值 。 示例 1: 输入:head = [1,0,1] 输出:5 解释:二进制数 (101) 转化为十进制数 (5) 示例 2: 输入:head = [0] 输出:0 ''' def getDecimalValue(head): s = int(''.join(str(x) for x in head), 2) print(s) getDecimalValue([1, 0, 1]) getDecimalValue([0, 0])
false
cacbf029b45a960fa30b175e3f0bafe66ebfaab6
gschen/where2go-python-test
/1200-常用算法/其他/111_二叉树的最小深度.py
1,288
4.15625
4
# https://leetcode-cn.com/problems/minimum-depth-of-binary-tree/ from typing import * import unittest # Definition for a binary tree node. class TreeNode: def __init__(self, x): self.val = x self.left = None self.right = None class Solution: def levelOrderBottom(self, root: TreeNode)...
true
4e441ab239c7d9bec2ed15b889002935808f9adc
pcebollada/Python
/Ejercicios de clase/Buenos días, tardes, noches.py
493
4.15625
4
# -*- coding: cp1252 -*- #hacer un programa que segun la hora que sea, nos diga buenos dias, buenas tardes o buenas noches# #De seis a catorce, son buenos das;de catorce a veinte son buenas tardes; y de 20 a 6 son buenas noches# def saludador(): h=input("Dime que hora es?:") if (h>=6 and h<14): pr...
false
5253599aa98ef4900197ef5616ceb94936048fe2
K23Nikhil/PythonBasicToAdvance
/Program13.py
507
4.125
4
#Write a program that asks the user how many Fibonnaci numbers to generate and then generates them. # Take this opportunity to think about how you can use functions. startIndex = 0 endIndex = 10 FabSer = [] i = 1 if startIndex ==1: FabSer.append(startIndex) FabSer.append(startIndex) else: FabS...
true
8929a0b3e7d0dcbf04f6bc907de9f9aece86c9d1
spoorthyandhe/project-98
/game.py
885
4.34375
4
import random print(" Number guessing game :") number = random.randint(1,9) chances = 0 print ("Guess a number (between 1 and 9): ") # while loop to count the umbers of changes while chances <5: guess = int(input("Enter your guess: ")) #compare the user enteres number with the number if gue...
true
ef05347532b0eab4ddede67797e8a39725fefc07
Mfrakso/Week3
/FiberOptic If_Statements.py
1,895
4.4375
4
''' File: FiberOptic If_Statments.py Name: Mohammed A. Frakso Date: 14/12/2019 Course: DSC_510 - Introduction to Programming Desc: Programe calculates the need of fiber optic cable and evaluate a bulk discount for a user Usage : This program is built to take the 'Company Name' and 'required length(in feet)' of optic c...
true
ea17d0d98e64c444106d0c018c8ac171a84c3b32
pangyang1/Python-OOP
/Python OOP/bike.py
794
4.15625
4
class Bike(): """docstring for Bike.""" def __init__(self,price,max_speed,miles): self.price = price self.max_speed =max_speed self.miles = 0 def displayinfo(self): print "The price is $" + str(self.price) + ". The max speed is " + str(self.max_speed) + ". The total miles are...
true
b38b3a2082f4da3dc269982aab04ac935a5e96bd
IeuanOwen/Exercism
/Python/triangle/triangle.py
1,087
4.25
4
import itertools def valid_sides(sides): """This function validates the input list""" if any(side == 0 for side in sides): return False for x, y, z in itertools.combinations(sides, 3): if (x + y) < z or (y + z) < x or (z + x) < y: return False else: return True def...
true
9f865f967c9a164b95c49e5f84b17d5d0204c5f8
IeuanOwen/Exercism
/Python/prime-factors/prime_factors.py
428
4.1875
4
"""Return a list of all the prime factors of a number.""" def factors(startnum): prime_factors = [] factor = 2 # Begin with a Divisor of 2 while startnum > 1: if startnum % factor == 0: prime_factors.append(factor) startnum /= factor # divide the startnum by the factor ...
true
375e0bf125558618bb74238ec40264ce59ca9344
Jeevan-Palo/oops-python
/Polymorphism.py
1,050
4.5
4
# Polymorphism achieved through Overloading and Overriding # Overriding - Two methods with the same name but doing different tasks, one method overrides the other # It is achieved via Inheritance class Testing: def manual(self): print('Automation Tester with 5 years Experience') class ManualTest(Testing)...
true
cc50929915eae260da1160b515b30cbea4268108
MicheSi/Data-Structures
/binary_search_tree/sll_queue.py
2,213
4.1875
4
class Node: def __init__(self, value=None, next_node=None): # the value at this linked list node self.value = value # reference to the next node in the list self.next_node = next_node def get_value(self): return self.value def get_next(self): return self.next_node def set_next(self, n...
true
572e08a21a64a898d60e2bd26bec4f350da44d65
his1devil/lintcode-note
/flattenlist.py
449
4.1875
4
#! /usr/bin/env python # -*- coding: utf-8 -*- class Solution(object): """ Given a list, each element in the list can be a list or integer. Flatten it into a simply list with integers. 递归 """ def flatten(self, nestedList): result = [] if isinstance(nestedList, int): ...
true
cd54caff7a61f615fd855cc9a012871652fb4c2a
his1devil/lintcode-note
/rotatestring.py
1,055
4.25
4
#! /usr/bin/env python # -*- coding: utf-8 -*- class Solution(object): """ Given a string and an offset, rotate string by offset. (rotate from left to right) offset=2 => "fgabcde" """ def rotateString(self, s, offset): # 防止offset越界,offset 对len(s)取模 if s is None or len(s) == 0: ...
true
6c78661c73b2892e248eff64a7395e6b1e84359b
paulmagnus/CSPy
/mjenkins-programs/windchill.py
447
4.3125
4
def windChill(): print 'Welcome to the windchill calculator!' temperature = input("Enter the temperature: ") windspeed = input("Enter the wind speed: ") windchill = 35.74 + (0.6215 * temperature) - (35.75 * (windspeed ** 0.16)) + (0.4275 * temperature * (windspeed ** 0.16)) print 'At ' + str(temperature) + ' degre...
true
fd8809831149570c0750c8d612f2bd99c0d31479
katyduncan/pythonintro
/lesson2/8IntegersFloats.py
409
4.1875
4
# Check data type print(type(3)) print(type(4.3)) # whole number float print(type(4.)) # operation involving int and float always results in float print(3 + 2.5) # cut decimal off float to convert to int print(int(49.7)) # 49 no rounding occurs # add .0 to convert int to float print( float(3520 + 3239)) # 6759.0 #...
true
a57f59a87013bed7f79d9524af8858e8c48c024d
Bumskee/-Part-2-Week-2-assignment-21-09-2020
/Problem 2.py
483
4.15625
4
"""Problem 2 finding the average score tests of 3 students""" #Assigning the value for the student scores student1 = 80 student2 = 90 student3 = 66.5 #Function for finding the average out of those student scores def findAverage(student1, student2, student3): scoreAverage = (student1 + student2 + student3) / 3 ...
true
bdda614bb2a711d293961a0ce85ee4df83f0c6c6
kosiA1/Pythonlevel1
/Practice 2.py
1,988
4.15625
4
#------------------------------------------------------------------------------- # Name: module 2 # Purpose: Learning Variables # Author: Kosisochi # Created: 06-12-2020 # Copyright: (c) anado 2020 # Licence: <your licence> #---------------------------------------------------------------------...
false
63d1c825ba44f094558ed37759d9f9d018a7a484
samanthaalcantara/codingbat2
/Logic-1/caught_speeding.py
758
4.28125
4
""" Date: 06 12 2020 Author: Samantha Alcantara Question: You are driving a little too fast, and a police officer stops you. Write code to compute the result, encoded as an int value: 0=no ticket, 1=small ticket, 2=big ticket. If speed is 60 or less, the result is 0. If speed is between 61 and 80 inclusive, the res...
true
19a6de32c4a6c72a5dbd89ad23600d9de5893ce6
peterhchen/runBookAuto
/code/example/01_Intro/05_Age.py
539
4.4375
4
#!/usr/bin/python3 # Display different format based on age. # Age 1 to 18: Important # Age 21, 50, or >= 65: Important # All othera Ages: Not important # Get age and store in age age = eval (input('Enter age: ')) # if age >= 1 and <= 18: important if (age >= 1) and (age <= 18): print ("Important") # if age == ...
true
3b3012a175b7e66ea1d9d57b493b6df098ae68f3
peterhchen/runBookAuto
/code/example/01_Intro/03_UnitConv.py
449
4.28125
4
#!/usr/bin/python3 # Problem: Receive miles and convert to kilometers # kilometers = miles * 1.6 # Enter Miles 10. # 10 Miles euqls to 16 kilometer. # ask the user to input miles and assign it to the mile variable. mile = input ('Enter Mile: ') # Convert the string to integer. mile = int (mile) # Perform multiplica...
true
36b71ce66e635ac8c938e50bd3f18cc2731ec79e
peterhchen/runBookAuto
/code/example/07_Dict/01_Dict.py
460
4.4375
4
#!/usr/bin/python3 myDict = {"fName": "Peter", "lName": "Chen", "address": "652 Calle Victoria"} print("My Name:", myDict["fName"]) myDict["address"] = "1225 Vienna Drive" myDict ["city"] = "Suunyvale" print ("Is there a city:", "city" in myDict) print(myDict.values()) for i in myDict: print (i) myDict.clear()...
false
c208d5ee251a4de8b5d953ad057143ab9ef49bb2
peterhchen/runBookAuto
/code/example/01_Intro/04_Calculator.py
655
4.40625
4
#!/usr/bin/python3 # Enter Calculator: 3 * 6 # 3 * 6 = 18 # Store the user input of 2 number and operator. num1, oper , num2 = input ('Enter Calculator: ').split() # Conver the strings into integers num1 = int (num1) num2 = int (num2) # if + then need to provide the output based on addition # Print the result. if o...
true
91679fa0afb893e30dd4c04fd8acfd1b85659c36
peterhchen/runBookAuto
/code/example/05_Func/06_MultiValue.py
208
4.15625
4
#!/usr/bin/python3 # How to return the multiple values. def mult_divide (num1, num2): return (num1 * num2), (num1 / num2) mult, divide = mult_divide (5, 4) print ("5 * 4 =", mult) print ("5 / 4 =", divide)
false
4a425f72e61d4dd08b5c413a2ecec116ec5c767e
jamariod/Day-5-Exercises
/WordSummary.py
397
4.1875
4
# Write a word_histogram program that asks the user for a sentence as its input, and prints a dictionary containing the tally of how many times each word in the alphabet was used in the text. any_word = input( "Enter any word to tally how many times each letter in the alphabet was used in the word: ") word_split =...
true
641aae71ec1efa9634631c16e6b8faa5f4742706
boringPpl/Crash-Course-on-Python
/Exercises on IDE/7 String/ex7_2_string.py
614
4.375
4
'''Question 7.2: Using the format method, fill in the gaps in the convert_distance function so that it returns the phrase "X miles equals Y km", with Y having only 1 decimal place. For example, convert_distance(12) should return "12 miles equals 19.2 km". ''' def convert_distance(km): miles = km * 0.621 # 1km is ...
true
59155ff91c8651d8db1bd9273b46e12b9de074c1
boringPpl/Crash-Course-on-Python
/Exercises on IDE/6 For Loops/ex6_2_for.py
441
4.65625
5
'''Question 6.2: This function prints out a multiplication table (where each number is the result of multiplying the first number of its row by the number at the top of its column). Fill in the blanks so that calling mul_table(1, 3) will print out: 1 2 3 2 4 6 3 6 9 ''' def mul_table(start, stop): for x in ___: ...
true
2f0d5f695e42fb4e7027352362c147ba68a491be
boringPpl/Crash-Course-on-Python
/Exercises on IDE/3 Function/ex3_2_function.py
994
4.65625
5
''' Question 3.2: This function converts kilometers (km) to miles. 1. Complete the function. Your function receive the input kilometers, and return the value miles 2. Call the function to convert the trip distance from kilometers to miles 3. Fill in the blank to print the result of the conversion 4. Calculate the round...
true
3664bf0af663c33035ab8e699dd1f2d5f8af76cc
boringPpl/Crash-Course-on-Python
/Exercises on IDE/6 For Loops/ex6_3_for.py
636
4.6875
5
'''Question 6.3: The display_even function returns a space-separated string of all positive numbers that are divisible by 2, up to and including the maximum number that's passed into the function. For example, display_even(4) returns “2 4”. Fill in the blank to make this work. ''' def display_even(max_num): retur...
true
2cf55be5afac37d8737a9e4254ffccb2394ce111
nigelginau/practicals_cp1404
/prac_03/password_entry.py
872
4.3125
4
"""" Nigel Ginau """ """"write a program that asks the user for a password, with error-checking to repeat if the password doesn't meet a minimum length set by a variable. The program should then print asterisks as long as the password. Example: if the user enters "Pythonista" (10 characters), the program should print...
true
6570314af2afc2a8491dfeabec25383deda462e2
tikale/SOLID_Python
/SOLID_SingleResponsibility.py
2,145
4.25
4
# 1. Single Responsibility Principle - jedna odpowiedzialność # Każda funkcja, klasa lub modół powinien mieć tylko jeden powód do zmiany. # Taki kod łatwiej zrozumieć, naprawić i utrzymać. Łatwiej się go testuje. # klasa prostokąt ma 3 odpowiedzialności class Rectangle: def __init__(self, width=0, heigh...
false
e00334f1474a2caa644d4f60498ffc3497570701
Arslan0510/learn-basic-python
/3strings.py
574
4.40625
4
language = 'Python' # print(len(language)) # Access each individual letter # letter = language[3] # letter = language[0:3] # first to third letter # letter = language[1:] # skip first letter and show all the remaining part letter = language[-1] # get reverse of string # String Methods languageString...
true
1cbf04f88b879ad37b959c8b41a19ec8fe0b1b9a
dguzman96/Python-Practice
/Chapter 4/counter.py
336
4.21875
4
#Counter #Demonstrates the range() function print("Counting:") for i in range(10): print(i, end = " ") print("\n\nCounting by fives:") for i in range (0, 50, 5): print(i, end = " ") print("\n\nCounting backwards:") for i in range (10, 0, -1): print(i,end = " ") input("\n\nPress the enter ...
false
7866ce25883a04152b4587c683ff0be544a85ce5
bigbillfighter/Python-Tutorial
/Part1/chap9_p2.py
845
4.21875
4
#the python library practise from collections import OrderedDict favourite_languages = OrderedDict() favourite_languages['Lily'] = 'C' favourite_languages['Max'] = 'Ruby' favourite_languages['Lucas'] = 'Java' favourite_languages['Peter'] = 'C' for name, language in favourite_languages.items(): print(n...
true
c7a140cabdf8de7fb2dc7b46420ec7951b8e8052
felipeandrademorais/Python
/Basico/BasicoPython.py
981
4.25
4
""" ########### Imprimir valores ############# num_int = 5 num_dec = 7.3 val_str = "Qualquer valor" print("Concatenando Inteiro:", num_int) print("Concatenando Inteiro: %i" %num_int) print("Concatenando Inteiro" + str(num_int)) print("Concatenando Decimal: ", num_dec) print("Concatenando Decimal: %.10f" %num_dec) pr...
false
a1de6e3402e992ba1cb9503dd3308d1c6fa31c38
yourback/OfflineDataConversionAndDrawingSoftware
/clac_module/rangecalc.py
1,171
4.125
4
# 区间数据计算 # 获取最小值 def max_calc(list_data): i = list_data[0] for d in list_data: if i < d: i = d return i def min_calc(list_data): i = list_data[0] for d in list_data: if i > d: i = d return i def average_calc(list_data): i = 0 for d in list_dat...
false
f04a47dd64a1cae114c053e53a1ce85533fec5e9
mrggaebsong/Python_DataStructure
/PythonSort.py
2,576
4.125
4
def bubble_sort(list): for last in range(len(list)-1,-1,-1): swap = False for i in last: if l[i] > l[i+1]: l[i], l[i+1] = l[i+1], l[i] swap = True if not swap: break return list l = [5,6,2,3,0,1,4] print("Bubble Sort") print(l) bub...
false
ec9d6f83ed95af87724cc60be71c9c14d3b1ae3a
Yash25gupta/Python
/Tutorial_Codes/12 Chapter - Lambda Expressions.py
765
4.21875
4
# Tutorial 150 - Lambda Expression # anonymous function def add(a,b): return a+b add2 = lambda a,b : a+b print(add2(2,3)) multiply = lambda a,b : a*b print(multiply(2,3)) print(add) print(add2) print(multiply) # Tutorial 151 - Lambda Expression Practice def is_even(a): return a % 2 ==0 p...
false
a2aaf99fcc1b5ce257d8506092ed273c1fd432a3
amitsindoliya/datastructureandalgo
/selection_sort.py
577
4.3125
4
## selection Sort ## ## In selection sort we find the minimum element or maximum element # of the list and place it at the start # continue this operation until we have an sorted array # complexity O(N^2)/2 # unstable def selection_sort(iterable): for i in range(len(iterable)-1): for j in range(i+1,len(...
true
f65d0d677044624e03d82e2f43cb8c48a94f7226
razmikmelikbekyan/ACA_2019_python_lectures
/homeworks/CapstoneProject/database/books.py
1,422
4.28125
4
from typing import Dict, List BOOKS = "database/books.txt" def create_books_data(): """ Creates an empty txt file for storing books data. If the file already exists, it should not do anything. """ pass def get_all_books() -> List[Dict]: """Returns all books data in a list, where each item i...
true
cc9f9dc9810af12141c6f005a9b951c25bffd1e0
lowks/py-etlt
/etlt/cleaner/DateCleaner.py
1,871
4.3125
4
import re class DateCleaner: """ Utility class for converting dates in miscellaneous formats to ISO-8601 (YYYY-MM-DD) format. """ # ------------------------------------------------------------------------------------------------------------------ @staticmethod def clean(date): """ ...
true
5f59166ef3478ece7bb0bed7ea6e3fc02ef1ca44
sb17027/ORS-PA-18-Homework07
/task4.py
1,336
4.34375
4
""" =================== TASK 4 ==================== * Name: Number of Appearances * * Write a function that will return which element * of integer list has the greatest number of * appearances in that list. * In case that multiple elements have the same * number of appearances return any. * * Note: You are not allow...
true
115490da841034c40a2c2c3029adede809f4c499
mali0728/cs107_Max_Li
/pair_programming/PP9/fibo.py
1,017
4.25
4
""" PP9 Collaborators: Max Li, Tale Lokvenec """ class Fibonacci: # An iterable b/c it has __iter__ def __init__(self, val): self.val = val def __iter__(self): return FibonacciIterator(self.val) # Returns an instance of the iterator class FibonacciIterator: # has __next__ and __iter__ ...
true
379181112c350d080fae6376a2cae3029ec35a9d
goulartw/noob_code
/curso-noob-python/variaveis-tipos-dados/hello.py
1,409
4.3125
4
# hello world # print("hello world") # string # nome = input("Qual é o seu nome: ") # print(nome) # inteiros # numero1 = int(input("Digite um número: ")) # numero2 = int(input("Digite um número: ")) # numero3 = int(input("Digite um número: ")) # calc = numero1 + numero2 * numero3 # print(calc) # float # numero1 = ...
false
6a98a213ff9063964adc7731056f08df3ac755ae
gatisnolv/planet-wars
/train-ml-bot.py
2,062
4.25
4
""" Train a machine learning model for the classifier bot. We create a player, and watch it play games against itself. Every observed state is converted to a feature vector and labeled with the eventual outcome (-1.0: player 2 won, 1.0: player 1 won) This is part of the second worksheet. """ from api import State, uti...
true
09bfd4953bc24b2ab0eafac8b7bdb73074b1a4bf
bats64mgutsi/MyPython
/Programs/power.py
205
4.40625
4
# Calculates a^b using a for loop # Batandwa Mgutsi # 25/02/2020 a = eval(input("Enter a: ")) b = eval(input("Enter b: ")) ans = 1 for _ in range(1, b+1): ans *= a print(a, "to the power of ", b, "is", ans)
false
41895c829a967c20cb731734748fe7f407b364a3
bats64mgutsi/MyPython
/Programs/graph.py
2,244
4.28125
4
# A program that draws the curve of the function given by the user. # Batandwa Mgutsi # 02/05/2020 import math def getPointIndex(x, y, pointsPerWidth, pointsPerHeight): """Returns the index of the given point in a poinsPerWidth*pointsPerHeight grid. pointsPerWidth and pointsPerHeight should be odd numbers...
true
768ffb93219b9d95d73ec3075fbb191ed00837a6
Tobi-David/first-repository
/miniproject.py
625
4.15625
4
## welcome message print("\t\t\tWelcome to mini proj! \nThis application helps you to find the number and percentage of a letter in a message.") ## User message input user_message = input("This is my message ") ## user letter input user_letter = input("this is my letter ") ## count letter in message letter_fr...
true
637267a96a001520af71a7c748f1a05109726f5e
Colosimorichard/Choose-your-own-adventure
/Textgame.py
2,513
4.15625
4
print("Welcome to my first game!") name = input("What's your name? ") print("Hello, ", name) age = int(input("What is your age? ")) health = 10 if age >= 18: print("You are old enough to play.") wants_to_play = input("Do you want to play? (yes/no) ").lower() if wants_to_play == "yes": ...
true
d3f40012da083979a5c97407e2e2b6a43346ece0
december-2018-python/adam_boyle
/01-python/02-python/01-required/07-functions_intermediate_2.py
2,453
4.15625
4
# 1. Given x = [[5,2,3], [10,8,9]] students = [ {'first_name' : 'Michael', 'last_name' : 'Jordan'}, {'first_name' : 'John', 'last_name' : 'Rosales'} ] sports_directory = { 'basketball' : ['Kobe', 'Jordan', 'James', 'Curry'], 'soccer' : ['Messi', 'Ronaldo', 'Rooney'] } z = [ {'x': 10, 'y': 20} ] x[1][0...
true
34533f19a443b7063a4637c798b97233006acc02
Seon2020/data-structures-and-algorithms
/python/code_challenges/ll_zip/ll_zip.py
698
4.375
4
def zipLists(list1, list2): """ This function takes in two linked lists and merges them together. Input: Two linked lists Output: Merged linked list the alternates between values of the original two linked lists. """ list1_current = list1.head list2_current = list2.head while list1_current and list2...
true
04f7f3d62fe77d102c4bf88ef08621bb6b0b1740
Seon2020/data-structures-and-algorithms
/python/code_challenges/reverse_linked_list.py
351
4.28125
4
def reverse_list(ll): """Reverses a linked list Args: ll: linked list Returns: linked list in reversed form """ prev = None current = ll.head while current is not None: next = current.next current.next = prev prev = current current = next l...
true
d70c86867376ccb77491b6d1e20c3f1a0b98bfe2
concon121/project-euler
/problem4/answer.py
688
4.3125
4
# A palindromic number reads the same both ways. The largest palindrome made # from the product of two 2-digit numbers is 9009 = 91 × 99. # Find the largest palindrome made from the product of two 3-digit numbers. ZERO = 0 MIN = 100 MAX = 999 def isPalindrome(number): reverse = str(number)[::-1] if (str(numbe...
true
7af9a74b13af5cc1c52a70970744b0a837bc52ca
cepGH1/dfesw3cep
/convTemps.py
413
4.21875
4
#°F = (°C × 9/5) + 32. #C =(F -32)*(5/9) myInput = input("please enter the temperature using either 'F' or 'C' at the end to show the scale: ") theNumber = int(myInput[:-1]) theScale = myInput[-1] print(theNumber) print(theScale) if theScale == "C": fahrenheit = (theNumber*(9/5)) + 32 print(fahrenheit, "F") if ...
true
cdb5dff43e44f80ce8cc79bdc4424b24e06f1094
balvantghanekar11/python-lern
/cal1.py
686
4.21875
4
def operation(op,n1,n2): if op == "+": return n1+n2 elif op == "-": return n1-n2 elif op == "*": return n1-n2 elif op == "/": return n1-n2 elif op == "%": return n1-n2 elif op == "**": return n1**n2 else: print("Wrong Choice") ...
false
f505a0fff46edd244a7c3472acf385440b76ae01
salcosser/learningPython
/FizzBuzz.py
542
4.21875
4
# Write a program that prints the numbers from 1 to 100. # But for multiples of three print “Fizz” instead of the number # and for the multiples of five print “Buzz”. For numbers which # are multiples of both three and five print “FizzBuzz”. def fb(): for i in range(100): if i % 3...
false
1cb7a726b1074a78252ba83a4b358821fd6f6385
LeoBaz20/Netflix-Style-Recommender
/netflix-style-recommender-master/PythonNumpyWarmUp.py
1,770
4.28125
4
# coding: utf-8 # In[25]: # Handy for matrix manipulations, likE dot product and tranpose from numpy import * # In[26]: # Declare and initialize a 2d numpy array (just call it a matrix, for simplicity) # This how we will be organizing our data. very simple, and easy to manipulate. data = array([[1, 2, 3], [1, 2...
true
a0c0f8f6df218174460ece178e34a090775f0ccc
Annu86/learn_Python
/anu_ex8.py
824
4.125
4
# Membership and Bitwise Operators #Membership in and not in a = 14 b=10 list = [11, 12, 14, 15, 16, 17] print('a is present in the list:', a in list) print('b is present in the list:', b in list) if(a in list): print('a is present in the list') if(b not in list): print('b is not in the list') #Bitwise ...
false
52b9c167b058db6092d8f6b5dc760a306cc9b608
jdellithorpe/scripts
/percentify.py
1,497
4.15625
4
#!/usr/bin/env python from __future__ import division, print_function from sys import argv,exit import re def read_csv_into_list(filename, fs): """ Read a csv file of floats, concatenate them all into a flat list and return them. """ numbers = [] for line in open(filename, 'r'): parts ...
true
a4bd50b4ac26814d745411ca815aa8115c058d0c
bettymakes/python_the_hard_way
/exercise_03/ex3.py
2,343
4.5
4
# Prints the string below to terminal print "I will now count my chickens:" # Prints the string "Hens" followed by the number 30 # 30 = (30/6) + 25 print "Hens", 25 + 30 / 6 # Prints the string "Roosters" followed by the number 97 # 97 = ((25*3) % 4) - 100 # NOTE % is the modulus operator. This returns the remainder ...
true
fb4089bcce2764ddd695f378f9911c1374ee911b
jxq0816/psy_learn_python
/diamond.py
241
4.25
4
#请输入一个奇数,打印出一个行数为奇数行的菱形 n=int(input("number=?")) for i in range(1,n+1,2): string_1="*"*i print(string_1.center(n)) for i in range(n-2,0,-2): string_1="*"*i print(string_1.center(n))
false
77ff1d18e2d88269716f2eda2e09270d78d39840
eckoblack/cti110
/M5HW1_TestGrades_EkowYawson.py
1,650
4.25
4
# A program that displays five test scores # 28 June 2017 # CTI-110 M5HW1 - Test Average and Grade # Ekow Yawson # #greeting print('This program will get five test scores, display the letter grade for each,\ \nand the average of all five scores. \n') #get five test scores score1 = float(input('Enter test s...
true
40867a0b45d2f9f37f5d4bcfe0027bd954c82c36
eckoblack/cti110
/M6T1_FileDisplay_EkowYawson.py
451
4.1875
4
# A program that displays a series of integers in a text file # 5 July 2017 # CTI-110 M6T1 - File Display # Ekow Yawson # #open file numbers.txt def main(): print('This program will open a file named "numbers.txt" and display its contents.') print() readFile = open('numbers.txt', 'r') file...
true
4fdb7741fa84ad336c029825adf0994f174aaa2b
ocean20/Python_Exercises
/functions/globalLocal.py
602
4.28125
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Sun Jun 23 16:41:56 2019 @author: cawang """ x = 2 def fun1(): x = 1 print("Inside function x =", x) fun1() # Inside function x = 1 print("Outside function x =", x) # Outside function x = 2 def fun2(): print("Inside function x =", x) fun2() ...
true
28bf46ca0222b8365920e445c6e85d78dd2ae452
Caiovg/Algoritimos-de-Ordenacao-e-Busca
/heap_sort.py
1,049
4.125
4
def heap_sort(data): length = len(data) index = length // 2 parent = 0 child = 0 temp = 0 while True: if index > 0: index -= 1 temp = data[index] else: length -= 1 if length == 0: return temp = data[lengt...
false
30f36be3d0fbe3105c4a29a5e770ceab051505c9
henriquelorenzini/EstruturasDeDecisao
/Exercicio24.py
1,184
4.3125
4
# Faça um Programa que leia 2 números e em seguida pergunte ao usuário qual operação ele deseja realizar. O resultado da operação deve ser acompanhado de uma frase que diga se o número é: # par ou ímpar; # positivo ou negativo; # inteiro ou decimal. numero1 = float(input("Digite o número 1: ")) numero2 = float(input("...
false
a8f0b493d291147afa08f2e699112412f5ccbeb9
henriquelorenzini/EstruturasDeDecisao
/Exercicio15.py
1,180
4.3125
4
# Faça um Programa que peça os 3 lados de um triângulo. O programa deverá informar se os valores podem ser um triângulo. Indique, caso os lados formem um triângulo, se o mesmo é: equilátero, isósceles ou escaleno. # Dicas: # Três lados formam um triângulo quando a soma de quaisquer dois lados for maior que o terceiro; ...
false
921035af4cf9beef9eea8661aab63cbd26477227
henriquelorenzini/EstruturasDeDecisao
/Exercicio06.py
586
4.125
4
#Faça um Programa que leia três números e mostre o maior deles. print('Veja qual dos três números é maior') num1 = float(input('Digite o primeiro valor: ')) num2 = float(input('Digite o segundo valor: ')) num3 = float(input('Digite o terceiro valor: ')) if num1 > num2 and num1 > num3: print('O número {:.2f} é ma...
false
128039caec432553bb36875e92b86d6578175728
AndreasGustafsson88/assignment_1
/assignments/utils/assignment_1.py
1,179
4.46875
4
from functools import lru_cache """ Functions for running the assignments """ def sum_list(numbers: list) -> int: """Sums a list of ints with pythons built in sum() function""" return sum(numbers) def convert_int(n: int) -> str: """Converts an int to a string""" return str(n) def recursive_sum(...
true
d48a7f13d05b9e5c3f955873c5185258b8d05a04
KarlVaello/python-programming-challenges
/SpaceArrange_PPC2.py
1,974
4.15625
4
from random import randint import math from Point import Point # def that sort an array of points (bubble algorithm) def bubbleSort(alist): n = len(alist) for i in range(len(alist)-1): swp = False for j in range(len(alist)-1): if (alist[j][2] > alist[j+1][2]): tempPo...
false
fd50491b2f67bc3b76ff3b1b5391952b0bed92eb
JonSeijo/project-euler
/problems 1-9/problem_1.py
825
4.34375
4
#Problem 1 """ 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. """ MAXNUM = 1000 def findMultiples(number): """Return a list with the multiples of the number, betw...
true
ec2a73d8147e75ab14f1453c16295bb50e52a58e
JonSeijo/project-euler
/problems 50-59/problem_57.py
1,689
4.125
4
# -*- coding: utf-8 -*- # Square root convergents # Problem 57 """ It is possible to show that the square root of two can be expressed as an infinite continued fraction. √ 2 = 1 + 1/(2 + 1/(2 + 1/(2 + ... ))) = 1.414213... By expanding this for the first four iterations, we get: 1 + 1/2 = 3/2 = 1.5 1 + 1/(2 + 1/2)...
true
a09e6de32320dca2795f35f7218ec5bd4d4f85bb
brennobrenno/udemy-python-masterclass
/Section 11/spam.py
1,525
4.15625
4
def spam1(): def spam2(): def spam3(): z = " even" z += y print("In spam3, locals are {}".format(locals())) return z y = " more " + x # y must exist before spam3() is called y += spam3() # do not combine these assignments ...
true
1f6689ff4d8990151ca329843ec12486157182b3
brennobrenno/udemy-python-masterclass
/Section 7 & 8/43.py
863
4.21875
4
# list_1 = [] # list_2 = list() # # print("List 1: {}".format(list_1)) # print("List 2: {}".format(list_2)) # # if list_1 == list_2: # print("The lists are equal") # # print(list("The lists are equal")) # even = [2, 4, 6, 8] # another_even = even # # another_even = list(even) # New list # another_even2 = sorted(...
true
7a4c6e46d471dee68f06f28956a964fd56559912
wesbasinger/LPTHW
/ex22/interactive.py
1,213
4.15625
4
print "Let's just take a little quiz." print "On this section, you were supposed to just review." points = 0 def print_score(): print "So far you have %d points." % points print_score() print ''' Here's your first question. Which of the following objects have we talked about so far? a Strings b Integers b Functio...
true
edaff19fc7b3ea2a8ab87e1ab10ad6c029009841
wesbasinger/LPTHW
/ex06/practice.py
739
4.34375
4
# I'll focus mostly on string concatenation. # Honestly, I've never used the varied types of # string formatting, although I'm sure they're useful. # Make the console print the first line of Row, Row, Row Your Boat # Do not make any new strings, only use concatenation first_part = second_part = # should print 'Ro...
true
cf4a99e1a7c7562f04bb9d68cc91673f7d108309
wesbasinger/LPTHW
/ex21/interactive.py
1,924
4.28125
4
from sys import exit def multiply_by_two(number): return number * 2 def subtract_by_10(number): return number - 10 def compare_a_greater_than_b(first_num, second_num): return first_num > second_num print "So far, you've done only printing with function." print "Actually, most of the time you will want your" pri...
true
50f7a379886e1b687eafe0ae37ff11c2461ec95b
wesbasinger/LPTHW
/ex40/interactive.py
2,919
4.40625
4
from sys import exit print "This is point where things take a turn." print "You can write some really great scripts and" print "do awesome stuff, you've learned just about" print "every major data type and most common pieces" print "of syntax." print "But, if you want to be a real programmer," print "and write applica...
true
64bd98e9099267c2b5239a12c68a1c0108f4d92a
AmenehForouz/leetcode-1
/python/problem-0832.py
1,144
4.34375
4
""" Problem 832 - Flipping an Image Given a binary matrix A, we want to flip the image horizontally, then invert it, and return the resulting image. To flip an image horizontally means that each row of the image is reversed. For example, flipping [1, 1, 0] horizontally results in [0, 1, 1]. To invert an image mea...
true
9f489fa5b55db295368c9ea6ff621fe59f2e37e9
AmenehForouz/leetcode-1
/python/problem-0088.py
625
4.15625
4
""" Problem 88 - Merge Sorted Array Given two sorted integer arrays nums1 and nums2, merge nums2 into nums1 as one sorted array. """ from typing import List class Solution: def merge( self, nums1: List[int], m: int, nums2: List[int], n: int ) -> None: """ Do not return anything, mod...
true
2315e0c5f7b08cb87aab56f835a7122e096e5a80
priyankabhalode/Test
/Hungry.py
316
4.15625
4
hungry = input("Are u hungry?") if hungry == "yes": print("eat samosa") print("eat pizza") print("eat burger") print("eat fries") else: #print("Do your home work") thirsty = input("Are u thirsty?") if thirsty == "yes": print("drink water") print("drink soda or coldrink")
false
1d79a965da3406b42c492b8a9aa2bfd6ae4c1bba
nathanielam0ah/homework
/exercise009.py
230
4.21875
4
#!/usr/bin/env python def maxList(Li): currentMax = Li[0] for index in Li: if index > currentMax: currentMax = index return currentMax myList = ['3', '4', '6', '3', '-100'] print(maxList(myList))
true
030622a70d0b52144a0b3e604fd7105e97511e0a
dishit2141/Internship-Work
/day3(basic programme)/smallestno.py
246
4.15625
4
no1=int(input("Enter Number 1:")) no2=int(input("Enter Number 2:")) no3=int(input("Enter Number 3:")) if(no1<no2 and no1<no3): print(no1,"is Smallest") elif(no2<no1 and no2<no3): print(no2,"is Smallest") else: print(no3,"is Smallest")
false
da6106e6aa5268cc241d03472d3ff572f0a63e58
ucsd-cse-spis-2020/spis20-lab03-Sidharth-Theodore
/lab3Letters_pair.py
596
4.5625
5
#Sidharth and Theodore #1.the "anonymous turtle" is the default turtle used if none are created in Code, or the first created if multiple are created #2."turtle" refers to the turtle library while "Turtle()" refers to the turtle class #3.myTurtle.sety(100) import turtle def drawT(theTurtle, size): '''Takes a turtl...
true
0c399de5188adb0418cef31a5896a2376afdf4bb
linzifan/python_courses
/misc-Stack.py
1,487
4.40625
4
""" Stack class """ class Stack: """ A simple implementation of a FILO stack. """ def __init__(self): """ Initialize the stack. """ self._items = [] def __len__(self): """ Return number of items in the stack. """ return len(self._it...
true
f74f78bb3fc27e9abd3158ff8cdbe7a93a7dc8b6
Shruti0899/Stack_to_list
/stcklst.py
1,837
4.25
4
print("list to stack\n") class StackL: def __init__(self): self.menu() def add(self,my_list,l): val=input("value:") if len(my_list)==l: print("\nStack is full.\nCannot add further.\nYou may choose to delete items to proceed.") else: my_list.appe...
false
2384c7c82af5eccdb070c7522a11895f2c3f4aa6
ldocao/utelly-s2ds15
/clustering/utils.py
674
4.25
4
###PURPOSE : some general purposes function import pdb def becomes_list(a): """Return the input as a list if it is not yet""" if isinstance(a,list): return a else: return [a] def add_to_list(list1, new_element): """Concatenate new_element to a list Parameters: ---------- ...
true
a3d90fc11ec40efd2f075b1f5e1ee1f03f66d465
qiao-zhi/pythonCraw
/HelloPython/function1.py
1,638
4.25
4
# python函数练习 # 1.python自带的一些常见函数的练习 print(abs(-95)) print(hash(-95)) print("sssssssssssssssss"+str(95)) # 2.自定义函数 def my_abs(a): if a >= 0: return a else: return -a # 3.定义不带参数与返回值的函数(无返回值的函数类似于return None,可以简写为return) def print_star(): print("***********") print_star() x=print_star() #...
false