blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
ad5cb253e28d7e27d12419911a3006b405a6c813
JunIce/python_note
/note/note_15.py
1,326
4.3125
4
#!/usr/bin/python #coding=utf-8 ''' locals and globals 当一行代码要使用变量 x 的值时,Python会到所有可用的名字空间去查找变量,按照如下顺序: 1.局部名字空间 - 特指当前函数或类的方法。如果函数定义了一个局部变量 x,Python将使用这个变量,然后停止搜索。 2.全局名字空间 - 特指当前的模块。如果模块定义了一个名为 x 的变量,函数或类,Python将使用这个变量然后停止搜索。 3.内置名字空间 - 对每个模块都是全局的。作为最后的尝试,Python将假设 x 是内置函数或变量。 from module import 和 import modul...
false
8edcbf1541b7f6ab2121dcefc102414293d58318
s724959099/py_pattern_note
/BehavioralPattern/visit.py
1,489
4.28125
4
class Wheel: def __init__(self, name): self.name = name def accept(self, visitor): # 每個visitor是同樣的,但是其中的方法是不一樣的,比如這裡是visitWheel, # 然後傳入瞭self,想想?他其實想做什麼就能做什麼 visitor.visit_wheel(self) class Engine: def accept(self, visitor): visitor.visit_engine(self) class Body: ...
false
38134c740f1dac177e5d3263895314053e7a6fcc
ism23867017/Python-Estructurado
/primo.py
227
4.125
4
#!/usr/bin/env python # -*- coding: utf-8 -*- salir = False numero = input("Introduzca un numero: ") if numero<2: print "No es primo" else: if numero/numero==0 and numero/numero=1 print "Es primo" salir = True
false
a3a462573a5d9069a7736bd4036dd1f2012e079f
Novandev/chapt2
/convert3.py
483
4.25
4
# convert3.py # A program that convert Celsius temps to Fahrenheit and prints a table # redone by donovan Adams def main(): print "This is a program that converts Celcius to Fahrenheit." print "Here are the temperatures every 10 degrees" print " ____________________" for i in [10,20,30,40,50,60,70,80,9...
true
860cdce5fdb20a8ad9ab3ab4e17e3238243ec9a5
sageserin/cssi_code
/tester-python/datatypes.py
279
4.3125
4
""" exploring data types lists are mutable dictionaries """ x = [1, 2, 3] def weird(num, default_ls=None): default_ls = default_ls or [] # default_ls.append(num) print(default_ls) weird(1) weird(2) weird(3) dict = {1: 'a', 2:'b', 3:['c', 'd', 'e']}
false
9d0a204ea2f2a8311b09b1c3cc7e278e9535364a
danieled01/python
/myapps/test_scripts/reverse.py
355
4.5625
5
#have to write a function that will return the value of a string backwards: def solution(string): return string[::-1] #string[::1] works by specifying which elements you want as [begin:end:step]. So by specifying -1 for the step you are telling Python to use -1 as a step which in turn starts #from the end. This...
true
db892f7ee026d9356d5ffce80899ffb20bc3e698
DevanKula/CP5632_Workshops
/Workshop 7/do from scratch.py
364
4.15625
4
word_string = str(input("Enter the a phrase: ")).split() counter = 0 words_dicts = {} for word in word_string: counter = word_string.count(word) words_dicts = {word:counter} print(words_dicts) #print(word_count) # print(words_lists) # # word_count = word_string.count(words) #for word in words_lists: # ...
true
d73871c1c1b53578c182cb14eb2a66c40f7b2834
DevanKula/CP5632_Workshops
/Workshop 7/Color.py
455
4.15625
4
COLORS = {"coral":"#ff7f50", "coral1":"#ff7256", "coral2":"#ee6a50", "coral3":"#cd5b45", "coral4":"#8b3e2f", "CornflowerBlue":"#6495ed", "cornsilk1":"#fff8dc", "cornsilk2":"#eee8cd", "cornsilk3":"#cdc8b1", "cornsilk4":"#8b8878"} color = input("Enter color: ").lower() while color != "": if color in COLO...
false
8e28859c7fa7cdb32794e51b3c3fc8c45ce6b544
shobhit-nigam/strivers
/day2/list/11.py
539
4.1875
4
# functions # append vs extend # part one lista = ['aa', 'hh', 'aa', 'KK', 'dd', 'rr'] listb = ['ff', '25', 'WW'] print("lista =", lista) print("len of lista =", len(lista)) lista.append(listb) print("-----") print("lista =", lista) print("len of lista =", len(lista)) print("##################") # part two lista = [...
false
b86a00994c09f0ecf9cd87ef82f50d66b69f9dc7
abhisheklomsh/MyTutorials
/#100daysOfCode/day1.py
2,781
4.34375
4
""" Two Number Sum: Write a function that takes in a non-empty array of distinct integers and an integer representing a target sum. If any two numbers in the input array sum upto the target sum, the function should return them in an array, in any order. If no two numbers sum up to the target sum,...
true
cfd5e4b286025af3112ce456e847263fa45dcf1f
bopopescu/python-1
/m3_operator/format_str.py
636
4.125
4
print('{0} is {1} years old !' .format('TOM',30)) print('{1} is {0} years old !' .format(30,'TOM')) print('{} is {} years old !' .format('TOM',30)) print('{name} is {age} years old !' .format(name='TOM',age=30)) print('{name} is {age} years old !' .format(age=30,name='TOM')) print('{} is {age} years old !' .format('TOM...
false
ee53bf76298753fd95975aefde030d4ae3baf56a
prathimaautomation/python_oop
/python_functions.py
1,422
4.59375
5
# Let's create a function # Syntax def is used to declare followed by name of the function(): # First Iteration # def greeting(): # print("Welcome on Board! enjoy your trip.") # # pass # pass keyword that allows the interpretor to skip this without errors # # # greeting() # if we didn't call the function it ...
true
b77dc0558251c9f7e86390143e4d708a48249f15
2kaiser/raspberry_pi_cnn
/mp1/pt2.py
2,403
4.15625
4
import numpy as np #Step 1: Generate a 2-dim all-zero array A, with the size of 9 x 6 (row x column). A = np.zeros((9,6)) print("A is: ") print(A) #Step 2: Create a block-I shape by replacing certain elements from 0 to 1 in array A A[0][1:5] = 1 #top of I A[1][1:5] = 1 #top of I A[2][2:4] = 1 #middle of I A[3][2:4] = ...
true
9b7535587b9e92bcd7cf5bb1577863b01b1f3792
lacoperon/CTCI_Implementations
/1_ArraysAndStrings/1.3.py
1,672
4.1875
4
''' Elliot Williams 08/02/18 Q: `URLify`: Write a method to replace all spaces in a string with '%20'. You may assume that the string has sufficient space at the end to hold the additional characters, and that you are given the "true" length of the string ''' def URLify(char_array, true_length): j = len(cha...
true
5a481d5050fe713ca17e5b63747f03488e0f6540
jknight1725/pizza_compare
/pizza.py
948
4.125
4
#!/usr/bin/env python3 from math import pi from sys import argv p1_size = int(argv[1]) p1_price = int(argv[2]) p2_size = int(argv[3]) p2_price = int(argv[4]) def pizza(size, price): stats = {} radius = size / 2 radius_squared = radius*radius area = radius_squared * pi stats['size'] = size st...
true
dafb9574bdc22831f57d013a3d7faf02276b245c
lee7py/2021-py-IDE-VE
/py code/np 샘플코드3.py
497
4.15625
4
# http://riseshia.github.io/2017/01/30/numpy-tutorial-with-code.html import numpy as np a = np.arange(12) # array([ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]) print(a) b = a.reshape(4, 3) # 변환된 행렬을 반환 print(b) a.resize((3, 4)) # 자체를 변환함 print(a) b = a.flatten() print(b) b = a.ravel() print(b) ...
false
3453b1722291df1e10df811649950da89e8abac4
SumitAnand1/hello1
/Calculator.py
2,190
4.21875
4
from math import* x=float(input('enter:')) y=float(input('enter:')) class calculator(): def __init__(self): '''calculator''' class math_operation(calculator): def sum(self): print('sum of two digits') print(x+y) def sub(self): print('subtraction of two digit') ...
false
b0c65894f67a4ee168f84e472fd3f8bf1afe0ad7
Wormandrade/Trabajo02
/eje_p1_06.py
448
4.28125
4
#Utilizando la función range() y la conversión a listas genera las siguientes listas dinámicamente: print("========================") print("\tEJERCICIO 06") print("========================") print("\nListas dinamicas\n") def listas(inicio, fin, salto): num_lista = [] for num in range(inicio, fin+1,salto): ...
false
4ea6c3c11397c35e0acadf6e69de7c2489d6ddbf
RLewis11769/holbertonschool-higher_level_programming
/0x0B-python-input_output/100-append_after.py
773
4.125
4
#!/usr/bin/python3 """ append_after - inserts text to file if line contains string @filename: file to search and append to @search_string: if in line, insert text after given line @new_string: text to insert after found text """ def append_after(filename="", search_string="", new_string=""): """ Appends new_stri...
true
182e81555a1d0d5f4d9312d73ba8dfed7bc50841
Andy931/AssignmentsForICS4U
/BinarySearchInPython.py
2,318
4.15625
4
# Created by: Andy Liu # Created on: Oct 17 2016 # Created for: ICS4U # Assignment #3b # This program searches a number exists in an random array using binary search from random import randint array_size = 250 # define the size of the array def binary_search(search_value, num): # these variables defi...
true
697b324ffae85c598109b5ac5986f2c3af5dddc3
DenisLo-master/python_basic_11.06.2020
/homeworks/less3/task3.py
839
4.5625
5
""" 3. Реализовать функцию my_func(), которая принимает три позиционных аргумента, и возвращает сумму наибольших двух аргументов. """ def my_func(num1: int, num2: int, num3: int) -> int: """ search for two of the smallest arguments out of three :param num1: any number :param num2: any number :par...
true
d621e1e36862636796eb36c99ecbdc070b4a2328
skawad/pythonpractice
/datastructures/ex_08_05.py
1,003
4.1875
4
# 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 # You will parse the From line using split() and print out the second word in the line (i.e. the entire address of the person who ...
true
cc6567dbbf51778cc3aa8ca439727d1b6b80ea07
janelstewart/myshoppinglistproject.py
/shopping_list_project.py
2,044
4.25
4
my_shopping_lists_by_list_name = {} def add_list(list_name): #check if list name exists in dictionary #if doesnt exist add list to dictionary if list_name not in my_shopping_lists_by_list_name: my_shopping_lists_by_list_name[list_name] = [] def add_item_to_list(list_name,item): #use list name to retrieve lis...
true
e4b882493feb4792ecd3b72b781edb0856b5ffb5
Suhyun-2012/Suhyun-2012.github.io
/Works/CYO.py
893
4.28125
4
answer1 = input("Should I go walk on the beach or go inside or go to the city?") if answer1 == "beach": if input("Should I go swimming or make a sandcastle?") == "sandcastle": print("Wow, my sandcastle is very tall!") #elif input(print("Should I go swimming or make a sandcastle?")) == "jiooswimming": ...
true
19c38fbcff05936e5b981613229378b6569c890f
williamdarkocode/AlgortithmsAndDataStructures
/threeway_set_disjoint.py
1,243
4.125
4
# given 3 sequences of numbers, A, B, C, determine if their intersection is empty. Namely, there does not exist an element x such that # x is in A, B, and C # Assume no individual sequence contains duplicates import numpy as np def return_smallest_to_largest(A,B,C): list_of_lists = [A,B,C] len_list = [len(A),...
true
11a37184c06031fb300cc01555acc86b5fc7620e
milesmackenzie/dataquest
/step_1/python_intro_beginner/intro_functions/movie_metadata_exercise3.py
785
4.375
4
# Write a function index_equals_str() that takes in three arguments: a list, an index and a string, and checks whether that index of the list is equal to that string. # Call the function with a different order of the inputs, using named arguments. # Call the function on wonder_woman to check whether or not it is a movi...
true
144387536b64e9518bb04d72279f8bcd28cd4e77
sivabuddi/Python_Assign
/python_deep_learning_icp1/stringreplacement.py
1,355
4.21875
4
# Replace Class in Python class Replace: def replace(self,input_string,original_word, replacement_word): output_string = "" temp_string = "" temp_counter = -1 init = 0 for char in input_string: # check if its starting with Original word for replacing ...
true
624fece2eb26804725675757255cafe640ad30a5
islamuzkg/tip-calculator-start
/main.py
1,332
4.15625
4
#If the bill was $150.00, split between 5 people, with 12% tip. #Each person should pay (150.00 / 5) * 1.12 = 33.6 #Format the result to 2 decimal places = 33.60 #Tip: There are 2 ways to round a number. You might have to do some Googling to solve this.💪 #HINT 1: https://www.google.com/search?q=how+to+round+number+to...
true
ab4dc1572c3040ffb05287f4779bb16b41b0fa65
Magical-Man/Python
/Learning Python/allcmd.py
990
4.34375
4
assert 2 + 2 == 4, "Huston, we have a probelm" #If the above was == 5, there would be an error. for n in range(2, 10): for x in range(2, n): if n % x == 0: print(n, 'equals', x, '*', n//x) break else: #loop fell through without finding a factor print(n, 'is a p...
true
5031ef63a8e97b9b55df8c872002e5a03fff41e2
Magical-Man/Python
/Learning Python/practice/listprc.py
1,269
4.25
4
##Here what we are doing is just declaring a variable, and then printing some stuff ten_things = "Apples Oranges Crows Telephone Light Sugar" print("Wait, there are not 10 things in that list. Let's fix that.") ##Here we declare a variable assigned to the ten_things var, but split ##Then we make a list called more_...
true
07e495cda7220ffa3299cb09e7ee082ba57210e2
Magical-Man/Python
/Learning Python/functions/functions.py
994
4.75
5
#Functions let you make our own mini-scripts or tiny commands. #We create functions by using th word def in python #This function is like argv scripts #So here we create a function named print_two, and we call *args on it, just #Like argv def print_two(*args): arg1, arg2 = args print("arg1: %r, arg2: %r" %(ar...
true
17d6d883df6ba8104ebfe57d97e5319e4055f058
fil0o/git-repo
/sort_arr.py
1,562
4.28125
4
def find_smallest(arr): """Функция поиска индекса наименьшего элемента в массиве""" smallest = arr[0] # Для хранения наименьшего элемента smallest_index = 0 # Для хранения индекса наименьшего элемента for i in range(1, len(arr)): if arr[i] < smallest: smallest = arr[i] ...
false
35bf75a0803313c21064ad56b83c47368965b30a
Ruiznun/WordMath
/wordMath.py
2,643
4.21875
4
test = 'ONETWOPLUSONEMINUSNEGATIVETWO' #two variables that wil be cariong all the data exp = '' result = '' print('The Text : ' + test) #loops through the expression for c in test: exp = exp + c.lower() #check for numbers and other expressions if exp == 'negative': result = result + '-' ...
false
65e0a32d9c63d627800087b4040041ed3b0f04e9
rohinikavitake/py_pretice
/RE.py
700
4.15625
4
import re text="This is pune , pune is in maharastra" print(re.search("pune",text)) print(re.findall("pune",text)) phase="What is your email,it is hello@gmail.com" split_trem="@" print(re.split('@',phase)) phrase="The rain in pune" print(re.sub("\s","g",phrase)) #represtation syntax # text_phrase='sdsd....ssss...
false
fb20e6839f882a85e11b7275a54458dc1c3046a7
kalensr/pygrader
/prog_test_dir/Debug2.py
1,407
4.15625
4
# Debug Exercise 2 # Create a change-counting game that gets the user to enter the number of # coins required to make exactly one dollar. The program should prompt # the user to enter the number of pennies, nickels, dimes, and quarters. # If the total value of the coins entered is equal to one dollar, the # progr...
true
d4af8a596aed03f073999cf901a4d130875b8807
DWaze/CreateDB
/checkdb.py
230
4.15625
4
import sqlite3 conn = sqlite3.connect("contacts.sqlite") name = input("Please enter your name : ") sql_query = "SELECT * FROM contacts WHERE name LIKE ?" for row in conn.execute(sql_query, (name,)): print(row) conn.close()
true
e9312cbdd177670bc054bb0b3e116f17e812dbbc
hcerqueira/python
/Q2.py
1,666
4.1875
4
''' Lista de exercícios n° 1 Professor: Marcos Simões Disciplina: Algoritmos Resolvida em Python e pseudo-código por: @author Carlos Henrique Questão 2: Dadas duas posições em um plano cartesiano, descritas por dois números reais X e Y, Informe se os dois pontos estão na mesma posição ou em p...
false
6b65fe8dcc636c019417b307b810b9fc1cf08ae2
yousuf1318/hypervage
/DSA_step_6/Bubble Sort.py
465
4.21875
4
def bubbleSort(arr): n=len(arr) for i in range(n): for j in range(0, n-i-1): if ar[j] > ar[j+1]: ar[j], ar[j+1] = ar[j+1], ar[j] ar = [5,4,1,2,3,5,7,2] # inp1=int(input("Enter the len of arr")) # emp_err=[] # for i in range(inp1): # ar=int(input("enter the nu...
false
9faa391b58a4bf2a25cefc344beb926bd7fea41b
tharlysdias/estudos-python
/aula_6.py
704
4.28125
4
# Loop for # Intera sobre uma lista # Pode ser qualquer lista (números ou strings) # Objeto interavel for i in [1,2,3]: print(i) else: print("Fim do loop") # Contando Strings for i in "Tharlys Dias": print(i) else: print("Fim do loop") # Função biotina do python que conta de 0 até um determinado número for i in r...
false
faf53bb2c018785736f7b59550d1e86362c2dac8
masciarra/encrypted-icmp-tunnel
/substitution_encryption.py
1,079
4.53125
5
"""Takes input as following: examples: python substitution_encryption.py encrypt input.txt output.txt""" def substitutionEncrypt(str): """Encrypts string by substituting each character with the ordinal inverse: ABCDEFGHIJKLMNOPQRSTUVWXYZ ZYXWVUTSRQPONMLKJIHGFEDCBA """ str = str.lower() n...
false
1078a1e6e0c3191e26b2f4255cb7b2a3260a1dba
ShettyDhanu/17cs060python
/pgm9.py
250
4.25
4
#is and in operator x1=5 y1=5 x2='Hello' y2='Hello' x3=[1,2,3] y3=[1,2,3] print(x1 is not y1) print(x2 is y2) print(x3 is y3) a="hello python" b={1:'c',2:'d'} print('h'in a) print('Hello'not in a) print(1 in b) print('c'in b)
false
e3a318a9cadbfc7d82b3ca5885c80c1bad4e1b36
VanessaTan/LPTHW
/EX03/ex3.py
1,178
4.375
4
#Subject introduction print "I will now count my chickens:" #Calculation of how many Hens. 30.0 divided by 6.0 + 25.0. print "Hens", 25.0 + 30.0 / 6.0 #Calculation of how many Roosters. (25.0x3.0 = 75.0) Take 75.0 ÷ 4.0 = 18 with remainder 3.0. Therefore: 100.0 - 3.0 = 97 print "Roosters", 100.0 - 25.0 * 3.0 % 4.0 #N...
true
4e72c4f48e96103d758a6c766d0b2aa76aed1822
anandkrthakur/AlgorithmsEveryProgrammerShouldKnow
/01a. BinarySearch_Iterative.py
1,206
4.15625
4
# Find out if a key x exists in the sorted list A # or not using binary search algorithm def binarySearch(A, x): # search space is A[left..right] (left, right) = (0, len(A) - 1) # till search space consists of at-least one element while left <= right: # we find the mid value in the ...
true
0dccf3b276606b24679a1fc520dc963f8f32600d
TsunamiMonsoon/InternetProgramming
/Homework3/Homework3.py
1,124
4.1875
4
import sqlite3 from os.path import join, split conn = sqlite3.connect("Courses.sq") # create a query cmd = "select * from Courses" # create a cursor crs = conn.cursor() # send a query and receive query result crs.execute(cmd) Courses = crs.fetchall() for row in Courses: print(row) cmd2 = "...
true
59924003253bf6eaf850df9876ceef651c38f84f
KuldeepJagrotiya/python
/function/isPalindrome.py
254
4.21875
4
## Q3 take the input from user and check if number is palindrome inp = (input("enter the number : ")) out = str() for i in range(len(inp)-1,-1,-1): out+=inp[i] if out==inp: print(inp,"is a palindrome") else: print(inp,"is not a palindrome")
true
46734740a355dcfab21ca9ed817eda423b106c51
mohitKhanna1411/COMP9020_19T3_UNSW
/Assignment_3/count_full_nodes.py
1,250
4.34375
4
# Python program to count full # nodes in a Binary Tree class newNode(): def __init__(self, data): self.data = data self.left = None self.right = None # Function to get the count of # full Nodes in a binary tree def getfullCount(root): if (root == None): return -1 if (ro...
true
cf326c3bd46d29e86cfa3574178dc2857a1d1a84
natanonsilver/General-Knowledge-City-Quiz-
/version 3.py
2,036
4.125
4
# In version 3 of my quiz i will doing my 10 question quiz that is a multichoice quiz. #asking user for name try: name=str(input("enter your name:")) if name == "1234": raise Exception except: input("Please try again, enter your name \n") #ask the user to enter there age. try: ...
true
7878baa20ea886491c4b11fb42d3f1064c6a11ed
krisbuote/cryptography
/substitution_cipher.py
1,945
4.1875
4
import string ''' --- CAESARIAN CIPHERZ --- ''' ''' Plaintext is shifted an int. See "substitution cipher" on wikipedia. ''' ''' Author: Kristopher Buote ''' def buildCoders(shift): assert shift >=0 and shift <=26 encoder = dict() decoder = dict() alpha_lower = string.ascii_lowercase alpha_up...
false
30222559108f77a110df35f437588ddedb1afc21
rdoherty2019/Computer_Programming
/analyze.py
944
4.15625
4
def is_odd(x): #Module will leave a remainder if it is not divisable num = x % 2 if num != 0: return True else: return False def is_prime(x): for i in range(1, x+1): if i == x or i == 1: continue num = x % i if num == 0: return False ...
false
d2af3f9c481bf5d868e446c186eb9c48efd75157
rdoherty2019/Computer_Programming
/forwards_backwards.py
1,024
4.1875
4
#setting accumulator num = 0 print("Using while loops") #Iterations while num <31: #If number is divisably by 4 and 3 if num % 4 == 0 and num % 3 == 0: #accumalte num += 3 #continue to next iterations continue #IF number is divisable by 3 print if num % 3 == 0 : ...
true
780e01cf0530b9f534adb390d52365ea99ca36aa
jc23729/day-1-3-exercise-1
/main.py
220
4.3125
4
#Write your code below this line 👇 #This code prints the number of characters in a user's name. print( len( input("What is your name? ") ) ) #Notes #If input was "Jack" #1st: print(len("Jack")) #2nd: print(4)
true
adfcda8ef7d793d0f240e811b2676dabd0217023
jeanjosephgeorge/python_exercises
/Week 1/functionExercises.py
1,973
4.21875
4
#1. HELLO FUNCTION # def name(x): # print("Hello,",x,"!") # name(input("What\'s your name?\n")) #2. Y = X+1 Write a function f(x) that returns x + 1 and plot it for x values of -3 to 3 in increments of 1. import matplotlib.pyplot as plot # import matplotlib.pyplot as plot # def f(x): # y = x+1 # ...
false
841bfb0cf506bdd439d2aa0f5b54814dfda31ebf
ani17/data-structures-algorithms
/merge-sort.py
906
4.15625
4
import math def mergeSort(A): # If no more divison possible through mergeSort return to "merge" logic # for merging subarrays back into same array by repacing values # accordingly if len(A) < 2: return # Keep Dividing Array in to Left & Right Sub Arrays mid = int(math.floor(len(A) / 2)) L = A[0 : mid] R ...
true
891262eabe5174b820a8b43673c21e222e8bad85
LeonVillanueva/Projects
/Daily Exercises/daily_17.py
473
4.15625
4
''' The ancient Egyptians used to express fractions as a sum of several terms where each numerator is one. For example, 4 / 13 can be represented as 1 / 4 + 1 / 18 + 1 / 468. Create an algorithm to turn an ordinary fraction a / b, where a < b, into an Egyptian fraction. ''' import numpy as np def e_frac (n, d...
true
efbb95ed9051e1b6127a64f7eb8c967691d26f41
Mrfranken/advancepython
/chapter02/company.py
756
4.1875
4
class Company(object): def __init__(self, employee_list): self.employee = employee_list # 魔法函数既不属于object类,也不是Company类特有的方法,作为一个独立的存在的特殊方法可以加强类的功能 # 直接影响类的使用语法,如果不添加__getitem__方法,对这个类的实力的遍历和切片都将不可用 def __getitem__(self, index): return self.employee[index] def __len__(self): ...
false
bfc8e8f9574f6cdbe394ebeabee29b2b3a12f80e
aliabbas-s/tathastu_week_of_code
/day3/3.py
246
4.1875
4
#Day-3 #Program 3 string = input("Enter a Word") length = len(string) duplicate_string = "" for i in range(0,length): if string[i] in duplicate_string: continue else: duplicate_string += string[i] print(duplicate_string)
true
d0b6cc898aca8d016713caf44b36612a9f662fa1
SteeveJose/luminarpython
/languagefundamentals/largestamong2.py
243
4.125
4
num1=float(input("enter the first number:")) num2=float(input("enter the second number:")) if (num1>num2): print(num1,"is greater than",num2) elif (num2>num1): print(num2,"greater than",num1) else: print("the two numbers are equal")
true
0aee0120683e267da353a0af63e518cefebdd7da
TheodoreAI/puzzle
/algorithm.py
2,753
4.125
4
# Mateo Estrada # CS325 # 03/01/2020 # Description: This algorithm checks to see if the input solution to the 8-puzzle (also known as the sliding puzzle) is solvable. # Step 1: I choose my favorite puzzle: the 8-puzzle (puzzle number 12 from the list). # Step 2: The following rules were taken from: file:///Users/ma...
true
fd3a67b45acba3593efdd159ba41e1aa57b3c256
SushanShakya/pypractice
/Functions/14.py
298
4.21875
4
# Write a Python program to sort a list of dictionaries using Lambda nameSort = lambda x: x['name'] sample = [ { "name" : "Sushan" }, { "name" : "Aladin" }, { "name" : "Sebastian" }, ] sorted_list = sorted(sample,key=nameSort) print(sorted_list)
true
34dd81b6d4c5480951d6be4595848f0f4da63cdc
morisasy/data-analysis-with-python
/week1/multiplication.py
580
4.21875
4
#!/usr/bin/env python3 """ Make a program that gives the following output. You should use a for loop in your solution. 4 multiplied by 0 is 0 4 multiplied by 1 is 4 4 multiplied by 2 is 8 4 multiplied by 3 is 12 4 multiplied by 4 is 16 4 multiplied by 5 is 20 4 multiplied by 6 is 24 4 multiplied by 7 is 28 4 multiplie...
true
cb6eb22fff86e8a80974c2a21bbe88c2e53af786
PetersonZou/astr-119-session-4
/operators.py
724
4.1875
4
x=9 y=3 #integers #arithmetic operators print(x+y) #addition print(x-y) #subtraction print(x*y) #multiplication print(x/y) #division print(x%y) #modulus print(x**y) #exponentiation x=9.1918123 print(x//y) #floor division #Assignment operators x=9 #sets x to equal 9 x+=3 #x=x+3 print(x) x=9 x-=3 #x=x-3 pri...
true
09164664fb940298ad2dfa5fefa78c52121ab04d
carlavieira/code-study
/algorithms/sorting_searching/sparse_search.py
1,250
4.125
4
def sparse_search(arr, string): if not arr or not string: return -1 return recursive_binary_search(arr, string, 0, len(arr)-1) def recursive_binary_search(arr, string, first, last): if first > last: return -1 mid = (first + last) // 2 #that is not midd, find the closest nonempty value if not ...
true
edd7c8fb9a385d76702d906104eb9ccde836fa1e
vishnu2981997/Programming_Ques
/PROG QUES/1.py
2,902
4.1875
4
""" ID: 437 Given an array of n numbers. sort the array in ascending order based on given conditions: ---convert the elements of array to filesize formats ---convert the file sizes to corresponding binary representations ---sort the actual array based on number of 1's present in the binary representation of th...
true
74e106cda0e7a685124ea86603fe61faf9c2fa7f
Rich43/rog
/albums/3/challenge145_easy/code.py
1,818
4.34375
4
''' Your goal is to draw a tree given the base-width of the tree (the number of characters on the bottom-most row of the triangle section). This "tree" must be drawn through ASCII art-style graphics on standard console output. It will consist of a 1x3 trunk on the bottom, and a triangle shape on the top. The tree must ...
true
c8305d2dcb7962c7f460d4e44851d4a24c495e6e
Rich43/rog
/albums/3/challenge160_easy/code.py
2,037
4.25
4
''' (Easy): Trigonometric Triangle Trouble, pt. 1 A triangle on a flat plane is described by its angles and side lengths, and you don't need to be given all of the angles and side lengths to work out the rest. In this challenge, you'll be working with right-angled triangles only. Here's a representation of how this ...
true
f2a5494dea131dd5bacd09931c98aa04a4fb6e43
Rich43/rog
/albums/3/challenge87_easy/code.py
1,235
4.15625
4
''' Write a function that calculates the intersection of two rectangles, returning either a new rectangle or some kind of null value. You're free to represent these rectangles in any way you want: tuples of numbers, class objects, new datatypes, anything goes. For this challenge, you'll probably want to represent your...
true
401ec919e87f936bd9e31a9d4e413da50bddb44e
Rich43/rog
/albums/3/challenge23_easy/code.py
524
4.125
4
''' Input: a list Output: Return the two halves as different lists. If the input list has an odd number, the middle item can go to any of the list. Your task is to write the function that splits a list in two halves. ''' lst = [1, 2, 3, 4, 5] half_lst = len(lst) // 2 first_lst = [] second_lst = [] for x in rang...
true
d758ed97ea2aea49f6e70a9253952f6ba271e398
Rich43/rog
/albums/3/challenge168_easy/code.py
2,067
4.46875
4
''' So my originally planned [Hard] has issues. So it is not ready for posting. I don't have another [Hard] so we are gonna do a nice [Easy] one for Friday for all of us to enjoy. Description: We know arrays. We index into them to get a value. What if we could apply this to a string? But the index finds a "word". Imag...
true
12f29461a004ea1e8264153d5cfb473973ee153f
Rich43/rog
/albums/4/problem18.py/code.py
418
4.15625
4
def panagram(strng): '''(str) -> bool return whether the string is a panagram ''' sett = set() strng = strng.lower() for letter in strng: if letter.isalpha(): sett.add(letter) return len(s...
true
16652e2897466142fd0b285578018c150e0a5a5e
Rich43/rog
/albums/3/challenge126_easy/code.py
2,287
4.15625
4
''' Imagine you are an engineer working on some legacy code that has some odd constraints: you're being asked to implement a new function, which basically merges and sorts one list of integers into another list of integers, where you cannot allocate any other structures apart from simple temporary variables (such as...
true
5bcf6fd1c5bb4eb598aca0a9c70d0ee65d883a7a
Rich43/rog
/albums/3/challenge171_easy/code.py
1,983
4.125
4
''' Description: Today we will be making some simple 8x8 bitmap pictures. You will be given 8 hex values that can be 0-255 in decimal value (so 1 byte). Each value represents a row. So 8 rows of 8 bits so a 8x8 bitmap picture. Input: 8 Hex values. example: 18 3C 7E 7E 18 18 18 18 Output: A 8x8 picture that represen...
true
469bcb352f966ce525cc49271d3c707085ce1e17
Rich43/rog
/albums/3/challenge10_easy/code.py
866
4.53125
5
'' The exercise today asks you to validate a telephone number, as if written on an input form. Telephone numbers can be written as ten digits, or with dashes, spaces, or dots between the three segments, or with the area code parenthesized; both the area code and any white space between segments are optional. Thus, all...
true
458fcbc5b06298bd4fc084465f91f1a86bae2e17
Rich43/rog
/albums/3/challenge149_easy/code.py
1,838
4.25
4
''' Disemvoweling means removing the vowels from text. (For this challenge, the letters a, e, i, o, and u are considered vowels, and the letter y is not.) The idea is to make text difficult but not impossible to read, for when somebody posts something so idiotic you want people who are reading it to get extra frustrate...
true
d702030522318f0d1aa5c9c134e670bf2dd23db5
Rich43/rog
/albums/3/challenge41_easy/code.py
967
4.15625
4
''' Write a program that will accept a sentence as input and then output that sentence surrounded by some type of an ASCII decoratoin banner. Sample run: Enter a sentence: So long and thanks for all the fish Output ***************************************** * * * So long and th...
true
dc507cd0c38636a157f79882827f66505af93ee2
Rich43/rog
/albums/3/challenge193_easy/code.py
1,657
4.4375
4
''' An international shipping company is trying to figure out how to manufacture various types of containers. Given a volume they want to figure out the dimensions of various shapes that would all hold the same volume. Input: A volume in cubic meters. Output: Dimensions of containers of various types that would hold ...
true
93ea951e7c2eb9c49eab5ecaefba68570832a79a
Rich43/rog
/albums/3/challenge191_easy/code.py
1,995
4.25
4
''' You've recently taken an internship at an up and coming lingustic and natural language centre. Unfortunately, as with real life, the professors have allocated you the mundane task of counting every single word in a book and finding out how many occurences of each word there are. To them, this task would take hours...
true
83e038b449f0db56788edf9ac5a8d41898141dd9
Rich43/rog
/albums/3/challenge199_easy/code.py
2,042
4.15625
4
''' You work for a bank, which has recently purchased an ingenious machine to assist in reading letters and faxes sent in by branch offices. The machine scans the paper documents, and produces a file with a number of entries which each look like this: _ _ _ _ _ _ _ | _| _||_||_ |_ ||_||_| ||_ _| |...
true
7634f458818e574f22aee33c9c64e0263bc51312
Rich43/rog
/albums/3/challenge194_easy/code.py
2,678
4.25
4
''' Most programming languages understand the concept of escaping strings. For example, if you wanted to put a double-quote " into a string that is delimited by double quotes, you can't just do this: "this string contains " a quote." That would end the string after the word contains, causing a syntax error. To remedy...
true
b22a560b7c2cdfae02f5a0e47cfc9a9714f5986f
Rich43/rog
/albums/3/challenge33_easy/code.py
885
4.125
4
''' This would be a good study tool too. I made one myself and I thought it would also be a good challenge. Write a program that prints a string from a list at random, expects input, checks for a right or wrong answer, and keeps doing it until the user types "exit". If given the right answer for the string printed, it...
true
84e5a596be210ab77c029504c094f3328162aba2
Rich43/rog
/albums/3/challenge34_easy/code.py
373
4.25
4
''' A very basic challenge: In this challenge, the input is are : 3 numbers as arguments output: the sum of the squares of the two larger numbers. Your task is to write the indicated challenge. ''' #nums = input('Input three numbers in the form 1/2/3 : ') nums = '5/8/4' nums = sorted(nums.split('/')) ans = (fl...
true
3fda92e3ae36967245d8366a30d54987ef9f3694
kaczifant/Elements-of-Programming-Interviews-in-Python-Exercises
/string_integer_interconversion.py
1,767
4.25
4
# 6.1 INTERCONVERT STRINGS AND INTEGERS # Implement an integer to string conversion function, and a string to integer conversison function. # Your code should handle negative integers. You cannot use library functions like int in Python. from test_framework import generic_test from test_framework.test_failure imp...
true
57f902e278e495aa66de4b3cc1408aaebfbda91e
cory-schneider/random-article-generator
/writer.py
2,873
4.21875
4
#!/usr/bin/python3 #Pulls from a word list, creates "paragraphs" of random length, occasionally entering a blank line. #User Inputs: # word list file path # test file, exit if bad path # print word count # file name for output # number of paragraphs # min words per paragraph (prompt user not to use...
true
dc282841394adaf3cd83d97bf55e1e7bedfbab15
saarco777/Centos-REpo
/User age - Pub.py
672
4.21875
4
# define your age name = input('Hi there, whats your name?') # user defines their name age = input('How old are you?') # user gets asked whats their age if int(age) > 20: print('Hi', name, 'Welcome in, Please have a Drink!') # if age is bigger than 20, user gets inside and HAS a drink elif int(age) < 20 and...
true
dacafce3f5455a01d105f0f3e017dc17d5f3efde
dark-glich/data-types
/Tuple.py
874
4.59375
5
# tuple : immutable - ordered tuple_1 = (1, 2, 3, 4, 2, 5, 2, ) print(f"original name : {tuple_1}") # tuple[index] is used to access a single item from the tuple. print(f"tuple[2] : {tuple_1[2]}") # tuple.index[value] is used to get the index of a value. x = tuple_1.index(3) print(f"tuple.index : {x}") # tupl...
true
cecd850e5ac271d9cf8f27faf059188ecf53f8c6
xiaojias/python
/development/script.py
1,383
4.28125
4
my_name = "Codecademy" print("Hello and welcome " + my_name + " !") # Operators message = "First Name" message += ", Sure Name" print(message) # Comment on a single line user = "Jdoe" # Comment after code # Arithmetic operators result = 10 + 20 result = 40 - 30 result = 20 * 2 result = 16 / 4 result = 25 % 2 resul...
true
b5694e5bb2c3d591d886a5f21f63f5ef0f1dcadc
gururajh/python-standard-programs
/Fibonacci.py
1,995
4.15625
4
# -*- coding: utf-8 -*- """ Created on Sat Jan 29 14:27:50 2022 @author: Gururaja Hegde V' """ """Write a program to generate Fibonnaci numbers. The Fibonnaci seqence is a sequence of numbers where the next number in the sequence is the sum of the previous two numbers in the sequence. The sequence looks like...
true
1382f8c14d706cf5c5a089821a0e0211b5d5c8f4
AmGhGitHub/SAGA_Python
/py_lesson8.py
1,164
4.40625
4
# Arithmetic operators x = 10.0 y = 3.1415 exponent = 3 print("sum:", x + y) # addition print("subtraction:", x - y) # addition print("multiplication:", x * y) # multiplication print("float division:", x / y) # float division print("floor division:", int(x) // int(y)) # floor division print("modulus:", in...
true
9ec395003a967ab68c644c01cd3a792fc27a0d67
AmGhGitHub/SAGA_Python
/py_lesson17.py
1,657
4.1875
4
class Well: """ Well class for modelling vertical well performance """ def __init__(self, radius, length): """ Initialize well attributes :param radius (float): radius of the well in ft :param length (float): productive length of the well ...
true
118ac7580a7f7c7335e6428eb055a3ed05e3bbf8
habahut/CS112-Spring2012
/classcode/day12--objects/bobExample.py
847
4.15625
4
#! usr/env/bin python class Student(object): #classes should have a capital letter def __init__(self, name="Jane Doe"): self.name = name def say(self, message): print self.name + " : " + message def sayTo(self, other, message): self.say(message +"," +other.name) ...
false
6e21a23abb976fbfd248c0e107ad86250bed9c12
raberin/Sorting
/src/recursive_sorting/recursive_sorting.py
2,749
4.25
4
# TO-DO: complete the helpe function below to merge 2 sorted arrays def merge(arrA, arrB): merged_arr = [] arrA_index = 0 arrB_index = 0 # Until the merged_arr is as big as both arrays combined while len(merged_arr) < len(arrA) + len(arrB): print( f"arrA_index = {arrA_index}, arr...
true
26c5201471d8948cfe707093710a05820f85e72b
CatLava/oop_practice
/car.py
697
4.28125
4
class Car: def __init__(self, color, mileage): self.color = color self.mileage = mileage # This is a built in function for only car # Put a repr on any defined class, this helps to understand it def __repr__(self): return 'Car({self.mileage})'.format(self=self) # Python buil...
true
de853c093fd83515f4a98a5f4c453272a6b5579c
sethifur/cs3030-seth_johns_hw5
/seth_johns_hw5.py
918
4.25
4
#!/usr/bin/env python3 import sys def GetInput(): """ Function: asks for a pin input <9876> validates the size, type, and number. returns pin if correct if incorrect 3 times exits program """ for index in range(3): try: pin = int(input('Enter your p...
true
cdcdb23d6ac63da1b095a1ee68be9b97e4643c20
niko-vulic/sampleAPI
/leetcodeTester/q35.py
1,744
4.1875
4
# 35. Search Insert Position # Given a sorted array of distinct integers 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. # You must write an algorithm with O(log n) runtime complexity. from typing import List class Solution: def ...
true
7fff33692bf4f4aad318681b76b177bb021f6637
niko-vulic/sampleAPI
/leetcodeTester/q121.py
1,311
4.125
4
# 121. Best Time to Buy and Sell Stock # You are given an array prices where prices[i] is the price of a given stock on the ith day. # You want to maximize your profit by choosing a single day to buy one stock and choosing a different day in the future to sell that stock. # Return the maximum profit you can achieve f...
true
1aca8af29f7519569145abfe34d3cd2efa535327
enderceylan/Projects
/Solutions/FibonacciSequence.py
390
4.3125
4
# Fibonacci Sequence - Enter a number and have the program generate the Fibonacci # sequence to that number or to the Nth number. # Solution by Ender Ceylan x = 1 y = 1 num = int(input("Enter the amount of Fibonacci values to be viewed: ")) while num <= 0: num = int(input("Input must be above 0: ")) for i in range...
true
8e328d70a1be51172286f69bb0d9189c6d36a080
adityasunny1189/100DaysOfPython
/day1.py
460
4.1875
4
print("Hello World") print("Hello" + " " + "Aditya") print("Hello" + " " + input("Enter your name: ")) print(len(input("Name: "))) name = input("Enter username: ") length = len(name) print(name) print(length) #Project Day 1 print("Welcome to band name generator") city_name = input("Enter the name of city you gre...
false
08eb776f982387f55fe513b09a624472c158dc5f
dhrvdwvd/practice
/python_programs/34_pr_04.py
206
4.1875
4
names = ["dhruv", "ratnesh", "abhinav", "jaskaran"] name = input("Enter a name to search: ") if name in names: print(name+" is present in the list.") else: print("Name entered is not in the list.")
true
3ff3ba9cd497c199e24a8683e59595802bedc4f2
dhrvdwvd/practice
/python_programs/06_operators.py
238
4.3125
4
a = 3 b = 4 # Arithmetic Operators print("a + b = ", a+b) print("a - b = ", a-b) print("a * b = ", a*b) print("a / b = ", a/b) # Python gives float when two ints are divided. # Assignment operators. a = 12 a+=22 a-=12 a*=2 a/=4 print(a)
true
06ead9d50bb8b9eaad3a0c1bf43434331bcda7cb
dhrvdwvd/practice
/python_programs/66_try.py
425
4.21875
4
while(True): print("Press q to quit") a = input("Enter a number: ") if(a == 'q'): break try: a = int(a) if(a>6): print("Entered number is greater than 6.") except Exception as e: print(e) # This breaks the loop as well. print("Thanks for playing the game.") # The try-exc...
true
bdec843924ca0e0e4e45ccd6bd315245098bf6ec
dhrvdwvd/practice
/python_programs/12_strings_slicing.py
331
4.15625
4
greeting = "Hello, " name = "DhruvisGood" #print(greeting + name) #print(name[0]) #name[3] = 'd' --> does not work # String can be accessed but not changed. print(name[0:3]) # is same as below print(name[:3]) print(name[1:]) # will print from index 1 to last index print(name[1:8:2]) # will start printing index 1, 1+...
true