blob_id stringlengths 40 40 | repo_name stringlengths 5 127 | path stringlengths 2 523 | length_bytes int64 22 3.06M | score float64 3.5 5.34 | int_score int64 4 5 | text stringlengths 22 3.06M |
|---|---|---|---|---|---|---|
ea57b522f2bd14f19df61477c8141c238401f1b8 | DavidCasa/tallerTkinter | /Ejercicio4.py | 559 | 4.125 | 4 | ############## EJERCICIOS 4 ################
from tkinter import *
root = Tk()
v = IntVar()
#Es un pequeño menú, en el cual se aplica Radiobuttons para hacer la selección de opciones
Label(root,
text="""Choose a programming language:""",
justify = LEFT,
padx = 20).pack()
Radiobutton(root,
... |
a7baf85ed30fdb9113d105341886e7492a4d91e4 | DavidCasa/tallerTkinter | /Ejercicios - Tkinter (Python)/Ejercicio5.py | 509 | 4.0625 | 4 | from tkinter import *
root = Tk()
v = IntVar()
v.set(1) # initializing the choice, i.e. Python
languages = [ ("Python",1), ("Perl",2), ("Java",3), ("C++",4), ("C",5)]
def ShowChoice():
print (v.get())
Label(root,text="""Choose your favourite programming language:""",
justify = LEFT, padx = 20).pack()
for t... |
8efdeef0aa4af75fd19c32ed6eb5b9b2ddcd5d56 | midah18/Hangman_Python | /Hangman_Iterations/Hangman_Iteration-3/hangman.py | 4,350 | 4.21875 | 4 | import random
def read_file(file_name):
file = open(file_name,'r')
return file.readlines()
def get_user_input():
return input('Guess the missing letter: ')
def ask_file_name():
file_name = input("Words file? [leave empty to use short_words.txt] : ")
if not file_name:
return 'short_word... |
3d999f7baa9c6610b5b93ecf59506fefd421ff86 | Minglaba/Coursera | /Conditions.py | 1,015 | 4.53125 | 5 | # equal: ==
# not equal: !=
# greater than: >
# less than: <
# greater than or equal to: >=
# less than or equal to: <=
# Inequality Sign
i = 2
i != 6
# this will print true
# Use Inequality sign to compare the strings
"ACDC" != "Michael Jackson"
# Compare characters
'B' > 'A'
# If statement example
ag... |
a6bf335219d08bfeb6471b9135b530baee1245e2 | tatiana-kim/contest-algorithms | /contest4/C_most_frequent_word.py | 494 | 3.578125 | 4 | # C_most_frequent_word.py
f = open("C/input.txt", "r")
words = f.read().strip().split()
f.close()
count = {}
maxval = -1
tmp = ""
for i in words:
if i not in count:
count[i] = 0
count[i] += 1
if count[i] > maxval:
maxval = count[i]
tmp = i # intermediate result = one of most ... |
e013b04bd6afd5dedd83a740a33b0a42115c2baf | tatiana-kim/contest-algorithms | /contest6/H_wires.py | 946 | 3.8125 | 4 | def right_bin_search(left, right, check, checkparams):
while left < right:
middle = (left + right + 1) // 2
if check(middle, checkparams):
left = middle
else:
right = middle - 1
return left
# how many wires with given length from 1 to 10**7 cm
def checklength(x,... |
1ca5aa1330f5d93f60bb335c9e9b097bd30acc0c | tatiana-kim/contest-algorithms | /contest6/B_binary_approximative.py | 3,729 | 3.625 | 4 | """
Приближенный двоичный поиск
Для каждого из чисел второй последовательности найдите ближайшее к нему в первой.
Формат ввода
В первой строке входных данных содержатся числа N и K ().
Во второй строке задаются N чисел первого массива, отсортированного по неубыванию,
а в третьей строке – K чисел второго массива.
Каж... |
fd9803e3c521082db6d967c75dbc21d6b0a56073 | archithyd/some-array-questions | /Arrays/Triplet Sum in Array.py | 833 | 3.515625 | 4 | def binary(arr, val) :
if len (arr) >= 1 :
mid = len (arr) // 2
if arr[mid] == val :
return True
elif val > arr[mid] :
return binary (arr[mid + 1 :len (arr)], val)
else :
return binary (arr[0 :mid], val)
else :
return False
... |
ed320d2a8c01915a40b818fe6b030ee8c1e78c7e | pedjasladek/PAZ2-1 | /testmodule.py | 1,124 | 3.921875 | 4 | """Book examples for basic testing"""
from implementmodule import Vertex, breadth_first_search, depth_first_search, print_path
VERTEXR = Vertex('R')
VERTEXV = Vertex('V')
VERTEXS = Vertex('S')
VERTEXW = Vertex('W')
VERTEXT = Vertex('T')
VERTEXU = Vertex('U')
VERTEXY = Vertex('Y')
VERTEXX = Vertex('X')
VERTEXZ = Vertex... |
6d0e36daf1c926b7ee1bf20e4d85359411bccfff | tianti1/covid-seating-optimization | /simulated_annealing.py | 3,830 | 3.53125 | 4 | import math
from copy import deepcopy
import random
import numpy as np
class State:
def __init__(self):
raise NotImplementedError
def mutate(self):
raise NotImplementedError
class MyState(State):
def __init__(self, placing_order):
self.placing_order = placing_order
@staticm... |
eb43ff67cffd4b87e4a59f2f85385abae737ce58 | prashantgupta23/Sort-Employee-by-DOB | /SortEmpbyDOB-Quarter.py | 920 | 3.734375 | 4 | import pandas as pd
# load excel file using pandas and parse date columns
tmpdf = pd.read_excel('employee__1_.xls', parse_dates=['Date of Birth', 'Date of Joining'])
#print(tmpdf)
# sort rows by column 'Date of Birth'
new_tmpdf = tmpdf.sort_values(by='Date of Birth')
# converting pandas dataframe to dictionary form... |
f8964398d3d0772156029cc5179dd80cdf3edd17 | mathman93/SPRI2021_Roomba | /Pastry_Code/Desynch.py | 4,861 | 3.609375 | 4 | ''' RPi_Testing.py
Purpose: Basic code for running Xbee, and illustrating code behavior.
Sets up Xbee;
IMPORTANT: Must be run using Python 3 (python3)
Last Modified: 6/30/2021
By: Jamez White
'''
## Import libraries ##
import serial # For serial port functions (e.g., USB)
import time # For accessing system time
import... |
14d07f71f1bbefd436926933bf8d581f94ead74a | GregorySeth/book_database | /main.py | 5,201 | 3.71875 | 4 | from tkinter import *
from back import Database
from tkinter import messagebox
class MainWindow(object):
def __init__(self, window):
#Window
self.window = window
self.window.title("Book database")
self.window.geometry("500x370")
#Labels
lbl_title = Label(self.wind... |
9a12a3be1583dfa72740742706ae0b2d1b73d21c | zvasdfg/GraphPython | /graph.py | 3,328 | 3.765625 | 4 | #Importamos la funcion deque
from collections import deque
#Definimos la clase Grafo y asignamos valor vacio al diccionario de terminos
class Grafo(object):
def __init__(self):
self.relaciones = {}
def __str__(self):
return str(self.relaciones)
#Definimos la funcion agregar(Recibe un gra... |
813838aabd9e345dfbef4efe9c80436d6dfa304d | aksiwme/PythonLecture | /python300.py | 3,406 | 3.75 | 4 | # 사용자로부터 값을 입력 받은 후 해당 값에 20을 더한 값을 출력하라.
# 단 사용자가 입력한 값과 20을 더한 값이 255를 초과하는 경우 255를 출력해야 한다.
num = int(input())
if num + 20 > 255:
num = 255
else:
num = num + 20
print(num)
# 사용자로부터 값을 입력 받은 후 해당 값에 20을 뺀 값을 출력하라.
# 단, 출력 값의 범위는 0 ~ 255이다.
# (결과값이 0보다 작을 경우 0, 255 보다 클 경우 255를 출력해야 한다.)
num = int... |
7bbdd543e8340a3c1429e44121de6ef9cb2c5835 | mohammadsh97/Prework_1 | /workers/person.py | 3,198 | 3.59375 | 4 | import abc
import re
class Person:
__id = 0
list_phone = []
address = []
@staticmethod
def generatId(self):
self.__id += 1
@staticmethod
def validEmail(email):
fields = email.split("@")
if len(fields) != 2:
return False
else:
regex ... |
8fce380bffd2b7baf5f804bad1fd96ce87dbb4be | bartnic2/Python-Guides | /Games/cave_game.py | 1,060 | 3.84375 | 4 | import shelve
with shelve.open("cave data") as data:
loc = 1
while True:
availableExits = ", ".join(data["locations"][loc]["exits"].keys())
print(data["locations"][loc]["desc"])
if loc == 0:
break
else:
allExits = data["locations"][loc]["exi... |
bcd4278ea6f15697b4baa017521468f8c5d69c9a | artemiocabelin/pythonfundamentals | /draw_stars.py | 396 | 3.828125 | 4 | def draw_stars(numList):
for num in numList:
if isinstance(num,int):
star = ""
for i in range(num):
star += "*"
print star
elif isinstance(num,str):
word = ""
for letter in num:
word += num[0]
pri... |
90a03657ec4eee4a278237e2358c8fa094df5a0b | artemiocabelin/pythonfundamentals | /making_dictionaries.py | 1,159 | 3.796875 | 4 | name = ["Anna", "Eli", "Pariece", "Brendan", "Amy", "Shane", "Oscar","papoy"]
favorite_animal = ["horse", "cat", "spider", "giraffe", "ticks", "dolphins", "llamas"]
def make_dict(arr1,arr2):
new_dict ={}
for item1, item2 in zip(arr1,arr2):
new_dict[item1] = item2
print new_dict
# Hacker challenge
... |
36c764b200f9d956fa1552fb970a5a8a76fd073d | cindylebron/leetcode | /20200611/101symmetricTree.py | 559 | 3.859375 | 4 | # Definition for a binary tree node.
# class TreeNode:
# def __init__(self, val=0, left=None, right=None):
# self.val = val
# self.left = left
# self.right = right
class Solution:
# O(n)
def isSymmetric(self, root) -> bool:
if not root:
return True
return ... |
4b9cc18a95ab96ffba85bcdc3e31fd3032464d4a | juliushamilton/match_loc | /fasta.py | 2,215 | 3.75 | 4 | def is_fasta(name):
# is_fasta determines whether a filename is fasta or not.
if not isinstance(name, str):
raise TypeError('ERROR: is_fasta requires string inpute.')
elif len(name) <= 10:
return False
elif name[-10:] == '.fasta.txt':
return True
else:
return False
... |
f490fff601ddab9e47adcb2a8602051a605585f6 | Kjosev/aoc2020 | /09/script.py | 1,748 | 3.734375 | 4 | def read_input():
with open('input.txt', 'r') as f:
lines = f.readlines()
lines = [line.strip() for line in lines]
return lines
def check_sum(arr, num):
# print(arr)
# print(num)
for i in range(len(arr)):
for j in range(i + 1, len(arr)):
if arr[i] + arr[j] == ... |
2cc886e5bb11a8ed0fa37089601809d5bef77b56 | Kjosev/aoc2020 | /08/script.py | 1,489 | 3.546875 | 4 | def read_input():
with open('input.txt', 'r') as f:
lines = f.readlines()
lines = [line.strip() for line in lines]
return lines
def run_program(lines, op_to_switch=None):
visited = set()
accumulator = 0
current_idx = 0
finished_normally = False
while current_idx not in v... |
0e3a78b306e6fa1fa01314feb32dc9210c5d38ea | jjmaturino/LinearRegression_MarkovChains2020 | /Python/ProbabilityCode.py | 3,256 | 3.703125 | 4 | def computeProb(counterWon, counterWS, counterGame):
pb = counterWS / counterGame
paib = counterWon / counterGame
if pb == 0:
pab = 0
else:
pab = paib / pb
return pab
import pandas as pd
df = pd.read_csv("modifiedWinStreaks - good.csv")
streaks = df["Numeric Win Streak"]
# nextO... |
f256746a37c0a050e56aafca1315a517686f96c8 | luxorv/statistics | /days_old.py | 1,975 | 4.3125 | 4 | # Define a daysBetweenDates procedure that would produce the
# correct output if there was a correct nextDay procedure.
#
# Note that this will NOT produce correct outputs yet, since
# our nextDay procedure assumes all months have 30 days
# (hence a year is 360 days, instead of 365).
#
def isLeapYear(year):
if ye... |
885f286dede01bb151f8a9145219fee8a1544905 | DjElad/PycharmProjects | /pythonProject/encode.py | 288 | 3.59375 | 4 | def duplicate_encode(word):
word = word.lower()
lst = [str(i) for i in word]
res = []
for x in range(0, len(lst)):
if word.count(lst[x]) > 1:
res.append(")")
else:
res.append("(")
print("".join(res))
duplicate_encode("(( @")
|
9bca67af509859de71d49928ae773d8acbf5a14c | SravanthiSinha/holbertonschool-webstack_basics | /0x01-python_basics/4-add.py | 280 | 3.828125 | 4 | #!/usr/bin/python3
add = __import__("add_4").add
def addition():
"""calls the add function passing with the value of a and b"""
a = 1
b = 2
print("{} + {} = {}".format(a, b, add(a, b)))
"""not executed when imported"""
if __name__ == "__main__":
addition()
|
e9ec010604334aa592a34eb31d6c6221f876804f | SuhwanJang/Code_History | /Python/CSVFileSorting/main.py | 773 | 3.671875 | 4 | import csv
from algorithm.sort import *
from algorithm.search import *
# ---- 패키지 안의 모듈을 import ----#
# ----------------------------------#
result = []
key = []
with open("unsorted.csv", 'r') as p_file:
csv_data = csv.reader(p_file) # Open한 파일을 csv 객체를 사용해서 읽기
for row in csv_data:
row = [int(i) for i... |
d57e951c0f2e1d179734e548b05b541662b589a2 | khshim/lemontree | /lemontree/generators/image.py | 11,133 | 3.734375 | 4 | """
This code includes image generators to make minibatch and shuffle.
Generator make data to feed into training function for every mini-batch.
Each generator can hold multiple data, such as data and label.
Image Generator preprocess image before training and during training.
"""
import numpy as np
from lemontree.gene... |
4f4e34e6e44eaeab6b1abf3da474b1c41aca289f | khshim/lemontree | /lemontree/data/gutenberg.py | 3,396 | 3.671875 | 4 | """
This code includes functions to preprocess text in gutenberg dataset.
Especially, for certain book.
Download
--------
Project Gutenberg.
https://www.gutenberg.org/ebooks/
Base datapath: '~~~/data/'
Additional folder structure: '~~~/data/gutenberg/alice_in_wonderland.txt'
SAVE THE TEXT TO ANSI FORMAT.
"""
import t... |
d3c023cedac286f682bf242bf66211e413b0e0fd | reveriess/TarungLabDDP1 | /lab/05/lab05_b_d.py | 2,219 | 3.6875 | 4 | '''
Program Mini-Kuis DDP1
Program untuk mengerjakan kuis yang berisi 4 buah pertanyaan yang meminta
user untuk mengkonversi bilangan biner ke bilangan desimal.
'''
def cetak_pertanyaan(urutan, angka_biner):
'''
Mencetak pertanyaan
'''
print("Soal {}: Berapakah angka desimal dari bilangan b... |
eb2f50317c0a20a34da8283953118fa386a2b2a5 | reveriess/TarungLabDDP1 | /lab/01/lab01_b_d_s1.py | 1,622 | 4 | 4 | '''
Program gambar bentuk anak tangga
Menggambar 3 buah anak tangga dengan panjang anak tangga berdasarkan input dari
user. Penggambaran dilakukan menggunakan Turtle Graphics.
'''
# Inisialisasi
# Mengimpor modul turtle
import turtle
# Menginstansiasi objek turtle "kura"
kura = turtle.Turtle()
# Meminta input untuk... |
bf6d09ae3d5803425cf95dd4e53fe62dad41fda0 | reveriess/TarungLabDDP1 | /lab/01/lab01_f.py | 618 | 4.6875 | 5 | '''
Using Turtle Graphics to draw a blue polygon with customizable number and
length of sides according to user's input.
'''
import turtle
sides = int(input("Number of sides: "))
distance = int(input("Side's length: "))
turtle.color('blue') # Set the pen's color to blue
turtle.pendown() # Start drawing
d... |
4c1a5fb48e01821922bd7f3da9775d394caa8b0d | Datos-1-TEC/Circuit-Designer | /src/Dijkstra2.py | 4,262 | 4.3125 | 4 | import math
class Dijkstra2:
"""
Class used to get the shortest path or the largest path of two given nodes
Attributes------------------------
unvisited_nodes : graph, graph given by parameter
shortest_distance : dictionary, stores the shortest distance
route : list, gives the route of the ... |
67744e56f329d3236393a0bbeed33f78335c814b | burakozdemir/CSE321---Introduction-to-Algorithm-Design | /hw5/CSE321_HW5_141044027/CSE321_HW5_141044027/theft_StudentID.py | 1,423 | 3.5625 | 4 | #Algoritmada listenin icindeki ilk listenin her elemanına baslangıc oldgu ıcın bakıyor
#Daha sonra alttakı elemanlara duruma gore secım yapıyor.
#WorstCase:O(n'2) . Ic ice donguler oldgu ıcın n^2
def theft(amountOfMoneyInLand):
x = list(zip(*amountOfMoneyInLand))
currentIndex=0
result=0
for i in range... |
b43338373cdecf46e7f7b499a4fd77e6b2524552 | Saifullahshaikh/1st-detail-assignment | /problem 3.24.py | 195 | 4 | 4 | print('Saifullah, 18B-092-CS, A')
print('1st Detailed Assignment, Problem 3.24')
words = eval(input('Enter list of word: '))
for word in words:
if word != 'secret':
print(word)
|
33bc99d392cda0bea8b46e39be54390519422b87 | Saifullahshaikh/1st-detail-assignment | /Problem 3.31.py | 191 | 4 | 4 | print('Saifullah, 18B-092-CS, A')
print('1st Detailed Assignment, Problem 3.31')
x = eval(input('Enter x: '))
y = eval(input('Enter y: '))
r = 5
if x<r and x<r:
print('It is in!')
|
5795eb31750f0fd17609649455c9224636766976 | Saifullahshaikh/1st-detail-assignment | /Ex. 3.23.py | 478 | 3.734375 | 4 | print('Saifullah, 18B-092-CS, A')
print('1st Detailed Assignment, Ex. 3.23')
#(a)
print('\nEx. 3.23(a)')
for i in range(0,2):
print(i)
#(b)
print('\nEx. 3.23(b)')
for x in range(0,1):
print(x)
#(c)
print('\nEx. 3.23(c)')
for y in range(3,7):
print(y)
#(d)
print('\nEx. 3.23(d)')
for m in rang... |
3b25b8e94fdd18cc667ef5587a17715e4a5f4d36 | driverxb/xb | /spider.py | 1,577 | 3.515625 | 4 | import sys
import nmap
scan_row = []
input_data = input('Please input hosts and port: ')
#scan_row以空格分隔
scan_row = input_data.split(' ')
if len(scan_row) != 2:
print("Input errors, example \"192.168.209.0/24 80,443,22 \"")
sys.exit(0)
#接收用户输入的主机
hosts = scan_row[0]
#接收用户收入的端口
port = scan_row[1]
try:
#创建... |
57ca71ae3723dacbcbcde871453e81a6e060e7eb | pdeesawat4887/python_daily | /SAT_2019_02_23/leap_year.py | 1,100 | 3.890625 | 4 | class LeapYear:
def __init__(self):
while True:
self.option = int(input("Enter option 1:[A.D.] or 2:[B.E.]: "))
self.statement = {
1: self.calculator_leap_year,
2: self.buddhist_era
}
try:
self.statement[self.op... |
35c3c4396ba98cd17a7b71bb42820557aceb1799 | pdeesawat4887/python_daily | /tue_2019_04_01/replace_word.py | 157 | 3.84375 | 4 | def replaceWord(string, old_word, new_word):
return string.replace(old_word, new_word)
print(replaceWord('Hello world 123 world 123', 'world', 'bug'))
|
a537096f9bbbb14068f63403ca94593874b22796 | eamritadutta/PythonSolutions | /MergeKSortedLists.py | 1,386 | 3.796875 | 4 | import sys
# merge K sorted lists where the lists are as follows:
# 3 4 10 12
# 1 5
# 7 11
def mergeKSortedLists(heads):
pMinNode = None
newHead = None
# scan values at pHeads of each list
while True:
minV = sys.maxint
minNode = None
for h in heads: # n3, n1, n7
i... |
e89e3ac1c03ad1d3ee103df8b81fc76d16f2912a | eamritadutta/PythonSolutions | /RemDupsFromList.py | 872 | 3.921875 | 4 | # class for node
class Node:
def __init__(self, val, next):
self.val = val
self.next = next
# create the following list inside a method
# 1->1->2->3->3
def create_list():
three_one = Node(3, None)
three_two = Node(3, three_one)
two = Node(2, three_two)
one_one = Node(1, two)
hea... |
09b89bfbe5eb2b5ab29ab8cef9e979e29897f172 | eamritadutta/PythonSolutions | /mergeSortedList.py | 957 | 3.96875 | 4 | def mergeSortedLists(l1, l2):
p1 = 0
p2 = 0
sortedl = []
while p1 < len(l1) and p2 < len(l2):
if l1[p1] > l2[p2]:
sortedl.append(l2[p2])
p2 += 1
else:
sortedl.append(l1[p1])
p1 += 1
# print sortedl
# print p1
# print p2
... |
7657e0aa494bb651a05632b1a32ea0c0a80b0abb | eamritadutta/PythonSolutions | /LongestIncSequence.py | 2,741 | 4.03125 | 4 | # The following algorithm returns the length of longest increasing sequence in a input array in O(N log N) time
# first I am trying to reason about the problem on lines similar to the explanation at GeeksForGeeks
# lets start with the input array:
# A = [0, 8, 4, 12, 2, 10, 6, 14, 1, 9, 5, 13, 3, 11, 7, 15]
# to sol... |
a85557a0977048f499e4e594e493dba49396f780 | zellstrife/Python | /Ex005.py | 159 | 4.125 | 4 | n1 = int(input('Digite um numero: '))
print('O numro escolhido foi: {}'
'\n Seu antecessor é: {}'
'\nSeu sucessor é: {}'.format(n1,n1-1,n1+1)) |
fab57e2099f63f2113edf1075432a2375981009f | zellstrife/Python | /Ex040.py | 956 | 3.84375 | 4 | aluno = str(input('Digite o nome do aluno: '))
p1 = float(input('Digite a nota da P1 do aluno {}: '.format(aluno)))
p2 = float(input('Digite a nota da P2 do aluno {}: '.format(aluno)))
p3 = float(input('Digite a nota da P3 do aluno {}: '.format(aluno)))
p4 = float(input('Digite a nota da P4 do aluno {}: '.format(al... |
a448f0328cb4544480726b8b821e68a13d6a47c7 | zellstrife/Python | /Ex030.py | 216 | 3.75 | 4 | import random
n = random.randint(0,1000)
m = n%2
if(m == 0):
print('Numero: {}'
'\n Este numero é PAR'.format(n))
else:
print('Numero: {}'
'\n Este numero é IMPAR'.format(n)) |
0e9a26ead6f13a4301f7741c72d700fa6c4a3ca2 | zellstrife/Python | /Ex043.py | 1,207 | 3.890625 | 4 | nome = str(input('Digite o nome da pessoa a ser analisada: '))
peso = float(input('Digite o peso em Kg de {}: '.format(nome)))
altura = float(input('Digite a altura de {}: '.format(nome)))
imc = peso / (altura * altura)
if imc < 18.5:
print('Nome: {}'
'\nPeso: {}Kg'
'\nAltura: {}M'
... |
3e91723032ccc985d8e5518fdb66cbc27f73e90c | zellstrife/Python | /Ex020.py | 310 | 3.640625 | 4 | import random
al1 = str(input('Digite o nome do aluno: '))
al2 = str(input('Digite o nome do aluno: '))
al3 = str(input('Digite o nome do aluno: '))
al4 = str(input('Digite o nome do aluno: '))
list = [al1,al2,al3,al4]
random.shuffle(list)
print('A ordem de apresentação será: {}'.format(list)) |
7dfa59fdc67172ceca72a859cc73de72027d0e08 | mdrummond1/euler | /multiples_3_and_5.py | 531 | 4.09375 | 4 | def listMulThree():
for num in range(1000):
if (num % 3 == 0):
print(num)
def listMulFive():
for num in range(1000):
if (num % 5 == 0):
print(num)
def addMuls():
sum = 0
for num in range(1000):
if (num % 3) == 0:
sum += num
if (num % ... |
ef031629d2e3ac0da8e5052078cc710f549fb4ed | boristsarkov/Project | /tsak_1_2.py | 1,970 | 3.671875 | 4 | cubes = [x**3 for x in range(1000) if x % 2 != 0]
my_numbers_sum = 0
my_numbers_sum_list = []
total_7 = 0 # Переменна суммы чисел делящихся на 7
total_17 = 0 # Переменная суммы чисел делящихся на 7 после прибавки 17
# проход по списку
for i in range(len(cubes)):
my_str = str(cubes[i])
my_list = list(my_str)
... |
aa6bbf6c626ebb5a060e6d3c2dcf7f860e9232a7 | yywecanwin/PythonLearning | /day04/13.列表的嵌套.py | 605 | 3.6875 | 4 | # -*- coding: utf-8 -*-
# author:yaoyao time:2019/10/4
# 如果列表中的元素还是列表,你的列表就是嵌套的列表
name_list = [["孙俪", "谢娜", "贾玲"], ["蓉蓉", "百合", "露露"]]
print(name_list[0]) #['孙俪', '谢娜', '贾玲']
print(name_list[0][0]) # 孙俪
print(type(name_list[0])) # <class 'list'>
print(type(name_list[0][0])) # <class 'str'>
print(name_list[0][1]) # 谢娜... |
80c8b7551375a6c99acf300893897af119d5d6b7 | yywecanwin/PythonLearning | /day10/05.异常语句中else语句的使用.py | 484 | 3.75 | 4 | # -*- coding: utf-8 -*-
# author:yaoyao time:2020/2/9
"""
else 语句的格式:
try:
可能会出现异常的代码块
except(异常类1,异常2,。。。。) as 异常对象名:
处理异常的代码块
使用场景:
通常用来检测是否出现异常了
"""
list1 = [10,20]
try:
print(list1[1])
print(list1[2])
pass
except:
print("索引越界")
pass
else:
print("没有异常,说明索... |
8d6d1fc3f3d63ac15d819943203721f0fbc256d8 | yywecanwin/PythonLearning | /day06/11.可变类型和不可变类型.py | 995 | 3.515625 | 4 | # -*- coding: utf-8 -*-
# author:yaoyao time:2019/12/28
"""
不可变类型
如果改变了类型的数据的值,地址 也发生了变化,这种类型的数据,是不可变类型的数据
常见类型
int float bool str tuple
可变类型
如果改变了该类型的数据的值,地址,没有 发生了变化,这种类型的数据,是可变类型的数据
常见类型
列表,字典,set集合
"""
a = 10
print(id(a)) # 140729720616048
a = 20
print(id(a)) # 140729720616368
p... |
c4d6a7f80e4014f6e1bb56ed59065d0844bf0119 | yywecanwin/PythonLearning | /day09/04.子类中重写父类的方法.py | 1,018 | 3.90625 | 4 | # -*- coding: utf-8 -*-
# author:yaoyao time:2020/2/2
"""
重写父类中的方法的原因:
父类中的方法不能满足子类的需要,但是子类又想保留这个方法名
重写父类中的方法
这就需要子类中定义一个同名的方法,这叫重写父类中的方法
如何重写:
1.把父类中的方法复制粘贴到子类中
2.在子类中秀修改方法体
特点:
子类重写了父类的方法后,当通过子类对象调用这个方法时,调用的是子类中的这个方法
"""
class Father: # class Father(object)
def __init__(self,money,house)... |
7ebc2621de57aba29a68be3d6dacaa16ebf4c4dc | yywecanwin/PythonLearning | /day03/13.猜拳游戏.py | 657 | 4.125 | 4 | # -*- coding: utf-8 -*-
# author:yaoyao time:2019/9/28
import random
# 写一个死循环
while True:
# 1.从键盘录入一个1-3之间的数字表示自己出的拳
self = int(input("请出拳"))
# 2.定义一个变量赋值为1,表示电脑出的拳
computer = random.randint(1,3)
print(computer)
if((self == 1 and computer == 2) or (self == 2 and computer == 3) or (self == 3 an... |
3d6608651b62ae8ed96025323afa81aa1943ae28 | yywecanwin/PythonLearning | /day01/06.字符串格式化操作符.py | 661 | 3.53125 | 4 | # -*- coding: utf-8 -*-
# author:yaoyao time:2019/9/26
#如果输出的字符串中包含某一个变量的值,就需要使用字符串的格式操作符
"""
格式化操作:
%d 整数
%s 字符串
%f 小数
"""
age = 50
print("我的年龄是%d岁" % age) # 我的年龄是50岁
print("我的年龄是%d岁" % 50) # 我的年龄是50岁
username = "小庄"
print("用户的姓名是%s" % username)
pi = 3.1415
#如果是保留n位小数,在%的后面f的前面添加 .n
print("圆周率是%.2f" % p... |
b87055f8f74ad82c0568858cdf51d6e5e91b26a1 | yywecanwin/PythonLearning | /day02/11.逻辑运算符.py | 1,037 | 3.890625 | 4 | # -*- coding: utf-8 -*-
# author:yaoyao time:2019/9/27
"""
and x and y 布尔"与": 并且的意思
如果 x 为 False,x and y 返回 False,否则它返回 y 的值。
True and False, 返回 False。
or x or y 布尔"或":
如果 x 是 True,它返回 True,否则它返回 y 的值。
False or True, 返回 True。
not not x 布尔"非":
如果 x 为 True,返回 False 。
如果 x 为 False,它返回 True。
... |
d397ac5d24de87a8796eaa2e13deb5767bf58347 | yywecanwin/PythonLearning | /day08/02.__init__方法基本使用.py | 1,002 | 3.890625 | 4 | # -*- coding: utf-8 -*-
# author:yaoyao time:2020/1/28
class Student:
"""
是一个魔法方法
比较特殊,Python解释器会自动在对象刚刚创建出来之后,立即调用这个方法
初始化对象:给对象添加属性并赋值
通过self给对象添加属性:
self.属性值 = 属性值
属性是存储在对象里面的
属性是属于对象的
访问属性:
对象名.属性名
"""
def __in... |
53b4367b887dfd841dacd1814173058c374c5900 | yywecanwin/PythonLearning | /day07/06.set-list-tuple三者之间的类型转换.py | 535 | 4.09375 | 4 | # -*- coding: utf-8 -*-
# author:yaoyao time:2020/1/11
"""
数据类型转换的格式:
目标数据类型(数据)
"""
# set->list
set1 = {10,20,30}
list2 = list(set1)
print(list2) # [10, 20, 30]
set2 = set(list2)
print(set2) #{10, 20, 30}
list3 = {10,20,30,40,10}
set3 = set(list3)
print(set3) # {40, 10, 20, 30}
list4 = list(set3)
print(list4)... |
1f4e012554b7f319f279c89fa3c20eaf93fda517 | yywecanwin/PythonLearning | /day05/17.函数的嵌套调用.py | 228 | 3.703125 | 4 | # -*- coding: utf-8 -*-
# author:yaoyao time:2019/12/18
def func1(a,b):
s = a + b
print(f"func1中的s:{s}")
def func2():
print("开始调用func2......")
func1(12,12)
print("func2结束了.....")
func2() |
857d4ee6a870d6633d23ca6a9dd3b58b2b4ca542 | yywecanwin/PythonLearning | /day07/03.递归函数.py | 460 | 3.84375 | 4 | # -*- coding: utf-8 -*-
# author:yaoyao time:2020/1/10
"""
递归函数:
在函数的里面自己调用自己
定义递归函数的条件:
1.自己调用自己
2.必须设置一个终止递归条件
使用递归函数求1-5的累加和
"""
def sum(n):
# 条件2,设置终止递归的条件
if n == 1:
return 1
else:
# 条件1:自己调用自己
return n + sum(n-1)
print(sum(5))
|
eb42aaa882346528732e069a8cde5e7ad92155d0 | yywecanwin/PythonLearning | /day04/07.字符串常见的方法-查找-统计-分割.py | 885 | 4.25 | 4 | # -*- coding: utf-8 -*-
# author:yaoyao time:2019/9/28
s1 = "hello python"
# 1.查找"o"在s1中第一次出现的位置:s1.find()
print(s1.find("aa")) # -1
print(s1.find("o",6,11)) # 10
print(s1.find("pyt")) # 6
print(s1.rfind("pyt")) # 6
"""
index()方法,找不到将会报错
"""
# print(s1.index("o", 6, 11))
# print(s1.index("aa"))
#统计"o"出现的次数
print(s... |
95ce77d9c77b94715837162ed9e85dac67f64053 | yywecanwin/PythonLearning | /day04/15.元组.py | 922 | 4.15625 | 4 | # -*- coding: utf-8 -*-
# author:yaoyao time:2019/10/5
"""
元组:
也是一个容器,可以存储多个元素,每一个元素可以是任何类型
元组是一个不可需改的列表,不能用于 增删改查操作,只能用于查询
定义格式:
定义非空元组
元组名 = (元素1,元素2,,,,,)
元组空元组
元组名 = ()
定义只有一个元素的元组
元组名 = (元素1,)
什么时候使用元组村粗一组数据?
当那一组数据不允许修改时,需要使用元组存储
"""
tuple1 = ("冬冬", "柳岩", "美娜")... |
59b5e3d7675d3b0e2322cd958800fa71e3a2f090 | yywecanwin/PythonLearning | /day04/01.字符串.py | 817 | 3.90625 | 4 | # -*- coding: utf-8 -*-
# author:yaoyao time:2019/9/28
name = "yaoyao"
age = 18
print("姓名是%s,年龄%d" % (name,age))
# f-strings
"""
f-strings
提供一种简洁易读的方式, 可以在字符串中包含 Python 表达式.
f-strings 以字母 'f' 或 'F' 为前缀, 格式化字符串使用一对单引号、双引号、三单引号、三双引号. 格式化字符串中
"""
f_string1 = f"姓名是{name},年龄是{age}"
print(f_string1)
f_string2 = f"3 + 5 ... |
da05f4a044900727f15b01d2760e92660c4be5a3 | yywecanwin/PythonLearning | /day03/01.使用if语句实现三目运算符.py | 357 | 3.609375 | 4 | # -*- coding: utf-8 -*-
# author:yaoyao time:2019/9/27
"""
if语句实现三目运算符(三元运算符)
a if a > b else b
向判断 a > b是否成立,如果成立计算的结果是a的值,否则就是b的值
"""
a = 20
b = 10
result = a if a > b else b
print(result) # 20
result2 = a + 10 if a < b else b + 200
print(result2) # 210
|
7229a9c285b03df22f176624c5e0f5b54b27a88d | yywecanwin/PythonLearning | /day04/03.字符串的遍历.py | 628 | 3.78125 | 4 | # -*- coding: utf-8 -*-
# author:yaoyao time:2019/9/28
"""
字符串的遍历:
一个一个的得到里面的元素
"""
s = "hello python"
"""
# 遍历的方式1:
# 1.定义一个变量i 表示元素的索引,赋值为0,因为元素的索引是从0开始的
i = 0
# 2.while循环遍历字符串
while i <= len(s)-1:
#3.在循环中, 根据索引得到元素, 把元素打印出来
print(s[i])
# 4.在循环中,让i加1,是为了让索引加1,便于下次循环时得到下一个元素
i += 1
"""
"""
for 变量... |
453e2b84ad87ba17af80dcd0761b8d06302a0b42 | DemonChaak/Final | /main.py | 2,207 | 3.640625 | 4 | import pygame
import random
###inicializando la libreria###
pygame.init()
####configurar pantalla####
size=(500,500)
pantalla=pygame.display.set_mode(size)
####Configuración del Reloj####
reloj=pygame.time.Clock()
#####configuración de Colores####
#r= Red, g=Green, b=Blue
negro=(0,0,0)
rojo=(255,0,0)
azul=(0,0,255... |
f5a7f2c67206b679d03684202eff3afe35c81e23 | Gao-pw/PythonDemo | /EditFileName.py | 704 | 3.671875 | 4 | # coding:utf8
import os
def rename():
path = "D:\\work\\nzpt\\new\\1"
file_list = os.listdir(path)
for files in file_list:
print("原来文件名字是是:", files)
old_name = os.path.join(path, files)
if os.path.isdir(old_name):
continue
file_name = os.path.splitex... |
8e95be25db4c8f25ca8a47df804e32b1e8e842cb | sylwiakulesza/kurs_taps_SK | /scripts/operatory.py | 680 | 3.90625 | 4 |
number = 1
number1 = 2
print(number + number1)
list = ['Ala', 'ma', 'kota']
print(list[0])
print(list[0:3])
text = 'test'
text1 = 'czesc, jestem "Sylwia"'
print(text1)
cities = {'city': ['Warszawa', 'Gdańsk', 'Bratysława']}
print(cities['city'])
print(cities['city'][2])
suma = 1 + 2
print(suma)
roznica = 1 - 2
p... |
a5e38356ed1974b0290ceae4989e031720ca92d1 | rupert-adams/Fizz-Buzz-in-Python | /fizzBuzz.py | 585 | 3.703125 | 4 | class FizzBuzz(object):
def __init__(self, number):
if FizzBuzz.is_valid_number(number):
self.number = number
@property
def result(self):
if self.number % 3 == 0 and self.number % 5 == 0:
return "FizzBuzz"
elif self.number % 3 == 0:
return "Fizz"
... |
a8206a6838f8a9d801dcac175988e0fd857edb4c | Gyeol0/TIL | /Algorithm/List/Gravity.py | 549 | 3.671875 | 4 | def gravity(N, lst):
max_height = 0
for i in range(N-1):
count = 0
# 밑에 있는 상자들 중에서 자신보다 높은 상자 count
for j in range(i+1, N):
if lst[i] <= lst[j]:
count += 1
# 오른쪽으로 회전하였을 때 현재 높이 - 자신보다 높거나 같은 상자 count
if max_height < N - (i+1) - count:
... |
f0c0488de2f340e22a7e5ba81456157386a85ce6 | Gyeol0/TIL | /Algorithm/Stack_practice/4866. 괄호검사.py | 605 | 3.78125 | 4 | def Parentheses(arr):
stack = []
P = {'(': ')', '{': '}', '[': ']'}
for i in arr:
# 여는 괄호인지 확인, 괄호면 스택에 추가
if i in P:
stack.append(i)
# 닫는 괄호인지 확인, top과 비교
elif i in P.values():
if stack:
s = stack.pop()
if P[s] != i:
... |
0bdb2a259ae6a04e72b10855fdd1878bf15a77a8 | Gyeol0/TIL | /Algorithm/List_practice/1289. 원재의 메모리 복구하기.py | 289 | 3.59375 | 4 | def Memory(bit):
count = 0
current = '0'
other = '1'
for i in bit:
if i != current:
current, other = other, current
count += 1
return count
T = int(input())
for test in range(1, T+1):
bit = input()
print(f'#{test}', Memory(bit)) |
5e4b5f1d3fa006c1530cccf6a121f157a3935db5 | Gyeol0/TIL | /Algorithm/List_practice/Factorization.py | 402 | 3.703125 | 4 | def Factorization(N):
F = [2, 3, 5, 7, 11]
answer = []
for i in F:
count = 0
while N % i == 0:
count += 1
N //= i
answer.append(count)
return answer
T = int(input())
for test in range(1, T+1):
N = int(input())
result = Factorization(N)
print(f... |
1d60149c79a8ef1655923f0824ebfd1a279d81b5 | Gyeol0/TIL | /Algorithm/Stack_practice/4875. 미로.py | 703 | 3.5 | 4 | dx = [1, -1, 0, 0]
dy = [0, 0, 1, -1]
def DFS(x, y):
global answer
# 도착하면 1
if arr[x][y] == '3':
answer = 1
# 아니면 방문
else:
arr[x][y] = '1'
for k in range(4):
ax = x + dx[k]
ay = y + dy[k]
# 벽이나 방문 한 곳이 아닐 때
if 0 <= ax < N and 0 <= ay < N and arr[a... |
8dec23cfd1bca66e7ce5744f915519a9f04cd061 | pavansw/anzPython | /switch1.py | 611 | 4.0625 | 4 | def my_circle(r):
return 3.14*r*r
def my_square(s):
return s**2
def my_rectange(b,h):
return b*h/2
choice = int(input("enter 1. Area of circle \n 2. Area of square \n 3. Area of rectangle \n 0. To exit"))
if choice==1:
var = eval(input("What is r? "))
print ("Area of Circle is : ",my_circle(var))
elif choice=... |
2c2b4f56fc3f3c0c76ba69866da852edcfbf8186 | Anshikaverma24/to-do-app | /to do app/app.py | 1,500 | 4.125 | 4 | print(" -📋YOU HAVE TO DO✅- ")
options=["edit - add" , "delete"]
tasks_for_today=input("enter the asks you want to do today - ")
to_do=[]
to_do.append(tasks_for_today)
print("would you like to do modifications with your tasks? ")
edit=input("say yes if you would like edit your tasks - ")
if edit=="ye... |
55d8b0d431c7202c7afe1181d87501fa8291ec7c | prometeyqwe/leetcode_problems | /easy/Remove Duplicates from Sorted Array/main.py | 645 | 3.796875 | 4 | """
Given a sorted array nums, remove the duplicates in-place such that each element
appear only once and return the new length. Do not allocate extra space for
another array, you must do this by modifying the input array in-place with O(1)
extra memory
"""
class Solution:
def removeDuplicates(self, nums):
... |
0345861b092d7030b58df46955ff2900b89f470b | Zmolik/smart_calculator | /calculator.py | 9,735 | 4.09375 | 4 | from string import ascii_letters, digits
from collections import deque
stack = deque()
main_postfix = deque()
dic = {}
def is_of_letters_only(string):
"""returns True if the input string consists only of ascii_letters"""
for char in string:
if char not in ascii_letters:
return... |
1ee3b5d9b5c4fe2e769c6b4920cdefd9f8a71e9d | cpscofield/Tools | /src/main/python/rosalind/utils.py | 1,586 | 3.859375 | 4 | """
A class to hold a bunch of simple, commonly-used utility functions.
"""
class Utils(object):
def __init__(self):
pass
def revcomp( self, seq ):
"""
Produce a reverse complement of the sequence.
"""
if 'U' in seq and not 'T' in seq:
return self... |
ebcda70f8266e9795efc8713b4f93de03aeea94a | cpscofield/Tools | /src/main/python/rosalind/mrna.py | 1,477 | 3.640625 | 4 | """
Solution to Rosalind challenge "MRNA: Inferring mRNA from Protein"
See http://rosalind.info/problems/mrna for details.
Attention ROSALIND competitor: if you have not solved this particular
problem yet, it would be unfair to all the other competitoris if you
peruse this code, so please refrain from doing so.
... |
4a310956f38a49ab7976cc8e01455acbec07ef45 | kprashant94/Codes | /BinaryTree/bst_predeccessor.py | 1,267 | 3.828125 | 4 |
########################################################################
# Title: Binary Search Tree
# Algrithm: Predeccessor
# Project: codewarm.in
#
# Description:
# To find the prdecessor of the key k:
# 1. Fnd the node storing key k, let it be x.
# 2. If the x has left subtree then the node having maximum element ... |
c92f38897943131c0240bc6c9518edee6a070240 | kprashant94/Codes | /Stack/stack_push.py | 502 | 3.859375 | 4 |
#####################################################################
# Title: Stacks
# Algorithm: push
# Project: codewarm.in
#
# Description:
# In the this code the method 'push' takes the 'stack' and the key
# (to be inserted in stack) as its aruguments and inserts it at the
# top of the stack by appending the ke... |
951e3d89f407b49534dc9e4ca9bd8e0617520c6f | kprashant94/Codes | /Heaps/MaxPriorityQueue/mpq_insert.py | 640 | 4.09375 | 4 |
##################################################################
# Title: Max Heaps
# Sub-Title: Max Priority Queue
# Algorithm: Insert
#
# Description:
# max_heap_insert(S,x) method inserts key x in the set S.
# time complexity : O()
#
##################################################################
class Ma... |
5b756d1d82866109e23334c7c7c2ae6d52d96187 | kprashant94/Codes | /Queue/queue_isempty.py | 461 | 3.75 | 4 |
#####################################################################
# Title: Queue
# Algorithm: isEmpty
# Project: codewarm.in
#
# Description:
# In the this code the method 'isEmpty' takes the 'queue' as its
# arugument and returns 'True' if 'queue' is empty else returns
# 'False'.
#
###########################... |
8fd287d71484bf0365d14ac9fccdd0e9a023e2af | kprashant94/Codes | /Stack/stack_top.py | 492 | 3.84375 | 4 | #####################################################################
# Title: Stacks
# Algorithm: top element
# Project: codewarm.in
#
# Description:
# In the this code the method 'top' takes the 'stack' as its arugument
# and returns the top element of the stack.
#
##################################################... |
fc73c7c52dcbe9e85c5639d7a40fe7453bb69a8e | kprashant94/Codes | /Fibonacci/fib_rec.py | 223 | 3.546875 | 4 |
def fib_rec(n):
if n==0:
return 0
elif n==1:
return 1
else:
return fib_rec(n-1)+fib_rec(n-2)
print fib_rec(0)
print fib_rec(1)
print fib_rec(2)
print fib_rec(3)
print fib_rec(4)
print fib_rec(5)
print fib_rec(30) |
6fd57771b4a4fdbd130e6d408cd84e02f89f48a4 | Jayasuriya007/Sum-of-three-Digits | /addition.py | 264 | 4.25 | 4 | print ("Program To Find Sum of Three Digits")
def addition (a,b,c):
result=(a+b+c)
return result
a= int(input("Enter num one: "))
b= int(input("Enter num one: "))
c= int(input("Enter num one: "))
add_result= addition(a,b,c)
print(add_result)
|
2da2d69eb8580ba378fac6dd9eff065e2112c778 | sk24085/Interview-Questions | /easy/maximum-subarray.py | 898 | 4.15625 | 4 | '''
Given an integer array nums, find the contiguous subarray (containing at least one number) which has the largest sum and return its sum.
A subarray is a contiguous part of an array.
Example 1:
Input: nums = [-2,1,-3,4,-1,2,1,-5,4]
Output: 6
Explanation: [4,-1,2,1] has the largest sum = 6.
Example 2:
Input: nums ... |
daa21099590ab6c4817de8135937e9872d2eb816 | sk24085/Interview-Questions | /easy/detect-capital.py | 1,464 | 4.34375 | 4 | '''
We define the usage of capitals in a word to be right when one of the following cases holds:
All letters in this word are capitals, like "USA".
All letters in this word are not capitals, like "leetcode".
Only the first letter in this word is capital, like "Google".
Given a string word, return true if the usage of ... |
9ad73537eaff31b96e6b5cb98718c578e93555c7 | shimulhawladar/python3 | /hangManGame.py | 1,253 | 3.90625 | 4 | from getpass import getpass
print("Welcome to Hang Man Game!")
word = ""
while word == "": word = getpass("Guess a word: ").lower()
word = list(word); word_pop = word.copy()
targeted = []
hint = input("later you want thow show : ").lower()
if hint != "":
for w in word:
if hint[0] == w: targeted.append(hi... |
7791b08606ad91a802309940263da56784d67efd | Hyacinth-OR/415Project2 | /Project2.py | 1,951 | 3.53125 | 4 | def karatsuba_mult2(x,y):
if x < 10 or y < 10:
return x * y
else:
# Calculate the number of digits of the numbers
sx, sy = str(x), str(y)
m2 = max(len(sx), len(sy)) // 2
# Split the digit sequences about the middle
ix = len(sx) - m2
iy = len(sy)... |
ed64a53350a9bf30fe5e7f9dca79d2f23611ec44 | saurabhshrivastava/expression | /parser.py | 3,220 | 3.6875 | 4 |
# stmt = [ expr ]
# expr = expr OR term | term
# term = term AND factor | factor
# factor = NOT factor | atom
# atom = ( expr ) | NUM
# stmt = [ expr ]
# expr = term expr_
# expr_ = OR term expr_ | eps
# term = factor term_
# term_ = AND factor term_ | eps
# factor = NOT factor | atom
# atom = ( expr ) | NUM
i... |
63509453c08fd578d146b270a3b32a02285544fb | BagiJ/Algorithms | /vezba05/bst.py | 4,530 | 4.34375 | 4 | class Node:
"""
Tree node: left child, right child and data
"""
def __init__(self, p = None, l = None, r = None, d = None):
"""
Node constructor
@param A node data object
"""
self.parent = p
self.left = l
self.right = r
self.data = d
cl... |
86d1aabf783754c982baf6e08ca50fb6304f48ee | ryrimnd/basic-python-d | /b-list.py | 199 | 3.53125 | 4 | wishlist = ["Microphone", "Monitor", "Camera", "Camera Lens"]
#print(wishlist)
#print(wishlist[1])
#print(wishlist[0][2])
wishlist.append("Keyboard")
print(wishlist)
for x in wishlist:
print(x) |
997899682fd6b3da055864d1e339640e4d049f67 | 0xti4n/holbertonschool-higher_level_programming | /0x0A-python-inheritance/101-add_attribute.py | 273 | 3.921875 | 4 | #!/usr/bin/python3
""" function that adds a new attribute
to an object if it’s possible
"""
def add_attribute(self, name, new):
"""adds a new attribute to an object"""
try:
self.name = new
except:
raise TypeError('can\'t add new attribute')
|
88b9801928aff74686aebd58e31776f2e063d6eb | SkqLiao/Project-Euler | /code/51-100/65.py | 237 | 3.515625 | 4 | if __name__ == '__main__':
f = [2]
for i in range(33):
f += [1, 2 * i + 2, 1]
up, down = 1, 1
for i in range(len(f) - 2, -1, -1):
newup = up + down * f[i]
up = down
down = newup
print(sum(map(int, list(str(down))))) |
ddc0722d92fdb0e09b77a943ef9c2ff4f1614f18 | timsamson/Python-Challange | /PyBank/Main.Py | 1,778 | 3.71875 | 4 | #import Modules
import os
import csv
#Define Variables
month_count = 0
net_revenue = 0
profit = 0
max_rev = 0
min_rev = 0
monthly_change = 0
#create lists
dates = []
revenue = []
#location of resources
data_csv = os.path.join( "Resources", "budget_data.csv")
with open(data_csv) as csvfile:
csv_reader = csv.reade... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.