我有一個簡單的Python程序,我正在開發,而且我是編程新手,並且工作不太好。我仍然在學習模塊和函數,但這裏是程序要求。我無法理解程序的導入和調用部分以及模塊參數參數,以及全局變量和局部變量。我仍然在學習,所以任何反饋或建議都會有所幫助。我的書似乎主要是用僞代碼編寫的,而不是真正的Python代碼,它讓事情變得混亂。用於簡單指數計算的Python模塊
'''
Write a program that has thee modules:
1) the first module takes two numbers from the user
2) the second module calculate firstNumber to the power of secondNumber and prints it
3) the third module will print 'end of program'
'''
Module main()
#Global Variables
Declare Integer num1
Declare Integer num2
#Welcome Exponent Power Program
Print ('Welcome to the Exponent Powers Program.')
Call askNumbers(num1, num2)
Call numberPower
Call endProgram
End Module
#This program gets the 2 numbers from the user
Module askNumbers(Integer num1, Integer num2)
num1 = int(raw_input('Enter Number : '))
num2 = int(raw_input('Enter Raised Power Number: '))
End Module
Module numberPower(int num1, int num2)
Declare Int expTotal
Set expTotal = (num1**num2)
Print(expTotal)
End Module
Module endProgram()
Print('End of Program')
End Module
偉大的幫助,並再次感謝您的時間。
這是VisualBasic中...爲什麼你在Python過程中使用VBA的書?這很奇怪 –