blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string |
|---|---|---|---|---|---|---|
022e48b480452645c386a294d061efbeea9dc027 | pofin/Crypto-Final-Project | /final/crypto/mac.py | 885 | 3.5625 | 4 | class Mac:
""" Generic interface for all MAC algorithms. """
@classmethod
def get_name(self):
"""
Returns:
A unique name for this MAC algorithm. """
raise NotImplementedError("get_name() must be implemented by subclass.")
def get_length(self):
"""
Returns:
The length in charact... |
0300b703a046069d6f8ce39cf9e1f5f04683266a | lexraye/python_files | /fundamentals/fundamentals/for_loop_basic1.py | 1,007 | 3.75 | 4 | # print all integers from 0 to 150
for x in range(0, 151):
print(x)
# print all the multiples of 5 from 5 to 1,000
for x in range(5, 1001, 5):
print(x)
# print integers 1 to 100. if divisible by 5 print Coding if divisible by 10 print Dojo
for x in range(1, 101):
if x % 10 == 0:
print('Coding D... |
a7fdf346dba1559d16584e8dd222dd03eaeede5a | AustinPenner/ProjectEuler | /Problems 26-50/euler042.py | 652 | 3.78125 | 4 | def is_triangle(word):
alphabet = ['','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z']
letter_sum = 0
for letter in word:
letter_sum += alphabet.index(letter)
# Triangle numbers:
# n = x*(x+1)/2
# 2*n = x^2+x
# 0 = x^2+x-2*n
# Quadratic formula:
x = ... |
914351c70d36b23df2ac1811b16ff77bd02a1d51 | CosmiX-6/Library-Management-System-CLI | /validator.py | 3,134 | 3.6875 | 4 | def checkstring(value):
restrict='1234567890!@#$%^&*()-_+=} {:][|\"\'\\|/?.><,'
for i in value:
flag=True
if i in restrict:
print('Invalid character used in name.')
flag=False
break
return flag
def checkpass(value):
restrict='-][,\)... |
ae718cc60a1df4142f44e10e38ce7b7f48b6e0dc | j3nnn1/pyj3nnn1 | /tarea02/exercise04.py | 1,166 | 3.859375 | 4 | #!/usr/bin/python
# -*- coding: utf-8 -*-
"""
4- Crear una clase que procese la edad de una persona
y a traves de metodos verifique, retornando booleanos,
si pertenece a estos grupos de edad y ademas, pueda ser
modificada y luego revisar otra vez
- 0 a 10
- 11 a 20
- 21 a 40
- 41 a 60
- Mayor de 60
"""
class age:
... |
b96c1029e73b208079fc8d006eba187e956df9ca | DaminduSandaruwan/LearnPython | /Variables.py | 495 | 3.828125 | 4 | num = 5
print(id(num)) #print address of num
name ='Damindu'
print(id(name)) #print address of name
a = 10
b = a
print(id(a)) #1938475072
print(id(b)) #1938475072
# address are same because b = a; in python
print(id(10)) #1938475072 address is based on box it self
k = 10
print(id(k)) #1938475072
a=9
print(id(a))... |
b93c5aebcac957b210e675856e97bf2ef14590d5 | daniel-reich/ubiquitous-fiesta | /7Y2C8g3fXXyK2R9Bn_3.py | 1,364 | 3.578125 | 4 |
def keyword_cipher(key, message):
alphabet = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u',
'v', 'w', 'x', 'y', 'z']
value_dict = {'a': 1, 'b': 2, 'c': 3, 'd': 4, 'e': 5, 'f': 6, 'g': 7, 'h': 8, 'i': 9, 'j': 10, 'k': 11, 'l': 12,
... |
8a8be9d06bf0c0984f7fbf5c6956f29d7bd6dc32 | jayant92/tictactoe | /tictac.py | 3,194 | 3.921875 | 4 | import random
def display_board(board):
print("\n"*100)
print(board[7]+"|"+board[8]+"|"+board[9])
print(board[4]+"|"+board[5]+"|"+board[6])
print(board[1]+"|"+board[2]+"|"+board[3])
def player_input():
marker = ""
while marker!="X" and marker != "O":
marker = input("Player O... |
ce1f91e55e29269422ff0e2b1e0af2901a0042e3 | huyihui004/python | /自己/公司电脑py文件/xiaoyouxi.py | 1,520 | 3.5625 | 4 | #!/usr/bin/env python
#coding=utf-8
import random
import os
'''
分组实现保存不同用户的数据
game.txt的内容如下
胡益辉 3 5 31
总游戏次数,最快猜出的轮数,猜过的总轮数
'''
Name = raw_input('请输入名字:')
if not os.path.exists('game.txt'): #如果文件不存在则新建一个空文件
open('game.txt','w')
game = open('game.txt')
Data = game.readlines()
game.close()
result = {} #初始化一个字典
for ... |
1970de42fbf0cd80665bd5b7ddfb4362967c30f3 | JneWalter25/SimpleChattyBot | /Topics/Program with numbers/Calculating S V P/main.py | 306 | 3.53125 | 4 | # put your python code here
length = int(input())
width = int(input())
height = int(input())
sum_lengths_edges = 4*(length + width + height)
print(sum_lengths_edges)
surface_area = 2*(length * width + width * height + length * height)
print(surface_area)
volume = length * width * height
print(volume)
|
c1de126e68d648ad9d8d178b9044b8c1e3a8d0d7 | Sher-dil/MathSolution | /math_expression.py | 2,907 | 4.03125 | 4 | import re
def seperate_expression(expression):
#We just convert our expression to it's parts and return it as a list.
return re.findall(r'\d+\.\d+|\d+|[\+\*\-\/]', expression)
def calculate(expression):
num_sym_list=seperate_expression(expression)
#Solve our expresion by multi... |
284d8ec970d662bd684799b6533f445aca1e7c15 | nirmalshah20519/GTU_PRACTICALS | /PDS/SET_1/Prog-7.py | 220 | 4.15625 | 4 | # Python Program to find out the second largest number in the list
arr1=[100,99,98,97,96,95,94,93,92,91]
print(arr1)
arr2=arr1
arr2.sort()
print("Second Largest Element in the given array is : ", arr2[-2])
arr2.clear()
|
f6f9fae8e999c571fcc61a5dbb4a3fbffa32b1eb | christine2623/Mao | /K-fold cross validation.py | 8,315 | 3.859375 | 4 | # K Fold Cross Validation
# In the previous mission, we learned about cross validation,
# a technique for testing a machine learning model's accuracy on new data that the model wasn't trained on.
"""
K-fold cross-validation works by:
splitting the full dataset into k equal length partitions,
selecting k-1 partitions a... |
c764106862aa09477602b11a6761eab8e3d79bef | Jventura1/python_practice | /sample_classes.py | 475 | 3.9375 | 4 | class simple_arithmetic:
'''This object takes two arguments at initialization. there are four methods that will return
simple arithmetic operations'''
def __init__(self,arg1,arg2):
self.arg1 = arg1
self.arg2 = arg2
def add(self):
return self.arg1+self.arg2
def sub(self):
... |
0bc30d168a94324b5e6a4a70f0aa4cc6e77b25e6 | yuhangxiaocs/LeetCodePy | /search/Number_of_SquarefulArrays.py | 1,096 | 3.59375 | 4 | import math
class Solution(object):
def numSquarefulPerms(self, A):
"""
:type A: List[int]
:rtype: int
"""
A.sort()
def check(nums):
n = len(nums)
for i in range(n - 1):
s = (nums[i] + nums[i + 1])
sqrt = ... |
88af451542490159c2d02811dd50e01dc5208d90 | lesliemayer/catalogImages | /Modules/imageutils.py | 2,588 | 3.703125 | 4 | # python code imutils.py
#
# LR Mayer from OpenCV book (pdf)
# 08/22/2016
#
# Defining our own imutils package :
import numpy as np
import cv2
from matplotlib import pyplot as plt
import __future__ # for the print function so that it works in python 3
# function to translate an image in the x & y direction
def tran... |
ef616e72eea64e0df6959eed3b6041f61d4250be | JaviS1997/feb172020 | /tripled_letters.py | 170 | 4 | 4 | string = input("Give me the text please")
if string[::3] == string[1::3] == string[2::3]:
print("They are all tripled ")
else:
print("They are not all tripled")
|
20f7406d297ef7de2ef25cb198670418a91d02c1 | tbo4500/Horizons | /Assignment1/Problem6/example6-1.py | 72 | 3.75 | 4 | array = ['a', 'b', 'c', 'd', 'e']
for i in range(3):
print array[i]
|
67846b713d0bab5066b84264a3a5d36e33324ebc | BIG-S2/PSC | /Scilpy/scilpy/utils/python_tools.py | 503 | 3.90625 | 4 | #! /usr/bin/env python
# -*- coding: utf-8 -*-
from itertools import tee
import re
def natural_sort(l):
# Taken from http://stackoverflow.com/a/2669120/912757
def alphanum(key):
return [int(c) if c.isdigit() else c.lower()
for c in re.split('([0-9]+)', key)]
return sorted(l, key=a... |
6e6eebc2b1688c4dc2e7ec3fc7f7e3ec6751c989 | carb/EulerWork | /Euler5.py | 835 | 3.765625 | 4 | '''
2520 is the smallest number that can be divided by each of the numbers from 1 to 10 without any remainder.
What is the smallest positive number that is evenly divisible by all of the numbers from 1 to 20?
Brute force doesnt work!!
\>>> for num in range(10000000):
... e = 0
... for thang in range (1,21):
... ... |
d98bc4ba86d49cfab3fba4638a3fefce0f2107b8 | T300M256/Python_Courses | /python1hw/check_string.py | 405 | 4.375 | 4 | #!/usr/local/bin/python3
"""check the input meets the requirements"""
s = ""
while not s.isupper() or not s.endswith("."):
s = input("Please enter an upper-case string ending with a period: ")
if not s.isupper():
print("Input is not all upper case.")
elif not s.endswith("."):
print("Input do... |
d72e7b91c72074d60e0ab79157a195a7f7d79776 | msflores10307/python-challenge | /PyBank/main.py | 2,038 | 3.53125 | 4 | import os
import csv
# sets data file path
data_path = os.path.join(".", "Resources", "budget_data.csv")
# initiates important arrays and dictionary
month_column = []
prof_loss_column = []
changes = []
monthly_prof = {}
monthly_changes = {}
# opens reader file
with open(data_path) as csvfile:
csv_reader = csv.re... |
f68d9d42c6a1a752e7fd9b19e9f891b4a32100d5 | hellcat-git/PythonBasics | /Lesson3_Task2.py | 834 | 3.515625 | 4 | my_users_attr = ['Имя', 'Фамилия', 'Год рождения', 'Город проживания', 'email', 'Телефон']
def collect_data():
new_user_data = []
for i in my_users_attr:
a = input(f"Введите значение атрибута '{i}': ")
new_user_data += [(i, a)]
new_user_dict = dict(new_user_data)
return new_user_dict
... |
7db1b0b9c766005be18cd7bded5160b4b1d2f6ab | artainmo/python_bootcamp | /day03/ex01/ImageProcessor.py | 667 | 3.734375 | 4 | import matplotlib.image as img
import matplotlib.pyplot as plt
class ImageProcessor:
def load(self, path): #opens the .png file specified by the path argument and returns an array with the RGB values of the image pixels. It must display a message specifying the dimensions of the image (e.g. 340 x 500).
RGB... |
7d2aa29ebb3431476eb0f189a0ab034b2e8538ff | kmod/icbd | /icbd/compiler/tests/24.py | 411 | 3.546875 | 4 | """
string test
"""
s = ""
for i in xrange(10):
s += " 5"
print s
def ident(s):
return s
def double(s):
return s + s
print double("hello"), ident("world")
def callit(f):
return f("hello")
print callit("world ".__add__)
l = ["hi"]
while len(l) < 10:
l.append(l[-1] + "i")
for i in xrange(len(l)):... |
16ebf3eaf0071d84326010beece3686762ca76c9 | serena-mower23/repo-test | /serena-stuff/hello-world.py | 188 | 3.65625 | 4 | import pandas as pd
print('Hello World')
grades = pd.read_csv('grades.csv')
grade_pivot = grades.pivot(
columns="test",
index="student",
values="grade"
)
print(grade_pivot) |
4db01a58cbd9ab2c54ac7e9ee68795cb0583ccb3 | gibson20g/ExerciosPythonPojeto | /ex034salario.py | 1,257 | 3.9375 | 4 | nome = str(input("Digite o Nome do Funcionario: "))
salario = float(input("Qual é o salário do funcionario?R$: "))
if salario <= 1045:
novo = salario + (salario * 5.26 / 100)
porcent = 5.26
aumento = novo - salario
print("O salario antigo é R${:.2f}, Porcentagem de aumento {}% ".format(salario, porcent))
print("a... |
9affeca6f4157d56207c9e00e4f18469159aca8d | MrWJB/rtxs | /rtxs/复习/偏函数复习.py | 595 | 3.984375 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
i1 = int('12306')
print('i1的值: %s ' % i1)
def int2(x, base=2):
return int(x, base)
i2 = int2('1010010111011')
print('i2的值: %s' % i2)
# functools.partial 就是帮助我们创建一个偏函数的,不需要我们自己定义int2(), 可以直接使用下面的的代码创建一个新的函数int2:
import functools
int2 = functools.partial(int, base... |
acb33b2069fa3c13e8f67328e2ad4f9ffb42fdbe | raghum96/pythonTutorial | /WhileLoop.py | 139 | 3.59375 | 4 | i = 0
while i < 10:
# print(i)
i = i + 1
for i in range(0, 100, 7):
if i > 0 and i % 11 == 0:
print(i)
break
|
056b6116c9f07e19d98ec9f39ea1dc11158f78d6 | Dhrumil-Zion/Competitive-Programming-Basics | /LeetCode/Arrays/check_for _doubles_in_array.py | 151 | 3.703125 | 4 | arr = [3,1,7,11]
flag = 0
for a in arr:
temp = a*2
if temp in arr:
flag=1
print("True")
if flag==0:
print("false")
|
f46d8a29fdbb09750c1ce4fdde06d937008116a5 | marcogmaia/proj_com | /q2/account.py | 1,045 | 3.640625 | 4 | class account():
def __init__(self, user, password):
self.user = user
self.password = password
'''getters'''
def getUser(self):
return self.user
def getPass(self):
return self.password
'''setters'''
def setUser(self, curAccount, newUser):
if newUser != "" and self.getUser() == curAccount.getUser() and s... |
4e41e6bd816d64e958b6784058142039e752c645 | henryji96/LeetCode-Solutions | /Easy/671.second-minimum-node-in-binary-tree/second-minimum-node-in-binary-tree.py | 735 | 3.8125 | 4 | # Definition for a binary tree node.
# class TreeNode:
# def __init__(self, x):
# self.val = x
# self.left = None
# self.right = None
class Solution:
def findSecondMinimumValue(self, root):
"""
:type root: TreeNode
:rtype: int
"""
if not root:
... |
2d8f037e8317d5f09e7dca5cc98700e44a5310f6 | mfitrihani/project-euler-solutions | /Python/010.py | 573 | 3.796875 | 4 | def generate_prime_number(max_prime_number):
candidate = [True for x in range(0, max_prime_number)]
for i in range(2, int(max_prime_number**0.5) + 2):
if candidate[i]:
j = i*i
x = 1
while j < max_prime_number:
candidate[j] = False
j = i... |
13624609bc4cca1b6e0bc0350b5c9cc7926627aa | daniel-reich/ubiquitous-fiesta | /Egh2HES8eqPTTX9Q2_4.py | 228 | 3.546875 | 4 |
def rolling_cipher(txt, n):
return "".join(alphaSwap(c,n%26) for c in txt)
def alphaSwap(c,add):
cur = ord(c)-ord("a")+1
if cur+add<=26:
return(chr(ord(c)+add))
add = (cur+add)%26
return(chr(ord("a")+add-1))
|
c4ae13f442e1f412002bb7554263b126cc52ca19 | KasraNezamabadi/InterviewPractice | /SortPractice.py | 2,288 | 3.8125 | 4 | import math
def MergeSort(inputList: [int]):
# Stop condition for recursive call
if len(inputList) == 1:
return inputList
# We need to divide the array into two halves and recursively call mergeSort for each.
leftSublist = inputList[:math.floor(len(inputList) / 2)]
rightSublist = inputLi... |
116f3a3a50601caf48cc0cb3c04920c9db6074bb | HenDGS/Aprendendo-Python | /python/Exercicios/5.9.py | 279 | 3.984375 | 4 | usuarios=["henrique","clara","guilherme","admin","pedro"]
if usuarios:
for usuario in usuarios:
if (usuario=="admin"):
print("Olá admin, gostaria de um relatorio?")
else :
print(usuario.title() + ", bom dia!")
else:
print ("Preciamos encontrar alguns usuários")
|
e46e5331c2a3b189c5082674a1193a8b8e1cf6cd | gong1209/my_python | /Class & function/C_car.py | 1,446 | 4.4375 | 4 | ''' 父類別 Parent class'''
class Car():
def __init__(self,year,brand,color):
self.year = year
self.brand = brand
self.color = color
self.miles = 0
def get_name(self): # 印出名字
print(str(self.year) +" "+ self.brand)
def get_mile(self): # 存取公里數
print("Your "+self... |
aa38ac57b56ae86a53d2f74fa2da22060894b3f3 | BabyCakes13/Python-Treasure | /Laboratory 5/problem1/Class.py | 544 | 3.9375 | 4 | class Class:
"""Class which contains the transform methods."""
def __init__(self):
"""Initialises the string."""
self.string = ""
def ask_str(self):
"""Gets the string from the user."""
self.string = input("give the string...")
def transform_str(self):
"""Pri... |
860b79853073b7b85229d8f9cc5acdd195399dd5 | huicheese/Bootcamp | /Lab4/Lab 4 Example 7.py | 174 | 3.609375 | 4 | date_input = input("Enter DOB (d/m/y)")
parts = date_input.split("/") # this will be a list of strings
my_dob = (int(parts[0]), int(parts[1]), int(parts[2]))
print(my_dob)
|
34680d1fe86a79ec05b9fd451a7d9fdbfa7de72e | guoweifeng216/python | /python_design/pythonprogram_design/Ch6/6-3-E15.py | 718 | 4.09375 | 4 | import turtle
def main():
## Draw nested set of five squares.
t = turtle.Turtle()
t.hideturtle()
for i in range(1, 6):
drawRectangle(t, -10 * i, -10 * i, 20 * i, 20 * i, "blue")
def drawRectangle(t, x, y, w, h, colorP="black"):
## Draw a rectangle with bottom-left corner (x, y),
## wi... |
f1c4c2668b6b96df37addd17705baf073c7fb953 | bam0/Project-Euler-First-100-Problems | /Problems_21-40/P23_Non-Abundant_Sums.py | 3,183 | 3.859375 | 4 | '''
Problem: Find the sum of all the positive integers which cannot be
written as the sum of two abundant numbers.
Using the algorithms we already created in problem 21, this problem won't present
us with too much of a challenge. First we'll generate a list of primes with our
prime sieve, then calculate the sum of div... |
c4cb28945cc6f922a36ed15f6307d09b1d136a7f | spradeepv/dive-into-python | /hackerrank/domain/python/data_types/lists.py | 470 | 3.578125 | 4 | # Enter your code here. Read input from STDIN. Print output to STDOUT
n = int(raw_input())
l = []
for i in range(n):
commands = raw_input().split()
count = 0
method = ""
method = commands[0]
args = map(int, commands[1:])
if method == "print":
print l
elif not args and method != "prin... |
fc78249cea41af1185722f0ad3dd2683d66d39a9 | ahmadzaidan99/Codewars | /Persistent_Bugger.py | 236 | 3.5 | 4 | def persistence(n):
arr = [int(x) for x in str(n)]
count = 0
while(len(arr)!=1):
result=1
count += 1
for x in arr:
result *= x
arr = [int(x) for x in str(result)]
return count
|
3a328c5584ab89c3073c79a643659c3c7114313a | navctns/Python-Exercices | /38_string_print.py | 233 | 4.3125 | 4 | #38. Write a program to print every character of a string entered by user
#in a new line using loop
str1=input("Enter the string:")
for i in str1:
print(i)
"""
OUTPUT:
Enter the string:python
p
y
t
h
o
n
"""
|
3e881ac5996acdd84eca88d2be9aa0fec25ccfe3 | KoskiKari/easyHangman | /hangman.py | 5,032 | 4.0625 | 4 | import time, random, os, string
def menuLayout():
#game's main menu
print(f'HANGMAN GAME ')
print(f' ____ ')
print(f'/ | ')
print(f'| O ')
print(f'| -|- ')
print(f'| / \ ')
print(f'| ')
print(f' _________ ')
prin... |
44a3c5e35b62d1bb329b844a0aae4a1d58bab706 | huit-sys/progAvanzada | /6.py | 1,518 | 3.671875 | 4 | # -*- coding: utf-8 -*-
"""
Created on Tue Sep 17 15:08:48 2019
@author: stitch
"""
#hacer un progrmaa en el que el ussuario introduzca el nombre de la comida que ordeno
#en un restaurante y su precio. despues, su programa debe calcular el subtotal, el iva,
#y la propina de toda la cuenta. La salida del prog... |
a73626f7b389af136ab945be353d198fa60e16e8 | Caroline-Wendy/Python-Notes | /ABOP_Function.py | 2,044 | 3.5 | 4 | # -*- coding: utf-8 -*-
#====================
#File: abop.py
#Author: Wendy
#Date: 2013-12-03
#====================
#eclipse pydev, python3.3
#函数
def sayHello():
print('Hello World')
sayHello()
sayHello()
#带参数的函数
def printMax(a, b):
if a > b:
print(a, 'is maximum') #python自动生成空格
elif a == b... |
488b698154161ce6520b54901874c0fef37a8502 | anastyer/Python-projects | /генератор паролей.py | 1,300 | 3.59375 | 4 | import random
digit = '1234567890'
low_letters = 'qwertyuiopasdfghjklzxcvbnm'
up_letters = 'QWERTYUIOPASDFGHJKLZXCVBNM'
signs = '#$%^&*_+=?-@!'
chars = ''
n = int(input(' ? '))
length = int(input(' : '))
need_digit = input(' ? ( ) ')
need_low = input(' ? ( ) ')
need_up = input(' ? ( ) ')
nee... |
af7979b48e640ea6f094599f3f3015132f0f65ab | sroshan106/HackerRank-Solutions | /pairs.py | 331 | 3.5625 | 4 | #!/bin/python3
# Complete the pairs function below.
def pairs(k, arr):
arr= set(arr)
count=0
for i in arr:
if(i+k in arr):
count+=1
return count
nk = input().split()
n = int(nk[0])
k = int(nk[1])
arr = list(map(int, input().rstrip().split()))
result = pairs(k, arr)
pri... |
67a47f605c82a0d86d6b3aa220fb1d03455b389c | ItsTuukka/Ohjelmistotekniikka | /minigolf-game/src/field_elements/field.py | 4,199 | 3.828125 | 4 | import sys
import pygame
from field_elements.element import Element
from field_elements.ball import Ball
class Field:
"""A class for creating the field.
Attributes:
height, width: Dimensions of the current field
holes,
walls,
grass,
water,
light_sand,
d... |
e91b3f52fbf9bb6f3de33c8190ddb7a86d38a802 | 931808901/GitTest | /day1/1025/demos/W4/day4/00Homework.py | 2,957 | 3.515625 | 4 | #! C:\Python36\python.exe
# coding:utf-8
'''
从1加到一亿,使用单线程、10并发进程、10并发线程分别求其结果,统计并比较执行时间
@结论:
·效率对比:多进程 > 多线程 ≈ 单线程
·为什么多进程最快?
多进程可以充分使用CPU【多核的并发计算能力】
·为什么多线程和点线程差不多?
多线程是伪并发
·既然多线程在效率上与单线程相差无几,多线程存在的意义是什么?
1、确实有多任务同时进行的需要
2、平摊每条线程阻塞、抛异常的风险(试想主线程被阻塞时,逻辑全线瘫痪)
@ 多线程 VS 多进程
·进程的资源开销远远大于线程,能多线程解决的就不用多进程
·计算密... |
8e4aaa40eb00add78b7e12c00a4005025631ded5 | Kevinloritsch/Buffet-Dr.-Neato | /Python Labs/5. Python More Casting/run5.py | 167 | 3.796875 | 4 | valueone = input("Please enter a first number: ")
valuetwo = input("Please enter a second number: ")
print(valueone+"*"+valuetwo)
print(int(valuetwo)*int(valueone))
|
70e729cd3ebc8118c9e7e0c51f8a6ec108bb5475 | Ivanich99/Progect1 | /Оценка вероятности работы устройства состоящего из нескольких элеметов.py | 1,324 | 3.84375 | 4 | import random
i = 0
result = 0
#v1 = float(input('Введите вероятность для A ')) На случай если вероятности для устройства задаются каждый раз
#v2 = float(input('Введите вероятность для B '))
#v3 = float(input('Введите вероятность для C '))
#v4 = float(input('Введите вероятность для D '))
#v5 = float(input('Введи... |
967b3fd38554a22c5da23c0ddf7572ace0f07820 | sumitpatra6/leetcode | /backtracking/letter_case_permutation.py | 585 | 3.8125 | 4 | def letter_case_permutation(S):
final_result = set()
def util(string, start, end):
if start == end:
final_result.add(''.join(string[:]))
return
if string[start].isdigit():
util(string, start+1, end)
else:
string[start] = string[sta... |
a6939e0ee92c589fc3b09c7ed1ed8b2116bd51f4 | Tom-Szendrey/Highschool-basic-notes | /Notes/Harder Dictionaries.py | 919 | 4 | 4 | inventory = {
'gold' : 500,
'pouch' : ['flint', 'twine', 'gemstone'], # Assigned a new list to 'pouch' key
'backpack' : ['dagger', 'bedroll','bread loaf']
}
# Adding a key 'burlap bag' and assigning a list to it
inventory['burlap bag'] = ['apple', 'small ruby', 'three-toed sloth']
# Sorting the l... |
6ffc6a18bbd9a04db0b4d45901151a1c5fb0cb41 | jmavis/CodingChallenges | /Python/Guess.py | 1,095 | 4.25 | 4 | #------------------------------------------------------------------------------
# Jared Mavis
# jmavis@ucsc.edu
# Programming Assignment 3
# Guess.py - Generates a number from 1-10 and asks the user to guess up to 3 times reporting if the real number is higher or lower
#--------------------------------------------... |
3aec47df044730a468a11d35536fbefec00258df | franciscojunior10/uri-answers | /1005.py | 109 | 3.75 | 4 | A = float(input(''))
B = float(input(''))
result = ((A * 3.5) + (B * 7.5)) / 11
print('MEDIA = %0.5f'%result) |
974cd0777cfc233f5edf3e864cc3aae3f4d0e786 | ArifSanaullah/Python_codes | /209.Try , Except - exception handling, python tutorial 207.py | 424 | 4.125 | 4 | # 209.Try , Except - exception handling, python tutorial 207
# exception
# try exception else finally
while True:
try:
age = int(input('please enter your age: ')) # seven
break
except ValueError:
print("invalid input...")
except:
print("unexpected error...")
... |
1951f3f37b1bf3fe2e9a5f3460976469a5d58a35 | akjanik/Project-Euler | /problem-005.py | 467 | 3.609375 | 4 | """
2520 is the smallest number that can be divided by each of the numbers from 1 to 10 without any remainder.
What is the smallest positive number that is evenly divisible by all of the numbers from 1 to 20?
"""
#Brute force
a = 2520
step = 20
cond = True
while cond:
a += step
for i in range(20,0, -1):
... |
f20e9e24ead79c26635acb82b3060e875e468714 | joaovictorgb/Python-Algorithms | /placar_futebol.py | 1,079 | 3.90625 | 4 | #Quantidades
Linhas = 10 ; Colunas = 2 ; mtimes = [] ;mplacar = [] ; vencedores = []
#Gerando as matrizes dos times e do placar
for i in range(Linhas):
mtimes.append([0] * Colunas)
for i in range (Linhas):
mplacar.append([0] * Colunas)
#Adiçao dos times e do placar
for i in range(Linhas):
for b in range (Col... |
74bd3b433a02610f3e746f1039386a2659401df1 | KaySchus/Project-Euler | /Problem 1 - 50/Problem_10.py | 351 | 3.515625 | 4 | import math
def sieve(limit = 125000):
sieve = [True] * limit
sieve[0] = sieve[1] = False
primes = []
for (i, isprime) in enumerate(sieve):
if (isprime):
primes.append(i)
for n in range(i * i, limit, i):
sieve[n] = False
return primes
primes = sieve(2000000)
summation = 0
for prime in primes:
summ... |
af4c78375ef7149b65e3601d12b60ae9f36d2ffc | jebrunnoe/Project-Euler | /problem55.py | 409 | 3.546875 | 4 | def palindrome(s):
if s == s[::-1]:
return True
return False
lychrels = list()
for n in range(1, 10000):
lychrel = True
s = str(n)
iterations = 0
result = n
while lychrel and iterations <= 50:
result = result + int(str(result)[::-1])
if palindrome(str(result)):
lychrel = Fal... |
d4602dbcc1fc9f6882fa90607ae7868df42b458c | Hieunt27/GoogleKickStart_Solutions | /2020_RoundF/helper.py | 474 | 3.5 | 4 | from random import randint
print "100"
for T in range(100):
myDict=set()
n=0
while n<12:
x=randint(1,6)
y=randint(1,2*x-1)
if (x,y) in myDict:
continue
myDict.add((x,y))
n+=1
myDict=list(myDict)
result="6 "+str(myDict[0][0])+" "+str(myDict[0][1])+"... |
afeead076705c4b7ef8b5778792193067c84e4ad | mle8109/repo1 | /CS_Python/DataStructure/linkedlist.py | 1,867 | 4.1875 | 4 | class Node:
def __init__(self, data):
self.data = data
self.next = None
class LinkedList:
def __init__(self):
self.head = None
def addToFront(self, new_data):
newNode = Node(new_data)
newNode.next = self.head
self.head = newNode
def addToTail(self, new_... |
1373fb955938c3beaacadef4d5d0785e6cc73596 | tiendong96/Python | /Practice/String/findAString.py | 884 | 4.15625 | 4 | # In this challenge, the user enters a string and a substring.
# You have to print the number of times that the substring occurs in the given string.
# String traversal will take place from left to right, not from right to left.
# https://www.hackerrank.com/challenges/find-a-string/problem
def count_substring(string... |
582069e7c43e44b7cbc6b175867e6fd9e590f815 | Alberts1995/Example | /Turtle/шар.py | 573 | 4 | 4 | import turtle
windows = turtle.Screen()
windows.title('мячь')
play = turtle.Turtle()
play.speed(0)
play.up()
play.goto(300, 300)
play.down()
play.hideturtle()
play.pensize(8)
play.color("yellow")
play.goto(300, -300)
play.goto(-300, -300)
play.goto(-300, 300)
play.goto(300, 300)
bool = turtle.Turtle()
bool.shape("cir... |
72b7a72d3d0ba14de258db56bf6a493fbff48c03 | amrit2995/break_out_game | /player_bar.py | 493 | 3.5625 | 4 | from turtle import Turtle
direction = {'right': 0, 'left': 180}
class Player(Turtle):
def __init__(self):
super().__init__()
self.shape('square')
self.shapesize(stretch_wid=1, stretch_len=8)
self.penup()
self.color('white')
self.reset()
def left(self):
... |
ce86c5a564b1ccf76bad36f0993eed84a15648be | ChrisHolley/toyProblems | /disemvowel.py | 307 | 3.953125 | 4 | def disemvowel(str: str):
vowelDict = {'a': 1, 'e': 1, 'i': 1, 'o': 1, 'u': 1, 'A': 1, 'E': 1, 'I': 1, 'O': 1, 'U': 1}
str = list(str)
print(str)
for idx, char in reversed(list(enumerate(str))):
if vowelDict.get(char) == True:
str.pop(idx)
return ''.join(str)
print(disemvowel('hello')) |
ff750bcd7eb8f825b624ff219b3ec36310a09b90 | ethan1022/yangsTriangle | /yangsTriangle.py | 410 | 3.703125 | 4 | # -*- coding: utf-8 -*-
def triangles(max):
n, result = 0, [1]
while n < max:
yield result
if len(result) >= 2:
result = [result[x] + result[x+1] for x in range(len(result) - 1)]
result.insert(0, 1)
result.append(1)
n = n + 1
return "done"
scale = input("input scale: ")
while scale.isdigit() == Fals... |
fe02b2d4a20405af920a08f78f7e66019007d106 | charlie14516/AE402-python | /校長獎學金.py | 311 | 3.921875 | 4 | math_score=input('請輸入數學成績')
english_score=input('請輸入英文成績')
math_score=int(math_score)
english_score=int(english_score)
if((math_score>=90 and english_score>=90) or math_score==100 or english_score==100):
print('可得獎學金')
else:
print('無法得獎學金')
|
7c7c990f4719180d6227e562b690fe14da75bb22 | marinme/learning | /Pythagorean Triples Checker/test_pythag.py | 614 | 4 | 4 | from pythag import pythag
import unittest
class TestPythag(unittest.TestCase):
def test_pythag(self):
# test basic inputs
self.assertTrue(pythag(3,4,5))
self.assertFalse(pythag(3,4,6))
def test_pythag_ordering(self):
self.assertEqual(pythag(3,4,5), pythag(5,3,4))
def test_... |
3b76fab0a9cec9e06f7aeb582373dd1e77fd58ce | Retchut/MNUM-2020-2021 | /exams/2015/4.py | 433 | 3.53125 | 4 | # -*- coding: utf-8 -*-
"""
Created on Tue Feb 2 14:33:25 2021
@author: Retch
"""
import math
def g(x): return 2*math.log(2*x)
def picard_peano(x0, n):
print("initial guess:", x0)
y0 = 0
for i in range(n):
y0 = g(x0)
x0 = y0
print("\niteration", i+1)
pr... |
8ad3e1de27ceb7e0c8cae7f9e153b5dfc09069d0 | AdamZhouSE/pythonHomework | /Code/CodeRecords/2606/60771/285032.py | 361 | 3.703125 | 4 | #03
def binary(arr,l,r,x):
if r > l:
mid = int(l + (r-1)/2)
if arr[mid] == x:
return mid
elif arr[mid] > x:
return binary(arr,l,mid-1,x)
else:
return binary(arr,mid+1,r,x)
else:
return -1
num = eval(input())
n = int(input())
outcome = b... |
d03d72ec72619f8ed37762f1d75ea0b434310563 | real-ashd/AutomateBoringStuffWithPython | /FileSystem/DeletingFiles.py | 1,147 | 3.546875 | 4 | #Delting files and folders
#Be careful as this doesn't sent the file/folders to Recycle bin
import shutil
import os
"""Using os module"""
# print(os.unlink(r'C:\Users\Abc\Documents\Folder1\hello.txt')) #Use os.unlink() to delete a file
# print(os.rmdir(r'C:\Users\Abc\Documents\Folder1\Folder2')) #To use os.rmdi... |
1e63b27ef7663ac451168b12608946fc88dcc3e4 | nikrhem/simmm | /sum.py | 110 | 3.578125 | 4 | a = int(input())
m = 0
if a > 0:
for i in range(1,a+1):
m = m + i
print(m)
else :
print("invalid") |
ed6f178101cdc1c2829ca98105e6c8320231b309 | L200170115/prak_ASD_C | /Modul8/No_3.py | 947 | 4.03125 | 4 | class stack ():
def __init__ (self): #membuat stack kosong
self.item = []
def empty (self): #mengembalikan nilai bolean yang menunjukan apakah stack itu kosong
return len(self) == 0
def __len__ (self):#mengembalikan banyaknya item di stack
return len(self.item)
def peek(... |
bcd1281e7106b867dd6df6af17a7898a37086af7 | Alexandra323/car_package | /car_package/cars_module.py | 1,240 | 3.96875 | 4 |
class Car():
def __init__(self, make, model, year):
self.make = make
self.model =model
self.year = year
self.odometr = 0
def car_description(self):
print(f"Car info:{self.make},{self.model}, {self.year}")
def read_odometr(self):
print(f"your odometr show... |
5a3e022e7d5ede996408f36bfa39c1017b5af213 | KimiHsieh/I2DL_19S | /Ex1/exercise_code/classifiers/softmax.py | 8,818 | 3.5625 | 4 | """Linear Softmax Classifier."""
# pylint: disable=invalid-name
import numpy as np
from .linear_classifier import LinearClassifier
def cross_entropy_loss_naive(W, X, y, reg):
"""
Cross-entropy loss function, naive implementation (with loops)
Inputs have dimension D, there are C classes, and we operate o... |
0a1f4a077dd56b59ba660c1441c4b3e2b396fb0a | Aasthaengg/IBMdataset | /Python_codes/p03852/s139643247.py | 143 | 3.625 | 4 | c=input()
a='aiueo'
lst=list(a)
count=0
for i in lst:
if c==i:
count+=1
if count>0:
print('vowel')
else:
print('consonant') |
82f3180ffdf047bc4e444f3a3dc11c80a80cf119 | leonh/pyelements | /examples/a2_sequences.py | 1,274 | 4.3125 | 4 | """
1.Tuple : Immutable
ordered sequence of items
Items can be of mixed types, including collection types
2.Strings : Immutable•
Conceptually very much like a tuple
3.List : Mutable
ordered sequence of items of mixed types
"""
from examples.a1_code_blocks import line # import from this package
# import sys
# print(... |
00cf636d063792b4a2402a779d80f23a227df2e5 | InverseLina/python-practice | /Base/TestFunction.py | 2,113 | 3.59375 | 4 |
# encoding=utf-8
__author__ = 'Hinsteny'
'''
关于高阶函数的使用示例,即函数式编程
'''
from functools import reduce
from operator import itemgetter
def test_map():
def f(x):
return x * x
r = map(f, [1, 2, 3, 4, 5, 6, 7, 8, 9])
print(list(r))
return "Test map success!"
def test_reduce():
def f(x, y):
... |
57091f8b2bfade335482f73f74a4a289c12c8b14 | shubhii0206/Project-Euler | /Problem4_11/largest_palindrome.py | 823 | 3.78125 | 4 | import math
def upper_limit(n):
return int(math.pow(10, n) - 1)
def lower_limit(n):
return int(1 + (upper_limit(n) / 10))
def reverse(num):
rev = 0
while num > 0:
dig = num % 10
rev = rev * 10 + dig
num = num // 10
return rev
def isPalindrome(num):... |
d9510d01578717079d08df59fc05dc84b42e77f1 | angusmacdonald/sorting-algorithm-analysis | /src/sortingalgorithms/insertionsort.py | 3,914 | 3.953125 | 4 | import logging
import Monitoring
"""
Simple implementation
Efficient for (quite) small data sets
Adaptive, i.e. efficient for data sets that are already substantially sorted: the time complexity is O(n + d), where d is the number of inversions
More efficient in practice than most other simple quadratic, i.e. O(n2) alg... |
70545f6febab448218c41ed6d645c461a03bf6ac | probbe/python_u | /PalindromeCheck.py | 123 | 3.9375 | 4 | #checks whether a passed in string is palindrome or not.
def palindrome(s):
reverse = s[::-1]
return s == reverse
|
db13c6b98eb2cdf65c806d18dac00674e58a1be3 | sohampatne/python_basics | /loops/04-diamond.py | 636 | 4.03125 | 4 | diamondLevel = int(input('Please enter diamond level (must be even number odd number): '))
counter = 1
starCounter = 1
dashCounter = diamondLevel - 1
if diamondLevel%2 == 0 :
print('Please enter odd value!')
else :
diamondLevel = diamondLevel//2 + 1
while diamondLevel >= counter :
print(' ' * dash... |
f8e5fcd7bda104c16f9e7c093f31086ae2df3910 | mka2011/Machine-Learning-Projects | /Perceptron_Algorithm/Perceptron.py | 3,305 | 3.515625 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Mon Oct 19 18:36:10 2020
@author: manavagrawal
"""
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
"""For getting training set"""
def getTrainVal(gate):
x = np.array([[1,0,0],[1,0,1],[1,1,0],[1,1,1]])
y = np.array([])
... |
d9cddad7d9ab2aeb1ec0d15431c1e2d1a464be9f | basvandriel/learning-python | /input.py | 184 | 4.15625 | 4 | # User input
name = input('Name: ')
age = input('Age: ')
print('Hello,', name, '. You are', age, 'years old')
# Type conversion in input
num = input('Number: ')
print(int(num) - 5)
|
a50b6b8ad280414e20d3293b1626cc8d0b1d01d2 | syurskyi/Algorithms_and_Data_Structure | /_algorithms_challenges/exercism/exercism-master(1)/word-count/word_count.py | 292 | 4.09375 | 4 | import re
def count_words(sentence):
results = {}
words = re.findall(r"[a-zA-Z0-9]+'?[a-zA-Z0-9]+|[a-zA-Z0-9]", sentence.lower())
print(words)
for word in words:
if word.lower() not in results:
results[word.lower()] = words.count(word)
return results
|
f07a1904b3cc43143f8a840cadb3ee71433c18c2 | coderabbit6/python | /Python网络爬虫/爬虫小例子/多进程的使用.py | 1,283 | 3.578125 | 4 | from multiprocessing import Process,Pool
import time
import os
# import calendar
def run(name):
print("{0} is running".format(name))
time.sleep(3)
print("{0} is ending".format(name))
if __name__ == '__main__':
p = Pool(10)
for i in range(10):
print("{0} is running".format(i))
p.apply_async(run,args=(i,))
p... |
8ca51187994fe7ba61936e8bca41a3a7db107f9f | manastole03/Programming-practice | /python/String/0's_at_left.py | 112 | 3.921875 | 4 | str=input('Enter a string: ')
wid=int(input('Enter width: '))
print('Left 0s to given string- ',str.zfill(wid))
|
b0e0e076b215d9ff493c154d3978de6b7146bc79 | ngoctrong2009/KIEUNGOCTRONG_57132025 | /swap.py | 160 | 3.59375 | 4 | print("nhap a :")
a = float(input())
print("nhap b :")
b = float(input())
tam = a
a = b
b = tam
print("a va b sau khi hoan doi")
print("a = ",a)
print("b = ",b) |
bc0b6ce6ef5d8d3cfd37f8dd9e4c8ce7b4ff02b8 | rainydyinlondon/pythonbasicapplication | /propertiestekrar2.py | 1,854 | 3.65625 | 4 | # -*- coding: utf-8 -*-
"""
Created on Wed Feb 17 15:53:02 2021
@author: Feyza
"""
class Product:
def __init__(self,name,price): #Oluşturulan Nesne için çalışacak kodlar
self.name=name
if price>=0: # (self,name,price): parametre olarak gelicek değer >=0 mı diye kontrol ediyoruz...
... |
ff3e25128abc916d609c18161d6fd04481871b3b | ikostan/Exercism_Python_Track | /bank-account/bank_account.py | 2,202 | 3.953125 | 4 | import threading
class BankAccount(object):
"""
Simulate a bank account supporting opening/closing,
withdrawals, and deposits of money.
"""
def __init__(self):
self._balance = 0.0
self._is_opened = False
self._lock = threading.Lock()
def get_balance(self) -> float:
... |
a928fb214a14ac1617af688db59075e6be5ee7d6 | haiou90/aid_python_core | /day16/exercise_personal/07_exercise.py | 352 | 3.640625 | 4 | list01 = [54,43,23,67,28,69,90]
def get_number(list_target):
list_result = []
for number in list_target:
list_result.append(number % 10)
return list_result
result = get_number(list01)
print(result)
def get_number(list_target):
for number in list_target:
yield number % 10
for num in ge... |
9a4696fc9d87fe8e2dfc665ecc2574b49085b5ca | jongin1004/algorithm-coding_test- | /문제/count_of_primes.py | 667 | 3.65625 | 4 | def isPrimes(x): # 소수인지 검증하는 함수 선언
for i in range(2, x): # 2부터 x보다 작은 값까지 for문
if x % i == 0: # i값으로 x를 나눴을 때 딱 나뉘어 떨어지면, 소수가 아니므로 False 리턴
return False
return True
num = int(input()) # n을 입력 받음
primesList = [] # 소수를 넣을 리스트
for i in range(num-1, 1, -1): # num이 2이하 일 때에는 for문이 0번 돌기... |
bc87e25dd96b56ee3fac4296caabc46433282f80 | ImtiazVision/Python | /HW Chp 7/ex16.py | 1,821 | 3.625 | 4 | # c05ex02.pyw
# An archery target.
import math
from graphics import *
def targetWindow():
win = GraphWin("Archery Scorer", 400, 400)
win.setCoords(-6, -6, 6, 6)
win.setBackground("gray")
center = Point(0,0)
# Draw the target
c1 = Circle(center, 5)
c1.setFill("white")
c1.draw(win)
... |
8e7e56dca7121d0064c0d6dc4895822e2eb6b386 | raffmiceli/Project_Euler | /Problem 96/test 3.py | 854 | 3.5 | 4 | def solve(sudoku):
mask = [0,1,2,9,10,11,18,19,20]
def getSet(i):
s, row, col = set(), int(i/9), i%9
corner = (int(row/3)*27) + (int(col/3)*3)
for i in range(9):
for j in [row*9+i, col+i*9, corner + mask[i]]:
s.add(sudoku[j])
return set("123456... |
cbbd4b8ca3392c0ec00beb14fa72cdf5a216ef68 | romanchemist/OOP | /venv/nasled.py | 413 | 3.640625 | 4 | class W:
def X(self):
print('W')
class A(W):
def X(self):
print('A')
super().X()
# W.X(self) # TAK NE PRAVIL'NO!!!
class B(W):
def X(self):
print('B')
super().X()
class C(A, B):
def X(self):
print('C')
super().X()
# super(A, sel... |
8985ffba7afdb929f137e63628f083393a9d62ae | faizanzafar40/Intro-to-Programming-in-Python | /2. Practice Programs/10. list_exercise.py | 248 | 4.40625 | 4 | '''
Take a list and write a program that prints out all the
elements of the list that are less than 13.
'''
test_list = [1, 1, 2, 3, 5, 8, 13, 21, 4, 55, 9]
for i in test_list:
if(i < 13):
print("Values from list less than 13: ", i)
|
302268553ff9220905c5d0cbddb3f65c651de782 | faelks/dh2321-group-vis | /data_handler/kth_social_usage_quantify.py | 1,397 | 3.71875 | 4 | from enum import Enum
import numpy as np
def get_social_usage_number(original_text):
social_usage = None
# Quantify the fixed options
# KTH Social is likely not going to be used for any interaction.
# I think that the lecturer explained that it will probably only
# used for checking the projects... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.