blob_id stringlengths 40 40 | repo_name stringlengths 5 119 | path stringlengths 2 424 | length_bytes int64 36 888k | score float64 3.5 5.22 | int_score int64 4 5 | text stringlengths 27 888k |
|---|---|---|---|---|---|---|
e30d4dc7efb2b204c93ba1aa5c08e52e7ebf3549 | preetha2711/CipherChecks | /ElGamal/ElGamal_Verify_Existential_Forgery.py | 462 | 3.609375 | 4 | file = open("public_key.txt", 'r')
q = int(file.readline())
g = int(file.readline())
h = int(file.readline())
file.close()
file = open("forged_sign.txt",'r')
r = int(file.readline())
signature = int(file.readline())
file.close()
file = open("plain_text_forgery.txt", 'r')
plain_text_forgery = int(file.readline())
file... |
e6d0b9eeee0bac49285e51228abafad76e7bc259 | SumaDabbiru/DS-and-Algorithms | /AlgoExpert/LongestPalindromicSubstring(1).py | 3,723 | 3.71875 | 4 | # def longestPalindromicSubstring(string):
# """
# did this comparing with longest peak
# return the length of longest palindrom string
# """
# longestlength = 0
# i = 1
#
# while i < len(string) - 1:
# ispeak = string[i - 1] == string[i + 1]
# while not ispeak:
# ... |
8ef0a6baf3995f49d8d005e68d6018ab67a34071 | shubhamnag14/Python-Documents | /Standard Library/gc/PyMOTW/05_When_Cycle_is_Broken.py | 1,037 | 3.625 | 4 | import gc
import pprint
class Graph(object):
def __init__(self, name):
self.name = name
self.next = None
def set_next(self, next):
print(f"Linking nodes {self}.next = {next}")
self.next = next
def __repr__(self):
return f"{self.__class__.__name__}, {self.name}"
... |
ad0635cfc98f860f3335577d5530a21f61340226 | raquelinevr/python | /Avaliaçoes/ATIVIDADE 6.py | 2,915 | 3.984375 | 4 | #C:\Users\Raqueline\AppData\Local\Programs\Python\Python37-32
Utilizando quaisquer dos comandos, funções e operadores vistos até a Semana 6,
faça programas Python para resolver as questões abaixo.
1. Nessa semana ocorrerá a 16a rodada do Brasileirão (Série A). Serão 10 jogos
envolvendo 20 times.
Faça um programa... |
b13053edae610db0dc23fc7364243ed12384d062 | CKZfd/LeetCode | /leetcode/141_hasCycle.py | 781 | 3.96875 | 4 | """
141、环形链表
给定一个链表,判断链表中是否有环。
为了表示给定链表中的环,我们使用整数 pos 来表示链表尾连接到链表中的位置
(索引从 0 开始)。 如果 pos 是 -1,则在该链表中没有环。
"""
"""
快慢指针、套圈
"""
# Definition for singly-linked list.
class ListNode:
def __init__(self, x):
self.val = x
self.next = None
class Solution:
def hasCycle(self, head: ListNod... |
7059034caa077941efa8b0e491f54555c1616a07 | jitendragangwar123/Python | /ex.py | 118 | 3.875 | 4 | num1,num2,num3=(input("enter the no: ").split(","))
print(f"avg of three no {(int(num1)+int(num2)+int(num3)) / 3}")
|
81ec3425a52ca917d5cacebd63ff7e4b3f16277d | adamny14/LoadTest | /test/as2/p1.py | 243 | 4.0625 | 4 | #-------------------------------------
# Adam Hussain
# print out squares of numbers until n
#-------------------------------------
n = input("Enter number: ");
counter = 1;
while counter <= n:
print(counter * counter);
counter = counter+1;
|
d6481e2ee0d8e2f4e20930b4b3aa547eab801060 | Alin0268/Functions_in_Python | /Linear_Search_(without_any_functions).py | 563 | 3.75 | 4 | # -*- coding: utf-8 -*-
"""Return index of key in mylist. Return -1 if key not present."""
# Вводим числа через пробел
mylist = input('Enter the list of numbers: ')
mylist = mylist.split()
mylist = [int(x) for x in mylist]
key = int(input('The number to search for: '))
indicator = 0
for i in range(len(mylis... |
5e51ec111c22407110292e8f7dd33c47c49e6398 | Nerdylicious/SquareAndMultiply | /squaremultiply.py | 323 | 3.796875 | 4 | import math
#z=x^c mod n
print "\nFormat is z=x^c mod n"
x = raw_input("\nEnter x: ")
c = raw_input("Enter c: ")
n = raw_input("Enter n: ")
x = int(x)
c = int(c)
n = int(n)
c = '{0:b}'.format(c)
z = 1
l = len(c)
for i in range(0, l):
z = (math.pow(z, 2)) % n
if (c[i] == "1"):
z = (z*x) % n
print "\nz = %d" % z... |
83a04176f1bb2fd3a22b8cf2b7a14451c00a994b | tarcisio-neto/PythonHBSIS | /Exercicios Python/Exercicio 52.py | 355 | 3.78125 | 4 | # 52- Faça um algoritmo que calcule e escreva a média aritmética dos números inteiros entre
# 15 (inclusive) e 100 (inclusive).
print('Média aritimética')
soma = 0
divisor = 101-15
for contador in range(15,101,1):
soma = soma + contador
media = (soma /divisor)
print('A média aritimética dos valores entre 15 e 100... |
52e3a08ef3f3d47195aeb7545f1f59aacc171472 | juhnowski/FishingRod | /production/pygsl-0.9.5/pygsl/block.py | 3,039 | 3.546875 | 4 | #!/usr/bin/env python
# Author : Pierre Schnizer
import _block
class _generic:
"""
Generic block class. Handles common operation.
"""
# Defines what basis type this class handles. To be defined in a derived
# class. e.g. base = 'vector'
_base = None
def _get_function(self, suffix):
... |
ce40115d1640232be66eba21ebefa4881582a9cd | kamaihamaiha/Tutorial | /python_tutorial/com/python/chapter9/demo2/user.py | 614 | 3.53125 | 4 | class User():
def __init__(self,first_name,last_name,age):
self.first_name = first_name
self.last_name = last_name
self.age = age
"""登录次数属性"""
self.login_attempts = 0
"""增加登录次数 1次"""
def increment_login_attempts(self):
self.login_attempts+=1
"""... |
d3150853d83d56baaee10e9ca75e9c17124059aa | autoolops/python-sh-ops | /day4/上课笔记/06 名称空间与作用域.py | 2,944 | 4.40625 | 4 | '''
1 名称空间Namespaces
存放名字与值绑定关系的地方
2 名称空间的分类
内置名称空间:
存放python解释器自带名字,比如内置的函数名:len,max,sum
创建:随着python解释器启动而创建
销毁:随着python解释器关闭而销毁
全局名称空间
存放文件级别的名字,比如x,f1,z
x=1
def f1():
y=2
if x == 1:
z=3
创建:文件开始执行时则立即创建
销毁... |
dd8ba1efa929ff16959eca2a972d800336c00a73 | hannesthiersen/zelle-2010 | /10-defining_classes/projectile_tests.py | 2,422 | 3.71875 | 4 | # File: projectile_tests.py
# Date: 2020-06-04
# Author: "Hannes Thiersen" <hannesthiersen@gmail.com>
# Version: 0.1
# Description:
# Testing projectile for problems by graphing the trajectories.
#------------------------------------------------------------------------------
# ... |
74753fe01ab5fb87d60b2b6425fb23a3e14ff4e8 | akshaybogar/DS-Algo | /linked list/doubly_linked_list/insertion.py | 1,737 | 3.703125 | 4 | class Node:
def __init__(self, data, next=None, prev=None):
self.data = data
self.next = next
self.prev = prev
class DoublyLinkedList:
def __init__(self):
self.head = None
def insert_at_beginning(self, data):
temp = Node(data)
if not self.head:
s... |
3893855bbb8d8fc779502b43bd5d735fd333966c | gc-ss/hy-lisp-python | /examples_translated_to_python/matplotlib/plot_relu.py | 245 | 3.6875 | 4 | import numpy as np
import matplotlib.pyplot as plt
def relu(x):
return np.maximum(0.0, x)
X = np.linspace(-8, 8, 50)
plt.plot(X, relu(X))
plt.title('Relu (Rectilinear) Function')
plt.ylabel('Relu')
plt.xlabel('X')
plt.grid()
plt.show()
|
9ab0d857e469cb07d47b677881655ed4a6d07ae6 | karbekk/Python_Data_Structures | /Interview/LC/Dynamic_Programming/198_House_Robber.py | 491 | 3.765625 | 4 | class Solution(object):
def rob(self, nums):
"""
:type nums: List[int]
:rtype: int
"""
even = 0
odd = 0
for i in range(0,len(nums)):
if i % 2 == 0:
even = even + nums[i]
even = even if even > odd else odd
... |
6214414b353fe5f4a7ea0272755ae9d959f38e1a | Tatsuro0726/MIT_DS | /practice_Ch3.py | 4,697 | 3.875 | 4 | # -*- coding: utf-8 -*-
# #完全立方の立方根を求める⇒3乗してそのxになるものを探している
# x = int(input('Enter an integer:'))
# ans = 0
# while ans ** 3 < abs(x):
# ans = ans + 1
# if ans ** 3 != abs(x):
# print(x, 'is not a perfect cube')
# else:
# if x < 0:
# ans = -ans
# print('Cube root of',x,'is',ans)
# # practice:p2... |
c968ff4a42eb9f3f60aaf5f6e211165c8ddd6eaa | shinkarenkoalexey/Python | /Labs/lab4/8.py | 107 | 3.703125 | 4 | n = int(input("n..."))
x = 0
y = 0
F = 1
for i in range(2, n+1):
x = y
y = F
F = x + y
print(F) |
136539ca6dae87fa2d0c1845a24a51bdc06ee8ec | kangnamQ/I_Do | /code/pytest2.py | 9,166 | 4.34375 | 4 | print("로봇공학 2주차-1")
print("")
string1 = "Life is too short"
string2 = 'You need python'
print(type(string1), type(string1))
#"",'' < 상관없이 str형
print("Life 'is' too short")
print('You "need" python')
#""와 ''를 구분해서 양쪽에 것과 다른 것을 사용
print("Life \"is\" too short,\nYou \'need\' python")
print("특수문자 \"로 \"자체가 ... |
488e8b099c4ecf77ef3159203e85fc99ea538212 | iamjai-3/python-scripts | /Python_Examples.py | 5,547 | 3.828125 | 4 |
# # Try, Except, Finally
# try:
# print(x)
# except:
# print("Error Occured")
# finally:
# c = 2+3
# print(c)
# #Value Validation
# def age(value):
# assert value>0 , "please give"
# print(value)
# inp = int(input("Enter no:"))
# age(inp)
# #Exception Info
# import sys
# a = [5,8,"d",9,7... |
9af235b9a87039cb34744903c34ae216daf48718 | summerbr/Class | /Week2-Python/phonebook_summerbr.py | 1,146 | 4.15625 | 4 | print('Electronic Phone Book')
print('=====================')
print('1. Look up an entry')
print('2. Add an entry')
print('3. Delete an entry')
print('4. List all entries')
print('5. Quit')
#add a function prompt to run again after selection run
#while selection != 5:
phonebook = {
'Harry': '895-3000',
'Ron': '89... |
912ad9da5a4281e4df332d909c8861f7a47eb3e6 | yingliufengpeng/python_design_pattern | /P6_Adapter_Pattern/__init__.py | 1,679 | 4 | 4 | import abc
class Player(abc.ABC):
# name = ''
def __init__(self, name):
self.name = name
@abc.abstractmethod
def attack(self):
pass
@abc.abstractmethod
def defense(self):
pass
class ForwardPlayer(Player):
def __init__(self, name):
super().__init__(name)... |
535dc454a2dd8105949a059dc2240115389b27b7 | reni04/IF1311-10219003 | /input user.py | 550 | 3.65625 | 4 | #episode input user
#data yang dimasukan pasti string
data = input("Masukan data : ")
print("data = ", data,",type =", type(data))
#jika kita ingin mengambil int maka
angka = float(input("Masukan angka:"))
print("angka float = ", angka,",type =", type(angka))
angka = int(input("Masukan angka:"))
print(... |
53ed9bb2854e5617fbb47e6c0be485321cb160ff | xbouteiller/DetectBrokenSensor | /ConvertDXD/EmptyList.py | 1,869 | 4.1875 | 4 | def EmptyListofFiles():
'''
# function for crating an empty list for the first day
# should evaluate if file exists and creat it only if file not exists
'''
import os
import pickle
if not os.path.isfile("ListOfFiles.txt"):
ListOfFiles=[]
with open("ListOfFiles.txt"... |
9a2c2af86c6b6dba2151e8f6e5df45fb12a28615 | JosiahRooney/Python | /bubble_sort.py | 572 | 4.03125 | 4 | import random
numbers = []
for i in range(0,100):
numbers.append(round(random.random() * 10000))
print('before ' + str(numbers))
def bubble_sort(input_list):
is_sorted = False
while not is_sorted:
is_sorted = True
for (idx, num) in enumerate(input_list):
if idx < len(input_list... |
285a15c0eac1f172f0f3fb033360219e79f6d4bd | dougal428/Daily-Python-Challenges | /Challenge 19.py | 3,082 | 3.84375 | 4 | #Question 19
#This problem was asked by Facebook.
#A builder is looking to build a row of N houses that can be of K different colors. He has a goal of minimizing cost while
#ensuring that no two neighboring houses are of the same color.
#Given an N by K matrix where the nth row and kth column represents the ... |
fb86da14c1eabad139837643f81093f233ffeaa7 | joshianshul2/Python | /arrayfac.py | 251 | 3.703125 | 4 | n=int(input("Enter a No in List "))
a=[]
f=1
print("Enter a No in Array ")
for i in range(n) :
x=int(input())
a.append(x)
for i in range(n):
f=1
b=a[i]
while b>=1 :
f=f*b
b-=1
print("Factorial No is :",f)
|
70086aae3b4f078999a46020021e27296baef025 | hyejun18/daily-rosalind | /prepare/template_scripts/algorithmic-heights/CC.py | 595 | 3.59375 | 4 | ##################################################
# Connected Components
#
# http://rosalind.info/problems/CC/
#
# Given: A simple graph with n <= 10^3 vertices
# in the edge list format.
#
# Return: The number of connected components in
# the graph.
#
# AUTHOR : dohlee
############################################... |
7837432a247ea8553f85e18afd55b490641b8519 | mohsas/PythonScripts | /w2z6.py | 494 | 3.765625 | 4 | <#EBieleninikPWr WIZ136. Napisać program, który tworzy listę 20 liczb
wg poniższego schematu:fn= 2 dla n = 0
1 dla n = 1
fn-1+ fn-2 dla n > 2
Na podstawie pierwszej listy tworzy listę drugą wypełnioną wg schematuf2/f1, f3/f2, ........ fn/fn-1Wyświetla obie listy.Uwaga: Wykorzystać informacje
o lis... |
6ec9aeef4a23f6522b65f6a1af01eeec9664973c | nyashasimango/Practical-Security- | /Lab+Assignment+Ceaser+Cipher.py | 3,752 | 4.15625 | 4 |
# coding: utf-8
# In[4]:
#Function to encrypt
def encrypt(a,b):
h=int(a)
i=int(b)
result=((i+h)%26)
return result
#Function to decrypt
def decrypt(a,b):
h=int(a)
i=int(b)
result=((i-h)%26)
return result
#Function to start execution
def calculate():
x=3
v= int(input("select (1.... |
3cd6ed59195671eeb146f1545860aabce47ece9e | SonaliChaudhari/Chaudhari_Sonali_spring2017 | /Assignmen_3_001285029/Q2/Q2_1_Final.py | 1,010 | 3.5625 | 4 |
# coding: utf-8
# # Question 2 Part 1
# In[1]:
#importing all the required lib
import string
import csv, sys
from pandas import Series, DataFrame
import pandas as pd
# In[2]:
# reading the csv file using pandas
df = pd.read_csv('Data/employee_compensation.csv')
# Retrieving only the required columns
s = pd.Dat... |
92e80904bfe060dbf72fb08d2ce94f864cc3f1e4 | MukundaRachamalla/veggie_store | /veggiestore.py | 3,651 | 4.21875 | 4 | print("**********welcome to veggie store**********")
cart = {}
def menu():
mainmenu()
def mainmenu():
print("vegetables:price per kg")
avail_veg = {"carrot":50,"onion":30,"brinjal":30,"tomato":60,"":"",}
print(avail_veg)
choose =input("select vegetables you want to buy")
if choose == "carrot" :
... |
2302452868b51ca7a15f7d1bbff43378dfaca150 | vova0808/KPI-Python-tasks | /lab4_2.py | 456 | 4.0625 | 4 | """
Input data: an arbitrary, greater than zero quantity of arguments
Arguments may be a numbers or a strings, that may contain numbers and letters
without spaces
Output: a string, that consisiting of recieved values in reversible order,
recorded through a gap. The space in the end of string is absent.
"""
... |
c08d4d681005185bc85e521e05eb12f46fc6da02 | Louisee607/Projects | /Projects/exo4.py | 665 | 3.8125 | 4 | import matplotlib.pyplot as plt
quantity= []
y_utility= []
print('Please enter a product')
product = input()
print('Please enter the maximum quantity')
max = int(input())
i = 0
while (i < max):
print('For',max - i,product,' what added level hapiness do you ?')
quantity.append(max - i)
y_utility.append(int(... |
1c922b07b6b1f011b91bc75d68ece9b8e2958576 | Leah36/Homework | /python-challenge/PyPoll/Resources/PyPoll.py | 2,168 | 4.15625 | 4 | import os
import csv
#Create CSV file
election_data = os.path.join("election_data.csv")
#The list to capture the names of candidates
candidates = []
#A list to capture the number of votes each candidates receives
num_votes = []
#The list to capture the number of votes each candidates gather
percent_votes = []
#... |
92128117095fef38864f9a86a2298b4eea9a7829 | Taraslut/cs50_train | /week6/demo_f_float.py | 88 | 3.671875 | 4 |
change = int(input("Enter your change >> "))
print(f"In 10 years you have {change}") |
f9f415c527cd91765921a9f7d2b66b4634e9e598 | richnakasato/ctci-py | /3.1.three_in_one.0.py | 2,544 | 3.5 | 4 | import random
class TripleStack():
def __init__(self):
self.data = [None] * 9
self.stack_max = 3
self.growth = 2
self.stack_starts = [x * self.stack_max for x in range(3)]
self.stack_sizes = [0] * 3
def __str__(self):
outstring = ''
for idx in range(3):... |
0614b7b5abd5368e3c15150b9cc21817ac9d3496 | namnamgit/pythonProjects | /aumento_salariov3.py | 609 | 3.78125 | 4 | # rodrigo, apr2513
# escreva um programa que pergunte o salário do funcionário e calcule o valor do aumento.
# para salários superiores a r$ 1.250,00 calcule um aumento de 10%. para os inferiores ou iguais, de 15%
while True:
salario = float(input('Salário: '))
if salario > 1250.00:
aumento = salario * 10 / 100
... |
6ce6baee09019f8e127601c54ad3f728bac53183 | nishantchaudhary12/w3resource_solutions_python | /Dictionary/concatenatingDict.py | 359 | 3.765625 | 4 | #Write a Python script to concatenate following dictionaries to create a new one
def concatenate(dic1, dic2, dic3):
dic_new = dict()
for dic in dic1, dic2, dic3:
dic_new.update(dic)
print(dic_new)
if __name__ == '__main__':
dic1 = {1: 10, 2: 20}
dic2 = {3: 30, 4: 40}
dic3 = {5: 50, 6... |
855472636b00dff2a60b752663b3b4c111e359ca | Galahad3x/AdventOfCode2020 | /day01/parse_input.py | 182 | 3.515625 | 4 | filename = "input.txt"
inputs = []
with open(filename, "r") as f:
for line in f.readlines():
if line != '\n':
inputs.append(line[:-1])
print("[" + ",".join(inputs) + "]")
|
b3485a4c37b6db7f00790d73a340f270d58c356d | AlexandrZhytenko/solve_tasks | /word_game.py | 614 | 4.15625 | 4 | # function will receive a positive integer and return:
# "Fizz Buzz" if the number is divisible by 3 and by 5
# "Fizz" if the number is divisible by 3
# "Buzz" if the number is divisible by 5
# The number as a string for other cases
def word_game(number):
result = ["Fizz Buzz", "Fizz", "Buzz"]
if number % 3 ==... |
298a2b4897fed56f276d274fb028e64c11e8e54a | chuliuT/Python3_Review | /LeetCode小卡片/code/转盘锁.py | 1,322 | 3.5625 | 4 | # -*- coding: utf-8 -*-
"""
Created on Wed Jul 22 22:37:09 2020
@author: TT
"""
from typing import List
class Solution:
def openLock(self, deadends: List[str], target: str) -> int:
deadends = set(deadends)#转为 set 保证唯一
if '0000' in deadends: return -1 # 初始的值不能为 deadends
# BFS
... |
cbf52a4106f02879428506a99236d6bfd55d291c | sanjoycode97/python-programming-beginners | /python tutorial/arithmatic progression/print the sum of n/python programming practice/series.py | 169 | 3.78125 | 4 | sum=0
for i in range(1,11):
sum=sum+1/i
print(1/i)
print(sum)
def fact(i):
fact=1
for x in range(1,i+1):
fact=fact*x
return fact
ft=fact(i)
print(ft) |
bcbc621c951529f4c57a0ed80521f44cb8cf103b | camila-2301/EXAMEN-FINAL-PYTHON | /TRABAJO FINAL ADRIANA ARANIBAR PYTHON/ARCHIVOS PYTHON/MODULO3/credit.py | 607 | 3.5 | 4 | def prob5(numero):
AMEX = [34, 37]
MASTERCARD = [51, 52, 53, 54 , 55]
def convert(numero2):
lista = [ int(x) for x in list(str(numero2)) ]
return sum(lista)
num = str(numero)
size = len(num)
suma = 0
for i in range(size-2, -1, -2):
suma += convert(int(num[i])*2)
for i in range(size-1, -1,... |
3c380645262b8c236620f4e23db990b0107d99b0 | SNithiyalakshmi/pythonprogramming | /Beginnerlevel/rev.py | 77 | 3.8125 | 4 | b=int(input("enter the number"))
print("\n",''.join(list(reversed(str(b)))))
|
b9342b4aa75e39854d2bfc10991a48ca9083f449 | sonushakya9717/Hyperverge__learnings | /sorting/merge_sort.py | 687 | 4.03125 | 4 | ############ Merge Sort #########
def merge(left,right):
sorted_lst=[]
i=0
j=0
while i<len(left) and j<len(right):
if left[i]<right[j]:
sorted_lst.append(left[i])
i+=1
else:
sorted_lst.append(right[j])
j+=1
while i<len(left):
... |
d7de9f54e70e6ed79128dd545a6261ed18c64340 | hideyk/CodeWars | /Python/Detect Pangram.py | 306 | 3.96875 | 4 | import string
def is_pangram(s):
alphabet = set(string.ascii_lowercase)
return set(s.lower()) >= alphabet
def is_pangram2(s):
return set(string.lowercase) <= set(s.lower())
text = "The quick brown fox jumps over the lazy dog"
text_is_pangram = is_pangram(text)
print(text_is_pangram) |
aab4da2d4a91d9eca0b71c77a88962938a2529b0 | Swati213/pythonbasic | /billing/discount.py | 215 | 3.640625 | 4 | item = input("Enter the total item = ")
discount = input("Enter the discount allowed = ")
amount = input("Enter the total amount = ")
grandtotal = amount-(amount*discount/100)
print grandtotal, "Grand total"
|
c37be9530016679e1b6ad28fe215e52e5ad2a03d | JuanRx19/TallerFinal | /Ejercicio 1.py | 155 | 3.703125 | 4 | b = eval(input("Por favor digite la base: "))
h = eval(input("Por favor digite la altura: "))
a = (b*h)/2
print("El area del triangulo es: " + str(a)) |
fe76456be7816873ed9a8349c4e5f93e3f48e10e | iqballm09/python_proj-team-dta | /module/ConvNumSys.py | 4,839 | 3.71875 | 4 | # Program Konversi Satuan Bilangan
# Pengaturan Input diatur dalam program utama apakah string/int
class NumberSysConverter:
def __init__(self):
self.__input = 0
def destodes(self, val):
self.__input = val
return self.__input
def hextohex(self, val):
self.__input = val
... |
3e972116cb124d8175735b008efcd2ec1df8ff80 | brucekevinadams/Python | /NormalDistribution.py | 1,398 | 4.21875 | 4 | # Python 3 code
# Bruce Adams
# austingamestudios.com
# ezaroth@gmail.com
# Program problem from Hackerrank.com
# In a certain plant, the time taken to assemble a car is a random variable, X,
# having a normal distribution with a mean of 20 hours and a standard deviation of 2 hours.
# What is the probability that a c... |
c6a7ca613a9ca94fca9947f02ea16a2b8670842a | inergoul/boostcamp_peer_session | /coding_test/testdome_python_interview_questions/3_BinarySearchTree/solution_anna.py | 412 | 3.65625 | 4 | import collections
Node = collections.namedtuple('Node', ['left', 'right', 'value'])
def contains(root, value):
dq = collections.deque([root])
while dq:
cur = dq.popleft()
if not cur:
continue
if cur.value == value:
return True
if cur.value > value:
... |
713b611e63ca60799b7b775272f54da86ae7ee6c | JpBongiovanni/PythonFunctionLibrary | /commaCode.py | 580 | 4.09375 | 4 |
# def commaCode(list):
# for x in range(len(list)-1):
# print(list[x] + ",", end= " ", sep=', ')
# commaCode(['apples', 'bananas', 'tofu', 'cats'])
# def commaCode(list):
# print(*range(len(list)), sep=", ")
# commaCode(['apples', 'bananas', 'tofu', 'cats'])
def commaCode(list):
for x in range(... |
f75fad306ee7cdaf4cf588fb16c6c64c99e86bc6 | DaHuO/Supergraph | /codes/CodeJamCrawler/16_0_3_neat/16_0_3_Q112_Program.py | 1,409 | 3.703125 | 4 | import sys
import os
from itertools import *
Out = open(os.path.dirname(os.path.abspath(__file__))+'/'+sys.argv[2],'w')
if sys.argv[1] == 'Test':
N, J = 6,3
elif sys.argv[1] == 'Small':
N, J = 16, 50
elif sys.argv[1] =='Large':
N, J = 32, 500
else:
print('Please enter one of the three options Test, Sma... |
96d953fcdcc787ab8d45849d96d75773023859b3 | xingyazhou/Data-Structure-And-Algorithm | /DynamicProgramming/climbStairs.py | 1,278 | 4.125 | 4 | # -*- coding: utf-8 -*-
"""
Created on Tue Sep 29 11:24:36 2020
70. Climbing Stairs (Easy)
You are climbing a stair case. It takes n steps to reach to the top.
Each time you can either climb 1 or 2 steps. In how many distinct ways can you climb to the top?
Example 1:
Input: 2
Output: 2
Explanation: There are two way... |
43d2382caa4d00514bce028adbfef36688b28b49 | ZainebPenwala/leetcode-solutions | /self_dividing_number.py | 955 | 4.15625 | 4 | '''A self-dividing number is a number that is divisible by every digit it contains.
For example, 128 is a self-dividing number because 128 % 1 == 0, 128 % 2 == 0, and 128 % 8 == 0.
Also, a self-dividing number is not allowed to contain the digit zero.
Given a lower and upper number bound, output a list of every possibl... |
defd32cc6432d12f64ba0abee16531f28431c718 | Ivan-yyq/livePython-2018 | /day12/demon8.py | 506 | 3.671875 | 4 | #!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time : 2018/4/29 23:55
# @Author : yangyuanqiang
# @File : demon8.py
import codecs
ENCODING = "utf-8"
with codecs.open("1.txt", "r", encoding=ENCODING) as f:
print(f.read())
a = lambda x: x*x
print(a)
print([x for x in range(1, 10) if x%2==0])
def startEnd... |
e83f41251e229f5df29ff4dd7f4718cdaca753cb | zacharydenton/montyhall | /montyhall.py | 1,180 | 3.796875 | 4 | #!/usr/bin/env python3
import random
def new_game():
game = [("closed", "goat"), ("closed", "goat"), ("closed", "car")]
random.shuffle(game)
return game
def others(game, choice):
return [i for i, _ in enumerate(game) if i != choice]
def closed(game):
return [i for i, (status, _) in enumerate(g... |
e6c43eb53003b3c27c03efcb030a0d7203afccc2 | airje/codewars | /sprayingtrees.py | 358 | 3.640625 | 4 | def task(w,n,c):
dict={'Monday':'James', 'Tuesday':'John', 'Wednesday':'Robert',
'Thursday':'Michael', 'Friday':'William', 'Saturday':'James',
'Sunday':'John'}
for k,v in dict.items():
if k==w:
return f'It is {w} today, {v}, you have to work, you must spray {n} trees and... |
51677e0add84760f65c0a8c4fde7e3a82eeb92f4 | westgate458/LeetCode | /P0152.py | 2,105 | 3.765625 | 4 | # -*- coding: utf-8 -*-
"""
Created on Mon May 20 14:50:31 2019
@author: Tianqi Guo
"""
class Solution(object):
def maxProduct(self, nums):
"""
:type nums: List[int]
:rtype: int
"""
# maintain three running records
# minimum product including current number
... |
aabe12abfd09d1f6e8b71850eaddf64e797131d5 | aishwat/missionPeace | /graph/topologicalSort.py | 871 | 3.90625 | 4 | from collections import defaultdict
class Graph:
def __init__(self, vertices):
self.V = vertices
self.graph = defaultdict(list)
def addEdge(self, u, v):
self.graph[u].append(v)
def topological_sort(self):
visited = [False] * self.V
stack = []
for i in ran... |
aaefaff964fcb0ed619bbf5b31803f86cc7bba0b | ethem5234/TICT-VrPROG-15 | /les04/ExtraOpdracht 4_1.py | 215 | 3.921875 | 4 | temp= eval(input('wat is de temperatuur vandaag: '))
if temp <= 0:
print('Het vries vandaag')
elif temp >0 and temp <= 15:
print('Het is koud vandaag')
elif temp >15:
print('Het is lekker vandaag') |
e7b7fc883dd87c9e4c3a81a3942b1a344db2beba | arthurdysart/HackerRank | /programming/algorithms/strings/the_love_letter_mystery/python_source.py | 4,609 | 3.78125 | 4 | # -*- coding: utf-8 -*-
"""
HackerRank - The Love-Letter Mystery
https://www.hackerrank.com/challenges/the-love-letter-mystery
Created on Wed Dec 5 19:53:42 2018
@author: Arthur Dysart
"""
## REQUIRED MODULES
import sys
## MODULE DEFINITIONS
class Solution:
"""
Iteration over all characte... |
a3c23efec284f5d0f07895f07e839a9fdcc0c83b | prodseanb/Income-Expense-Budget-Analysis | /income_vs_expenses.py | 2,230 | 3.59375 | 4 | # -*- coding: utf-8 -*-
"""
Created on Sat Feb 27 20:56:37 2021
Income/Expense Line Graph Budget Analysis
@author: Sean Bachiller
"""
import matplotlib.pyplot as plt
# plot 1 values
x1 = ["Month 1","Month 2","Month 3", "Month 4", "Month 5", "Month 6"]
y1 = []
# plot 2 values
x2 = ["Month 1","Mont... |
8a7ac82a81fc894595e299d93b9fc7f42850dea7 | cristinamais/exercicios_python | /Exercicios Colecoes Python/exercicio 19 - secao 07 - p1.py | 268 | 3.71875 | 4 | """
19 - Faça um vetor de tamanho 50 preenchido com o seguinte valor: (i+5*i)%(i+1), sendo i a posição do elemento no vetor.
Em seguida imprima o vetor na tela.
"""
vetor = []
for i in range(50):
vetor.append((i+5*i) % (i+1))
print(f'Vetor[{i}]:{vetor}')
|
35e1541e0d41081f37272c761716e05e55e6c901 | BomberDim/Python-practice | /examples№2/task3/v3pr11_and_17.py | 263 | 4.09375 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
a = int(input("a = "))
b = int(input("b = "))
c = int(input("c = "))
if a % 2 == 0 or b % 2 == 0 or c % 2 == 0:
print("Имеются четные числа")
else:
print("Четных чисел нет")
|
0d09ccf67899a9189b9b2502f6b49e6e0bc1aea6 | fpischedda/lsystem | /src/core/user.py | 4,086 | 3.59375 | 4 | # module that define a User object
# a user has list of plants, a credit balance
# and a list of items to use
__author__ = "francescopischedda"
__date__ = "$27-mag-2011 17.04.07$"
from plant import Plant
from environment import Environment
from item import Item
def new_user(username, password, email):
"""
c... |
6f617328ea10c433af7511f65d809cc5dba90986 | jachymb/python2modelica_tests | /testcases/test_0005.py | 249 | 3.71875 | 4 | # Simple test for if statement.
# Returns the absolute value of a 'float'.
# The code is intentionaly redundant to use
# the 'elif' branch.
def abs0005(r):
if r > 0:
return r
elif r < 0:
return -r
else
return 0
|
3dadbed299ace690289242b034fcc6f141cc478f | ereynolds123/introToProgramming | /password.py | 400 | 4.25 | 4 | while True:
password = input("Enter your new password: ")
while True:
if len(password) >=7:
break
print("Your password must be at least 7 characters.")
password= input("Enter your new password: ")
secondPassword = input("Enter your password again: ")
if secondPas... |
545f2e965205889354480b64dff0368da70bcdb7 | TravisDvis/SURF2020 | /Gissenger/Rescale.py | 546 | 3.65625 | 4 | import numpy as np
def rescale(xMatrix):
while True:
rescaled_xMatrix = np.array(xMatrix,copy=True)
x = str(input("Do you want to rescale the dipole values? (Y/N): "))
if x == "Y" or x == "y":
max = np.mean(abs(rescaled_xMatrix[1][:]))
rescaled_xMatrix[1][:] = resca... |
8582f222117a17b6383276740a1e189c8837d8ac | dablackwood/my_scripts_project_euler | /specific_solutions/project_euler_059.py | 3,284 | 4.375 | 4 | """
Each character on a computer is assigned a unique code and the preferred
standard is ASCII (American Standard Code for Information Interchange).
For example, uppercase A = 65, asterisk (*) = 42, and lowercase k = 107.
A modern encryption method is to take a text file, convert the bytes to
ASCII, then XOR each byte... |
bc9ed8a112a5dd8c9c0c4e1a3f308a3cf39e25c0 | tsankesara/CodeChef-Submissions | /Beginner/Byte to Bit - BITTOBYT.py | 781 | 3.9375 | 4 | ##Username: chefteerth ## https://www.codechef.com/users/chefteerth
#Question URL: https://www.codechef.com/problems/BITOBYT
# Problem Name: Byte to Bit
# Problem Code: BITOBYT
# Programming Lang: Python3
def BytetoBit(Test):
for i in range(Test):
N = int(input())
ans=0
k=0
bit,ni... |
63cf20d96eff8cf98cde846eb497b7735356c1f4 | learn-cloud/cisco | /EE/api.py | 148 | 3.828125 | 4 | a = 10
b = 20
c = a+b
print('------------------------------')
print ("adittion of two numbers is: ",c)
print('------------------------------')
|
3e1d911ae8fac586903da2bdd28dd8f8e26d94ea | gundlacc/CS362-Testing-Project | /datetime_helper.py | 2,865 | 3.9375 | 4 | from math import floor
def initial_date_calc(total_days, four_years, years_passed, extra_days):
if total_days >= four_years:
years_passed = floor(total_days / four_years)
years_passed = years_passed * 4
extra_days = total_days % four_years
else:
if total_days < 365:
... |
4b0df9a0deb4143a7c6fdb4a349c057d1df04945 | davidenoma/python-introduction | /fifth_class_assignment.py | 2,226 | 3.828125 | 4 | import random
def main():
cities = ['New york','Boston', 'Atlanta', 'Dallas']
outfile = open('cities.txt','w')
for item in cities:
outfile.write(item + '\n')
outfile.close()
#Question1
file = open('number_list.txt', 'a')
for i in range(1,6):
file.write(str(i)+"\n")... |
0d964d588e0e52d69ce2522bace27594c421ae60 | nikatov/tmo | /prog4.py | 4,479 | 3.875 | 4 | # -*- coding: utf-8 -*-
# +-------------------------------+
# | Многоканальная СМО без |
# | ограничений на длину очереди, |
# | но с ограниченным временем |
# | ожидания в очереди. |
# +-------------------------------+
from math import factorial
import matplotlib.pyplot as plt
def multiply(lst)... |
3d5d2f3ae9d0eb0c1eb6cceec6d13b049a674d25 | sugengriyadi31/python | /if else.py | 521 | 3.65625 | 4 | nilai = 101
if nilai >=80 and nilai <=100:
print("Nilai kamu A")
elif nilai >=75 and nilai <80:
print("Nilai Kamu B+")
elif nilai >=70 and nilai <75:
print("Nilai Kamu B")
elif nilai >=65 and nilai <70:
print("Nilai Kamu C+")
elif nilai >=60 and nilai <65:
print("Nilai Kamu C")
elif nilai >=55 and ... |
ed79efb3dfd620f4e0f6a0dcf726f0e821221f2d | sr-utkarsh/python-TWoC-TwoWaits | /day_6/13th.py | 530 | 3.8125 | 4 |
n=int(input("Enter the size of list: "))
A=[]
print("Enter the elements: ")
for i in range (n):
el=float(input())
A.append(el)
A.sort()
flag=0
for i in range(0,n-2):
j=i+1
k=n-1
while (j < k):
if( A[i] + A[j] + A[k]>1 and A[i] + A[j] + A[k]<2):
print(A[i]," ",A... |
5081a058ad5e0c021702d4812a05a31f621e7dda | fabriciovale20/AulasExercicios-CursoEmVideoPython | /Exercícios Mundo 3 ( 72 à 115 )/ex098.py | 1,142 | 4.15625 | 4 | """
Exercício 98
Faça um programa que tenha uma função chamada contador(), que receba três parâmetros: início, fim e passo e realize
a contagem.
Seu programa tem que realizar três contagens através da função criada:
a) De 1 até 10, de 1 em 1;
b) De 10 até 0, de 2 em 2;
c) Uma contagem personalizada.
"""
from ... |
a407ec5976ad6ad812b5d636f3e252d931854fe9 | anobhama/Intern-Pie-Infocomm-Pvt-Lmt | /OOPS concept/multiple_inheritance.py | 863 | 3.765625 | 4 | # -*- coding: utf-8 -*-
"""
Created on Fri Aug 14 10:44:26 2020
@author: Anobhama
"""
#multiple inheritance
#many base classes in a single child classes
class room:
def __init__(self,length,breath):
self.length = length
self.breath = breath
def arearect(self):
area = self.length * self.... |
b9777587a1a396d8c062a0158589af1d62e0e6e0 | fernandopreviateri/Exercicios_resolvidos_curso_em_video | /ex069.py | 1,042 | 4.09375 | 4 | '''Crie um programa que leia a idade e o sexo de várias pessoas. A
cada pessoa cadastrada, o programa deverá perguntar se o usuário
quer ou não continuar. No final, mostre:
a) Quantas pessoas tem mais de 18 anos;
b) Quantos homens foram cadastrados;
c) Quantas mulheres tem menos de 20 anos.'''
print('CADASTRO DE ... |
9abebc1e539c54df6e0083992260420efad3cca7 | MuratArda-coder/Python_Tutorials | /Python_Tutorials/Lab5/Lab5.6.py | 152 | 3.65625 | 4 | #!/usr/bin/python3
a = int(input("a= "))
d = int(input("d= "))
n = int(input("n= "))
sum1 = 0
for index in range(n):
sum1 += a+(index*d)
print(sum1)
|
e79f7059e10ce9e651e65dafca68e33c4d37b6e6 | BackToTheStars/Theano_Keras | /Theano/Keras/mnist.py | 5,126 | 3.5 | 4 | #%% #creates separate cell to execute
from keras.datasets import mnist #import MNIST dataset
from keras.models import Sequential #import the type of model
from keras.layers.core import Dense, Dropout, Activation, Flatten #import layers
from keras.layers.convolutional import Convolution2D, MaxPooling2D #import... |
96df16c30d124979cacaf4ccc22ec8ab0f139090 | AnvilOfDoom/PythonKursus2019 | /Bogopgaver/Kap 8/8-14.py | 1,022 | 4.5 | 4 | """8-14, Cars
Write a function that stores information about a car in a dictionary. the function
should always receive a manufacturer and a model name. It should then accept an
arbitrary number of keyword arguments. Call the function with the required
information and two other name-value pairs, such as a color or an op... |
88f81b42ef2beae05b568a289a42d203370a7df9 | kartikay89/Python-Coding_challenges | /getAvgDifficulty.py | 1,848 | 3.703125 | 4 | """
While submitting each task I ask you "how difficult was this it?" in order to adjust the difficulty level of
next tasks. Write a function called get_avg_difficulty(list_of_lists) that takes as input a list of lists ,
for example l = [[1,0,8,4], [2, 5, 6, 2], [8,8,1,7], ..., [1,9,4,5]] where each list in l shows th... |
7e65c5af3e44a17fea767e2bb985ccb23de2522d | francososuan/3-PracticePythonOrg | /8-MaxofThree.py | 479 | 4.25 | 4 | num_1 = input("Please input first number: ")
num_2 = input("Please input second number: ")
num_3 = input("Please input third number: ")
print("First Number: {}" .format(num_1))
print("Second Number: {}" .format(num_2))
print("Third Number: {}" .format(num_3))
if num_1 >= num_2 and num_1>=num_3:
print("Highest Num... |
ce197b8a5bf612cb2cbfa5fe4496bdb76d4489b8 | ehnana/Data-Analysis-Notebook | /DataManagement/Pandas_Data.py | 1,304 | 3.984375 | 4 | # Import pandas package
import pandas as pd
# Import Data
data = pd.read_csv("country_vaccinations.csv")
# Activate column names
pd.set_option('display.max_columns', None)
# Three first line
Three_first_line = data.head(3)
# Dataframe column
print(data.columns)
# Columns to drop
to_drop = ['source_name', 'source_w... |
c6fce2951e9edca3a9d6107e567a1ff3d6adbb0d | c940606/leetcode | /297. Serialize and Deserialize Binary Tree.py | 3,511 | 4.0625 | 4 | # Definition for a binary tree node.
# class TreeNode(object):
# def __init__(self, x):
# self.val = x
# self.left = None
# self.right = None
class Codec:
def serialize(self, root):
"""Encodes a tree to a single string.
:type root: TreeNode
:rtype: strt
... |
0b57619f0973cc13ecf7bdaa9651429d8b773ea5 | pondycrane/algorithms | /python/tree/preorder/split_bst.py | 2,025 | 3.796875 | 4 | import collections
from typing import List
import base.solution
from lib.ds_collections.treenode import TreeNode
class Solution(base.solution.Solution):
def split_bst(self, root: List[int], V: int) -> List[List[int]]:
root = TreeNode.deserialize(root)
def preorder(node):
if no... |
ac36b419700cc844f3ddeca1da85ea1935932a7b | snmsaj/Digital-Craft | /Week-2/Day-3/apphend-to-file.py | 294 | 3.703125 | 4 | file = open("I-love-programming.txt", "w")
file.close()
while True:
reason = input("Enter a reason why you like programming or press q to quit: ")
if reason == "q":
break
else:
with open("I-love-programming.txt", "a") as file:
file.write(f"{reason}\n") |
3330f1440cc95fa25babd711441e16a2fd3e328e | mfarizalarfn/Pertemuan9-praktikum4 | /membuat list-module4.py | 1,215 | 4.09375 | 4 | print("===================================================================")
print("Nama : Mohamad Farizal Arifin")
print("NIM : 312010231")
print("Kelas : TI.20.B1")
print("Mata Kuliah : Bahasa Pemrograman")
print("===================================================================")
# membuat list
print("Buat sebuah ... |
11b75ccb3fdedf546c5aea49970fcd65798049b5 | joelstanner/codeeval | /python_solutions/ARMSTRONG_NUMBERS/ARMSTRONG_NUMBERS.py | 979 | 4.53125 | 5 | """
An Armstrong number is an n-digit number that is equal to the sum of the n'th
powers of its digits. Determine if the input numbers are Armstrong numbers.
INPUT SAMPLE:
Your program should accept as its first argument a path to a filename. Each
line in this file has a positive integer. E.g.
6
153
351
OUTPUT SAMP... |
1ba06c10324ab01de9bc4ea3eeb0a57f009b34f7 | DerickMathew/adventOfCode2020 | /Day11/01/solution.py | 1,707 | 3.765625 | 4 | def getLines():
inputFile = open('../input.txt', 'r')
lines = inputFile.readlines()
return map(lambda line: line.split('\n')[0], lines)
def getNeigbourCount(seatingMap, x, y):
neighbourCount = 0
for neighbourY in xrange(y-1, y+2):
for neighbourX in xrange (x-1, x+2):
if 0 <=neighbourX < len(seatingMap[0]) a... |
c3a5f8d923cefb0fd79299b792a75636fb869f5f | ikaushikpal/Hacker_Rank_Problems | /Problem solving/A Chessboard Game/A Chessboard Game.py | 378 | 3.734375 | 4 | def chessboardGame(x, y):
x = x % 4
y = y % 4
if((y == 0) or (y == 3) or (x == 0) or (x == 3)):
return "First"
else:
return "Second"
if __name__ == '__main__':
t = int(input())
for t_itr in range(t):
xy = input().split()
x = int(xy[0])
y = int(xy[1])
... |
6844afb8a6115ed169881367b72ea73c5ef58b06 | Kanefav/exercicios | /ex073.py | 521 | 3.71875 | 4 | times = ('Flamengo', 'Santos', 'Palmeiras', 'Grêmio', 'Athletico-PR',
'São Paulo', 'Internacional', 'Corinthians', 'Fortaleza', 'Goiás',
'Bahia', 'Vasco', 'Atlético-MG', 'Fluminense', 'Botafogo', 'Ceará',
'Cruzeiro', 'CSA', 'Chapecoense', 'Avaí')
print('-='* 20)
print(f'Lista de times do Bras... |
0c664f1c39d04d1fd674edaf096095757a523160 | sarmisthamaity/pythonLogicalquestion | /addreturn.py | 1,939 | 3.984375 | 4 | # def add_numbers(number_x, number_y):
# number_sum = number_x + number_y
# return number_sum
# sum1 = add_numbers(20, 40)
# print (sum1)
# sum2 = add_numbers(560, 23)
# a = 1234
# b = 12
# sum3 = add_numbers(a, b)
# print (sum2)
# print (sum3)
# number_a = add_numbers(20, 40) / add_numbers(5, 1)
# print (numb... |
2f244d77e648c7dbe3cb48499c71bd0dd1433252 | laszlokiraly/LearningAlgorithms | /ch04/dynamic_heap.py | 2,742 | 4.15625 | 4 | """
max binary Heap that can grow and shrink as needed. Typically this
functionality is not needed. self.size records initial size and never
changes, which prevents shrinking logic from reducing storage below
this initial amount.
"""
from ch04.entry import Entry
class PQ:
"""Priority Queue implemented using a heap... |
19e181501bc3fccaad883557870bff7421a53c12 | kogos/Scipy_codes | /input.py | 818 | 3.921875 | 4 | __author__ = 'stephen'
from object_task import *
"""
#def f(shape, length, width):
#=['rectangle', '5', '4']
a = ['', '', '']
a[0] = input("Enter the shape")
a[1] = input("Enter the length")
a[2] = input("Enter the width")
a[0] = str.capitalize(a[0])
a[1] = float(a[1])
a[2] = float(a[2])
c = 'a[1], a[2]'
#b = {'a[0]':... |
ff5c7c9415bd7bb1447644414dc454c7cf82ffc7 | ivansharma/snake_coder | /Python in general/supermarket.py | 126 | 3.65625 | 4 | produce_department = input('Would you like to buy someting from the produce department? ')
if input yes:
bill = bill + 2
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.