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
cf8d0e2ad3a4c37bfc5d197d7f33e3b55e030e1a
wisesky/LeetCode-Practice
/src/275.h-index-ii.py
1,842
3.6875
4
# # @lc app=leetcode id=275 lang=python3 # # [275] H-Index II # # https://leetcode.com/problems/h-index-ii/description/ # # algorithms # Medium (36.51%) # Likes: 579 # Dislikes: 907 # Total Accepted: 146.3K # Total Submissions: 400.1K # Testcase Example: '[0,1,3,5,6]' # # Given an array of integers citations whe...
16a28d36f0bf2ba627a8bb4b3558f5ed1bf04ca7
wisesky/LeetCode-Practice
/src/33. Search in Rotated Sorted Array.py
2,740
3.5625
4
from typing import List class Solution: def search(self, nums: List[int], target: int) -> int: if len(nums) == 0 : return -1 st =0 ed = len(nums)-1 # mid = (st+ed) // 2 while st <= ed: mid = (st+ed) // 2 print(st, mid, ed) ...
06691b22a92eb56cbb2b25cee7668b6c388851c9
wisesky/LeetCode-Practice
/src/110. Balanced Binary Tree.py
576
3.75
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: def isBalanced(self, root: TreeNode) -> bool: # if root == None: # return True r, _ = self...
48a535e67a65486730aaa4f2d10e77be8609e6e4
alexsnow348/Full_Stack
/PYTHON/Prank/main.py
588
3.734375
4
from os import listdir, rename # from os.path import isfile def rename_file(_dir): # Get the file name from folder lists = listdir(_dir) # print(lists) for name in lists: trantab = name.maketrans("0123456789"," ","0123456789") new_name = name.translate(trantab) old_pat...
31e121e4facd9b159492a8195ea4316317aa766d
brunnacroches/python-calculadora
/3.0CalculoDaApp.py
1,422
4.375
4
#CALCULADORA DE PINTURA# #Bem, agora pegando todos os dados do usario # vamos fazer todos os calculos que faltam definir # a litragem de tinta necessaria para fazer a nossa calculadora de pintura #CALCULADORA DE PINTURA# #1- REMOVER A EXPRESSAO DO PRINT E COLOCA-LA DENTRO DE UMA VARIAVEL # VARIAVEL CHAMADA DE AREA ...
68727bd46246a89c9e4d760ee030a4a7b6e2ef10
brunnacroches/python-calculadora
/4.4Identacao.py
729
3.640625
4
# >>>>criar um objeto da classe Calculadora # >>>> ele vai ter um atributo chamado area_paredes # >>>> e esse abrituto vai ser igual a zero # >>>>esses 4 espacos sao o que definem que essa variavel # >>>>esta dentro da calculador...
9ed99d11848417e4addbf425c1b85a42b46742cd
jackparra253/pythonya
/ejercicio12.py
510
3.71875
4
#Se ingresan tres notas de un alumno, si el promedio es mayor o igual a siete mostrar un mensaje "Promocionado". mensaje_ingresar_nota = "Ingrese la nota del alumno: " primera_nota = int(input(mensaje_ingresar_nota)) segunda_nota = int(input(mensaje_ingresar_nota)) tercera_nota = int(input(mensaje_ingresar_nota)) to...
acfa9d5fd8f1c22e0a15d8e26ef8882c8de07907
jackparra253/pythonya
/ejercicio19.py
515
4.15625
4
#Confeccionar un programa que lea por teclado tres números enteros distintos y nos muestre el mayor mensaje = "Ingrese un número " numero_uno = int(input(mensaje)) numero_dos = int(input(mensaje)) numero_tres = int(input(mensaje)) if numero_uno > numero_dos and numero_uno > numero_tres: print(numero_uno) else: ...
44681eddcd5168da60834ff2ec601f8a37005448
jackparra253/pythonya
/ejercicio24.py
472
4
4
# Se ingresan por teclado tres números, si al menos uno de los valores ingresados es menor a 10, # imprimir en pantalla la leyenda "Alguno de los números es menor a diez". diez = 10 mensaje = "Ingrese un número: " numero_uno = int(input(mensaje)) numero_dos = int(input(mensaje)) numero_tres = int(input(mensaje)) if ...
9793e5d0d09d1f3ba86a0c19c43bd1e0bab17e51
tanran-cn/arithmetic-data_structure-py
/arithmetic/mergesort.py
1,578
3.953125
4
# _*_ coding: utf-8 _*_ # 2019/3/23 14:19 __auther__ = "tanran" def merge_sorted_list(sorted_a, sorted_b): """ 合并两个有序数列 :param sorted_a:有序数列a :param sorted_b: 有序数列b :return: 合并后的有序数列 """ length_a, length_b = len(sorted_a), len(sorted_b) index_a = index_b = 0 new_sorted = [] w...
26a43e8b4512706ddf78167a73b3b763369d089c
omakasekim/2020_SoftwareDesign
/Code/5-1/1.py
419
3.6875
4
Student = {} count = 0 def InputNameScore(): global count studentName , studentScore = input().split() Student[studentName] = studentScore count +=1 if(count <5): InputNameScore() InputNameScore() userInput = input("Which student's score?\n") if(userInput in Student.keys()): print(userI...
1caefc145fe3cda3e4573d41b8aa88216387772b
omakasekim/2020_SoftwareDesign
/Code/3-2/4.py
145
3.796875
4
num = int(input()) i=0 while(i<num): j=0 while(j<i+1): print('*', end='') j+=1 if(i!=num-1): print() i+=1
2faf23634a209ff9b6adcd47ef3a06402e659109
Codeman655/task2-dm-project
/parsers.py
1,995
3.796875
4
#!/usr/bin/python ''' Parsers ''' import sys,os ''' This gets you the dictionary index given a word Returns: index on success when using this with the matrix it's matrix[quest][key1] -1 on failure ''' def get_word_index(word, dict): for key in dict.keys(): if word == dict[key]: return key return ...
8d861e7264140f645606c7f3c4e5a02ef6f24a52
Huang-Min-Xiong/Crawler_PTT_Movie
/Crawler_PTT_Movie.py
1,339
3.515625
4
import sqlite3 import urllib.request as req from bs4 import BeautifulSoup #取得資料 def GetData(url): #設置Request Headers的資訊 request = req.Request(url,headers={ "user-agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.108 Safari/537.36" }) with...
091f7dfec9d426452fa7c9afb1758b7cb97d40f4
Siyamukela/115392
/Binary Search.py
13,037
3.6875
4
import sqlite3, time def login(): while True: username = input("Please enter your username: ") password = input("Please enter your password: ") with sqlite3.connect("login.db") as db: cursor = db.cursor() find_user = ("SELECT * FROM user WHERE username = ? AND pa...
0edc9be60c21387e26662b8573ea31b3f7057671
zihaowangcmu/Python-Game-Dropour
/Drop.py
598
3.640625
4
############################################################################################# # This is the class Drop # This class defines the movement of drop ############################################################################################# class Drop(): def __init__(drop,x,y): drop.x = ...
bf7327ad7244cb2f888dcc1535f6228f20e728a7
keithsm/python-specialization
/Fifth_Assignment/continue_example.py
200
3.9375
4
while True: line = input('>') #if line[0] reads as "If the first character entered is a pound sign" if line[0] == '#' : continue if line == 'done' : break print(line) print('Done!')
1bf86108fe73ed2004793ad957e6c0c631a3aa51
keithsm/python-specialization
/Seventh_Assignment/input_read_upper.py
409
4.625
5
#Assignment 7.1 #Program that prompts for a file name, then opens that file and #reads through the file, and print the contents of the file in upper case. #Input and open the the file fname = input ('Enter the name of the file: ') file_contents = open (fname) #Read the file contents text = file_contents.read() text =...
f9c5f7c4e9c4e2ce9e5eb502c067b8a18ff9fd56
keithsm/python-specialization
/Sixth_Assignment/find_replace_slice.py
283
3.59375
4
text = "X-DSPAM-Confidence: 0.8475" #Find position of a common delimiter ':' pos=text.find(':') #Get the balance of the string past the ':' rawvalue = (text[pos + 1 :]) #strip whitespace and convert string to float and print convalue = float(rawvalue.strip()) print (convalue)
d66b03850f84eaf6dc8403bccba0cf798db1d0e3
Biuku/KNN_Game
/algo.py
3,497
3.59375
4
""" April 24, 2021 """ import pygame import math as m import numpy as np from setup.printr import Printr from arr import Arr from draw import Draw class Algo(Arr): def __init__(self, win): super().__init__() pygame.init() self.win = win self.printr = Printr(self.win) self...
e3ec3047adc2c04aa6a184cb286e08449dcadafe
alandaleote/Algoritmos-II
/Aula03/Lista.py
2,581
3.625
4
from No import No class Lista: def __init__(self): self.inicio = None self.fim = None self.tamanho = 0 def __len__(self): return self.tamanho def adicionar_inicio(self, dado): no = No(dado) if self.tamanho == 0: self.inicio = no s...
af73c1e95044953a0fcf88f0bce2f3622a2dd110
alandaleote/Algoritmos-II
/Aula01/atividade_aula01.py
2,055
4.25
4
''' Construir um algoritmo que contenha 3 listas: • Nomes de produtos • Preços de cada produto • Quantidades de cada produto • Construir uma função para imprimir um dos produtos da lista e uma função para retirar um dos produtos das listas ''' nome_produto = [] preco_produto = [] quantidade_produto = [] def inserir_p...
1708ba01af55f49a00f835d4872ce553a8a01cd1
Goldenresolver/Functions-and-pizza
/happy 3 using write to a file.py
876
4.125
4
def happy(): return "Happy Birthday to you!|n" # the magic of value returning functions is we have streamlined the #program so that an entire verse is built in a single string expression. # this line really illustrates the power and beauty of value returning functions. # in this line we are calling happy() f...
f201cea50e49f480c357d05536e24df1279e18c1
leilalu/algorithm
/剑指offer/第四遍/11.旋转数组的最小数字.py
1,207
3.921875
4
""" 把一个数组最开始的若干个元素搬到数组的末尾,我们称之为数组的旋转。输入一个递增排序的数组的一个旋转,输出旋转数组的最小元素。 例如,数组 [3,4,5,1,2] 为 [1,2,3,4,5] 的一个旋转,该数组的最小值为1。   示例 1: 输入:[3,4,5,1,2] 输出:1 示例 2: 输入:[2,2,2,0,1] 输出:0 """ class Solution: def minArray(self, numbers): if not numbers or len(numbers) <= 0: return None left = 0 ...
e47f4fbd7866bd272fae080bc44af55004c66ceb
leilalu/algorithm
/剑指offer/第一遍/stack&queue/59-2.队列的最大值.py
943
4.125
4
""" 题目二:队列的最大值 请定义一个队列并实现函数max得到队列里的最大值,要求函数max、push_back和pop_front的时间复杂度都是O(1) """ class MaxQueue: def __init__(self): # python内置的deque的popleft 时间复杂度才是O(1),python数组的pop(0)的时间复杂度是O(n) from collections import deque self.data = deque() # 原始队列 self.max_data = deque() # 辅助队列 d...
96e25313fb7f457fb0aced433a64ecc1d4380c0b
leilalu/algorithm
/剑指offer/第四遍/64.求1+2+...+n.py
1,003
3.609375
4
""" 求 1+2+...+n ,要求不能使用乘除法、for、while、if、else、switch、case等关键字及条件判断语句(A?B:C)。 示例 1: 输入: n = 3 输出: 6 示例 2: 输入: n = 9 输出: 45   限制: 1 <= n <= 10000 """ class Solution: def sumNums(self, n): """" 使用递归法代替循环的唯一问题在于,怎么判判断递归的结束条件。 本题中的结束条件是当 n 减为0时 不应该再继续递归调用了 应该返回0 利用了P...
4b7e5f65d65791fbc076bda44a36f848e109006a
leilalu/algorithm
/剑指offer/第一遍/array/37.正则表达式匹配.py
2,889
3.5625
4
""" 题目描述 请实现一个函数用来匹配包括'.'和'*'的正则表达式。 模式中的字符'.'表示任意一个字符,而'*'表示它前面的字符可以出现任意次(包含0次)。 在本题中,匹配是指字符串的所有字符匹配整个模式。 例如,字符串"aaa"与模式"a.a"和"ab*ac*a"匹配,但是与"aa.a"和"ab*a"均不匹配 """ class Solution: def match(self, s, pattern): """ 思路:当模式中的第二个字符是“*”时: 如果字符串第一个字符跟模式第一个字符不匹配,则模式后移2个字符,继续匹配。 ...
3310ebaeeb45761e15c82f0b8db3eb4f0c81ad79
leilalu/algorithm
/剑指offer/第一遍/search/29.旋转数组的最小数字.py
4,045
4
4
""" 题目描述 把一个数组最开始的若干个元素搬到数组的末尾,我们称之为数组的旋转。 输入一个【非递减排序】的数组的一个【旋转】,输出旋转数组的最小元素。 例如数组{3,4,5,1,2}为{1,2,3,4,5}的一个旋转,该数组的最小值为1。 NOTE:给出的所有元素都大于0,若数组大小为0,请返回0。 """ class Solution1: def minNumberInRotateArray(self, rotateArray): """ 暴力法:遍历所有的元素 观察旋转数组,旋转数组最大的元素应该与最小的元素相邻,且最大值在左,最小值在右,即左边大于右边...
d043a003f818bdb6acaa2aa0236af89860a51200
leilalu/algorithm
/剑指offer/第四遍/54.二叉搜索树的第k大节点.py
984
3.546875
4
""" 给定一棵二叉搜索树,请找出其中第k大的节点。   示例 1: 输入: root = [3,1,4,null,2], k = 1 3 / \ 1 4 \   2 输出: 4 示例 2: 输入: root = [5,3,6,2,4,null,null,1], k = 3 5 / \ 3 6 / \ 2 4 / 1 输出: 4 """ class TreeNode: def __init__(self, x): self.val = x self.left = None sel...
84089da211d4a2fd2a2319633fea1ff8e6d27f3e
leilalu/algorithm
/剑指offer/第五遍/59-1.滑动窗口的最大值.py
1,471
3.90625
4
""" 给定一个数组 nums 和滑动窗口的大小 k,请找出所有滑动窗口里的最大值。 示例: 输入: nums = [1,3,-1,-3,5,3,6,7], 和 k = 3 输出: [3,3,5,5,6,7] 解释: 滑动窗口的位置 最大值 --------------- ----- [1 3 -1] -3 5 3 6 7 3 1 [3 -1 -3] 5 3 6 7 3 1 3 [-1 -3 5] 3 6 7 5 1 3 -1 [-3 5 3] 6 7 5 1 3 ...
b594bb0709bc987ea1b4585fb91b4b1b2525a437
leilalu/algorithm
/剑指offer/第五遍/22-2.求链表的中间结点.py
542
3.75
4
""" 题目描述 求链表的中间结点。 如果链表中的结点总数为奇数,则返回中间结点;如果结点总数是偶数,则返回中间两个结点的任意一个。 """ class Solution: def FindMiddleNode(self, head): if not head: return None first = second = head while first.next: next = first.next if next.next: first = next.next...
cc4ba6a05a199e723f03017e00bb6ebe48be6601
leilalu/algorithm
/剑指offer/第四遍/37.序列化二叉树.py
1,757
3.9375
4
""" 请实现两个函数,分别用来序列化和反序列化二叉树。 示例: 你可以将以下二叉树: 1 / \ 2 3 / \ 4 5 序列化为 "[1,2,3,null,null,4,5]" """ class TreeNode(object): def __init__(self, x): self.val = x self.left = None self.right = None class Codec: def serialize(self, root): """Encodes a tree ...
a3a323105fc3ce315912054baa8934bdd8a4390d
leilalu/algorithm
/剑指offer/第五遍/32-3.之字形打印二叉树.py
1,361
3.75
4
""" 请实现一个函数按照之字形顺序打印二叉树,即第一行按照从左到右的顺序打印,第二层按照从右到左的顺序打印,第三行再按照从左到右的顺序打印,其他行以此类推。 例如: 给定二叉树: [3,9,20,null,null,15,7], 3 / \ 9 20 / \ 15 7 返回其层次遍历结果: [ [3], [20,9], [15,7] ] """ class Solution: def levelOrder(self, root): if not root: return [] res = [] ...
a4d3d77b735a93d7d4c41c53b569e6dbc93b0de1
leilalu/algorithm
/剑指offer/第一遍/array/55.数组中的逆序对.py
3,578
3.8125
4
""" 题目描述 在数组中的两个数字,如果前面一个数字大于后面的数字,则这两个数字组成一个逆序对。 输入一个数组,求出这个数组中的逆序对的总数P。并将P对1000000007取模的结果输出。 即输出P%1000000007 输入描述: 题目保证输入的数组中没有的相同的数字 数据范围: 对于%50的数据,size<=10^4 对于%75的数据,size<=10^5 对于%100的数据,size<=2*10^5 示例1 输入 1,2,3,4,5,6,7,0 输出 7 """ class Solution: def InversePairs(self, data): """" ...
f4f23dd68d3069f5d424e36e6e5b0e5e6a7759ac
leilalu/algorithm
/剑指offer/第一遍/recursive/25.n个骰子的点数.py
4,303
3.859375
4
""" 题目描述: 把n个骰子扔在地上,所有骰子朝上的一面的点数之和为s。 输入n,打印出s的所有可能的值出现的概率。 """ class Solution1: # 基于循环求点数, 时间性能好 def PrintProbability(self, number): """ 用两个数组来存储骰子点数的每一个总数出现次数。 在一次循环中,第一个数组中的第n个数字表示骰子和为n出现的次数。 在下一次循环中加入一个新的骰子,此时和为n的骰子出现的次数应该等于上一次循环中骰子点数和为n-1,n-2,n-3,n-4,n-5,n-6的...
0280e97048b01dc05c9bc29ef960f503b9d07df4
leilalu/algorithm
/剑指offer/第二遍/10-2.跳台阶.py
389
3.546875
4
""" 题目: 一只青蛙一次可以跳上1级台阶,也可以跳上2级台阶。求该青蛙跳上一个n级台阶总共可以有多少次条法 """ class Solution: def Jump(self, number): if number < 0: return None array = [1, 1] for i in range(2, number+1): array[i % 2] = array[0] + array[1] return array[number % 2]
da381a3fef91cd468b93fd05ec8c5a3a2f1e9f56
leilalu/algorithm
/二叉树/LeetCode/111.二叉树的最小深度.py
3,985
3.9375
4
""" 给定一个二叉树,找出其最小深度。 最小深度是从根节点到最近叶子节点的最短路径上的节点数量。 说明: 叶子节点是指没有子节点的节点。 示例: 给定二叉树 [3,9,20,null,null,15,7], 3 / \ 9 20 / \ 15 7 返回它的最小深度  2. """ class TreeNode: def __init__(self, x): self.val = x self.left = None self.right = None class Solution1: def minDepth...
9c964d8904d64445d4269be5c02795835697ca1c
leilalu/algorithm
/剑指offer/第一遍/array/39.调整数组顺序使奇数位于偶数前面.py
3,372
3.796875
4
""" 题目描述 输入一个整数数组,实现一个函数来调整该数组中数字的顺序,使得所有的奇数位于数组的前半部分,所有的偶数位于数组的后半部分, 并保证奇数和奇数,偶数和偶数之间的【相对位置】不变。 """ class Solution1: def reOrderArray(self, array): """ 暴力法,读取两遍数组,并用额外的空间保存新数组,第一遍读奇数,第二遍读偶数 :param array: :return: """ if not array or len(array) == 0: r...
afddd511ae83be85fc7706f6cf946ba2ef684f0a
leilalu/algorithm
/二叉树/LeetCode/110.平衡二叉树.py
1,183
3.5625
4
"""" 给定一个二叉树,判断它是否是高度平衡的二叉树。 本题中,一棵高度平衡二叉树定义为: 一个二叉树每个节点 的左右两个子树的高度差的绝对值不超过1。 示例 1: 给定二叉树 [3,9,20,null,null,15,7] 3 / \ 9 20 / \ 15 7 返回 true 。 示例 2: 给定二叉树 [1,2,2,3,3,null,null,4,4] 1 / \ 2 2 / \ 3 3 / \ 4 4 返回 false 。 """ class TreeNode: def __init__...
0b01dd3d6c9fae6d5f8c5441826cb5e3aea9e5bf
leilalu/algorithm
/剑指offer/第一遍/tree/17.二叉树中和为某一值的路径.py
3,850
3.84375
4
""" 题目描述 输入一棵二叉树的根节点和一个整数,打印出二叉树中结点值的和为输入整数的所有路径。 路径定义为从树的根结点开始往下一直到叶结点所经过的结点形成一条路径。(注意: 在返回值的list中,数组长度大的数组靠前) """ """ 深度优先遍历(DFS)的写法: 递归写法: def binaryTreePaths(self, root): if not root: return [] result = [] self.DFS(root, result, [root.val]) return result def ...
45f8dbaf8a85344931335070d7e1701384c786c4
leilalu/algorithm
/剑指offer/第二遍/10-4.矩形覆盖.py
456
3.859375
4
""" 题目描述 我们可以用2*1的小矩形横着或者竖着去覆盖更大的矩形。请问用n个2*1的小矩形无重叠地覆盖一个2*n的大矩形,总共有多少种方法? """ class Solution: def rectCover(self, n): if n < 0: return 0 if n == 0: return 0 array = [1, 1] for i in range(2, n+1): array[i % 2] = array[0] + array[1] retur...
8ab7440e90e5d9527d973428e86a20cccf336aca
leilalu/algorithm
/剑指offer/第一遍/search/30-3.数组中数值和下标相等的元素.py
1,522
4.125
4
""" 题目三:数组中数值和下标相等的元素 假设一个单调递增的数组里的每个元素都是整数并且是唯一的。请编程实现一个函数,找出数组中任意一个数值等于其下标的元素。 例如,在数组[-3,-1,1,3,5]中,数字3和它下标相等。 """ class Solution1: def GetNumberSameAsIndex(self, numbers): """ 暴力法,顺序遍历数组 """ # 检查无效输入 if not numbers: return for i in range(len(...
a421b259b46f3b72ac1c5b5f2b1aa2cd697489cb
leilalu/algorithm
/二叉树/LeetCode/93.不同的二叉搜索树.py
850
3.609375
4
""" 给定一个整数 n,求以 1 ... n 为节点组成的二叉搜索树有多少种? 示例: 输入: 3 输出: 5 解释: 给定 n = 3, 一共有 5 种不同结构的二叉搜索树: 1 3 3 2 1 \ / / / \ \ 3 2 1 1 3 2 / / \ \ 2 1 2 3 """ class Solution: def numTrees(se...
03bdbf7857ae16c8d9d3a0112336abdd284aba82
leilalu/algorithm
/剑指offer/第二遍/16.数值的整数次方.py
1,485
4.21875
4
""" 题目描述 给定一个double类型的浮点数base和int类型的整数exponent。求base的exponent次方。 保证base和exponent不同时为0 """ class Solution1: def Power(self, base, exponent): """" base = 0 exp = 0 0 base = 0 exp > 0 0 base = 0 exp < 0 倒数无意义 base > 0 exp > 0 累乘 base > 0 exp < 0 累乘 取倒数 base >...
368bd1aab12e8757f56d16cb3822ed15851cdd22
leilalu/algorithm
/剑指offer/第四遍/49.丑数.py
1,081
3.640625
4
""" 我们把只包含因子 2、3 和 5 的数称作丑数(Ugly Number)。求按从小到大的顺序的第 n 个丑数。 示例: 输入: n = 10 输出: 12 解释: 1, 2, 3, 4, 5, 6, 8, 9, 10, 12 是前 10 个丑数。 说明: 1 是丑数。 n 不超过1690。 """ class Solution: def nthUglyNumber(self, n): if n < 1: return 0 dp = [0] * n dp[0] = 1 index2 = 0 index3 ...
7c914dcf10b51cd00c6f6f4c3aa6e6ee60c139ea
leilalu/algorithm
/剑指offer/第四遍/28.对称的二叉树.py
3,581
3.84375
4
""" 请实现一个函数,用来判断一棵二叉树是不是对称的。如果一棵二叉树和它的镜像一样,那么它是对称的。 例如,二叉树 [1,2,2,3,4,4,3] 是对称的。 1 / \ 2 2 / \ / \ 3 4 4 3 但是下面这个 [1,2,2,null,3,null,3] 则不是镜像对称的: 1 / \ 2 2 \ \ 3 3 示例 1: 输入:root = [1,2,2,3,4,4,3] 输出:true 示例 2: 输入:root = [1,2,2,null,3,null,3] 输出:false """ class TreeNode: ...
dda02aad9b6b13583cdd91d31ab74e027ef73f5d
leilalu/algorithm
/剑指offer/第一遍/bit/33-3.改变m的二进制表示中的多少位才能得到n.py
763
4.09375
4
""" 题目描述 输入两个整数m和n,计算需要改变m的二进制表示中的多少位才能得到n。 比如,10的二进制表示为1010,13的二进制表示为1101,需要改变1010中的3位才能得到1101。 """ class Solution: def Change(self, m, n): """ 可以分为两步进行: 第一步:求两个数的异或 第二步:统计异或结果中1的位数 """ # 第一步:求异或 s = m ^ n # 第二步:计算二进制表示中1的个数 count...
82f9b479f9c49fa935cba7a2447829d534757abb
leilalu/algorithm
/剑指offer/第一遍/array/57-2.和为s的连续正数序列.py
1,939
4
4
""" 题目描述 小明很喜欢数学,有一天他在做数学作业时,要求计算出9~16的和,他马上就写出了正确答案是100。 但是他并不满足于此,他在想究竟有多少种连续的正数序列的和为100(至少包括两个数)。 没多久,他就得到另一组连续正数和为100的序列:18,19,20,21,22。现在把问题交给你,你能不能也很快的找出所有和为S的连续正数序列? Good Luck! 输出描述: 输出所有和为S的连续正数序列。序列内按照从小至大的顺序,序列间按照开始数字从小到大的顺序 输入一个正数s,打印出所有和为s的连续正数序列(至少含有两个数) 例如,输入15,由于1+2+3+4+5 = 4+5+6 = 7+8 = 15 所以打印出3个连续序...
1b788ed26371d117fb008e34947901a28423aebd
leilalu/algorithm
/剑指offer/第二遍/08.二叉树的下一个节点.py
1,115
4.15625
4
""" 题目: 给定一棵二叉树和其中的一个节点,如何找【中序遍历】序列的下一个结点? 树中的结点除了有两个分别指向左、右子结点的指针,还有一个指向父结点的指针。 """ def FindNextNode(pNode): """" 如果是根结点:如果有右结点,返回右结点 如果没有右结点,是否有父结点: 如果有父结点: 它是左子结点:返回父结点 它是右子结点:返回父结点的父结点,直到某个父结点是左子结点 ...
78e05511a05b0ab901e8772cc04b86aa29a26a40
leilalu/algorithm
/剑指offer/第五遍/59-2.队列的最大值.py
1,219
4.125
4
""" 请定义一个队列并实现函数 max_value 得到队列里的最大值,要求函数max_value、push_back 和 pop_front 的均摊时间复杂度都是O(1)。 若队列为空,pop_front 和 max_value 需要返回 -1 示例 1: 输入: ["MaxQueue","push_back","push_back","max_value","pop_front","max_value"] [[],[1],[2],[],[],[]] 输出: [null,null,null,2,1,2] 示例 2: 输入: ["MaxQueue","pop_front","max_value"] [[],[],[]] 输...
3726a8df13efdf8702892f3ef38c5d7d28be7669
leilalu/algorithm
/剑指offer/第三遍/16.数值的整数次方.py
2,079
3.96875
4
""" 实现函数double Power(double base, int exponent),求base的exponent次方。不得使用库函数,同时不需要考虑大数问题。   示例 1: 输入: 2.00000, 10 输出: 1024.00000 示例 2: 输入: 2.10000, 3 输出: 9.26100 示例 3: 输入: 2.00000, -2 输出: 0.25000 解释: 2-2 = 1/22 = 1/4 = 0.25 """ class Solution1: def myPow(self, x, n): """" 循环累乘做乘方,会超时 ...
16bae73784752dc5107eab2617aea2b95d40084e
leilalu/algorithm
/剑指offer/第三遍/53-2.0~n-1中缺失的数字.py
540
3.515625
4
class Solution: def missingNumber(self, nums): if not nums or len(nums) <= 0: return None left = 0 right = len(nums) - 1 while left <= right: mid = left + ((right - left) >> 1) if nums[mid] == mid: left = mid + 1 else: ...
e96f65da16b73a61426d3b554d3dafa19d7e9c0e
leilalu/algorithm
/剑指offer/第三遍/21.调整数组顺序使奇数位于偶数前面.py
934
3.703125
4
""" 输入一个整数数组,实现一个函数来调整该数组中数字的顺序,使得所有奇数位于数组的前半部分,所有偶数位于数组的后半部分。   示例: 输入:nums = [1,2,3,4] 输出:[1,3,2,4] 注:[3,1,2,4] 也是正确的答案之一。   提示: 1 <= nums.length <= 50000 1 <= nums[i] <= 10000 """ class Solution: def exchange(self, nums): if not nums or len(nums) <= 0: return [] left = 0 ...
40367af09c02d81feaec515f24d78fa2f7599033
leilalu/algorithm
/剑指offer/第一遍/array/53.把数字翻译成字符串.py
2,183
3.59375
4
""" 题目描述 给定一个数字,我们按照如下规则把它翻译成字符串: 0翻译成'a',1翻译成'b'……11翻译成'1',……25翻译成'z'。 一个数字可能有多个翻译。例如:12258有5种不同的翻译,分别是'bccfi'、'bwfi'、'bczi'、'mcfi'和'mzi' 请编程实现一个函数,用来计算一个数字有多少种不同的翻译方法。 """ class Solution: def GetTranslationCount(self, number): """" 定义函数f(i)表示从第i位数字开始的不同翻译数目,题目最后会返回f(0) f(i) = ...
ce9c7d4ed641ef86fa8c8df0726df90f6c0d4216
leilalu/algorithm
/剑指offer/第一遍/linkedlist/06-2.删除链表中重复的节点.py
2,398
3.828125
4
""" 题目二:删除链表中重复的节点 在一个排序的链表中,存在重复的结点,请删除该链表中重复的结点,重复的结点不保留,返回链表头指针。 例如,链表1->2->3->3->4->4->5 处理后为 1->2->5 """ class ListNode: def __init__(self, x): self.val = x self.next = None def __del__(self): self.val = None self.next = None class Solution: def deleteDuplication(...
2e8e2cae2b7392ce58e0ffdda73d35b7b834a96d
leilalu/algorithm
/剑指offer/第五遍/55-2.平衡二叉树.py
885
3.734375
4
""" 输入一棵二叉树的根节点,判断该树是不是平衡二叉树。如果某二叉树中任意节点的左右子树的深度相差不超过1,那么它就是一棵平衡二叉树。 """ class TreeNode: def __init__(self, x): self.val = x self.left = None self.right = None class Solution: def isBalanced(self, root): return self.isBalancedCore(root) != -1 def isBalancedCore(self, roo...
0f22ec392ae63f511031b417ac5940b8e3ecda9d
leilalu/algorithm
/剑指offer/第五遍/10-4.矩形覆盖.py
400
3.8125
4
""" 题目描述 我们可以用2*1的小矩形横着或者竖着去覆盖更大的矩形。请问用n个2*1的小矩形无重叠地覆盖一个2*n的大矩形,总共有多少种方法? """ class Solution: def rectCover(self, n): if n < 1: return 0 tmp = [1, 1] for i in range(2, n+1): tmp[i % 2] = tmp[0] + tmp[1] return tmp[n % 2]
82ef0942369e22c9af0219890c4e5594e2f34717
leilalu/algorithm
/剑指offer/第三遍/55-2.平衡二叉树.py
573
3.703125
4
class Solution: def isBalanced(self, root): return self.isBalancedCore(root) != -1 def isBalancedCore(self, root): if not root: return 0 left = self.isBalancedCore(root.left) if left == -1: return -1 right = self.isBalancedCore(root.right) ...
39d93508cdac623f964bec181da2af020fa40443
leilalu/algorithm
/剑指offer/第三遍/48.最长不含重复字符的子字符串.py
1,554
3.515625
4
""" 请从字符串中找出一个最长的不包含重复字符的子字符串,计算该最长子字符串的长度。   示例 1: 输入: "abcabcbb" 输出: 3 解释: 因为无重复字符的最长子串是 "abc",所以其长度为 3。 示例 2: 输入: "bbbbb" 输出: 1 解释: 因为无重复字符的最长子串是 "b",所以其长度为 1。 示例 3: 输入: "pwwkew" 输出: 3 解释: 因为无重复字符的最长子串是 "wke",所以其长度为 3。   请注意,你的答案必须是 子串 的长度,"pwke" 是一个子序列,不是子串。 """ class Solution: def lengthOfLongestSub...
6c77c365c2fc2eb045fcee57246229cb39f0bf14
leilalu/algorithm
/剑指offer/第一遍/search/30-2.0~n-1中缺失的数字.py
2,503
3.640625
4
""" 题目二:0~n-1中缺失的数字 一个长度为n-1的递增排序数组中的所有数字都是唯一的,并且每个数字都在范围0~n-1之内。 在范围0~n-1内的n个数字中有且只有一个数字不再该数组中,请找出这个数字。 """ class Solution1: def GetMissingNumber(self, numbers, length): """ 暴力法: 可以先计算出 0~n-1内n个数字的和 即 n(n-1)/2 然后计算出数组中元素的和 两和之差就是缺少的那个元素 ...
5f9d9c318770b69bb6a638aeeb7592674cefdd2f
leilalu/algorithm
/剑指offer/第一遍/linkedlist/06-1.删除链表的节点.py
5,763
3.96875
4
""" 题目一:在O(1)时间内删除链表结点 给定单向链表的头指针和一个节点指针,定义一个函数在O(1)时间内删除该节点。 """ class ListNode: def __init__(self, x): self.val = x self.next = None def __del__(self): self.val = None self.next = None class Solution1: def DeleteNode(self, head, node): """ 删除链表中指定...
47dbfb007926c1117b127fca7fe3ab4802e331f2
mainchararacter420/Algorithms
/QuickSortingAlgo.py
445
3.5625
4
def solve(sequence): length = len(sequence) if length <= 1: return sequence else: pivot = sequence.pop() items_greater = [] items_lower = [] for item in sequence: if item > pivot: items_greater.append(item) else: items_low...
3500394cc1da77913ec3752c8bb2d29b11b1f29b
justien/CourseraPython
/ch6_Test0.py
1,106
4.15625
4
# -*- coding: utf8 -*- # justine lera 2016 # Python Specialisation - Coursera # 234567890123456789012345678901234567890123456789012345678901234567890123456789 print "==================================================" print "Chapter 6: Strings Assignment" print print # Comment comment print """ 6.5 Write code usin...
3a395824c4d84cecc66f85e65c041a29496281d7
justien/CourseraPython
/ch9_Dictionaries.py
2,313
4.09375
4
# -*- coding: utf8 -*- # justine lera 2016 # Python Specialisation - Coursera # 234567890123456789012345678901234567890123456789012345678901234567890123456789 print "==================================================" print "Chapter 9: Dictionaries" print print # Comment comment purse = dict() purse['money'] = 12 #...
07b76072b8d00f6f251c3f286ece31f522abe5d7
rgj7/coding_challenges
/codeabb/Python/p28_body_mass_index.py
497
3.75
4
""" CodeAbbey, Problem 28 Coded by Raul Gonzalez """ def body_constitution(weight, height): bmi = weight / (height**2) if bmi < 25: return "under" if bmi < 18.5 else "normal" else: return "over" if bmi < 30 else "obese" def main(): n = int(input()) results = [] for _ in range...
39e96f3744fca9117716eb96fb03ebeb7883e7fc
rgj7/coding_challenges
/codeabb/Python/p87_tree_builder.py
1,214
3.640625
4
""" CodeAbbey, Problem 87 Coded by whoisrgj """ class Node: def __init__(self, value): self.value = value self.left = None self.right = None class Tree: def __init__(self): self.root = None def add(self, value): if self.root is None: self.root = Node(...
a724a1b7e5aa76fa090edf144621de4dcb535016
rgj7/coding_challenges
/dailyprogrammer/Python/c154h_wumpus_cave_game.py
6,229
3.734375
4
# reddit.com/r/dailyprogrammer # challenge 154, hard: wumpus cave game from enum import Enum import os import random class RoomType(Enum): EMPTY = "You see nothing which is something." ENTRANCE = "You see the entrance here. You wish to run away?" PIT_TRAP = "You fell to your death. SPLAT!" GOLD = "Be...
8cf3f62affd37fafed174777ef6897744949627b
rgj7/coding_challenges
/codeabb/Python/p127_anagrams.py
523
3.8125
4
""" CodeAbbey, Problem 127 Coded by whoisrgj """ def anagram_count(word): count = -1 # accounts for original word word_sorted = "".join(sorted(word)) with open('words.txt', 'r') as f: for line in f: test_word = line.rstrip() if len(word) == len(test_word) and word_sorted =...
aa9a8ca0abe0d69603f9b26480f683fd9e6484d8
rgj7/coding_challenges
/codeabb/Python/p171_tree_height_measurement.py
418
3.515625
4
""" CodeAbbey, Problem 171 Coded by whoisrgj """ import math def tree_height_measurement(distance, degrees): return round(distance * math.tan(math.radians(degrees - 90))) def main(): n = int(input()) results = [] for _ in range(n): dist, deg = map(float, input().split()) results.appe...
e83348e7228c2b5c9c7bd33af84212d41544a414
rgj7/coding_challenges
/codeabb/Python/p155_depth_first_search.py
692
3.59375
4
""" CodeAbbey, Problem 155 Coded by whoisrgj """ from collections import defaultdict def depth_first_search(graph): stack = [(0, -1)] seen = {} while stack: current, from_ = stack.pop() if current not in seen: seen[current] = from_ for neighbor in sorted(graph[curre...
d23f15d2d18ba42043b9424f4c926a3b0cca66ba
mmnasir/coursera_python
/andrew/assn3.3.py
472
3.796875
4
try: inp1 = raw_input("Enter Score between 0.0 and 1.0:") score = float(inp1) except: print "Error, enter numeric value between 0.0 and 1.0" quit() if score > 1.0: print "Error, enter numeric value between 0.0 and 1.0" elif score < 0.0: print "Error, enter numeric value between 0.0 and 1.0" el...
c7f97c0a90209160fdfe622ad34ce0365e4bc212
mmnasir/coursera_python
/greg/eightpointfive.py
498
3.90625
4
# open mbox-short.txt # when line starts with #stephen.marquard@uct.ac.za Sat Jan 5 09:14:16 2008 #parse the from using split() and print the email address #then print out a count at the end fname = raw_input("Enter file name: ") fh = open(fname) count = 0 lst = [] for line in fh: line = line.rstrip() if line.star...
33112db5c662df1d891228c9d58efc7b65a7a595
mmnasir/coursera_python
/lance/ex7.2.py
1,166
3.703125
4
# Use the file name mbox-short.txt as the file name fname = raw_input("Enter file name: ") fh = open(fname) numlist = list() for line in fh: line = line.strip() if not line.startswith("X-DSPAM-Confidence:") : continue # print line # displays whole line # print line # displays X-DSPAM-Confidence: 0... ...
ea6ea929f1d04d96264d30638f163ff8b0db6ae2
mmnasir/coursera_python
/lance/ex10.2.py
1,043
3.953125
4
#Figure out the distribution by hour of the day for each of the messages. #You can pull the hour out from the 'From ' line by finding the time and #then splitting the string a second time using a colon. #From stephen.marquard@uct.ac.za Sat Jan 5 09:14:16 2008 #Once you have accumulated the counts for each hour, pr...
6443b60c3cc0caba6f261b8fb2738d55953b4b7f
Aleksei-Zaichenko/cs-sprint-challenge-hash-tables
/hashtables/ex4/ex4.py
480
3.78125
4
def has_negatives(a): """ YOUR CODE HERE """ # Your code here result = [] posNumber = {} negNUmber = {} for number in a: if number > 0: posNumber[number] = number else: negNUmber[number] = number for number in posNumber.keys(): if neg...
17d2807e91c18c55082fb1f1b59091773ce09542
GamuceroJP/Animaciones-con-Tkinter
/ButtonBall.py
2,109
3.640625
4
from tkinter import Tk, Button, Canvas, Frame, ALL, W #.....................................................Global variables RunAll=True RunMotion=False #.....................................................Start/Stop motion def StartStop(): global RunMotion RunMotion= not RunMotion if RunMotion: ...
b3c2e4fcd0e1c6c6f498d29c58baf365f70bf4dc
DINESH-KUMAR-7/talentpy-Assign3
/1r89.py
972
4.03125
4
""" Mr.Talentpy would like to create a func,on one_or_eight which takes an integer input (no) and performs following opera,on. 1. Square the number if it is single digit. (Eg: 3, then 3 * 3 = 9) 2. If it is not single digit, square each digits and add. (Eg: 12, then (1*1) + (2*2) = 1+4 = 5 You have ...
21bb7cc70d1e241938b97c291051c43c91dd61c9
yangxin42/LeetCode-Python
/2.py
1,029
3.703125
4
# Definition for singly-linked list. # class ListNode(object): # def __init__(self, x): # self.val = x # self.next = None class Solution(object): def addTwoNumbers(self, l1, l2): """ :type l1: ListNode :type l2: ListNode :rtype: ListNode """ sum =...
104c779dbb023a359fefdac263d67fcbd510be22
alexZeLoCO/Subrutinas1
/Ejercicio1.py
883
3.96875
4
def leeEntero(): #Subrutina leeEntero(): """ :return: entero - Introducido por el usuario """ entero=int(input("Introduzca un entero: ")) #Solicita entero return entero #Devuelve entero def devuelveMayor(a,b): #Subrutina devuelveMayor(a,b): """ :param: a - número...
008fa62c3a5496dfbeeac1b2eba75ab36129fb2c
OberoiSahaj/Interesting-Problems
/cyclic_encryption.py
1,339
3.90625
4
''' QUESTION: For a given phrase, we need to encrypt with the help of cyclic shift in their reversed indices: INPUT: yum OUTPUT: avm In obove example, yum is given as input. When reverse indexed, index of y = 2, u = 1, m = 0. Now we need to replace existing alphabets such that theird reverse index is added to e...
ce3c4a0371a029dbd273360dbc52835b11c2cb33
shaoda06/python_work
/Part_I_Basics/exercises/exercise_9_4_number_served.py
1,650
4.4375
4
# 9-4. Number Served: Start with your program from Exercise 9-1 (page 166). # Add an attribute called number_served with a default value of 0. Create an # instance called restaurant from this class. Print the number of customers the # restaurant has served, and then change this value and print it again. # Add a method ...
888a1e66add51623a4a7ca61c432ffaf2e7306ac
shaoda06/python_work
/Part_I_Basics/examples/example_2_3_Strings.py
1,245
4.625
5
# 2.3.1 Changing Case in a String with Methods name = "ada lovelace" print(name.title()) print(name.upper()) print(name.lower()) # 2.3.2 Combining or Concatenating Strings first_name = "ada" last_name = "lovelace" full_name = first_name + " " + last_name print(full_name) print("Hello, " + full_name.title() + "!") mes...
05e07093f6d271ffc57bebbf4fd0c857e58be4a1
shaoda06/python_work
/Part_I_Basics/exercises/exercise_5_10_checking_usernames.py
1,310
4.28125
4
# 5-10. Checking Usernames: Do the following to create a program that simulates # how websites ensure that everyone has a unique username. # • Make a list of five or more usernames called current_users. # • Make another list of five usernames called new_users. Make sure one or # two of the new usernames are also in the...
7602118ef68bcdea80a5facb0d8d6fbf2d897779
shaoda06/python_work
/Part_I_Basics/examples/example_10_1_3_file_reader.py
330
3.734375
4
# 10.1.3 Reading Line By Line file_name = "example_10_1_1_pi_digits.txt" with open(file_name) as file_object: # for line in file_object: # print(line) for line in file_object: # using rstrip() on each line in the print statement eliminates these # extra blank lines: print(line....
1525ef3a80fe96f54fd4fb09b7491abaf15f3118
shaoda06/python_work
/Part_I_Basics/exercises/exercise_5_7_favorite_fruit.py
597
4.40625
4
# 5-7. Favorite Fruit: Make a list of your favorite fruits, and then write a series of # independent if statements that check for certain fruits in your list. # • Make a list of your three favorite fruits and call it favorite_fruits. # • Write five if statements. Each should check whether a certain kind of fruit # is ...
c90cafde1b6aaa92f509d27efb3e77f47151ad0d
shaoda06/python_work
/Part_I_Basics/exercises/exercise_6_4_glossary_2.py
668
4.5
4
# 6-4. Glossary 2: Now that you know how to loop through a dictionary, clean # up the code from Exercise 6-3 (page 102) by replacing your series of print # statements with a loop that runs through the dictionary’s keys and values. # When you’re sure that your loop works, add five more Python terms to your # glossary. W...
9334659921bff17abfd27f4ee846e4266df22a80
shaoda06/python_work
/Part_I_Basics/examples/example_7_1_1_greeter.py
691
4.375
4
# Writing Clear Prompts # Each time you use the input() function, you should include a clear, # easy-to follow prompt that tells the user exactly what kind of information # you’re looking for. Any statement that tells the user what to enter should # work. For example: prompt = "If you tell us who you are, we can perso...
3896dfec904e99bf3baa8f8bbb62a60a5a5f9fc8
shaoda06/python_work
/Part_I_Basics/exercises/exercise_3_5_changing_guest_list.py
930
4.15625
4
# 3-5. Changing Guest List: You just heard that one of your guests can’t make the # dinner, so you need to send out a new set of invitations. You’ll have to think of # someone else to invite. # • Start with your program from Exercise 3-4. Add a print statement at the # end of your program stating the name of the guest ...
826d693bb54c1320ddea28370ceb07e0696dc487
shaoda06/python_work
/Part_I_Basics/exercises/exercise_6_2_favorite_numbers.py
676
4.25
4
# 6-2. Favorite Numbers: Use a dictionary to store people’s favorite numbers. # Think of five names, and use them as keys in your dictionary. Think of a # favorite number for each person, and store each as a value in your # dictionary. Print each person’s name and their favorite number. For even # more fun, poll a few ...
fe792070d524789aa7b9759fbe1be9a394c1e379
shaoda06/python_work
/Part_I_Basics/exercises/exercise_10_7_addition_Calculator.py
847
4.125
4
# 10-7. Addition Calculator: Wrap your code from Exercise 10-6 in a while loop # so the user can continue entering numbers even if they make a mistake and # enter text instead of a number. prompts = "Please enter two numbers, and I will add them together.\n" \ "Enter 'quit' to stop." while True: first_nu...
fb894772decf3dd8681a1bb67a4a97514f9a70f4
shaoda06/python_work
/part_II_projects/exercises/exercise_13_3_raindrops.py
1,947
4.21875
4
# 13-3. Raindrops: Find an image of a raindrop and create a grid of raindrops. # Make the raindrops fall toward the bottom of the screen until they disappear. import sys import pygame from pygame.sprite import Sprite class Screen: def __init__(self): self.screen_width = 1200 self.screen_height = ...
399056e76c322c0401c5e7e41fe7817fd7f20ac3
shaoda06/python_work
/Part_I_Basics/examples/example_10_3_7_word_count.py
1,369
4.375
4
# 10.3.7 Working with Multiple Files def count_words(file_name): """Count the approximate number of words in a file.""" try: with open(file_name) as file_object: contents = file_object.read() except FileNotFoundError: msg = "Sorry, the file " + file_name + " dose not exist." ...
bc5e2f1dd3c6dbc6a3e9ac1e2b4c98837f478225
shaoda06/python_work
/Part_I_Basics/exercises/exercise_9_5_login_attempts.py
1,882
4.09375
4
# 9-5. Login Attempts: Add an attribute called login_attempts to your User # class from Exercise 9-3 (page 166). Write a method called increment_ # login_attempts() that increments the value of login_attempts by 1. Write # another method called reset_login_attempts() that resets the value of # login_ attempts to 0. Mak...
b55ecdea34e869b1fce4453d43e1a49b7d3006d9
shaoda06/python_work
/part_II_projects/exercises/exercise_12_1_blue_sky.py
680
3.828125
4
# 12-1. Blue Sky: Make a Pygame window with a blue background. import sys import pygame class Screen: """Make a Pygame window with a blue background""" def __init__(self): pygame.init() self.bg_color = (0, 0, 255) self.screen = pygame.display.set_mode((1200, 800)) pygame.displ...
c6a008188c768f9d5266406123eb5f1c3497b389
shaoda06/python_work
/Part_I_Basics/exercises/exercise_3_6_more_guests.py
1,250
4.59375
5
# 3-6. More Guests: You just found a bigger dinner table, so now more space is # available. Think of three more guests to invite to dinner. # • Start with your program from Exercise 3-4 or Exercise 3-5. Add a print # statement to the end of your program informing people that you found a # bigger dinner table. # • Use i...
13241be97d33f44f265445186c56be2048e9a1e9
shaoda06/python_work
/Part_I_Basics/examples/example_9_2_1_car.py
2,058
4.6875
5
# 9.2.1 The Car Class # Let’s write a new class representing a car. Our class will store information # about the kind of car we’re working with, and it will have a method that # summarizes this information: # 9.2.2 Setting default value for an attribute # Line #24 is to initialize attribute with a default value 0 # Li...
691552139e74d957439f164a1315dddced1b9414
TheVibration/pythonprocedures
/findelement.py
606
4.15625
4
# find_element takes two inputs # lst and v. lst is a list of # any type and v is a value of any # type. find_element will go through # lst and find the index at which # v exists. If v isn't in lst, -1 # will be returned. def find_element(lst,v): counter = 0 for i in lst: pos = i.find(v) if p...
c3088ca94097514354999b6d1d1a61bcfb8da3f7
TheVibration/pythonprocedures
/memoization.py
463
3.6875
4
# cached_execution uses memoization which # which saves previously run results. cache is # a dictionary in which the previous results # are stored. proc is a procedure that will # return a result, and proc_input is the input # that will be used as a key in cache. def cached_execution(cache, proc, proc_input): if...
1895691b4c245c3f5eac4cc0b56d254d3a755a08
nelsonruth11/Demultiplex
/Assignment-the-first/part_1.py
830
3.640625
4
!/usr/bin/env python def convert_phred(letter): """Converts a single character into a phred score""" letter = ord(letter) - 33 return letter file = "/home/ndr/bgmp/bioinfo/Bi622/Demultiplex/Assignment-the-first/r1" #file = "../../test.fastq" ## Use this cell to populate your numpy array of arrays #my...
c3bdba69d1ab814aa57f40208d048442f0d0ab1d
leiva7/trabajosPracticosPractica
/practico10.py
4,482
3.765625
4
#!/usr/bin/python3 #-*- coding: utf-8 -*- import os import psutil def menu(): print ("Seleccione una opcion") print("1-Listar los PIDs actuales") print("2-Mostrar el nombre de un proceso, seleccionando el PID") print("3-Mostrar la ruta de dicho proceso") print("4-Mostrar los parametros de consola...