blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string |
|---|---|---|---|---|---|---|
9263e3ad0f5c0a7be63d0016f0defc148d75051c | seiyamiyaoka/basic_algorithm | /problem_7.py | 2,250 | 3.625 | 4 | class RouteTrie:
# 本当のトップのnode
def __init__(self, path, handler):
# ルートpathのnode
self.root_node = RouteTrieNode(path, handler)
def insert(self, path_routes, handler):
# 再帰的に追加して最も深いノードのハンドラーを追加する
node = self.root_node
end_path = path_routes[-1]
for path in path_routes:
if path:
... |
ee55513f90fe3159719f77c93920bb542f9038b2 | OkavianusAuwdri/OktavianusAuwdri_I0320077_AdityaMahendra_Tugas3 | /I0320077_exercise3.8.py | 165 | 3.6875 | 4 | #Akses Nilai Dalam Tuple Pyhton Exercise 3.8
tup1 = ('fisika', 'kimia', 1993, 2017)
tup2 = (1,2,3,4,5,6,7)
print("tup1[0]: ",tup1[0])
print("tup2[1:5]: ", tup2[1:5]) |
251d19197995305918852de1a25a9d39bf2959c5 | ShadowKaeltas/HomeWork | /OOP_HW/OOP_HW.py | 972 | 3.734375 | 4 | from datetime import datetime, time, date
class homework():
def __init__(self, text, final):
self.text = text
self.created = datetime.now(tz = None)
self.deadline = datetime(
self.created.year, self.created.month,
self.created.day + final, self.created.hour,
self.created.minute, self... |
08ce149a6f3527284b723a71d0cf73d2928b90fc | Timothy-W-Hilton/WRF_pre_post_processing | /FogChangeViz/fog_change_vis.py | 6,047 | 3.609375 | 4 | """try out some visualizations of fog change/urbanization
uses universal tranverse mercator (UTM) zones to project the
coordinates. This allows me to use the vectorized distance
calculation in geopandas geoseries (which, in turn, uses shapely's
distance function). Shapely calculates cartesian distances, not
geodesic... |
cc2717310f1ed4d41527dda4a7572036f8812529 | p7on/epictasks1 | /5.1.random_letter1.py | 680 | 3.953125 | 4 | import random
a = ['самовар', 'весна', 'лето']
word = random.choice(a) # рандомное слово
letter = random.choice(word) # рандомная буква
letter_index = word.index(letter) # находим индекс рандомной буквы
word1 = list(word) # преобразуем выбранное слово в список
word1[letter_index] = '?' # заменяем рандомную букву н... |
da344013faf680a3d45942de80e161b3b4348598 | Spector255/izdruka | /uzdevumi/celsijs_farenhejts.py | 141 | 3.5 | 4 | celsijs = float(input("Ievadiet grādus Celsija: "))
farenhejts = celsijs*9/5+32
print(f"Tas ir {farenhejts} grādu pēc Farenheita skalas.") |
5573dbc3185851a29362f7e200be5b2ce84f1526 | murster972/ClassicalCiphers-old- | /bifid cipher/main.py | 3,579 | 4.09375 | 4 | #!/usr/env/bin python
"""
Bifid Cipher: A classical cipher that combines the polybius square with
transposition, and uses fractionation to achieve diffusion
"""
import os
import random
class BifidCipher(object):
def __init__(self, msg, values={}):
self.msg = msg
self.values = values
self.alph = "ABCDEFGHIKLMN... |
5d2714a5d986459472349f52cc95ea8ad869defb | YorkFish/learning_notes | /Python3/TuLingXueYuan/DS+Algo/05/insert_sort.py | 417 | 3.859375 | 4 | from random import randrange
def insert_sort(lst):
for i in range(1, len(lst)):
for j in range(i, 0, -1):
if lst[j] < lst[j-1]:
lst[j], lst[j-1] = lst[j-1], lst[j]
else:
break
if __name__ == "__main__":
lst = [randrange(10, 100) for i in range(... |
ef2197d8ba05b77fd42480e4015f4e0fa1bbce0c | WhWhWhWh1243/2lesson | /rrbvfvfv/fv.py | 1,097 | 4.5 | 4 | '''
s = 'hello world'
#crezы
#Index - порядковый номер элемента, начинается с
print(s[3])#вывод елемента по индексу
print(s[3:5])#Добавление выреза
print(s[3:6:2]) #дабавление шага выборки
print(s[::-1])
#операции со строками
print('Hello' + 'World')
print ('YAYAYAYAYAYAYA' * 3)
#Методы
print( 'Hello Wor... |
609a15fbed0bd0de86820764e6b01d1f0c8eb441 | felipemcm3/ExerPython | /Pythonexer/ExerPython/aprendendopython/ex061.py | 255 | 3.65625 | 4 | p = int(input('Informe o primeiro termo da PA'))
r = int(input('Informe a razão da Progressão Aritimetica'))
aux = 0
print('A progressão aritimetica de {} com razão {} é:'.format(p, r))
while aux != 10:
print(p, end = ' ')
p += r
aux += 1 |
12cc75a4c9bc5f99ab07d12ede88bf92bb20d46a | syllable2009/py3 | /advanced/myjson.py | 208 | 3.5 | 4 | import json
data = [ { 'a' : 4, 'b' : 5, 'c' : 6, 'd' : 7, 'e' : 8 } ]
json = json.dumps(data)
print(json)
import json
jsonData = '{"a":4,"b":5,"c":6,"d":7,"e":8}';
text = json.loads(jsonData)
print(text) |
4b35bb3b057fff6ef34bf022475593978dadf57c | varnachandran/Fundamentals | /merge_sort.py | 620 | 3.9375 | 4 | def merge_sort(arr,first,last):
if first<last:
mid=(first+last)//2
merge_sort(arr,first,mid)
merge_sort(arr,mid+1,last)
arr=joinarrays(arr,first,mid,last)
return arr
def joinarrays(arr,first,mid,last):
l=arr[first:mid+1]
r=arr[mid+1:last+1]
counter=first
i=0
... |
bbf8ea443ce6fe92b597c19c628e5375b615f48a | nichenxingmeng/PythonCode | /蓝桥杯/无标签/___输入输出格式练习.py | 146 | 3.6875 | 4 | s = input().strip()
temp1 = s[:3]
temp2 = float(s[3:s.index('|')])
temp3 = s[s.index('|'):]
print('{:<8}|{:>8.1f}{}'.format(temp1, temp2, temp3))
|
9e6cac2d4567601f93b4b162181aa520a074844d | FIRESTROM/Leetcode | /Python/113__Path_Sum_II.py | 813 | 3.734375 | 4 | # Definition for a binary tree node.
# class TreeNode(object):
# def __init__(self, x):
# self.val = x
# self.left = None
# self.right = None
class Solution(object):
def pathSum(self, root, sum):
"""
:type root: TreeNode
:type sum: int
:rtype: List[List[i... |
d4f921aa931102cf3641283efe659e3ab3f0bc4d | Tim-hyx/UNSW-Courses | /COMP9021/20T2/final/question_1.py | 3,661 | 3.71875 | 4 | # Returns the product of the prime factors of n whose multiplicity
# (the power of the factor in the decomposition of n as prime factors)
# is maximal.
#
# The sample tests show the prime decomposition of inputs and
# outputs, so provide illustrative examples.
#
# You will pass all tests if, writing the prime decomposi... |
bf39143dccf0a7dff5d3d126920a3dd5c08aefb5 | balamurugan2405/python | /Day-5-nexted loop/mini atm.py | 794 | 3.9375 | 4 | balance=1000
pin=int(input("ENTER YOUR 4-Digit ATM pin"))
pasword=9876
if pin==pasword:
print("welcome mam/sir")
print("1-balance enquery")
print("2-withraw amount")
print("3-deposite amount")
option=int(input("1-3 enter which one"))
if option==1:
print(balance)
elif optio... |
2e9f984bca2d2060ecce2ede122019ebd20b6456 | Mierln/Computer-Science | /William/Hanoi.py | 1,480 | 3.96875 | 4 | #The Tower Of Hanoi
global towers
donut1 = ("*")
donut2 = ("**")
donut3 = ("***")
donut4 = ("****")
towers = [[donut4, donut3, donut2, donut1],
[],
[]]
def show_tower():
print("\nTowers \n")
print(f"Tower 1 : {towers[0][::-1]}")
print(f"Tower 2 : {towers[1][::-1]}")
print(f"Tower ... |
137e4895073238f667a5a3c4ea2b7982c2c42073 | sersavn/practice-hackerrank | /Python/Built-Ins/AnyOrAll_2.py | 826 | 4 | 4 | #Input Format
#The first line contains an integer N.
#N is the total number of integers in the list.
#The second line contains the space separated list of N integers.
#Output Format
#Print True if all the conditions of the problem statement are satisfied.
#Otherwise, print False.
#Sample Input
#5
#12 9 61 5 14
#Samp... |
b3f9647fa38fb3f24ebeb1cc993c707d4cc2b718 | samrahsoarus/build-a-blog | /crypto/helpers.py | 731 | 3.765625 | 4 | def alphabet_position(letter):
alphaz = ['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']
upperLetter = letter.upper()
return alphaz.index(upperLetter)
def rotate_character(char, rot):
alphaz = ['A','B','C','D','E','F','G','H','I','J','K','L','M',... |
bb67feac22648c951f54d6a24fbbb2247c66a5c5 | rguschke/Pythoncourse | /Exercise14.py | 515 | 3.5625 | 4 | from sys import argv
script, user_name = argv
prompt = '> '
print "Hello this is my %s and its called %s" % (script, user_name)
print "Id like to ask you a few questions."
print "Do you like me %s" % user_name
likes = raw_input(prompt)
print "Where do you live %s?" % user_name
lives = raw_input(prompt)
print "What... |
cf4dd46a5a3014e7a215307d9922967bf4387292 | izlatkin/euler-project | /interview/strings/6_2_convert_base.py | 1,413 | 3.671875 | 4 | import functools
import math
import string
def convert_base(s: str, b1: int, b2: int) -> str:
def int_digit_to_string(d: int) -> str:
dd = ["A", "B", "C", "D", "E", "F"]
if d <= 9:
return str(d)
else:
tmp = ord('A')
return chr(ord('A') + d - 10)
is_... |
2a354417d05d19ed6c09c7273fe7382b77ad5249 | klysman08/Python | /Exericicios e provas/Prova1/problema5.py | 369 | 3.859375 | 4 | valor = float(input('Digite o valor da compra: '))
desconto = valor * 0.9
parcela = valor / 6
comissao_v = valor * 0.9 * 0.05
comissao_p = valor * 0.05
print('Valor com desconto: %.2f ' % desconto)
print('Valor da parcela: %.2f ' % parcela)
print('Comissão do vendedor (à vista): %.2f ' % comissao_v)
print('Comissão d... |
a1584fd76cc20ad8d57b177ec07f4369e4764932 | MiltonPlebeu/Python-curso | /Mundo 1/scripts/Aulas678e9/desafio005SucessorAntecessor.py | 330 | 4.125 | 4 | n = int( input('Digite um número inteiro: '))
s = n + 1
a = n - 1
print('Analisando o valor {} seu sucessor é {} e seu antecessor é {}'.format(n, s, a))
#Com apenas uma váriavel
#n = int( input('Digite um número inteiro: '))
print('Analisando o valor {} seu sucessor é {} e seu antecessor é {}'.format(n, (n+1), (n-1))... |
111c4121011595fea7693ec3571b23f56df119b9 | 4dsolutions/python_camp | /primes/euler_test.py | 2,754 | 3.984375 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Sat Dec 2 21:36:26 2017
@author: Kirby Urner
This module demonstrates the RSA algorithm for public
key cryptography. Neither test_small nor test_big uses
industrial strength public keys. Generating primes or
probable primes of some thousands of digits ... |
92c955924a64a40fd45509d01a0c2043128efbd8 | surajsvcs1231/SurajProject | /Practice1.py | 369 | 3.734375 | 4 | '''n="YOUTUBE"
#print(n[1:5:2])
#print(n[-2:-7:-2])
l1=[2,3,4,5,6]
l1.insert(2,9)
print(l1)
l1.pop()
print(l1)
from random import choice
print(choice(l1))
t1=tuple(l1)
print(t1)
print(type(t1))
l2=['hello','world','bye',3,1,2]
print(list(zip(l2)))
print(l2)
d1=dict(zip(l2[0::2],l2[1::2]))
print(d1)
print(l1.__iter__())... |
9d557c57dc381cf020b6e104d2d695b4b123d7ea | RajatPrakash/Python_Journey | /regex.py | 363 | 3.9375 | 4 | import re
user = input("enter text: ")
# if re.search('[0-9]',user) is None:
# print("enter atleat one number")
# else:
# print('correct')
# if re.search('[A-Z]',user) is None:
# print("atleat one chracter should be capital")
# else:
# print('correct')
if re.search('[!@#$%^&*]',user) is None:
pr... |
31e6d2b928d9ae1a9a1356025917362000204b07 | Mishakaveli1994/Python_Fundamentals_May | /Lists Basics/4_Search.py | 235 | 3.84375 | 4 | number = int(input())
word = input()
all_list = []
filtered_list = []
for i in range(number):
text = input()
all_list.append(text)
if word in text:
filtered_list.append(text)
print(all_list)
print(filtered_list)
|
b5aea7b1a46579505287e54113274bdeb4ec6a4c | karanalang/technology | /python_examples/SortStringByCountOfOccurences.py | 1,333 | 3.90625 | 4 | # https://stackoverflow.com/questions/23429426/sorting-a-list-by-frequency-of-occurrence-in-a-list
from itertools import chain, repeat
from collections import Counter
class SortStringByCountOfOccurrences:
def sortString(self, S:str):
S = str(sorted(S))
print(" sorted S -> ", S)
def sortStr... |
c3c7ac16193609766b002bb1ae1916f2b495adeb | antocaroca/ejercicios-usm-python | /ejercicios_parte_1/estructuras_condicionales/triangulos.py | 1,081 | 4.09375 | 4 | # Los tres lados a, b y c de un triángulo deben satisfacer la desigualdad triangular:
# cada uno de los lados no puede ser más largo que la suma de los otros dos.
# Escriba un programa que reciba como entrada los tres lados de un triángulo, e indique:
# si acaso el triángulo es inválido; y
# si no lo es, qué tipo ... |
0f429838f6db3713afebb088f76f0a5e0d411e26 | kristiyankisimov/HackBulgaria-Programming101 | /week0/prime-number-of-divisors/tests.py | 450 | 3.53125 | 4 | from solution import prime_number_of_divisors
import unittest
class PrimeNumberOfDivisorsTest(unittest.TestCase):
def test_prime_number_of_divisors(self):
self.assertEqual(prime_number_of_divisors(7), True)
self.assertEqual(prime_number_of_divisors(8), False)
self.assertEqual(prime_number_o... |
9ca81295fb7491efe32fddbc0a36f5914a5ad921 | GlobalYZ/recruitmentDjango | /pythonBasis/leetcode50/有效的括号(简单).py | 942 | 4.1875 | 4 | # 给定一个只包括 '(',')','{','}','[',']'的字符串 s ,判断字符串是否有效。
# 有效字符串需满足:
# 左括号必须用相同类型的右括号闭合。
# 左括号必须以正确的顺序闭合。
#
# 示例 1:
# 输入:s = "()"
# 输出:true
#
# 示例2:
# 输入:s = "()[]{}"
# 输出:true
#
# 示例3:
# 输入:s = "(]"
# 输出:false
#
# 示例4:
# 输入:s = "([)]"
# 输出:false
#
# 示例5:
# 输入:s = "{[]}"
# 输出:true
class Solution:
def isValid(self, s: st... |
7eac2e6fe7f82ce5c96c2984d3d8fc5a2c5816b1 | smykad/rockpaperscissors | /rockpaperscissors.py | 3,051 | 4.25 | 4 | # ********************************
# Author: Doug Smyka
# Application: rockpaperscissors
# Date Created: 9.8.20
# Date Revised: 9.23.20
# ********************************
import random # allows random choice
# list of choices for computer to choose from
choices = ['rock', 'paper', 'scissors']
user_guess = '' # varia... |
0392b8c810e995398493b5f8f1e17b3294c9e4dc | drxuess/project-euler | /problem4.py | 648 | 3.546875 | 4 | ########################################################
# Problem 4 - Largest palindrome product
#
# A palindromic number reads the same both ways. The largest
# palindrome made from the product of two 2-digit numbers
# is 9009 = 91 × 99.
#
# Find the largest palindrome made from the product of
# two 3-digit number... |
91361d6bef6b3cbec53ad22e98ce88c1af917d23 | AngelDelunadev/python-101 | /sqaure2.py | 112 | 4.03125 | 4 | sqaure = int(input("How big is the sqaure? "))
x = 0
while x <5 sqaure:
print("*"*sqaure)
x = x + 1
|
aaf0c75938491fdb95632ec34f1e2011d635ed3e | bunshue/vcs | /_4.python/__code/Python邁向領航者之路_超零基礎/ch15/ch15_5.py | 405 | 3.65625 | 4 | # ch15_5.py
def division(x, y):
try: # try - except指令
ans = x / y
except ZeroDivisionError: # 除數為0時執行
print("除數不可為0")
else:
return ans # 傳回正確的執行結果
print(division(10, 2)) # 列出10/2
print(division(5, 0)) # 列出5/0
print(division(6... |
265c469480aba3c5e03e0cdd750bf1e2e569d633 | jsatt/advent | /2015/d1/p1.py | 175 | 3.6875 | 4 | def calc_floor(directions):
floor = 0
for i in directions:
if i == '(':
floor += 1
elif i == ')':
floor -= 1
return floor
|
a9a9c1670349d5ef7ed25ccf40a89d72d2572be0 | Ran-oops/python | /1python基础/01 Python基础/07/nonlocal.py | 301 | 3.828125 | 4 |
#声明一个外部函数
def outer():
#声明一个变量(肯定不是全局变量)
x = 5
#声明一个内部函数
def inner():
nonlocal x#声明x不是局部变量
x += 9
print(x)
#调用函数
inner()
#调用outer
outer()
|
63c7cf7c76692948ef7b326e27326b16bb507c76 | Soooooda/HCOPE-estimater | /rl687/environments/cartpole.py | 5,128 | 3.875 | 4 | import numpy as np
from typing import Tuple
from .skeleton import Environment
class Cartpole(Environment):
"""
The cart-pole environment as described in the 687 course material. This
domain is modeled as a pole balancing on a cart. The agent must learn to
move the cart forwards and backwards to keep t... |
6b5a1233e4ef8c59db0bfeb6d473d77b6f6e250d | stepbaro/toilet_earnings | /te.py | 582 | 4.125 | 4 | # -*- coding: utf-8 -*-
#Find out how much you earn on the toilet in work time!
currency = raw_input("Do you earn in $ or $")
def wage_calc():
salary = input("What is you annual salary? ")
days = input("How many days a week do you work? ")
hours = input("How many hours a day do you work? ")
days = float(days)
ho... |
7f9eaf388345f3b820c00eaac607561cf3bd10c0 | juanda2222/playground | /arrays/median_between2_lists.py | 2,012 | 4.03125 | 4 |
def max_length_sorted_arrays(arr1:list, arr2:list) -> int:
total_lenth = len(arr1) + len(arr2)
# start point:
index1 = 0
index2 = 0
combined_array = list()
median = 0
# define the stop index:
stop_index = int( total_lenth / 2 ) # exact center if impar number of elements, used then ... |
276b5c7003d6d5092e639a44a81c85db5313d17b | Galyopa/SoftServe_Marathon | /Sprint_06/question02.py | 1,956 | 3.765625 | 4 | """
Implement function parse_user(output_file, *input_files) for creating file that will contain
only unique records (unique by key "name") by merging information from all input_files argument
(if we find user with already existing name from previous file we should ignore it).
If the function cannot find input files ... |
e18cc85de5463b9a2c041da44e4a7f75acee059a | Emma-ZSS/repo-zhong253 | /repo-zhong253/labs/lab08/workout.py | 1,557 | 3.53125 | 4 | # CSCI1133,Lab Section 004,lab08 Shanshan Zhong Workout
"""
Created on Wed Mar 13 22:58:26 2019
@author: shanshanzhong
"""
#============================================
# ***The empty lists are omitted
#
# a. Base Case:
# (mylist[0] is int)
# square it
# return mylist[1:]
# b. General Cases:
# (mylist[0] is l... |
3633ee5d736c731685f5214c9aa39a143f4ee331 | JuliaAlsop/python-challenge | /PyBank/main.py | 1,397 | 3.609375 | 4 | import os
import numpy as np
import csv
#Path for file
pybank_csv = os.path.join("PyBank", "Resources", "budget_data.csv") #or just put: "budget_data.csv" in ()
#Open the CSV
csvreader = csv.reader(pybank_csv, delimiter=",")
#Start of file layout
print("Financial Analysis")
print("--------------------------")
#The... |
971fd0f327e8e2243ee8b2d3875c1707c214bffe | ashifujjmanRafi/code-snippets | /python3/data-structures/array/array.py | 1,289 | 4.15625 | 4 | # import array module
import array
# declare an array
arr = array.array('i', [1, 2, 3])
# print the original array using for loop
for i in range(3):
print(arr[i], end=' ')
print('\r')
print(arr.itemsize) # return the length of a item in bytes
print(arr.typecode) # return the type code
print(arr.buffer_info()) ... |
0718747b1833e0456a2f65e41abec430de904419 | pwhitetj/TicTacToe | /shell.py | 1,434 | 3.53125 | 4 | import time
import random
import pickle
from strategy import *
####################################
# original version of shell / client
# does NOT currently work with current strategy/core
# use mini-shell instead
#####################################
def play(strategy_X, strategy_O, first = MAX, verbosity = 1):
... |
fa1d4470185a2ff8af7a90acc3fab290c521d837 | sudhanvalalit/Koonin-Problems | /Koonin/Chapter2/Exercises/Ex1.py | 1,388 | 4 | 4 | '''
Exercise 2.1: A simple and often stringent test of an accurate numerical
integration is to use the find value of y obtained as the initial condition
to integrate backward from the final value of x to the starting point. The
extent to which the resulting value of y differs from the original initial
condlition is the... |
db81ed51c2edca1d0d64db296781b4020c87c326 | hadassah0987/python-crash-course | /tuple-tatti.py | 364 | 3.6875 | 4 |
julia = ("Julia", "Jones", 2000, "6 Mariner Way", "Monsey", "NY")
print(julia)
(name, surname, b_year, address, city, state) = julia
print(f"\nFirst Name: {name}\nLast Name: {surname}\nBorn: {b_year}\nAddress: {address}\nCity: {city}, {state}")
print(f"\nFirst Name: {julia[0]}\nLast Name: {surname}\nBorn: {b_year}\n... |
8146883957eef07735804ef7ff5a06de31ddd9f9 | longxinzhang/Python_Learning | /LPTHW/condition.py | 1,278 | 4.15625 | 4 | # coding: utf-8
#age = int(input("please tell me your age:...."))
#单条件
#if age>= 18:
# print ('your age is, ',age)
# print ('adult')
#else:
# printcdcdcd的 ('your age is, ',age)
# print ('teenage')
#多条件elif
#if age>=18:
# print('your age is,', age)
# print('You are adult')
#elif age>=12:
# print('your age is,', age)
... |
0a4cef192aee00a540dfc8dc78fbfe6fe5ece5e9 | cleverinsight-open-ai-foundation/challenges | /code.py | 5,037 | 3.71875 | 4 | """
Load module to filter data on fly
"""
import pandas as pd
class Load():
"""
Load class is used for exclusive dataframe filtering
which takes `df` a csv file and convert into dataframe
"""
def __init__(self, filename):
self.version = open('VERSION').readlines()[0]
self.df = pd.rea... |
fb7b61462dfb0073917ee6f893b701343995165a | RodrigoBC2/prime_number | /main.py | 1,422 | 4.4375 | 4 | from crypto_functions import prime_number_check
from crypto_functions import prime_range
print("If you want just to check if a number is a prime number, type: 1")
print("If you want to know all prime numbers within a given range starting with 1 to any other integer and positive "
"number, type: 2")
option_type... |
a774b2b99553f982057f3626316e4a405e0ce707 | ttafsir/ip-subnet-calculator | /subnet_calculator.py | 1,564 | 4.34375 | 4 | #! /usr/bin/env python
"""
This script is a part of a tutorial to build a Python subnet Calculator.
The script accepts string inputs in the following formats:
`192.168.1.0/24` or `192.168.2.0/255.255.255.0`
Example Usage:
$ python subnet_calc.py 192.168.1.0/26
Output:
IP Subnet Calculator
Subnet: 192.16... |
0b8669ca2ab41a2b5bc5f74d8382a8dbc6580cff | tyedge/holbertonschool-higher_level_programming | /0x05-python-exceptions/4-list_division.py | 492 | 3.921875 | 4 | #!/usr/bin/python3
def list_division(my_list_1, my_list_2, list_length):
retval = []
num = 0
x = 0
while x in range(list_length):
try:
num = my_list_1[x] / my_list_2[x]
except IndexError:
print("out of range")
except TypeError:
print("wrong t... |
5bf19d1427870bda2992afa6b0e3e45b7cebc37f | vivekcs18/Computer-Networks-Lab-5th-Sem | /lab 6/crc.py | 1,326 | 3.5 | 4 | import hashlib
def xor(a, b):
result = []
for i in range(1, len(b)):
if a[i] == b[i]:
result.append('0')
else:
result.append('1')
return ''.join(result)
def mod2div(dividend, divisor):
pick = len(divisor)
tmp = dividend[0: pick]
while pick < len(div... |
8dd9afa91f85178b5ee02a86314a386c14c49e91 | DavidirwinNI/Grok-Introduction-to-Programming-Python | /7 - Looping in the unknown/3 - Up the lift.py | 148 | 4.03125 | 4 | start = int(input("Current floor: "))
end = int(input("Destination floor: "))
for num in range(start, end + 1):
print("Level",num, end = "\n")
|
624be81f1b41d35049be17a820a4123b77551466 | GuiseClown/Earth | /Ex01.py | 344 | 3.984375 | 4 | import math
while True:
try:
year = int(input("Enter year: "))
if year < 0 or year > 2005:
print("Please input the year between 1 and 2005")
continue
break
except:
print("Plese input interger only")
century = year/100
result = math.ceil(century)
pri... |
83442edeab41c8338839ff9cbffc35cec6e6f367 | jboegeholz/ud120-projects | /naive_bayes/nb_author_id.py | 1,125 | 3.578125 | 4 | #!/usr/bin/python
"""
This is the code to accompany the Lesson 1 (Naive Bayes) mini-project.
Use a Naive Bayes Classifier to identify emails by their authors
authors and labels:
Sara has label 0
Chris has label 1
"""
from __future__ import print_function
import sys
from time import time
sy... |
14ef83063813243104cee1105b735af472445417 | Heeseok-Jeong/20_2_PythonProgramming | /HW3/hw3_21400707.py | 7,296 | 3.90625 | 4 | from datetime import datetime #Q3
import random #Q10, Q11
def get_date_format(): #Q4
date_format = '' #Q4
while not (date_format == '1' or date_format == '2'): #Q4
date_format = input("Choose a Date Format (1 or 2) : ") #Q4
date_format = int(date_format) #Q4
print() #Q4
return date_format #... |
c1968f1081743019e455a6d1eb41454475ba14ff | zipengwang98/129L_backup | /hw2/Problem1.py | 246 | 4.15625 | 4 | #!/usr/bin/python3
while True:
try:
x = int(input("Please enter an integer: "))
y = x**2
print("the number squared is", y )
break
except ValueError:
print("That is not an integer. Try again.")
|
d5aaf00fd5406e9ae4b5c34702bf41f0948c76c7 | prashuym/IKPrograms | /Sort-Practice1-Sum3.py | 1,065 | 3.515625 | 4 | """
https://oj.interviewkickstart.com/view_test_problem/15890/103/
"""
def findZeroSum(arr):
# Write your code here.
if len(arr) < 2: return []
arr.sort() # n log(n)
res = []
lenArr = len(arr)
# print ("sorted ", arr)
prevValue = None
for i in range(lenArr - 1):
curEle = arr[i... |
6af5bed882ff27838233c8dfa4bc57e7ef36f4b1 | ryogoOkura/atcoder | /entrant/hhkb2020/hhkb2020-a.py | 153 | 3.515625 | 4 |
def main():
s=input()
ans=input()
if s=='Y':
ans=ans.upper()
return ans
if __name__=='__main__':
ans=main()
print(ans)
|
78233480f95ed18307efbc04a6d4beb31f14117a | lmeraz/py-jsonl | /jsonl.py | 532 | 3.5 | 4 | #!/usr/bin/python
import json
def write_jsonl(obj, outfile):
"""
Writes new line delimited json object
:param obj: object to jsonify
:param outfile: file to write to
:return: None
"""
json_string = json.dumps(obj)
outfile.write(json_string+'\n')
def read_jsonl(infile):
"""
Re... |
c15acfb5c5b390a94b17db9478629ef074ffa177 | Nifled/programming-challenges | /codeeval/Easy/SimpleSorting_easy.py | 355 | 4.0625 | 4 | # https://www.codeeval.com/open_challenges/91/
# Simple Sorting
# CHALLENGE DESCRIPTION:
# Write a program which sorts numbers.
test = "-29.857 -25.849 -1.157 -33.311 67.590 -37.450 97.293 -33.572 -41.757 -4.338 -19.210"
test = test.split()
numList = [float(x) for x in test]
result = ["%.3f" % num for num in sorte... |
bdd648edfb2c3ac8b306b4e9100198b040e4d3a9 | andreferreira4/Programa-o1 | /ficha 1 entregar/Ex1.py | 197 | 4.09375 | 4 | #Exercício1
numero = int(input("Escreva um número: "))
antecessor = numero - 1
sucessor = numero + 1
print("O antecessor de {} é o {} e o seu sucessor é {}".format(numero,antecessor,sucessor)) |
983f809239935a1e000016b337f96686bc57f230 | Richard-Hansen/Blackjack | /Blackjack.py | 3,595 | 3.765625 | 4 | #Let's play some blackjack!
import random
class Player(object):
def __init__(self, isDealer):
self.isDealer = isDealer
self.bankroll = 100
self.hand = []
def checkBank(self):
return self.bankroll
def checkHand(self):
return self.hand
class Blackjack(object):
def __init__(self, player, dealer):
se... |
266b85ee9931f51cbd77780c0da9ece64a69665d | lalit97/dsa-lessons | /stack-queue/reverse-using-stack.py | 205 | 3.96875 | 4 | """
https://practice.geeksforgeeks.org/problems/reverse-a-string-using-stack/1
"""
def reverse(string):
"""
argument: input string
return type: reversed string
"""
my_stack = Stack()
|
f8694f6012a34ca90abc90a733ad2234f4fb1036 | hhsalik/staj | /02-19-Cuma/functions.py | 220 | 3.703125 | 4 | def sayHi(name, age):
print("Hello " + name + ", you are " + str(age))
# sayHi("Cihat", 45)
# return statement
def sayHi(name, age):
return "Hello " + name + ", you are " + str(age)
print(sayHi("Cihat", 20)) |
7a57b21dac9e96039c2b430df32e48c731ef9d92 | tomdom35/Project-Euler-Challenges | /Euler Problem 26 - July 22, 2016 - Reciprocal cycles/Euler Problem 26 - July 22, 2016 - Reciprocal cycles - Python.py | 1,456 | 3.59375 | 4 | import math
def find_largest_repeating(d):
max_dec = 1
max_d = 3
for i in range(4,d):
dec = divide2(1,i,'',[])
rep = len(dec)
if rep > max_dec:
max_d = i
max_dec = rep
return max_d
def divide(dividend,divisor,quotient,remainder_list):
i... |
01d5e7369986672e98b2686bc45cbe5eb9dd8a80 | kellysan/learn | /python/day10_函数/demo02_高阶函数/demo04_内置函数reduce.py | 706 | 4.0625 | 4 | #! /usr/bin/env python
# @Author : sanyapeng
'''
reduce()规约
1 python3 中reduce()不在是内置函数,移到 functiontools模块
2 reduce()
第一个参数 func
def fun(x,y)
return
第二个参数 序列
[元素1,元素2]
第三个参数,初始值
'''
from functools import reduce
#累计求和
def get_sum(a,b):
return a + b
li... |
ae7a34f480ec98382c92c75e087c00aebf1569f6 | AoifMurphy/UCDPA_aoifmurphy | /TEST3.py | 460 | 3.515625 | 4 | import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import matplotlib as mpl
df=pd.read_csv('Telco-Customer-Churn.csv')
print(df.head())
print(df.info())
df.TotalCharges = pd.to_numeric(df.TotalCharges, errors='coerce')
df.isnull().sum()
df1 = df.iloc[:,1:]
#transform to binary code
df1['Churn'].r... |
12f3b4ed10d960ec43a9bf9264e3676fe82feb5e | DeveloperLY/Python-practice | /05_sequence/_04_列表的数据统计.py | 270 | 3.515625 | 4 | name_list = ["zhangsan", "lisi", "wangwu", "zhangsan", "zhangsan"]
list_len = len(name_list)
print("列表中包含 %d 个元素" % list_len)
count = name_list.count("zhangsan")
print("zhangsan 出现了 %d 次" % count)
name_list.remove("zhangsan")
print(name_list)
|
d418c52664f9576cf774d17fbff810c514285781 | neelamy/Leetcode | /LinkedList/23_MergekSortedLists.py | 1,763 | 3.921875 | 4 | # Source : https://leetcode.com/problems/merge-k-sorted-lists/description/
# Algo/DS : Linked List
# Complexity : O(K) to create heap + mlogK to get smallest element
# Definition for singly-linked list.
# class ListNode(object):
# def __init__(self, x):
# self.val = x
# self.next = None
### L... |
2aec14ab7fb8e63afb4915f612e99109143711ee | UrviSoni/competitive-programming | /Leet-Code/03_10_20_k_diff_pairs_in_an_array.py | 1,325 | 3.734375 | 4 | # Given an array of integers nums and an integer k, return the number of unique k-diff pairs in the array.
# A k-diff pair is an integer pair (nums[i], nums[j]), where the following are true:
# 0 <= i, j < nums.length
# i != j
# a <= b
# b - a == k
# Example 1:
# Input: nums = [3,1,4,1,5], k = 2
# Output: 2
# Explan... |
fd2645d48d219deb4a44066b4e8a617d19a03ba5 | AlvaroRubilar/PildorasPython | /poo.py | 1,306 | 3.625 | 4 | class Coche():
def __init__(self):
self.__largoChasis = 250
self.__anchoChasis = 120
self.__ruedas = 4
self.__enMarcha = False
def arrancar(self, arrancamos):
self.__enMarcha = arrancamos
if (self.__enMarcha):
chequeo = self.__chequeoInterno()
... |
580ed26304f9a1d809874819872f70eb095a54b3 | behnamasadi/OpenCVProjects | /scripts/diff.py | 3,060 | 3.53125 | 4 | import cv2
import numpy as np
def is_blurry(image, threshold=100):
"""
Determine if the image is blurry based on the variance of the Laplacian.
Parameters:
- image_path (str): Path to the image.
- threshold (float): Variance threshold below which the image is considered blurry.
Returns:
... |
8202d7a0624669274e2c18ef23d8ae977844d424 | sahiljajodia01/Competitive-Programming | /leet_code/power_of_three.py | 513 | 3.921875 | 4 | # https://leetcode.com/explore/interview/card/top-interview-questions-easy/102/math/745/
######### A very naive solution ###########
####### There are a lot of other methods to solve this problem. I should revisit those methods again later. ############
class Solution:
def isPowerOfThree(self, n: int) -> bool:
... |
34dae77b65a46f85100fa90a4f5a8bf104c52df0 | sirbobthemarvelous/billybobjoe-early-content | /Chapter8.py | 938 | 4.15625 | 4 | #lists, aka collections aka arrays
friends = ['Sammy','Richard','Luna']
#you could put anything in a list or nothing
print friends[2] #you'll get Luna
#Lists are Mutable aka the things in them can be changed
friends[0] = 'Sam Reddick' #replace Sammy with sam
print len(friends) #ya get 3
print range(4) #ya get 0,1,2,3
#... |
16709610091a17d65036a20fd6aba53af1ce0aec | weirdindiankid/HackerRank-Spring-CodeSprint | /smithnumber.py | 765 | 3.65625 | 4 | def primeFactors(n):
factors = []
l = 2
while l ** 2 <= n:
while (n % l) == 0:
factors.append(l)
n //= l
l += 1
if n > 1:
factors.append(n)
return factors
def sumOfDigits(n):
if n == 0:
return 0
return n % 10 + (sumOfDigits(n // 10))
... |
01d1c1c75b23f6f1ca61a83a4b85c6ee22752cc4 | hudefeng719/uband-python-s1 | /homeworks/A16502/checkin06/day12.py | 682 | 3.859375 | 4 | #!/usr/bin/python
# -*- coding: utf-8 -*-
# @author: 小仙女
def main():
tup = (1,2,3,4)
#取值
print tup[0]#[]中是上标
print tup[1]
# 切片
print tup
print tup[0:3]#同list一样左闭右开
print tup[2:]#右边没有意味着到最后
# 是否存在某值
print(1 in tup)
print(9 in tup)
# 赋值
a,b,c,d=(1,2,3,4)
print b
# 遍历
for item in tup:
... |
0411c8119b4a87d2d37062afedbd016509fcb46b | neerajrush/Samples | /calc_binomial_d.py | 716 | 3.765625 | 4 | def factorial(n):
if n == 0 or n == 1:
return 1
return n * factorial(n-1)
def choose(n, x):
return factorial(n)/(factorial(x) * factorial(n-x))
def calc_binomial_d():
rejection = 12
batch = 10
prob_being_rejected = 0.12
prob_being_ok = 0.88 #(1 - 0.12)
pb_no_more_... |
4138830e83a2d1e2562df5acc27a4b12338a2bd2 | avinashtangudu/Python-Files | /Functions.py | 589 | 4.3125 | 4 |
# Functions in Python
# we can define a function with 'def'.
def hello_python():
pass
print(hello_python()) # It prints a 'None Value'
# It will prints the print statement
def hello_python():
print('Namaste Python..!')
hello_python()
# One More Method
def hello_python():
return 'Namaste Python..!'
pr... |
3f4b171798ecce03cd7fb8054083db0832484d98 | gbliao00/IonTrap | /laser-development-kit-master/examples/morse_code.py | 4,658 | 3.59375 | 4 | """
Program for making the RedPitaya / Koheron laser development work as a morsecode emitter.
Code is scanned from the command line by the program, and transmitted as short and long laser-pulses.
"""
import os
import time
import numpy as np
import matplotlib.pyplot as plt
from koheron import connect
from drivers impo... |
a6bc12469ed88f10acd0ac38ef5a0e1126d41656 | hlynurstef/Space_Invaders | /life.py | 487 | 3.671875 | 4 | from pygame.sprite import Sprite
class Life(Sprite):
"""A class representing one life."""
def __init__(self, settings, screen, x, y):
"""Initialize life."""
super(Life, self).__init__()
self.settings = settings
self.screen = screen
self.image = settings.player_ship_image
self.rect = self.image.get_rect(... |
d1d5d3c83ce67b854bfe02dbf267144ed08d1cf8 | emiliechhean/Checkers_MC | /src/player.py | 4,339 | 3.75 | 4 | import random
class Player:
""" class """
def __init__(self, symb='x'):
if symb != 'x' and symb != 'o':
raise Exception("wrong symbol, try 'x' or 'o' ")
self.symb = symb
self.pawns = []
self.checkers = []
#init pos combi ici
def __str__(self):
... |
b7e2e5496f22adbdfaf987ff0e86d50541b432c8 | sebasalvarez13/ww-tag-generation | /tags_display.py | 1,710 | 3.578125 | 4 | #!/usr/bin/env python3
import pandas as pd
from IPython.display import HTML
from combine_csv import MergedDataFrame
def tagdisplay():
df = MergedDataFrame.merge()
html = df.to_html()
# write html to file
output_file = "../templates/tagstable.html"
try:
with open(output_file, ... |
0cdc8512be1b13fae755ae40b4a3c8533d273355 | RavenAyn/Astrophys-Hons | /Activity 1/Q5(The one with the vowels and reverse indexing).py | 396 | 3.90625 | 4 | aleph='abcdefghijklmnopqrstuvwxyz'
a=aleph.index((input('Gimme a vowel: ')))
#x=aleph.index(a)
print(a)
if a==0:
print('*A* Vowel!')
elif a==4:
print('A Vow*E*l!')
elif a==8:
print('*I* see a Vowel')
elif a==14:
print('*O*Oooh a Vowel!' )
elif a==20:
print('U entered a Vowel!')
els... |
f79f393f378d75ad5b4d0cdf492b1333b27238c8 | Global19-atlassian-net/ComputationalPhysics | /PHYS510 Final2 FFT.py | 7,448 | 3.75 | 4 | """
Created on Fri Jul 26 14:36:45 2013
PHYS 510, Final Exam Problem 2
"""
# Final Exam Problem 2: Fourier Signal Analysis
"""
Use Fourier power spectrum analysis to determine the frequency content
of the data in the Fourier data file. The first column in the data file
corresponds to time in seconds and the second col... |
48046ea3d606bd9761516923a9e8756fafeaaa68 | AlanFermat/leetcode | /backtracking/39 combineationSum.py | 439 | 3.84375 | 4 | def combine(candidates,target):
# candidates = sorted(candidates)
res = []
def track(arr, aim, temp):
summ = sum(temp)
if summ == aim:
res.append(temp)
elif summ > aim:
return
else:
for pos, num in enumerate(arr):
if num + summ <= aim:
track(arr[pos:], aim, temp + [num])
else:
ret... |
7d7542fb196ad3136623e32432feced1a5a81ff5 | ikhwan/pythonkungfu | /participants/5uh3ndra/lat.py | 674 | 3.875 | 4 | #!/usr/bin/env python
asbak = ["abu","puntung", "ludah", "anu", "ijuk", 3,4];
print asbak;
for i in xrange(0, len(asbak)):
print asbak[i];
def cetak(arg):
print arg;
beberapaangka = [12,3,7,9,];
def tambah(arg1,arg2,arg3,arg4):
print arg1 + arg2 + arg3 + arg4;
tambah(12,3,7,9);
#tambahin angka 10 ke dalam arr... |
40f2f0c470198750702b25a25a99b8eec2e1d715 | SubhamSubhasisPatra/Data-Structure-Interview-Probelm-Solution-in-Python | /src/binary_search/count_negatve.py | 577 | 4.09375 | 4 |
def binary_search(arr):
left = 0
right = len(arr) - 1
mid = (left + right) // 2
min_val = 0
while left < right:
if arr[mid] < 0
def total_negative(arr):
# find the total length
# binary search to find the index where the negative start
# subtract from the arr len
def count... |
98b783ada2b021567dc1661579b2e83ba9227e6e | dtekluva/Collection_of_python_apps | /banking/express.py | 651 | 3.5625 | 4 | from banking_class import Banking
class BankingExpress(Banking):
def in_transfer(self,sender,reciever,amount):
if self.withdraw(sender,amount)==True:
self.deposit(reciever,amount)
newaccount= BankingExpress("fidelity")
newaccount1= BankingExpress("fidelity")
print(newaccount.createAccount("in... |
fb58afcc5113e5addb19e5d8353e19a61512e8f5 | burgonyapure/ow | /12.diszno.py | 237 | 3.78125 | 4 | a = int(input("Add meg a keret magasságát: "))
b = int(input("Add meg a keret szélességét: "))
c = input("Adj egy karaktert amivel rajzolok: ")
print(c * b)
for x in range(1, a - 1):
print(c," " * (b - 2),c, sep="")
print(c * b)
|
2b80ce33249641271ca3cad1818206710b8374fc | parthmehta/polynomial-regression | /poly-regression.py | 2,053 | 3.53125 | 4 | import numpy as np
import pandas as pd
from sklearn.preprocessing import PolynomialFeatures
from sklearn.linear_model import LinearRegression
from sklearn.metrics import mean_absolute_error
from sklearn.model_selection import train_test_split
house_data = pd.read_csv('./data/house_rental_data.csv.txt', index_col='Un... |
252d393c8f08f2ef4b2ec6e56e759a12ed2b2c89 | kubas1129/WDI | /Lab3.py | 1,936 | 3.703125 | 4 | import random
import time
import os
import math
def cls():
os.system('cls' if os.name=='nt' else 'clear')
def BoardAnim(x,y,execTime):
board = [" o" * x for i in range(y)]
cls()
while(execTime > 0):
for i in range(y):
if (i < y - 1):
board[y - 1 - i] = board[y - 2 -... |
2588d8b4d695ccc7e8fc3754d72089cfbfaf1362 | takecap/70puzzles | /src/q09_1.py | 883 | 3.78125 | 4 | # Q09 つりあわない男女
# seq: ['B' or 'G']
def unbalance(numB, cntG, maxB, maxG):
head = numB != cntG # 前から見て、等分割できるかを判定する
tail = (maxB - numB) != (maxG - cntG) # 後ろから見て、等分割できるかを判定する
return head and tail
def count(numB, numG, maxB, maxG, memo):
if (numB, numG) in memo:
return memo[numB, numG]
if unbalance(numB,... |
152876deb7628f15f147df645db73e0d56e47f1c | TheBillusBillus/snek | /Exercise2BZ.py | 1,779 | 3.890625 | 4 | import math
import time
x = 0
x0 = 0
v0 = 0
t = 0
a = 0
opt = input ("Choose your option:\n1. Solve for x\n2. Solve for x0\n3. Solve for v0\n4. Solve for t\n5. Solver for a\nInput: ")
if opt == "x":
#x = x0 + v0*t + (1/2)*a*(t**2)
x0 = float (input ("Displacement (Initial): ")) #define variables
v0 =... |
fccbc7f4d13ec08bb806900d29a3b61b77ff14a5 | Jyoshna9346/Become-Code-Python | /phase 1 assignment.py | 815 | 3.8125 | 4 | ##closed path program
'''
def closedPaths(number):
closedPaths=0
while number:
r=number%10
number//=10
if r==0:
closedPaths+=1
if r==4:
closedPaths+=1
if r==6:
closedPaths+=1
if r==8:
closedPaths+=2
... |
bdb741208a0ffed372c3f77894da7851f8fb9a85 | SophiaWald/Email | /Weather-Email.py | 2,702 | 3.625 | 4 | import requests #to request the weather data
import json #to format the weather data
import smtplib, ssl #for the email
from email.mime.text import MIMEText #to attach text
from email.mime.multipart import MIMEMultipart #to structure the subject,from,to,Bcc
port = 465 #port for gmail
smtp_server = "smtp.gmai... |
e1ba3b3b69c7c85e2a48750324b6be476fea83ba | wh1tezzf/LeetCode | /739Daily-Temperatures.py | 1,052 | 3.6875 | 4 | from collections import deque
class Solution:
def dailyTemperatures(temperatures):
stack = deque()
#push first tuple into stack
stack.append((temperatures[0], 0))
array = [0] * len(temperatures)
#each tuple in stack consists of its index and position
for i in range(1,... |
039b8804ed469352a97153c7b0da65e76fe60cae | alexbelan1999/university_python_labs | /serp/triangle.py | 1,602 | 4.1875 | 4 | import turtle
n = int(input("Введите степень: "))
turtle.shape('turtle')
Turtle = turtle.Turtle()
window = turtle.Screen()
window.setup(width=800, height=600, startx=200, starty=50)
turtle.penup()
turtle.goto(0, 250)
turtle.pendown()
turtle.write("Алексей Белан, 34 группа , Треугольник Серпинского", move=False, alig... |
4dcc2a6efe6875af99f0725319ec63019ae4b98b | andyrockenbach/Projects | /counting_strategy.py | 2,465 | 3.5625 | 4 | from Tkinter import *
class CountingStrategy(Frame):
def __init__(self, master):
Frame.__init__(self, master)
self.grid()
self.create_widgets()
def create_widgets(self):
self.count_label = Label(self, text="Counting Strategy")
self.count_label.grid(row=0, columnspan=2, sticky=W+E+N+S)
self.ace_label = ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.