blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
3a138f569de9b1e4d5e2227e1ee290489eb5883c
emir-naiz/first_git_lesson
/Courses/1 month/4 week/day 1/Задача №5 setify number.py
353
4.125
4
def setify(number_list): number_list.sort() empty_list = [] for number in empty_list: if number not in empty_list: empty_list.append(number) return empty_list print(setify(1,2,3,3,4,4,6,6,5,5)) print(set(([1,2,3,3,4,4,6,6,5,5]))) # при помощи set можно удалить дублирующие цифры
false
2355ee5a02dcbc66d33649b618d1c57e356e9ada
jamj2000/Programming-Classes
/Math You Will Actually Use/Week6_Sympy.py
725
4.3125
4
' "pip install sympy" before you do any of this ' import sympy # import the calculator with variable buttons :) from sympy import Symbol # -------------------------- first, solve the simple equation 2*x=2 x = Symbol('x') # create a "symoblic variable" x equation = 2*x - 2 # define the equation 2*x = 2 solution =...
true
0b6dae16fec055ad0eccb3d651b02f5643540e81
jamj2000/Programming-Classes
/Intro To Python/semester1/Week10_Challenge0.py
1,798
4.34375
4
''' This is a deep dive into FUNCTIONS What is a function? A function is a bunch of commands bundled into a group How do you write a function? Look below! CHALLENGES: (in order of HEAT = difficulty) Siberian Winter: Change the link of the Philly function Canada in Spring: Make the link an inp...
true
d3f6517aeea44395a9796ee175fc8ef0dcaacaa1
csmdoficial/aulas-python
/curso/venv/bin/exercicios/desafio 033.py
537
4.15625
4
"""faça um programa qu leia três números e mostre qual é o menor e o maior """ a = float(input("Digite um numero:")) b = float(input("Digite outro numero:")) c = float(input('Digite o ultimo numero:')) #verificando quem é o menor menor = a if b < a and b < c: menor = b if c < a and c < b: menor = c #verificando...
false
e543c991e7ad17b2a657274bb1a5483636fc0d4f
csmdoficial/aulas-python
/curso/venv/bin/exercicios/desafio 025.py
265
4.15625
4
"""crie um programa que leia o nome de uma pessoa e diga se ela tem 'silva' no nome""" nome = str(input('Digite um nome:')).upper().strip() print('SILVA'in nome) n = str(input('Digite um nume:')).upper().strip() print('Seu nome tem Silva? {}'.format('SILVA' in n))
false
6fb1b7fff352717f4654ee2f38548c0fff13cfb7
iulyaav/coursework
/stanford-algo-courses/matrix_multiplication.py
1,177
4.25
4
def matrix_add(X, Y): pass def matrix_multiply(X, Y): """ Let X = | A B | and Y = | E F | | C D | | G H | We have the products: P1 = A(F-H) P2 = (A+B)H P3 = (C+D)E P4 = D(G-E) P5 = (A+D)(E+H) P6 = (B-D)(G+H) P7 = (A-C)(E+F) Claim: X * Y = | (P5 ...
false
ad291e7fa25471945efc95465a4589cd89a44e7a
mihir-liverpool/RockPaperScissor
/rockpaperscissor.py
841
4.125
4
import random while True: moves = ['rock', 'paper', 'scissor'] player_wins = ['paperrock', 'scissorpaper', 'rockscissor'] player_move = input('please choose between rock paper or scissor: ') computer_move = random.choice(moves) if player_move not in moves: print('please choose an option betw...
true
1dbd6a073c1fbdae4bdc435d7a678e49e8709ab3
sombra721/Python-Exercises
/Regular Expression_ex.py
1,503
4.125
4
''' The script will detect if the regular expression pattern is contained in the files in the directory and it's sub-directory. Suppose the directory structure is shown as below: test |---sub1 | |---1.txt (contains) | |---2.txt (does not contain) | |---3.txt (contains) |---sub2 | |...
true
8ae7109db20182e8e0367a39c03fa9e4dd04dba5
ryanthemanr0x/Python
/Giraffe/Lists.py
561
4.25
4
# Working with lists # Lists can include integers and boolean # friends = ["Kevin", 2, False] friends = ["Kevin", "Karen", "Jim"] print(friends) # Using index friends = ["Kevin", "Karen", "Jim"] # 0 1/-2 2/-1 print(friends[0]) print(friends[2]) print(friends[-1]) print(friends[-2]) print(fri...
true
6b82f94e0a3149bcb55199f4d3d3d860732aa475
ryanthemanr0x/Python
/Giraffe/if_statements.py
631
4.40625
4
# If Statements is_male = False is_tall = False if is_male or is_tall: print("You are a male or tall or both") else: print("You are neither male nor tall") is_male1 = True is_tall1 = True if is_male1 and is_tall1: print("You are a tall male") else: print("You are either not male or tall or both") i...
true
a97dadaf6560e38dafc3078ce3bbc4a849c66431
kiyotd/study-py
/src/6_asterisk/ex1.py
606
4.1875
4
list_ = [0, 1, 2, 3, 4] tuple_ = (0, 1, 2, 3, 4) print(list_) # [0, 1, 2, 3, 4] print(tuple_) # (0, 1, 2, 3, 4) # * # unpack 展開する print(*list_) # 0 1 2 3 4 print(*tuple_) # 0 1 2 3 4 # ** # 辞書などをキーワード引数として渡すことができる my_dict = {"sep": " / "} print(1, 2, 3, **my_dict) # 1 / 2 / 3 print(1, 2, 3, sep=" / ") # と同じ ...
false
2d259320a70264f55f837a84741a5a1b2abe6fd5
xhweek/learnpy
/.idea/ly-01.py
525
4.21875
4
#循环打印 #print('* ' * 5) """ for i in range(0,4): for j in range(0,5): print("* ",end=" ") print() """ for i in range(4): for j in range(5): #print(i,"-===========",j) if i == 0 or i == 3 or j == 0 or j == 4: print("* ",end = " ") else: print(" ",end...
false
9e0a944f2100cab01f4e4cad3921c8786998681b
ikramsalim/DataCamp
/02-intermediate-python/4-loops/loop-over-lists-of-lists.py
446
4.25
4
"""Write a for loop that goes through each sublist of house and prints out the x is y sqm, where x is the name of the room and y is the area of the room.""" # house list of lists house = [["hallway", 11.25], ["kitchen", 18.0], ["living room", 20.0], ["bedroom", 10.75], ["bathroom", ...
true
dcf1b439aa3db2947653f9197e961d4969f92095
ycayir/python-for-everybody
/course2/week5/ex_09_05.py
782
4.25
4
# Exercise 5: This program records the domain name (instead of the # address) where the message was sent from instead of who the mail came # from (i.e., the whole email address). At the end of the program, print # out the contents of your dictionary. # python schoolcount.py # # Enter a file name: mbox-short.txt # {'med...
true
16d0cc5afda917ebc335553cc6d338014b19f87b
aflyk/hello
/pystart/lesson1/l1t2.py
467
4.4375
4
""" Пользователь вводит время в секундах. Переведите время в часы, минуты и секунды и выведите в формате чч:мм:сс. Используйте форматирование строк. """ user_time = int(input("Введите кол-во секунд: ")) user_time = user_time % (60*60*24) print(f"{user_time // 3600}:{(user_time % 3600) // 60}:{(user_time % 3600)...
false
254210227b8c1c1ce4ddca88fb6a889a1c0e7c47
aflyk/hello
/pystart/lesson6/l6t2.py
1,224
4.3125
4
""" Реализовать класс Road (дорога), в котором определить атрибуты: length (длина), width (ширина). Значения данных атрибутов должны передаваться при создании экземпляра класса. Атрибуты сделать защищенными. Определить метод расчета массы асфальта, необходимого для покрытия всего дорожного полотна. Использовать фор...
false
c3c1bf04376f728f6470a055e56c878ceec2d3b3
mjdall/leet
/spiral_matrix.py
2,106
4.1875
4
def spiral_order(self, matrix): """ Returns the spiral order of the input matrix. I.e. [ [1, 2, 3], [4, 5, 6], [7, 8, 9] ] becomes [1, 2, 3, 6, 9, 8, 7, 4, 5]. :type matrix: List[List[int]] :rtype: List[int] """ if not matrix or matrix is None: return ...
true
3dd6609f9805f7c8bbf9949b56584a2c044475a3
mjdall/leet
/count_elements.py
668
4.28125
4
def count_elements(arr): """ Given an integer array arr, count element x such that x + 1 is also in arr. If there're duplicates in arr, count them seperately. :type arr: List[int] :rtype: int """ if arr is None or len(arr) == 0: return 0 ...
true
334da6ffae18a403cc33ae03c1600238a6a45ddd
denemorhun/Python-Problems
/Hackerrank/Strings/MatchParanthesis-easy.py
1,891
4.40625
4
# Python3 code to Check for balanced parentheses in an expression # EASY ''' Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid. An input string is valid if: Open brackets must be closed by the same type of brackets. Open brackets must be closed in...
true
bb708c316a2f7041f23c61036ff825153ad424a2
denemorhun/Python-Problems
/Grokking the Python Interview/Data Structures/Stacks and Queues/q_using_stack.py
1,149
4.21875
4
from typing import Deque from stack import MyStack # Push Function => stack.push(int) //Inserts the element at top # Pop Function => stack.pop() //Removes and returns the element at top # Top/Peek Function => stack.get_top() //Returns top element # Helper Functions => stack.is_empty() & stack.isFull() //returns...
true
a34383ee463d3c9749caf0e52c10e3e114fe02a7
denemorhun/Python-Problems
/AlgoExperts/LinkedList/remove_duplicates_from_linked_list.py
1,693
4.15625
4
''' A Node object has an integer data field, , and a Node instance pointer, , pointing to another node (i.e.: the next node in a list). A removeDuplicates function is declared in your editor, which takes a pointer to the node of a linked list as a parameter. Complete removeDuplicates so that it deletes any duplic...
true
07bab891b92ca248e39056da104d2a9afdff953c
denemorhun/Python-Problems
/Hackerrank/Arrays/validate_pattern.py
1,708
4.34375
4
'''Validate Pattern from array 1 to array b Given a string sequence of words and a string sequence pattern, return true if the sequence of words matches the pattern otherwise false. Definition of match: A word that is substituted for a variable must always follow that substitution. For example, if "f" is substituted ...
true
7ff5903c490ef8c34099db9252ec42918f2e850b
tcano2003/ucsc-python-for-programmers
/code/lab_03_Functions/lab03_5(3)_TC.py
1,028
4.46875
4
#!/usr/bin/env python3 """This is a function that returns heads or tails like the flip of a coin""" import random def FlipCoin(): if random.randrange(0, 2) == 0: return ("tails") return ("heads") def GetHeads(target): """Flips coins until it gets target heads in a row.""" heads = count = ...
true
3b1315a4ffacc91f29a75daa3993a1cb2aab4133
tcano2003/ucsc-python-for-programmers
/code/lab_03_Functions/lab03_6(3).py
2,442
4.46875
4
#!/usr/bin/env python3 """Introspect the random module, and particularly the randrange() function it provides. Use this module to write a "Flashcard" function. Your function should ask the user: What is 9 times 3 where 9 and 3 are any numbers from 0 to 12, randomly chosen. If the user gets the answer right, your f...
true
008fa26d54dc77f783b3b60f5e2f85c83535a3fd
tcano2003/ucsc-python-for-programmers
/code/lab_14_Magic/circle_defpy3.py
1,823
4.1875
4
#!/usr/bin/env python3 """A Circle class, acheived by overriding __getitem__ which provides the behavior for indexing, i.e., []. This also provides the correct cyclical behavior whenever an iterator is used, i.e., for, enumerate() and sorted(). reversed() needs __reversed__ defined. """ #need to have def __getitem__(<...
true
32ecb9b4cfe42fc63007e72ac3c8778fa8121ad5
huang-zp/pyoffer
/my_queue.py
646
4.125
4
class MyQueue: def __init__(self): """ Initialize your data structure here. """ self.stack_in = [] self.stack_out = [] def push(self, x: int) -> None: """ Push element x to the back of queue. """ self.stack_in.append(x) def pop(self)...
true
aee36a7523ad8fc3de06ef7b047aff60fa3ab0d6
ADmcbryde/Collatz
/Python/recursive/coll.py
2,842
4.25
4
# CSC330 # Assignment 3 - Collatz Conjecture # # Author: Devin McBryde # # # def collatzStep(a): counter = 0 if (a == 1): return counter elif ( (a%2) == 1) : counter = collatzStep(a*3+1) else: counter = collatzStep(a/2) counter = counter + 1 return counter #The program is programmed as a function sinc...
true
0d075a750c9745eb97a2577db4b7c7cf2407d903
ergarrity/coding-challenges
/missing-number/missing.py
1,009
4.21875
4
"""Given a list of numbers 1...max_num, find which one is missing in a list.""" def missing_number(nums, max_num): """Given a list of numbers 1...max_num, find which one is missing. *nums*: list of numbers 1..[max_num]; exactly one digit will be missing. *max_num*: Largest potential number in list >...
true
8717208247c2d4f9eb24522c1b54ec33ce41789c
kwozz48/Test_Projects
/is_num_prime.py
613
4.1875
4
#Asks the user for a number and determines if the number is prime or not number_list = [] def get_integer(number = 'Please enter a number: '): return int(input(number)) def is_number_prime(): user_num = get_integer() number_list = list(range(2, user_num)) print (number_list) i = 0 a = 0 ...
true
7b84faec3e2daad6d731610e6d4967f1e3859537
yucheno8/newPython6.0
/Day01/p_07输出和格式字符串一起使用.py
479
4.125
4
''' 格式 化字符串并输出 ''' # 占位符形式的字符串 # 1 a = 10 print('现在要打印一个数字,值是 %d' % a) # 2 print('name: %s age: %d' % ('Tom', 12)) # 占位符的常用 格式 print('%d' % 1) print('%5d' % 1) print('%05d' % 1) print('%-5d' % 1) print('%3d' % 12345) print('%.2f' % 3.1415926) print('%.3f' % 1) # f-string name = 'Tom' age = 11 print(f'name: {name...
false
3c47b56deda38352aa8cd571d65a29c76d40827e
BRTytan/Unipexercicios
/IPE/Listas/ex04-04.py
330
4.15625
4
""" Exercicio 04-04:Escreva um programa que mostre os números de 1 até um numero digitado pelo usuário, mas, apenas os números impares. """ ################################################################################################### n1 = int(input("Digite um número: ")) x = 1 while x <= n1: print(x) x ...
false
f04b4b2d639091ef6d2a21bf0a40604936664cc4
BRTytan/Unipexercicios
/IPE/inicias/ex01-02.py
382
4.34375
4
"""Exercicio 02: Resolva as expressões matematicas manualmente no caderno, apos, converta as seguintes expressões matematicas para que possam ser calculadas usando o interpretador python(confirmando o resultado encontrado)""" a = (10+20)*30 b = (4 ** 2) / 30 c = (9**4+2) * (6-1) print('Resultado de A é: {} \nResultad...
false
0eb55829a0aee6d7136f91550e89b9bb738f4e73
Scertskrt/Ch.08_Lists_Strings
/8.1_Months.py
722
4.40625
4
''' MONTHS PROGRAM -------------- Write a user-input statement where a user enters a month number 1-13. Using the starting string below in your program, print the three month abbreviation for the month number that the user enters. Keep repeating this until the user enters 13 to quit. Once the user quits, print "Goodby...
true
539fadb2fc145e48a70950cd77d804d77c9cec07
roachaar/Python-Projects
/national debt length.py
1,937
4.5
4
############################################################################## # Computer Project #1: National Debt # # Algorithm # prompt for national debt and denomination of currency # user inputs the above # program does simple arithmetic to calculate two pieces of informati...
true
3597d031334cadd8da79740431f5941c2adb38c5
BeryJAY/Day4_challenge
/power/power.py
531
4.34375
4
def power(a,b): #checking data type if not((isinstance(a,int) or isinstance(a,float)) and isinstance(b,int)): return "invalid input" #The condition is such that if b is equal to 1, b is returned if(b==1): return(a) #If b is not equal to 1, a is multiplied with the power function and call...
true
511d35743234e26a4a93653af24ee132b3a62a7a
AntoanStefanov/Code-With-Mosh
/Classes/1- Classes.py
1,465
4.6875
5
# Defining a list of numbers numbers = [1, 2] # we learned that when we use the dot notation, we get access to all methods in list objects. # Every list object in Python has these methods. # numbers. # Wouldn't that be nice if we could create an object like shopping_cart and this object would have methods # like this:...
true
a8f7dceb7daec1a665e215d9d99eeb620e73f398
AntoanStefanov/Code-With-Mosh
/Exceptions/7- Cost of Raising Exceptions.py
1,849
4.5
4
# As I explained in the last lecture, when writing your own functions, # prefer not to raise exceptions, because those exceptions come with a price. # That's gonna show you in this lecture. # From the timeit module import function called timeit # with this function we can calculate the execution time of some code. # ...
true
1f7f8382c688f22fe10e8057185ce55307c90b1d
AntoanStefanov/Code-With-Mosh
/Exceptions/4- Cleaning Up.py
706
4.375
4
# There are times that we need to work with external resources like files, # network connections, databases and so on. Whenever we use these resources, # after, after we're done we need to release them. # For example: when you open a file, we should always close it after we're done, # otherwise another process or anoth...
true
91dc1d2f54c0cf7ad75ff9f9449b5c46051c4b4c
pedrolisboaa/pythonpro-pythonbirds
/exercicios/busca_linear.py
616
4.125
4
""" Crie um programa que recebe uma lista de inteiros e um valor que deve ser buscado. O programa deve retornar o índice onde o valor foi encontrado, ou -1, caso não encontre o valor. """ tamanho_lista = int(input('Digite o tamanho da sua lista:')) lista = [] for i in range(tamanho_lista): inserir_lista = int(in...
false
a12230a5edc331e0989940c8ecd1243b9415aba9
daria-andrioaie/Fundamentals-Of-Programming
/a12-911-Andrioaie-Daria/main.py
2,983
4.46875
4
from random import randint from recursive import recursive_backtracking from iterative import iterative_backtracking def print_iterative_solutions(list_of_numbers): """ The function calls the function that solves the problem iteratively and then prints all the found solutions. :param list_of_num...
true
41891f9a090ead7873bf5c006f423238a48f05db
daria-andrioaie/Fundamentals-Of-Programming
/a12-911-Andrioaie-Daria/iterative.py
2,158
4.5
4
from solution import is_solution, to_string def find_successor(partial_solution): """ The function finds the successor of the last element in the list. By "successor" of an element we mean the next element in the list [0, +, -]. :param partial_solution: array containing the current partial so...
true
a43a94fda2b1a6ff937b0ab5df42f12fff90bde1
sal-7/OMIS485
/Python_chapter 4/A_temperature.py
1,206
4.125
4
""" /*************************************************************** OMIS 485 P120 - Ch4 Spring 2019 Programmer: Faisal Alharbi, Z-ID 1748509 Date Due:04/07/2018 Tutorials from Chapter 4 - Temperature Exercise. ***************************************************************/""" #!/usr/bin/env p...
false
48f7e3ee1d356eda254447e928321e6d7a8402c8
samsolariusleo/cpy5python
/practical02/q07_miles_to_kilometres.py
661
4.3125
4
# Filename: q07_miles_to_kilometres.py # Author: Gan Jing Ying # Created: 20130207 # Modified: 20130207 # Description: Program that converts miles to kilometres and kilometres to miles # before printing the results # main # print headers print("{0:6s}".format("Miles") + "{0:11s}".format("Kilometres") + "{0:11s...
true
2e1e1897d6e0c4f92ee6815c9e1bb607dee10024
samsolariusleo/cpy5python
/practical02/q12_find_factors.py
562
4.4375
4
# Filename: q12_find_factors.py # Author: Gan Jing Ying # Created: 20130207 # Modified: 20130207 # Description: Program that displays the smallest factors of an integer. # main # prompt for integer integer = int(input("Enter integer: ")) # define smallest factor factor = 2 # define a list list_of_factors = [] # fi...
true
750d0ff689da9aa8aea56e2e9b248df47ed51057
samsolariusleo/cpy5python
/practical02/q05_find_month_days.py
956
4.625
5
# Filename: q05_find_month_days.py # Author: Gan Jing Ying # Created: 20130207 # Modified: 20130207 # Description: Program that displays number of days in the month of a particular # year. # main # prompt for month month = int(input("Enter month: ")) # prompt for year year = int(input("Enter year: ")) # define list...
true
cce715b6938e2f5c16d6ee158ebfa7e15b4e0645
samsolariusleo/cpy5python
/practical02/q11_find_gcd.py
725
4.28125
4
# Filename: q11_find_gcd.py # Author: Gan Jing Ying # Created: 20130207 # Modified: 20130207 # Description: Program to find the greatest common divisor of two integers. # main # prompt user for the two integers integer_one = int(input("Enter first integer: ")) integer_two = int(input("Enter second integer: ")) # fin...
true
8254638df080d0a3b76a0dddd42cf41e393dfed7
samsolariusleo/cpy5python
/practical01/q1_fahrenheit_to_celsius.py
453
4.28125
4
# Filename: q1_fahrenheit_to_celsius.py # Author: Gan Jing Ying # Created: 20130122 # Modified: 20130122 # Description: Program to convert a temperature reading from Fahrenheit to Celsius. #main # prompt to get temperature temperature = float(input("Enter temperature (Fahrenheit): ")) # calculate temperat...
true
8e1570c6e03ec4817ab65fdba077df7bad1e97da
justintrudell/hootbot
/hootbot/helpers/request_helpers.py
490
4.46875
4
import itertools def grouper(iterable, n): """ Splits an iterable into groups of 'n'. :param iterable: The iterable to be split. :param n: The amount of items desired in each group. :return: Yields the input list as a new list, itself containing lists of 'n' items. """ """Splits a list int...
true
dfb6d90f75f7c2fbe370185856549fdf6c089927
gbaweja/consultadd_assignments
/assignment1/A1-6.py
654
4.1875
4
# Govinda Baweja # Assignment 1 # Date: 04-26-2019 # Nested if else statement i = 10 if (i == 10): # First if statement print ("\ni is 10") if (i < 15): print ("\ni is smaller than 15") # Nested - if statement # Will only be executed if statement above # it is true ...
false
4182316191f1b325cb7640dd77c1acc023045c82
ZhbitEric/PythonLearning
/Python_work/_20ds_reference.py
310
4.1875
4
# 引用 shopList = ['apple', 'mango', 'carrot', 'banana'] myList = shopList del shopList[0] print(shopList) print(myList) # 这样的引用就没有指向同一个对象了 myList = shopList[:] # 切片操作,相当于循环复制拿元素出来 print(myList) del myList[0] print(shopList) print(myList)
false
73d37bf82e89c293e0e0fd86e99d74ec79b3b275
SRAH95/Rodrigo
/input_statement.py
1,748
4.15625
4
"""message = input("Tell me something, and I will repeat it back to you: ") print(message)""" ######################################################################################## '''name = input("Please enter your name: ") print("Hi, " + name.title() + "!")''' ####################################################...
true
ba982e9794b3cbaaa034584cbb1f2017068f5ce5
Pranalihalageri/Python_Eduyear
/day5.py
516
4.125
4
1. list1 = [5, 20, 4, 45, 66, 93, 1] even_count, odd_count = 0, 0 # iterating each number in list for num in list1: # checking condition if num % 2 == 0: even_count += 1 else: odd_count += 1 print("Even numbers in the list: ", even_count) print("Odd numbers in the lis...
true
258d4ea28ffe6b9a85b2ecd34a34214ccb3a0682
FredericoVieira/listas-python-para-zumbis
/Lista 02/lista2ex5.py
433
4.15625
4
# -*- coding: utf-8 -*- num1 = int(raw_input('Digite o valor do primeiro inteiro: ')) num2 = int(raw_input('Digite o valor do segundo inteiro: ')) num3 = int(raw_input('Digite o valor do terceiro inteiro: ')) list = [num1, num2, num3] num_max = max(list) num_min = min(list) print('O maior número entre %d, %d, %d é %...
false
b0398f9d1751611c505aa530849336dbb7f3ef00
Ran05/basic-python-course
/ferariza_randolfh_day4_act2.py
1,153
4.15625
4
''' 1 Write a word bank program 2 The program will ask to enter a word 3 The program will store the word in a list 4 The program will ask if the user wants to try again. The user will input Y/y if yes and N/n if no 5 If yes, refer to step 2. 6 If no, Display the total number of words and all the words that user enter...
true
92151c4a1ceca1910bd60785b2d5d030559cd241
niteshrawat1995/MyCodeBase
/python/concepts/classmethods.py
1,481
4.125
4
# Class methods are methods wich take class as an argument (by using decorators). # They can be used as alternate constructors. class Employee: num_of_emps = 0 raise_amount = 1.04 def __init__(self, first, last, pay): self.first = first self.last = last self.pay = pay sel...
true
5f109dfef4214b33302401e473d9b115a65bffa5
niteshrawat1995/MyCodeBase
/python/concepts/getters&setters&deleters.py
1,284
4.15625
4
# getters,setters and deleters can be implemented in python using property decorators. # property decorators allows us to define a mehtod which we can access as an attribute. # @property is the pythonic way of creating getter and setter. class Employee(object): def __init__(self, first, last, pay): self....
true
95484e7fe8d71eaa0fbcd723b67eddeafd17f535
niteshrawat1995/MyCodeBase
/python/practise/DS/Doubly_LinkedList.py
937
4.34375
4
# Implementing doubly linked list: class Node(object): """Node will have data ,prev and next""" def __init__(self, data): self.data = data self.prev = None self.next = None class LinkedList(object): """Linked list will have head attribute.""" def __init__(self): self....
false
e78334b2ae75714172fad80bf81e8c76497f7cb5
scantea/hash-practice
/hash_practice/exercises.py
2,554
4.3125
4
def grouped_anagrams(strings): """ This method will return an array of arrays. Each subarray will have strings which are anagrams of each other Time Complexity: O(n) Space Complexity: O(1) """ freq_hash = {} for word in strings: key = ''.join(sorted(word)) ...
true
5b119b5d6ee2dfeb455b174a2b2332de7cd7a6a7
sivaram143/python_practice
/conditions/ex_01.py
202
4.3125
4
#!/usr/bin/python # program to check whether a given no is even or ood num = input("Enter any number:") if num % 2 == 0: print("{0} is even".format(num)) else: print("{0} is odd".format(num))
true
de43dc0d3c246bfdd7a124e2942be5ebc717cb9d
sivaram143/python_practice
/operators/arithmetic.py
706
4.375
4
#!/usr/bin/python # Arithmetic Operators: +, -, *, /, %, **(exponent:power) num1 = input("Enter first number:") num2 = input("Enter second number:") print("************* Arithmetic Operators *************") print("Addition(+):{0}+{1}={2}".format(num1,num2,num1+num2)) if num1 > num2: res = num1 - num2 else: ...
false
fdc9e5dc5a169d1178cf3efa9e1f70a2f42576a1
rcoady/Programming-for-Everyone
/Class 1 - Getting Started with Python/Assignment4-6.py
982
4.375
4
# Assignment 4.6 # Write a program to prompt the user for hours and rate per hour using raw_input to # compute gross pay. Award time-and-a-half for the hourly rate for all hours worked # above 40 hours. Put the logic to do the computation of time-and-a-half in a function # called computepay() and use the function to do...
true
e94e9bba980e60c3c6bbb96ef5c221a3852e9941
Shakleen/Problem-Solving-Codes
/Hacker Rank/Language Proficiency/Python/3. Strings/13. sWAP cASE.py
276
4.125
4
def swap_case(s): L = list(s) for pos in range(len(L)): if L[pos].isalpha: L[pos] = L[pos].lower() if L[pos].isupper() else L[pos].upper() return ''.join(L) if __name__ == '__main__': s = input() result = swap_case(s) print(result)
false
c3be60d54a88d10b85264b02689c43ffc9ec8b9e
Hr09/Python_code
/cicerciper.py
1,240
4.21875
4
message=input("Enter a message:") key=int(input("How many Charachters should we shift (1-26)")) secret_message="" for char in message: if char.isalpha(): char_code=ord(char) char_code+=key if char.isupper(): if char_code > ord('Z'): char_code-=26 ...
false
57abcfd1f015392cec8b05af62fdf4a1ff06aa35
Luisarg03/Python_desktop
/Apuntes_youtube/operador_in.py
512
4.15625
4
print("Eleccion de asignaturas") print("Asignaturas disponibles: Bioquimica - Fisiologia - Salud mental") asignatura=input("Elige la asignatura: ") if asignatura in ("Bioquimica", "Fisiologia", "Salud mental"): print("La asignatura elegida es "+asignatura) else: print("La asignatura elegida no esta contempla...
false
381467c9ac0ae671463340dee5d4b34297918d14
Luisarg03/Python_desktop
/Apuntes_youtube/practica_lista.py
1,537
4.3125
4
lista1=["maria", "luis", "natalia", "juan", "marcos", "pepe"]#el indice empieza contar desde el cero, ej "luis" seria posicion 2 indice 1 print([lista1]) print(lista1[2])#indico que solo quiero que aparezca el indice 2 print(lista1[-1])#el menos hace que el indice se cuente de derecha a izquierda, en este caso solo ...
false
73b0b07826794a242dde684f94f946581c180949
Dszymczk/Practice_python_exercises
/06_string_lists.py
803
4.40625
4
# Program that checks whether a word given by user is palindrome def is_palindrome(word): return word == word[::-1] word = "kajak" # input("Give me some word please: ") reversed_word = [] for index in range(len(word) - 1, -1, -1): reversed_word.append(word[index]) palindrome = True for i in range(l...
true
6fcd96b8c44668ccac3b4150d9b6c411b325bcc0
mm/adventofcode20
/day_1.py
2,436
4.375
4
"""AoC Challenge Day 1 Find the two entries, in a list of integers, that sum to 2020 https://adventofcode.com/2020/day/1 """ def find_entries_and_multiply(in_list, target): """Finds two entries in a list of integers that sum to a given target (also an integer), and then multiply those afterwards. """ ...
true
7252e716f0bb533d1a612728caf027276883e0ef
git4rajesh/python-learnings
/String_format/dict_format.py
800
4.5625
5
### String Substitution with a Dictionary using Format ### dict1 = { 'no_hats': 122, 'no_mats': 42 } print('Sam had {no_hats} hats and {no_mats} mats'.format(**dict1)) ### String Substitution with a List using Format ### list1 = ['a', 'b', 'c'] my_str = 'The first element is {}'.format(list1) print(my_str) ...
true
79618644a020eaa269bc7995d650afed3043b411
ravitej5226/Algorithms
/backspace-string-compare.py
1,312
4.15625
4
# Given two strings S and T, return if they are equal when both are typed into empty text editors. # means a backspace character. # Example 1: # Input: S = "ab#c", T = "ad#c" # Output: true # Explanation: Both S and T become "ac". # Example 2: # Input: S = "ab##", T = "c#d#" # Output: true # Explanation: Both S and ...
true
08815d5371e53a75f10ec4d2b0b9bba1747a6fa6
ravitej5226/Algorithms
/zigzag-conversion.py
1,458
4.15625
4
# The string "PAYPALISHIRING" is written in a zigzag pattern on a given number of rows like this: (you may want to display this pattern in a fixed font for better legibility) # P A H N # A P L S I I G # Y I R # And then read line by line: "PAHNAPLSIIGYIR" # Write the code that will take a string and make thi...
true
5fa0a0ab95042208eb2bef0dc47498c34056dda6
arthuroe/codewars
/6kyu/sort_the_odd.py
2,963
4.25
4
''' You have an array of numbers. Your task is to sort ascending odd numbers but even numbers must be on their places. Zero isn't an odd number and you don't need to move it. If you have an empty array, you need to return it. Example sortArray([5, 3, 2, 8, 1, 4]) == [1, 3, 2, 8, 5, 4] ''' import sys def sort_arr...
true
78576dc109ab336280899a740fbc2f3797563e52
bryansilva10/CSE310-Portfolio
/Language_Module-Python/Shopping-Cart_Dictionary/cart.py
1,423
4.21875
4
#var to hold dictionary shoppingCart = {} #print interface print(""" Shopping Options ---------------- 1: Add Item 2: Remove Item 3: View Cart 0: EXIT """) #prompt user and turn into integer option = int(input("Select an option: ")) #while user doesn't exit program while opt...
true
9b72b3dd6d3aba0798f18f06ab37bdf0c39a339a
xu2243051/learngit
/ex30.py
858
4.125
4
#!/usr/bin/python #coding:utf-8 #================================================================ # Copyright (C) 2014 All rights reserved. # # 文件名称:ex30.py # 创 建 者:许培源 # 创建日期:2014年12月09日 # 描 述: # # 更新日志: # #================================================================ import sys reload(sys) sys.se...
true
3c4cb233be63715f662d6f81f76feae91e51ac85
cupofteaandcake/CMEECourseWork
/Week2/Code/lc1.py
1,787
4.375
4
#!/usr/bin/env python3 """A series of list comprehensions and loops for creating sets based on the bird data provided""" __appname__ = 'lc1.py' __author__ = 'Talia Al-Mushadani (ta1915@ic.ac.uk)' __version__ = '0.0.1' __license__ = "License for this code" birds = ( ('Passerculus sandwichensis','Savannah sparrow',18....
true
0b4d452a26c2b44684c2eae50ba622c56dd97f4f
kriti-ixix/python2batch
/python/Functions.py
614
4.125
4
''' Functions are of two types based on input: - Default - Parameterised Based on return type: - No return - Some value is returned ''' ''' #Function definition def addTwo(first, second): #first = int(input("Enter first number: ")) #second = int(input("Enter second number: ")) third = ...
true
2bbe8852b53fe5d099afbbd8a310704c04c0423b
mecosteas/Coding-Challenges
/count_words.py
1,260
4.375
4
""" Given a long text string, count the number of occurrences of each word. Ignore case. Assume the boundary of a word is whitespace - a " ", or a line break denoted by "\n". Ignore all punctuation, such as . , ~ ? !. Assume hyphens are part of a word - "two-year-old" and "two year old" are one word, and three differen...
true
507e4a5ea9054c11509e8d6f678d74aa6c3f545e
sleepingsaint/DS-ALG
/DS/linkedList.py
2,724
4.21875
4
# defining stack element object class Element(object): def __init__(self, value): self.value = value self.next = None # defining stack object class Stack(object): def __init__(self, head=None): self.head = head # helper class functions # function to add elements def append...
true
d5891584688ff83c60bf74fc7611c625f57b14db
Sukanyacse/Assignment_2
/assignment 2.py
254
4.1875
4
numbers=(1,2,3,4,5,6,7,8,9) count_even=1 count_odd=-1 for value in range(1,10): if(value%2==0): count_even=count_even+1 else: count_odd=count_odd+1 print("Number of even numbers:",count_even) print("Number of odd numbers:",count_odd)
true
92ff8e67eb22909831b10bfcdd1faedef658825e
Lauraparedesc/Algoritmos
/Actividades/ejercicios/exlambda.py
1,291
4.25
4
#Exponente n de un # dado exponente = lambda base = 0, exponente = 0 : base**exponente resultado = exponente (5,2) print (resultado) #string string = lambda cantidad = 0 : print ('♡'*cantidad) string (60) #maximo # listaEdades1 = [18,12,14,13,12,20] listaEdades2 = [19,47,75,14,12,22] lambdamaximos = lambda x = [], y...
false
e644585b9b3a99f72e3ed4fc948ecb26ca0465f0
moheed/python
/languageFeatures/python_using_list_as_2d_array.py
1,976
4.5625
5
#NOTE: creating list with comprehension creates many #pecularities.. as python treats list with shallow copy... #for example arr=[0]*5 #=== with this method, python only creates one integer object with value 5 and #all indices point to same object. since all are zero initially it doesn't matter. arr[0]=5 #when we ...
true
7cc37dc2b2888106efb3c2ee41d61bb86b511f5b
moluszysdominika/PSInt
/lab02/zad3.py
644
4.15625
4
# Zadanie 3 # Basic formatting text1 = "Dominika" text2 = "Moluszys" print("{1} {0}" .format(text1, text2)) # Value conversion class Data(object): def __str__(self): return "Dominika" def __repr__(self): return "Moluszys" print("{0!s} {0!r}" .format(Data())) # Padding and aligning strings ...
false
92a753e7e633025170d55b3ebdb9f2487b3c4fa0
HayleyMills/Automate-the-Boring-Stuff-with-Python
/Ch6P1_TablePrinter.py
1,352
4.4375
4
##Write a function named printTable() that takes a list of lists of strings ##and displays it in a well-organized table with each column right-justified. ##Assume that all the inner lists will contain the same number of strings. ##For example, the value could look like this: ##tableData = [['apples', 'oranges', '...
true
e317905dca19712d90a62f463a4f782bd22668e5
Ahmad-Magdy-Osman/IntroComputerScience
/Classes/bankaccount.py
1,195
4.15625
4
######################################################################## # # CS 150 - Worksheet #11 --- Problem #1 # Purpose: Practicing User-Defined Classes. # # Author: Ahmad M. Osman # Date: December 9, 2016 # # Filename: bankaccount.py # ######################################################################## cla...
true
b19db0ac2fef12e825b63552fbd0b298fcb632ec
Ahmad-Magdy-Osman/IntroComputerScience
/Turtle/ex10.py
859
4.65625
5
###################################### # # CS150 - Interactive Python; Python Turtle Graphics Section, Exercise Chapter - Exercise 10 # Purpose: Drawing a clock with turtles # # Author: Ahmad M. Osman # Date: September 22, 2016 # # Filename: ex10.py # ##################################### #Importing turtle module imp...
true
bbcefac3f0243ed8df81ed8a4875626b78ab3ca4
iangraham20/cs108
/labs/10/driver.py
976
4.5
4
''' A driver program that creates a solar system turtle graphic. Created on Nov 10, 2016 Lab 10 Exercise 5 @author: Ian Christensen (igc2) ''' import turtle from solar_system import * window = turtle.Screen() window.setworldcoordinates(-1, -1, 1, 1) ian = turtle.Turtle() ss = Solar_System() ss.add_sun(Sun("SUN", 8....
true
0e75d78ea6d8540a5417a8014db80c0b84d32cc9
iangraham20/cs108
/projects/07/find_prefix.py
1,677
4.125
4
''' A program that finds the longest common prefix of two strings. October 25, 2016 Homework 7 Exercise 7.3 @author Ian Christensen (igc2) ''' # Create a function that receives two strings and returns the common prefix. def common_prefix(string_one, string_two): ''' A function that compares two strings, determines...
true
b3e1ca7c075544d30a3a7cbd65193871f62f7a64
iangraham20/cs108
/projects/12/polygon.py
881
4.25
4
''' Model a single polygon Created Fall 2016 homework12 @author Ian Christensen (igc2) ''' from help import * class Polygon: ''' This class represents a polygon object. ''' def __init__(self, x1 = 0, y1 = 0, x2 = 0, y2 = 50, x3 = 40, y3 = 30, x4 = 10, y4 = 30, color = '#0000FF'): ''' This is the ...
false
50b03235f4a71169e37f3ae57654b7a37bcb9d10
adamsjoe/keelePython
/Week 3/11_1.py
246
4.125
4
# Write a Python script to create and print a dictionary # where the keys are numbers between 1 and 15 (both included) and the values are cube of keys. # create dictonary theDict = {} for x in range(1, 16): theDict[x] = x**3 print(theDict)
true
86e3aa25fd4e4878ac12d7d839669eda99a6ea1c
adamsjoe/keelePython
/Week 1/ex3_4-scratchpad.py
964
4.125
4
def calc_wind_chill(temp, windSpeed): # check error conditions first # calc is only valid if temperature is less than 10 degrees if (temp > 10): print("ERROR: Ensure that temperature is less than or equal to 10 Celsius") exit() # cal is only valid if wind speed is above 4.8 if (windS...
true
d3ab5cfe7bb1ff17169b2b600d21ac2d7fabbf70
adamsjoe/keelePython
/Week 8 Assignment/scratchpad.py
1,193
4.125
4
while not menu_option: menu_option = input("You must enter an option") def inputType(): global menu_option def typeCheck(): global menu_option try: float(menu_option) #First check for numeric. If this trips, program will move to except. if float(menu_option).is_integer(...
true
4720925e6b6d133cdfaf1fd6cf5358813bbec7e3
george5015/procesos-agiles
/Tarea.py
460
4.15625
4
#!/usr/bin/python3 def fibonacci(limite) : numeroA, numeroB = 0,1 if (limite <= 0) : print(numeroA) elif (limite == 1) : print(numeroB) else : print(numeroA) while numeroB < limite: numeroA, numeroB = numeroB, numeroA + numeroB print(numeroA) return numeroLimite = int(input("Ingrese el numero para cal...
false
35612faf608a4cb399dacffce24ab01767475b35
imsure/tech-interview-prep
/py/fundamentals/sorting/insertion_sort.py
775
4.15625
4
def insertion_sort(array): """ In place insertion sort. :param array: :return: """ n = len(array) for i in range(1, n): v = array[i] k = i j = i - 1 while j >= 0 and array[j] > v: array[j], array[k] = v, array[j] k = j j -...
false
db160f1b741178589e3b097dfdb4d46f39168350
Bngzifei/PythonNotes
/学习路线/1.python基础/day09/06-str方法.py
608
4.21875
4
"""str()就是可以自定义输出返回值,必须是str字符串""" class Dog: def __init__(self, name): self.name = name def __str__(self): # 把对象放在print()方法中输出时,就会自动调用str()方法 return '呵呵呵%s' % self.name # 只能返回字符串 # overrides method :覆盖方法 重写了 dog1 = Dog('来福') print(dog1) # 如果将str()方法注释掉,把对象放在print中输出时,默认输出的是对象的内存地址 <__main__.Dog object at...
false
e3d36397e4ba0307b0574963d8bfddbed8d12ef0
Bngzifei/PythonNotes
/学习路线/1.python基础/day10/09-多继承.py
1,608
4.34375
4
""" C++ 和Python 支持多继承,其他语言不支持 发现规律找规律记,记住区别.初始化只是一次.再次调用init()方法就是和普通的方法调用没区别了. 多态依赖继承. 鸭子类型不依赖继承. Python中没有重载一说,即使同名函数,方法,出现2次后,第2次的慧覆盖掉第1次的.在一个类里面只能有一个,通过修改参数来进行需要的变化. 同名属性和同名方法只会继承某个父类的一个.继承链中挨的最近的那个. """ class Dog: def eat(self): print('肉') def drink(self): print('水') class God: def fly(self): p...
false
d8c4501a2f890f7e63f7e08444204882e45cef5c
Bngzifei/PythonNotes
/学习路线/1.python基础/day03/01-猜拳游戏.py
970
4.1875
4
""" 石头1剪刀2布3 猜拳游戏 import random # 导入生成随机数模块 同行的注释时: #号和代码之间是2个空格,#号和注释内容之间是1个空格 这是PEP8的编码格式规范 """ import random # 导入生成随机数模块 # print(random.randint(1,3)) # 生成1,2,3其中的某一个 以后的才是左闭右开,前小后大,只能生成整数 区间: 数学意义上的()是开区间 ,[]是闭区间.取值规则是:取闭不取开.这里的random.randint(n,m)实际上是n<= 所取得值 <= m.原因是内置函数写死了. player_num = int(input('请出拳 石头(1)...
false
279e7cd4a60f94b9e7ff20e2d16660850f6a76cb
Bngzifei/PythonNotes
/学习路线/1.python基础/day06/01-参数混合使用.py
1,040
4.5
4
print('参数补充:') """ 形参:位置参数(就是def func(a,b):),默认参数(就是def func(a = 5,b = 9):),可变参数(就是def func(*args):),字典类型的可变参数(就是def func(**kwargs):) 实参:普通实参,关键字参数 形参使用顺序:位置参数 -->可变参数 -->默认参数 -->字典类型可变参数 实参使用顺序:普通实参 ---> 关键字参数 """ """位置参数和默认参数混合使用时,位置参数应该放在默认参数的前面""" """位置参数和可变参数混合使用时位置参数在可变参数的前面""" # # # def func1(a, *args): # ...
false
5149018a67ac854d93a1c553f315b0b44858848a
Bngzifei/PythonNotes
/学习路线/1.python基础/day05/11-函数的参数补充.py
2,020
4.15625
4
""" 形参:有4种类型,位置参数,默认参数(缺省参数),可变参数(不定长 参数).字典类型可变参数 实参:2种类型 普通实参,关键字参数 """ """位置参数:普通参数 实参和形参位置数量必须一一对应""" # def func1(num1, num2): # print(num1) # # # func1(10, 20) """ 默认参数(缺省参数): 如果某个形参的值在多次使用时,都是传一样的值,我们可以把此参数改成默认参数 默认参数如果没有传递实参就用默认值,如果传递了实参就使用传递来的实参 默认参数必须放在非默认参数的后面.除非均是默认参数 """ # def func2(a, b=2): #...
false
b36169cf1712dca276d8bc33bca89412500342d1
Bngzifei/PythonNotes
/学习路线/1.python基础/day04/09-切片.py
834
4.1875
4
""" 切片:取出字符串的一部分字符 字符串[开始索引:结束索引:步长] 步长不写,默认为1 下一个取得索引的字符 = 当前正在取得字符索引 + 步长 其他语言叫截取 步长:1.步长的正负控制字符串截取的方向 2.截取的跨度 """ str1 = "hello python" # print(str1[0:5]) # print(str1[:5]) # 如果开始索引为0,可以省略 # str2 = str1[6:12] # str2 = str1[6:] # 如果结束索引最后,可以省略 # print(str2) # list1 = [11, 12, 14] # print(list1[-1]) # 负索引,倒着数,比较方便 ...
false
258f80cccb19730b8ad4b8f525b9fcac8ab170f2
Bngzifei/PythonNotes
/学习路线/2.python进阶/day11/02-闭包.py
1,079
4.34375
4
""" closure:闭包的意思 闭包特点: 1.>函数的嵌套定义,就是函数定义里面有另外一个函数的定义 2.>外部函数返回内部函数的引用<引用地址> 3.>内部函数可以使用外部函数提供的自由变量/环境变量 <顺序是先去找自己的位置参数,看看是否有同名,如果没有就向外扩展一层,继续这个过程.直到找到> 这就是闭包的三个特点 概念:内部函数 + 自由变量 构成的 整体 这是IBM 开发网站的一个说法 理解:内部函数 + 外部函数提供给内部函数调用的参数. """ def func(num1): # 外部函数 的变量称之为自由变量/环境变量 内部函数也可以使用 print('in func', num1) d...
false
cdab2900e3495440613dfeea792f09953078fa1a
Bngzifei/PythonNotes
/学习路线/1.python基础/day03/07-定义列表.py
530
4.1875
4
""" 存储多个数据,每个数据称之为元素 格式:[元素1,元素2...] 列表中尽可能存储同类型数据,且代表的含义要一致.实际上可以存储不同类型的数据 获取元素:列表[索引] 常用的标红:整理一下好复习 增.删.改.查 """ list1 = ['11', '22', 18, 1.75, True] print(type(list1)) print(list1[4]) l1 = list() print(l1) # IndexError: list index out of range # print(list1[8]) 索引超出list范围,报错 list1[0] = '你大爷' # 修改元素的值 p...
false