blob_id
stringlengths
40
40
repo_name
stringlengths
5
127
path
stringlengths
2
523
length_bytes
int64
22
545k
score
float64
3.5
5.34
int_score
int64
4
5
text
stringlengths
22
545k
072dcd8e43d0c7ef4fb8d027a74dcf71f2cfaff2
neochen2701/TQCPans
/程式語言 V2答案檔/Python/306.py
173
3.890625
4
# python print '!=' as '≠' def compute(x): cnt = 1 for i in range(2, x+1): cnt *= i return cnt x = int(input()) print(str(x) + '!=' + str(compute(x)))
1f9a4fd2fbab51a24c4ce49237e991a70e23be43
neochen2701/TQCPans
/程式語言 V2答案檔/Python/606.py
249
3.640625
4
for i in range(3): number = input() cnt = ((int(number[0]) + int(number[2]) + int(number[4])) + ((int(number[1]) + int(number[3])) * 5))% 26 if cnt == ord(number[-1]) - ord('A') + 1: print('Pass') else: print('Fail')
075944abd879b9bcf298e92ddb78ece47dc3c02e
neochen2701/TQCPans
/程式語言Python 3答案檔/PYA203.py
147
4.125
4
year = int(input()) if year%400==0 or (year%4==0 and year%100!=0): print(year, "is a leap year.") else: print(year, "is not a leap year.")
0e734f3168962bd6e25cecc2b1a3276c9784af36
neochen2701/TQCPans
/程式語言Python 3答案檔/PYA206.py
188
3.875
4
score = eval(input()) if 80 <= score <= 100: grade = 'A' elif 70 <= score <= 79: grade = 'B' elif 60 <= score <=69: grade = 'C' elif score <= 59: grade = 'F' print(grade)
c0712277b57e69ecd3da3acc62533667e6b894ef
neochen2701/TQCPans
/程式語言Python 3答案檔/PYA506.py
444
3.75
4
def compute(a, b, c): delta = b**2 - 4 * a * c if delta < 0: return None elif delta == 0: return -b / (2 * a) else: res1 = (-b + delta**0.5) / (2 * a) res2 = (-b - delta**0.5) / (2 * a) return str(res1) + ", " + str(res2) a = eval(input()) b = eval(input()) c =...
8a46df8921f35971dbc4f2a1c446e1596206c938
neochen2701/TQCPans
/程式語言Python 3答案檔/PYA807.py
122
3.515625
4
s = input() slist = [int(x) for x in s.split(' ')] print("Total =", sum(slist)) print("Average =", sum(slist)/len(slist))
45ea510dda932e81decf9670e714f740c6044216
gharnett/the-log-book
/updnDiv.py
1,702
3.609375
4
def div(x, b): """Return quotient of x by b using the upscale-downshift logarithm algorithm, mutatis mutandis""" import sys # prepare inputs and parameters # b = (divisor of quotient) if b == 0.0: print "We don't divide by zero."; sys.exit() elif b < 0.0: br = -b; oppb = -1 ...
0aaae3026d9b88f7fede9735dcca5027800945bc
Diva-Pant/OpenCV
/draw.py
1,262
3.796875
4
import cv2 as cv import numpy as np #Creating blank images blank = np.zeros((500,500,3), dtype = 'uint8') #cv.imshow('Blank', blank) # 1.Paint the image a certain color #blank[:] = 0,255,0 #cv.imshow('Green', blank) # 2. Paint certain portion of images #blank[200:300,300:400] = 0,255,0 #3. Draw the rectan...
399b26576a459bcf274b981ee1ebe4f52bb66bb6
harideepusappa/DataStructures-python
/Tree.py
2,493
4.0625
4
class Node: def __init__(self, value): self.left = None self.data = value self.right = None class Tree: def createNode(self, data): return Node(data) def insert(self, node , data): if node is None: return self.createNode(data)...
f97136d46bb546d641e9eaf28896181f38c6518a
AlvinOng98/CP1404_Practicals
/Prac_05/word_occurrences.py
841
4.03125
4
""" CP1404/CP5632 Practical 4 Student Name: Alvin Ong Zhi Xiang Word occurrences """ def main(): input_str = input("Please enter a string: ") print("") print("Text: {}".format(input_str)) word_count = occurrences(input_str) # sort dictionary by using sorted() that sorts into a tuple # by keys...
bd9afbd459e5f0e1e72e7a6d93e257bc20f85e42
AlvinOng98/CP1404_Practicals
/Prac_02/files.py
536
3.65625
4
""" CP1404/CP5632 - Practical 2 Student Name: Alvin Ong Zhi Xiang Files """ out_file = open("name", 'w+') with open("name", "w+") as name: name.write(input("Please enter your name:")) output = out_file.read() print("Your name is", output) print("") out_file.close() in_file = open("numbers.txt", "r") result = 0...
986f98966bf3ffc56c2dd424567688f778270979
pantherfire/Timus
/Q1011Conductors_timeout.py
2,087
3.5625
4
''' Created on Feb 6, 2018 @author: root ''' ''' def get_pq(): p_percent = None q_percent = None got_num = 0 while got_num < 2: line_without_space = input().replace(" ", "") if line_without_space != "": if got_num == 0: p_percent = round(float(line_without_s...
190145631d89b0ceb2675995d25c79dbbf763213
pantherfire/Timus
/Q1017Staircases.py
701
3.640625
4
''' Created on 2018 Feb 12 @author: surface ''' import math if __name__ == '__main__': n = int(input()) stair_dicts = {} for i in range (1,n+1): #initial the dicts and add the elements stair_dicts[i] = {1:1} for i in range(1,n+1): for j in range(2,n+1): ...
fd02ff3da9867c20f519a4644ffc6e18fb3103bf
LauchieHarvey/game_of_life
/main.py
8,503
3.59375
4
import pygame import random from matplotlib import pyplot as plt import numpy # CONSTANTS # You can change these to modify user experience: GRID_SIZE = 50 INITIAL_CELL_COUNT = 0 WIN_DIMENSIONS = (800, 800) # width, height WHITE = (140, 140, 140) BLACK = (0, 0, 0) # Leave these constants alone unless you know what yo...
5e53080b0af272b0d9f0aa69e542bbaaa9af09f5
Azeem-Q/Py4e
/ex84.py
711
4.28125
4
""" 8.4 Open the file romeo.txt and read it line by line. For each line, split the line into a list of words using the split() method. The program should build a list of words. For each word on each line check to see if the word is already in the list and if not append it to the list. When the program completes, sort a...
7a057d5e54abae7fc34c95c27db857cad026bd19
Azeem-Q/Py4e
/ex94.py
1,049
4.03125
4
""" 9.4 Write a program to read through the mbox-short.txt and figure out who has sent the greatest number of mail messages. The program looks for 'From ' lines and takes the second word of those lines as the person who sent the mail. The program creates a Python dictionary that maps the sender's mail address to a coun...
447f347fe9261951e27c3246bab7f1aa0b1fb9fa
gopal97-beep/python-assignment
/assignment/day3/encapsulation.py
1,329
3.875
4
class person: """this is for oop""" team="konoha" #class level encapsulation def sayjhi(p): print("santoruo"+p.name+" "+p.lname) def __init__(o,f,l): o.name = f o.lname = l def __del__(self): print("destructor called for"+self.name+self.lname+self.team) ...
b2e3fe34044aeb0ce54901bfecfd3fcb8f19d66d
gopal97-beep/python-assignment
/assignment/day1/pattern3.py
78
3.671875
4
i=int(input("Enter n:")) for n in range(i,0,-1): print(((i-n)*' '),n*'*')
81a1d000528055d643e6db6778b7609a4f556023
Botany-Downs-Secondary-College/practice-assessment-RyanVIK
/GUI Maths Program.py
13,227
3.84375
4
from tkinter import * from random import* import tkinter as tk root = tk.Tk() score = 0 total = 0 def next_problem(): global x global y global problem_label global answer_entry global problem_text x = randrange(10) y = randrange(10) problem_text = str(x) + " + " +st...
cf34ecf9f1f6c0cc0c0b792c262c701454bd1eac
lamstephanie/sasmodels
/sasmodels/kernelcl.py
19,823
4.125
4
""" GPU driver for C kernels There should be a single GPU environment running on the system. This environment is constructed on the first call to :func:`env`, and the same environment is returned on each call. After retrieving the environment, the next step is to create the kernel. This is done with a call to :meth:...
cc5839e5ac8f647f51bd1735f9a46018f5ce384a
mehnazchyadila/Python_Practice
/for=loop.py
123
3.953125
4
i=1 while i<=100: print(i) i=i+2 print("Even Number") i=2 while i<=100: print(i) i=i+2 print("Program End")
4959abf41dc25e142cdc57f82ef7e1678868f915
mehnazchyadila/Python_Practice
/excercise/Sum_of_First_N_Pos_Int.py
138
3.984375
4
# How to Sum of the First N Positive Integers in Python n = int(input("Enter the value of N : ")) sum = n * (n + 1) / 2 print(sum)
da35a0922c0cfc44c09e239a9570d78a99eed898
mehnazchyadila/Python_Practice
/program19.py
631
3.875
4
# Some function subjects =["C" , "C++" ,"Java" ,"Basic"] length = len(subjects) print(length) #print(len(subjects)) subjects.append("TOC") print(subjects) subjects.insert(2,"Python") print(subjects) subjects.remove("C++") print(subjects) subjects.sort() print(subjects) subjects.reverse() print(subjects) subjects...
7dcaaef2c96df0c369667bcd25c5613742fec825
mehnazchyadila/Python_Practice
/program43.py
447
3.90625
4
# File Writing """ If we write [open("student.txt","w")] it overlap the existing text file .For this we write [open("student.txt","a")] . It add the addition value with the existing file . """ file = open("student.txt","a") file.write("Rista Chowdhury - Studied in class Nine") file = open("student1.txt","a") file.wri...
9cc61d67204d972a70529b1bb4e101a1e5ae0952
mehnazchyadila/Python_Practice
/Magic_methods.py
686
4.0625
4
# Magic methods """ __eq__(self,other) == __lt__(self,other) < __le__(self,other) <= __gt__(self,other) > __ge__(self,other) >= __ne__(self,other) != __init__(self) __str__(self) __add__(self,other) __sub__(self,other) __mul__(self,other) __div__(self,other) """ class Bike: def __init__(self,...
c48d98df8de36c4d645307f14aef87d691a8f09b
mehnazchyadila/Python_Practice
/program47.py
416
4.03125
4
# Class & Object in python class student(): roll = "" gpa = "" rahim = student() # An Object Of Student Class print(isinstance(rahim ,student)) rahim.roll = 101 rahim.gpa = 3.50 print(f"Rahim's Roll: {rahim.roll} , Rahim's GPA : {rahim.gpa}") karim = student() print(isinstance(karim ,student)) karim.roll ...
4877cfe0219914090f0eb38fec32a4cdafb780ec
mehnazchyadila/Python_Practice
/program45.py
512
4.15625
4
""" Exception Handling """ try: num1 = int(input("Enter Any Integer number : ")) num2 = int(input("Enter any integer number : ")) result = num1 / num2 print(result) except (ValueError,ZeroDivisionError,IndexError): print("You have to insert any integer number ") finally: print("Thanks") def voter...
93d40e60956d2236b7fb1878833db008dbd7a713
mehnazchyadila/Python_Practice
/program32.py
361
3.75
4
# Function def add(x,y): sum = x+ y print(sum) add(20,30) add(40,50) def addition(a,b,c): sum = a + b + c print(sum) addition(12,32,45) def sub(x,y): sum = x - y print(sum) sub(20,30) sub(40,50) def subtraction(a,b,c): sum = a - b - c print(sum) subtraction(12,32,45) def message...
a6297ee56ac50f283d064ca871c360abbcd20fcd
modcomlearning/advanced_web
/OOP.py
1,644
3.828125
4
# a bank object class Account: def __init__(self): self.name = 'Your Name' self.branch = 'Waiyaki way' self.age = 10 self.accno = 1000050 self.balance = 50 # we define the atributes of states of your account # behavior deposit, withdraw, buyairtime, checkbalanc...
5cc179d85cbd098f4bcbec6ef1f759881fec6301
gondo321/TRAMPO-BD
/tabelaCliente.py
1,896
3.6875
4
# coding: utf-8 #Importar biblioteca import sqlite3 from getpass import getpass #Criação da tabela def tabela_cliente(conexao): cursor = conexao.cursor() sql = ''' CREATE TABLE IF NOT EXISTS cliente( nome TEXT NOT NULL, data_nasc TEXT NOT NULL, bairro TEXT NOT NU...
03880a31d598b138bea944a0a74942deed0ff3eb
name-hacke/python
/authentication.py
1,098
3.875
4
import os cur_dir = os.getcwd() enter = input('do you want to login or signup ') if enter == 'signup': username = input("Enter the user name ") password = input("Enter your password ") filepwd = open(username + password+".txt","w+") filepwd.write(password) filepwd.close() details = inpu...
87c7fa65332cd453521fbc957b430fd2878e2eb8
antoniougit/aByteOfPython
/str_format.py
916
4.34375
4
age = 20 name = 'Swaroop' # numbers (indexes) for variables inside {} are optional print '{} was {} years old when he wrote this book'.format(name, age) print 'Why is {} playing with that python?'.format(name) # decimal (.) precision of 3 for float '0.333' print '{0:.3f}'.format(1.0/3) # fill with underscores (_) with...
688207b1b06c3d594e2dbf5e13cbd9e1bacf5738
danmartinez78/AutonomousRover
/simulator/KalmanFilter.py
6,701
3.5
4
#!/usr/bin/python import numpy as np import matplotlib.pyplot as plt from matplotlib import animation from matplotlib import patches # import pylab import time import math from numpy.linalg import inv class KalmanFilter: """ Class to keep track of the estimate of the robots current state using the Kalman ...
63bfd50d7bb68d12f2e590b12e2985372b082d48
parastooh79/image_processing
/grayscale-invert.grayscale.py
534
3.640625
4
import numpy as np import matplotlib.pyplot as plt import cv2 image = cv2.imread('infile.jpg') image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB) def rgb2gray(image): gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY) plt.imshow(gray, cmap= 'gray') plt.show() ...
f0816e433a5c7e300f913c571a6fa1145a272706
kangyul/Python
/list.py
1,182
4.5625
5
# List - use "[]"" subway = ["Terry", "Sebastian", "Dylan"] print(subway) # ['John', 'Tim', 'Dylan'] # .index finds an index of an element print(subway.index("Dylan")) # 0 # .append inserts a new element at the end of the list subway.append("Justin") print(subway) # ['John', 'Tim', 'Dylan', 'Justin'] # inserting a...
4f272c2c779150ca8ad15a521ae72675aca2c7fc
maxttor/study_python
/005.py
576
3.71875
4
#Task description: https://stepik.org/lesson/24471/step/6 import re import requests a = input() b = input() def spider(a, b, depth=0): result = requests.get(a) if result.status_code != 200: return False else: links = re.findall(r"<a.+href=\"(.+)\">", result.text) for link in links...
3646fe68cd86c577336fd3f4364a826799ca419f
heroFFF/python
/ex5_2.py
420
4.03125
4
def isOdd(n): if n%2 == 1: return True else: return False while True: s = input("Plese enter an Integer:") if not s.isdigit(): print("Please enter again!") continue n = eval(s) if n == -1: print("program is over!") break if...
50b70c4afc649d7edd3186a22d1cbcae1ed60333
himol7/Sosio-Submission
/Python/python1.py
251
3.640625
4
# -*- coding: utf-8 -*- """ Created on Sun Dec 30 20:03:16 2018 Compress the String! @author: Himol Shah """ from itertools import groupby x = input() a = [] for k, d in groupby(x): a.append(((len(list(d))), int(k))) print(*a)
4cbac350ae670893f55099e23c1a92d25080ceb5
AndradeLaryssa/Python
/Habitantes.py
1,366
3.71875
4
nomes = [] salarios = [] sexos = [] idades = [] habitan = [] mulheres = 0 while(True): nome = input('Digite o nome do habitante responsável: ') nomes.append(nome) salario = int(input('Digite o sálario do responsável: ')) salarios.append(salario) sexo = input('Digite o sexo do responsável[M/F]: ') ...
12d9402a73059effd411ba5ae8b7ec3a9c9ef352
AndradeLaryssa/Python
/Covid.py
853
3.8125
4
obitos = [] positivos = [] cidades = [] while(True): print('\nPara interroper a leitura digite o código como -1') codigo = int(input('\nDigite o código do estado: ')) if codigo == -1: break nome = input('Digite o nome do estado: ') cidades.append(nome) positivo = int(input('Digite a quantidade de pacie...
ddfc821b45dbafb0b6655f250c87537498066707
gunjanpatidar13/Python-Project
/8.py
288
4
4
# -*- coding: utf-8 -*- """ Created on Thu Mar 14 20:43:11 2019 @author: Administrator """ num=int(input("Enter a number:")) flag=0 for i in range(2,num): if(num%i==0): flag=1 if(flag==0): print("Prime Number") else: print(" Not Prime Number")
958e9ad8d6c2e145e24b84409225b7f69afe7c6f
gunjanpatidar13/Python-Project
/3.py
272
3.96875
4
# -*- coding: utf-8 -*- """ Created on Thu Mar 14 20:26:40 2019 @author: Administrator """ a,b,c=input("Enter three numbers:").split() if(a>b and a>c): print(a,"is Greatest") elif(b>c and b>a): print(b,"is Greatest") else: print(c,"is Greatest")
bd2d7b5e14cfcd1afdee8400f7eeadfa24cb13a7
MarkHXB/Python
/Day_02/project.py
688
4.28125
4
""" Tip calculator """ bill = float(input("What was the total bill? $")) tip = int(input("What percentage tip would you like to give? 10, 12 or 15 ")) people = int(input("How many people to split the bill? ")) #my own derivation bill_people = bill/people tip_per_person = bill_people * (tip/100) total_amount_of_tip_per...
e1273985dbf6124f0bfd1fab8daeabd0d71ce59c
gergely-k5a/building-ai
/3. Machine learning/1. Linear regression/11b. linear-regression.py
424
3.671875
4
# Linear regression import numpy as np # input values for three mökkis: size, size of sauna, distance to water, number of indoor bathrooms, # proximity of neighbors X = np.array([[66, 5, 15, 2, 500], [21, 3, 50, 1, 100], [120, 15, 5, 2, 1200]]) c = np.array([3000, 200, -50, 5000, 100]) # coefficient value...
7f7039b798df1ae0a938952e514c5965342691e7
LogicallySpeakingLaura/coding-bat
/python/warmup-2.py
2,992
3.90625
4
""" Author: LogicallySpeakingLaura Date last modified: 2020/10/29 Medium warmup string/list problems with loops. https://codingbat.com/python/Warmup-2 """ def string_times(str, n): """ Given a string and a non-negative int n, return a larger string that is n copies of the original string. """ return st...
8011ad2639e721b9ef9fc46b0b8e97e84cfe3668
anniemou/dojoassignments
/Python/Dictionary_Basics.py
462
3.96875
4
#!name, age, country of birth, favorite language. # #My name is Anna # #My age is 101 #My country of birth is The United States #My favorite language is Python ############################################################### info2 = {"name": "Anna", "age": 101, "country of birth": "The United States", "favorite language...
3c111a7574885c789da1b6971ac8a79a4bd8be30
nuaalixu/pyos
/pyos/task.py
1,536
3.828125
4
"""A task is a wrapper around a coroutine.""" from typing import Generator from pyos.systemcall import SystemCall class Task(object): """This object encapsulates a running task.""" taskid = 0 def __init__(self,target): Task.taskid += 1 self.tid = Task.taskid # Task ID self...
9b9edc35e7d301379f721fb40f4534c533772455
alexandrugeorgemadalin/Blackjack-Game
/Main.py
3,838
3.5
4
import Package as Package import Player as Player import Dealer as Dealer if __name__ == '__main__': pack = Package.Package() pack.create_pack() pack.shuffle() dealer = Dealer.Dealer() f = open("ListaParticipanti.txt", "r") data = f.readlines() players = [] for line in data: w...
64cc17ae8701d7c5769bc41f8fcb7ac312e634ce
Yan30672/python
/textbook/Ex5.1.py
241
3.625
4
def honai(n,A,B,C): if n == 1: return [(A,C)] else: return honai(n-1,A,C,B)+honai(1,A,B,C)+honai(n-1,B,A,C) n = int(input('請輸入盤數:')) for move in honai(n,'A','B','C'): print('盤由 %c 移到 %c' % move)
a26370dc32ffeaf42b9b412358575e8b73e34465
Yan30672/python
/雜想/Sierpinski.py
604
3.5625
4
import matplotlib.pyplot as plt import random number = 0 a1 = 3 a2 = 2 plt.scatter(3, 2) plt.scatter(0, 0) plt.scatter(5, 0) plt.scatter(3, 4) def midpoint(x1, y1, x2, y2): return ((x1 + x2) / 2, (y1 + y2) / 2) while number != 1000: c = random.randint(1, 6) if 1 <= c <= 2: (a1, a2) = midpoint(a...
fddd7de4ec082000d0b2a7db7e4a066e9f908d53
Yan30672/python
/textbook/Ex4.4.py
186
3.640625
4
# 找出周長為24,三邊長都是整數的直角三角形 num = range(1,24) edge = [(a,b,c) for a in num for b in num for c in num if a+b+c == 24 if a**2+b**2 == c**2] print(edge)
ab9677f3c65e98b11bd1fc4705f89abc67d5d99f
ronjacobvarghese/cp-python
/data centre.py
151
3.6875
4
a=int(input()) b=a**(1/2)//1 if b==a**(1/2): print('%d'%(b*4)) else: while a%b!=0: b=b+1 d=a/b print('%d'%(2*(d+b)))
de26aa786a1789cc6396d6dcaba471eb8d77d470
ronjacobvarghese/cp-python
/life without zeroes.py
133
3.671875
4
a=input();b=input() print('YES' if str(int(a)+int(b)).replace('0','')==str(int(a.replace('0',''))+int(b.replace('0',''))) else 'NO')
8271262f63453ddd5ec5ff88bab498e6727e4ea1
ronjacobvarghese/cp-python
/stringly.py
80
3.5
4
a=input() if 'ing' in a[(len(a)-4):]: a=a+'ly' else: a=a+'ing' print(a)
ef2b0cdcbef6374355d28f45cbc08700cf2d1ef5
ronjacobvarghese/cp-python
/word.py
152
3.703125
4
a=input() c=0 b=0 for i in a: if i.isupper(): b+=1 else: c+=1 if b>c: print(a.upper()) else: print(a.lower())
dec1dd454ca2ccf65878d292652a850420a41aff
NiuYao0033/chujizhishi
/43.py
199
3.8125
4
for number in range(2,100): for number1 in range(2,number): if number%number1 == 0: break number1 +=1 else: print(number,end=',') number +=1 print('')
48377d662c652668f8523917be9943e4fdfe8795
NiuYao0033/chujizhishi
/7.py
175
3.734375
4
print('父亲的身高:/cm') a = float(input()) print('母亲的身高:/cm') b = float(input()) print('------------') c = (a+b)*0.54 print('儿子的身高:/cm') print(c)
a897287bb031e7e14e7a162fcbd2555713368dc7
NiuYao0033/chujizhishi
/28.py
462
3.828125
4
age = int(input('请输入年龄:')) subject = input('请输入专业:') college = input('是不是重点大学毕业?') if subject == '电子信息工程专业' and age > 25: print('恭喜您,面试合格') elif subject == '电子信息工程专业' and college == '是': print('恭喜您,面试合格') elif age < 28 and subject == '计算机专业': print('恭喜您,面试合格') else: print('抱歉,您未达到面试要求')
c729e69c8a22f9b5dbef64bcfe4a731eae93f4f5
NiuYao0033/chujizhishi
/17.py
613
4.09375
4
name = '小明' height = 1.75 weight = 80.5 BMI = int(weight/(height**2)) if BMI <= 18.5: print(name,height,weight,BMI) print('测试结果:过轻。') elif BMI > 18.5 and BMI <= 25: print(name,height,weight,BMI) print('测试结果:正常。') elif BMI > 25 and BMI <= 28: print(name,height,weight,BMI) print('测试结果:过重。') elif B...
c8ea9d277c47ccc4bae9a1b3a696689dfc755269
NiuYao0033/chujizhishi
/16.py
1,793
3.71875
4
print('请输入姓名') name = input() print('1.水瓶座:1.20-2.18') print('2.双鱼座:2.19-3.20') print('3.白羊座:3.21-4.19') print('4.金牛座:4.20-5.20') print('5.双鱼座:5.21-6.21') print('6.巨蟹座:6.21-7.22') print('7.狮子座:7.23-8.22') print('8.处女座:8.23-9.22') print('请根据如上提示选择对应编号') xingzuo = int(input()) print('请输入日期:××.××') date = float(input()) i...
0b1225824735f8ea11d3b76bcbe706475c07e628
S-Haile/JavaProjects
/SnapShop/doc/time340.py
13,569
3.78125
4
#Samson Haile #CSS 340 #10/6/17 #Prog 1: TimeSpan # This class represents a TimeSpan, and overloads operators allowing for the addition, subtraction, division, and multiplication of them (among other functions). class TimeSpan: def __init__(self, seconds = 0 , minutes = 0, hours = 0): self.__seconds ...
56a8b63c88b9eb29967cdbbf520db18e443f4ce9
borko81/Algorithms-Data-Structures-Python
/arrays/reverse_array_in_list.py
346
4.1875
4
def reversed_array(nums): start_index = 0 end_index = len(nums) - 1 while end_index > start_index: nums[start_index], nums[end_index] = nums[end_index], nums[start_index] start_index += 1 end_index -= 1 return nums if __name__ == '__main__': n = [1, 2, 3, 4, 5, 6, 7, 8] ...
d21ef654b3c41909eef25186a7e5ac14e9772c38
borko81/Algorithms-Data-Structures-Python
/stack/tracert_max_element_in_stack.py
737
3.78125
4
class MaxStack: def __init__(self): self.main = [] self.max_in_main = [] def push(self, data): self.main.append(data) if self.len_of_main == 1: self.max_in_main.append(data) return temp_variable = self.max_in_main[-1] if data > temp_var...
c457bdbe385fa0e6347a66f6ddf2dac40538b12e
Nikita-99/1lab
/1.1.py
477
3.84375
4
print("Введите a") a = int(input()) print("Введите b") b = int(input()) print("Введите c") c = int(input()) print("Введите k") k = int(input()) try: s = (a**2/b**2+c**2*a**2)/(a+b+c*(k-a/b**3))+c+(k/b-k/a)*c if s > 0: print(s) else: print(-s) except ZeroDivisionE...
18fc00397361c93c36c9a702bf31d6a4c0a75d8f
trqmhd/udemy_tryout
/database_sqlite3/script.py
1,246
3.5625
4
import sqlite3 def create_table(): connection = sqlite3.connect("lite.db") cursor = connection.cursor() cursor.execute("CREATE TABLE if not exixt store(item text, quantity integer, price real)") connection.commit() connection.close() def insert(item, quantity, price): connection = sqlite3.con...
8fd8dcab7f35affa6f1fc04eaffc7e3d4d4f4235
vhdinh/Python-ScoreGrades
/ScoreGrades.py
535
4
4
print "score and grades" for i in range(1,11): score = input("enter your score:") if score <= 59: print "score: %s; You failed :( " % score elif score > 59 and score < 70: print "score: %s; Your grade is D" % score elif score > 69 and score < 80: print "score: %s; Your grade is C" %...
1f866cb95d70245df5e8c8c4839d563dc1476d92
kubos777/cursoSemestralPython
/CodigosClase/Funciones/funciones2.py
1,252
4.03125
4
# -*- coding: utf-8 -*- #Parámetros por omisión, keywords """def saludar(nombre,mensaje='gfadgfadgfadgfa'): print(mensaje,nombre) saludar(nombre=input("Cómo te llamas?")) """ def recorre_parametros_arbitrarios(parametro_fijo,*arbitrarios): #Los parametros "arbitrarios" se guardaran en una tupla for argumento in arbi...
2dfb298dcdf0fe21871ae65949518515a088d7dd
kubos777/cursoSemestralPython
/CodigosClase/Objetos/Abstraccion-Clases-objetos-MetodosY-funcionesdeClase/Persona3.py
1,494
4.125
4
#*-* coding:utf-8*.* class Persona3: #Definimos el constructor def __init__(self,nombre1,apellido1,edad1,estatura1,dinero): self.nombre=nombre1 self.apellido=apellido1 self.edad=edad1 self.estatura=estatura1 self.dinero=dinero print("Hola soy ",self.nombre," ",self.apellido,",tengo",self.edad,"años y mido...
28d19efe095993d7b436dddf318ce5f6dd7d2c04
kubos777/cursoSemestralPython
/CodigosClase/TiposDeDatos/conjuntos.py
698
4.125
4
########### # Conjuntos ########### conjunto={1,2,2,3,4,5} print("Tipo de dato: ",type(conjunto)) print(conjunto) conjunto2=set([1,"A","B",2,1]) print(conjunto2) print("Tipo de dato: ",type(cadena)) print("Indexacion: ",cadena[0]) print("Indexacion negativa: ",cadena[-1]) print("Tamaño: ",len(cadena)) print("Conca...
0ead4c23ae645c62a05e0fcc15e59425f5e48f30
kubos777/cursoSemestralPython
/Tareas/SolucionesTarea3/tarea3P9.py
597
3.96875
4
################################################################################################# # Tarea 3 , Problema 1 # Escriba un programa de Python que calcule el factorial de un número. # Ejemplo: Factorial de 5 = 5 x 4 x 3 x 2 x 1 = 120 # NOTA: Factorial de 0 = 1. ################################################...
913a9d30131c1d004e65fddf5a21a5741dd2fbf9
pperorin/Data-Struct
/2.1 Simple OOP Calculator.py
199
3.703125
4
def findMinimum(l): if len(l) == 1: return l[0] else: return min(l[0], findMinimum(l[1:])) x=list(map(int,input('Enter Input : ').split())) print('Min :',findMinimum(x))
59aa7c686476893de6339bba89ead80ac5d0b928
pperorin/Data-Struct
/4.2 Queue.py
1,116
3.5625
4
class Queue(): def __init__(self,lst = None): self.lst = lst if lst is not None else [] def size(self): return len(self.lst) def isEmpty(self): return len(self.lst) == 0 def top(self): return self.lst[0] def enQ(self,obj): self.lst.append(obj) def deQ(self...
8f590bec22c64d0c9d89bfcc765f042883955a02
tprhat/codewarspy
/valid_parentheses.py
807
4.34375
4
# Write a function that takes a string of parentheses, and determines if the order of the parentheses is valid. The # function should return true if the string is valid, and false if it's invalid. # Constraints # 0 <= input.length <= 100 # # Along with opening (() and closing ()) parenthesis, input may contain any vali...
3c96e8b2c3abd9a89e8c91b6a74651ee31bbd5bb
tprhat/codewarspy
/sum_of_intervals.py
1,035
4.09375
4
# Write a function called sumIntervals/sum_intervals() that accepts an array of intervals, and returns the sum of all # the interval lengths. Overlapping intervals should only be counted once. # Intervals Intervals are represented by a pair of integers in the form of an array. The first value of the interval # will alw...
51e3004950811a4f885fcb9f6f785944163923f8
lidorelias3/Lidor_Elias_Answers
/python - Advenced/Camel Case/CamelCase.py
347
3.8125
4
import sys def main(): if len(sys.argv) != 2: print("usage: ./CamelCase.py sentence") sys.exit(1) camleCase_to_regular = lambda sentence: ''.join( [' {}'.format(letter) if letter.isupper() else letter for letter in sentence]) print(camleCase_to_regular(sys.argv[1])) if __name__...
657dd462815393c877709d5dcdef2485ec6d8763
lidorelias3/Lidor_Elias_Answers
/python - Advenced/Pirates of the Biss‏/PiratesOfTheBiss‏.py
678
4.3125
4
import re def dejumble(scramble_word, list_of_correct_words): """ Function take scramble word and a list of a words and check what word in the list the scramble word can be :param scramble_word: word in pirate language :param list_of_correct_words: a list of words in our language :return: the ...
3bd0c5441fb01beebdba196a8565c57d3c041170
Xiangyaojun/Algorithms
/数组查找/字符串模式匹配.py
595
3.609375
4
# coding:utf-8 ''' 字符串模式匹配算法 题目:求一个字符串(m长度)在主串(n长度)中第一次出现的位置 1.暴力求解:时间复杂度: O(n*m) 2.KMP算法:O(n+m) ''' class Sloution: def findIndex(self,s,t): i = 0 j = 0 while i < len(s) and j < len(t): if s[i] == t[j]: i += 1 j += 1 else: ...
72fd843654ad1f3eecd60dd883459f175a312387
Xiangyaojun/Algorithms
/数组查找/旋转数组.py
1,322
3.6875
4
# coding:utf-8 ''' leetcode 189 给定一个数组,将数组中的元素向右移动 k 个位置,其中 k 是非负数。 示例 1: 输入: [1,2,3,4,5,6,7] 和 k = 3 输出: [5,6,7,1,2,3,4] 解释: 向右旋转 1 步: [7,1,2,3,4,5,6] 向右旋转 2 步: [6,7,1,2,3,4,5] 向右旋转 3 步: [5,6,7,1,2,3,4] 说明: 尽可能想出更多的解决方案,至少有三种不同的方法可以解决这个问题。 要求使用空间复杂度为 O(1) 的原地算法。 解析: 1.暴力求解:一个一个元素旋转,时间复杂度O(n) 需要移动k...
a66af4ba7b1f78078bb8b3cd8197db66ccc57058
Xiangyaojun/Algorithms
/递归,回溯,动态规划/全排列.py
1,047
3.65625
4
# coding:utf-8 ''' leetcode 46 全排列(没有重复元素的序列) 递归算法:缺点就是最后还需要去重 解析: 直观来看,存在n!个不同的排列,时间复杂度为O(n*n!) leetcode 47 全排列(有重复元素的序列) 1.递归算法 : 2.非递归算法 ''' class Solution: def permutation(self, nums, begin, end): # 递归算法:当数组中有重复元素时,会重复输出排列,需要在加一步去重的工作 # 假设总共有n个元素,其核心是:将每个元素放到余下n-1个元素组成的队列最前方,然后对剩余元素进行全排列,依次递...
36b674170408577d83af35d7ad458fb66b0f8842
Xiangyaojun/Algorithms
/二叉树/Trie树(字典树).py
2,796
3.984375
4
# coding:utf-8 ''' leetcode 208 实现一个 Trie (前缀树),包含 insert, search, 和 startsWith 这三个操作。 示例: Trie trie = new Trie(); trie.insert("apple"); trie.search("apple"); // 返回 true trie.search("app"); // 返回 false trie.startsWith("app"); // 返回 true trie.insert("app"); trie.search("app"); // 返回 true 说明: 你可以假设所有的输入都是...
229674c763d3646cd5e259d87f25f5c8d19117ac
Xiangyaojun/Algorithms
/数组查找/搜索插入位置.py
1,207
3.828125
4
# coding:utf-8 ''' leetcode 35 给定一个排序数组和一个目标值,在数组中找到目标值,并返回其索引。如果目标值不存在于数组中,返回它将会被按顺序插入的位置。 你可以假设数组中无重复元素。 示例 1: 输入: [1,3,5,6], 5 输出: 2 示例 2: 输入: [1,3,5,6], 2 输出: 1 解析: 1.暴力解法:直接一个一个遍历整个数组查找,时间复杂度O(n+m) 2.二分查找法:时间复杂度O(logn) ''' class Solution: def searchInsert(self, nums, target): ...
862f2bab8e49c24eacf212930d85b32a6c938b95
Xiangyaojun/Algorithms
/数组查找/两个排序数组的中位数.py
726
3.671875
4
# coding:utf-8 ''' 给定两个大小为 m 和 n 的有序数组 nums1 和 nums2 。 请找出这两个有序数组的中位数。要求算法的时间复杂度为 O(log (m+n)) 。 你可以假设 nums1 和 nums2 均不为空。 示例 1: nums1 = [1, 3] nums2 = [2] 中位数是 2.0 示例 2: nums1 = [1, 2] nums2 = [3, 4] 中位数是 (2 + 3)/2 = 2.5 解析: 1.暴力求解,合并两个有序数组为一整个有序数组,时间复杂度O(n+m),空间复杂度O(1) 2.HashMap求解,时间复杂度O(n),空间复杂度O(...
f2b06363eb7bf486e5d397ffbf4c68f88ba6c5bc
Xiangyaojun/Algorithms
/栈和队列/用栈实现队列.py
1,886
4.125
4
# coding:utf-8 ''' leetcode 224 题目:使用栈实现队列的下列操作: push(x) -- 将一个元素放入队列的尾部。 pop() -- 从队列首部移除元素。 peek() -- 返回队列首部的元素。 empty() -- 返回队列是否为空。 示例: MyQueue queue = new MyQueue(); queue.push(1); queue.push(2); queue.peek(); // 返回 1 queue.pop(); // 返回 1 queue.empty(); // 返回 false 说明: 你只能使用标准的栈操作 -- 也就是只有 push to top, p...
73625883e34a6c22f5662064e50bc878aaf5609e
KevinAlanis/Introduccion-a-la-Programacion-y-Taller-de-Programacion
/Código/Tareas/Taller/tarea6-taller-kalanis/Employee.py
590
3.890625
4
class Employee: 'Common base class for all employees' empCount = 0 def __init__(self, name, salary): self.name = name self.salary = salary Employee.empCount += 1 def displayCount(self): print("Total Employee %d" % Employee.empCount) def getName(self): retu...
608fc25425c9a71e54f7d4ca42159aad117fbb7c
rohan8594/DS-Algos
/leetcode/easy/Arrays and Strings/FirstUniqueCharInString.py
620
3.671875
4
# Given a string, find the first non-repeating character in it # and return it's index. If it doesn't exist, return -1. # Examples: # s = "leetcode" # return 0. # s = "loveleetcode", # return 2. # Note: You may assume the string contain only lowercase letters. class Solution: def firstUniqChar(self, s: 'str') ...
a878a76b3e889571640e90185b53823cf530d745
rohan8594/DS-Algos
/leetcode/medium/Arrays and Strings/3Sum.py
1,035
3.609375
4
# Given an array nums of n integers, are there elements a, b, c in nums such that a + b + c = 0? Find all unique triplets in the array which gives the sum of zero. # Note: # The solution set must not contain duplicate triplets. # Example: # Given array nums = [-1, 0, 1, 2, -1, -4], # A solution set is: # [ # [-1...
1c5c4b844a759fff1e58e3b003ab744a40b8bb1b
rohan8594/DS-Algos
/leetcode/medium/Arrays and Strings/Permutations.py
1,072
3.734375
4
# Given a collection of distinct integers, return all possible permutations. # Example: # Input: [1,2,3] # Output: # [ # [1,2,3], # [1,3,2], # [2,1,3], # [2,3,1], # [3,1,2], # [3,2,1] # ] class Solution: def permute(self, nums): """ :type nums: List[int] :rtype: List[List[int...
7fb1607bae1d3270b4e0382f5d7c761150ced66b
rohan8594/DS-Algos
/leetcode/medium/SurroundedRegions.py
1,892
3.984375
4
# Given a 2D board containing 'X' and 'O' (the letter O), capture all regions surrounded by 'X'. # A region is captured by flipping all 'O's into 'X's in that surrounded region. # Example: # X X X X # X O O X # X X O X # X O X X # After running your function, the board should be: # X X X X # X X X X # X X X X # X O ...
ad2fa71e8738b4a11bcc9b6ccd79adcd709990d8
rohan8594/DS-Algos
/leetcode/medium/Trees/KthSmallestInBST.py
929
3.96875
4
# Given a binary search tree, write a function kthSmallest to find the kth smallest element in it. # Note: # You may assume k is always valid, 1 ≤ k ≤ BST's total elements. # Example: # Input: root = [5,3,6,2,4,null,null,1], k = 3 # 5 # / \ # 3 6 # / \ # 2 4 # / # 1 # Output: 3 # Fol...
d84fa6120c40089830ad8a6a1ee20003c92b1515
rohan8594/DS-Algos
/algorithms/Searching/BinarySearch.py
424
3.875
4
def binary_search(arr, ele): first = 0 last = len(arr) - 1 found = False while first <= last and found == False: mid = (first + last) // 2 if arr[mid] == ele: found = True else: if arr[mid] > ele: last = mid - 1 else: ...
2cfcc086fdd23132c263b2f2d3125db953c50e52
rohan8594/DS-Algos
/leetcode/easy/Arrays and Strings/SingleNumber.py
734
3.796875
4
# Given a non-empty array of integers, every element appears twice # except for one. Find that single one. # Note: # Your algorithm should have a linear runtime complexity. Could you # implement it without using extra memory? # Example 1: # Input: [4,1,2,1,2] # Output: 4 # # NOTE: # # Soln could be improved by usin...
5d582ff8d8e4e857b24e7291eea53ada71327a27
rohan8594/DS-Algos
/leetcode/easy/Arrays and Strings/MinIndexSumOfLists.py
1,404
3.96875
4
# Suppose Andy and Doris want to choose a restaurant for dinner, and they both have a list of favorite # restaurants represented by strings. # You need to help them find out their common interest with the least list index sum. If there is a # choice tie between answers, output all of them with no order requirement. Yo...
8678b04cd9e28847b30d4b8ec7fe3f9aaddc1708
rohan8594/DS-Algos
/leetcode/medium/Arrays and Strings/ReverseWordsInAString.py
1,076
4.3125
4
# Given an input string, reverse the string word by word. # Example 1: # Input: "the sky is blue" # Output: "blue is sky the" # Example 2: # Input: " hello world! " # Output: "world! hello" # Example 3: # Input: "a good example" # Output: "example good a" # Note: # A word is defined as a sequence of non-space...
53fa94d8ca5fdea75ff0060f07a1f2c85912e0a8
rohan8594/DS-Algos
/leetcode/easy/Arrays and Strings/IntersectionOf2Arrays_ii.py
896
3.953125
4
# Given two arrays, write a function to compute their intersection. # Example 1: # Input: nums1 = [1,2,2,1], nums2 = [2,2] # Output: [2,2] # Example 2: # Input: nums1 = [4,9,5], nums2 = [9,4,9,8,4] # Output: [4,9] # Note: # Each element in the result should appear as many times as it shows # in both arrays. And th...
634119cf7cb1a5d461e0a320ac79151f217e00fd
rohan8594/DS-Algos
/leetcode/easy/Arrays and Strings/UniqueCharachters.py
476
4.25
4
# Given a string,determine if it is comprised of all unique characters. For example, # the string 'abcde' has all unique characters and should return True. The string 'aabcde' # contains duplicate characters and should return false. def uniqueChars(s): seen = set() for i in range(len(s)): if s[i] not...
09d9d808f45ce5408c1e8e7cb202c89b90ac01b1
rohan8594/DS-Algos
/leetcode/medium/Arrays and Strings/SpiralMatrix.py
1,016
3.984375
4
# Given a matrix of m x n elements (m rows, n columns), return all elements of the matrix in spiral order. # Example 1: # Input: # [ # [ 1, 2, 3 ], # [ 4, 5, 6 ], # [ 7, 8, 9 ] # ] # Output: [1,2,3,6,9,8,7,4,5] # Example 2: # Input: # [ # [1, 2, 3, 4], # [5, 6, 7, 8], # [9,10,11,12] # ] # Output: [1,2,3,4,8...
9c18ba68ff108c6f8c65b67a8d9f273583978727
rohan8594/DS-Algos
/leetcode/medium/DP/WordBreak.py
1,284
3.9375
4
# Given a non-empty string s and a dictionary wordDict containing a list of non-empty words, determine # if s can be segmented into a space-separated sequence of one or more dictionary words. # Note: # The same word in the dictionary may be reused multiple times in the segmentation. # You may assume the dictionary doe...
55d08fba3f6b8f887fe317de21e8f3c93102f90a
rohan8594/DS-Algos
/leetcode/medium/Arrays and Strings/DegreeOfArray.py
1,379
3.796875
4
# Given a non-empty array of non-negative integers nums, the degree of this array is defined # as the maximum frequency of any one of its elements. # Your task is to find the smallest possible length of a (contiguous) subarray of nums, that # has the same degree as nums. # Example 1: # Input: [1, 2, 2, 3, 1] # Output...
16967053196d3ddc81d47cee56e2333b7092797e
rohan8594/DS-Algos
/leetcode/easy/Arrays and Strings/MeetingRooms.py
539
3.515625
4
# Given an array of meeting time intervals consisting of start and end times [[s1,e1],[s2,e2],...] (si < ei), # determine if a person could attend all meetings. # Example 1: # Input: [[0,30],[5,10],[15,20]] # Output: false # Example 2: # Input: [[7,10],[2,4]] # Output: true class Solution: def canAttendMeeting...
bce31c7854e9835b1a697eb2a0604d78664c0bda
mrDurandall/Python-Basics-Course
/Lesson_3/Lesson-3_HW_Task-1.py
1,184
4.125
4
# Задание 1 - Функция деления. print('Задание 4 - Функция деления.') def divide(): """Функция деления двух чисел для вводимых чисел используется формат float, т.к. пользователь может ввести не только целые числа. также при вводе каждого числа проверям, точно ли пользователь ввел числа, а не другой ...