text stringlengths 5 121k |
|---|
print("Welcome To Deovano Bank\n")
chanses=3
balance=900
while chanses>=0:
pin=int(input("Plese Enter your Pin\n"))
if (pin==1234):
print("Welcome")
break
|
def bmi(in_data):
in_data = in_data.split('\n')
out = ''
for i in range(1, int(in_data[0]) + 1):
person = in_data[i].split()
weight = int(person[0])
height = float(person[1])
bmi = weight / (height ** 2)
if bmi >= 30:
out += 'obese '
elif... |
"""
Receiver which receives the message from the queue.
"""
import pika
"""Create a connection to the RabbitMQ server and establish a channel"""
connection = pika.BlockingConnection(pika.ConnectionParameters(host="localhost", port=5672))
channel = connection.channel()
"""
- Create or get the existing chann... |
"""
A producer to send the message to the RabbitMQ server.
"""
import pika
"""Create a connection to the RabbitMQ server and channel"""
connection = pika.BlockingConnection(pika.ConnectionParameters(host='localhost',port=5672))
channel = connection.channel()
"""Create a queue named 'hello'. If no queue name is def... |
flag = [16, 9, 3, 15, 3, 20, 6, 20, 8, 5, 14, 21, 13, 2, 5, 18, 19, 13, 1, 19, 15, 14]
result = []
for n in flag:
result.append(n % 26)
if flag == result:
print("Hello, world!")
|
text = "llkjmlmpadkkc"
key = "thisisalilkey"
def encrypt(plain, key):
plain = list(plain)
j = 0
for i in range(len(plain)):
j %= len(key)
if plain[i].islower():
if key[j].islower():
plain[i] = (ord(plain[i]) - 97 + ord(key[j]) - 97) % 26
elif key[j].i... |
text = "vgefmsaapaxpomqemdoubtqdxoaxypeo"
def encrypt(plain, key):
plain = list(plain)
for i in range(len(plain)):
if plain[i].islower():
plain[i] = (ord(plain[i]) - 97 + key) % 26 + 97
elif plain[i].isupper():
plain[i] = (ord(plain[i]) - 65 + key) % 26 + 65
else... |
class persons():
def __init__ (self,nama,umur):
self.nama = nama
self.umur = umur
def setname(self,namabaru) :
self.nama=namabaru
def getnama(self) :
return self.nama
orang1=persons('aki',17)
print(orang1.nama)
print(orang1.umur)
orang1.setname('sujo')
print(oran... |
'''
Funcion que permite ver si una persona es mutante o no,
tiene como parametro una lista y devuelve True si es mutante
o False si no lo es
'''
def Mutant(adn):
try:
'''
Funcion que permite verificar si la matriz es correcta
siendo NxN y que solo tenga las letras A T C G... |
AB = 3
AC = 4
import math
BC = int(math.sqrt(AB**2+AC**2))
print("The hypotenuse of the triangle ABC:",BC) |
string=input()
punctuations = '''!()-[]{};:'"\,<>./?@#$%^&*_~'''
for x in string.lower():
if x in punctuations:
string = string.replace(x, "")
print(string,end="")
|
l = input().lower()
s = 'abcdefghijklmnopqrstuvwxyz'
for i in s:
if i not in l:
print('No',end='')
break
else:
print('Yes',end='')
|
a=int(input())
for i in range(1,a+1):
for j in range(1,i+1):
print(j,end="")
for k in range(i-1,0,-1):
print(k,end="")
print()
|
def compute_hcf(x, y):
if x > y:
smaller = y
else:
smaller = x
for i in range(1, smaller+1):
if((x % i == 0) and (y % i == 0)):
hcf = i
return hcf
num1 = int(input())
num2 = int(input())
print(compute_hcf(num1, num2))
"""
(m,n,pro)=(int(input()),int... |
class Github():
"""
Compiles a hyperlink for source code stored in a Github repository.
Parameters
----------
root : str
Path to the root directory of the source code. e.g. `'https://github.com/<username>/blob/master'`.
Attributes
----------
root : str
Set from the `roo... |
import xml.etree.ElementTree as ET
import pandas as pd
import numpy as np
xml = '''<?xml version="1.0" encoding="UTF-8"?>
<MedlineCitationSet>
<Article>
<ArticleTitle>Title 1</ArticleTitle>
<AuthorList>
<Author>
<LastName>Public</LastName>
<ForeName>J Q</ForeName>
<Initials>JQ</Initia... |
import numpy as np
def RK4Step(x0,dt,fv,direction=1.0):
'''
This Function returns the step taken along the field provided by the
function 'fv' using the Runge-Kutta 4th order method.
Inputs
======
x0 : float
Initial location vector.
dt : float
Step size.
fv : callable
Callable function which provides ... |
import pandas as pd
data = pd.read_csv("bakery_update.csv")
dictmonth = {}
for i in range(len(data)):
check = data['Date'][i]
if '2016' in check:
if len(check) == 10:
month = check[3:5]
if month not in dictmonth:
dictmonth[month] = 1
else:
dictmonth[month] += 1
else:
month = c... |
'''
Created on Jan 9, 2019
@author: rch
'''
import time
def run_rerun_test(s):
print('\nRUN the calculation thread from t = 0.0')
s.run_thread()
print('\nWAIT in main thread for 3 secs')
time.sleep(3)
print('\nPAUSE the calculation thread')
s.pause()
print('\nPAUSED wait 1 sec')
... |
import re
def remove_special_characters(text):
new_text = re.sub(r"[^a-zA-Z0-9\s]", "", text)
return new_text
|
import pygame
from pygame.draw import *
from random import randint
pygame.init()
FPS = 40
screen = pygame.display.set_mode((1200, 800))
length=1200
height=800
change = [-4, -3, -2, -1, 1, 2, 3, 4]
RED = (255, 0, 0)
BLUE = (0, 0, 255)
YELLOW = (255, 255, 0)
GREEN = (0, 255, 0)
MAGENTA = (255, 0, 255)
CYAN = (0, 25... |
import turtle as tur
import numpy as np
tur.shape('turtle')
tur.speed(9)
tur.left(90)
def arch(halfr):
ag=6
n=(np.pi*halfr**2/180*ag)
for i in range(180//ag):
tur.left(ag)
tur.forward(n)
while 2>1:
arch(10)
arch(5) |
class SimpleChattyBot:
user_name = None
user_age = None
def __init__(self, name, birth_year):
self.name = name
self.birth_year = birth_year
def greeting(self):
print(f"""Hello! My name is {self.name}.
I was created in {self.birth_year}.""")
def get_user_name(self):
... |
water_current = 400
milk_current = 540
coffee_current = 120
money_current = 550
cups_current = 9
def take():
global money_current
print("I gave you ${}".format(money_current))
money_current = 0
def buy():
global water_current, milk_current, coffee_current, money_current, cups_current
choice = ... |
import random
def check(player_move_):
disadvantage = {"paper": "scissors", "rock": "paper", "scissors": "rock"}
moves = ["rock", "paper", "scissors"]
computer_move = random.choice(moves)
if disadvantage[player_move_] == computer_move:
print(f"Sorry, but computer chose {computer_move}")
... |
from unittest import TestCase
from foo.bar import whats_the_meaning_of_life, calculate_mean
__author__ = "Your Name"
__credits__ = []
__license__ = "MIT"
__maintainer__ = "Jürgen"
__email__ = "yname@km3net.de"
class TestMeaningOfLife(TestCase):
"""Tests for the bar module"""
def test_meaning_of_life(sel... |
'''
Write a program: input of this program has a single line with integers. The program must output the sum of these numbers.
'''
print(sum(map(int, input().split())))
|
'''MKAD
The length of the Moscow Ring Road (MKAD) is 109 kilometers. Biker Vasya starts from the zero kilometer
of MKAD and drives with a speed of V kilometers per hour. On which mark will he stop after T hours?
Input data format
The program gets integers V and T as input. If V > 0, then Vasya moves in a positive di... |
"""
Authors: Michal Swiatek, Jan Wasilewski
Github: https://github.com/michal-swiatek/Checkers
"""
import itertools
from pieces import Piece, Man
class Board:
"""
Represents current board state
Board holds all currently active pieces and generates representation
of current game... |
import random
import string
def _pass_generator(n):
upper_letters = [random.choice(string.ascii_uppercase) for _ in range(int(n*0.3))]
lower_letters = [random.choice(string.ascii_lowercase) for _ in range(int(n*0.3))]
digits = [random.choice(string.digits) for _ in range(int(n*0.2))]
special = [random... |
def file_txt(filename):
lista = []
with open(filename) as f:
line = f.readline()
while line:
lista.append(int(line))
line = f.readline()
return lista
def run():
list1 = file_txt('lista1_exe23.txt')
list2 = file_txt('lista2_exe23.txt')
... |
def _palindrome(text):
text = text.lower()
text = text.replace(' ', '')
left, right = 0, len(text)-1
while left < right:
if text[left] != text[right]:
return False
left += 1
right -= 1
return True
def run():
text = input('Tell me a string: '... |
import random
def bogoSort(arr):
count = 0
result, count = isSorted(arr)
while (result == False):
shuffle(arr)
result, comparisons = isSorted(arr)
count = count + comparisons
return count
def isSorted(arr):
n = len(arr)
count = 0
for i in range(0, n - 1):
... |
s = input()
x = s.count('z')
y = s.count('o')
if 2*x == y:
print("YES")
else:
print("NO") |
N=int(input())
hour=0
minute=int(N/60)
if minute>60:
hour=int(N/3600)
secnd=N%3600
minute=int(secnd/60)
secnd=secnd%60
else:
secnd=N%60
print(str(hour)+':'+str(minute)+':'+str(secnd))
|
class ListNode:
def __init__(self,data):
self.data=data
self.next=None
Node1=ListNode(11)
Node2=ListNode(21)
Node3=ListNode(31)
head=Node1
Node1.next=Node2
Node2.next=Node3
def traversal(head):
fNode=head
while fNode is not None:
print (fNode,fNode.data)
fNode=fNode.next
... |
def find_fib(n):
if n <=2:
return 1
fib_x,fib_next=1,1
i=3
while i<=n:
i=i+1
fib_x , fib_next=fib_next,(fib_x + fib_next)
return fib_next
for x in range(1,11):
print(find_fib(x))
|
print('TABEL OF -ve 4')
for A in range(0,-100,-1) :
print('4 x ' + str(A) + " = " + str( A * 4))
print('TABEL OF -ve 4')
for A in range(100) :
print('-4 x ' + str(A) + " = " + str( A * -4))
|
"""
Created on Mon Oct 21 20:36:37 2019
@author: Sudharshan
"""
def spreadsheet_encoding(x):
def conv(y):
return ord(y) - ord('A') + 1
power, res = 0, 0
for i in reversed(range(len(x))):
res += conv(x[i]) * 26 ** power
power += 1
return res |
"""
Created on Sat Sep 21 21:19:56 2019
@author: Sudharshan
"""
def plus_one(digits):
carry = 0
for i in reversed(range(len(digits))):
if carry == 0 and i != len(digits) - 1:
break
value = digits[i] + 1
if value > 9:
carry = 1
else:
car... |
x = True
if (x):
print('statement entered')
elif (x):
print('Statment not printed')
else:
print('statement not enetered')
q=0
while x:
print('still true')
q += 1
if q==10:
x = False
print('not true')
x = ['banana', 'strawberry', 'orange']
for y in x:
if y=='orange':
... |
import numpy as np
a=np.array([0,1,2,3,4])
type(a)
a.dtype
a.size
a.ndim
print(a.shape)
c=np.array([20,1,2,3,4])
c[0] = 100
d = c[1:4]
u=np.array([1,0])
v=np.array([0,1])
z = u + v
z = u - v
z = 2*u
u = np.array([1,2])
v = np.array([3,2])
z = u*v
result = np.dot(u,v)
z = u+1
mean_a=a.mean()
max_... |
firstNumber=input('put in first int number')
secondNumber=input('put in second int number')
sumNumbers=int(firstNumber)+int(secondNumber)
print(sumNumbers) |
number = [3, 7, 1, 4, 2, 8, 5, 6]
print(number.index(5))
number *= 2
print(number)
print(number.index(5,7))
print(number.index(7,0, 4))
|
list = [67, 12, 46, 43, 13]
key1 = 43
key2 = 44
if key1 in list:
print(f'{key1} is present at {list.index(key1)}')
else:
print(f'{key1} not found')
if key2 in list:
print(f'{key2} is present at {list.index(key2)}')
else:
print(f'{key2} not found')
|
dict1 = {'A':'aa','B':'bb','C':'cc'}
for i in dict1.values():
print(i)
for i in dict1.keys():
print(i)
for i, j in dict1.items():
print(f'{i} {j}')
|
import turtle
turtle = Turtle()
inputs = ["thing1", "thing2", "thing3"]
for thing in inputs:
print(thing)
print(3 + 5)
print('Hello world')
print("ahhhh")
if x > 3:
print(x ** 2) |
import numpy as np
def load_dataset():
dataset = np.genfromtxt('ex1data2.txt', delimiter=',')
X = dataset[:,:-1]
y = dataset[:, [-1]]
X = np.insert(X, 0, 1, axis=1)
return X, y
def feature_standardization(X):
for col in range(1, X.shape[1]):
mean = np.mean(X[:, col])
... |
def find_missing_letter(chars):
for i in range(len(chars) - 1):
if ord(chars[i]) - ord(chars[i + 1]) != -1:
res = chr(ord(chars[i]) + 1)
return res
|
class Airplane:
'''Module Airplane class
Module classes are used by the logic layer classes to create new instances of Airplane
gets an instance of a Airplane information list
Returns parameters if successful
---------------------------------
'''
... |
def palindrome(value: str) -> bool:
"""
This function determines if a word or phrase is a palindrome
:param value: A string
:return: A boolean
"""
result = True
value_rev = value[::-1]
if value != value_rev:
result = False
return result |
import pandas as pd
df = pd.DataFrame([] , columns=['col0' , 'col1' , 'col2'])
df['col0'] = [1,2,3]
df['col1'] = [4,5,6]
df['col2'] = [7,8,9]
print (f'df\n{df}')
|
from typing import List
import pandas as pd
def insert_row_to_new_df(i_row : int, df : pd.DataFrame, row : List)->pd.DataFrame:
df1 = df[0:i_row].copy()
df2 = df[i_row:]
df1.loc[i_row]=row
new_df = pd.concat([df1, df2])
new_df.reset_index(inplace... |
import pandas as pd
df1 = pd.DataFrame([[1, 2, 3, 4], [4, 5, 6 , 7], [7, 8, 9 , 10]],
columns=['col1', 'col2', 'col3' , 'col4'])
df2 = pd.DataFrame([[1, 2, 3, 4], [4, 5, 6 , 7], [7, 8, 9 , 10]],
columns=['col1', 'col2', 'col3' , 'col4'])
df3 = pd.DataFrame([[11, 2, 3, 4], [4, 5, 6... |
'''
TEMPERATURE PROGRAM
-------------------
Create a program that asks the user for a temperature in Fahrenheit, and then prints the temperature in Celsius.
Test with the following:
In: 32 Out: 0
In: 212 Out: 100
In: 52 Out: 11.1
In: 25 Out: -3.9
In: -40 Out: -40
'''
print("Welcome to my Fahrenheit to Celsius ... |
a = int(input("A:"))
b = int(input("B:"))
c = ((a ** 2 + b ** 2) ** 0.5)
print("Hipotenüs:",c) |
x=0
while (x<10):
print("x'nin değeri:",x)
x+=1 |
from distance import distance, tempDiff
def distExample():
from City import City
stg = City("Stg", 48.7758459, 9.1829321, 22)
ber = City("Ber", 52.521918, 13.413215, 21)
ham = City("Ham", 53.551085, 9.993682, 24)
nür = City("Nür", 49.452030, 11.076750, 22)
fra = City("Fra", ... |
def bubble_sorter(arr):
n=len(arr)
i=0
for j in range(0,n):
for i in range(0,n-j-1):
if (arr[i]>arr[i+1]):
arr[i],arr[i+1]=arr[i+1],arr[i]
return arr
array1=[21,4,1,3,9,20,25,6,21,14]
print(bubble_sorter(array1))
" Average and worst case time complexity: O(n*n)"
" The above algorithm alw... |
from collections import deque
queue=deque(["muffin","cake","pastry"])
print(queue.popleft())
queue.append("cookie")
print(queue)
|
def get_fib_val(pos):
if (pos==0):
return 0
if (pos==1):
return 1
first=0
second=1
next=first+second
for i in range(2,pos):
first=second
second=next
next=first+second
return next
print(get_fib_val(6)) |
numbers = {"Johan": 10.0, "Hojt": 2.1, "Peter": 5.0}
mysum = sum(numbers.values())
length = len(numbers)
avg = mysum / length
print(avg)
hej = "Hej"
print(hej.lower())
|
import numpy.linalg as LA
import numpy as np
import matplotlib.pyplot as plt
class PDF:
def __init__(self,means,variances,correlation,a_size):
self.means = means
self.variances = variances
self.correlation = correlation
self.a_size = a_size
... |
man = {
'first_name': 'Jacob',
'last_name': 'Lee',
'age': 22,
'city': 'Shanghai'
}
print(man)
python = {
'dictionary': 'it can store many Key/value pairs',
'list': 'it can store many data, but they can be changed',
'tuple': 'it can store many data, and they can\'t be changed'
}
dictionar... |
def city_country(city, country):
conclusion = f"{city.title()}, {country.title()}"
return conclusion
info = city_country("Santiago", "Chie")
print(info)
info = city_country("Shanghai", "China")
print(info)
info = city_country("Tokyo", "Japan")
print(info)
def make_album(singer_name, album_name, count):
a... |
if __name__ == '__main__':
count = input();
for i in range(0,int(count)):
mylist = input()
newlist = mylist.split(' ')
mytuple = tuple(newlist)
print(int(mytuple[0]) * int(mytuple[1])) |
import math
if __name__ == '__main__':
x = int(input())
for j in range(0, x):
n = int(input())
isPrime = 0
if n == 1:
isPrime = 1
elif n == 2:
isPrime = 0
else:
for i in range(2, math.ceil(math.sqrt(n)+1)):
if n % ... |
import numpy as np
def sigmoid(z):
return 1 / (1 + np.exp(-z))
def initialize_with_zeros(dim):
w = np.zeros(shape=(1, dim))
b = 0
assert(w.shape == (1, dim))
assert(isinstance(b, float) or isinstance(b, int))
return w, b
def propogate(w, b, X, Y):
m = X.shape[0]
... |
import nltk
from nltk import word_tokenize
with open("../feature_extraction/resources/slang_words.txt", encoding="utf-8") as f:
content = f.readlines()
slang_list = [x.strip() for x in content]
def calculate_num_slang_words(text):
if text == "":
return 0
words = word_tokenize(text)
is_slang_l... |
'''
嵌套调用 拿到另一个协程函数中的结果
'''
import asyncio
'''
队列
'''
async def add(store, name):
''' 写入数据到队列 '''
for i in range(6):
await asyncio.sleep(3)
await store.put(i)
print('{2}-->add num ...{0}, size:{1}'.format(i, store.qsize(), name))
async ... |
'''
#now_process = current_process() #当前进程
'''
import time
from multiprocessing import current_process, Pool
def run(file_name, i):
'''
多线程执行的代码 ---写入文件
:param file_name: str 文件名称
:param i: int 写入的数字
:return:
'''
now_process = current_process()
with open(file_name, 'a+'... |
while True:
a = int(input("ingrese la base del numero:"))
if a==0:
print("final del programa")
break
b = int(input("ingrese el exponente del numero: "))
def a_power_b(a, b):
prod = 1
for x in range(1, b + 1):
prod = prod * a
print(prod)
a_powe... |
import random
import time
from termcolor import colored
print("Hello there!")
time.sleep(1)
print("If you know some cities from Europe... ")
time.sleep(1)
print(colored("Let's play HANGMAN!", "green"))
time.sleep(1)
namey = input("What's your name?: ")
time.sleep(1)
print( "Hello " + namey + "!\n")
time.sleep(1)
pr... |
def get_number(starting_numbers, turn):
num_starting_numbers = len(starting_numbers)
last_seen_idx = dict()
for i, num in enumerate(starting_numbers[: len(starting_numbers) - 1]):
last_seen_idx[num] = i
last_spoken = starting_numbers[-1]
for i in range(turn - len(starting_numbers)):
... |
def pick3_ll(right_pointers, current_cup):
pick3 = []
next_ = right_pointers[current_cup]
for _ in range(3):
pick3.append(next_)
next_ = right_pointers[next_]
right_pointers[current_cup] = next_
for label in pick3:
del right_pointers[label]
return pick3, right_po... |
def find_first_invalid_number(numbers):
preamble_size = 25
for idx, number in enumerate(numbers[preamble_size:]):
offset_number = preamble_size + idx
prev_slice = numbers[offset_number - 25 : offset_number]
if not find_pairs(prev_slice, number):
return offset_number, number
... |
from typing import Optional
class ListNode:
def __init__(self, val = None):
if isinstance(val, int):
self.val = val
self.next = None
elif isinstance(val, list):
self.val = val[0]
self.next = None
cur = self
for i in val[1:]:
... |
def help():
print("""
Help
Objective
* The objective of the game is to reach 21 points or as close as possible without going over.
Rules
* The player is dealt 2 cards giving a certain total.
* The computer opponent known as the dealer is dealt 2 cards as well however only 1 is shown.
* The player can choose to H... |
nama=str(input ("write your name here: "))
age= int(input("how old are you: "))
teks= "im {} and {} years old".format(nama,age)
print(teks)
|
import Netmiko
def ssh(device_type, ipaddress):
"""
This function is used for performing ssh to linux devices
:param device_type: The device for which you want to perform ssh login.
:param ipaddress: IP address of the device.
:return: connection | None
"""
try:
connection = netmiko.... |
"""
day 9 of Advent of Code 2018
by Stefan Kruger
Solution using actual linked list to avoid O(n) insertion behaviour that
cripples part 2.
An alternative approach could have used a deque:
https://stackoverflow.com/questions/39522787/time-complexity-of-random-access-in-deque-in-python
"""
from collections import Co... |
def convert(number):
sound=''
if number%3==0:
sound='Pling'
if number%5==0:
sound=sound+'Plang'
if number%7==0:
sound=sound+'Plong'
if len(sound)==0:
sound=str(number)
return sound
|
def score(word):
marks = {'1':['A', 'E', 'I', 'O', 'U', 'L', 'N', 'R', 'S', 'T'], '2':['D', 'G' ], '3': ['B', 'C', 'M', 'P'], '4': ['F', 'H', 'V', 'W', 'Y'], '5': ['K'], '8': ['J', 'K'], '10': ['Q','Z']}
print(marks.values())
if 'A' in marks.values():
print('exists')
print(score('ABCD')) |
import sys
x=(1)
print(type(x))
x=(1,)
print(type(x))
tup_1=(1,2,3,4,5)
print('length:', len(tup_1))
print('Slicing:', tup_1[:2])
try:
tup_1[0] = 9
except Exception as e:
print(e)
for i in tup_1:
print(i, end=' ')
tup_2 = 6, 9, 8
print(tup_2)
print(type(tup_2))
a,b,c = tup_2
print(a,b,c)
pri... |
"""
This file contains all utility functions used in the "Data Analysis & Visualization" Notebook
Stephen Kaplan, 2020-07-05
"""
import matplotlib.pyplot as plt
import seaborn as sns
def get_top_stations_by_total_traffic(df, num_stations=10):
"""
Returns a DataFrame containing the busiest stations by total tr... |
from typing import *
from chord_node import ChordNode
def stabilize_and_print(nodes: List[ChordNode]):
print('**************************')
for i in range(10):
for node in nodes:
node.stabilize()
node.fix_fingers()
for node in nodes:
print(node)
print('********... |
from nltk.corpus import words
from tkinter import *
import random
def anagram_matcher():
output_word2.config(state=NORMAL)
output_word2.delete(0.0, END)
output_word2.config(state=DISABLED)
the_anagram = input_word2.get("1.0", "end-1c")
characters = the_anagram.lower()
if len(charact... |
count = 0
while (count < 100):
if count%15==0:
print ("fizzbuzz")
elif count%3==0:
print ("fizz")
elif count%5==0:
print ("buzz")
else: print ("%d" % (count))
count += 1 |
"""
Node is defined as
self.left (the left child of the node)
self.right (the right child of the node)
self.info (the value of the node)
"""
def preOrder(root):
print(preOrderHelper(root))
def preOrderHelper(root):
if(root):
result = str(root.info) + " "
result += preOrderHelper(root.l... |
def reverseArray(a):
pos0 = 0
posF = len(a)-1
while(pos0 < posF):
aux = a[pos0]
a[pos0] = a[posF]
a[posF] = aux
pos0 += 1
posF -= 1
return a
|
class Node:
def __init__(self, num_of_people, next = None):
self.num_of_people = num_of_people
self.next = next
def get_num_of_people(self):
return self.num_of_people
def get_next(self):
return self.next
def set_next(self, next):
self.next = next
class Que... |
import time
customer_name = ""
acc_no = ""
bal = 500
while True:
time.sleep(2.5)
print('+------------------------------------+')
print('| 1 - get the values |')
print('| 2 - deposit to account |')
print('| 3 - withdraw in account |')
print('| 4 - ... |
"""Embedding layer for NeuralPy"""
from torch.nn import Embedding as _Embedding
from neuralpy.utils import CustomLayer
class Embedding(CustomLayer):
"""
A simple lookup table that stores embeddings of a fixed dictionary and size
To learn more about RNN, please check pytorch
documentation at https://p... |
"""Dropout3D Layer"""
from torch.nn import Dropout3d as _Dropout3D
from neuralpy.utils import CustomLayer
class Dropout3D(CustomLayer):
"""
Applies Dropout3D to the input.
The Dropout3D layer randomly sets input units to 0 with a frequency of `rate`
at each step during training time, which helps pre... |
"""GELU Activation Function"""
from torch.nn import GELU as _GELU
from neuralpy.utils import CustomLayer
class GELU(CustomLayer):
"""
Applies the Gaussian Error Linear Units function to the input tensors.
For more information, check https://pytorch.org/docs/stable/nn.html#gelu
Supported Arguments
... |
"""Flatten layer for NeuralPy"""
from torch.nn import Flatten as _Flatten
from neuralpy.utils import CustomLayer
class Flatten(CustomLayer):
"""
Flattens a contiguous range of dims into a tensor
To learn more about Dense layers, please check PyTorch
documentation
https://pytorch.org/docs/stable/... |
MAX_LOOP = 500
def get_rightup(max = MAX_LOOP):
''' 中心からみて右斜め上方向に出現する数字列を求める関数
最大max個まで求める
先頭(0番目)は1である'''
list_rightup = [1]
n = 1
while n <= max:
list_rightup.append(list_rightup[n-1] + n*8)
n += 1
return list_rightup
def get_other(list_rightup,max = MAX_LO... |
num = int(input())
a=(num%10)
b=(num//10)%10
c=(num//10)//10
print(a+b+c)
|
number = int(input())
if number % 5 == 0:
print('zero')
if number % 5 == 1:
print('one')
if number % 5 == 2:
print('two')
if number % 5 == 3:
print('three')
if number % 5 == 4:
print('four')
|
def BubbleSort(a):
for i in range(len(a)):
for j in range(len(a) - 1):
if a[j + 1] > a[j]:
a[j], a[j + 1] = a[j + 1], a[j]
return a
a = list(map(int, input().split()))
a = BubbleSort(a)
print(' '.join(list(map(str, a))))
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.