Почему моя импортированная функция не работает в моем основном файле в PythonPython

Программы на Python
Ответить Пред. темаСлед. тема
Anonymous
 Почему моя импортированная функция не работает в моем основном файле в Python

Сообщение Anonymous »

Я делаю демонстрацию всех моих программ на Python из разных файлов, и я не хочу перемещать весь код в основной файл.
(извините за имена функций и переменных, а также за орфографию, я незрелый и плохой в программировании)
Я пытался импортировать функцию из файла в коде Visual Studio, но все, что она сделала, когда я ее вызвал, это
0 to stop
1 for settings
2 for calculator
3 for number game
4 for palindrome detector
5 for pig latin translator
6 for anagram maker
7 for averager
8 for temperature calculator
9 for area calculator
what do you want: 1

затем я попробовал просто импортировать сам файл без этой функции и получил тот же результат.
мой код предназначен для основного:
import time
from utils import type_text
from config import debugging
from calculater import calcu
from area_calculater import area
from anagram import anagram
from average import run
from code import tuchy
from number_game import game
from paladrome import pal
from pig import call
from temp_calculate_hub import farinhight451
from settings import changeSettings
hubo = 0

def hub():
while True:
type_text("Welcome to the hub. I am hubby I will direct you to wherever you want.")
hubo = 0
type_text("0 to stop")
type_text("1 for settings")
type_text("2 for calculator")
type_text("3 for number game")
type_text("4 for palindrome detector")
type_text("5 for pig latin translator")
type_text("6 for anagram maker")
type_text("7 for averager")
type_text("8 for temperature calculator")
type_text("9 for area calculator")
hubo = int(input("what do you want: "))
if hubo == "":
type_text("oops looks like you are a bit trigerhappy")
else:
if hubo ==0:
type_text("Goodby please come back soon! ##connection terminated by:Hubby##")
time.sleep(1)
quit()
if hubo ==2:
type_text("Ok sending you to Calcu.")
time.sleep(1)
calcu()
elif hubo ==3:
type_text("Ok sending you to Guessy.")
time.sleep(1)
game()
elif hubo ==4:
type_text("Ok sending you to Pally.")
time.sleep(1)
pal()
elif hubo ==5:
type_text("Ok sending you to Pig.")
time.sleep(1)
call()
elif hubo ==6:
type_text("Ok sending you to Anny.")
time.sleep(1)
anagram()
elif hubo ==7:
type_text("Ok sending you to AV (she is a bit crazy).")
run()
elif hubo ==8:
type_text("Ok sending you to Kelvin.")
farinhight451()
elif hubo ==9:
type_text("Ok sending you to Arion.")
area()
elif hubo ==11:
type_text("Sorry this option is not available yet.")
elif hubo ==10:
type_text("Sorry this option is not available yet.")
elif hubo ==1:
changeSettings()
elif hubo == 7232010:
tuchy()
else:
type_text("Sorry this option is not available yet.")

if not debugging:
print("initiating")
time.sleep(1.5)
print("initiating")
time.sleep(1.5)
print("initiating")
time.sleep(1.5)
print("initiating")
time.sleep(1.5)
print("connection successful")
time.sleep(1)
hub()
else:
hub()

пример моей импортированной функции:
from config import debugging
from utils import type_text
def calcu():
operation = 0
type_text("Hi this is Calcu. What do you want me to calculate today")
a = "n/a"
b = "n/a"
while True:
type_text("0 to stop")
type_text("1 for division")
type_text("2 for multiplication")
type_text("3 for subtraction")
type_text("4 for addition")
type_text("5 for modulo")
type_text("6 for factoring")
operation = input("what do you want: ").lower()
if operation == "":
type_text("oops looks like you are a bit trigerhappy")
else:
if operation == "0":
type_text("ok sending you back to Hubby.")
break
if operation == "1" :
while True:
a = int(input("what is the first number:"))
if a == "":
type_text("oops looks like you are a bit trigerhappy")
else:
while True:
b = int(input("what is the second number: "))
if b == "":
type_text("oops looks like you are a bit trigerhappy")
else:
if b == 0 :
type_text("division by 0 error")
else:
print(a,"/",b,"=",a/b)
break
if operation == "2" :
while True:
a = int(input("what is the first number: "))
if a == "":
type_text("oops looks like you are a bit trigerhappy")
else:
while True:
b = int(input("what is the second number: "))
if b == "":
type_text("oops looks like you are a bit trigerhappy")
else:
print(a,"X",b,"=",a*b)
if operation == "3" :
while True:
a = int(input("what is the first number: "))
if a == "":
type_text("oops looks like you are a bit trigerhappy")
else:
while True:
b = int(input("what is the second number:"))
if b == "":
type_text("oops looks like you are a bit trigerhappy")
else:
print(a,"-",b,"=",a-b)
if operation == "4" :
while True:
a = int(input("what is the first number:"))
if a == "":
type_text("oops looks like you are a bit trigerhappy")
else:
while True:
b = int(input("what is the second number:"))
if b == "":
type_text("oops looks like you are a bit trigerhappy")
else:
print(a,"+",b,"=",a+b)
if operation == "5" :
while True:
a = int(input("what is the first number:"))
if a == "":
type_text("oops looks like you are a bit trigerhappy")
else:
while True:
b = int(input("what is the second number:"))
if b == "":
type_text("oops looks like you are a bit trigerhappy")
else:
print(a,"%",b,"=",a%b)
if operation == "6" :
while True:
a = int(input("what is the first number:"))
if a == "":
type_text("oops looks like you are a bit trigerhappy")
else:
while True:
b = int(input("what is the second number:"))
if b == "":
type_text("oops looks like you are a bit trigerhappy")
else:
print(a,"^",b,"=",a**b)


Подробнее здесь: https://stackoverflow.com/questions/790 ... -in-python
Реклама
Ответить Пред. темаСлед. тема

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

  • Похожие темы
    Ответы
    Просмотры
    Последнее сообщение

Вернуться в «Python»