blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
4a7ba22c431cb61001dad9d7d1656e8bcc257b03
Sagar-1807/Python-Projects
/Algorithms/Selection Sort.py
500
4.28125
4
# MULTIPLE SWAPPING CONSUME MUCH CPU POWER,OR MEMORY POWER # SORT FROM START TO END def bubblesort(list): for i in range(5): # UPPER INDEX :7, INITIAL i=0 min=i for j in range(i, 6): if list[j] < list[min]: min = j temp = list[i] list...
true
f9649f0473bc7900d653fd0e216a35d95b6412a3
gxgarciat/Playground-GUI-Tkinter
/4_entry.py
738
4.375
4
from tkinter import * # Everything on tkinter is based using widgets # The program will expand depending on the content root = Tk() # For this, an entry widget will be required e = Entry(root,width=50,borderwidth=5) e.pack() # This will get the event from clicking the Button. It needs to be inside of the function #...
true
dc557b764ba7e2bacf978872247772ac0a222a8d
HALF-MAN/pythonlearn
/learning/oop/InstanceAndClassaAttributes.py
1,307
4.71875
5
""" 直接在class中定义属性,这种属性是类属性,归Student类所有: class Student(object): name = 'Student' 当我们定义了一个类属性后,这个属性虽然归类所有,但类的所有实例都可以访问到。 >>> class Student(object): ... name = 'Student' ... >>> s = Student() # 创建实例s >>> print(s.name) # 打印name属性,因为实例并没有name属性,所以会继续查找class的name属性 Student >>> print(Student.name) # 打印类的name属性 Studen...
false
bd4b01a4f57c749e711c7bce1cbcd2fefaf9ba2a
HALF-MAN/pythonlearn
/learning/oop_advanced_features/binding.py
2,716
4.1875
4
""" 正常情况下,当我们定义了一个class,创建了一个class的实例后, 我们可以给该实例绑定任何属性和方法,这就是动态语言的灵活性。先定义class: class Student(object): pass 给实例绑定一个方法: >>> def set_age(self, age): # 定义一个函数作为实例方法 ... self.age = age ... >>> from types import MethodType >>> s.set_age = MethodType(set_age, s) # 给实例绑定一个方法 >>> s.set_age(25) # 调用实例方法 >>> s.age # 测试结...
false
73b8018ce662ca4b68220e091a3cfa9bc546c507
HALF-MAN/pythonlearn
/learning/functional_programming/higher_order_function/Filter.py
1,222
4.375
4
""" Python内建的filter()函数用于过滤序列。 和map()类似,filter()也接收一个函数和一个序列。和map()不同的是,filter()把传入的函数依次作用于每个元素,然后根据返回值是True还是False决定保留还是丢弃该元素。 例如,在一个list中,删掉偶数,只保留奇数,可以这么写: def is_odd(n): return n % 2 == 1 list(filter(is_odd, [1, 2, 4, 5, 6, 9, 10, 15])) # 结果: [1, 5, 9, 15] filter()这个高阶函数,关键在于正确实现...
false
4236a00fc82ac2bed48764a68e3bb8f4be2791b5
webfudge95/codenation
/DayTwo/challenge6.py
444
4.3125
4
def is_even(num): if (num % 2) == 0: return True else: return False def addition(num1, num2): num3 = num1 + num2 return num3 num1 = int(input("What's the first number: ")) num2 = int(input("What's the second number: ")) num3 = addition(num1, num2) print("The sum of {} and {} is {}".f...
true
b83bba009e6e982bc75af1503329a627babef0dd
webfudge95/codenation
/DayTwo/challenge2.py
278
4.46875
4
num = int(input("Please type a number: ")) if (num % 3) != 0: print("Your number is not dividasable by 3") else: print("Your number is divisable by 3") if (num % 5) != 0: print("Your number is not dividasable by 5") else: print("Your number is divisable by 5")
false
ae6b39bf461f69f0dd0e01b562925c852693e15a
JPB-CHTR/mycode
/challenge_labs/sleepytime.py
975
4.1875
4
#!/usr/bin/env python3 def toddler(): diaper = input("Is the diaper wet? (Y or N)") if diaper == "Y": print("Change Diaper") elif diaper == "N": print("Give milk") else: print("You should have answered Y or N") def teen(): wakestate = input("Is the kid sleep walking (Y or N...
true
64d16b3172d910897e8f36d186684e9d88f46cb7
bundu10/lpthw
/example4.py
1,987
4.25
4
cars = 100 space_in_a_car = 4.0 drivers = 30 passengers = 90 cars_not_driven = cars - drivers cars_driven = drivers carpool_capacity = cars_driven * space_in_a_car average_passengers_per_car = passengers / cars_driven print("USING THE NORMAL METHOD OF (CONCATENATE) STRINGS") # Blank line print() print("The...
true
0f75d6bf0c8928802e6e31076ba6d42bccc2ae14
HK002/JavaBasics
/Code/Data Structures/Linked Lists/MiddleElement.py
1,269
4.125
4
class Node: def __init__(self,data): self.value = data self.link = None class LinkedList: def __init__(self): self.start = None def insert(self,data): if self.start is None: self.start = Node(data) else: x = self.start ...
true
3468217eda250070effb82e9c49c2a4ceeee9724
Neil-C1119/CIS156-Projects
/3exercise12.py
1,102
4.25
4
#Print the table of quantities and discount percentages print("Here is the table of discounts: \n") print(" QUANTITY | DISCOUNT") print("------------------------") print(" 10-19 | 10%") print(" 20-49 | 20%") print(" 50-99 | 30%") print(" 100 or more | 40%") #Store the user's package amoun...
true
9bcbe5a5caa77120fe736a32f57e83b393a443e4
Neil-C1119/CIS156-Projects
/6exercise6n9.py
2,498
4.21875
4
#Start of try try: #This opens the file as the var numbers, then closes the file once finished running with open("numbers.txt", "r") as numbers: #Variable for each line of the file lines = numbers.readlines() #Variable for the amount of lines in the file line_amount = len(...
true
969dd51c64bf4eeab6f4f8c19360b1e7b4d3825b
Neil-C1119/CIS156-Projects
/4exercise12.py
597
4.40625
4
#Factorial #Ask the user to input a number to calculate number = int(input("Which number would you like to find the factorial of? ")) #Defining the factorial function def factorialFunc(number): #Set the final_number variable to start at 1 final_number = 1 #For every number between 1 and the u...
true
758db104ef47bfb2cd00843ef90063c2bbb86199
sharonbrak/DI-Sharon
/Week_4/day_3/Exercises_XP_Gold.py
1,746
4.28125
4
# Exercise 1 fruits = input('What is/are your favorite fruits? ') print(fruits) type(fruits) mylist = fruits.split(' ') newfruit = input('Type another fruit: ') if newfruit in mylist: print('you chose one of your favorite fruits! Enjoy!') else: print('You chose a new fruit. I hope you enjoy it too!'...
true
f41aa1be3a521b5004c0ed67f26137d03c57d2dd
alvas-education-foundation/K.Muthu-courses
/25 May 2020/qstn_complex.py
1,627
4.21875
4
""" Problem Statement: Take an input string parameter and determine if exactly 3 question marks exist between every pair of numbers that add up to 10. If so, return true, otherwise return false. Some examples test cases are below: "arrb6???4xxbl5???eee5" => true "acc?7??sss?3rr1??????5" => true ...
true
68b024412a8e0ff9e57797211031660e0118a94e
alvas-education-foundation/K.Muthu-courses
/19 May 2020/Function.py
266
4.21875
4
# Convert the temperature into Fahrenheit, given celsuis as inpit using function. #Function definition def temp(c): f=(c*9/5)+32 return f c=int(input("Enter the temperature in celsius : ")) #Function call f=temp(c) #Output print("Temperature in Fahrenheit : ",f)
true
9d49d0866bfb843c538298bb26585fd6f75851bb
venkateshwaracholan/Thinkpython
/chapter 8/eight_ten.py
212
4.21875
4
def is_palindrome_modified(word): """Returns true if the string is palindrome in a sinle check statement without involving loop""" return word==word[::-1] print is_palindrome_modified("madam")
true
763f8d9d7db3093bb454ff43ea3a0c58c13fca7a
venkateshwaracholan/Thinkpython
/chapter 12/twelve_two.py
731
4.21875
4
import random def sort_by_length(words): """ sorts with 2 argument tuple""" t = [] for word in words: t.append((len(word), word)) t.sort(reverse=True) print t res = [] for length, word in t: print length, word res.append(word) return res def sort_by_length_ran...
false
3b82dcc452a6fe1f964f02bb2661f56d7efc0a57
venkateshwaracholan/Thinkpython
/chapter 9/nine_one.py
212
4.15625
4
"""reads all the words from the text file and prints the words which has more than 20 characters""" fin = open('words.txt') for line in fin: word = line.strip() if(len(word) >= 20): print word
true
e2fa6f5594de3d52b39cae5fa29867778f5c520a
morganjacklee/com404
/1-basics/3-decision/8-nestception/bot.py
1,294
4.40625
4
print("Where shall I look?") print("Choices are:") print("""- Bedroom - Bathroom - Labratory - Somewhere else""") location = str(input()) # Using if, else and elif statements if location == "Bedroom" : print("Where in the bedroom?") print("""- Under the bed - Somewhere else""") location_bedroom = str(input()) ...
true
16214125be23fce25190cbb1857d02b14105e11d
warriorwithin12/python-django-course
/course/WarGameProject/hand.py
1,045
4.25
4
class Hand: ''' This is the Hand class. Each player has a Hand, and can add or remove cards from that hand. There should be an add and remove card method here. ''' def __init__(self, cards): self.cards = cards def add_card(self, card): """ Add card to hand if not exists ...
true
c5b341105b836ce803e61bd4c065eae6df2a9925
wmm98/homework1
/视频+刷题/6章2/生词本的生词.py
1,449
4.1875
4
""" 【问题描述】 生词本包含多个条目。每个条目由生词和该生词的含义组成。例如,生词name的含义是名字。编写程序,输出多个生词及其含义,列出生词本中包含的生词。 【输入形式】 输入多行。每一行包含生词及其含义。这一行内,生词和含义之间用冒号分隔。 【输出形式】 输出一行。列出所有的生词,之间用空格分隔。生词按字典序从小到大排序 【样例输入】 name:名字 hello:你好 python:蟒蛇 【样例输出】 hello name python 【提示】 1. 在Pycharm集成开发环境中,运行程序的时候如何告诉程序输入已经结束?答案是,按Ctrl + D组合键。在Windows命令行中运行程序的话, 则是按Ctr...
false
23763e6a12f59c64cbc2a32b42aa06da0d74c470
wmm98/homework1
/视频+刷题/函数/带参数装饰器注意事项.py
896
4.15625
4
# # 当程序有返回值的时候 # def print_num(func): # def inner(n, m): # print("*" * 30) # func(n, m) # # return inner # # # @print_num # def pnum(n, m): # print(n, m) # # # pnum(1, 2) # 相当于调用inner函数,所以在在这里赋值的时候, # # 所以要传相应的参数到inner函数里面,而后面还要调用pnum函数 # # 其函数也要传相对应得函数 # 当有几个函数的的时候,不能每个函数都配有有个装饰器,这样代码就...
false
212f63b5b38e596fff59af833d73efea2cce750c
wmm98/homework1
/视频+刷题/第四章练习/单词个数统计.py
1,104
4.4375
4
"""编写一个程序,输入一个句子,然后统计出这个句子当中不同的单词个数。例如,对于句子“one little two little three little boys",总共有5个不同的单词,one, little, two, three, boys。 说明: (1)句子当中包含有空格。 (2)输入的句子当中只包含英文字符和空格,单词之间用一个空格隔开。 (3)不用考虑单词的大小写,假设输入的都是小写字符。 (4)句子长度不超过100个字符 (5)该问题实现的基本思路是: a. 先定义一个存储不同单词的列表 b. 每次从句子中读取下一个单词 c.不断将新读取的单词加入该单词列表中。若单词列表中已存在该单词,则不添加。 【输入形式】...
false
86bcf759663bf85c225c3e3560fe0d3dbfdc0c90
uschwell/DI_Bootcamp
/Week4 (18.7-22.7)/Day3 (20.7)/DailyChallenge/ceaser_cypher.py
1,747
4.21875
4
from typing import final alphabet=['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'] #function that builds an encryption dictionary def build_dict(shift): shift=int(shift) dict={} for letter in range(len(alphabet)): if(letter+shift)<len(alpha...
false
3f7d5cc212695f3f9459c5dca44d05d5a318c61c
vyanphan/codingchallenges
/reverse_linked_list.py
1,270
4.21875
4
''' Reversing a singly linked list in-place. You should be able to do this in O(n) time. Do not put the items into an array, reverse the array, and put them back into the linked list. ''' ''' For testing purposes. ''' class LinkedNode(object): data = None next = None def __init__(self, data): sel...
true
47c52239a862d693010207f8477f58140a372fe7
vyanphan/codingchallenges
/regex.py
1,940
4.28125
4
''' Make a simple regex function that matches * and + + matches any single or empty character * matches any sequence (including empty) text: 'baaabab' regex: 'baa*a++' True regex: 'ba*a+' True regex: 'a*ab' False ''' def regex_match_recursive(string, regex): if string == '' and regex == '': retur...
false
21360bf9fec454ffe7b9c05e97e6c26f328ec225
lzxysf/python
/cli/python_043_dynamic.py
2,333
4.3125
4
# python是动态语言 # 动态语言是运行时可以改变其结构的语言 # C、C++是静态语言 import types class Person: def __init__(self, name, age): self.name = name self.age = age print("{} is {} years old".format(name, age)) def eat(self): print("i am eating") p = Person('liming', 15) # liming is 15 years old print(p...
false
bc5a2f1f7114718e5cc4406e165f252bdde907be
Audarya07/99problems
/P33.py
344
4.1875
4
# Determine whether two positive integer numbers are coprime. def gcd(a, b) : if b == 0: return a return gcd(b, a%b) num1 = int(input("Enter first number : ")) num2 = int(input("Enter Second number : ")) if gcd(num1, num2) == 1: print("Given numbers ARE co-primes") else : print("Given num...
true
38b08a3205e61662c82c1fce1aa055514e2f926c
SeggevHaimovich/Python-projects
/Aestroids/asteroid.py
2,520
4.75
5
############################################################################### # FILE : asteroid.py # WRITER : ShirHadad Seggev Haimovich, seggev shirhdd # EXERCISE : intro2cs2 ex10 2021 # DESCRIPTION: the class: Asteroid ############################################################################### import ma...
true
1dcdafb730f5addeef92b23d02184f30de3bef2d
gurmeetkhehra/python-practice
/Listhomwork4.py
614
4.25
4
# 4. Write a Python program to check a list is empty or not. Take few lists with one of them empty. fruits = ['apple', 'cherry', 'pear', 'lemon', 'banana'] fruits1 = [] fruits2 = ['mango', 'strawberry', 'peach'] # print (fruits[3]) # print (fruits[-2]) # print (fruits[1]) # # # print (fruits[0]) # print (fruits) # # f...
false
608309973a1b4917b47c610e571f5c14b0fe521b
gurmeetkhehra/python-practice
/list after removing.py
383
4.3125
4
# 7. Write a Python program to print a specified list after removing the 0th, 4th and 5th elements. # Go to the editor # Sample List : ['Red', 'Green', 'White', 'Black', 'Pink', 'Yellow'] # Expected Output : ['Green', 'White', 'Black'] colors = ['Red', 'Green', 'White', 'Black', 'Pink', 'Yellow'] colors.remove('Red...
true
a29f0ca42991b52d22f538584f6cbc0b53587823
mateusers/Homeworks-PYTHON
/matrix.py
2,268
4.125
4
print("Добро пожаловать в вычисление матриц!") operacia = input("Вас интересует сложение или умножение матриц?\nЕсли сложение, то введите: +\nЕсли умножение, то введите: *\n") x = int(input("1 число 'первой' матрицы: ")) y = int(input("2 число 'первой' матрицы: ")) z = int(input("3 число 'первой' матрицы: ")) m...
false
522237f16f2ea405b0cb2afa37b95331bc9294b3
gokayozcoban/3.b.g.-Data-Types---Strings---Metodlar---find-ve-index---aranan-harfi-kelimeyi-sayar-metin-icinde
/3.b.g. Data Types - Strings - Metodlar - find() ve index()- aranan harfi kelimeyi sayar, metin içinde kaçıncı sırada olduğunu.py
1,115
4.125
4
# find() ve index() # Aranan karakterin veya kelimenin yerini bulurlar. Ama bunu sayı ile verir. # Yani metin değişkeni içerisinde bir kelime ya da karakter arıyorsak # find() ve index() metodları bize onun kaçıncı karakterde başladığını söyler. # karakterleri saymaya 0'dan başlarlar. 0,1,2,3... gibi: metin = """B...
false
f25df7963a9a9c81d8b28186b223350cf8d9ba87
wudizhangzhi/leetcode
/medium/merge-two-binary-trees.py
2,296
4.40625
4
# -*- coding:utf8 -*- """ Given two binary trees and imagine that when you put one of them to cover the other, some nodes of the two trees are overlapped while the others are not. You need to merge them into a new binary tree. The merge rule is that if two nodes overlap, then sum node values up as the new value of th...
true
2c8eea9be7b8b5de96a5c44cf1d3c8e365eda746
ChrisMatthewLee/Lab-9
/lab9-70pt.py
847
4.25
4
############################################ # # # 70pt # # # ############################################ # Create a celcius to fahrenheit calculator. # Multiply by 9, then divide by 5, then add 32 t...
true
93ed0f3ceef0a0fa18cb59080ff6542697db2335
KyleKing/dash_charts
/dash_charts/equations.py
2,691
4.4375
4
"""Equations used in scipy fit calculations.""" import numpy as np def linear(x_values, factor_a, factor_b): """Return result(s) of linear equation with factors of a and b. `y = a * x + b` Args: x_values: single number of list of numbers factor_a: number, slope factor_b: number,...
true
6f1d5c730e20841150ac7b491b56cb52d28b221e
zingpython/december
/day_four/Exercise2.py
1,322
4.28125
4
def intToBinary(number): #Create empty string to hold the binary number binary = "" #To find a binary number divide by 2 untill the number is 0 while number > 0: #Find the remainder to find the binary digit remainder = number % 2 #Add the binary digit to the left of the current binary number binary = str(...
true
8cb15496c6ef28903d1ea910ab0abb964522d3d9
missbanks/pythoncodes
/21062018.py
359
4.125
4
# TASK # print(51 % 48) name = input ("Hi what is your name") add_time = 51 current_time = int(input("What is your current time")) alarm_time = 5 extra_time = 3 if current_time == "2pm": print("your alarm will go off at 5pm you have {} extra hours to go".format(extra_time)) else: print("sorry you entered the wron...
true
75e03f156082c03a2170993e90c2507dff58721a
ge01/StartingOut
/Python/chapter_03/programming_exercises/pe_0301/pe_0301/pe_0301.py
1,107
4.65625
5
######################################################### # Kilometer Converter # # This program asks the user to enter a distance in # # kilometers, and then converts that distance to miles. # # The conversion formula is as follows: # # Miles = Kilometers * 0.6214 ...
true
abdd052b5d57d6181e0d12a28283889354f045e5
jjsanabriam/JulianSanabria
/Taller_1/palindromo.py
410
4.4375
4
'''It reads a word and it validates if word is a palindrome Args: PALABRA (string): word to validate Returns (print): resultado (string): Result of validate word (False or True) + word validate ''' print("Ingrese Palabra: ") PALABRA = input() PALABRA_MAYUSCULA = PALABRA.upper() if PALABRA_MAYUSCULA != ...
true
5f430dcd768230062b69004348041912274cb180
piskunovma/Python_hw
/les3/hw1.py
873
4.3125
4
""" 1. Реализовать функцию, принимающую два числа (позиционные аргументы) и выполняющую их деление. Числа запрашивать у пользователя, предусмотреть обработку ситуации деления на ноль. """ def my_func(number1, number2): try: number1, number2 = int(number1), int(number2) if number2 == 0: ...
false
b91944901cb2c351bb0f1844e6436b8067f6138c
piskunovma/Python_hw
/les2/hw3.py
1,843
4.21875
4
""" 3. Пользователь вводит месяц в виде целого числа от 1 до 12. Сообщить к какому времени года относится месяц (зима, весна, лето, осень). Напишите решения через list и через dict. """ # Решение через list # month = input("Введите номер месяца : ") # result_list = ["Зима", "Весна", "Лето", "Осень"] # # if month.isdi...
false
facc0ddf980a825b8587cc05e4caf70ff85415b8
bdllhdrss3/fizzbuzz
/fizzbuzz.py
556
4.1875
4
#making a fizz buzz app #creating input of list list1 = input("Enter list one : ") list2 = input("Enter list two : ") length1 = len(list(list1)) length2 = len(list(list2)) sumation = length1 + length2 fizz = sumation%3 buzz = sumation%5 #now creating the fizzbuzz function def fizzbuzz(): if buzz == 0 and fizz == ...
true
a8b0b1306df3c42d9333f9d979b494a39ca79d96
Resham1458/Max_Min_Number
/max_min_nums.py
520
4.34375
4
total=int(input("How many numbers you want to enter?")) #asks user the total number he/she wants to enter numbers = [int(input("Enter any whole number:")) for i in range(total)] # lets the user to enter desired number of numbers print("The list of numbers you entered is:",numb...
true
0cc4375b4bdce67644fa9a56784738b057b847f5
kathytuan/CoffeeMachine
/main.py
2,606
4.125
4
MENU = { "espresso": { "ingredients": { "water": 50, "coffee": 18, }, "cost": 1.5, }, "latte": { "ingredients": { "water": 200, "milk": 150, "coffee": 24, }, "cost": 2.5, }, "cappuccino": { ...
true
a87fa54c7333f4b517a7c4daf7883b6d463a6234
kayanpang/champlain181030
/week5-2_functions_181129/function.py
684
4.34375
4
# example: repetition print("this is line 1") print("---------------") print("this is line 2") print("---------------") print("this is line 3") print("---------------") # so create a function to do this repetition def print_underscores(): print("---------------") # function needs to be defined before used print("th...
true
e4754d3dce75fe063cd24ecfc5dc2d543cdf0932
kayanpang/champlain181030
/190225_revision/different-kinds-of-array.py
1,524
4.5625
5
# list is ordered and changeable. Allows duplicate members. it uses [] square brackets # – Use lists if you have a collection of data that does not need random access. # Try to choose lists when you need a simple, iterable collection that is modified frequently. mylist = [1, 2, 'Brendan'] print(mylist[1]) # tuple is o...
true
c8b21caf9356d06471480f3488522d6ca31b01ed
kayanpang/champlain181030
/week7-2_private-contribution/encapsulation.py
859
4.375
4
# worker - employee - contractor initializer in child Classes (slide15) # read everything about class he whole chapter class Worker: """this class represents a worker""" def __init__(self, worker_name=""): self.name = worker_name def set_name(self, new_name): self.__name - new_name def ...
true
6c01d290efd21c4d689c0c102398550d308dda30
adesanyaaa/ThinkPython
/fermat.py
941
4.46875
4
""" Fermat's Last Theorem says that there are no positive integers a, b, and c such that a^n=b^n=c^n Write a function named check_fermat that takes four parameters-a, b, c and n-and that checks to see if Fermat's theorem holds. If n is greater than 2 and it turns out to be true the program should print, "Holy smokes, F...
true
32c8fe672f6a6127973b4b28a62ab056321249bf
adesanyaaa/ThinkPython
/lists10.py
862
4.15625
4
""" To check whether a word is in the word list, you could use the in operator, but it would be slow because it searches through the words in order. Because the words are in alphabetical order, we can speed things up with a bisection search (also known as binary search), which is similar to what you do when you look a ...
true
3f7e4990a911eabae25c224a4d9454f1196d4e4e
adesanyaaa/ThinkPython
/VolumeOfSphere.py
300
4.375
4
""" The volume of a sphere with radius r is (4/3)*pi*r^3 What is the volume of a sphere with the radius 5 Hint: 392.7 is wrong """ # For this we will be using the math.pi function in python # first we need to import the math class import math r = 5 volume = (4 / 3) * math.pi * r ** 3 print(volume)
true
712e3c920965f9a21bedcdd7df712a7f79cd9dbd
adesanyaaa/ThinkPython
/dictionary2.py
502
4.34375
4
""" Dictionaries have a method called keys that returns the keys of the dictionary, in no particular order, as a list. Modify print_hist to print the keys and their values in alphabetical order. """ hist = {1: 2, 3: 4, 5: 6, 7: 8} mydict = {'carl': 40, 'alan': 2, 'bob': 1, 'danny': 3} d...
true
88140b85b4cbc6075b2f18b09f12beb48eacc55a
adesanyaaa/ThinkPython
/store_anagrams.py
1,116
4.1875
4
""" Write a module that imports anagram_sets and provides two new functions: store_anagrams should store the anagram dictionary in a "shelf;" read_anagrams should look up a word and return a list of its anagrams. """ import shelve import sys from anagram_set import * def store_anagrams(filename, ad): """Stores ...
true
a6ae696b7ffe00652f7ef0d1c5ab8c4a7de0b474
adesanyaaa/ThinkPython
/lists3.py
570
4.21875
4
""" Write a function that takes a list of numbers and returns the cumulative sum that is, a new list where the ith element is the sum of the first i + 1 elements from the original list. For example, the cumulative sum of [1, 2, 3] is [1, 3, 6] """ def nested_sum(): a = int(input("Enter the number of Elements you ...
true
481095e995d267d95df513b8deace98d3492090a
adesanyaaa/ThinkPython
/VariableAndValues.py
849
4.6875
5
""" Assume that we execute the following statements width= 17 height=12.0 delimiter='.' for each of the expressions below write down the expression and the type 1. width/2 2. width/2.0 3. height/3 4. 1+2*5 5. delimiter*5 """ width = 17 height = 12.0 delimiter = '.' # 1. Width /2 should give an integer value of 8.5-f...
true
97914bc6f8c62c76aa02de1bd5c5f2a82e02e6db
nuria/study
/EPI/11_real_square_root.py
748
4.1875
4
#!usr/local/bin import sys import math def inner_square_root(_max, _min, n): tolerance = 0.05 middle = (_max - _min) *0.5 middle = _min + middle print "max: {0}, min:{1}, middle:{2}".format(_max, _min, middle) if abs(middle* middle -n) < tolerance: return middle elif middle * middle ...
true
fd5abb56732e9ddf37f093fe007c6c848d414b44
nuria/study
/misc/five-problems/problem3.py
714
4.25
4
#!/usr/local/bin/python ''' Write a function that computes the list of the first 100 Fibonacci numbers. By definition, the first two numbers in the Fibonacci sequence are 0 and 1, and each subsequent number is the sum of the previous two. As an example, here are the first 10 Fibonnaci numbers: 0, 1, 1, 2, 3, 5, 8, 13...
true
d929b25cb329d8a2c6589856e48e660c372b7aae
nuria/study
/crypto/xor.py
1,748
4.46875
4
#!/usr/local/bin/python import sys import bitstring import virtualenv # snipet given in coursera crypto course # note xor of 11 and 001 will be 11, chops the last '1' at the longer string def strxor(a, b): # xor two strings of different lengths if len(a) > len(b): return "".join([chr(ord(x) ^ ord(y)...
true
352b8196d758694512da5c5105977cf6d4e76ce4
nuria/study
/EPI/tmp_linked_list_flatten.py
1,957
4.1875
4
#!usr/local/bin # define each node with two pointers class llNode: def __init__(self, value, _next = None, head = None): self.value = value # next node self.next = _next self.head = head def __str__(self): if self.value is None: return 'None ->' ret...
true
cc3c31b09a402b7637ed05d98a01476620f26280
nuria/study
/misc/five-problems/problem6.py
1,726
4.25
4
#!/usr/local/bin/python import sys def main(): ''' Given a sorted array and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in order. There won't be duplicate values in the array. For example: [1, 3, 5, 6] with target v...
true
e37aeda0aa6f7d493dd27b2715d362a25138392a
maike-hilda/pythonLearning
/Ex2_5.py
469
4.28125
4
#Exercise 2.5 #Write a program that prompts the user for a Celsius temperature, #convert the temperature to Fahrenheit, and print out the converted #temperature #Note: 0 deg C equals 32 deg F and 1 C increase equals 9/5 F increase C = raw_input('Enter the current temperature in Degree Celcius:\n') try: C = f...
true
767d08be4e912dd1824c4431dc5a4a047b53f805
maike-hilda/pythonLearning
/Ex6_3.py
326
4.21875
4
#Exercise 6.3 #Write a function named count that accepts a string and a letter to #be counted as an argument def count(word, countLetter): count = 0 for letter in word: if letter == countLetter: count = count + 1 print 'The letter', countLetter, 'appeared', count, 'times.' ...
true
c362e44626893049bbf9753c7d46da60d4f07604
fslaurafs/NanoCourses-FiapOn
/Python/Python/Cap3/Manipulação de Listas, Funções e Módulos/Ep01_listas.py
410
4.125
4
# Ep01 - INTRODUÇÃO: VARIÁVEIS E LISTAS inventario = [] resposta = "S" while resposta == "S": inventario.append(input("Equipamento: ")) inventario.append(input("Valor: R$")) inventario.append(input("Número Serial: ")) inventario.append(input("Departamento: ")) resposta = input("Digite ...
false
fbda37076aa297d6d627f467a4d9a9c573c01a9d
fslaurafs/NanoCourses-FiapOn
/Python/Python/Cap2/Variáveis, Tomada de Decisão e Laços de Repetição/Ep01_variaveis.py
857
4.1875
4
# Ep01 - CONCEITUAÇÃO E TIPOS DE VARIÁVEIS nome = input("Digite um funcionário: ") empresa = input("Digite a instituição: ") qtde_funcionarios = int(input("Digite a quantidade de funcionários: ")) mediaMensalidade = float(input("Digite a média da mensalidade: R$")) print(nome + " trabalha na empresa " + empres...
false
e9840375c81c4bc383698ab2fd105ddabfd0f27f
kobeding/python
/lxfpy/class/special_getattr.py
811
4.15625
4
#!/usr/bin/python3.5 #__getattr()__:动态的返回一个属性 class Student(object): def __init__ (self): self.name = 'kobe' def __getattr__ (self,attr): #调用不存在,会试图调用这个来尝试获取属性 if attr == 'score': return 99 if attr == 'age': return lambda:25 #返回函数也是完全可以的 raise AttributeError(" Student() object has no attribute '%s' "...
false
7c46d453e8cc017101c8e96a9cb192baea562d71
VilmaLago/Estudos_iniciais_Python
/testes_iniciais/teste_funções.py
641
4.125
4
# Testes iniciais para aprender sobre funções. # Defina a função para formatar nomes. def nome_formatado(primeiro_nome, sobrenome): '''Formate o nome da pessoa''' nome_completo = primeiro_nome + ' ' + sobrenome return nome_completo.title() # Receba os inputs de nome e sobrenome. print("Digite seu nome comp...
false
20ef3d59c8d2b75569e2fbe8a419dc8a6461a38e
VilmaLago/Estudos_iniciais_Python
/testes_iniciais/teste_exceptions.py
577
4.15625
4
# Testes iniciais para aprender sobre exceções. print("Dê-me dois números e eu irei dividí-los: ") print("Digite 'sair' sempre que quiser fechar o programa.") while True: primeiro_numero = input("Digite o primeiro número: ") if primeiro_numero.lower() == 'sair': break segundo_numero = input("Digit...
false
14e0fa9c2a493870a09bd9be0818e2c0d0766ca2
priya510/Python-codes
/01.10.2020 python/min.py
419
4.125
4
num1=int(input("Enter the first number: ")); num2=int(input("Enter the second number: ")); num3=int(input("Enter the Third number: ")); def find_Min(): if(num1<=num2) and (num1<=num2): smallest=num1 elif(num2<=num1) and (num2<=num3): smallest=num2 elif(num3<=num1) and (n...
true
4ddcecdbb97a17c6537ad2d9360cba1f9f2dc54e
CUCEI20B/zodiaco-AndresSanchez-A
/main.py
2,047
4.21875
4
print("Simbolo del Zodiaco") dia = int(input("Numero de dia de nacimiento: ")) mes = int(input("Numero de mes de nacimiento: ")) if mes == 12: if dia >= 1 and dia <= 21: print("Tu simbolo es sagitario") if dia >= 22 and dia <= 31: print("Tu simbolo es capricornio") elif mes == 1: if dia >=...
false
c8503897bb274bac5cb7d4ed0762db5316501b9c
MythicalCuddles/Learning-Python
/simple calculator.py
350
4.1875
4
# int only allows whole numbers num1 = input("Please enter a number: ") num2 = input("Please enter another number: ") result = int(num1) + int(num2) print(result) # float allows for decimals num1 = input("Please enter a number: ") num2 = input("Please enter another number: ") result = float(num1) + ...
false
b6de4bd1f23daba6a2cee75f17ec0a19d32a9256
BogdanSorbun/Date_Finder
/what_day_is_it.py
614
4.25
4
days = ['saturday', 'sunday', 'monday', 'tuesday', 'wednesday', 'thursday', 'friday'] days_in_month = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31] # day 1 started on a saturday def num_of_leap(year): leap_years = int(year/4)-(int(year/100) - int(year/400)) return leap_years def date(y...
false
886ab87338fe873257b61abdb90971044bfb1db1
jdn8608/Analysis_of_Algo_hw_2
/src/sphere.py
2,341
4.1875
4
import math ''' Name: Joseph Nied Date: 2/12/20 Class: CSC-261 Question: 3 Description: Algorithm to see if given a points, if any would lie on a sphere together ''' def main() -> None: SIZE = int(input()) #Create an empty array with size SIZE Magnitude = [None] * SIZE #Get the input coordinates ...
true
cec6fafd666635de71fc1c2a2d188f297c8b514b
Khalid-Sultan/Section-2
/to binary.py
273
4.1875
4
def main(): value=eval(input("Enter an integer:")) print("The binary value is",decimalToBinary(value)) def decimalToBinary(value): result="" while value!=0: bit=value%2 result=str(bit)+result value=value//2 return result main()
false
61af3f82b452f1e0402cafc2a5797e3ffbb399be
Tamabcxyz/Python
/th2/dictionariescollectioninpython.py
371
4.15625
4
#A dictionary is a collection unordered can changeable, index. In python dictionary are written with curly brackets #the have keys and values a={"name":"Tran Minh Tam", "age":22} print(a) for x in a.values(): print(x) for x in a.keys(): print(x) for x,y in a.items(): print(f"a have key {x} values is {y}") #...
true
d5438545ead5bb2d41c7791b6e86c72c4f93aa66
LuannaLeonel/data-structures
/src/python/InsertionSort.py
314
4.125
4
def insertionSort(value): for i in range(len(value)): j = i while (j > 0 and value[j] <= value[j-1]): value[j], value[j-1] = value[j-1], value[j] j -= 1 return value a = [1,3,7,9,5] b = [5,5,7,3,0,2,1,52,10,6,37] print insertionSort(a) print insertionSort(b)
true
197fb6b7d7b4db1ccde7078e85475f80d9c604d9
arpith143a/best-practices
/interview_easy/interview3.2.py
204
4.125
4
m=int(input('Enter number:')) if m<=0: print('Enter number greater than zero') for i in range(1,m+1): for k in range(i,m): print(' ',end='') for j in range(1,i+1): print('*',end='') print('')
false
37679aa5f19d56a0cd004f0349fb566d902f9464
nara-l/100pythonexcercises
/Ex66basic_translator.py
299
4.125
4
def translator(word): d = dict(weather="clima", earth="terra", rain="chuva") try: return d[word.lower()] except KeyError: return "We don't understand your choice." word = input("Please enter a word to translate, weather, earth, rain etc. \n ") print(translator(word))
true
43dd5fb872255883905ff1748a99867cd3c7079a
Plaifa/python
/test2.py
610
4.125
4
from datetime import datetime , timedelta current = datetime.now() print('Today is '+ str(current)) oneday = timedelta(days=1) ytd = current - oneday print ('Yesterday is '+ str(ytd)) oneweek = timedelta(weeks=1) lastw = current - oneweek print ('last week is '+ str(lastw)) print('-------------------------') print...
false
7d614f93d73dae587402e28e85e31062bafbdfa6
matthewosborne71/MastersHeadstartPython
/Programs/Exercise1.py
411
4.125
4
# Write a program that generates a random integer between 1 and 100 # and then has the user guess the number until they get it correct. import random Number = random.randint(1,100) Guess = -99 print "I thought of a number, want to guess? " while Guess != Number: Guess = int(raw_input()) if Guess != Number: ...
true
b68ed99d0e68860f0ccdff2b272babe8ab836381
InFamousGeek/PythonBasics
/ProgramToFindTheLngthOfAString1.py
276
4.375
4
# Python Program to find the length of a String (2nd way) # using for loop # Returns length of string def findLen(str): counter = 0 for i in str: counter += 1 return counter str = str(input("Enther the string : ")) print(findLen(str))
true
cf0fcc053e157beaa2b6eee2a78fa788d7cb2b8c
jonathan-murmu/ds
/data_structure/leetcode/easy/344 - Reverse String/reverse_string.py
991
4.3125
4
''' Write a function that reverses a string. The input string is given as an array of characters s. You must do this by modifying the input array in-place with O(1) extra memory. Example 1: Input: s = ["h","e","l","l","o"] Output: ["o","l","l","e","h"] Example 2: Input: s = ["H","a","n","n","a","h"] Output: ["h","a...
true
3fb235ced0711f77d36d1d8a59c62bd1fdf7d564
naman-32/Python_Snippets
/BASIC/v6.py
1,107
4.28125
4
if True:#False not ok print("alright") else : print("not ok") #nkgnkgnkgbnkbgl#lkvjbljgkglbvjlbjbklbkbvlkbvljlbvjj #"""jigbjljgfjgfljgfjlfgjbgfbjgfjlfjdrnamanjgoenka is very language = 'jav' if language == 'python': print("la is python") elif language == 'java': print("la is java") else: pri...
false
d49fc41036398468f691da9300ab49fd2a3c0f9b
ranoaritsiky/Udemy_tsiky
/udemy.py
732
4.125
4
# liste = ["Java", "Python", "C++"] # liste.insert(3, liste[1]) # liste.remove("Python") # print (liste) # liste = ["Maxime", "Martine", "Christopher", "Carlos", "Michael", "Eric"] # print (liste[0:3]) # liste = [1, 2, 3, 4, 5] # liste.append(6) # if 6 in liste: # print ("Le nombre 6 a bien été ajouté à la liste."...
false
05a2eece1e470e7324b753635da58de637b61b7c
Descent098/schulich-ignite-winter-2021
/Session 3/Solutions/Exercise 1.py
1,266
4.34375
4
"""Exercise 1: Country Roads Steps: 1. Fill out fill_up() so that it fills the fuel level to the gas tank size (line 18) 2. Fill out drive() so that it removes the amount of fuel it should for how far you drove(line 22) 3. Fill out kilometres_available so that it returns the amount of kilometers left based...
true
dd29ea41437ef40746dc5df10398a3b9ca4c1389
tic0uk/python-100daysofcode
/day-5-fizzbuzz-game.py
420
4.28125
4
# replicating a game called fizzbuzz that children play; for i in range(1,101): # if number is divisible by both 3 or 5 say "fizzbuzz" if (i % 3 == 0 and i % 5 == 0): print ("fizzbuzz") # if number is divisible by 3 say "fizz" elif i % 3 == 0: print ("fizz") # if number is divisible by 5 say "buzz" el...
false
4b88131b589761baf17e03992be46cb9742c0a62
praemineo/backpropagation
/backpropagation.py
1,720
4.15625
4
import numpy as np #define sigmoid function def sigmoid(x): return 1 / (1 + np.exp(-x)) # X is a unit vector x = np.array([0.5, 0.1, -0.2]) # target that we want to predict target = 0.6 #learning rate or alpha learnrate = 0.5 #weight that we initialize weights_input_hidden = np.array([[0.5, -0.6], ...
true
5a47d18b0353a71db8c6d177beed9cbda00ab3b6
birdcar/exercism
/python/scrabble-score/scrabble_score.py
584
4.1875
4
from typing import Dict # Generates a mapping of letters to their scrabble score e.g. # # { 'A': 1, ..., 'Z': 10 } # SCORE_SHEET: Dict[str, int] = dict( [(x, 1) for x in 'AEIOULNRST'] + [(x, 2) for x in 'DG'] + [(x, 3) for x in 'BCMP'] + [(x, 4) for x in 'FHVWY'] + [(x, 5) for x in 'K'] + ...
true
d7025c13f88527f24d10fc1a9b131f0c7e7bd627
TheAughat/Setting-Out
/Python Practice/app4.py
641
4.15625
4
# The following block of code writes the times table for anything till times 10. Users can enter 'please stop' to quit print('Writes the times table for anything till times 10. Enter "please stop" to quit.') while True: print() tables = input("Which number do you want to see the tables of? ") number ...
true
d969a5a2b642277e499e2c6cafe59c947e7be3f3
AliHassanUOS/PythonProgramaAndProject
/dictionaryinpython.py
2,338
4.1875
4
# print("Dictionary in python") # print() # # # print(dic[2]) # # print(dic) # dic = {1: 'ali', 2: 'hassan', 3: 'rubab', 4: 'ahmad'} # # print(11 not in dic) # dic = {1: 'ali', 2: 'hassan', 3: 'rubab', 4: 'ahmad'} # print(dic) # print() # dic.clear() # print(dic) # dic = {1: 'ali', 2: 'hassan', 3: 'rubab', 4: 'a...
false
1cabb3e6a643fcb1d052eda08e4a1fd96f0f820c
AliHassanUOS/PythonProgramaAndProject
/OopPractice.py
1,709
4.28125
4
print("ALLAH") # class calculator(object): # create calculator class # # def add(self, x, y): # return x + y # # def sub(self, x, y): # return x - y # # def mul(self, x, y): # return x * y # # def divide(self, x, y): # return x // y # # # obj = calculator() # while Tru...
false
9208bc3b8e1ef3b6ef3e291d410057f926b0a2ac
kenedilichi1/calculator
/main.py
917
4.15625
4
def add(x, y): ''' Adds 2 numbers ''' return x + y def subtract(x, y): return x - y def multiply(x, y): return x * y def divide(x, y): return x / y isRunning = True while isRunning: choice = input("operator: ") if choice in ('add', 'subtract', 'multiply', 'divide'): num1 = fl...
true
8a4a09865d205160bc4fdbcbedbd77e8d1f48124
Prithvi103/code-with-me
/Longest Mountain in Array {Medium}.py
2,314
4.125
4
""" Let's call any (contiguous) subarray B (of A) a mountain if the following properties hold: B.length >= 3 There exists some 0 < i < B.length - 1 such that B[0] < B[1] < ... B[i-1] < B[i] > B[i+1] > ... > B[B.length - 1] (Note that B could be any subarray of A, including the entire array A.) Given an array A of int...
true
9be5923a412b0d78f7a283c93f5acb80b52ac9b8
musicakc/NeuralNets
/Tutorial/threelayernn.py
1,701
4.15625
4
''' Neural Networks Tutorial 1: https://iamtrask.github.io/2015/07/12/basic-python-network/ 3 input nodes, 4 training examples ''' import numpy as np ''' Nonlinearity or sigmoid function used to map a value to a value between 0 and 1 ''' def nonlin(x,deriv=False): #ouput can be used to create derivative if(deriv ...
true
ca5d631772a998607acba42ead0af35f7956b6ee
nonstoplearning/python_vik
/ex13.py
1,135
4.125
4
from sys import argv script, first, second, third = argv fourth = input("Enter your fourth variable: ") fifth = input("Enter your fifth variable: ") print ("Together, your first variable is %r, your second variable is %r, your third variable is %r, " "your fourth variable is %r, your fifth variable is %r" % (...
true
db7f21092dc6cba286f2c1270129f7c56b706d25
cheokjw/Pytkinter-study
/tkinter/Codes/tk button.py
849
4.3125
4
from tkinter import * # Initializing Tk class OOP(Object-Oriented Programming) root = Tk() # A function that shows the text "Look! I clicked a Button" def myClick(): myLabel = Label(root, text = "Look! I clicked a Button !") myLabel.pack() # Button(root, text) = having a button for user to click # state = DI...
true
fdb87fcf446a3f42b572033a2af22279516bf5e5
gom7430/Basic-ML-algorithms
/kmeans_algo.py
932
4.34375
4
#--------------------------------------------------------------- #basic implementation of k-means clustering algorithm #--------------------------------------------------------------- import numpy as np import matplotlib.pyplot as plt from sklearn.cluster import KMeans #prepare the data x = np.array([[5,3],[...
false
ac6b346fd9f0262cfd9381e374236955ee972a5e
bfakhri/deeplearning
/mini-1/bfakhri_fakhri/regressor.py
1,365
4.28125
4
""" Author: Bijan Fakhri Date: 2/3/17 CSE591 - Intro to Deep Learning This file implements the regressor class which performs a linear regression given some data """ import numpy as np class regressor(object): """ Class that implements a regressor. After training, it will have weights that can be exported. Ar...
true
4c483c108073d56208c7d1e56497e2dca3e6588a
NewAwesome/Fundamental-algorithms
/LeetCode/21. Merge Two Sorted Lists/Solution.py
1,321
4.1875
4
from ListNode import ListNode class Solution: # Iteration def mergeTwoLists(self, l1: ListNode, l2: ListNode) -> ListNode: # create a var named 'head' node, used for point to head of the result LinkedList # create a var named 'cur' node, used for iteration point to the smaller node of l1 and ...
true
5e8d193c0a21c3c3dfafcb0fb94419777359e9ca
jjunsheng/learningpython
/mosh python/quiz(comparison operators).py
438
4.46875
4
#if name is less than 3 characters long #name must be at least 3 characters #otherwise if it's more than 50 characters long #name can be a maximum of 50 chatacters #otherwise #name looks good name = input('Name : ') if len(name) < 3: print("Name must be a minumum of 3 characters. Please try again.") elif len(nam...
true