def findScalarMul(decimal,P,a,p):
	R=P;
	binary="{0:b}".format(decimal);
	for i in range(1,len(binary)):
		if binary[i]=='1':
			R=Addition.doubleP(R,a,p);
			R=Addition.addP(P,R,a,p);
		else:
			R=Addition.doubleP(R,a,p);

	return R;
Example #2
0
def findOrder(P,a,p):
	R=P;
  	order=1;
  	Result=Addition.doubleP(P,a,p)
  	while Result!='O':
  		#print Result;
  		order=order+1;
  		R=Result;
  		Result=Addition.addP(P,R,a,p);

  	order=order+1;
  	return order;
Example #3
0
def findOrder(P, a, p):
    R = P
    order = 1
    Result = Addition.doubleP(P, a, p)
    while Result != 'O':
        #print Result;
        order = order + 1
        R = Result
        Result = Addition.addP(P, R, a, p)

    order = order + 1
    return order
Example #4
0
File: HMM.py Project: ahhlau/cs329e
def p_addition(p):
    '''addition : term
                | term addOP addition'''
    from java.lang import Math
    import Addition
    if len(p) == 4 and isinstance( p[1], int ) and isinstance( p[3], int ):
        print "Calling java Math: ", Math.max(p[1], p[3])
        print "Calling java Addition.add: ", Addition.add(p[1], p[3])
    if len(p) == 4: p[0] = str(p[1]) + str(p[2]) + str(p[3])
    else : p[0] = p[1]
Example #5
0
def query_handler(call):
	global done, msg
	done = call.data
	if call.data == 'btn_1':
		answer = 'Начнем регистрацию команды с ввода названия. Наберите имя команды и, ' \
				 'когда будете уверены, подтвердите нажатием на кнопку'
		bot.send_message(call.message.chat.id, answer, reply_markup=Buttons.keyboard_step2)

	elif call.data == 'btn_2':
		answer = 'Получите помощь :-)'
		bot.send_message(call.message.chat.id, answer, reply_markup=Buttons.keyboard_step1)

	elif call.data == 'btn_7':
		answer = 'Вы зарегестрировали вот эти команды. Выберите одну из команд, чтобы увидеть состав этой команды'
		Buttons.create_btn_teams(Addition.find_my_teams(call))
		bot.send_message(call.message.chat.id, answer, reply_markup=Buttons.keyboard_step7_1)
		Buttons.keyboard_step7_1 = types.InlineKeyboardMarkup()

	elif call.data == 'btn_3':
		Addition.create_team(msg)
		answer = 'Название команды подтверждено. Приступим к наполнению команды спорстменами. ' \
				 'Введите ФИО и дату рождения в формате дд.мм.гггг ' \
				 'Дальше подтвердите нажатием на кнопку "Утверждаю спортсмена"'
		bot.send_message(call.message.chat.id, answer, reply_markup=Buttons.keyboard_step3)

	elif call.data == 'btn_4':
		Addition.add_members(msg)
		answer = 'Что будем делать дальше?'
		bot.send_message(call.message.chat.id, answer, reply_markup=Buttons.keyboard_step4)

	elif call.data == 'btn_5':
		answer = 'Введите ФИО и дату рождения в формате дд.мм.гггг ' \
				 'Дальше подтвердите нажатием на кнопку "Утверждаю спортсмена"'
		bot.send_message(call.message.chat.id, answer, reply_markup=Buttons.keyboard_step3)

	elif call.data == 'btn_6':
		Addition.members_team(msg)
		answer = 'Что дальше?'
		bot.send_message(call.message.chat.id, answer, reply_markup=Buttons.keyboard_step5)

	elif call.data.startswith('btn_7_1_'):
		Addition.members_team(call)
Example #6
0
class calculator:
    print("choose option : ")
    print("1. Addition")
    print("2. Subtract")
    print("3. Division")
    n = int(input("select option: "))
    if(n==1):
        print("Addition is selected")
        num1 = int(input("Enter the number:"))
        num2 = int(input("Enter the number:"))
        obj = Addition(num1, num2)
    if(n==2):
        print("Subtraction is selected")
    if(n==3):
        print("Division is selected")
Example #7
0
#sys package to find python path
import sys
sys.path

#random function

import random
for x in range(5):
    print(random.randint(1, 101))

#pandas package

dict = {"country": ["Brazil", "Russia", "India", "China", "South Africa"]}
import pandas as pd
bb = pd.DataFrame(dict)
print(bb)


#create a module to link to another py file#
def sum(a, b):
    return a + b


myList = [1, 2, 3, 4, 5]

import Addition
print(Addition.sum(2, 3))
Addition.myList
Example #8
0
'''
Modules
-------
In python each python file is considered as a module.

In java, we need not specify import of the package if the class we use is within same package. But in python whether if
the file we refer is in same directory/package then also we need to specify 'import' of that.

NOTE : We should not use '_' in file names because when we import that module. if name contains '_', it will not find that file.

'''

# When we import any module. python will literally execute that file/module. In this case, 'Addition.py' have
# print statement "Start of Addition Module" and then definition of function 'addition()'.
# So in below statement, we import 'Addition.py' so it is executed and prints "Start of Addition Module"
import Addition as add  # Output --> "Start of Addition Module"

# NOTE : due to this we should always put whatever we want to do within function definitions instead of putting it
#        outside. because when we import a module, we don't want something to be executed in that file, we just
#        import that module in our file.

print(add.addition(5, 3))  # Output --> 8

import packageY.Substraction as sub  # Importing a module within different package. Syntax --> 'Package.module'

print(sub.substraction(5, 3))  # Output --> 2
Example #9
0
#Style1
import Addition

print(Addition.add(4, 5))
print(Addition.add(14, 5))
print(Addition.add2(14, 15))
print(Addition.add2(14))

#Style2
from Addition import *

print(add(4, 5))
print(add(14, 5))
print(add2(14, 15))
print(add2(14))
Example #10
0
# link to download python ----> https://www.python.org/downloads/

# 1)Loading whole module
# syntax ---> import module_name

import Addition

sum1 = Addition.add_two_numbers(20, 30)
print('Sum1 ==== ', sum1)

sum2 = Addition.add_three_numbers(20, 30, 40)
print('Sum2 ==== ', sum2)

print('List1 ==== ', Addition.num_list)

# print('dict1 ===== ',Addition.dict11) #<----- error

# 2)Loading module and giving different name/ alias
# syntax ---> import module_name as alias_name

import Addition as ad

sum1 = ad.add_two_numbers(20, 30)
print('Sum1 ==== ', sum1)

sum2 = ad.add_three_numbers(20, 30, 40)
print('Sum2 ==== ', sum2)

print('List1 ==== ', ad.num_list)

# 3) Importing only selected functions or variables
Example #11
0
import Addition
print(Addition.add(10,20))
print(__name__)