blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string |
|---|---|---|---|---|---|---|
f186d8fcb18b323436fdf5b5d5d97e4789a53992 | GucciGerm/holbertonschool-higher_level_programming | /0x03-python-data_structures/10-divisible_by_2.py~ | 148 | 3.953125 | 4 | #!/usr/bin/python3
def divisible_by_2(my_list=[]):
for n in my_list[]:
if n & 2 == 0:
while n < 0:
print(n)
|
b2fb6650924701c078b68c743666cc0ba0bdc0f0 | concpetosfundamentalesprogramacionaa19/ejercicios-clases5-020519-davisalex22 | /miproyecto/run.py | 328 | 3.546875 | 4 | """
file: misvariables.py
autor: @David Salazar
"""
from misvariables import *
# Declaracion de variables e ingreso de valores
nota = input("Ingrese nota 1: ")
nota2 = input("Ingrese nota 2: ")
# Variable String a Int
nota = int(nota)
nota2 = int(nota2)
# CONDICIONALES
if nota >= 18:
print(mensaje)
if nota2 >= 18:
... |
69ca3d4707e153b6d242f45cf472e2b6384e0ea2 | vipulshah31120/PythonClassesByCM | /Homework/22-02-2021/iterate_practice.py | 975 | 4.15625 | 4 | list = ["I", "still", "have", "hope"]
itr1 = iter(list)
print(itr1.__next__()) # 1st syntax
print(next(itr1)) # 2nd syntax
print(itr1.__next__())
print(next(itr1))
str1 = "Salvatores"
itr2 = iter(str1) # iter() method which is used to get an iterator
print(next(itr2))
print(next(itr2))
print(next(itr2))
print(next(... |
982f29f0455d551dd8ae39907fd066cc0e8ece5a | yeebon/BMI-TAIWAN | /coding/BMI值設計.py | 1,095 | 4.25 | 4 | # BMI
print('BMI值計算:【 體重(kg) / 身高(m)的平方 】') #title
print('***請注意!體重請填公斤(kg)***') #subtitle weight
weight = input('請填體重(kg): ') #輸入體重
weight = float(weight)
print('***請注意!身高請填公分(cm)***') #subtitle height
height = input('請填身高(cm): ') #輸入身高
height = float(height)
h = height ** 2 / 100 ** 2
BMI = float #BMI值
BMI = weig... |
8786c4629157c808bf33b9e633252ea212d46990 | MarioRial22/tree | /pytree.py | 2,965 | 3.71875 | 4 | #!/usr/bin/python
# -*- coding: utf-8 -*-
import os
import sys
"""""
for dirpath, dirnames, filenames in os.walk('/home/mario'):
print ("Path: " + dirpath)
print ("DirNames: " + str(dirnames))
print ("FileNames: " + str(filenames))
"""""
"""""""""
def getPathDepth(absolute_path):
return len(absolute_... |
7aedc6a0a0799029b5276a9fe9a9f30341c44568 | bobheck/tut | /python_complete/SetsAndDictionaries/sets1.py | 2,729 | 4.3125 | 4 | # sets are unique and unordered
# two ways to create a set
# 1 braces
farm_animals = {"sheep", "cow", "hen"}
print(farm_animals)
for animal in farm_animals:
print(animal)
print("=" * 50)
# 2 pass a list to the set constructor
wild_animals = set(["lion", "tiger", "panther", "deer", "bison"])
print(wild_animals)
... |
3bffeeb45938e155a92e64edae2b69dd2d11ebdf | HeimerR/holbertonschool-machine_learning | /supervised_learning/0x08-deep_cnns/1-inception_network.py | 3,062 | 3.640625 | 4 | #!/usr/bin/env python3
""" Inception Network """
import tensorflow.keras as K
inception_block = __import__('0-inception_block').inception_block
def inception_network():
""" builds the inception network
The input data will have shape (224, 224, 3)
All convolutions inside and outside the inception b... |
50a535e50c3fb2819b659f9e367b0bf6971a5f18 | Abhid1239/Python_codes | /Python_Basics/triangle yeild imp??????.py | 674 | 3.8125 | 4 | def countd(i):
while i > 10:
yield i
i -= 1
for i in countd(11):
print(list(countd(i)))
#triangle value is created
def inf():
while True:
yield 0
#for m in inf():
# print(n)
def is_primes(num):
for i in range(2,num):
if num %i==0:
return False
return True
def get_primes():
... |
292abbe3764c71bb3ab10718bc46e670712d22b1 | subramaniam-kamaraj/codekata_full | /strings/sum_first_last.py | 205 | 3.765625 | 4 | '''
Given a number N, print the sum of first and last digit.
Input Size : |N| <= 1000000000000000
Sample Testcase :
INPUT
51233
OUTPUT
8
'''
n=input()
first=int(n[0])
second=int(n[-1])
print(first+second)
|
3b7a1341f6ee54f60abb513a3ea83ea4a59b04ae | locvx1234/Programming | /Lab Python/tieng_viet_k_dau.py | 664 | 3.765625 | 4 | #coding: utf-8
import string
import re
INTAB = "ạảãàáâậầấẩẫăắằặẳẵóòọõỏôộổỗồốơờớợởỡéèẻẹẽêếềệểễúùụủũưựữửừứíìịỉĩýỳỷỵỹđ"
INTAB = [ch.encode('utf8') for ch in unicode(INTAB, 'utf8')]
OUTTAB = "a"*17 + "o"*17 + "e"*11 + "u"*11 + "i"*5 + "y"*5 + "d"
r = re.compile("|".join(INTAB))
replaces_dict = dict(zip(INTA... |
0df8db5b94fee62176460cf99d29a209193350c6 | hoverzhao/Python | /SudokuSolver/SudokuSolver.py | 2,029 | 4.09375 | 4 | # Initial guide for basic logic https://www.youtube.com/watch?v=eqUwSA0xI-s&t=732s
import pygame
pygame.init()
import copy
import Screen
import Input
import Solve
def solveBoard(board): # Sets the Solve class's variables and solves the puzzle
Solve.Solving.setNumRows(... |
111115eac72aa791c2a8fb8bd3ac18d6f5b99861 | Burence1/password-locker | /credentials.py | 2,051 | 3.890625 | 4 | import random
import string
class Credentials:
'''
class that creates new instances of Credentials
'''
credentials_list =[]
def __init__(self, app_name, acc_username,acc_password):
'''
__init__ method helps create new instances of the Credentials class.
Args:
app_name: App... |
564f45e2ebd87a594870decaab0aaad32fbb7721 | ashwin-ganesh23/curriculum_dev | /peerbuds/py_for_professionals/day2/warmup_str.py | 827 | 3.84375 | 4 | """
Functional Programming in Python
Topics include:
-Warm-up Exercise
-Functions, Modules and Classes
-Intro to File Object
Part 1 : String Warm-up Exercises
"""
import string
# Write a Python program to store the character frequency of a string in a dictionary
def char_freq(s):
lc = {}
for char in s:
if l... |
31314f76f47961170610d8ecd363ce564bb16bf6 | zebehn/pandan | /pandan/pandan.py | 2,072 | 3.6875 | 4 | from collections import Counter
class Decision(object):
def __init__(self):
self.belief = None
self.certainty = None
class NumericPandan(object):
def __init__(self, decision_name, N):
self.N = N
self.decision_name = decision_name
self.evidences = []
# decision =... |
9a33a6872eb85835d68b91afccaced225a4aea1e | mridhosaputraad/DocumentationPython | /p15. more on list/latihan.py | 1,017 | 4.03125 | 4 | barang = ['kunci', 'ember', 'jaket', 'ban', 'mobil']
print(barang)
# Beberapa method yang bisa digunakan untuk memanipulasi list
# 1. append fungsinya menambah data ke dalam list
barang.append('sepeda')
print(barang)
# 2. extend fungsinya mengambil iterables dari string
# Pengantar:
# data = 'test' # string ini sif... |
ab4294a795d2ebd897c463c57ef0bc159a8abc6b | DagnyTagg2013/CTCI-Python | /DP/LongestCommonSequence.py | 4,725 | 3.640625 | 4 |
"""
PROBLEM:
GIVEN:
- 2 strings
FIND:
- length of longest common sequence
- actual common sequence
- order matters
- match in letter and occurrences
- letters don't need to be contiguous
EXAMPLE:
ABCDGH, AEDFHR => 3, ADH
AGGTAB, GXTXAYB => 4, GTAB
INFO: THIS IS BASIS for DIFF ALGO
- https://en.wikipedia.org/wik... |
a5453402d1c272b620a7fc67949e24c5f2d446f0 | diabolo-dan/danpy_extras | /danpy_extras/key_lock.py | 1,128 | 3.703125 | 4 | from threading import Lock
from contextlib import contextmanager
from collections import defaultdict
class KeyLock(object):
"""
A collection of Key-seperated Locks in the form of context_managers.
For use with dynamically created resources that are used for an extended period.
Use as:
keyed_lock = KeyLock()
... |
864271f4f7c54424f538543ba131dbe3964e4710 | arvindxyogesh/rock-papers-AND-SCISSORS | /rockpaperscissors.py | 892 | 4.28125 | 4 | import random
import time
playeroption=["rock","paper","scissors"]
while True:
computer=playeroption[random.randint(0,2)]
player=input("enter any one of the three rock,paper or scissors")
print(f'computer chose {computer}')
time.sleep(2)
if(player==computer):
print("tie")
elif(player=="r... |
6182463aea0845024942d137a04da6555b9498c7 | bmkrutgers/MyDaemon | /register.py | 2,384 | 3.546875 | 4 | import os
import sys
import smtplib
import pyAesCrypt
import random
import string
userdetails =[]
def key_generator(size=6, chars=string.ascii_uppercase + string.digits):
return ''.join(random.choice(chars) for _ in range(size))
def registration():
print("welome to registration")
loop = 'true'
while(... |
5766ee180e6c2078736d9d6b19dd2a9861e88074 | AndriyPolukhin/Python | /learn/ex01/milescinverter.py | 639 | 4.40625 | 4 | # !important List all the things that need to happen to solve a problem!
# Problem : Receive miles and convert to kilometers
# kilometers = miles * 1.60934
# Enter Miles 5
# 5 miles equals 8.04 kilometers
miles = input('Enter amount of miles to convert ')
miles = float(miles)
print("Miles entered: {}".format(miles))... |
1fc005b7b983245c4539ab52c354e2cfcbb17712 | rrabit42/Python-Programming | /Python프로그래밍및실습/ch11-list&file&dic&exception handling/lab11-1.py | 243 | 3.5625 | 4 | import random
n1 = int (input("난수의 범위1 : "))
n2 = int (input("난수의 범위2 : "))
n = int (input("난수의 개수 : "))
R = [0 for i in range (n)]
for i in range (len(R)) :
R[i] = random.randint(n1, n2)
print(R)
|
6ad2bd9792427f237d0e3a102a49a88fbf890e4a | jonnysassoon/Projects | /DataStructuresAndAlgorithms/DataStructures/DoublyLinkedList.py | 5,344 | 3.53125 | 4 | """
Author: Jonny Sassoon
Program: DoublyLinkedList
Implementation of DoublyLinkedList Data Type including additional, non-trivial methods (sorting, reversing, removing)
"""
class Empty(Exception):
pass
class DoublyLinkedList:
class Node:
def __init__(self, data=None, prev=None, next=None):
... |
d0fe66c441ce38333bed7026d3f0f558584875ba | sudheermeka/Unscramble-Computer-Science-Problems | /Task4.py | 1,141 | 4.3125 | 4 | """
Read file into texts and calls.
It's ok if you don't understand how to read files.
"""
import csv
with open('texts.csv', 'r') as f:
reader = csv.reader(f)
texts = list(reader)
with open('calls.csv', 'r') as f:
reader = csv.reader(f)
calls = list(reader)
marketing_numbers = set()
non_marketing_numb... |
5008086d71b96a1f2fb6808cd426b74f360d800a | kenreitz27/mini_projects | /src/rolldice.py | 967 | 3.859375 | 4 | from random import randint
from src.utils import clear_screen, good_integer_between
def get_sides():
good_input = False
while good_input == False:
sides = input('How many sided dice? (2-99) :')
good_input = good_integer_between(2, 99, sides)
return sides
def roll(sides):
return str(... |
bf08b7f23580e6c61efd9af6fd5a2dea0dc678dd | Akagilnc/everyone-can-code | /Vita112/homework_201805/sq_cal.py | 536 | 3.5625 | 4 |
# 定义一个计算待求数g的平方根x的函数
def sq_cal(g):
# 规定开方根的精度,x的初始值,确定待求值的获取范围
s, n, x = 0.01, 1, 1
low, high = 0, g
# 设置函数出口
while abs(x**2 - g) >= s:
x = (low + high) / 2
# 使用二分搜索算法,规定g的开方根在精度外时的计算方法
if x**2 > g:
high = x
else:
low = x
print(x, n)
... |
9a23a5bdadffb4c3aa26ef4f0ed07295a1015df1 | Nordenbox/Nordenbox_Python_Fundmental | /MagicSquare.py | 2,078 | 3.6875 | 4 | ''' 这是我写的一个三阶幻方的生成方法,完全用暴力的办法随机计算,
虽然效率极其低下,但是原理极其简单,不需要设计算法。完全依靠
CPU暴力生成数字,一个一个去实验。
'''
import random
import time
loops = 0
a = True
time_start = time.time()
while a: # 定义三阶幻方的每一个方格里的数字是 1-9 的随机整数。
x1, x2, x3, y1, y2, y3, z1, z2, z3 = (
random.randint(1, 9),
random.randint(1, 9),
... |
c33d8a3fef942b3e0b3d9778928bb301f26794b4 | vladkudiurov89/Test_book | /test_algorithms/quick_sort.py | 626 | 3.609375 | 4 | import numpy as np
from time import sleep
def quick_sort(arr):
if len(arr) < 2:
return arr
else:
pi_arr = arr[0]
less = [i for i in arr[1:] if i <= pi_arr]
great = [i for i in arr[1:] if i > pi_arr]
return quick_sort(less) + [pi_arr] + quick_sort(great)
zz =... |
bddac420b6f84d431efc615e6bf9b59a9b2c4db7 | mikekhalil/LeetCode | /LongestPalindrome.py | 566 | 3.765625 | 4 | #naive solution - find a better one (TLE)
class Solution(object):
def isPalindrome(self,string):
return string == string[::-1]
def longestPalindrome(self, string):
#find the longest palindrome within a string
i, j, pal = 0, 0, string[0]
while i < len(string):
j = i +... |
9cac23cf0b2bc7cdb7752849eec0fde00a34738d | drejleeo/workbench | /algebrae/permutations.py | 938 | 3.75 | 4 | """draft file - workbench, ideas"""
def permute(list, s):
if list == 1:
return s
else:
return [
f'{x} * {y}'
for x in permute(1, s)
for y in permute(list - 1, s)
if eval(f'{x} * {y}') == 72
]
def permutation(list, start, end):
'''... |
af7b90f2736b61828fda74315b43bfd0bc42b677 | rotem20-meet/allthelabs | /lab2ex3.py | 119 | 3.515625 | 4 | a=[12,23,34,45]
b=[12,111,223,23]
c=[]
for i in a:
for t in b:
if i==t:
c.append(i)
print(c)
|
63ab4c664e6390740bcf440088b411351a2e1e9a | jixinfeng/leetcode-soln | /python/322_coin_change.py | 2,300 | 3.84375 | 4 | """
You are given coins of different denominations and a total amount of money
amount. Write a function to compute the fewest number of coins that you need to
make up that amount. If that amount of money cannot be made up by any
combination of the coins, return -1.
Example 1:
coins = [1, 2, 5], amount = 11
ret... |
a228de4b5bce91eb827a535116a47b8b59ca7a60 | odys-z/hello | /challenge/leet/medium/q959.py | 4,054 | 3.90625 | 4 | '''
959. Regions Cut By Slashes
https://leetcode.com/problems/regions-cut-by-slashes/
In a N x N grid composed of 1 x 1 squares, each 1 x 1 square consists of a /, \, or blank space.
These characters divide the square into contiguous regions.
(Note that backslash characters are escaped, so a \ is represented as "\\... |
62212178ed091661be34fd2eb903dfcbfb2c991f | Pratt91/IntoToNetworks | /networkstype.py | 8,690 | 3.734375 | 4 | """
-A simple link simulator that emulates the transmission of packets from a
-sender A to a receiver B.
-
-"""
from collections import deque
received_packets = []
received_packets_atC = []
received_packets_atD = []
class Packet:
"""
This stores the information associated with a packet
"""
... |
ad3d399024d2759fca41939da5b8b7bee6e0d2cb | mbmcmullen27/foobar | /lvl4/task1/simple_symmetry.py | 2,208 | 3.546875 | 4 | def matchlist(challenger,bananas):
memo=dict()
def wrestle(a,b):
x=a
y=b
history=set()
while x!=y:
if x > y:
history.add((x,y))
if memo.get((x,y)) or (x-y,y*2) in history:
return history
x... |
914246a52b7e0ed918f3a6ce82228556d87fc3f7 | IAmFiveHigh/learnPython | /Algorithm/day1.py | 458 | 3.859375 | 4 | """
created by IAmFiveHigh on 2019-02-19
"""
# Hailstone
def hailstone(a, l=[]):
l.append(a)
if a <= 1:
return l
elif a % 2 == 1:
l = hailstone(3 * a + 1, l)
else:
l = hailstone(a / 2, l)
return l
# 冰雹序列
print("冰雹序列 输入42")
l1 = hailstone(42)
print(l1, '\n')
print("冰雹序列... |
bd9eba510d43cf4915912eb0a6e1c9be23cd4db3 | jaecheolkim99/CodingPlayground | /LeetCode/Rotate Array.py | 687 | 3.859375 | 4 | """
https://leetcode.com/explore/challenge/card/october-leetcoding-challenge/561/week-3-october-15th-october-21st/3496/
Given an array, rotate the array to the right by k steps, where k is non-negative.
Follow up:
Try to come up as many solutions as you can, there are at least 3 different ways to solve this problem.... |
4d6f1d909d5b178666fd28059126f8e16feba088 | syasky/python | /day06/03_变量的作用域.py | 776 | 3.75 | 4 | '''
# 全局变量
s=100
def funcA():
# 局部变量
a=1
print(a)
print(s)
funcA()
# print(a) 报错
'''
s=100
def funcB():
a=2
print(a)
s=300
print(s)
funcB()
print(s)
print('----------------------------')
'''
s = 200
def funcB():
a = 2
print(a)
# print(s) 不能... |
7e9679fd3afd8b37a9733b9271bbde282cca0515 | enjoy2000/discord-pokemon-go-snipe-bot | /test.py | 356 | 3.6875 | 4 | # Test script to get pokemon names regex
import json
with open('data/pokemons.json') as data:
pokemons = json.load(data)
regex = ''
for index, pokemon in enumerate(pokemons):
regex += pokemon.get('Name', 'NA')
regex += '|'
regex += pokemon.get('Name', 'NA').lower()
if index + 1 != len(pokemons):
... |
299d8fce9660a61159899fad8ae62d813844f8cb | hergin/AdventOfCode2020 | /day11/day11-part1.py | 3,215 | 3.5 | 4 | import os, sys, copy
def createGrid():
grid = []
for line in open(os.path.join(sys.path[0], "input11.txt")):
grid.append(list(line.strip()))
return grid
def printGrid(aGrid):
for i in range(0,len(aGrid)):
for j in range(0,len(aGrid[i])):
print(aGrid[i][j],end='')
pr... |
d7f8996ea9b9b7c964d3e36868ca5d9b2b818155 | nikhi76/python-programs | /program3.py | 117 | 3.578125 | 4 | lst=[1,1,2,3,4,64,35,93,35,87,4,3]
unique=[]
for i in lst:
if i not in unique:
unique.append(i)
print(unique) |
d093ca44fd8d420eb8256e65a2c42c44130e105c | nshekhawat/PythonClass | /Questions-Unit2/Question2-Unit2.py | 343 | 4.28125 | 4 | #!/usr/bin/env python
# Author: Narendra
__doc__ = '''Wap to find the max of the three numbers ?'''
num1 = int(raw_input("Enter first no.:"))
num2 = int(raw_input("Enter second no.:"))
if num1 > num2:
print "{} is maximum".format(num1)
elif num1 == num2:
print "Both numbers are equal."
else:
print "{} is... |
5ce18c10e84f88c34ddbfa184cddfd2f57d7e8ac | valeriacavalcanti/ALP-2020-R | /Bimestre_02_Aula_04/aula/exemplo4.py | 227 | 3.640625 | 4 | # ler 4 números. exibir a quantidade de valores "positivo (acima de zero)"
qtde = 0
for i in range(4):
numero = int(input(f"Informe o {i + 1} valor: "))
if (numero > 0):
qtde += 1
print("Quantidade =", qtde)
|
f36ab204f94fde215aa72908636fb7955cd052f8 | vxela/altera-batch5- | /Prabootcamp/CHALLENGE/sumprime.py | 67 | 3.828125 | 4 | num = int(input("your num : "))
r = num ** 0.5
print (int(r)) |
e1823bb1d84e37e482e682180ab1134f599b4a35 | Ruh-Marcondes/LearnPython | /Basico/Exercicio/M2/e4.py | 958 | 3.546875 | 4 | '''
solcita salário e calcula INSS(11%)
calcula contribuição,
tabela || salário < 800 = 2% (contribuição sindical)
salário >= 800 && <= 1500 3% (contribuição sindical)
salário > 1500 5% (contribuição sindical)
mostrar - sal bruto, sál liquido, valor pago de inss
e valor pago de contribuição sindical
variáveis
... |
c6bd47d397c4ef8d44342e0990c89d6d282aeb99 | ww35133634/chenxusheng | /ITcoach/sixstar/基础班代码/3_while循环/lx_03_数据类型的转换.py | 1,067 | 4.21875 | 4 | """
演示数据类型的转换
"""
# 使用input得到的数据,,不管是什么,,都是默认带上了引号,是字符串,,,
# 想要通过输入去得到两个数字,然后进行求和
# 5+6 = 11
# num1 = input('请输入第一个数字:')
# num2 = input('请输入第二个数字:')
# print(type(num1+num2))
# 数据类型的转换 str >>> int 5 + 6 = 11
# int(num1) # str >>> int 使用int函数将其包裹起来
# num1 = int(input('请输入第一个数字:')) # int(str)
# num2 = int(in... |
6dd3dde901f7317a608332f6da3a369c2eaedad9 | wesjones15/dice | /dice_v5_2_pyg.py | 15,181 | 3.71875 | 4 | #need 10000pts to win
#you can keep rolling for as long as you are getting pts
#you must score at least 1000pts in a turn in order to start recording your score
#if you roll again and wouldn't gain any more points, you lose all points from that turn
#move scoreKeeper section to outside of reRoll if statement
... |
5e477becdce264301ed71a6ababec8d749cd04f0 | gatdotZF/qianfeng_py | /ZF_TEST/dict_test2_查询.py | 455 | 3.921875 | 4 | #! /usr/bin/env python
#coding=GB18030
'''
ѯԪأ
list1[index]--->element
dict1[key]--->value
'''
list1=[3,5,7,8]
print(list1[2]) #бвԪظ±ѯ
dict1={'0':'','1':'','2':''}
print(dict1['2'])
'''
ѯԳɼ90ֵ
'''
dict2={'':100,'':89,'oye':90,'lili':85}
for i in dict2.items():
print(i)
for key,value in dict2.items():
... |
7d2e074fa243084d95d6f3212bf988fdd4bba352 | 3desinc/YantraBot | /oldFiles/testcontrol.py | 295 | 3.578125 | 4 | from rrb3 import *
from time import sleep
rr = RRB3(9,6)
while True:
user = (input("input direction"))
if(user == 'w'):
rr.forward(0.5)
elif(user == 'a'):
rr.left(.55)
elif(user == 'd'):
rr.right(.55)
elif(user == 's'):
rr.reverse(0.5)
|
03af0a309f485ea53ec23399625c10958cc4990d | emithongle/AD---20160427 | /20160427 - 001/libs/utils.py | 3,324 | 3.5 | 4 | import string
def findMaxStringP(text, type, skip=0, skip_chars=''):
i, nskip = 0, 0
while (i < len(text) and nskip <= skip):
if (type == 'ascii'):
if (text[i] not in skip_chars):
if (text[i] in string.digits + string.punctuation):
nskip += 1
... |
7b770757da86347c09672398583f6e3d2e1d2b81 | rafaelperazzo/programacao-web | /moodledata/vpl_data/3/usersdata/61/454/submittedfiles/ex2.py | 167 | 4.03125 | 4 | # -*- coding: utf-8 -*-
from __future__ import division
a=input('digite um valor: ')
x=a**2
y=a**0.5
if a>=0:
print('%.2f' %y)
else a<0:
print('%.2f' %x)
|
5dac195364050faa6ff9f3058040e713d8fd3694 | josevini/python | /Introdução à Programação/capitulo6/ex_6-12.py | 187 | 3.921875 | 4 | # Exercício 6.12 - Livro
numeros = [2, 6, 8, 4, 1, 20, -26]
menor = numeros[0]
for num in numeros:
if num < menor:
menor = num
print('=-=' * 10)
print(f'Menor → {menor}')
|
bbf7c9cff5ec3dd0ee5501e07f9dd9728072f997 | ushastikin/command-line_scripts | /command-line_script_template.py | 873 | 3.828125 | 4 | #!/usr/bin/python
# This script is based on example from
# https://docs.python.org/2/library/argparse.html#module-argparse (which uses a little bit
# advanced argparse options).
# Pay attention that this example has already functionality.
import argparse
parser = argparse.ArgumentParser(description='Process some int... |
fa2ce7f78535afbc1072034c602413ea8a1786ac | Cc-bugwriter/CV | /assignment2/problem2.py | 7,479 | 3.703125 | 4 | import numpy as np
import os
from PIL import Image
def load_faces(path, ext=".pgm"):
"""Load faces into an array (N, H, W),
where N is the number of face images and
H, W are height and width of the images.
Hint: os.walk() supports recursive listing of files
and directories in a path
... |
6ea0f4f1dfbdc6c93a02ae1129af6f6337069cab | ZBr14n/Algorithms-Data-Structures-in-Python | /Python exercise/CountDiv.py | 323 | 3.84375 | 4 | # -*- coding: utf-8 -*-
"""
Created on Sat Jun 1 19:42:58 2019
@author: Brian
[6,11]
6%6==0
7%6
8%6
"""
def CountDiv(A,B,K):
count=0
while A <= B:
if A%K==0:
#print(A)
count+=1
A+=1
print(count)
CountDiv(6,11... |
918c81dd1f0cb86aade0e728758a24a775596deb | cvann/csf | /hw2.py | 2,467 | 4.15625 | 4 | # Name: ...Choya Vann
# Evergreen Login: ...vancho06
# Computer Science Foundations
# Programming as a Way of Life
# Homework 2
# You may do your work by editing this file, or by typing code at the
# command line and copying it into the appropriate part of this file when
# you are done. When you are done, running ... |
390c3090635d07e6a4fc4d6b7ade8ba7b4174e00 | junho5/python | /test/test14.py | 314 | 3.546875 | 4 | # 자리수 합 리턴
def sum_digit(num):
result = 0
num = str(num)
for i in range(len(num)):
result += int(num[i])
return result
# sum_digit(1)부터 sum_digit(1000)까지의 합 구하기
digit = 1
total = 0
while digit<=1000:
total += sum_digit(digit)
# 코드를 입력하세요. |
3c10945214f1697897f9e451f78cf743a8b08b32 | dgquintero/holbertonschool-higher_level_programming | /0x01-python-if_else_loops_functions/8-uppercase.py~ | 210 | 4.15625 | 4 | #!/usr/bin/python3
def uppercase(str):
for tmp in str:
if ord(tmp) >= ord('a') and ord(tmp) <= ord('z'):
tmp = chr(ord(tmp) - 32)
print("{:s}".format(tmp), end="")
print("")
|
57c53645301a0d6578d8ec918601833f4b777dba | r0ckburn/d_r0ck | /The Modern Python 3 Bootcamp/4 - Boolean and Conditional Logic/is_versus_double_equals.py | 505 | 4.15625 | 4 | # in python, == and is are very similar comparators, but they are not the same
a = 1
a == 1 # True
a is 1 # True
# in the following example using lists
# == checks the values to see if they are the same
# is checks if a and b are stored in the same place in memory
a = [1, 2, 3] # a list of numbers
b = [1,... |
e5e924bc1eb8f38184b0102e1777d6a7403a95e3 | Zhcong92/test | /code/test1.py | 91 | 3.75 | 4 | print("hello world")
print("hello python")
a = [1, 2, 3]
for i in a:
print(i)
print(a)
|
b3e7dab2e5039ed25913b9adaef5287e0e415957 | SteveKimSR/baekjoon | /python/p11720.py | 90 | 3.53125 | 4 | n = int(input())
s = input()
total = 0
for i in s:
total += int(i)
print(total)
|
4633c142b34b89ad1ebb9957df11518440c5c6f0 | MillionaireChen/Optimization_Algorithms | /SVP_CVP/SVP.py | 847 | 3.796875 | 4 | import numpy as np
import sympy as sym
a = np.array([2, 1])
b = np.array([3, 2])
m = sym.Symbol('m')
l = sym.Symbol('l')
L = m*a + l*b
print("Vectors belonging in the grid have the following form: L =", L)
print("(Brute Force) Starting calculations to solve the SVP for L...")
print("")
m, l = -10, -10
shortest_vect... |
fe5a3f4b3921c1a9a072df47a1f25bd3c7f53c81 | 1026237416/Python | /python_test/class_test2.py | 321 | 3.8125 | 4 | class A:
def __init__(self):
self.__ab = 0
def info(self):
print(self.__ab)
a = A()
a.info()
a.__ab = 3
a.info()
print(a.__ab)
class B:
def __init__(self):
self._ab = 0
def info(self):
print(self._ab)
b = B()
b.info()
b._ab = 3
b.info()
print(b._ab... |
69b136e2e0b9f3d13b6cb946b48a76d72c31a9c6 | merveeMalak/260201043 | /lab4/example5.py | 109 | 3.890625 | 4 | n = int(input("Enter a number: "))
result = 1
for i in range(n,1,-1):
result *= i
print(f"{n}! = {result}") |
c258fc042333c522d35f7dbb7047d7711c71e87f | Aasthaengg/IBMdataset | /Python_codes/p02397/s294570283.py | 169 | 3.625 | 4 | while True:
x,y=map(int,input().split())
if x==0 and y==0:
break
if x<y:
print(str(x)+" "+str(y))
else:
print(str(y)+" "+str(x))
|
afb608f8001438ed8b87a3900c652e64fc27c8b6 | MadPUG/Introduction-To-Python | /lesson_002/lists.py | 3,677 | 4.625 | 5 | from __future__ import print_function # Ignore this line until next month
# Section 5 of Lesson 2
# The following are lists
['here', 'is', 'a', 'list', 'of', 'strings']
['one element list']
[] # Empty list
# Unlike strings and tuples, lists *are* mutable.
fibonacci = [1, 1, 2, 3, 5, 8, 13, 21, 34]
print('Before:', ... |
6b339436a00b041729ffecc8cb545de7852f6529 | MatheusCoutoDeveloper/Aleatoriedades | /Algoritimos/Exercicio1.py | 354 | 3.8125 | 4 | a = float (input("Digite o valor de a= "))
b = float (input("Digite o valor de b= "))
c = float (input("Digite o valor de c= "))
delta - b**2-4*a*c
print("O valor de delta: ",delta)
raizdedelta=delta**0.5
print(" raiz de delta: ", raizdodelta)
x1=(-b+raizdodelta)/(2*a)
print(" x1; ", x1)
x2=(-b-raizd... |
84dd4050a3c84e2826dbeb3702c7860b8265a9f5 | magmine/Exercism | /python/matrix/matrix.py | 833 | 3.5 | 4 | class Matrix:
def __init__(self, matrix_string : str):
self.rows = []
self.cols = []
rows_string = matrix_string.split("\n")
self.get_rows_from_string(rows_string)
self.get_columns_from_rows()
def row(self, index : int) -> []:
return self.rows[index - 1]
d... |
e35c0b9d0dce64fcfba0c851eea0902158212d72 | roy-marquez/_IntroProg | /s07/T01_sets/sets_intersection.py | 1,454 | 4.34375 | 4 | """ Programa en Python que cree un set con los números compuestos del 1 al 100
y un set con los números impares del 1 al 100.
Usando esos dos sets, cree un tercer set (comp_even) con los números compuestos pares.
Luego pregunte al usuario un número y búsque este número entre el set (comp_even).
"""
compos... |
223ead68899f4622b0d22321ef405b45d9514fe0 | hengstchon/leetcode | /python/20_valid_parentheses.py | 799 | 3.84375 | 4 | # regular stack
class Solution1:
def isValid(self, s: str) -> bool:
pairs = {"(": ")", "{": "}", "[": "]"}
stack = []
for i in s:
if i in pairs:
stack.append(i)
elif stack and i == pairs[stack[-1]]:
stack.pop()
else:
... |
fe05cab40de57a35592c9273d23dd67e9f06a4ba | nicholasrokosz/python-crash-course | /Ch. 5/hello_admin.py | 221 | 3.9375 | 4 | users = ['admin', 'Nick', 'Nicole', 'Al', 'Pete', 'Michaela']
for user in users:
if user == 'admin':
print("Hello admin, would you like to see a status report?")
else:
print(f"Hello {user}, thanks for logging in.") |
3d21f9d3b9af32d276a02ea32c55dcd6c3398e0b | aHishamm/CodewarsKataSolutions | /7 Kyu/SquareEveryDigit/squareEveryDigit.py | 242 | 3.734375 | 4 | def square_digits(num):
squaredig = ''
numString = list(str(num))
for i in range(len(numString)):
numString[i] = str(int(numString[i]) ** 2)
numString = int("".join(numString))
return numString
|
929f83550b3d5b7b8e3c2faf4702c0cdf2914037 | kruthar/hackerrank | /algorithms/warmup/plus_minus.py | 509 | 3.703125 | 4 | import sys
def pad(decimal):
decimals = len(str(decimal).split('.', 2)[1])
return str(decimal) + '0' * (6 - decimals)
count = float(sys.stdin.next().strip())
numbers = sys.stdin.next().strip()
positive = 0
negative = 0
zero = 0
for number in numbers.split(" "):
if int(number) > 0:
positive += 1... |
36e8c48cdeb112804d2ec02f1f58054ed4127c21 | kabrick/jetbrains-hyperskill-coffee-machine | /app.py | 3,314 | 4.15625 | 4 | gl_money = 550
gl_water = 400
gl_milk = 540
gl_beans = 120
gl_disposable = 9
def how_many():
print()
print("The coffee machine has:")
print(gl_water, "of water")
print(gl_milk, "of milk")
print(gl_beans, "of coffee beans")
print(gl_disposable, "of disposable cups")
print("$" + str(gl_money... |
38eec38e3e41423320e4f6b94d1fcfbb49b6dcd6 | 2001128/p1805 | /07day/1-求闰年还是平年.py | 459 | 3.625 | 4 | '''
year=int(input("请输入年:"))
if year % 4 == 0 and year % 100 != 0:
print("闰年")
elif year % 400 == 0:
print("闰年")
else:
print("平年")
'''
'''
year=int(input("请输入有多少天:"))
if year %4 ==0 and year % 100!=0:
print("闰年")
elif year %400 ==0:
print("闰年")
else:
print("平年")
'''
i = 1
while i<10:
... |
17c02a707ff5c30718a19d2ba64738d7b7f823e0 | jpcifuentes16/Regex-Engine | /Entrega final/Directo.py | 7,277 | 3.5625 | 4 | from Nodo import Node
import NodoDirecto as nd
import Grafo as g
"""
Script con funciones utiles para el algoritmo
directo
Variable
----------
contador : int
se usa como id para las hojas
operadores : list
Operadores aceptados por el programa
numeros : list
Contiene todos los simbolos aceptados por
e... |
f8f10ebce1100b7ba21b3d9a5f68e2830b2e6662 | AP-Atul/wavelets-ext | /wavelet/compression/compressor_peak.py | 2,026 | 4.03125 | 4 | """ Compression using the difference of the max & min data in the signal """
import numpy as np
from .compressor import Compressor
class CompressorPeak:
"""
The magnitude calculated will be used to threshold the data signal, the
output generated would be the compressed signal with zeros that was threhol... |
5286ac905498bea736e6701667ee321140084c6d | YoussefMohamed1311999/hello-kayel | /kayles game v 2.0.py | 2,074 | 3.890625 | 4 | print ("each player chooses 1 or 2 numbers from the list on condition that they are adjacent. when there are no adjacent numbers players will enter 1 number. the player to remove the last number wins the game.")
z=1
p=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20]
while z==1:
print(p)
print('player 1 tur... |
ed2856a0fff22445bed8cd0cd6eece38b1ecd3d1 | Aasthaengg/IBMdataset | /Python_codes/p02899/s479991048.py | 247 | 3.546875 | 4 | N = int(input())
A = list(map(int, input().split()))
dic = {i:0 for i in range(1, N + 1)}
for i in range(N):
a = A[i]
dic[a] = i + 1
for i in range(1, N + 1):
print(dic[i], end="")
if i != N:
print(" ", end="")
print() |
1c480469287cbd16658b0ce7ea4ba700b83c3a91 | iikkapietila/Step-counter | /main.py | 26,298 | 4.28125 | 4 | """
Welcome to the step counter 2.0. This is an application made by Iikka Pietilä
for a basic programming course at TUT.
Assignment: Kierros 13 (t. 13.10 Graafisen käyttöliittymän suunnitteleminen
ja toteuttaminen)
Goals: "To design a program with a graphic user interface and execute it with
... |
7dc41ebda94b0eeb27985a1b0e39cd292008ec7c | qetennyson/functions_ex | /more_adv_functions.py | 884 | 4.125 | 4 | def make_sandwich(*items):
"""Print a summary of the sandwich being made"""
print("\nMaking a sandwich with the following: ")
for item in items:
print("- " + item)
make_sandwich('turkey', 'cheese', 'mayonnaise', 'lettuce', 'tomato', 'hot pepper')
make_sandwich('ham', 'cheese')
make_sandwich('roast... |
823e1cd7655991086d9621ed7c0211e55440f210 | umark7/BetaProject | /filterer_python_functions.py | 5,282 | 3.5 | 4 | import pandas as pd
import matplotlib.pyplot as plt
get_ipython().run_line_magic('matplotlib', 'inline')
plt.style.use('ggplot')
import seaborn as sns
import textwrap
#this is just to specify which columns to use. Its kinda wordy but gets the job done
cols = []
for i in range(9,129):
cols.append(i)
#F... |
44b61d149ec35270419f2424b6171dd88bda60fe | alvesvaren/AoC-2020 | /13.py | 720 | 3.609375 | 4 | import aoc
from sympy.ntheory.modular import crt
arrival, schedule = aoc.get_input(13).splitlines()
busses = schedule.split(",")
arrival = int(arrival)
minimum_bus = ()
for bus in busses:
if bus == "x":
continue
bus = int(bus)
first_bus_after_arrival = max(range(bus, arrival+bus, bus))
if not... |
57a0ff8e6c43ebd01addc8f50b6432a848016fc9 | zooee/PyDevtest1 | /PythonFirst/funcfirst.py | 2,042 | 3.96875 | 4 | #encoding:utf-8
'''
Created on 2016年3月22日
@author: Administrator
'''
import math
#移动xy坐标函数
def move(x, y, step, angle = 0):
nx = x + step * math.cos(angle)
ny = y - step * math.sin(angle)
return nx, ny
#求x的n次方函数
def power(x, n = 2):
s = 1
while n > 0:
n = n-1
s = s ... |
ea6b5f7e90939ee120e24683a075d09b9f1fdd0f | QtTao/daily_leetcode | /75.颜色分类/solution.py | 3,432 | 3.640625 | 4 | # !/usr/bin/python
# -*- coding: utf-8 -*-
# author : Tao Qitian
# email : taoqt@mail2.sysu.edu.cn
# datetime : 2021/4/26 21:42
# filename : solution.py
# description : LC 75 颜色分类
class Solution:
def sortColors(self, nums: List[int]) -> None:
""" 双指针(头尾) """
# 初始头尾指针
left... |
70b5791fc9e00c1693e2af18cca3f3fc59e01be2 | darrylpinto/Video_Processing_DataBank | /registration_server.py | 3,273 | 3.703125 | 4 | import pickle
import socket
def main():
"""
main function that reads the toplogy of all the nodes int the system.
once topology is read, it sends the information about the neighbors, their IP address, number of incomig an
outgoing edge information to each node as it connects to the registration server... |
056e16b6521cfae6f09dadd255bf6d09fb30886c | jleine02/Python_Workout | /login_system.py | 828 | 3.96875 | 4 | # usr/bin/env python3
"""Simulate a simple login system using a dictionary."""
def main():
"""Run program from the command line."""
login_to_system()
def login_to_system():
"""User prompted for username and password and denied access if either is incorrect."""
login_info = {"jake": "s3cret", "rachel... |
702b92fe701f681f82e4231e8c2e315f5ce1295c | EvanBialo/Xerus2 | /misc.py | 744 | 3.953125 | 4 | from lexicon import WORDS
import matcher
def alphagrammize(word):
return ''.join(sorted(word))
def alphagrammize_list(l):
alphagrams = []
for i in l:
if alphagrammize(i) not in alphagrams:
alphagrams.append(alphagrammize(i))
return alphagrams
def search(*matchers, words=WORDS)... |
1e3c2dbeacf0a15c85759d97bdb607cdff1accfd | JasminSantana/Patterns-Design | /Patterns/factory.py | 668 | 3.828125 | 4 | """"Author: Santana Mares Jasmin
gmail: sant.mar.1997@gmail.com
date: 11/11/2017 """
'''Hace uso de una clase que crea objetos con comportamientos similares'''
class Dog:
""""A single dog class"""
def __init__(self, name):
self._name = name
def speak(self):
return "W... |
5903cf535b804259ef3a8c7902d5e418d641e513 | arcaputo3/algorithms | /algos_and_data_structures/clustering_attempt.py | 2,130 | 3.5625 | 4 | class Node:
def __init__(self):
self.parent = None
class UnionFind(object):
def __init__(self):
#To hold the clusters
self.clusters = []
#create a new set(cluster) with a node
def makeSet(self, node):
#set the nodes parent to the node itself
node.parent = node
#set initial rank of node to 0
node.ra... |
ecc050d9ee7abfcef96c7203a4265dc3a3fe5e57 | Hammurabi1750BC/leetcode | /1452.py | 962 | 3.71875 | 4 | # 1452. People Whose List of Favorite Companies Is Not a Subset of Another List
class Solution:
def peopleIndexes(self, favoriteCompanies: List[List[str]]) -> List[int]:
orig_fc = [x for x in favoriteCompanies]
favoriteCompanies.sort(key = lambda x: len(x), reverse=True)
not_sub = [... |
35c1fb612bdef513a6c987f3b1653f02cc002d05 | lighted-zsz/python-code-learning | /对象方法.py | 836 | 3.671875 | 4 | class fun:
# self.属性名1 = 形参1
# self.属性名2 = 形参2
#只要有某个self.属性名 = 形参的定义,那么就可以使用这形参,传形参
def __init__(self):
pass
def first(self,name,age): #其中name,age是共有的属性参数
self.name = name
self.age = age
def qulification(self):
print("{}今年{}岁".format(self.name,self.age... |
911e847a330a193ba4cb9192fcd1a45faf88f0c8 | AdamZhouSE/pythonHomework | /Code/CodeRecords/2361/60640/278622.py | 1,658 | 3.984375 | 4 | """
读入数组
全排列,判断每个数组是否符合相邻元素之和为完全平方数
"""
import math
from copy import deepcopy
def isduplicate(li, n, t):
"""
从li的位置n到位置t-1,有没有和li[t]相等的数字
"""
while n < t:
if li[n] == li[t]:
return True
n += 1
return False
def swap(li, i, j):
if i == j:
return
temp = l... |
1306ac5eac512d3b6f3330e7a1c5a32347011268 | sofiasackett/Basic-Python | /trainTickets.py | 1,115 | 4.0625 | 4 | #use a loop so that the program will return to the beginning
while True:
from random import *
print("Welcome!")
n = input("Enter a number of tickets: ")
n = int(n)
tickets_left = 80 - n
if tickets_left < n:
print("Sorry, there are not enough tickets left.")
elif tickets_left >... |
d446157e0d2248fc0f1cbd09dd9ce86285b89eba | aeocista/pythonPractice | /numberGuess.py | 1,136 | 4.375 | 4 | """
This program adds the sum of two dice and asks the player to guess the sum. If the player is right, they win. If they are wrong, they lose.
Author: Wesley Applequist
"""
##GAME TIME
dice_roll(24)
##IMPORTS
#from module import function
from random import randint
from time import sleep
##FUNCTIONS
#Prompt the play... |
ff1a603019e0045c2aa84dc3c66f65aa9dec4545 | JiniousChoi/encyclopedia-in-code | /quizzes/interviewbit/programming/two_pointers/remove_duplicates_from_sorted_array.py | 1,474 | 3.578125 | 4 | #!/usr/bin/python3
## author: jinchoiseoul@gmail.com
class Solution:
# @param A : list of integers
# @return an integer
def removeDuplicates(self, A):
if not A:
return 0
n = len(A)
i = n-1
while i>=1:
if A[i] == A[i-1]:
A.pop(i)
... |
ebe6a397949b5cecedc65b5556190a91647cb665 | gloc-mike/100daysofcode-with-python-course | /days/49-51-measuring-perf/demo/final_csv_code/research.py | 1,598 | 3.5 | 4 | import os
import csv
import collections
from typing import List
data = []
Record = collections.namedtuple(
'Record',
'date,actual_min_temp,actual_max_temp,actual_precipitation'
)
def init():
if data:
return
base_folder = os.path.dirname(__file__)
filename = os.path.join(base_folder, 'da... |
d1bdbf1d7b96a51762c5786ac492a35bbf09940b | HayesCapers/python-basics | /python101.py | 8,161 | 4.34375 | 4 | # # print "Hello, World!"
# # print two things on the same line
# # print ("Hello, world", "Again")
# # print """ this
# # will ignore line breaks
# # until python finds
# # another three double quotes"""
# # print "new thing"
# # python
# # Arithmatic
# # the_meaning_of_life = 40 + 2
# # print the_meaning_of_life... |
09abcbef80bf99157aaea4a214ccebec93f26053 | JohannesBuchner/pystrict3 | /tests/data23/recipe-577548.py | 2,043 | 3.65625 | 4 | #-*- coding: utf-8 -*-
import socket
import ssl
import http.client
class HTTPSClientAuthConnection(http.client.HTTPSConnection):
""" Class to make a HTTPS connection, with support for full client-based SSL Authentication"""
def __init__(self, host, port, key_file, cert_file, ca_file, timeout=None):
h... |
60c9d98621aa807f59e8566182e92b2b369634af | Andrei-Br/Rock-Paper-Scissors | /rock_paper_scissors.py | 1,548 | 4.0625 | 4 | import os
from scenarios import rock_paper_scissors
class MyException(Exception):
""" Exception in case of input not 'rock', 'paper', 'scissors' """
#function for playing the game
def play_rps():
print('Welcome to Rock, Paper, Scissors!\n')
while True:
try:
# ask the firs... |
8d68165d566b7301851f0b14a836603593b4e250 | deepali02/Python | /0410/p33.py | 171 | 4.28125 | 4 | # WAP to display the sum of first n numbers
n=int(input("Enter number:"))
sum=0
i=1
while i<=n:
sum=sum+i
i=i+1
print("The sum of first",n,"numbers is :",sum)
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.