blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
a7c9258100394b4d612dcc42bea64ec910c27c8a
rodrigoadelino/CURSOEMVIDEO-DESAFIOS
/DESAFIO_008-Conversor_de_Medidas.py
210
4.09375
4
#Escreva um programa que leia um valor em metros #e o exiba convertido em centimetros e milimitros n=int(input('digite um numero em metros')) c=n*100 m=c*100 print ('{} centimetros\n{} milimetros'.format(c,m))
57b33fe63ea6b0177e61e3f766a1dd3d7015af27
tjuls123/DesignPattern
/builder.py
1,385
3.5625
4
# -*- coding:utf-8 -*- # Author: lsn5884@corp.netease.com # Date : 2020/5/26 # Note : 建造者模式 import abc class Product(object): """产品类,由不同的部件组成""" def __init__(self): self.parts = [] def add(self, part): self.parts.append(part) def show_product(self): for part in self.parts: print part class Builder(...
95d3b24be25ac09c4c1ad01c37ad135894e9adfe
aDENTinTIME/holbertonschool-higher_level_programming
/0x0C-python-almost_a_circle/models/rectangle.py
3,806
4.1875
4
#!/usr/bin/python3 """Rectangle class """ from models.base import Base class Rectangle(Base): """ class Rectangle inherits from class Base. A rectangle object that can create a rectangle of any size. It can return it's area or print a 2D representation of itself at a given offset. Args: ...
f73b92a213fe36930ef11939ec921c3ea2795987
rafaelribeiroo/scripts_py
/+100 exercícios com enunciados/RANDOM/Desconto.py
302
3.609375
4
print('Qual é o preço?') p = float(input('R$ ')) print('Qual é o preço após o desconto?') np = float(input('R$ ')) d = 100 - (np * 100 / p) print('Seu preço reduziu {:.0f}%'.format(d)) if d >= 20: print('> É um bom desconto') else: print('> É um desconto relativamente ruim')
74b960d0a66435668263ddb6d1cf61a2f348fc76
schau-sjsu/FlaskHw
/app/models.py
1,924
3.546875
4
from app import db class User(db.Model): """ Represent a table of users for the message board. Attributes ---------- id : Column User id represented by an integer. author : Column Name of the user represented by a string. message : Column Message posted by the user ...
ed19692d07b646e4a35f9793b75981ba45f67cea
rteja1113/AlgorithmsPractice
/dynamic_programming/rodCut.py
1,544
3.859375
4
""" We can cut up a rod of length n in 2^(n-1) different ways, since we have an in- dependent option of cutting, or not cutting, at distance i inches from the left end, """ def memoized_cut_rod(prices, n): """ Top Down Approach """ revenues = [-float("Infinity")]*(n+1) return revenues, memoized_cut_rod_aux(prices...
94c603e7b677ec729a9d12d4f4242cc83f3df59c
cocoon333/leetcode
/611_valid_traingle_number.py
771
3.84375
4
""" Given an integer array nums, return the number of triplets chosen from the array that can make triangles if we take them as side lengths of a triangle. """ class Solution: def triangleNumber(self, nums): if len(nums) < 2: return 0 nums.sort() res = 0 for i in range(...
b95f3a8315e1e9e9fbc68a5734cce84b339e1e38
Fandresena380095/Some-Projects-in-python
/Another test.py
789
4.03125
4
print("BUBBLE SORT") num2 = [55456,87,975757,34,987,65546565,98758585,986875754653642,22,2323223,23232332323,224242,444,444,4] for i in range(len(num2)): for j in range(i+1,len(num2)): #i must be compared to j if num2[i] > num2[j]: num2[i] ,num2[j] = num2[j] ,num2[i] print(num2) pr...
9dcab2280f761b38fdef5ffc8cd40a31739afdd8
Anvesh8263/python-lab-30
/update_binaryfile.py
1,046
3.703125
4
""" creat a binary file with roll number, name and marks. input roll number and update marks """ # create a file with roll number, name and marks with open("binary_filemarks.txt", 'wb' ) as f: flag = 'Y' while flag != 'N' or flag != 'n': roll_n = int(input("Enter the roll number ")) ...
a58775b53bd62f4c303fac722ec7f7934557c907
eugenius1/Udacity-CS101
/network-of-gamers.py
16,668
4.34375
4
# --------------------------- # # Intro to CS Final Project # # Gaming Social Network # # --------------------------- # # # Background # ========== # You and your friend have decided to start a company that hosts a gaming # social network site. Your friend will handle the website creation (they know # what th...
dbdc7507699ed99e9bdc1444ea829db2a1117416
l-schultz3/python-tictactoe
/prototypes/moreFromSO.py
480
3.765625
4
def place(who, when, where, table): if (None, None) not in table: # the table is full print(table) return if table[where] not (None, None): # this cell is already marked return table[where] (who, when) # can place our mark on the cell # make the recursive calls for i in ran...
27dec752daae7c4856a792f1e22fe6e6b9617dca
ankitk29kothari/Step2success
/Python/9. for loop/forelse.py
144
3.765625
4
a=[1,2,3,4,5,6] for i in a: print(i*i) if i==5: if i==7: break else: print('for loop exe completed') print('for loop exe completed')
bbb7e6421504cc4f3897ed1bc43dbde2873ce323
2062440602/rita
/day37求1~100以内的数的和.py
161
3.859375
4
print("使用while编程实现求1~100以内的数的和!") num=0 sum=0 i=0 while i<100: num=num+1 sum=sum+num i=i+1 print("和为:",sum)
e8b42921a51f1bca5ff53a6c8ecf31c97ed3aeca
runalb/Python-Problem-Statement
/PS-1/ps27.py
288
3.875
4
# PS-27 WAP to accept numbers and display its table. ''' Note: If user enters 7 output should be as follows 7 x 1 = 7 7 x 1 = 14 ... ... 7 x 1 = 70 ''' num = int(input("Enter no: ")) for x in range(1,10+1): res = num * x print("{} x {} = {}".format(num, x, res))
c59e205bc457f951172820d778ddcde93408e331
teju-akella/PythonScripts
/EvenAddBelow40lac.py
526
3.59375
4
class EvenNumAdd: def method1(self): j=1 k=0 result=0 #for i in range(i,number): while j<=4000000: temp=k+j k=j j=temp if j<=4000000: if j%2==0: print(temp) result=result+j...
7596b14fb128de74f9deb9fface4797c8c24be52
sid10on10/GUVI_codekata
/Stack/infix_to_postfix.py
1,287
3.828125
4
class Stack: def __init__(self): self.items = [] def push(self,data): self.items.append(data) def pop(self): return self.items.pop() def peek(self): return self.items[-1] def isEmpty(self): return self.items == [] ...
5fb74fa2635403ec8049f1eebf020510bdad2228
keerthiv1119/CoronaRelief
/Day1_SingleNumber.py
1,033
3.65625
4
''' Author : Keerthi Vutukuri Date : 01- 04-2020 Name : Single Number ''' #Using Iterations it will took O(n^^2) Time Complexity with O(1) Space Complexity def single(ar): for i in range(len(ar)): count = 1 for j in range(i+1,len(ar)): if ar[j] == ar[i]: count += 1 ...
be615098c8635044049bd2feaca2479c9289b297
TropinNikolay/EpamPython2019
/03-fp-decorator/hw/hw4.py
403
3.578125
4
def applydecorator(function): def wrapper(foo): def inner(*args, **kwargs): return function(foo, *args, **kwargs) return inner return wrapper @applydecorator def saymyname(f, *args, **kwargs): print('Name is', f.__name__) return f(*args, **kwargs) # saymyname is now a d...
659dbb382f42f6af9ffedc53d05add8858f7f3fb
anmolrajaroraa/python-reg-oct
/exception_handling.py
1,237
4.40625
4
#try -> write all logic here #except -> catches all the exceptions and do the needful #else -> will execute if try completes normally, if exception occurs, else will not execute # try: # num1 = int(input("Enter first number: ")) # num2 = int(input("Enter second number: ")) # # quotient = num1 / num2 # # ...
c599a67dd5334cc0904df56a6ec3ce4591fce1b9
breezekiller789/LeetCode
/896_Monotonic_Array.py
875
3.890625
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- # https://leetcode.com/problems/monotonic-array/ # 設定flag # Output: true nums = [1, 2, 2, 3] # Output: true # nums = [6, 5, 4, 4] # Output: false # nums = [1, 3, 2] # Output: true # nums = [1, 2, 4, 5] # Output: true # nums = [1, 1, 1] # Output: false # nums = [2, ...
a475988fec3f70c0f0e4deaee30ca029660c1ca5
thofiqming/python_basics
/file/copy_a_file.py
281
3.5
4
# copy file content and crate new one with file name ending with _copy def copy_a_file(file_path): with open(file_path, 'r') as fr: file_content = fr.read() with open(f'{file_path}_copy', 'w') as fw: fw.write(file_content) copy_a_file('test.txt')
82408a91919d37da3cb73b2301c6df440264da6d
kronoslee/c_to_f
/C_to_F.py
110
3.59375
4
c = input('請數入攝氏溫度:') c = float(c)#型別轉換 f = c * 9 / 5 + 32 print ('華氏溫度為:', f)
3717ed0141ce429b635f399ec78983b92f0de4e0
ssolod/locationgen
/randombasic.py
517
3.640625
4
import random from point import Point # generates a random point in a given rectangle class RandomPointRect: def __init__(self, rectTopLeft, rectBottomRight): self.topLeft = rectTopLeft self.botRight = rectBottomRight self.xRange = self.botRight.x - self.topLeft.x self.yRange = self.botRight.y - se...
72881edd7382f5fa211deba3db48da0d84c61b81
haokaibo/PythonPractice
/basic/iterate_tree_by_level.py
1,028
3.90625
4
""" Given A Binary Tree, print its values in level order such that there's a new line after every level """ from queue import Queue class Node: def __init__(self, val, left=None, right=None, level=0): self.val = val self.left = left self.right = right self.level = level root = No...
44879ef7f3634dbbc83ce121af4bea83fcc2e268
qmnguyenw/python_py4e
/geeksforgeeks/python/easy/30_14.py
6,772
4.28125
4
Timeit in Python with Examples This article will introduce you to a method of measuring the execution time of your python code snippets. We will be using an in-built python library timeit. This module provides a simple way to find the execution time of small bits of Python code. **Why timeit?** ...
53f782685a95a5abe64f27667197bb0704d96bad
sunyeongchoi/sydsyd_challenge
/argorithm/ni_test3.py
314
3.546875
4
def solution(A): answer = 0 temp = [] for i in range(len(A)-1): temp.append(A[i]-A[i+1]) t1 = temp[0] for j in enumerate(temp): if t1==j: return answer if __name__ == '__main__': real_answer = solution([-1,1,3,3,3,2,3,2,1,0]) print(real_answer)
053bf07f1bb8a808a88714f9d17d19ac375f72ab
danielGoldsteinCS2021/Connect4-Reinforcement-Learning
/connect4_MCTS.py
10,959
4.125
4
from math import sqrt, log from random import choice ''' The first class is our ConnectFour class which defines the logic and rules of our ConnectFour game. It determines when the game has reached a terminal or winning state and creates the necessary attributes and methods needed to play the game. States are represen...
bedd72cdf100f5672165794c9865662d8cfcfb6d
zhaopeilin1/pythonhello
/ThankYou.py
549
3.53125
4
#coding:utf-8 #ThankYou.py 感谢 #import sys #reload(sys) #sys.setdefaultencoding('utf8') my_name="zhaopeilin" my_age=32 #raw=raw_input("你的名字是什么?") #your_name=raw.encode("utf-8") #TODO 在centos的终端下,输入中文字句有编码问题,程序不能正常运行 your_name=input("你的名字是什么?") your_age=input("How old are you?") print("我的名字是",my_name,",我有",my_age,"岁") pr...
be0bd0a5fa49624cf342d8b9c9eed97fd7679301
sunyi1001/leetcode
/101.py
1,636
3.921875
4
class TreeNode: def __init__(self, x): self.val = x self.left = None self.right = None class MyTree: def createTree(self): root = TreeNode(1) root.left = TreeNode(2) root.right = TreeNode(2) return root class Solution: def isSymmetric(self, root): ...
ba6f2568e56c824d09f5076e6c242784634d1a42
krillato/python_basic
/Functions/EP81 Tower of hanoi.py
678
4
4
""" n = จำนวนจาน 3 เสา => A B C มีจานจำนวน 3 จาน n=1 (n-1) n=2 (n-1) n=3 (ใหญ่สุด) """ """ A => 3 => C ใหญ่ => เล็ก B (จุดพักจาน) A => ล ก ญ (เอา ล ก ไปอยู่ที่ B เพื่อเอา ญ ไปให้ C) A (ล ก) => B A ญ => C C => ? ? ? """ def hanoi(n,a,b,c): #a => c if n==0 : return hanoi(n-1,a,c,b) # ย้าย a (ล...
68a944b95907cfa82fa51f859f29af09a04934d9
AishwaryaJadhav9850/Sorting-Algorithm
/BubbleSort.py
853
4.15625
4
# -*- coding: utf-8 -*- """ Created on Sat Aug 1 10:15:42 2020 @author: SUPERNOVA2813 Time Complexity worst case O(n^2) best case O(n) Stable sorting alogrithmn inplace sorting works nicely for small set of data No additional storage is required """ def BubbleSort(): if(len(array)<0): ...
72ea53ede3c4cdfb794d82bd240f88a9f92ec611
dzionek/adventofcode2020
/03.py
846
4.09375
4
from math import prod tree_symbol = '#' file = open('inputs/3.txt') board = file.read().split('\n') board_length = len(board[0]) def traverse(right: int, down: int) -> int: """ Traverse the board until there are no more rows. Args: right: How many steps do we go to the right? down: How m...
f2b66705e8b7ca51fe48cd38463f36deaaaef39a
roberthsu2003/python
/TQC/PYD908.py
431
3.671875
4
f_name = input() n = int(input()) word_dict = dict() with open(f_name, 'r') as file: for line in file: word = line.strip('\n').split(' ') for x in word: if x in word_dict: word_dict[x] += 1 else: word_dict[x] = 1 word_list = word_dict.items()...
58a131523ad26b6474a8e0fb24112d3123fe564b
kevinelong/PM_2015_SUMMER
/StudentWork/SophiaOsintsev/python/palindrome.py
589
4.28125
4
#Return true if the given string is a palindrome. Otherwise, return false. def palindrome(string): punct = """.,?'":;!()""" output = [] #lowercase a string string = string.lower().replace(" ","") #remove white space # string = string.replace(" ","") #remove punctuation for letter in string: ...
cd61ac7e2b62d91a3c630cc536e5fa34edb92226
fanyichen/assignment6
/fnd212/intervals.py
8,331
3.515625
4
class InvalidInterval(Exception): def __str__(self): return '''Invalid Interval: The bounds must always meet the requirement that lower <= upper if both bounds are inclusive, lower < upper if one bound is exclusive and one inclusive, or lower < upper-1 if both are exclusive. ''' class MalformedInter...
f1570d1fc7c6b46a32dd8730f23d2fb167ecfb75
ebellbog/portfolio
/Code samples/School projects/Bioinformatics/NJTree.py
6,169
3.875
4
#!/usr/bin/python #CS 68, Bioinformatics: Lab 4 #By Elana Bogdan and Emily Dolson import pygraphviz as pgv import sys, os, copy def main(): #Make sure command-line arguments are valid if len(sys.argv) < 2: print "Usage: NJTree.py distances" exit() if not os.path.exists(sys.argv[1]): ...
0446576f852ddf6dfa640aad94fbd0cb94287ca7
HelberthGM/Python
/Tuplas.py
455
4.15625
4
# Tuples, Listas que no se pueden modificar, NO son necesarios los () miTupla=("Alejandro", 5, 12, 2002) # Desempaquetado de tuple nombre, dia, mes, agno=miTupla print(dia,nombre,agno,mes) # Convertir una tupla a lista miLista=list(miTupla) print(miLista) # Convertir de tupla a lista Igual q arriba solo q tuple en vez ...
015e16d0ab4636493160204b73ce88d098ffba93
CodetoInvent/interviews
/logest_substring_sliding_window.py
442
3.84375
4
# Longest Substring Without Repeating Characters def lengthOfLongestSubstring(s): maximum = 0 i = j = 0 charachters = set() while i < len(s) and j < len(s): if s[j] not in charachters: charachters.add(s[j]) j += 1 maximum = max(maximum, j - i) else: ...
23418341a3629e1c4fd9f693954aefbdcf04ef96
gpadiernos/advent-of-code
/2019/01/day01.py
713
4.09375
4
#!/usr/bin/python3 # Advent of code 2019 # Day 01 def calculate_fuel(fuel_mass): # recursively calculate the fuel needs to launch a module. new_fuel_mass = fuel_mass // 3 - 2 if new_fuel_mass <= 0: return 0 return new_fuel_mass + calculate_fuel(new_fuel_mass) #read in masses with open ('input...
96981ca08dfee07be091a170b8f3c485c02ba2f8
alephist/edabit-coding-challenges
/python/upvotes_vs_downvotes.py
387
4.15625
4
""" Upvotes vs Downvotes Given a dictionary containing counts of both upvotes and downvotes, return what vote count should be displayed. This is calculated by subtracting the number of downvotes from upvotes. https://edabit.com/challenge/SFE4q5pFTi8TBwj76 """ from typing import Dict def get_vote_count(votes: Dict[s...
7088d0de17cf160089243f74a82d478712fc2c12
jpalat/AdventOfCode-2020
/day11/day11.py
6,801
3.546875
4
import copy def model_seats(input): floor = list(input) floor_plan = [] size = len(floor[0])-1 for l in floor: line = list(l.strip()) floor_plan.append(line) print('Start') delta = 1 while delta > 0: floor_plan, delta = mutate(floor_plan) return count_passengers(...
d71ce9d78db9d0020b8f1c2a46560ee78450da8e
JosephLevinthal/Research-projects
/5 - Notebooks e Data/1 - Análises numéricas/Arquivos David/Atualizados/logDicas-master/data/2019-1/223/users/4191/codes/1716_2508.py
257
3.640625
4
n=int(input("Quantidades de termos: ")) sinal=1 numerador=2 cont=1 result=3 denominador=4 while(cont<n): result=result+(sinal*(4/(numerador*(numerador+1)*(numerador+2)))) sinal=sinal*(-1) numerador=numerador+2 cont=cont+1 print(round(result, 8))
4e28b6f89f11f7e972901dfd86c07c9478be7cbe
yagomotti/aps2
/____init___.py
1,290
3.5
4
#region import import tkinter as tk #importa p abrir o explorer from tkinter import filedialog #importa p abrir o explorer import sys import os import random import unicodedata root =tk.Tk() #faz sobrepor o explorer root.withdraw() def restart_program(): python = sys.executable os.execl(p...
0a64eb18db8aee51c5f62641fb01dcdee0c1e0fc
EmperorKaiser/Leetcode-Solution-Notes
/007_ Reverse_Integer.py
1,081
3.78125
4
class Solution: def reverse(self, x: int) -> int: ''' 题目:Given a 32-bit signed integer, reverse digits of an integer. Assume we are dealing with an environment which could only store integers within the 32-bit signed integer range: [−2^31, 2^31 − 1]. For the purpose of this problem...
fef4d0104795533b7c48ceed0b88668228c92e81
Sleeither1234/t08_huatay.chunga
/chunga/iteracion.py
1,108
4.15625
4
#EJERCIOIO 1 fruta="Pera" for i in fruta: print(i) print("-----") #EJERCIOIO 2 fruta="Manzana" for i in fruta: print(i) print("-----") #EJERCIOIO 3 fruta="platano" for i in fruta: print(i) print("-----") #EJERCIOIO 4 fruta="Mango" for i in fruta: print(i) print("-----") #EJERCIOIO 5 fruta="Sandi...
310f9b4b62af771421f13af1ad115b2ec08acbcc
bhaveshshrimali/projectCS450
/HW1/Problem1.py
2,844
3.78125
4
#Submitted by Bhavesh Shrimali #Importing the libraries import math as mp import numpy as np #Defines a function func, with inputs x and n defined as follows: #x: the value at which the function is evaluated #n: the number of terms in the taylor expansion def func(x,n): result = 0; for index1 in range(1,n+1)...
111f9c1a02990a04c77ba490334d49ae84e14993
marumuji/self-taught
/chap12-challenge/challenge-3.py
197
3.765625
4
class Triangle: def __init__(self, b, h): self.bottom = b self.height = h def area(self): return self.bottom * self.height / 2 t1 = Triangle(3, 4) print(t1.area())
ebb5521dfb4b34cc283d0c84002810f89424931d
hgranthorner/Blackjack
/Blackjack.py
2,303
4.03125
4
# Author: Grant Horner (h.grant.horner@gmail.com) # Create an interactive game of Blackjack # Draw between 1-11 import random print("Hi there! What's your name?") name = input("Enter your name: ") print("Nice to meet you " + name +"!") play = input("Want to play? (y or n)\n") while play != 'y' and play != '...
2143124de68106b3597cf13cd9b625963d9f9003
WillMc93/Rosalind
/fibd.py
549
3.625
4
import pdb def fibd(n, m): rabbits = [['b', 0]] for i in range(0, n): # oh they faukin rabbits_ = rabbits for rabbit in rabbits: if rabbit[0] == 'a': rabbits_.append(['b', 0]) rabbits = rabbits_ # increment age for rabbit in rabbits: rabbit[1] += 1 # age babies for rabbit in rabbits:...
7a67912e8dbd4b8915b14da01144d740961fa028
Fulvio7/curso-python-guppe
/guppe/exercicios_secao_5/ex_22.py
617
4
4
""" 22- Leia a idade e o tempo de serviço de um trabalhador e verifique se ele pode ou não se aposentar. Para se aposentar, as condições são as seguintes: - Ter pelo menos 65 anos; - Ou ter trabalhado pelo menos 30 anos; - Ou ter pelo menos 60 anos e trabalhado pelo menos 25 anos; """ print('=== INSS ===') idade = int...
c19f348cf2d2373321e496555a0619db9b9a7aaf
umunusb1/Python_for_interview_preparation
/all/leetcode/136_single_number.py
1,017
3.75
4
#!/usr/bin/python """ Purpose: https://leetcode.com/problems/single-number/ Given a non-empty array of integers, every element appears twice except for one. Find that single one. NOTE: Your algorithm should have a linear runtime complexity. Could you implement it without using extra memory? """ from typ...
32831ef37ae0cbead7535c5994f6c65b80d5edb9
Lucas-coder/dataprocessing
/Homework/Week_3/convertCSV2JSON.py
1,828
4.03125
4
# Convert CSV into json # Lucas Lumeij # # This script takes a CSV input file and JSON target file and converts the CSV data # into JSON data. import sys import getopt import csv import json def main(argv): """Checks input in command line and calls read function.""" # get options from command line, explain u...
1be26d38dca84c182663db150b52939022090307
Kalmihyun/ct_201710886
/강의/myEvent.py
1,244
3.671875
4
import turtle win = turtle.Screen() t1 = turtle.Turtle() def isInTrap(x,y,x1,y1,x2,y2): minx=min(x1,x2) maxx=max(x1,x2) miny=min(y1,y2) maxy=max(y1,y2) if ((minx<x and x<maxx) and (miny<y and y<maxy)): return True else: return False def drawRectWithFill(x1,y1,x2,y2,color): t1.got...
7f4eea40fea92041defcb2dd3e4615c477d24119
fujinotakaaki/practice_py
/practice_sympy/sample02.py
661
3.953125
4
# coding:utf-8 import math from sympy import * # 2元2次方程式の扱い [x,y] = symbols('x y') f = (y-2)**2 + (x-2)**2 - 1 # 各変数について解く x1 = solve(f, x) y1 = solve(f, y) print 'x = %s' % x1 # x = [-sqrt(-(y - 3)*(y - 1)) + 2, sqrt(-(y - 3)*(y - 1)) + 2] print 'y = %s' % y1 # y = [-sqrt(-(x - 3)*(x - 1)) + 2, sqrt(-(x - 3)*(x - 1...
5df29b5e6a28aeec23e77ee5d72e32adff2aa673
Bharadwaja92/CompetitiveCoding
/HackerEarth/CodeArena/IdealRandNum.py
936
3.71875
4
"""""" """ Assume there is an Ideal Random Number Generator which generates any real number between 0 and given integer. Two numbers are generated from the above generator using integer A and B, let's assume the numbers generated are X1 and X2. There is another integer C. What is the probability that summation of X1 ...
3203a7438af7c284f151333b72a55511a2568a7c
marchuknikolay/bytes_of_py
/byte091/anyall.py
740
4.125
4
""" Bite 91. Matching multiple strings Catching up after #PyCon2018 ... in this Bite you do multiple string matching. Complete contains_only_vowels, contains_any_py_chars, and contains_digits below. See more info in the docstrings and the tests. Have fun! """ VOWELS = 'aeiou' PYTHON = 'python' def contains_only_vo...
683afe6c753c31a4bfa3ec537d39eafb6d866634
MarinaFdezSues/PythonExercises
/diccionarios1.py
626
3.78125
4
def diccionarios1(lista): print(lista) dic={l[0] : l[1:] for l in lista} return dic def diccionarios1extra(l): dic={} print(l) for x in l: key=x[0] values=list(x[1:]) dic[key]=values return dic def extraDicc1(l): dic={} k=l[0] v=l[1] for x in range(0,len(k)): try: d...
2fa99b34918a25b6d23e02ca438c949f062ee36c
Madhu-Kumar-S/Python_Basics
/Tuple/min_max_tuple.py
147
3.96875
4
# Python – Maximum and Minimum elements in Tuple t = (1, 2, 3, 4, 5) print("minimum of t-elemnts",min(t)) print("maximum of t-elemnts",max(t))
71e33c49c5876ead8a444172a2cb8fb41e4611a6
nishikaverma/Python_progs
/variable_len_argument.py
224
4.0625
4
def find_largest(*t): max=0 large='' for x in t: if len(x)>max: max=len(x) large=x return x print("the largest strin among them is ",find_largest("january","feb","augusth"))
227efb9d7ba1bcd57486a02c2c7e3e17c60e501f
jdrestre/Online_courses
/Codigo_Facilito/development_python/professional_course_of_python/python_profesional/ejemplos/funciones/map.py
293
3.828125
4
def cuadrado(numero): return numero * numero lista = [1,2,3,4,5] resultado = map(cuadrado, lista) lista_resultado = list(resultado) print(lista_resultado) lista = [1,2,3,4,5] resultado = map(lambda numero: numero * numero , lista) lista_resultado = list(resultado) print(lista_resultado)
f1e44ba0208fc6b6a5562d6f4393c968942effa3
joseraz/learn-python
/ex13.sd1.py
579
3.921875
4
# adds features to the script from the Python feature set # "features" are more commonly known as "modules" from sys import argv # read the WYSS section for how to run this # this line takes what is in argv, unpacks the argv, then assigns it four different variables script, first, second, third = argv # print the varia...
50cb0801bd25c965722cb64888114a2e63bc7944
Pavlov83/Python
/AlgorithmsAndDataStructures with Projects/Python Basics/Strings.py
263
3.84375
4
#Strings in python are suurrounded by single or double quotes #Example print("Hello World") #If we have in our text a quote we use the other type of quote for the string #Example print("That's my quotes example") #We can also use '\' which is escape character
3043facb634827c8fbd5fc20a5a0c1ab6aa02232
tanaypatil/code-blooded-ninjas
/dynamic_programming_2/trader_profit.py
1,284
3.84375
4
""" Trader Profit Send Feedback Mike is a stock trader and makes a profit by buying and selling stocks. He buys a stock at a lower price and sells it at a higher price to book a profit. He has come to know the stock prices of a particular stock for n upcoming days in future and wants to calculate the maximum profit by ...
d745dcbe9950a8c0aa9198606fae4832c8f35f8a
FrankOdey/HNG5.0
/taskOne.py
250
4
4
hours = input("Enter your hours of work: ") rate = input("Enter your rate: ") pay = float(hours) * float(rate) print('Your pay is: ' + str(pay)) print('All payment of' + str(pay) +'is made via wire transfer') print('your working hour is'+ str(hours))
b2d776f69f7195d42ccb5adb0ffa5dcca5c7fade
buyi823/learn_python
/python_exmple/common_multiple.py
444
4.15625
4
#!/usr/bin/python3 # filename: common multiple def lcm(x, y): if x > y: greater = x else: greater = y while (True): if ((greater % x == 0) and (greater % y == 0)): lcm = greater break greater += 1 return lcm num1 = int(input("enter the first n...
11da01f963402245b215b00c1620592c10d47beb
bunyodabdusaidov/tournament-scoring-system
/tournament.py
1,492
3.65625
4
import random class Start: def __init__(self, registered, events, scores): # initialize registered participants, event types, scores self.registered = registered self.events = events self.scores = scores def start(self): """ Starts the tournament. Iterated through the...
defdf1bf610748899c791260b888ed2cdc73f6a6
alexiswalker/language-identification
/data/codes/train/yM50SyX9.Python
4,279
4.09375
4
#!/usr/bin/python # -*- coding: utf-8 -*- import sys import argparse import codecs import itertools """ My über secure encryption script! """ def xor(text, key1, key2): key1 = key1 * (len(text)//len(key1) + 1) key2 = key2 * (len(text)//len(key2) + 1) res = "" for i in range(len(te...
e4e875d71163aa451aa88f77952f1a735a4eba04
DennisMufasa/PythonPractice
/evenOdd.py
445
4.21875
4
def evenOdd(number): """Determining whether a number is odd or even""" number = int(number) if number % 2 == 0: print('{} is even'.format(number)) else: print('{} is odd'.format(number)) # evenOdd(4) def oddEven(number): """Determining whether a number is even or odd""" number...
b2746bde514e52dc37d1e356d8cd74da85f16c72
Parth-Ps/python
/csv_parsing/practise.py
1,292
4.1875
4
import csv # NORMAL METHOD # with open('names.csv', "r") as f: # csv_reader = csv.reader(f) # # next(csv_reader) # start from 1 index # with open('practise_new.csv', 'w') as new_file: # csv_writer = csv.writer(new_file, delimiter='\t') # for line in csv_reader: # csv_writer....
66d374fe4b46f73826b3818beef321921019c401
BoostCreep/samplepython
/foods.py
500
3.5625
4
my_foods = ['pizza','hotdogs','roast beef','tacos','tuna sandwich'] friend_foods = my_foods[:] print("My favorite foods are: ") print(my_foods) print("\n My friend's favorite foods are: ") print(friend_foods) my_foods = ['pizza','hotdogs','roast beef','tacos','tuna sandwich'] friend_foods = my_foods[:] m...
7e3c3c6c320cda9e99009cdeab6b37a8b24d4c08
wobuxiangtong/algorithm
/basics/bubble_sort.py
261
3.984375
4
def bubble_sort(lists): l = len(lists) for i in range(0,l-1): for j in range(i+1,l): if lists[i] > lists[j]: lists[i],lists[j] = lists[j],lists[i] a = [81, 23, 22, 56, 94, 47, 62, 6, 87, 17] bubble_sort(a) print(a)
940c8c452916fdfe5199ce54097c458978825e95
CoderDojo-Thessaloniki/Python
/ebook (greek)/(sourcecode)Introduction-To-Computer-Programming-With-Python/6.7.py
153
3.703125
4
name = 'Mariza' def sayHello(): print('Hello ' + name) def changeName(new_name): name = new_name sayHello() changeName('Katerina') sayHello()
b360fd625ddb8e2235342c59a298b830f6c9c928
CsRacer/LearnToPy
/rocket_academy/basics/_5_datastructures.py
3,872
4.15625
4
# Bei einer unbestimmten Menge von Daten und/oder Werten wird das Speichern mit einfachen datantypen zu kompliziert und unübersichtlich (Bsp. Gebrauchtwagenhaendler) # Weiterer nachteil von einfachen Datentypen => Mann muss den genauen Variablennamen kennen # Kategorisierung von Daten möglich (z.B. Kombi, SUV und weite...
f7e3c13b5435f3757446218db05016bf929f65a0
nhatcuong/DesignPatternsGangOf4
/creational_patterns/_control.py
687
3.53125
4
from creational_patterns._models import * def create_maze(): #create a maze with 2 rooms and a door in between maze = Maze() room1 = Room(1) room2 = Room(2) door = Door(room1, room2) maze.add_room(room1) maze.add_room(room2) room1.set_side(Direction.NORTH, Wall()) room1.set_side(Direc...
add104fbec11011c4136390935f8581e9924f691
IngridFCosta/Exercicios-de-Python-Curso-em-video
/Lista02/ex087_MatrizAprimorada.py
1,036
4.1875
4
"""087- Aprimore o desafio anterior(086) mostrando no final: a) A soma de todos os valores pares digitados b) A soma dos valores da terceira coluna c) O maior valor da segunda linha""" matriz=[] lista01=[] lista02=[] lista03=[] somaPares=somaTerceira=0 for x in range(0,3): valor=(int(input('Escreva um numero: ')...
21bb3f6b187c25a463c803b2cbe01b7e104b81a4
metanitesh/Data-Structure-Algorithm-Python
/data-structure/recursion/05-palindrom-check.py
268
3.90625
4
def is_palindrome(input): if len(input) <= 1: return True; first = input[0] last = input[-1] if first is not last: return False; input = input[1:-1] return is_palindrome(input); # print(input) print('**') print(is_palindrome('nitesh'));
3410f2a63c34fe8dc1e7ff3371a361c9ae2e3409
ssj1739/DNA_reader
/DNAreader.py
9,447
4.09375
4
#DNA-READER/GENERATOR # #Collects nontemplate DNA strand from user and translates to protein, #or creates random DNA sequence using random module and generates #translation of random sequence. Also checks protein for first start #amino acid (ATG/Met) and displays protein from first stop codon to #first stop codon (Ochr...
742f2cbd0b61503c15d5122db6f9cef53ddc13bd
kenneth7198/RpiForNMA
/backup/basic/tset44.py
81
3.53125
4
my_list = [1,2,3,4,5,6,7,8,9,10] for i in range(0,10,2): print(my_list[i])
c1f8631e0e39376f791cc8aa2451c846f15fd929
linnndachen/coding-practice
/Leetcode_By_Topic/tp_bit-1371.py
1,234
3.546875
4
class Solution: # "Time: O(n), Space: O(number of unique vowel count sequences)" def findTheLongestSubstring(self, s: str) -> int: vowels = {'a': 1, 'e': 2, 'i': 4, 'o': 8, 'u': 16} # seen: {010101 (a num that represent a combination of binary): last seen idx} seen, bit_count, result = ...
9bb3ff8db38e9b129d8a88ad7a66d3ab472a1c56
jordanst3wart/date-diff
/date-diff
935
4.40625
4
#!/usr/bin/env python3 """ Tells the difference between two dates """ import argparse from lib.date import Date def diff_dates(start_date, end_date): start = parse(start_date) end = parse(end_date) print("Day difference: " + str(end.diff(start))) def parse(date_string): value = date_string.split("-"...
7e7c6382efb3dfe1bb0ae5872f0e9355b7b5446b
q10242/pythone-practice
/ch6/ch6-3.py
679
3.578125
4
str = " DeepStone " print str print str.upper() print str.lower() print str.title() print "/"+str.lstrip()+"/" print "/"+str.rstrip()+"/" print "/"+str.strip()+"/" print dir(str) li = ['apple','banana','pineapple'] print li li += 'orange' print li li.append('orange') print li li.insert(3,'grape') print li li.pop(4) ...
533811a7e0cccbdf1e88ec4ac89467b58d65b4bb
charan2108/pyprocharmprojects
/pythoncrashcourse/AngelaPython/introduction/primitivetype.py
2,732
4.15625
4
print("Hello") print("Hello"[0]) print("Hello"[1]) print("Hello"[2]) print("Hello"[3]) print("Hello"[4]) # int print(123+456) 1234_4567_8910 # float 314.1456789 # boolean # true or false street_name = "Abbey Road" print(street_name[4] + street_name[7]) # typeconversion # num_char =input("Enter name") # print(len(num...
7bc1870a358a523a79f8c038457298f42711f895
heshuiming/hello-world
/day01/08-抽奖.py
1,500
3.84375
4
#做个抽奖程序,可以输入一个人的名字和抽奖号,然后随机抽取存在的抽奖号, #程序可以指定抽取次数,抽取后显示抽奖号和名字, #全部抽取完成后输出抽奖的总结果 #打印功能列表 print("抽奖系统") print("="*50) print("1、输入参与抽奖的名单") print("2、进行抽奖") print("3、查询中奖名单") print("4、退出系统") print("="*50) prize_list = [] #算法: while True: num = int(input("请输入功能编号:")) #1 能够死循环读入不同的名字和抽奖号,使用字典保存,在输入done的时候退出死循环。 if num ...
851c9aa4737f3b57fb43b8a2458119d3959b6fbb
QIAOZHIBAO0104/My-Leetcode-Records
/364. Nested List Weight Sum II.py
1,680
3.984375
4
''' https://leetcode.com/problems/nested-list-weight-sum-ii/ Given a nested list of integers, return the sum of all integers in the list weighted by their depth. Each element is either an integer, or a list -- whose elements may also be integers or other lists. Different from the previous question where weight is incre...
effb8d30ea7806f0fcdde73015f1700ac12558b1
microcephalus7/PS
/baekjoon/Python/practice 1/1.my.py
268
3.609375
4
# 나의 풀이 # 일일히 변수를 부름 # 각 변수를 list 에 넣고 변형한다는 풀이 a = int(input()) b = int(input()) c = int(input()) d = int(input()) e = int(input()) f = [a, b, c, d, e] for i in range: if(f[i] < 40): f[i] = 40 print(f)
584723dd0898140f7a23dd998cd5b93bfc80d892
Abhishek8093529403/python-in-summer
/7.10.py
740
4.21875
4
#!/usr/bin/python '''dream vacation''' nameq = "\nWhat's your name? " placeq = "If you could visit one place in the world, where would it be? " continueq = "\nWould you like to let someone else respond? (yes/no) " # Responses will be stored in the form {name: place}. responses = {} while True: # Ask the...
c08f720cab0dbb869ad01c226f42d261a9d6541e
mc-cabe/removeDupes1.0
/sorting.py
561
3.5625
4
planets = [ ("Mercury", 2440, 5.43, 0.395), ("Venus", 6052, 5.24, 0.723), ("Earth", 6378, 5.52, 1.000), ("Jupiter", 71492, 0.69, 9.551) ] size = lambda planet: planet[1] density = lambda planet: planet[2] planets.sort(key=density) print planets # [('Jupiter', 71492, 0.69, 9.551), ('Venus', 6052, 5.24, 0.723), # ('Me...
9e674613bfb1313d6e63142623957f6fa282f7b3
JuanMacias07x/30abril
/Ejercicio22.py
427
4.03125
4
#Programa que lea un número y determine si es positivo o negativo #Definir variables number = float(input("Ingrese un número = ")) print() #Proceso if number > 0: print("El número" + " " + str(number) + " " + "es positivo." + "\n") else: if number <0: print("El número" + " " + str(number) + " "...
fac92d19788f781853905a5ab5911fb4565ffa49
phlalx/algorithms
/misc/bst.py
2,080
3.8125
4
# TODO delete, pred, succ # # We need a handle for deletion of a specific node, and # access to parent pointer. Unless all keys are distinct # # # we need to compute the parent for pred/succ # see exercise "iterator for BST", compare solution where # we iterate using an iterative DFS, and the one where we compute # se...
8db053ed97d5d6139cd4c4ef2a29adad9df3d663
Loriern/python_test_game
/class_test.py
2,520
3.5
4
import turtle import math import random import time import sys class Grid: fwdSlashFlag = 0b100000 bckSlashFlag = 0b010000 horizFlag = 0b001000 vertiFlag = 0b000100 p2Flag = 0b000010 p1Flag = 0b000001 playerFlags = 0b11 def __init__(self, size=10): self.size=size ...
173eca8608245ee4da5a7229c1d995d9cb981079
rizkisadewa/pythoncrashcourse
/Part8/importing module/myclasses.py
338
3.5
4
# My first class class A: def __init__(self): pass def method(self): print("Method in class A") # My second class class B: def __init__(self): pass def method(self): print("Method in class B") # My Third class class C: def __init__(self): pass def method(self): print("M...
66b7b0e7bbee3894e713f1cd55006b18e1562a77
joshcv2112/TwitterIndexer
/index.py
2,535
3.546875
4
import csv import time from tweet import Tweet def print_tweet_list(tweets): for tweet in tweets: tweet.print_tweet() def objectify_tweets(file): tweet_list = [] with open(file) as csvfile: readCSV = csv.reader(csvfile, delimiter=',') for row in readCSV: tweet = Tweet(...
11012556caf5ea230bcd0cf2ac091490aac7a389
Silverkinzor/PythonCC
/PythonCC3-E4.py
10,269
4.09375
4
# List editor v. 1.1 # fixed bad programming habit (the while Trues and breaks) # Now to do it in all of my other programs -_- # You know, declaring all the variables helps reduce errors print('List Editor') print('Remember for position 0 = 1st, 1 = 2nd, etc and -1 = (current) last, -2 = 2nd last, etc also las...
a79feb7650412e0a0934c6dcc462ae2fb28923e6
cfchou/codeinpy
/src/MiniRotatedSortedArray.py
1,077
3.59375
4
__author__ = 'chifeng' # https://leetcode.com/problems/find-minimum-in-rotated-sorted-array/ #Suppose a sorted array is rotated at some pivot unknown to you beforehand. #(i.e., 0 1 2 4 5 6 7 might become 4 5 6 7 0 1 2). #Find the minimum element. #You may assume no duplicate exists in the array. class Solution: #...
2078914e0109b69c6498e1a9ac06a26a212f1e98
szwagiers/LearningTkinter
/tutorial/OtherWidgets.py
475
3.609375
4
from tkinter import * root=Tk() # text widget allows to put multiline text t=Text() #order of widgets is important. Widgets will show up in the same order as they are initialized with pack() method #e.pack() t.pack() #infinite loop used to run application, wait for an event to occur and process the event as long as ...
6080d8ba5d16079b600ac2bdcc393892380b730a
beng0/myworkspace
/test_re/re/re6.py
675
3.59375
4
""" iLmsux (?iLmsux) iLmsux的每个字符代表一个匹配模式,只能用在正则表达式的开头,可选多个 I re.I 忽略大小写 L re.L 使用预定字符类 \w \W \b \B \s \S 取决当前区域设定 m re.M 多行模式改变^ 和 $ 的行为 s re.S . 任意匹配模式 u re.U 使用预定字符类 \w \W \b \B \s \S \d \D 取决unicode定义的字符属性 x re.X 详细模式,可以多行,忽略空白字符,并且可以加入注释 """ import re p = re.compile(r"(?i)abc") print(p.findall("abc")) print(p.find...
23ddd95775972ef534b49559c2afccf6e9f2e58a
Hrckovak/Zoo
/mena.py
615
4.0625
4
class Parent: def __init__(self, name="Parent class"): self.name = name class Child1(Parent): def __init__(self, name): Parent.name = name class Child2(Parent): def __init__(self, name): Child2.name = name def vypis_potomkov(): print( f"Parent name: {Parent.name}\n" ...
2a1b2ce8b5c8061c04a53cf9508ba033e7a84fb1
Aasthaengg/IBMdataset
/Python_codes/p03657/s791332944.py
217
3.921875
4
# -*- coding: utf-8 -*- A,B = [int(i) for i in input().rstrip().split()] if (A%3) == 0: print("Possible") elif (B%3) == 0: print("Possible") elif ((A+B)%3) == 0: print("Possible") else: print("Impossible")
69800583d02077e8bc2c268fcc4190950535dded
cmorenoruiz/Curso_PHYTON_Junio_2018
/Bicicleta.py
731
3.796875
4
class Bicicleta: color = "roja" tamanio = "25" velMax=15 def __init__(self): self.velocidad = 0 def __str__(self): return "Color: "+str(self.color)+ ", Tamaño: "+str(self.tamanio)+", Velocidad actual: "+str(self.velocidad)+" y Velocidad Máxima: "+str(self.velMax) def subirMarcha...
d0f5221096d2e278b49318b861055be6548dba30
fedealdosivi/python-mini-projects
/cuentas/cuenta.py
1,656
3.796875
4
class cuenta: def __init__(self, cliente, numero,saldo=0): try: self.numero=int(numero) self.cliente=str(cliente) self.saldo=int(saldo) except Exception as e: raise e self.numero=numero self.cliente=cliente self.saldo=saldo def depositar(self,saldo): self....