Prototype of python application

Asked

Viewed 142 times

-3

Guys, I have a lot of work to do on creating a prototype of these parking apps, and I’m kind of new to programming and I’d like to know what I could improve on these coding lines:

telaInicio = int(input("Digite 1 para se cadastrar ou 2 para entrar: "))


if telaInicio == 1:
    usuarioCadastro = input("Digite seu usuario: ")
    senhaCadastro = input("Digite sua senha: ")
    print("Cadastro efetuado com sucesso !")

if telaInicio == 2:
    usuarioLogin = input("Digite seu Usuario: ")
    senhaLogin = input("Digite sua Senha: ")
    print("Acesso Confirmado !!!")
print("Para a utilização do aplicativo é necessario ter creditos em sua conta")
valor1 = int(input("Digite 10 para 10R$, 20 para 20R$ ou 50 para 50R$ : "))

if valor1 == 10:
    print("Voce comprou 10 Reais em creditos")
    if valor1 == 20:
        print("Voce comprou 20 reais em creditos")
    if valor1 == 50:
        print("Voce comprou 50 reais em creditos")

#opcoes para o usuario escolher
print("Para compra de creditos digite 1: ")
print("Para definir horario, carro ou dia digite 2: ")
print("Para cadastrar o veiculo digite 3: ")
print("Para vizualizar seus creditos digite 4: ")
print("Para vizualizar o ultimo uso digite 5: ")

opcao = int(input("Digite sua Escolha: "))

if opcao == 1:
    valor1 = int(input("Digite 10 para 10R$, 20 para 20R$ ou 50 para 50R$: "))
    if valor1 == 10:
        print("Voce comprou 10 Reais em creditos")
    if valor1 == 20:
        print("Voce comprou 20 reais em creditos")
    elif valor1 == 50:
        print("Voce comprou 50 reais em creditos")


if opcao == 2:
    carroDia = int(input("Deseja definir seu carro digite 1, Para definir seu dia e horario digite 2: "))
    if carroDia == 1:
       carroDefinido = input("Qual carro deseja definir ?: ")
       print("O carro",carroDefinido,"foi definido com sucesso !")
    if carroDia == 2:
       diaHorario = input("Digite o dia e o horario que deseja definir: Ex: 19/05 as 17:00: isso ira custar 10R$: ")
       print("Seu dia e horario ficaram definidos para: ",diaHorario)
       print("Seu saldo ficou com: ",valor1 - 10)


#opcao para cadastrar veiculo
if opcao == 3:
     cadastroCarro = input("Digite o ano e o modelo do carro: Ex: Honda Civic 2013: ")
     cadastroPlaca = input("Digite a placa do seu veiculo: Ex QAM-2513: ")
     print("O seu veiculo", cadastroCarro, "com o emplacamento",cadastroPlaca, "foi cadastrado com sucesso")

if opcao == 4:
    print("Seus creditos são de:",valor1,"R$")

  • 2

    The biggest problem of this question, in my view, is that it doesn’t even have a definition of what soft should do, in addition to reviewing the code needs "reverse engineering" to know what it does, nor does it say what the expected revision looks like, it was almost "based on opinion" broad. There could be endless answers with completely different and even incorrect codes, to make things worse. [Edit] as suggested in the table above resolving these issues could possibly make it possible to reopen the post.

1 answer

5

  1. The algorithm for registering the password is wrong. You have to ask twice for the password and confirm if it is the same, if you don’t have to error.

  2. The code does not use loops (loops), such as the while. Haven’t you studied yet? They are necessary to return to certain steps of the code, as in the case of inserting a value that failed to be outside the expected range, for example, until the user fills in correctly (as for example the password of the previous point).

  3. You repeat code, for example buying credit. Study how to divide code into functions, then you can call them when you need that same piece of code to run in different places.

  4. This line here contrary to what you think is not changing the value of valor1, he’s still worth what he was before:

    print("Seu saldo ficou com: ",valor1 - 10)

  5. The names of the variables are not terribly bad, but it doesn’t hurt to recommend to study how to give good names to variables. The worst thing I found was this valor1.

So in a glance over that’s what I thought might improve.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.