blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
01c5b4b2259d1277efd2ceb2cdb8c72d3283111d
cseharshit/Python_Practice_Beginner
/48.Check_File_extension.py
363
4.5
4
extensions=['gif','png','jpeg','jpg','svg'] file_extension=input("Enter the filename with extension: ").split('.') if (len(file_extension)>=2): extension=file_extension[-1].lower() if extension in extensions: print("File Extension exists") else: print("File Extension does not exists") else...
239e5237c8930e932fe0e5460cfe53fd2b2e424d
Khawoat6/programming-skills-development-laboratory
/week05/5_BuggyRobot/5_BuggyRobot.py
1,987
3.90625
4
# Phattaraphon Chomchaiyaphum 5930300585 def buggyRobot(move_forward, move_back, distance, l, state): while True: if l >= distance: state = state+distance break if move_forward >= distance: state = state+distance distance=0 else: d...
c41b13e7800e58d7d3cfe5f9ad38c970d6ff77d1
JAntonioMarin/PythonBootcamp
/Section3/20.py
607
3.875
4
my_list = [1,2,3] my_list = ['STRING', 100, 23.2] print(len(my_list)) my_list = ['one', 'two', 'three'] print(my_list[0]) another_list = ['four', 'five'] print(my_list+another_list) my_list[0] = 'ONE ALL CAPS' print(my_list) my_list.append('six') print(my_list) my_list.pop() print(my_list) popped_item = my_list.pop() p...
c6945ec32c781319816271bef9eace437719a505
Vikatsy/Vacation_Planner
/database.py
4,161
4.1875
4
import sqlite3 from sqlite3 import Error def create_connection(db_file): """ create a database connection to the SQLite database specified by db_file :param db_file: database file :return: Connection object or None """ try: conn = sqlite3.connect(db_file) return conn ex...
8fc2f51ab20d88a6e078b879e180b990238193bd
aa-ag/nano
/problems/reverse_polish_notation.py
2,535
4
4
###--- CREATE STACK ----### class Node: def __init__(self, data): self.data = data self.next = None class Stack: def __init__(self): self.num_elements = 0 self.head = None def push(self, data): new_node = Node(data) if self.head is None: self....
72892cdca0dcdf3b48d749a813fd5c75d98c5993
monteua/Python
/Python_Basic/6.py
394
4.25
4
''' Write a Python program which accepts a sequence of comma-separated numbers from user and generate a list and a tuple with those numbers. Sample data : 3, 5, 7, 23 Output : List : ['3', ' 5', ' 7', ' 23'] Tuple : ('3', ' 5', ' 7', ' 23') ''' user_data = raw_input('Enter a sequence of comma-separated numbers: ').str...
2dbaa892f86d468cabbfba74dc1c32c452919478
05k001/WinterNetworkFinal
/UDP_Echo.py
1,563
3.71875
4
''' The user datagram protocol (UDP) works differently from TCP/IP. Where TCP is a stream oriented protocol, ensuring that all of the data is transmitted in the right order, UDP is a message oriented protocol. UDP does not require a long-lived connection, so setting up a UDP socket is a little simpler. On the other...
969860bbe905574836fa62a970fef7400cba7609
hyejun18/daily-rosalind
/scripts/bioinformatics-stronghold/SIGN.py
1,119
3.828125
4
################################################## # Enumerating Oriented Gene Orderings # # http://rosalind.info/problems/SIGN/ # # Given: A positive integer n <=q 6. # # Return: The total number of signed permutations # of length n, followed by a list of all such permutations # (you may list the signed permutatio...
1b65a7cbadb7d0ec6ad73372b7fefecf43a6d82c
faneco/Programas
/Cursopython/exer53.py
182
3.828125
4
nome = input('Digite o nome: ').strip() palavra = nome.split() junto = ''.join(palavra) inverso = '' for i in range(len(junto)-1, -1, -1): inverso += junto[i] print (junto, inverso)
b295e82e2c27b0f1d13f46e144a7719be4a6b038
mjoehler94/login_system
/login.py
7,570
3.546875
4
# login.py -------------------------- # Author: Matt Oehler # libraries import getpass import sqlite3 # global _DATABASE_ = "data/user.db" _LOGIN_OPTION_ = 1 _REGISTER_OPTION_ = 2 _QUIT_OPTION_ = 3 class Login(): def __init__(self, database): self.db = database self.conn = sqlite3.connect(self.d...
5ea62694c395fb9eda7173b3730e3f9c1afe465c
Georgeh30/Mini-Curso-Python
/clases/video12_metodo@staticmethod.py
721
3.828125
4
# 1. METODO CON DATOS INDEPENDIENTES --> CLASSMETHOD # 2. METODO STATIC --> STATICMETHOD # NINGUNO DE LOS DOS METODOS NECESITAN CREAR UNA INSTANCIA import math class Pastel: def __init__(self, ingredientes1, tamano): self.ingredientes1 = ingredientes1 self.tamano = tamano def __repr__(self): ...
30923b7915b2ba3e487e59d83d0e5fcd7107cbe8
PreciseSlice/python_practice
/io.py
470
3.546875
4
my_list = [i ** 2 for i in range(1, 11)] my_file = open("output.txt", "w") for item in my_list: my_file.write(str(item) + "\n") my_file.close() # my_file = open("output.txt", "r") # print(my_file.read()) # my_file.close() # my_file = open("text.txt","r") # print(my_file.readline()) # print(my_file.readline(...
28148f82ce64dc9d2336853c88151ee679a75a57
itsolutionscorp/AutoStyle-Clustering
/all_data/exercism_data/python/bob/e96fe65800b445a3a6ec76aaf8eda1da.py
804
3.59375
4
# -*- coding: utf-8 -*- import re class Phrase: def __init__(self, text): self.text = text.strip() def is_question(self): return self.text[-1] == '?' def is_yelling(self): return self.__contains_uppercase_letters() and \ not self.__contains_lowercase_letters() def is_silence(self):...
38415a6bcca88b651339f4a8b3f1b2c02739ef61
yielding/code
/lang.py/ternary.py
206
3.953125
4
#!/usr/bin/env python #coding: utf-8 def translate(s): res = map(lambda x: '.' if ord(x) % 2 == 0 else x, s) return "".join(res) s = "leech babo" arr = [c for c in s] print arr print translate(arr)
18b36cad36422178f1d7b13b5b8f8ba030a2f199
j-flammia/CoffeeMachine
/Topics/Invoking a function/Longest word/main.py
67
3.59375
4
word1 = len(input()) word2 = len(input()) print(max(word1, word2))
888803263d539695e94556b5cc9e49859a2387c0
RajitPaul11/PythonBasix
/logical-relational-operators.py
237
4.1875
4
a=input("Enter a number: ") b=input("Enter a number to compare to: ") if a!=b and a>=b: print(a," equals to or greater than ", b) elif a!=b and a<=b: print(a," not equal to and less than ",b) else: print(a," equals to ", b)
4c76d51affe82b462793cb6342ebdb8cf9800ca7
ParulProgrammingHub/assignment-1-AmitDavra
/Answer-4.py
54
3.5
4
c=int(input("celcius= ")) c=c*1.8 f=c+32 print(f)
1877e6886e62995dc6fbf5c8dc99fa040e3933eb
paulreaver005/tarea_2
/tarea2.py
245
3.9375
4
mis_valores = [5, 6, 10, 13, 3, 4] sum = 0 for x in mis_valores: sum = sum + x average = sum / len(mis_valores) print("los numeros de la lista son: ", mis_valores) print("el promedio de los valores de la lista es: ", average)
c82813e190960d4061fe481c96b0d799e262f208
fajrinurhidayah/Fajri-Nur-Hidayah_I0320040_Andhika_Tugas2
/Soal 1.py
1,094
3.765625
4
#menghitung luas persegi panjang print("Menghitung luas persegi panjang") Panjang = float(input("Masukkan nilai panjang: ")) Lebar = float(input("Masukkan nilai lebar: ")) luas_persegi_panjang = Panjang * Lebar print("Luas persegi panjang adalah: ", luas_persegi_panjang) #menghitung luas lingkaran print("Menghitung lu...
05ce138bae430e7337c1fcf6d1d6f8bb6e271163
xwang322/Coding-Interview
/uber/uber_algo/RegularExpressionMatchingLC10Mutation_UB.py
1,538
4.09375
4
/* * 第二题是 * The matching should cover the entire input string (not partial). * The function prototype should be: * bool isMatch(String str, String patter) * Some examples: * isMatch("aa","a") → false * isMatch("aa","aa") → true * isMatch("aaa","aa") → false * isMatch("aa","a{1,3}") → true * isMatch("aaa","a{1...
e9374f9710e69542fa1cfc17f84040d074b05ead
gauffa/mustached-dubstep
/ch5/ch5ex6.py
517
3.90625
4
#Matthew Hall #ISY150 #Chapter 5 Exercise 6 #10/02/2013 #Celsius to Farenheit Table def main(): #define constants temp_range = 20 #print 'header' for table print("\nFahrenheit\tCelsius") print("----------------------") #maths to determine a range of temps for celsius in range (0, temp_range + 1, 1):#...
e7be580b93ac5e4ff49b25c0275ab41187747824
beingveera/whole-python
/python/projects/100`s of python/gratter.py
670
3.90625
4
class A: def one(self,x): self.val1=x class B(A): def two(self,y): self.val2=y class C(B): def three(self,x,y,z): self.val1=x self.val2=y self.val3=z if self.val1 > self.val2 and self.val1>self.val3: return "\n{} is Gretest...!!! ".format(self....
c6dd3266793a64ed2a140b7f0351598465333c17
oliveirajonathas/python_estudos
/pacote-download/pythonProject/exercicios_python_guanabara/ex090.py
542
4.03125
4
""" Faça um programa que leia nome e média de um aluno, guardando também a situação desse aluno em um dicionário. No final, mostre o conteúdo da estrutura na tela. """ sit_aluno = dict() sit_aluno['NOME'] = str(input('Nome: ')) sit_aluno['MEDIA'] = float(input('Média: ')) if sit_aluno['MEDIA'] < 5: sit_aluno['SITUA...
cf1beb99ca0ff03ed37555bc54d74479e744473c
rfa7/python
/add.py
1,872
3.671875
4
import sqlite3 from datetime import datetime #def addDeveloper(name, joiningDate): def addDeveloper(name): try: sqliteConnection = sqlite3.connect('SQLite_Python.db', detect_types=sqlite3.PARSE_DECLTYPES | sqlite3.PARSE_COLNAMES) cursor = sqliteConnection.cursor() print("Connected to SQLite...
e3fe28cedded72f55cb34051ab0def4596258c52
eulersformula/Lintcode-LeetCode
/Merge_Sorted_Array_II.py
920
4.25
4
#Merge two given sorted integer array A and B into a new sorted integer array. #Example #A=[1,2,3,4] #B=[2,4,5,6] #return [1,2,2,3,4,4,5,6] #Method 1: Time complexity O(n), Space complexity O(n) class Solution: #@param A and B: sorted integer array A and B. #@return: A new sorted integer array def merge...
2e4954fae0201205a049f16753bd67df8edbbe37
mahendraphd/Python_LD
/topLevelExample12.py
663
3.78125
4
import tkinter as tk root = tk.Tk() def create_top(): win = tk.Toplevel(root) win.rowconfigure(1, weight=1) win.columnconfigure(1, weight=1) win.title("Toplevel") f1 = tk.Frame(win, height=50, width=400, bg='red') f1.grid_propagate(0) f1.grid(row=0, column=0,sticky="nsew") f2 = tk.Fra...
2882b8f46f61835a945749912cf79e89e9c1defd
BaoziSwifter/MyPythonLeetCode
/pythonLeetcode/53-最大子序和.py
1,052
3.703125
4
#!/usr/bin/env python # -*- coding: utf-8 -*- # @Time : 2019/2/20 17:26 # @Author : Beliefei # @File : 53-最大子序列.py # @Software: PyCharm """ 给定一个整数数组 nums ,找到一个具有最大和的连续子数组(子数组最少包含一个元素),返回其最大和。 示例: 输入: [-2,1,-3,4,-1,2,1,-5,4], 输出: 6 解释: 连续子数组 [4,-1,2,1] 的和最大,为 6。 进阶: 如果你已经实现复杂度为 O(n) 的解法,尝试使用更为精妙的分治法求解。 """ c...
506d7e0207f0ff6e55debfbf2647ce85916e4804
Ritvik19/CodeBook
/data/HackerRank-Python/Collections deque.py
312
3.53125
4
from collections import deque d = deque() for i in range(int(input())): cmd, *arg = input().split() if cmd == 'append': d.append(int(arg[0])) if cmd == 'pop': d.pop() if cmd == 'popleft': d.popleft() if cmd == 'appendleft': d.appendleft(int(arg[0])) print(*d)
7ad96483759e22a1d5c4adcb4ad879341ab328fa
sarahhancock/well_drawdown_model
/well_drawdown_model.py
8,152
3.6875
4
import numpy as np import matplotlib.pyplot as plt from scipy.special import exp1 import matplotlib.animation as animation plt.style.use('ggplot') """ PROGRAM DESCRIPTION This program models the impact of transient groundwater flow and pumping wells on the hydraulic head in a confined aquifer. It starts with a 100 ...
787db91ec148afd3a51bd71b23a4be7b1527dcf8
turingtei/Python_Tutorial
/lesson_5b_ex1.py
772
4.46875
4
''' Create a dictionary day_to_number that converts the days of the week "Sunday", "Monday", … into the numbers 0, 1, ..., respectively ''' # Day to number dictionary problem ################################################### # Student should enter code below day_to_number = {"Sunday": 0, "Monday": 1, "Tuesday":2, "...
e5823469dfb8e1f724712e429038792d38c5a974
unchitta/py
/smallest_num.py
366
4.09375
4
# smallest_num.py # challenge: write a function that takes 3 numbers returns the smallest one # Sep 2014, Unchitta Kan print "Finding the smallest number" def getMin(a,b,c): x = 0 if (a > b): x = b else: x = a if (x < c): print "the smallest number is " , x else: p...
b5216cc5c8f79da0dbbb46ef9f432e4c4fa0455d
Viccari073/extra_excercises
/estruturas_condicionais5.py
993
4.1875
4
""" Faça um programa que leia o ano de nascimento de um jovem e informe, de acordo com sua idade: - Se ele ainda vai se alistar ao serviço militar; - Se é a hora de se alistar; - Se já passou do tempo do alistamento. Seu programa também deverá mostrar o tempo que falta ou que passou do prazo. """ from date...
c62e91789e93ed5ed2c10618eeda45ccd2102954
ShararAwsaf/Algorithms-Course
/Course-Contents/assignments/A4/practice/OBST.py
4,487
3.5
4
class CRCell: def __init__(self, C, R): self.C = C self.R = R class TreeNode: def __init__(self, value): self.value = value self.left_subtree = None self.right_subtree = None class Item: def __init__(self, v, prob): self.v = v ...
c8a8dcedeada81fb94067cddcbb518024b4ce236
surferJen/practice_problems
/coderbyte_timeConvert.py
354
4.03125
4
# Have the function TimeConvert(num) take the num parameter being passed and return the number of hours and minutes the parameter converts to (ie. if num = 63 then the output should be 1:3). Separate the number of hours and minutes with a colon. # Sample Test Cases # Input:126 # Output:"2:6" # Input:45 # Output:...
74477f1d4aa19e88778c992678655b7f4d687cfe
Devika-Baddani/python-program
/amstrong.py
240
4.125
4
num = int(input("enter a number: ")) d_num = num s = 0 while num>0: r = num%10 s = s + r**3 num //= 10 if s== d_num: print(d_num, "is an amstrong number") else: print(d_num, "is not an amstrong number")
f052e6d032ca3481513a1f2e319e282d0ef6ed20
green-fox-academy/Atis0505
/week-02/day-01/animals_and_legs.py
331
4.40625
4
# Write a program that asks for two integers # The first represents the number of chickens the farmer has # The seconf represents the number of pigs the farmer has # It should print how many legs all the animals have chickens = int(input("Chicken: ")) pigs = int(input("Pig: ")) print("Legs number: " + (str(2*chickens ...
517b63618e548904b9772056523fe166ed1a962d
cs-fullstack-2019-spring/python-review-functions-cw1-gkg901
/morningCW.py
1,641
4.09375
4
def main(): # ex1() ex2() def dothemath(n1,n2): myDict = {"SUM": n1+n2,"DIFF":n1-n2,"PROD":n1*n2,"QUOT":n1/n2} return myDict # Create a function that has a loop # Prompt for numbers until the user enters q to quit # If the user doesn't enter q, ask them to input another number # When the user e...
e2b60c729c42736b0db3f3ad01b425d009664b53
cat-box/2019PythonAssignments
/assignment1/test_team.py
6,943
3.5
4
import unittest from unittest import TestCase from team import Team from player_forward import PlayerForward from player_goalie import PlayerGoalie import inspect class TestTeam(TestCase): """ Unit Tests for the Team Class """ def setUp(self): self.logPoint() self.team = Team() self.f...
0b8a9f2ac8d6fceb9900d7d370652d2fef536267
rinman75/lesson1
/cod.py
182
3.5
4
def get_summ(one, two, delimiter = "&"): b = one + delimiter + two return b.upper() learn = "hello" python = "yury" get_summ(learn, python) print(get_summ(learn, python))
dfbb4a4ea8352adb5a56bca9066acd506993f0e3
novartval/simplebot
/ls2.py
2,418
3.671875
4
school = [ {'Class':'11', 'Оценки': [3,4,5,6,4,5]}, {'Class':'10', 'Оценки': [5,4,5,2,3,4]}, {'Class':'10', 'Оценки': [5,4,5,2,3,4]}, {'Class':'10', 'Оценки': [5,4,5,2,3,4]}, {'Class':'10', 'Оценки': [5,4,5,2,3,4]}, {'Class':'10', 'Оценки': [5,4,5,2,3,4]}, {'Class':'9', 'Оценки': [3,4,5,6,3,...
284d2f98ff6f6cee87f6ed2f4e2103fa2071cc03
sandeepkumar8713/pythonapps
/10_dynamic_programming/34_assembly_line.py
2,789
3.875
4
# https://www.geeksforgeeks.org/assembly-line-scheduling-dp-34/ # Question : A car factory has two assembly lines, each with n stations. A station is denoted by Si,j where i # is either 1 or 2 and indicates the assembly line the station is on, and j indicates the number of the station. # The time taken per station is d...
64c5665dcb6a88551680fe7def8587ba798c82f2
aamirna/python
/text_module.py
981
3.890625
4
#!/usr/bin/env python # coding: utf-8 # In[1]: #This function counts tabs in the text def count_tabs(text): return text.count("\t") #This function counts lines in the text def count_lines(text): return text.count("/n") #This function counts words in the given text def count_words(text): return len(text...
0098f453f83d8133ad81704ee510ae44cd7358c3
JDavid121/Script-Curso-Cisco-Python
/52 for loop.py
228
4.15625
4
# -*- coding: utf-8 -*- """ Created on Wed Feb 5 19:45:03 2020 @author: David """ for i in range(2, 8, 3): # 2: initial value. # 8: final value # 3: increment print("The value of i is currently", i)
c3cf58331b5f8fd26795fceb5b122e7c80a80d40
hilalekinci/HackerRank-Solutions
/Codes/diagonalDifference.py
651
3.671875
4
#!/bin/python3 import math import os import random import re import sys # Complete the diagonalDifference function below. def diagonalDifference(n,arr): PrimarySum = 0 SecondarySum = 0 for i in range(n): PrimarySum += arr[i][i] for j in range(n): SecondarySum += arr[j][n - j - 1] ...
b21b6cc68ac01b997a6b214e0d139c6a7068966e
chloro4m/python_practice_codes
/test.py
98
3.75
4
x=1 if x==2: print("f") else: leftt = 7 rightt = 7 print(leftt) print(rightt)
e018ce87d2ac928d64f34032e3d296fc46b082b9
LyricLy/python-snippets
/quick_sort.py
498
4.09375
4
#!/usr/bin/env python3 # encoding: utf-8 # Public Domain def quick_sort(t): if len(t) < 2: return t # copy the list (don't modify it) t = t[:] # pick the middle element as the pivot pivot = t.pop((len(t) - 1)//2) left = list(filter(lambda x: x < pivot, t)) right = list(filter(lambda x: x >= pivot, t)) ...
4283cc93401afd1400c9c46edd6bd5b875f0d761
slickFix/Python_algos
/DS_ALGO/GFG_practise/Deque.py
2,012
3.796875
4
class Deque: def __init__(self,capacity): self.capacity = capacity self.arr = [None]*capacity self.size = self.front = 0 self.rear = capacity-1 def is_full(self): return self.size == self.capacity def is_empty(self): return self.size == 0 def enque_f(...
cd15147e2001ed669acd0b6e99a8bc078f20b135
Sergio16T/algorithms-dataStructures-python
/dataStructures/queue.py
842
4.28125
4
# (“first-in, first-out”) # While appends and pops from the end of list are fast, doing inserts or pops from the beginning of a # list is slow (because all of the other elements have to be shifted by one). # Due to challenges with list implementation, Python3 has collections.deque which was designed # to have fast ap...
08238217714b4f8ff6cc613bee8d28f4ed48990d
youinmelin/practice2020
/oo_practice_count_time.py
791
3.734375
4
# compute the end time of an opera,while start time and duration time are given class Time: def __init__(self,hours:int,minutes:int,seconds:int): self.hours = hours self.minutes = minutes self.seconds = seconds def add_time(self,duration): end_hours = end_minutes = end_seconds =...
95ea56571394eb4a6ffeab3e4279f601cad40dac
chai1323/Data-Structures-and-Algorithms
/InterviewBit/Strings/Reverse the String.py
153
3.65625
4
def rev(st): st = st.split() rev = st[::-1] print(rev) rev = ' '.join(rev) return rev s = " hello world! " print(rev(s))
c7eb337499fa11c7e4c19791b1364f73f888b8ce
supportaps/python050920
/ua/univer/base/hw01arifmetic/task03.py
729
4.15625
4
#3. Расчет площади земельного участка. Один акр земли эквивалентен квадратным метрам. #Напишите программу, которая просит пользователя ввести общее количество квадратных #метров участка земли и вычисляет количество акров в этом участке. #Подсказка: разделите введенное количество на 4047, чтобы получить количество акров...
5d3d1cc0a76b90dbad54b332074a11b00ad3e806
g2des/taco4ways
/hackerrank/python/nested_list.py
594
3.703125
4
from operator import itemgetter if __name__ == '__main__': scores = list() second_lowest = None for _ in range(int(input())): name = input() score = float(input()) scores.append([name, score]) scores.sort(key=itemgetter(1,0)) minVal = min(scores, key=itemgetter(1))[1...
f2d9cf8404ded5ea82393ff305c12e6d77b21c9c
chends888/CodingInterviews
/rotate_matrix_chen.py
997
3.59375
4
class Solution: def rotate(self, matrix): import math """ Do not return anything, modify matrix in-place instead. """ for i in range(math.ceil(len(matrix) / 2)): for j in range(i, len(matrix[i]) - 1 - i): print(i, j) old_index = [i,...
b5826d07798740c4f60a8ca0b65d09c00e8487ef
ashleykwan8/class_lab
/skills-1-ashleykwan8/functions.py
7,804
4.1875
4
"""SKILLS: FUNCTIONS Please complete the following promps. """ #################### PART 1 #################### """PROMPT 1 Write a function that returns `True` if a town name matches the name of your hometown. Examples: (let's say my hometown is San Francisco) - 'Oakland' -> False - 'San Francisco' -> Tru...
11790885a826a5b5434be78c183700e7a9ce0366
max-szostak/coding_challenges
/leet_code/trapping_rainwater.py
768
3.640625
4
""" Given n non-negative integers representing an elevation map where the width of each bar is 1, compute how much water it can trap after raining. """ class Solution: def trap(self, height): lmaxes, rmaxes = [], [] hmax = 0 for h in height: if h > hmax: hmax = h...
ecc6b06574fd5b7e39c89fc55cb00483d2fa10fd
AshwinRaikar88/Python
/Assignments/Class Assignments/Assignment 1/pgm3.py
313
4.1875
4
#Assignment Program 3 number=list() while(True): num=input("Enter a number:") if(num=="done"): print("Maximum value:",max(number),"Minimum value:",min(number)) break try: number.append(int(num)) except: print("\nInvalid input")
5536252a582fe668166671a1bec234f678bd36ca
louismatsika/python
/triangle.py
129
3.796875
4
a=input("enter hieght ") b=input("enter base ") height=int(a) base=int(b) area=((height*base)/2) print("the area is",area)
0c890156bf6b01d598c2be703c39b8f9386afe95
Yurikimkrk/PythonInterview
/les2/task_6.py
1,487
3.96875
4
""" 6. Проверить на практике возможности полиморфизма. Необходимо разделить дочерний класс ItemDiscountReport на два класса. Инициализировать классы необязательно. Внутри каждого поместить функцию get_info, которая в первом классе будет отвечать за вывод названия товара, а вторая — его цены. Далее реализовать выпол...
82105e7f3450a039dd9d7126b79ff330e33af2cb
spidermedic/Games
/blackjack/cards.py
1,434
4.0625
4
""" Functions related to the deck of cards The first digit is the suit. The last two digits are the card. 1 = Ace, 11,12,13 = J, Q, K """ import random from colors import Colors color = Colors() def shuffle(): """ Returns a shuffled 52 card deck.""" main_deck = [101,102,103,104,105,106,107,108,1...
97d4d24fd4fea06e0b6815c94575892cd7543146
srinivasycplf8/LeetCode
/binary_subarrays_with_sum.py
359
3.625
4
def num_sub_array(A): left_pointer=0 right_pointer=0 count=0 for i in range(len(A)): if right_pointer>=len(A): break if A[left_pointer]+A[right_pointer]==2: count+=1 left_pointer+=1 right_pointer+=1 right_pointer+=1 p...
39957ec043beb2a41e4def28ff50680855e135e2
shyamambilkar/PracticePythonPrograms
/Module_7/Price_of_Product.py
338
4.03125
4
products = {"Mango": 6.9, "Banana": 4.9, "Apple": 4.7} for pro, price in products.items(): print(pro, " = ", price) cost = 0 while True: pro = input("Select Product (n = nothing): ") if pro == 'n': break qty = int(input("Number of Products? ")) cost += products[pro]*qty print("Price of Pr...
e2bcff36566e6fcf1c1f7bb53618b00c4eaf92bb
AndreaInfUFSM/elc117-2017a
/trabalhos/t2/svgcolors.py
1,234
3.5
4
#!/usr/bin/env python3 import itertools ''' Programacao funcional para gerar SVG: - gera uma lista de coordenadas de retangulos - define uma lista de estilos (cores), em qualquer quantidade - aplica os estilos aos retangulos, gerando uma lista com todos os dados para o SVG - coloca os dados no formato S...
40fdd8f45580403f0f11fa64ee195b5487371e6d
kevingreenb/Python
/most frequent word.py
523
3.890625
4
"""Quiz: Most Frequent Word""" def most_frequent(s): arr = s.split(); arr.sort(); m = 0; for each in arr: if(arr.count(each)>m): results = each; m = arr.count(each); return results def test_run(): """Test most_frequent() with some inputs.""" print(m...
25c60b9b705099d82a672183b3f4d1a89f782c32
elocj/FirstWebApp
/convoNN/cnn.py
2,569
3.546875
4
import numpy as np from convoNN.conv import Conv3x3 from convoNN.maxpool import MaxPool2 from convoNN.softmax import Softmax conv = Conv3x3(8) pool = MaxPool2() softmax = Softmax(47 * 47 * 8, 2) class Action: def __init__(self, y_train): data = np.load('/Users/anthonyjoo/Google Drive/Python/FirstWebApp/convoNN/...
4e1fe34bc121658eef85a30a193fbe7d00caa60a
graceliu2006/LearnToCode
/python/notin.py
447
3.921875
4
# activity = input("What would you like to do today? ") # if "cinema" not in activity.casefold(): # print("But I want to go to the cinema") name = input("What is your name? ") age_string = input("What is your age? ") if name!="" and age_string!="": if 18 <= int(age_string) < 31: print("Welcome to the...
b82ded7968d50a106a4a30da360b2ed989f42601
Ekeopara-Praise/python-challenge-solutions
/Ekeopara_Praise/Phase 2/FILE I & O/Day79 Tasks/Task3.py
241
4.25
4
'''3. Write a Python program to read a file line by line store it into a variable. ''' def file_read(fname): with open (fname, "r") as myfile: data=myfile.readlines() print(data) file_read('test.txt')
a97f074c559e5a091ac66053e99a1d7207cbe638
arkimede/pysynfig
/objects/tags/Vector.py
794
3.703125
4
class Vector: def __init__(self, x,y): self.x = x self.y = y self.node = None def __init__(self,x,y,node=None): #self.x = x #self.y = y self.node = node self.setX(x) self.setY(y) def setNode(self, node): self.node = node def getNode(self): return self.node def getX(self):...
f2acc97bc0fd88d10227e6058e59f6bca19d7d4b
tugisuwon/hackerrank
/exp_by_square.py
213
3.546875
4
def exp_by_square(x,n): if n == 0: return 1 elif n == 1: return x elif n % 2: return x*exp_by_square(x*x,(n-1)/2) elif n % 2 == 0: return exp_by_square(x*x,n/2) print exp_by_square(2,15)
ea7073d46ec728db3e56ce941f8d13cf9b7f65ca
claraj/ProgrammingLogic1150Examples
/4_loops/while_loop_check_for_number.py
2,544
4.4375
4
""" What if your program expects a numeric value, for example, number = int(input('Please enter a number: ')) and a user types in 'cat' or something that is not a number? The program will crash with a message like this, Please enter a number: cat Traceback (most recent call last): File "while_loop_check_for_numbe...
169ae59347df9decf31556b69c85a1bc1c2c7bb2
masterugwee/StockDataAutomation
/stock.py
1,805
3.515625
4
#!/usr/bin/env python3 import sys import sqlite3 import os import datetime from tabulate import tabulate from time import sleep from pathlib import Path def stocks(con,cursor): print("Have you made any trades today(y/n)") checker = input() counter = 0 while(checker == 'y'): try: if(...
f4ae094851f1289d6a4c29395e8f0b19247a23f9
trueneu/algo
/interviewcake/delete_node_from_linked_list.py
886
3.90625
4
from copy import deepcopy class LinkedListNode: def __init__(self, value): self.value = value self.next = None a = LinkedListNode('A') b = LinkedListNode('B') c = LinkedListNode('C') a.next = b b.next = c head = a def delete_node_linear_with_head(node): global head prev_node = None ...
db13f1e386beb25e708bebd3428cdce9c22117c7
adithshetty1995/python-aws-materials
/python_oops.py
990
4.125
4
class Human: def __init__(self,h,w): self.h=h self.w=w def intro(self): print(f"Weight of the person is {self.w}") print(f"Height of the person is {self.h}") def set_height(self,height): # Set Function self.h=height def set_weight(self,weight): # Set Function ...
2549402c5b3103983e22d50054164a2703235dd3
superlk/python_study
/登陆时验证用户名和密码
1,986
3.515625
4
#!/usr/bin/env python #_*_coding:utf-8_*_ #用户名密码用:分割,让用户输入用户名和密码,判断是否能登陆 arr=['user:pwd','user1:pwd1','user2:pwd2'] while True: ra_user=raw_input('请输入你的用户名:') ra_pwd=raw_input('请输入你的密码:') a=ra_user+':'+ra_pwd #把两字符串拼接在一起,中间加: # a=':'.join([ra_user,ra_pwd]) 此方法也可以 print a if a in arr: ...
dbf504f7828433a7a0cf7d509e7b947417263c85
RobertNguyen125/PY4E
/ex_07_files/ex_07_01.py
185
3.765625
4
fname = input ('Enter file name: ') try: fhand = open(fname) except: print ('file name invalid') quit() for line in fhand: line = line.rstrip().upper() print(line)
a776828330d2a94c34c472695ab6f2c5826fe527
AlexAbades/Python_courses
/2 - Python Bootcamp/Lesson_3_Classes/Classes.py
8,903
4.78125
5
# Object Oriented Programming # Working with classes, the way to create our own objects import numpy as np class Sample: pass my_sample = Sample() print('my_sample type is: ', type(my_sample)) print('\n') class Cat: def __init__(self, breed): self.breed = breed my_cat = ...
70196630bf988ee8a1b2e572790180c78f77f4e9
JoseArtur/phyton-exercices
/cap3/c3e3.12.py
308
4.3125
4
#Write a program that calculate the time of a car trip.Ask the distance to go and the medium speed waited for the trip. dist=int(input("Type the distance of the trip(in km):")) speed=int(input("Type the medium speed waited(in km/h): ")) time=dist/speed print(f"The duration of the trip will be {time} hours")
8d089ac6a5d584d7d7c372d71c91e4ff7ac5b355
gyoomi/orange
/base/OOPDemo1.py
3,511
4.0625
4
#!/usr/bin/python3 # -*- coding: utf-8 -*- # @Author : Leon # @Version : 2018/8/27 15:33 # class Car: # def toot(self): # print("汽车在鸣笛!") # # def move(self): # print("汽车正在移动...") # # # bm = Car() # bm.color = "黑色" # bm.price = "35W" # print(bm.color) # print(bm.price) # bm.move() # bm.toot() ...
4892d1caf1525aef395453f52e2e9ded7e6b3159
mikhail-ukhin/problem-solving
/array-of-digits.py
1,021
3.71875
4
# Given a non-empty array of digits representing a non-negative integer, plus one to the integer. # The digits are stored such that the most significant digit is at the head of the list, and each element in the array contain a single digit. # You may assume the integer does not contain any leading zero, except the nu...
bad1b4da6b2f71ff1b10b565eb90547ac98d3503
sanshitsharma/pySamples
/strings/rabin_karp.py
2,321
4.1875
4
#!/usr/bin/python ''' Given a text txt[0..n-1] and a pattern pat[0..m-1], write a function search(char pat[], char txt[]) that prints all occurrences of pat[] in txt[]. You may assume that n > m. Examples: Input: txt[] = "THIS IS A TEST TEXT" pat[] = "TEST" Output: Pattern found at index 10 Input: txt[] = ...
35344c587916a80e6e8263a3730327729fbe3a1a
dltech-xyz/Alg_Py_Xiangjie
/第10章/feibo.py
404
3.875
4
#coding=utf-8 def fib_list(n) : if n == 1 or n == 2 : return 1 else : m = fib_list(n - 1) + fib_list(n - 2) return m print("**********请输入要打印的斐波拉契数列项数n的值***********") try : n = int(input("enter:")) except ValueError : print("请输入一个整数!") exit() list2 = [0] tmp = 1 while(tmp <= n): list2.append(fib_...
2bd1754993eed7fae3b9c641604ba061b8bf3d95
holyrib/Django
/Lab_1/informatics/for/j.py
60
3.546875
4
a = 0 for x in range(0, 100): a = a + int(input()) print(a)
7ac40e0bf69d64ce889f0fc2176a7803d3d51289
ledbagholberton/holbertonschool-machine_learning
/supervised_learning/0x05-regularization/5-dropout_gradient_descent.py
1,946
3.84375
4
""" updates the weights of a neural network with Dropout regularization using gradient descent: Y is a one-hot numpy.ndarray of shape (classes, m) that contains the correct labels for the data: classes is the number of classes m is the number of data points weights is a dictionary of the weights and biases of ...
e10965b9d7d525cbe88c16e7eba12c6a9df2d75a
magks/leetcode
/6. Zigzag conversion Difficulty: Medium.py
2,567
3.5625
4
#python3 class Solution: def convert(self, s, numRows): """ :type s: str :type numRows: int :rtype: str """ rowsOfLetters = [ [] for _ in range(numRows) ] # print(json.dumps( rowsOfLetters )) lastRow = numRows-1 firstRow = currentRow = 0 ...
7eccf101bad98e0ff156e8520a8e4dbf21f1d1bd
dougallison/udemy-pythonbootcamp
/15-DictionaryEx/ex33.py
775
4.21875
4
# List to Dictionary Exercise # Given a person variable: # person = [["name", "Jared"], ["job", "Musician"], ["city", "Bern"]] # Create a dictionary called `answer`, that makes each first item # in each list a key and the second item a corresponding value. # Output should look like this: # {'name': 'Jared', 'job': 'Mu...
d1b0dbd44cd3c3d1c54a354468c85bdb04bf2f48
cpalm9/PythonDataStructures
/recursionPractice.py
316
3.546875
4
import os def search_directory(level, dirname): # search the dirname print(level, '>>>>>', dirname) #recurse through the directories for fn in os.listdir(dirname): path = dirname + '/' + fn if os.path.isdir(path): search_directory(level + 1, path) search_directory(0,'.')
b51dea523548cbd88e3e697be055dba26fe31eb8
jethropalanca/Quantnet_Python
/Level1/Section1_2/Exercise6.py
384
4.25
4
''' This program creates a list comprehension that results in a list of the squares of all numbers 0 through 100. ''' def main(): list_square = [i**2 for i in range(101)] list_1000 = [value for value in list_square if value > 1000] list_even = [value for value in list_1000 if value%2 == 0] print(list_...
50b5a2ae8f9b1e38c9ae3fdb89f416fdbc4cbc58
johnhuzhy/StellaPythonExam
/src/practiceFunction/h11.py
519
3.859375
4
# def demo(): # c=10 #局部变量 # #NameError: name 'c' is not defined # print(c) def demo1(): c=50 for i in range(0,3): a='abc' c+=1 print(c) #和Java不同之处,在Java里不能调用for循环里定义的变量,如果想要用,就先要提到for循环外,在里面改变。然后for循环外就可以调用了 #python里for循环外直接可以调用for循环里定义的变量。因为python没有块级作用域,只有函数作用域 print(a)...
967811ae0646a86f3280f7faac84b72c02e00daf
JacekGorski01/KursPython
/homeworks/day6/picle_loader.py
3,410
3.75
4
import pprint import pickle import random from create_menu import menu_builder from datetime import datetime def search_book(string): '''Search substring in strings - values in dictionary and print them Parameters: string (str) - piece of string you want to find Return: None ''' ...
30afe757f2effb046d6354ed49bde93a9b880db0
og-python-scripts/Automate-the-Boring-Stuff-with-Python-2015
/pg.106.sublists.slices.py
1,919
4.5
4
spam = ['cat', 'bat', 'rat', 'elephant'] spam[0:4] ['cat', 'bat', 'rat', 'elephant'] spam[1:3] ['bat', 'rat'] spam[0:-1] ['cat', 'bat', 'rat'] spam = ['cat', 'bat', 'rat', 'elephant'] spam[0:4] ['cat', 'bat', 'rat', 'elephant'] spam[1:3] ['bat', 'rat'] spam[0:-1] ['cat', 'bat', 'rat'] spam[:] ['cat', 'bat', 'rat', 'el...
996a1242575fdbc346f6979313ecad37ea1fbc0a
boulund/qnr-assembly
/extract_from_fasta.py
2,889
3.609375
4
#!/usr/bin/env python3.5 # Fredrik Boulund 2016 # Extract sequences from a FASTA file from read_fasta import read_fasta from sys import argv, exit, maxsize import argparse import re def parse_args(argv): """ Parse commandline arguments. """ desc = """Extract sequences from FASTA files. Fredrik Boul...
a813bb350e3cbbae1dd72b9442c09da1192250b2
RadkaValkova/SoftUni-Web-Developer
/Programming Fundamentals Python/18 Objects and classes/Party.py
756
3.734375
4
# class Party: # def __init__(self): # self.people = [] # # # party = Party() # # while True: # line = input() # if line == 'End': # break # name = line # party.people.append(name) # # print(f"Going: {', '.join(party.people)}") # print(f'Total: {len(party.people)}') class Party: ...
069363c29ada4822bc4f12bbe0bea3e22839dc4a
annewoosam/underpaid_customers
/underpaid_customers2.py
1,918
4.21875
4
MELON_COST = 1.00 def print_payment_status(payment_data_filename): """Calculate cost of melons and determine who has underpaid.""" payment_data = open(payment_data_filename) # open the file # Iterate over lines in file for line in payment_data: # Split line by '|' to get a list o...
667288bd35135f81ce23f67fa61468f83b5cdc06
edu-athensoft/ceit4101python
/stem1400_modules/module_6_datatype/m6_2_list/list7_remove.py
434
4.15625
4
# remove items from list my_list = ['p','r','o','g','r','a','m','i','z'] # remove() - remove one item my_list.remove('p') print(my_list) my_list = ['p','r','o','g','r','a','p','m','i','z'] # remove() - remove one item my_list.remove('p') print(my_list) my_list = ['p','r','o','g','r','a','p','m','i','z'] # remove...
e844701ed4a7d484bed55731241ab1b80775160d
JosephLevinthal/Research-projects
/5 - Notebooks e Data/1 - Análises numéricas/Arquivos David/Atualizados/logDicas-master/data/2019-1/223/users/4343/codes/1644_1053.py
189
3.984375
4
patrono = input("Qual o nome do patrono?") if(patrono == "cervo") mensagem = "cervo eh patrono de Harry Potter" else: mensagem = patrono + "nao eh patrono de Harry Potter" print(mensagem)
60a71455396e3d7c61227c04a44523efb6182a6a
andrezzadede/Curso-de-Python-POO
/polimorfismo.py
1,171
4.09375
4
# Quando um método é chamado por outra classe e é utilizado de outra forma import math class Forma(): def __init__(self): # Inicializador de instancia/ Construtor print('Construtor da forma') def area(self): print('Area da forma') def perimetro(self): print('Perimetro da forma') ...
839c8d3495c8c9ca1740386a60acabcdf6250285
ysze/python-refactorings
/week3/refactored.py
1,167
4.28125
4
def create_pixel_row(width, pixel): """ creates and returns a "row" of pixels with the specified width in which all of the pixels have the RGB values specified by pixel. input: width is a non-negative integer pixel is a list of RBG values of the form [R,G,B], wher...
d49324055676a2756bbec94103360ef8e370d288
gabriel-roque/python-study
/01. CursoEmVideo/Mundo 01/Aula 07 - Operadores Aritimeticos/Desafio09.py
582
3.921875
4
valor = int(input('De qual numero gostaria obter a tabuada: ')) print('-------------') print('{} x 1 = {}'.format(valor,(valor*1))) print('{} x 2 = {}'.format(valor,(valor*2))) print('{} x 3 = {}'.format(valor,(valor*3))) print('{} x 4 = {}'.format(valor,(valor*4))) print('{} x 5 = {}'.format(valor,(valor*5)...
4e6842d9f53c4758de4a8bdb5814dd3832d27866
Zahidsqldba07/CodeSignal-26
/Intro/Rains of Reason/028 - alphabeticShift.py
151
3.625
4
def alphabeticShift(inputString): res = '' for c in list(inputString) : res += chr(97) if ord(c)==122 else chr(ord(c)+1) return "".join(res)
816c1d3e1e6931d218cb81285fea98d747e3e974
marco9663/Command-line-chess-game
/Queen.py
1,519
3.59375
4
from termcolor import colored from Coordinate import Coordinate as C from Move import Move White = True Black = False class Queen: value = 90 def __init__(self, board, side, coord, movesMade=0): if side: self.side = White self.direction = -1 else: self.sid...
e2e037efd8c9afb004cdfaa60cc3c95e3f494cff
Aasthaengg/IBMdataset
/Python_codes/p03555/s343436550.py
100
3.875
4
a = input() b = input() b_reverse = b[::-1] if a == b_reverse: print('YES') else: print('NO')