blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
dc72e0c85760fb647f5ce64289303cbe915fdb04
Anosike-CK/class_code
/Membership_Operartors.py
1,389
4.625
5
# MEMBERSHIP OPERATORS ARE USED TO CHECK FOR THE MEMBERSHIP OF A VARIABLE IN A SEQUENCE a = 10 b = 20 num_list = [1, 2, 3, 4, 5 ] if ( a in num_list ): print ("Line 1 - a is available in the given num_list") else: print ("Line 1 - a is not available in the given num_list") if ( b not in num_list ): print ("...
true
fd0012b59d8cda95b17f00aecef6093446defd34
Anosike-CK/class_code
/first_thonny_practice.py
330
4.25
4
"""website = "Apple.com" #we re-write the program to change the value of website to programiz.com website = "programiz.com" print(website) """ """#Assign multiple values to multiple variables a,b,c = 5,3,5.2 print(a) print(b) print(c)""" #Assign the same value to multiple variables x = y = z = "hmm" print(x) print(y...
true
eec3c15f8d1a40faddbb551aafe9ee823c09cd09
zs1621/pythostudy
/argparse/argparse_example.py
808
4.28125
4
#!/usr/bin/env python # coding: utf-8 """ parser = argparse.ArgumentParser() - parser.add_argument help: description action: 动作 count-参数个数, default-参数默认值, store_true-如果参数指定,赋值 True 或 args.verbose, choice-参数可以选择的值, type-参数的类型 - parser.parse_args """ import argparse parser = argparse.ArgumentParser...
false
921c99126444561c5f940f00e569a7a1367765b1
zs1621/pythostudy
/class/attribute.py
1,147
4.21875
4
#!/usr/bin/env python # coding: utf-8 """ In Python, only class attributes can be defined here; data attributes are defined in the __init__ method. """ class Test: a = 0 #class attributes def __init__(self): self.a += 1 #data attributes print(Test.a) print(Test().a) """ 如果想改变 类的属性 """ class counte...
false
90e061241a1de2eb2ec544b864782218ec8d6711
Kllicks/DigitalCraftsPythonExercises
/OddNumbers.py
356
4.375
4
#using while loop, print out the odd numbers 1-10 inclusive, one on a line #initiate variable i = 1 #while loop to cycle through and print 1-10 while i <= 10: #if statement to check if the number is also odd #can't use and on outer while loop because it would end the program when 2 failed if i % 2 !...
true
5c250f4557d71212cde13a0002b7ebc8f39f4bc6
yasar84/week1
/lists.py
2,166
4.5
4
cars = ["toyota","lexus", "bmw", "merc" ] print(cars) # accessing the list print("first element of cars list: " + cars[0]) print("second element of cars list: " + cars[1]) print("third element of cars list: " + cars[2]) print("fourth element of cars list: " + cars[3]) print("last element of cars list: " + cars[-1]) ...
true
1d001ee57009334fa0394946f4b65c4f46741172
AgguBalaji/MyCaptain123
/file_format.py
380
4.71875
5
"""Printing the type of file based on the extension used in saving the file eg: ip-- name.py op--it is a python file""" #input the file name along with the extension as a string file=input("Input the Filename:") #it is a python file if it has .py extension if ".py" in file: print("The extension of the file is : '...
true
af8d1a4b71460e9ecd5819fddd63a97d4ccd7bfa
cai-michael/kemenyapprox
/matrix.py
1,382
4.3125
4
""" Defines some matrix operations using on the Python standard library """ def generate_zeros_matrix(rows, columns): """ Generates a matrix containing only zeros """ matrix = [[0 for col in range(columns)] for row in range(rows)] return matrix def get_column_as_list(matrix, column_no): """ ...
true
31a9494408c46a07d34b9b4d5f1338d1de9b37ef
Jon710/python-topicos2
/p2/analise_string.py
1,788
4.1875
4
# lista que será traduzida list_of_words = ['thy', 'thine', 'thee', 'thou', 'hath'] # função que busca as palavras e quantidade total das palavras do Middle English def find_middle_english_words(text): # lista que irá conter as palavras, entre as que estão na lista, encontradas no texto words_found = [] co...
false
9465c54f43091c6fad9eb280bee17541b764017b
RomaMol/MFTI
/DirBasePython/Lec3/main.py
865
4.25
4
#!/usr/bin/python # -*- coding: utf-8 -*- # https://www.youtube.com/watch?v=HrlUxTOxil4 # Python 3 #3: функции input и print ввода/вывода # """ работа input() input() a = input() print(a) """ """ вычисляем периметр w = int(input()) h = int(input()) p = (w+h)*2 print(p) """ """ # вычисляем периметр w = int(input(...
false
5c49261669a5d5655595e79976836a98af03287b
RomaMol/MFTI
/DirOPP/Lec2/main.py
2,481
4.34375
4
# https://www.youtube.com/watch?v=7kk2gRf8Uws&list=PLA0M1Bcd0w8zo9ND-7yEFjoHBg_fzaQ-B&index=2 # ООП Python 3 #2: методы класса, параметр self, конструктор и деструктор class House: """Класс существительное с большой буквы x = 1 y = 1 атрибуты == данные def fun() - методы == функции """ def __ini...
false
fd012f62255613d28ef3d9976b2aca82a9b92ebc
RomaMol/MFTI
/DirBasePython/Lec14/main.py
763
4.1875
4
#!/usr/bin/python # -*- coding: utf-8 -*- # https://www.youtube.com/watch?v=WElr9nSS6bo # Python 3 #14: функции (def) - объявление и вызов def printHelow(): print("Hellow world") # printHelow() p = printHelow p() def myxvkbd(x): x = x ** 2 return x print(myxvkbd(3)) def ispositive(p): if p...
false
37f813e7e6974fe499252e476755e3e7411a037c
khayk/learning
/python/cheatsheet.py
1,311
4.28125
4
# 1. Print two strings with formatting # see https://www.programiz.com/python-programming/input-output-import print("Hello %s %s! You just delved into python." % (a, b)) # 2. Map each item from the input to int integer_list = map(int, input().split()) # Creates a tuple of integers t = tuple(integer_list) ...
true
50b86447072eac47a70ad3e35bb1a285cd5a3619
BTHabib/Lessons
/Lesson 2 Trevot test.py
820
4.21875
4
""" Author: Brandon Habib Date: 1/21/2016 """ #Initializing the array numbers = [] #Initializing A A = 0 #Printing instructions for the user print ("Give me an integer Trevor and then type \"Done\" when you are done. When all is finished I will show you MAGIC!") #A while loop to continue adding numbers to the array...
true
771de63fb0fd06a32f10e41fd6411f28bd3b985c
mfcarrasco/Python_GIS
/AdvGIS_Course/MyClassPractice.py
720
4.15625
4
class Myclass: var = "This is class variable" def __init__(self, name):# first parameter always self in a class self.name = name def funct(self):#using method and a function within aclass so ALWAYS start with self print "This is method print", self.name foo = Myclass("Malle")...
true
13ab27733b3c75d0c5f0c278698b43c3dd04d5a3
haaruhito/PythonExercises
/Day1Question3.py
495
4.125
4
# With a given integral number n, write a program to generate a dictionary that # contains (i, i x i) such that is an integral number between 1 and n (both included). # and then the program should print the dictionary.Suppose the following input is # supplied to the program: 8 # Then, the output should be: {1: 1, 2:...
true
b197f01edc925e63d28fc0a0a4228d64fb3f767d
johannalbino/python
/exercicio_1.py
247
4.21875
4
#exercicio 1 python #Faça um programa que receba a idade do usuário e diga se ele e maior ou menor de idade idade = int(input("Qual a sua idade :")) if idade >= 18: print ("Você é maior de idade!") else: print ("Você é menor de idade!")
false
c142586277e8f59719f324b7c2aea239ecc98680
kmiroshkhin/Python-Problems
/medium_vowelReplacer.py
622
4.21875
4
"""Create a function that replaces all the vowels in a string with a specified character. Examples replace_vowels("the aardvark", "#") ➞ "th# ##rdv#rk" replace_vowels("minnie mouse", "?") ➞ "m?nn?? m??s?" replace_vowels("shakespeare", "*") ➞ "sh*k*sp**r*" """ def replace_vowels(txt,ch): vowels = ['a'...
true
561b7063ef63e21a32f425e8aa2cd0060d1e3048
kmiroshkhin/Python-Problems
/easy_recursion_Sum.py
353
4.25
4
"""Write a function that finds the sum of the first n natural numbers. Make your function recursive. Examples sum_numbers(5) ➞ 15 // 1 + 2 + 3 + 4 + 5 = 15 sum_numbers(1) ➞ 1 sum_numbers(12) ➞ 78 """ def sum_numbers(n): addition=int() for i in range(1,n+1): addition+=i return addi...
true
9e4a81ce2ea3628967b2f2194caee577914bd1d8
kmiroshkhin/Python-Problems
/Hard_WhereIsBob.py
650
4.3125
4
"""Write a function that searches a list of names (unsorted) for the name "Bob" and returns the location in the list. If Bob is not in the array, return -1. Examples find_bob(["Jimmy", "Layla", "Bob"]) ➞ 2 find_bob(["Bob", "Layla", "Kaitlyn", "Patricia"]) ➞ 0 find_bob(["Jimmy", "Layla", "James"]) ➞ -1 """ ...
true
3700278b8bb878b60eaaf97e88a321ec53e146d0
erikayi/python-challenge
/PyPoll/main_final.py
2,013
4.21875
4
# Analyze voting poll using data in csv file. # import csv and os. import csv import os # define the location of the data. election_csv = "Resources/election_data.csv" # open the data. with open(election_csv, 'r') as csvfile: election_csv = csv.reader(csvfile) header = next(election_csv) # define the va...
true
9e7d6229ad3039076757cff1edf336796064b671
Sudhijohn/Python-Learnings
/conditional.py
388
4.1875
4
#Conditional x =6 ''' if x<6: print('This is true') else: print('This is false') ''' #elif Same as Else if color = 'green' ''' if color=='red': print('Color is red') elif color=='yellow': print('Color is yellow') else: print('color is not red or yellow') ''' #Nested if if color == 'green': i...
true
5b3eeada4baa5ebf3a774b911e582541cfdd9e5b
Aravind2595/MarchPythonProject
/questions/demo5.py
708
4.125
4
#Create a child class Bus that will inherit all of the variables and methods of Vehicle class? class Vehicle: def setval(self,tyre,type,gear,seat): self.tyre=tyre self.type=type self.gear=gear self.seat=seat def printval(self): print("tyre:",self.tyre) print("Dis...
false
60b2ea5bc3f7100de9f8f05c80dee8b0a803de46
Aravind2595/MarchPythonProject
/Flow controls/demo6.py
235
4.21875
4
#maximum number using elif num1=int(input("Enter the number1")) num2=int(input("Enter the number2")) if(num1>num2): print(num1,"is the highest") elif(num1<num2): print(num2,"is the highest") else: print("numbers are equal")
true
aa97b8e2e82b353ca5f1d3c14c97471b30d12521
Aravind2595/MarchPythonProject
/Flow controls/for loop/demo6.py
237
4.15625
4
#check a given number is prime or not num=int(input("Enter the number")) flag=0 for i in range(2,num): if(num%i==0): flag=1 if(flag>0): print(num," is not a prime number") if(flag==0): print(num,"is a prime number")
true
8a48a24a816b1693e493ddd2795f5f44aa958523
kblicharski/ctci-solutions
/Chapter 1 | Arrays and Strings/1_6_String_Compression.py
2,506
4.375
4
""" Problem: Implement a method to perform basic string compression using the counts of repeated characters. For example, the string 'aabcccccaaa' would become 'a2b1c5a3'. If the "compressed" string would not become smaller than the original string, your method should return the original string. You...
true
61a24ed9b8931c925de092f0116f780e253de52e
kblicharski/ctci-solutions
/Chapter 1 | Arrays and Strings/1_8_Zero_Matrix.py
2,826
4.125
4
""" Problem: Write an algorithm such that if an element in an MxN matrix is 0, its entire row and column are set to 0. Implementation: My initial, naive approach to the problem was to first find all occurrences of zeros and add their row and column values to two lists. Afterwards, we would check th...
true
86fd334b83e5da79823e2858a504ce50d30ac10c
LevanceWam/DPW
/madlib/madlib.py
1,650
4.40625
4
ice_cream = raw_input("What's your flavor: ") print "Tom was walking down the street and wanted a "+ice_cream+" Ice cream cone" friends = ["Monster", "T-Rex", "Jello"] print "Tom's friends wanted Ice cream too and they all had the same amount of money, Tom already has $5.00" for f in friends: print f + ", Has $2...
true
416d8b79e8c1c70a12e0b22bbf444045505e1b97
GabrielNew/Python3-Basics
/World 2/ex037.py
513
4.46875
4
# -*- coding: utf-8 -*- ''' ex037 -> Escreva um programa que leia um número e pergunte ao usuário, para qual base ele quer converter o número. 1 - Binário 2 - Octal e 3 - Hexadecimal ''' num = int(input('Digite um número: ')) print('1 - Binário\n2 - Octal\n3 - Hexadecimal') op = int(input(f'Para qual base ...
false
f83dcadf559443152cf57962e83c4337e82928c6
3116005131/pythone_course
/currency_converter_v1.0.py
946
4.25
4
""" 作者:段浩彬 功能:货币兑换 版本:1.0 日期:2019/3/21 """ # def convert_currency(im, er): # """ # 汇率兑换函数 # """ # out = im * er # return out def main(): """ 主函数 """ # 汇率 USD_VS_RMB = 6.77 # 带单位的货币输入 currency_str_value = input("请输入带单位的货币金额") unit = curre...
false
9d9b4d12ab4445af1644d1f29f7dda9c6cfbe32e
spanneerselvam/Marauders-Map
/marauders_map.py
1,750
4.25
4
print("Messers Moony, Wormtail, Padfoot, and Prongs") print("Are Proud to Present: The Marauders Map") print() print("You are fortunate enough to stuble upon this map. Press 'Enter' to continue.") input() name = input("Enter your name: ") input2 = input("Enter your house (gryffindor, ravenclaw, hufflepuff, slythe...
true
b5ec6c31ea7a394cbbdf7e2b8a0ea42640d8b1d5
nagendrakamath/1stpython
/encapsulation.py
715
4.15625
4
calculation_to_unit = 24 name_of_unit ="hours" user_input = input("please enter number of days\n") def days_to_units(num_of_days): return (f"{num_of_days} days are {num_of_days * calculation_to_unit} {name_of_unit}") def validate(): try: user_input_number = int(user_input) if user_input_numbe...
true
2836cf6c0a9351a3687a244b6034eb760cc2f5ba
pya/PyNS
/pyns/operators/dif_x.py
636
4.1875
4
""" Returns runnig difference in "x" direction of the matrix sent as parameter. Returning matrix will have one element less in "x" direction. Note: Difference is NOT derivative. To find a derivative, you should divide difference with a proper array with distances between elements! """ # ========================...
true
494cc5b447f85b112110e34dcc16e156f7ff4c2b
raveendradatascience/PYTHON
/Dev_folder/assn85.py
1,334
4.3125
4
#*********************************************************************************# # 8.5 Open the file mbox-short.txt and read it line by line. When you find a line # # that starts with 'From ' like the following line: # # From stephen.marquard@uct.ac.za Sat Jan 5 09:14:16 2008 ...
true
652e6e20d73239960e48d9dea1ad75ce3a802cca
KaustubhDhokte/python-code-snippets
/deep&shallowCopy.py
1,562
4.4375
4
''' Two types of copy operations are applied to container objects such as lists and dictionaries: a shallow copy and a deep copy. A shallow copy creates a new object but populates it with references to the items contained in the original object. ''' a = [1, 2, [8, 9], 5] print id(a) # Output: 47839472 b = list(a) pri...
true
11692778a4a716519e08e49f5a129ab743542f7d
KaustubhDhokte/python-code-snippets
/closures_TODO.py
475
4.125
4
# https://realpython.com/blog/python/inner-functions-what-are-they-good-for/ ''' def generate_power(number): """ Examples of use: >>> raise_two = generate_power(2) >>> raise_three = generate_power(3) >>> print(raise_two(7)) 128 >>> print(raise_three(5)) 243 """ # define the in...
true
444297ec4f122e9e9419dbc4ea56e5d9752bfec3
KaustubhDhokte/python-code-snippets
/metaclasses_TODO.py
2,756
4.3125
4
# https://stackoverflow.com/questions/100003/what-is-a-metaclass-in-python ''' A metaclass is the class of a class. Like a class defines how an instance of the class behaves, a metaclass defines how a class behaves. A class is an instance of a metaclass. ''' ''' When the class statement is executed, Python first exec...
true
5193aded8a6ba9ce63f4104567bd714ab6b19887
jqnv/python_challenges_Bertelsmann_Technology_Scholarship
/caesar_cipher.py
2,421
4.53125
5
# Option 1 Difficulty Level: Elementary: One of the first known # examples of encryption was used by Julius Caesar. Caesar needed # to provide written instructions to his generals, but he didn’t want # his enemies to learn his plans if the message slipped into their hands. # As result, he developed what later became kn...
true
f88cd2ec59b884787116eb60c476374990109b9b
jqnv/python_challenges_Bertelsmann_Technology_Scholarship
/unique_characters.py
1,124
4.40625
4
# Create a program that determines and displays the number of unique characters in a string entered by the user. # For example, Hello, World! has 10 unique characters while zzz has only one unique character. Use a dictionary or # set to solve this problem def unique_characters(text): # Solution using dictionary ...
true
34e456552f63f881b56f9e06e924cbc6c4528d4b
jqnv/python_challenges_Bertelsmann_Technology_Scholarship
/license_plate.py
1,408
4.59375
5
#License plate #Option 1 Difficulty Level: Elementary: In a particular jurisdiction, # older license plates consist of three uppercase letters followed by three numbers. # When all of the license plates following that pattern had been used, the format was # changed to four numbers followed by three uppercase #letters. ...
true
b01a758c609d2701d59a74f7bf019c7c4bd9f608
jqnv/python_challenges_Bertelsmann_Technology_Scholarship
/calc.py
1,676
4.53125
5
# For this exercise I want you to write a function (calc) that expects a single argument -a string containing # a simple math expression in prefix notation- with an operators and two numbers, your program will parse the input # and will produce the appropriate output. For our purposes is enough to handle the six basic ...
true
76fddfefedace4aca36548cbc3b6f2ab6f9d3188
jqnv/python_challenges_Bertelsmann_Technology_Scholarship
/reverse_lines.py
814
4.3125
4
# In this function, we do a basic version of this idea. The function takes two arguments: the names of the input # file (to be read from) and the output file (which will be created). def reverse_lines(orig_f, targ_f): # Read original file storing one line at the time with open(orig_f, mode="r") as f_input: ...
true
b8ceabe1af9f24f1acb694641f32f61c05ca34a6
jqnv/python_challenges_Bertelsmann_Technology_Scholarship
/dice_simulation.py
2,603
4.53125
5
# In this exercise you will simulate 1,000 rolls of two dice. Begin by writing a function that simulates rolling # a pair of six-sided dice. Your function will not take any parameters. It will return the total that was rolled on # two dice as its only result. # Write a main program that uses your function to simulate r...
true
d52add20d1d0518c2c3fb82ce15f9015ce91890f
jqnv/python_challenges_Bertelsmann_Technology_Scholarship
/vowel_consonant.py
856
4.46875
4
# Option 2: Difficulty Level: Pre-Intermediate: In this exercise # you will create a program that reads a letter of the alphabet from the user. # If the user enters a, e, i, o or u then your program should display a message # indicating that the entered letter is a vowel. If the user enters y # then your program should...
true
f52eb17ccbdecf837794acd87b21ee422bbdf6c5
ak-alam/Python_Problem_Solving
/secondLargestNumberFromList/main.py
286
4.21875
4
''' For a list, find the second largest number in the list. ''' lst = [1,3,9,3,7,4,5] largest = lst[0] sec_largest = lst[0] for i in lst: if i > largest: largest = sec_largest largest = i elif i > sec_largest: sec_largest = i print(f'Largest Number: {sec_largest}')
true
9167003e750f0216857d8dab3aa3424231a33e11
jiezheng5/PythonFundamentals
/app5-DatabaseAppUsing-TinkerSqlite/app5_backend.py
2,261
4.375
4
""" A program that stores the book information: Title, Author Year, ISBN User can: view all records search an entry add entry update entry delete close https://www.udemy.com/the-python-mega-course/learn/v4/t/lecture/4775396?start=0 """ from tkinter import * import sqlite3 import numpy as np import ...
true
30bb3921d340b257331bdc7a5bc747fbd244055d
Ediel96/platzi-python
/conversor_de_string.py
237
4.15625
4
nombre = "hamilton" print(nombre.upper()) print(nombre.capitalize()) print(nombre.strip()) print(nombre.lower()) print(nombre.replace('o','a')) print(nombre[0]) print(len(nombre)) print(nombre[0:5]) print(nombre[3:]) print(nombre[:5])
false
dde99e6ba6b6a333681bef405e8af0524f576e94
gaozejing/test2
/列表.py
844
4.125
4
#建立一个空姓名列表 NameList = [] print("Enter 5 names:") #在姓名列表内添加姓名 for i in range(5): name = input() NameList.append(name) #输出姓名列表中的姓名 print("The names are ",end="") for name in NameList: print(name+" ",end="") print() #对姓名列表进行排序操作,且不改变原来的列表 NameListCopy = NameList[:] NameListCopy.sort() print("NameList:",end="")...
false
5f7098de49958aa36f2f76363f40da4302140291
gaozejing/test2
/BankAccount(类、属性、方法、对象).py
1,540
4.21875
4
class BankAccount: #属性账户名、账户号、账户余额 def __init__(self): self.account_name = "name" self.account_num = "000000" self.account_balance = 0 def __str__(self): msg1 = "Your account name: " + self.account_name msg2 = "Your account number: " + self.account_num msg3 = ...
false
a521ef2d94a766a9dfbfcc33fa6145537855af9e
Rekapi/PyProblemSolving
/PS02.py
2,898
4.1875
4
# Continue from __future__ import print_function import sys import math import textwrap import http.client # 41. how to Sum two given numbers and return a number (functions) def summation(x, y): suma = x + y if suma in range(15, 20): return 20 else: return suma print(summation(2, 2)) #...
true
90aa9b98e719c314488a86b049ba9d220eda47fb
PrtagonistOne/Beetroot_Academy
/lesson_04/task_2.py
815
4.21875
4
def main(): number = input('Enter your phone number here: ') message = phone_validator(number) if message == 'lenght': print('Your number should consist of exactly 10 digits') elif message == 'digits': print('Your number should consist of only numerical chars') elif message == 'vali...
true
5faa6ec0949f2cc7700a12ead0f83e74265d6bb3
PrtagonistOne/Beetroot_Academy
/lesson_07/task_1.py
704
4.125
4
# Make a program that has some sentence (a string) on input and returns a dict # containing all unique words as keys and the number of occurrences as values. # For testing: # 'Hello, my name is Andrey. Andrey is from Odessa. Andrey currently studies python language at Beetroot Academy in Python for Begginers course....
true
94204564422e698810bbcad1c30c3faf3fc20833
PrtagonistOne/Beetroot_Academy
/lesson_13/task_1.py
1,157
4.21875
4
# Method overloading. # Create a base class named Animal with a method called talk and then create two subclasses: Dog and Cat, # and make their own implementation of the method talk be different. For instance, Dog’s can be to print ‘woof woof’, # while Cat’s can be to print ‘meow’. # Also, create a simple generic ...
true
7c68e814e22c38c69fdd41fc981f8bcfb9153479
Pabitra-26/Problem-Solved
/LeetCode/Flipping_an_image.py
792
4.28125
4
# Problem name: Flipping an image # Description: 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 in...
true
88433a61b1a4375a5c71b61e8aa900e11a954961
Pabitra-26/Problem-Solved
/Hackerrank/Marc'sCakewalk.py
1,290
4.28125
4
# Problem name: Marc's Cakewalk """ Description: Marc loves cupcakes, but he also likes to stay fit. Each cupcake has a calorie count, and Marc can walk a distance to expend those calories. If Marc has eaten j cupcakes so far, after eating a cupcake with c calories he must walk at least (2^j)*c miles to maintain his...
true
254dd8950176dd184ca30efe93188af449d8627b
prateekbhat91/Algorithms
/Heap.py
1,806
4.125
4
""" Building Heaps, Max.Heap, Heapsort implementation @author: Prateek Bhat """ import math """Function returns position of parent of a node""" def parent(i): return int(math.floor((i-1)/2)) """Function returns the position of left child of a node""" def left(i): return int(math.floor((i*2)+1)) """Function ...
false
fd7c6633a7d1479b223fa8ce8f9e2cf5a05d326c
Pancc123/python_learning
/base_practice/quit.py
475
4.21875
4
pizza='' message='\nplease choose a ingredients on pizza:' message+="\nplease input 'quit' to stop" while pizza != 'quit': pizza=input(message) if pizza != 'quit': print(pizza) message='How old are you ?' age='' while True: age=input(message) if int(age)<3: print('you can look the movie for free.') elif...
true
c74ff911b9ee2da78543d23f131934fcff166f4e
alehpineda/bitesofpy
/Bite_15/enumerate_data.py
1,061
4.1875
4
""" Iterate over the given names and countries lists, printing them prepending the number of the loop (starting at 1). Here is the output you need to deliver: 1. Julian Australia 2. Bob Spain 3. PyBites Global 4. Dante Argentina 5. Martin USA 6. Rodolfo Mexico Notice that the 2nd column sh...
true
e9220e9906b453816143716ec56a5f26cd294959
alehpineda/bitesofpy
/159/calculator.py
733
4.125
4
import operator CALCULATIONS = { "+": operator.add, "-": operator.sub, "*": operator.mul, "/": operator.truediv, } def simple_calculator(calculation): """Receives 'calculation' and returns the calculated result, Examples - input -> output: '2 * 3' -> 6 '2 + 6' -> 8 Suppo...
true
22ba385cb0df70b44cb22f6fea070d33db4ecb7a
alehpineda/bitesofpy
/Bite_107/list_comprehensions.py
570
4.15625
4
""" Complete the function below that receives a list of numbers and returns only the even numbers that are > 0 and even (divisible by 2). The challenge here is to use Python's elegant list comprehension feature to return this with one line of code (while writing readable code). """ def filter_positive_even_numbers...
true
1c0617c520da6181d9379cf8e7ba471b8b8a78c6
alehpineda/bitesofpy
/119/xmas.py
913
4.21875
4
def generate_xmas_tree(rows=10): """Generate a xmas tree of stars (*) for given rows (default 10). Each row has row_number*2-1 stars, simple example: for rows=3 the output would be like this (ignore docstring's indentation): * *** *****""" xmas = [] for row in range(1, rows + ...
true
cd70d79780f6305f1feaa9af76346bf3568d5ef5
alehpineda/bitesofpy
/127/ordinal.py
1,286
4.53125
5
def get_ordinal_suffix(number): """Receives a number int and returns it appended with its ordinal suffix, so 1 -> 1st, 2 -> 2nd, 4 -> 4th, 11 -> 11th, etc. Rules: https://en.wikipedia.org/wiki/Ordinal_indicator#English - st is used with numbers ending in 1 (e.g. 1st, pronounced first)...
true
07fff703625eb01413ea7445b7be39b9c0590681
alehpineda/bitesofpy
/Bite_3/wordvalue.py
2,730
4.21875
4
""" Calculate the dictionary word that would have the most value in Scrabble. There are 3 tasks to complete for this Bite: - First write a function to read in the dictionary.txt file ( = DICTIONARY constant), returning a list of words (note that the words are separated by new lines). - Second write a function t...
true
c1a03320e99ded66b6d47084423527e367ed43c8
Innanov/PYTHON
/Area_of_rectangle.py
282
4.1875
4
# By INNAN Nouhaila # Compute the area of a rectangle, given its width and height. width = 5 height = 9 # Rectangle area formula area = width * height print("A rectangle " + str(width) + " inches wide and " + str(height) + " inches high has an area of " + str(area) + " square inches.")
true
05abc4d61d16c63496659697c9417c24bf27fd75
asdcxzqwe2/bill-splitter
/main.py
2,182
4.125
4
import random class BillSplitter: def __init__(self, n_of_friends): self.n_of_friends = n_of_friends self.friends_dictionary = {} self.total_bill = None self.lucky = None def friends_name(self): print("\nEnter the name of every friend (including you), " ...
false
bf2deeb289ddb3539008fcf4312d09921fc8d477
Ratna04priya/-Python-worked-problems-
/prob_-_soln/age_finder.py
359
4.21875
4
# Gives the age from datetime import date def calculate_age(dtob): today = date.today() return today.year - dtob.year - ((today.month, today.day) < (dtob.month, dtob.day)) a= int(input("Enter the year of birth : ")) b= int(input("Enter the month of birth : ")) c= int(input("Enter the date of birth : ...
true
c88ad612ba91849583a1fa1355343acd248f74ea
m0rtal/GeekBrains
/algorythms/lesson6/task1.py
1,262
4.1875
4
""" 1. Отсортируйте по убыванию методом пузырька одномерный целочисленный массив, заданный случайными числами на промежутке [-100; 100). Выведите на экран исходный и отсортированный массивы. Примечания: a. алгоритм сортировки должен быть в виде функции, которая принимает на вход массив данных, b. постарайтесь сделать ...
false
b8cd317c831848b1d33ba51ad96ec0acc80c1272
poly451/Tutorials
/Instance vs Class Variables/dunder classes (iter, next).py
1,819
4.3125
4
# ------------------------------------------------- # clas Car # ------------------------------------------------- class Car: def __init__(self, name, tires, seats): self.name = name self.tires = tires self.seats = seats def print_car(self): s = "name: {}, ...
true
a9036924ef986718c083163b1dff30880ad8d108
orkunkarag/py-oop-tutorial
/oop-py-code/oop-python-main.py
696
4.15625
4
# Object Oriented Programming ''' def hello(): print("hello") x = 1 print(type(hello)) ''' ''' string = "hello" print(string.upper()) ''' #creating class class Dog: #special method init def __init__(self, name, age): self.name = name #Attribute of the class Dog - unique for every object self.age = age def...
true
714dcc6e135a3103588ce3bcf8a96ac16b61fe5e
ricdtaveira/poo-python-ifce-p7
/aula03/funcionario.py
1,780
4.21875
4
""" Funcionario é uma classe abstrata (Abstract Base Class). Todos os empregados tem um primeiro_nome, ultimo_nome, e um salário. Cada empregado pode calcular o seu salario. Todavia, o mecanismo para calcular o salário depende do tipo de empregado. Assim, cada subtipo deve definir, o modo como calcular o seu...
false
f7729652596f8a71a8b172e337a95a10b18435ef
alluong/code
/python/prime.py
510
4.28125
4
def is_prime(num): if num > 1: if len(check_prime_list) == 0: return True return False while 1: num = int(input("please enter a number: ")) # check_prime_list is empty if num is a prime number # otherwise, check_prime_list contains a list of divisors divisible by num ch...
true
d06da6cf62aa2ac6cc4d915a83ce74e7ac03cfc0
balbachl/CIT228-1
/Chapter10/addition.py
402
4.125
4
def addition(n,d): return n+d quit="" while quit != "q": try: n = int(input("Type an integer")) d = int(input("Type another integer")) except ValueError: print("You entered a non-integer") else: print(n, "+", d, "=", addition(n,d)) finally: print("Thank you f...
true
9c99d10cdd77bb0e433ac2e69bd0b353c469d1b3
balbachl/CIT228-1
/Chapter7/multiplesOfTen.py
235
4.28125
4
number = int(input("Please enter a number and I will tell you if it is a multiple of ten")) if number%10==0: print("The number ", number, " is a multiple of ten") else: print("The number ", number, " is not a multiple of ten")
true
4bb93fb5614fc29bc99632a3103b870995c98b4f
aavinashjha/IamLearning
/Algorithms/Sorting/mergeSort.py
2,049
4.125
4
""" - Divide array into half - Merge in sorted order - Single element is always sorted: Base Case Time Complexity: - MergeSort uses at most NlgN compares and 6NlgN array accesses to sort any array of size N - C(N) <= C(ceil(N/2)) + C(ceil(N/2)) + N for N>1 with C(1) = 0 - A(N) <= A(ceil(N/2)) + A(ceil(N/2)...
true
4ea3a2bc913ad93cb3dad696b9cc9b138ac04309
aavinashjha/IamLearning
/OOPS/Patterns/factory.py
2,921
4.8125
5
""" Problem: - Who should be responsible for creating objects when there are special considerations such as complex creation logic, a desire to separate the creation responsibilites for better cohesion? When you need a factory pattern? - When you don't know ahead of time what class object you need - Wh...
true
bbf313aac3b7fb8130c4a3f4503011d5abf59a69
Mohitgola0076/Day6-Internity
/Creating_Arrays.py
1,549
4.15625
4
''' A new ndarray object can be constructed by any of the following array creation routines or using a low-level ndarray constructor. ''' numpy.empty # It creates an uninitialized array of specified shape and dtype. It uses the following constructor − numpy.empty(shape, dtype = float, order = 'C') # Exam...
true
1adb4807f2a38114e4d317a9ad00a18c08c611a4
vhenrik/AvaliacaoAlgoritmos
/usuario_senha.py
519
4.25
4
'''2) Faça um programa que leia um nome de usuário e a sua senha e não aceite a senha igual ao nome do usuário, mostrando uma mensagem de erro e voltando a pedir as informações.''' n=(input("Informe um nome de usuário: ")) x=(input("Informe uma senha diferente do usuário: ")) b=(1) while b==1: if n==x: ...
false
f1c88e528da47efcae52ccde723a48ccfc82bed7
shivaq/NetworkPractice
/Python/udemyPython/Python_Basic/文字列/文字列.py
1,167
4.1875
4
# 改行なし # ------------------------------------------------- print("hello", end="") print("World") # ------------------------------------------------- # セパレーター指定 # ------------------------------------------------- print("cats", "Dogs", "Mice", sep=",") # ------------------------------------------------- # 文字列も List 的に扱...
false
443d05d05168aed78d5f0e5b4c04fa4ed76c0faf
shivaq/NetworkPractice
/Python/udemyPython/Python_Basic/Enumerate/enumerate基本.py
728
4.40625
4
enumerate → 列挙型は tuple のリストを返す ------------------------------------------------- list(enumerate('abcde')) ------------------------------------------------- enumerate のインデックスと要素とを出力 ------------------------------------------------- # tuple がアンパックされる for i,letter in enumerate('abcde'): print("At index {} the lett...
false
fbc8821835083eea2a2002bb3970d740e80cf48b
yavani/pycourse
/merge.py
675
4.21875
4
""" merge module """ def merge ( list1, list2) : # set everything to zero. i = j = k = 0 list3 = [ ] ''' The below method merges two lists in sorted order, returns sorted new list. Prerequisite: all argument lists should eb sorted. ''' while True: if len ( list1 ) == i ...
true
9fa852a2e8d7479a8e48fe829ccaae77c646b47c
AhmetGurdal/Guess-Game
/Guess-Game.py
1,914
4.125
4
#-*- coding: cp1254 -*- import random import time print "Name?" ad = raw_input(":") print "OK, ",ad,"! let's play a game I think a number that between 1 and 1000." while True: print "If u can ,guess" num = random.randrange(1,1000) ts = 1 while True: ta = input(":") if num > ta: print "up" ts = ts + 1...
true
591d3941a9c5218323cb600c46d81bfce0eb4666
yarnpuppy/Python-the-Hard-Way
/ex6.py
922
4.15625
4
# d is some sort of variable. % allows you define the value x = "There are %d types of people." % 10 # defines binary as a string binary binary = "binary" # defines do_not as the string "don't" do_not = "don't" # Compound variable description for s and s. %(s,s), allows for consecutive variable substitution. y = "Thos...
true
99be2dd68589f521adffd6594f42cc1b0c95b395
e-walther-rudman/ProjectEulerSolutions
/PE_problem4_Maxime_Emily.py
647
4.125
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. LargestPalindrome = 0 for FirstNumber in range(100,1000): for SecondNumber in range(FirstNumber, 1000...
true
a7e42c9f2b2ad26b47ba97061729c86bc3b14c87
MarHakopian/Intro-to-Python-HTI-3-Group-2-Marine-Hakobyan
/Homework_3/factorial.py
222
4.15625
4
def factorial_f(n): factorial_n = 1 for i in range(1, int(n) + 1): factorial_n = factorial_n * i return f"The factorial of {n} is {factorial_n}!" n = input("Enter the number: ") print(factorial_f(n))
true
2c88c2ee54597db7130e56c60b7c393d0e3f0ff0
dongrami0425/opentutorials_python_basic
/opentutorials_python2/opentutorials_python2/16_object_and_variable/3_set_get_method.py
655
4.125
4
# < Set/Get method > # 인스턴스 변수를 읽고 쓰는 방식중에서 권장되는 방법. # 메소드에 set, get을 붙이는 것은 관습적인 약속. # 메소드밖(메인코드에서)에서 인스턴스 메소드에 직접적으로 접근한다는 것을 명시하는 방법. class C(object): def __init__(self, v): self.value = v def show(self): print(self.value) def getValue(self): # 값을 받아오는 메소드. return self.v...
false
f50ee5231eaa848d646ffe5aa71ad76a13498c7c
HaykBarca/Python
/tuples.py
457
4.4375
4
# A tuple is an immutable container that stores objects in a specific order my_tuple = tuple() print(my_tuple) my_new_tuple = () print(my_new_tuple) # You should add items when you creating tuple, you can't change, add, remove items from tuple tuple_items = ("Apple", "Orange") print(tuple_items) print(tuple_items[1])...
true
f1864d27157164507fde1e72b21b10d7a681701f
ashish-netizen/AlgorithmsAndDataStructure
/Python/DataStructure/Stack/stack.py
505
4.40625
4
#here we are using demonstrating stack in python #Initally we take an empty list a then we use append function to push element in the list. #printed [1,2,3] #after that elements poped out in Last In First Out Order a = [] a.append(1) a.append(2) a.append(3) print('Initial stack') print(a) print('\nEl...
true
9f66925e4433ef7a8b6743520e276311fdfa110b
Sincab/city
/s04-anagram.py
449
4.125
4
# def main(): # entered_word_1 = input('enter first word:') # entered_word_2 = input('enter second word:') # # print('They are ', is_anagram(entered_word_1, entered_word_2)) # # # def is_anagram(entered_word_1, entered_word_2): # if sorting_things(entered_word_1) == sorting_things(entered_word_2): # ...
false
98ac1ee97fbfb2e0b931aee26ba575164ff4d002
crawler4o/Learning_Python
/Hang_Man/hangman.py
2,483
4.375
4
### Hangman ### Exercise 32 (and Solution) ### ### This exercise is Part 3 of 3 of the Hangman exercise series. The other exercises are: Part 1 and Part 2. ### ### You can start your Python journey anywhere, but to finish this exercise you will have to have finished Parts 1 and 2 or use the solutions (Part 1 an...
true
528baefe3109452a19479d82a649018bbb35aa3b
terrylovesbird/lecture-w2-d2-OOP-CSV
/classes/animals/dog.py
676
4.34375
4
class Dog: species = "Canis Lupus Familiaris" # example of a *class attribute* sound = "Woof" legs = 4 tail = 1 mammal = True def __init__(self, name, breed): self.name = name # example of an *instance attribute* self.breed = breed def __str__(self): return f"I am a...
true
4b3d9a9351988f4e9038ed24535be5473fa8b048
jasminegrewal/algos
/algorithms/bubbleSort.py
1,050
4.125
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Mon Aug 28 11:14:37 2017 @author: jasmine """ def bubbleSort(arr): for i in range(len(arr)-1): ''' i will go from 0 to second last element last element will be compared at second last position''' for j in range((len(arr)-1)-i):...
true
b2578f87fc2bd326e5f588888a11e7a98ab670c4
Luxura/Learning
/Collatz square.py
328
4.21875
4
# this will try to use the collatz squar # if number even return number // 2, sinon number * 3 +1 # projet en cours def collatz(number): if number % 2 == 0: b = number // 2 print(b) else: b = number * 3 + 1 print(b) b = (int(input("Taper un chiffre: "))) while b != 1: col...
true
28cfa27fe7bbdf71e75420460511d83264404ec9
yasoob/pybasic
/mathquestions.py
1,452
4.125
4
# Angus Gardner import sys, random print "Welcome to Math Questions.\n" operators = { '*': lambda a, b: a * b, '+': lambda a, b: a + b, '/': lambda a, b: a / b, '-': lambda a, b: a - b } def question(oper): print "You are doing:", typeQ, "\n" numQ = int(raw_input("How many questions do you want to be asked?: ")...
false
c912b89f7c1035ef84282a4fcc7f6fd2f30aa8f2
ITianerU/algorithm
/剑指offer/16_数值的整数次方/python.py
977
4.28125
4
""" #### 题目描述 给定一个 double 类型的浮点数 base 和 int 类型的整数 exponent,求 base 的 exponent 次方。 #### 解题思路 下面的讨论中 x 代表 base,n 代表 exponent。 """ import math def Power(base, exponent): # return math.pow(base, exponent) if exponent == 0: return 1 m = base n = exponent if exponent < 0: exponent = -ex...
false
c1908b0f6d34e8d9eca3b8b3d1a5df2543e3862e
ITianerU/algorithm
/剑指offer/9_矩形覆盖/python.py
927
4.3125
4
""" #### Ŀ ǿ 2\*1 СκŻȥǸľΡ n 2\*1 Сصظһ 2\*n ĴΣܹжַ #### ˼· n Ϊ 1 ʱֻһָǷ n Ϊ 2 ʱָǷ Ҫ 2\*n ĴΣȸ 2\*1 ľΣٸ 2\*(n-1) ľΣȸ 2\*2 ľΣٸ 2\*(n-2) ľΡ 2\*(n-1) 2\*(n-2) ľοԿ⡣ĵƹʽ£ f(n): 1 n=1 2 n=2 f(n-1)+f(n-2) n>1 """ def rectCover(number): if number <= 0: return number rects = [0 for i in ra...
false
d154538bbd361e62ce04c5211f2c14e13b0ae335
ITianerU/algorithm
/剑指offer/4_从尾到头打印链表/python.py
1,966
4.28125
4
""" #### 题目描述 从尾到头反过来打印出每个结点的值。 #### 解题思路 ##### 使用递归 要逆序打印链表 1->2->3(3,2,1),可以先逆序打印链表 2->3(3,2),最后再打印第一个节点 1。而链表 2->3 可以看成一个新的链表,要逆序打印该链表可以继续使用求解函数,也就是在求解函数中调用自己,这就是递归函数。 """ class listNode(): def __init__(self, x): self.value = x self.next = None def printListFromTailToHead1(listNode): nlis...
false
2134f63f8ee05108164dbcf12cb19d1aede12bd1
MrAbhaySharma/Calculator
/t.py
779
4.1875
4
choice = raw_input(" What do you want to do? \n Enter:- \n \"add\" for addition \n \"sub\" for substraction \n \"multi\" for multiplication \n \"divide\" for division \n ") def input_number(): x1 = input(" Enter two number (in this form \"2\"):- \n ") x2 = input(" ") return(x1,x2) if(choice=="add"):...
false
2e78052fa41caae51f1d583fb025bef7d21bab67
navill/algorithm_coding_interview
/chapter_3/animal_shelter.py
2,675
4.15625
4
""" 먼저 들어온 동물(개 또는 고양이)이 먼저 나가는 동물 보호소 사람들은 가장 오래된 동물부터 입양할 수 있다. class Aniaml - Dog(Animal): dogs Queue에 저장된다 - Cat(Animal): cats Queue에 저장된다. AnimalQueue: 두 개의 큐를 이용해 각각 고양이와 강아지를 저장한다. - cats - dogs """ from queue import Queue class Animal: def __init__(self, name=None): self.name = name self...
false
aed710442c5cf49a03b9c8e2d21eec260d75ef75
vvek475/Competetive_Programming
/Competitive/comp_8/Q2_LION_squad.py
687
4.28125
4
def reverse_num(inp): #this line converts number to positive if negative num=abs(inp) strn=str(num) nums=int(strn[::-1]) #these above lines converts num to string and is reversed if inp>0: print(nums) else: #if input was negative this converts to negative again after above proce...
true
7cb9e0723aee588e621ea4c66477f20a769b5b60
raonifduarte/Estruturas_Controle
/if_else_RAONI.py
664
4.1875
4
#!/usr/local/bin;python3 nota = float(input('Insira a Nota do Aluno:')) if __name__ == '__main__': if nota >= 9.1: print('A') elif nota >= 8.1: print('A-') elif nota >= 7.1: print('B') elif nota >= 6.1: print('B-') elif nota >= 5.1: pri...
false