Пример #1
0
def calculating():
    x = input("Please enter the first number of your choice: ")
    if x == 'q':
        go_away()
    else:
        x = int(x)
        y = input("Please enter the second number of your choice: ")
        if y == 'q':
            go_away()
        else:
            y = int(y)
            print(
                "I can perform addition, subtraction, division and multiplication. What do you intend to perform?"
            )
            s = input("Please type the initials for each operation.")
            s = s.lower()
            if s == 'a':
                first.add(x, y)
            elif s == 's':
                first.sub(x, y)
            elif s == 'm':
                first.mul(x, y)
            elif s == 'd':
                first.div(x, y)
            elif s == 'q':
                go_away()
            else:
                print(
                    "This is beyond my scope of learning as of now. Please try again."
                )
Пример #2
0
def main():
    """
    The main entry point of the application
    """
    #get logger
    logger.setLevel(logging.INFO)
    # create the logging file handler and formatter
    fh = logging.FileHandler(FILEPATH)
    formatter = logging.Formatter(
        '%(asctime)s - %(name)s - %(levelname)s - %(message)s')
    fh.setFormatter(formatter)
    # add handler to logger object
    logger.addHandler(fh)

    logger.info("Program started")
    first.add(7, 8)
    second.add(7, 8)
    logger.info("Done!")
Пример #3
0
#####################################################################################
#
#  Copyright (c) Microsoft Corporation. All rights reserved.
#
# This source code is subject to terms and conditions of the Apache License, Version 2.0. A
# copy of the license can be found in the License.html file at the root of this distribution. If
# you cannot locate the  Apache License, Version 2.0, please send an email to
# [email protected]. By using this source code in any fashion, you are agreeing to be bound
# by the terms of the Apache License, Version 2.0.
#
# You must not remove this notice, or any other, from this software.
#
#
#####################################################################################

import first

print first.add(1, 2)
print first.add("Iron", "Python")
print first.factorial(10)
Пример #4
0
#####################################################################################
#
# Copyright (c) Microsoft Corporation. 
#
# This source code is subject to terms and conditions of the Microsoft Public
# License. A  copy of the license can be found in the License.html file at the
# root of this distribution. If  you cannot locate the  Microsoft Public
# License, please send an email to  [email protected]. By using this source
# code in any fashion, you are agreeing to be bound by the terms of the 
# Microsoft Public License.
#
# You must not remove this notice, or any other, from this software.
#
#####################################################################################

import first

print first.add(1, 2)
print first.add("Iron", "Python")
print first.factorial(10)
'''
如何引用其他路径下的python文件
引用“D:/DFWworkspace/PY4E”中的first.py
'''

import sys

sys.path.append(r"D:/DFWworkspace/PY4E")

import first

a = first.add(3, 5, 8)
print(a)
Пример #6
0
from first import add, mul

result = add(3, 9)
print(result)

print(mul(1, 2))