blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
e117310603ddc36c94e45d43883b828d17a78abf
nao2000com/python-study
/05-json-read.py
432
3.75
4
#!/usr/bin/python # coding: utf-8 import json #JSON ファイルの読み込み f = open('test.json', 'r') json_dict = json.load(f) #print('json_dict:{}'.format(type(json_dict))) #print json_dict["book1"] #book-page=json_dict["book1"]["page"] #print "page is" + book-page print '{book_title} is {book_page} page'.format(book_title=json_...
1551784dbf43bb890cf329392cc38b831c8667b7
JavierGutierrezC/holbertonschool-higher_level_programming
/0x01-python-if_else_loops_functions/8-uppercase.py
205
4.0625
4
#!/usr/bin/python3 def uppercase(str): for x in range(len(str)): y = ord(str[x]) if (y >= 97 and y <= 122): y = y - 32 print("{:c}".format(y), end="") print("")
49953ef190949af5446c114c52e94cd95343774a
robfatland/percival
/python/magnetism/lesson2.py
2,788
4.3125
4
######## # # Welcome to lesson2.py # # This program draws some pins on a chart, randomly # We use the results of lesson 1 and add in the necessary code to make this chart. # To find the lessone: Scroll down to where it says LESSON 2!!! # ######## # ######### # # Setup # # The plotting library import matplot...
f498770c476a410cfde935a37e26796ff9e016eb
pshoemaker39/Python-basics
/401/StudentDB.py
390
3.609375
4
class Student_DB: def __init__(self): self.studDB = list() def addStudent(self, student): self.studDB.append(student) print("Student added successfully.") def getStudents(self): return self.studDB def findStudent(self, name): for student in self.studDB: ...
1f6fe7be0c2e2bfe0e34cdbe9c70a1ce6945c5c2
hemuke/python
/17_process_thread/08_1_manual_thread.py
916
3.5625
4
#! /root/anaconda3/bin/python import time from threading import Thread from threading import current_thread print('父线程%s启动' % current_thread().getName()) class MyThread(Thread): def __init__(self, num, name, kwargs): super().__init__(name=name) self.kwargs = kwargs self.num = num de...
a346d054ed7a3fc85053c5b77e6b2b3f9550b2f4
wungjaelee/Go
/Deliverables/4/4.1/zz_3_test_driver.py
1,189
3.5625
4
import json.decoder import sys from board import Board from point import Point def main(): ''' test_driver.py Parses JSON from stdin, converting the JSON to a series of python objects representing statements. Each of those statements is then executed, and the results are passed to stdout. ''' ...
b4d8332bfddac03411ddbd37c33f7da944a49d4b
Fattouche/TextClassification
/src/compute_probability.py
1,037
3.96875
4
def compute_probability(model, total_wise, total_future, word): # divide the number of times the item appears in the wise plus 1, by the number of times wise appears plus total number of words in map. counter = model.get(word) if(counter is not None): wise_numerator = counter[0] + 1 future...
b4bca8f88ba0dc7b3b710d0b893a6061da88ecae
busyjeter/data_structure_python
/List/DLList.py
3,307
3.796875
4
# coding=utf-8 class LNode(): def __init__(self,elem,next_=None): self.elem=elem self._next=next_ class LList:#带有首尾结点引用的单链表 def __init__(self): self._head = None def is_empty(self): return self._head is None def prepend(self, elem): # 在表头添加 self._head ...
5a2687d3050a957ebce6f126ade2fd7ca27b217b
LucianaNascimento/CursoPythonGuanabara
/mundo2/52-NumerosPrimos.py
825
4.03125
4
''' Faça um programa que leia um número inteiro e diga se ele é ou não um número primo''' num = int(input('Digite um número e descubra se um número é primo: ')) isPrime = True current = (num // 2) for i in range(current, 0, -1): if num % i == 0 and i != 1: isPrime = False if isPrime: print(f'O númer...
cc60d20f05869f27814c2cf417c8d8060d12da98
AnnaNenarokova/rosalind
/lexv.py
795
3.515625
4
#!/usr/bin/python def lexv_rec(alphabet, n, strings): n = n - 1 result = [] for s in strings: if s[-1] == ' ': result.append(s) else: for l in alphabet: result.append(s + l) if n > 0: result = lexv_rec(alphabet, n, result) return resul...
21c0200033f4e835972f214cf24dce76fcab929a
TomaszNowakDev/modular_programming_module
/Lab02/task5.py
274
4.1875
4
# Indicating longer string def longer_string(a, b): longer = "" if len(a) > len(b): longer = a elif len(a) < len(b): longer = b return longer length = longer_string(input("Enter first word > "), input("Enter second word > ")) print(length)
39a615f92c25ad99c78b1ed349a7e43660cab9c2
peaceful321/python
/basic/oop/use_custom_made.py
616
3.671875
4
#!/usr/bin/env python # -*- coding: utf-8 -*- # @Time : 2018/1/15 上午11:33 # @Author : Ryan Xu # @File : use_custom_made.py # @Software: PyCharm class Spical(object): """ 定制化 类 """ def __init__(self): self.__name = "定制化类"; def __str__(self): return "Spical object (name : ...
4f6605dac63b28a1eb155e6bc990287abb8f630c
Brandonops/python-rpg-game
/hero.py
1,100
3.53125
4
from character import Character from goblin import Goblin class Hero(Character): name = "Hero" def __init__(self, health = 100, power = 2): super().__init__(health, power) self.winphrase = "The goblin is dead." def attackz(self, enemy): # attacking method enemy.health -= s...
17ea6093640e85a3bff025041f38dee8456927a9
matheusvictor/estudos_python
/outras_listas_de_exercicios/lista_01/q10.py
1,077
4.0625
4
# -*- coding: utf-8 -*- while(True): print("Informe o tipo de valor que deseja inserir em A:") print("1 - Número (inteiros ou reais)") print("2 - Caracter(es)") opc = int(input()) if(opc == 1): a = input("\nInforme o valor de A: ") break elif(opc == 2): a = raw_input("\...
ae96d6e78c8fbc004faa30bbcd39da4b96ae6c71
sFrom-Git/goCard
/GoCardAccount.py
2,002
4.1875
4
class GoCardAccount: """ Go-Card Account module for Python ================================= The class GoCardAccount must be passed an integer or float value when it is instantiated. This will be the initial balance on the account. """ def __init__(self, initialBalance): self._statementLog = [] self._curr...
a5e40e551137683e11ab7c9ef5a6308926219d27
uuboyscy/eb102-python
/13_exception1.py
573
3.796875
4
def createFile(name): try: with open(name, 'w', encoding='utf-8') as f: f.write('123') except FileNotFoundError as e: print(e) print(e.args) print(e.errno) name = name.replace('/', '') with open(name, 'w', encoding='utf-8') as f: f.write('1...
b355bb83b8d15c560305231eecf7af70100c4ce1
kwsp/life
/game.py
3,054
3.875
4
""" Conway's Game of Life Rules: 1. Any live cell with fewer than two live neighbours dies (underpopulation). 2. Any live cell with two or three live neighbours lives on to the next generation. 3. Any live cell with more than three live neighbours dies (overpopulation). 4. Any dead cell with exactly th...
9ff4e77c68c21ad7ad7aa4347077525be03b7ee5
SirishaRella/Cracking-the-Coding-Interview
/Chapter-1/URLify.py
1,403
4.0625
4
#Question: Write a method to replace all spaces in string with %20 #Sample Input: "Mr John Smith ", 13 #Sample Output "Mr%20John%20Smith" #Goal is to perform the operation in place. #hint53: Often easiest to modify strings from the end of the string to the beginnnig. #Hint 118: You might find you need to know the numbe...
314c24fcfdbefbbccb1bb9cf99a2b7d959fa8479
Trago18/python-lists-loops-programming-exercises
/exercises/15.2-Parking_lot_check/app.py
468
3.5625
4
parking_state = [ [1,1,1], [0,0,0], [1,1,2] ] def get_parking_lot(x): state = {'total_slots': 0, 'available_slots': 0, 'occupied_slots': 0} for d1 in x: for d2 in d1: if (d2 == 1): state['total_slots'] += 1 state['occupied_slots'] += 1 elif ...
1c33c9ab6b4b76b01416fabd8dd39c9c08396497
25shmeckles/scripts
/GuideToOligo.py
3,530
3.796875
4
#This script takes a "Guide sequence" generated by CRISPR Design Tool (http://tools.genome-engineering.org) #and generates the oligos needed for their cloning into a pX-series vector. #Input variable: sequence_list - Is a list o tuples of strings. #Each tuple contains the name of the sequence and the sequence. #For mor...
36b6e812f29d8cf764855ebfb49c552c5250f009
Projektbludiste/test
/analyse_numbers.py
129
3.640625
4
def is_whole_number(number): if number % 2 == 0: print("true") else: print("false") is_whole_number(2)
dae754df369de45326e2c08a0a71daffcbec1835
prog4biol/evop2019
/scripts/factorial.py
286
4.0625
4
#!/usr/bin/env python3 count=5 result=1 while count > 0: result*=count # result = result * count count-=1 # count = count -1 print(result) ###### do it again #### print("lets do it again\n") count = 1 result = 1 while count <= 5: result*=count count+=1 print(result)
f5db92244d560b680c190a18cfa3ed3e3f38ad75
anyadao/hw_python_introduction
/hw14.py
381
4.09375
4
# 14. Написать функцию, которая будет проверять четность некоторого числа. # def is_even(number): # returns boolean value # pass def is_even(number): if number % 2 == 0: result = True else: result = False return result print('Ваше число четное?', is_even(68))
03f1840dd5bd3b671ca86a415322241e14a43305
Diegotmi/Des_python
/loja_peças2.py
397
3.828125
4
# Faça um algoritmo para “Calcular o estoque médio de uma peça”, # sendo que ESTOQUEMÉDIO = (QUANTIDADE MÍNIMA + QUANTIDADE MÁXIMA) /2 codigo_peca = input('Insira codigo da peça:') qtd_min = int(input('Insira quantidade minima de peças:')) qdt_max = int(input('Insira quantidade maxima de peças:')) estoque_medio = (qt...
ec1bdabad7339e8d490a793a7bc9ad6555a6d06d
dreamlikexin/machine_learning
/Codes/linear_regression/greedy_bad_example.py
563
3.703125
4
import numpy as np from machine_learning.linear_regression.lib.stepwise_regression import StepwiseRegression from machine_learning.linear_regression.lib.stagewise_regression import StagewiseRegression X= np.array( [[ 0.06, 0.34, 0.03] ,[ 0.44, 0.76, 0.28] ,[ 0.86, 0.44, 0.20] ,[ 0.26, 0.09, 0.25]]) y = np....
2b49d1b5303280d00dd73d5f79efed698af41313
Denisfench/openclean-core
/tests/pipeline/test_stream_write.py
902
3.5
4
# This file is part of the Data Cleaning Library (openclean). # # Copyright (C) 2018-2021 New York University. # # openclean is released under the Revised BSD License. See file LICENSE for # full license details. """Unit tests for writing the rows in the data processing pipeline to file.""" import os import pandas as...
d245c0df8040152eebcd71333aa871ee8c615cb1
kbotero201/python-practice
/strings_code_challenges.py
2,582
4.375
4
# Python String Code Challenges # Check Name # Write a function called check_for_name that takes two strings as parameters named sentence and name. The function should return True if name appears in sentence in all lowercase letters, all uppercase letters, or with any mix of uppercase and lowercase letters. # The f...
cb1ab2ffb83bc3adeb294dad07aa61f0c505e90b
lincey-cherian-au7/CC-1
/CC2.py
378
4.03125
4
username = input("Enter your username : ") password = input("Enter your password : ") if username =="Priyesh" and password == "password": print("Entered the System") elif username =="Priyesh": print("Password donot match") elif password == "password": print("Username donot Exist") elif username !="Priyesh" and pa...
efa6ace7494cfd2a6098d9cdeeb075d9037e856f
LucianoUACH/IP2021-2
/PYTHON/vectores/suma_vectores.py
207
3.71875
4
suma = 0 numeros = [None] * 8 for i in range(8): print("Ingrese el " + str(i+1) + "° valor: ") numeros[i] = int(input()) suma = suma + numeros[i] print("El total de la suma es: " + str(suma))
4eb80c38d0da9c6e7818e200b960a897d9e70c49
19AlexOrtegaRosas97/Factorial-py
/factorial.py
647
4.09375
4
#@author: Alejandro Ortega Rosas import sys def factorial(num): if (num==1): print("1 Multiplicaciones") else: print(num, end=" * ") if(num!=1): num=num*factorial(num-1) print("Valor final es igual a ->",num) return num if(len(sys.argv)==2): try: valor = int(sys.argv[1]) i...
781824fb39992029009f0e4cf080c2d8e5f60e1c
Bahh-ctrl/DIgital_Solutions_2020_
/Chapter3/8. Cookout Calculator.py
295
3.765625
4
peo = int(input("People attending: ")) per = int(input("Hot dogs per-person: ")) t = peo * per HDP = t // 10 HDR = t % 10 BP = t // 8 BR = t % 8 print ("Required Hotdogs packs:", HDP) print("Bun Packets required", BP) print ("Hot dogs left over", HDR) print ("Buns leftover", BR)
f1dba5b103a1987cabb09977a0b83e87622e7b73
athletejuan/TIL
/Algorithm/D1/2047.py
188
3.890625
4
T = int(input()) for test_case in range(1, T+1): text = input() title = '' for i in text: if i.islower(): i = i.upper() title += i print(title)
11ee96d341ce1fadff09406e5379f8828e738aa4
TonyTcode/wed-6-26
/prime_numbers.py
191
3.96875
4
number = int(input("Type number ")) if number > 1: for index in range(2,number): if (number % index) == 0: print("Not prime number") break else: print("Prime number")
205d95b73e5b82bde9b3514c298f324709784f25
abccaba2000/sosoGame
/Python Learning Project/Chapter 1 Done/Answers_Lab_Vincent_Custom-Calculators_1-1.py
156
4.0625
4
Fahrenheit = input("Enter temperature in Fahrenheit : ") Fahrenheit = float(Fahrenheit) print("The temperature in Celsius : ", (Fahrenheit - 32) * (5 / 9))
6b121d4efca5f408f4a22544e52e0ecc1f05608b
OCHA-DAP/hdx-python-utilities
/src/hdx/utilities/base_downloader.py
3,953
3.53125
4
from abc import ABC, abstractmethod from typing import Any, Iterator, List, Tuple, Union from .typehint import ListDict, ListTuple class DownloadError(Exception): pass class BaseDownload(ABC): """Base download class with various download operations that subclasses should implement.""" def __enter_...
c1b2acca58cfc5dca84495f018f1471e810c4a56
rsuresh-coder/solved-code
/reversenumber.py
666
3.921875
4
def reverse_number(x: int) -> int: upper_limit = 2147483647 lower_limit = -2147483648 reverse = 0 while x: digit = x % 10 #This may not work for negative numbers x = x // 10 # This also may not work for negative numbers # print(digit, x) if (reverse > upper_limit // 10...
0bb7d6188a4234cdd76605dc7a6d1a28775e6e39
ausaki/data_structures_and_algorithms
/leetcode/rle-iterator/405223462.py
704
3.546875
4
# title: rle-iterator # detail: https://leetcode.com/submissions/detail/405223462/ # datetime: Tue Oct 6 18:31:14 2020 # runtime: 36 ms # memory: 14.7 MB class RLEIterator: def __init__(self, A: List[int]): self.A = A self.i = 0 def next(self, n: int) -> int: for j in range(self.i, l...
6b2130b06d32ca03ccd558b7e52559edd6045982
AAllanWang/open
/163/python/week6_t1.py
272
3.6875
4
def func(lst): for i in range(len(lst)-1): for j in range(i+1,len(lst)): if lst[i] < lst[j]: lst.insert(i,lst.pop(j)) else: pass else: return lst return -1 lst1 = [6,2,4,1,5,9] lst2 = func(lst1) print lst2[3:-2] lst2[3:-2] = [] print lst2 print lst1
2f772efa7da204f5fc71f644cdc4a9724f078d87
deniadobras/RepoDeniaDecember
/Part5_exercises1&2.py
1,144
3.921875
4
#Exercise1 - print random words words = ["cat", "dog", "dinosaur", "random", "words"] for x in words: print(x) #Exercise2 - sum of all float an dint in a list (version1) - there are 3 versions here but I am not happy with either of them, so I will have to re-think this one to find an actual solution alist = ['a...
99999a9b35b96c3a443215ab6b3fcf2e8cdc517c
daveswork/pythonforeverybody
/chapter-12/excercise-02.py
1,057
3.96875
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Exercise 2: Change your socket program so that it counts the number of characters it has received and stops displaying any text after it has shown 3000 characters. The program should retrieve the entire document and count the total number of characters and display t...
92abda906f8f063db41f52095a9455d3c999285c
eldydeines/blogging-app
/models.py
1,861
3.515625
4
from flask_sqlalchemy import SQLAlchemy """Initialize variable for database""" db = SQLAlchemy() def connect_db(app): """need to associate our app with db and connect""" db.app = app db.init_app(app) """Models for Blogly.""" class User(db.Model): """USER MODEL""" __tablename__ = "users" ...
5d416c5428192a6c047e4f6dde048d1659076d4b
Gbolly007/AdvancedPython
/Assignment2/As2_Number2.py
890
3.90625
4
# Python version 3.7.6 import types import dis # Method to generate bytecodes for python scripts def bytecodepy(): # Input to receive python script from user source_py = input('Enter file! ') # Condition to determine if the particular file # in the loop is valid a python file by checking the last 3 character...
83b47797069cccfa515cc4ca510bca3747b1561c
sohelbaba/Python
/Practical 3/p1.py
1,808
4.3125
4
#Develop a menu-based python program #menu items: 1. Addition 2. Subtraction 3. Multiplication 4. Division 5. Average 6. Find maximum 7. Find minimum import sys def PrintMenu(): print("Menu") print("1. Addition") print("2. Subtraction") print("3. Multiplication") print("4. Division") pr...
12aebf36d9adfb5aede3fd0d276173cd807f6c36
bhanupratapsinghcs/python
/my python programe/patter1.py
321
3.53125
4
n = int(input()) k = int(input()) print(" "*(n-1)+"*") for i in range(n-1): if (i == (k-2)): print(" "*(n-i-2)+"**"+"*"*(2*i),end="*\n") else: print(" "*(n-i-2)+"* "+" "*(2*i),end="*\n") continue arr = arry() # * # * * # * * # ********* # * * # * * # * ...
75d6a039f357eb219e8cf3cea309d613ba644a89
ClaudioCarvalhoo/you-can-accomplish-anything-with-just-enough-determination-and-a-little-bit-of-luck
/problems/LC56.py
541
3.515625
4
# O(n * log(n)) # n = len(intervals) from typing import List class Solution: def merge(self, intervals: List[List[int]]) -> List[List[int]]: intervals.sort(key = lambda interval: (interval[0], interval[1])) res = [intervals[0]] for i in range(1, len(intervals)): current = res[-...
c72a5068a0e386dc9b8278e1a91a5af5ea7ac38d
JennyCortez-lpsr/class-samples
/randomGame.py
445
4.0625
4
import random print("I'm thinking of a number between 1 and 1000. Enter your guess!") myNum = random.randint(1, 1000) guess = int(input()) myNums = int(myNum) while guess > myNums: print("Nope your guess is too high. Guess again.") guess = int(input()) while guess < myNums: print("Nope yo...
00ed6c578cd448f1cf4008ff5bd017a793158b8e
alantam626/introexercises
/dictionaries2.py
2,482
3.75
4
alien_0 = {'color': 'green'} print('The alien is ' + alien_0['color'] + '.') alien_0['color'] = 'yellow' print('The alien is now ' + alien_0['color'] + '.') print('///') alien_1 = {'x_position': 0, 'y_position': 25, 'speed': 'medium'} print('Original x_position: ' + str(alien_1['x_position'])) alien_1['s...
c7a6b9204f5cef97892b48735bbc9f25e54864d6
AMao7/Project_Monster_inc
/Buildings.py
548
3.640625
4
class Buildings(): def __init__(self, location, capacity, people_in_building = 0): self.location = location self.capacity = capacity self.people_in_building = people_in_building def toggle_lights(self): if self.people_in_building > 1: return 'lights on' els...
6e40ecdccdc2521f1bd8d032fd256ee663bc7ad4
falsigo/apprentissage
/Python Crash Course/Quiz.py
801
3.5625
4
from Questions import Question question_prompts = [ "How many sequences are present in AC - Unity?\n(a) 11\n(b) 3\n(c) 8\n(d) 17\n\n", "What was the name of Barny Stinson's best friend in 'How I Met Your Mother'?\n(a) Matthew Perry\n(b) Marshall " "White\n(c) Ted Mosby\n(d) Rachel McDawes \n\n", "What ...
06d61d00e9312df56135a09b35c54141541c8cbd
war-and-peace/SearchEngine
/src/engine/prefix_tree.py
3,220
3.765625
4
from functions import * # Prefix tree class Node(object): def __init__(self): self.children = [None] * 27 self.isEnd = False class PrefixTree(object): def __init__(self): self.root = Node() def insert(self, word): current = self.root for i in range(len(word)): ...
e52a9e2a92236b92677dfbde9d5518997ed4f407
vesteves33/cursoPython
/Exercicios/ex042.py
668
4.09375
4
#refatorando exercicio 35(retas que formam triangulos) r1 = float(input('digite o valor da reta 1: ')) r2 = float(input('digite o valor da reta 2: ')) r3 = float(input('digite o valor da reta 3: ')) if r1 < r2 + r3 and r2 < r1 + r3 and r3 < r2 + r1: if r1 != r2 and r1 != r3 and r2 != r3: print('As retas po...
0310709ecfe2ca19641dda8521026835af65700a
Rositsazz/HackBulgaria-Programming0
/week2/Simple Algorithms/is_perfect.py
333
3.59375
4
n = input("Please, enter a number: ") n = int(n) m = n/2 i = 1 array = [] suma = 0 while i<=m : if n%i==0 : array = array + [i] i+=1 print(array) j = 0 while j < len(array): suma=suma + array[j] j+=1 print(suma) if n==suma: print("The number is perfect") else: print("The number is n...
6e9c902043d02bc7b23f4145a69ab10402dc4ff9
rafaelperazzo/programacao-web
/moodledata/vpl_data/165/usersdata/268/65823/submittedfiles/lecker.py
181
3.5625
4
# -*- coding: utf-8 -*- import math a=float(input(' Digite o valor a')) b=float(input(' Digite o valor b')) c=float(input(' Digite o valor c')) d=float(input(' Digite o valor d'))
56e92c9b119708aed2fe420dcd9dae64a4455772
LeafBrightDay/data-structure-algorithms-learning
/daily coding problem/decoding msg.py
601
3.9375
4
#This problem was asked by Facebook. # Given the mapping a = 1, b = 2, ... z = 26, and an encoded message, count the number of ways it can be decoded. # For example, the message '111' would give 3, since it could be decoded as 'aaa', 'ka', and 'ak'. # You can assume that the messages are decodable. For example, '001...
ae27be5211b12fc377731200ba928cd5f400cf4a
TheMacte/python_base
/hw_01/ex4.py
522
3.9375
4
# 4. Пользователь вводит целое положительное число. # Найдите самую большую цифру в числе. # Для решения используйте цикл while и арифметические операции. user_num = int(input('Введите целое положительное число ')) user_max = 0 while user_num > 0: if user_num % 10 > user_max: user_max = user_num % 10 ...
ae8a7686f802ea392aa574871dd60f64c35d7224
GXTrus/Rock-Paper-Scissors
/Rock-Paper-Scissors/task/rps/game.py
2,189
3.78125
4
from collections import deque import random class RockPaperScissors: def __init__(self): self.item_list = deque(('paper', 'scissors', 'rock')) self.rating_file = 'rating.txt' self.players_scores = {} self.game() def game(self): check = True self.user_name = in...
d5ea5c6b4e8dc96dbfccd8112bd776d6e1b338c2
jahnavi-gutti/Basic-programs-in-python
/abundantno.py
169
3.71875
4
n=int(input()) c=0 for i in range(1,n): if n%i==0: c+=i if c>n: print("is abundant") else: print("not abundant") """ 18 is abundant """
11f83f8a51d5162fd50576a2f18b49d8a7ddd488
Capoqq/InteligenciaComputacional
/python excersism/acronimo.py
164
3.703125
4
import re def abbreviate(palabras): return "".join(palabra[0].upper() for palabra in re.findall(r"([a-zA-Z0-9]+(?:'\w+)?)", palabras))
e51ebdbdc45e41bc99dbd58f97c020b54bb3f873
bopopescu/Python-13
/Cursos Python/Python 3 Avançado - Marcos/17 - indexação negativa.py
47
3.609375
4
x = [item for item in range(3)] print(x[-1])
0d13a97990b5db33d68f4d085c9a2b4c4bf4f97c
mkhira2/automate-the-boring-stuff
/regular-expressions/repetition.py
2,904
3.625
4
import re #-------------------------- # Must match optional filter 0 or 1 time ()? batRegex = re.compile(r'Bat(wo)?man') mo = batRegex.search('The Adventures of Batman') print(mo.group()) # prints Batman mo = batRegex.search('The Adventures of Batwoman') print(mo.group()) # prints Batwoman mo = batRegex.search('Th...
0a1cfef702639cfb6c40dd37041f797aacb02f3b
shiannn/LeetCodePython
/linklist/109. Convert Sorted List to Binary Search Tree.py
1,702
3.875
4
# Definition for singly-linked list. class ListNode: def __init__(self, val=0, next=None): self.val = val self.next = next # 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 = r...
aad024b524fc7fb83fd27938004ec17ca7c18c5b
lse-my470/lectures
/wk7/tests.py
2,131
4.1875
4
# Example taken from Gries et al. 2013. Practical Programming: An Introduction # to Computer Science Using Python 3 import unittest import tools class TestRunningSum(unittest.TestCase): '''Tests for running_sum.''' def test_running_sum_empty(self): '''Test an empty list.''' inputted = [] ...
2bc5cd91bcdda15bbc033e158e8be1004086d7b0
DmShums/pyParser
/parser_01_04_20/file_manager.py
1,561
3.53125
4
import os from itertools import islice def check_and_create_file(): if not os.path.exists('translate.txt'): translate_file = open('translate.txt', 'w').close() def write_to_file(word, translated_word='EMPTY'): with open('translate.txt', 'a') as translated_file: translated_file.write(f'{word} ...
97a0d56ec4031a1b8668dc7516f9d0ded1ca20e5
karalgikarrahul/hello-world
/Largest prime factor.py
475
3.953125
4
from math import sqrt def is_prime(x): n = 2 if x == n: return True while x > n: if x%n != 0: n = n+1 return True else: return False def largest_prime_factor(x): n = 2 list = [] while n <= x: if is_prime(n) == True and x%n == 0:...
e2141e7df482f0b3c15ac194170cc3bf31f653e0
s-takayoshi/python_basic
/kuku_2.py
388
3.75
4
# 下記のような出力が得られる kuku_2.py を実装してください # 任意の行数および任意の列数での掛け算の結果が得られます line = int(input('行数を入力してください: ')) column = int(input('桁数を入力してください: ')) for x in range(1, line + 1): for y in range(1, column + 1): print(x * y, end=' ') print()
d7202833f1353c9b4fc47c86f362993a4dceb6e9
elochka99/--
/9.py
1,180
3.96875
4
import numpy as np import random while True: def bubble_sort(A): N = len(A) i = 0 flag = True while flag: flag = False for j in range(N - i - 1): if A[j] < A[j + 1]: A[j], A[j + 1] = A[j + 1], A[j] ...
3c929df4acc14a223f87cdb6c17f15c89d461a51
Shubham10-create/BloggersSpot
/app.py
4,799
3.5625
4
#Flask is a web framework written in python #Its a microwebframwork which is light weight and it doed not require particular tools or libraries from flask import Flask, render_template, request, redirect #render_template render the template from the given folder from flask_sqlalchemy import SQLAlchemy from datetime im...
b901de1bc873de067dc41a912733db44d78a3ef9
Donut08/Prueba01
/hfasdj.py
422
3.796875
4
def question(question, answers): for i in range(len(answers)): answers[i] = answers[i].lower() while True: p = input(f"{question} {answers}: ").lower() for r in answers: if p == r: print("OK") return p print("Esa no es u...
3b5f771421091b7de1e08a31f0832c91cb120a14
PomPomPix/unsticky-postit
/message.py
616
3.609375
4
import sqlite3 class Message(): def __init__(self): self.conn = sqlite3.connect('data/thewall.db') self.cursor = self.conn.cursor() def save(self, username, text): query = "INSERT INTO message (username, text) VALUES (?, ?) " self.cursor.execute(query, (username, text)) self.conn.commit() def all(se...
cdfa931eba86aa9967b39ca4591901f81a1e3f16
almirgon/LabP1
/Unidade-1/nome.py
195
3.6875
4
#coding: utf-8 #@Crispiniano #Unidade 1: Calcula Nome nome = raw_input('Nome? ') letra = float(raw_input('Letra? R$ ')) calculo = len(nome) * letra print 'Orçamento: R$ {}'.format(calculo)
c3ecbfc0fcba831596720295f4de23b5b3b99730
fengyehong123/Python_skill
/09-安全的访问字典.py
960
4.40625
4
# Python中有两种访问字典的方式 dict_name['key'] 和 dict_name.get('key') from collections import defaultdict d = { 'name': "Python", 'age': 27, 'version': 3.6 } # 当字典的键不存在的时候会报错 # print(d['nam']) # 当字典的键不存在的时候不会报错,会报None print(d.get('nam')) # None # 可以指定一个默认值,当键不存在的时候,会取出指定的默认的value print(d.get('nam', '我是一个默认值')) ...
bf67548120048b285e5c7b4fe0d8cfe8912c25d0
cooku222/python-repeat-0802
/8단원_2_7.py
252
3.609375
4
class Test: def __init__(self,name): self.name=name print("{}-생성되었습니다".format(self.name)) def __del__(self): print("{}-파괴되었습니다".format(self.name)) a=Test("A") b=Test("B") c=Test("C")
d49ef799b25c0b0eb4d259040aa15b275e214d03
saidskander/holbertonschool-higher_level_programming
/0x01-python-if_else_loops_functions/3-print_alphabt.py
140
3.890625
4
#!/usr/bin/python3 for n in range(ord('a'), ord('z')+1): if chr(n) != 'q' and chr(n) != 'e': print('{}'.format(chr(n)), end="")
58c8fa0b0258926fcc5a533e1f09f2ea119cde7f
manuchzhua/Geekbrains
/lesson_3/dz3_01v2.py
809
4.0625
4
def div(x, y): try: return round(x / y, 3) except ZeroDivisionError: return "Деление на ноль невозможно" while True: x = input('Введите делимое или нажмите q для выхода\n') try: x = float(x) except ValueError: if x.lower() == 'q': print('До свидания') ...
d2b96ee2c3b8a4b170873ccf7221a594f7618749
AkiraKane/DataScience
/Data_Analysis.py
6,927
4.125
4
##### Part 1 ##### from __future__ import division import pandas as pd # 1. read in the yelp dataset yelp = pd.read_csv('../hw/optional/yelp.csv') # 2. Perform a linear regression using # "stars" as your response and # "cool", "useful", and "funny" as predictors from sklearn.linear_model import LinearRegression fea...
779dd12b42e16eee455cf7ace17e13cca04cf061
rookieygl/LeetCode
/leet_code/lt_tiku/278.firstBadVersion.py
1,096
3.609375
4
""" 第一个错误的版本 你是产品经理,目前正在带领一个团队开发新的产品。不幸的是,你的产品的最新版本没有通过质量检测。由于每个版本都是基于之前的版本开发的,所以错误的版本之后的所有版本都是错的。 假设你有 n 个版本 [1, 2, ..., n],你想找出导致之后所有版本出错的第一个错误的版本。 你可以通过调用 bool isBadVersion(version) 接口来判断版本号 version 是否在单元测试中出错。实现一个函数来查找第一个错误的版本。你应该尽量减少对调用 API 的次数。 """ def isBadVersion(n): if n == 4: return True clas...
224d242ebda4c1dcf662595a3a82780253e81bdd
alessandrosp/46-simple-python-exercises
/exercise14.py
324
4.15625
4
# Exercise 14: http://www.ling.gu.se/~lager/python_exercises.html def map_length(words): '''A function that that maps a list of words into a list of integers representing the lengths of the correponding words.''' list_length = [] for w in array: list_length.append(len(w)) return list_le...
d781c1c4744b28f97f337a4d15e9659efbc23dd8
gxwangdi/Leetcode
/206-Reverse-Linked-List/ReverseLinkedList.py
520
3.828125
4
# Definition for singly-linked list. # class ListNode(object): # def __init__(self, x): # self.val = x # self.next = None class Solution(object): def reverseList(self, head): """ :type head: ListNode :rtype: ListNode """ if head == None or head.next == No...
85504ac5fe77ba89b41164774aaf885a56bb2030
sarkarChanchal105/Coding
/Leetcode/python/Easy/intersection-of-two-arrays-ii.py
2,222
3.65625
4
from collections import defaultdict ## Solution 1 #class Solution: # def intersect(self, nums1: List[int], nums2: List[int]) -> List[int]: # if len(nums1)>len(nums2): # return self.intersect(nums2,nums1) # hashTableNums1=defaultdict(int) # hashTableNum...
04d4bbe2f16bfdf423aba8f51ccc6bdade15e14e
ladislavdubravsky/bandaged-cube-explorer
/usage.py
3,264
3.921875
4
# -*- coding: utf-8 -*- """ Usage example. """ import networkx as nx import bce.core as c from bce.graphics import draw_cubes # 1. define a bandage shape - alcatraz puzzle solved shape alca = [ 6,6,0, 6,6,0, 0,0,0, 7,7,5, 7,7,4, 1,2,3, 7,7,5, ...
1f43b94a43d07cba809369df91eff375bb10a8e1
vishnuap/Algorithms
/The-Basic-13/Print-Odds-1-255/Print-Odds-1-255.py
155
3.890625
4
# The Basic 13 # Print-Odds-1-255 # Print all odd integers from 1 to 255 def printOdd255(): for i in range(1, 256, 2): print i printOdd255()
83ce9e37a5b300f6e63ed74b173ede73cd43b54b
Anja68/Smartninja
/Class2_Python3/example_00910_list_create_reference_exercise.py
334
4.125
4
# write a shopping list # list should have the elements: "bread", "butter", "soup" # print this list shopping_list = ["bread", "butter", "soup"] print(shopping_list) # you change your mind, you dont want soup, but chocolate # change the element soup to chocolate shopping_list[2] = "chocolate" # print the list print(s...
4250be35076fa98fef2f7e13bd7638557f55ef42
MrZhangzhg/nsd_2018
/nsd1808/python1/day02/guess.py
263
3.890625
4
import random number = random.randint(1, 10) # 生成1-10之间的数字,可以包括1和10 print(number) answer = int(input("number: ")) if answer > number: print('猜大了') elif answer < number: print('猜小了') else: print('猜对了')
e98298c799dd89f0e70afabb414628aa29a1684b
2324593236/MyPython
/Python基础/列表.py
2,845
3.9375
4
import random ##列表的创建与删除 list1 = [1,"a","倪","1","A",["asdf"]]#直接定义一个列表 list2 = []#直接定义一个空列表 list3 = list(range(1,10,1))#用list()函数和range()函数创建一个列表 str1 = "A2s4D5f9g7E5B4a" list4 = list(str1)#用list()函数转换字符串创建列表 list5 = [] del list2#删除列表list2 ##列表的访问 print(list1[2])#用print()函数直接打印输出列表索引为2的元素 print(list1[1:6...
7cd4ea4236cb48da55b8f7aeb45212153f5c45a6
sourav-gomes/Python
/Part - II (Advanced Python)/Chapter 12 - Advanced Python 1/enumerate.py
368
4.375
4
# enumerate(list_name): Enumerate function adds counter to an iterable and returns it list1 = [45, 87.9, True, 'Joseph'] i=0 for item in list1: print(i, item) # will print the index & item of the list i += 1 # The above function using the enumerate(): for index, items in enumerate(list1): print(item...
5b94b29e53b5e4e864313b7559b31076748fdc49
tmbern/Sprint-Challenge--Data-Structures-Python
/names/names.py
2,082
3.65625
4
import time from binary_search_tree import BSTNode start_time = time.time() f = open('names_1.txt', 'r') names_1 = f.read().split("\n") # List containing 10000 names f.close() f = open('names_2.txt', 'r') names_2 = f.read().split("\n") # List containing 10000 names f.close() duplicates = [] # Return the list of d...
6704e0cbd5ee030270f69af56775c30bab3df9ae
koskenni/ofitwol
/ofitwol/ofi2/cleanlex.py
1,538
3.703125
4
def main(): import argparse argparser = argparse.ArgumentParser( "python3 cleanlexc.py", description=""" Reads a newly compiled LEXC FST, extracts its alphabet and selects all symbols which start with "¤" i.e. weights and all symbols starting with "£" i.e. pattern names and ...
b283df7114426c95b793568b7ace2c352f634e45
ErkmenB/Python-Ogrenirken
/fonksiyonlar_2/fibonaci_sira.py
241
3.96875
4
def fibonaci(n): if n <= 0: return 0 elif n == 1: return 1 else: return fibonaci(n-2)+fibonaci(n-1) sira = int(input("Görmek istediğiniz fibonaci sıra numarasını giriniz : ")) print(fibonaci(sira))
bb45f4404e89e62c7e321d2d3142ec6b4bd09c78
NoelXP/the-Big-SleePy
/Getting-Started-w-Python/controlStructures.py
209
3.5625
4
#!/usr/bin/env python3 import sys # Used for the sys.exit function int_condition = 7 if int_condition < 6: sys.exit("int_condition must be >= 6") else: print("int_condition was >= 6 - continuing")
9c77efeab63d448c71cbcd1b1401c09e065e8da7
pysudoku/sudoku
/src/sudoku/writer/writerTXT.py
2,810
3.546875
4
#------------------------------------------------------------------------------- # Name: module5 # Purpose: # # Author: Ines Baina # # Created: 04/07/2013 # Copyright: (c) Ines Baina 2013 # Licence: <your licence> #--------------------------------------------------------------------------...
9360574a60cc6f7a52e52b1d695cd7e97c4a007e
jack-halpin/ZebraPuzzle
/constraint.py
5,293
3.75
4
#Declare a super class constraint class Constraint(object): def __init__(self): pass def is_satisfied(self): pass def reduction(self): pass #The declare and implement each subclass class Constraint_equality_var_var(Constraint): '''This class takes in two variable para...
dd2f31a6ef5fe89a1dbd99c7728e7083268400b8
NumanIbnMazid/Python
/python_basic/python_basic.py
1,506
4.0625
4
age = 21 name = "Numan" is_male = True # Execute code in terminal : 'python python_basic.py' and hit enter print("Hellow my name is {} and I am {} years old".format("Numan", 27)) if age > 18 and is_male: print("Yes you are adult male.") else: print("You are not adult or mot male.") # Function def hellow():...
ca84824c42bfcecf2925ae0a24ff935cc9e3e54b
mahsa19941994/tamrinat-jalase-aval
/Question4.py
293
4.125
4
while True: MySentence = "mahsa,shekari,mashhad,azad-university,Data-Minning" print("our words are: ",MySentence) input("Enter for spliting: ") MySentence_Splited = MySentence.split(",") print ("word after packaging : ", MySentence_Splited)
0ed42da022705a055e13a3946dbc9e0c7423e3a5
FilipHarald/FirstWebApp
/encrypter.py
1,047
4.09375
4
import string def encrypt_letter(letter): lowercase_alphabet = string.ascii_lowercase uppercase_alphabet = string.ascii_uppercase index_lowercase = lowercase_alphabet.find(letter) index_uppercase = uppercase_alphabet.find(letter) if (index_lowercase == -1): if (index_uppercase == -1): #o...
710a14a668a00ff1590e8aabd622d567f4fb4946
yangruihan/practice_7_24
/PythonPractice/ex_定制类.py
4,625
4.125
4
# -*- coding: utf-8 -*- # # filename:'ex_定制类' # #----------__str__/__repr__---------- class Student(object): def __init__(self, name): self.name = name print Student('Yang') # result:<__main__.Student object at 0x007DDC30> class Student2(object): def __init__(self, name): self.name = name def __str__(self)...
65b985f7c83760184e6cb8f2efb23047b59d076b
pjain4161/HW06
/HW06_ex09_05.py
1,832
4.1875
4
#!/usr/bin/env python # HW06_ex09_05.py # (1) # Write a function named uses_all that takes a word and a string of required # letters, and that returns True if the word uses all the required letters at # least once. # - write uses_all # (2) # How many words are there that use all the vowels aeiou? How about # aeiouy?...
30a91221b78ac19a4bd9fdfd0359b80919ba3e32
stcentre/Pandas-Tutorials
/Python_Tutorials/3Debugging_and_Error_Handling/Deebugging_with_pdb.py
1,998
3.8125
4
""" When We Encounter an error in our code that is not intentional.So we didnt raise it, we didnt expect it. or we can say that a silent error or silent bug like we can say our code isnt wotking the way we expect.but its not actually breaking the code.So thats the most frustrating. the code didnt break but it result s...
439c247bc3377b404a9daabbb39b4b31163c9f9c
CHepchirchir/MyFirstEver
/Assignment5_Updatedlast.py
3,633
3.84375
4
# -*- coding: utf-8 -*- """ Created on Fri Apr 16 13:23:30 2021 @author: chepchir """ options = '' #Declaring an empty string while options != 'Q': options = input('Enter the options [P,C,NM,M,CM,Y,In,Q]?') print() if options == 'P': print('[P] Print Options') print(...
f015be7f9b8444ee281c3c03ddbd343679e6a0bf
KrishothKumar/Python_Practice
/Circle.py
395
4.3125
4
# This program print circumference and area PI = 3.14 # r*r is repesents squire and PI =3.14 def area(r): return PI * (r**2) # 2 multiply PI=3.14 multiply r def circumference(r): return PI * (2 * r) # Main if __name__ == "__main__": ra = float(input("Enter the Radius of Circle: ")) print("Circum...
a28b0b961eec2af6f19dff62d56cca06844aaeff
mmylll/FDSS_Algorithm
/jzoffer/65-add.py
252
3.953125
4
def addTwoNumbers(num1, num2): while True: sum_num = num1 ^ num2 carry_num = (num1 & num2) << 1 num1 = sum_num num2 = carry_num if num2 == 0: return num1 print(addTwoNumbers(1, 10))