import math
import numpy as np
import matplotlib.pyplot as plt

print("y = a^x + b")
jarda=0
while jarda<=0 or jarda==1:
 jarda=int(input("zadej a "))

def v() :
 while True:
   číslo=(input("zadej b "))
   try :
return int (číslo)
  except ValueError
 print("nebylo zadané číslo")
barca=b()

A = int (input("zadej počáteční hodnotu def.oboru "))
B = int (input("zadej konečnou hodnotu def.oboru "))

if barca>=0:
 print("Px není")
else:
 print("Px je:[0; ",(math.log(-barca,jarda)))
 print("Py je:[0; ",(jarda0+barca))
if barca<=0:
 print("Py není")
else:
 print("Py je:[0; ",(jarda0+barca))

x= np.linspace(A,B)
y = jarda**x+barca

plt.plot(x,y, color="pink")
plt.axhline(y=0,color="black")
plt.axvline(x=0,color="orange")
plt.xlabel("x")
plt.ylabel("y")
plt.box(True)
plt.grid(True)
plt.title("exponenciální funkce")

Run the code. Python will tell you what is wrong and where. For example, I get syntax errors on line 14-16. Python requires consistent indentation, and you haven't done that here. Also, line 15 needs a ':' at the end of an except statement.

Fix those and the program then gets a runtime error on line 18: "NameError: name 'b' is not defined". At this point, I'm at a loss as to how to help you find your other problems. I don't speak Czech.

I will suggest that you find a Python-friendly programmer's editor. Use the one that comes with Python's "Idle" package if you don't have anything else, but find something that will help you with consistent indentation. Use spaces, not tabs, and use the same number of characters at each indentation level. The recommended indentation is four (4) spaces for each level of nesting.

Another suggestion is to define all of your functions first. Don't mix function defintions and main program code. Leave blank lines between functions definitions so it's clear where individual function definitions begin and end. Your first steps might get you a source file that looks something like:

import math
import numpy as np
import matplotlib.pyplot as plt

def v() :
    while True:
        číslo=(input("zadej b "))
        try :
            return int (číslo)
        except ValueError:
            print("nebylo zadané číslo")

print("y = a^x + b")
jarda=0
while jarda<=0 or jarda==1:
    jarda=int(input("zadej a "))

barca=b()  ### NameError: name 'b' is not defined

A = int (input("zadej počáteční hodnotu def.oboru "))
B = int (input("zadej konečnou hodnotu def.oboru "))

if barca>=0:
    print("Px není")
else:
    print("Px je:[0; ",(math.log(-barca,jarda)))
    print("Py je:[0; ",(jarda0+barca))
    if barca<=0:
        print("Py není")
    else:
        print("Py je:[0; ",(jarda0+barca))

        x= np.linspace(A,B)
        y = jarda**x+barca

        plt.plot(x,y, color="pink")
        plt.axhline(y=0,color="black")
        plt.axvline(x=0,color="orange")
        plt.xlabel("x")
        plt.ylabel("y")
        plt.box(True)
        plt.grid(True)
        plt.title("exponenciální funkce")

I added a comment to the line that tries to all call an undefined function named "b()". I hope some of this helps.

If you are going to print out y = a^x + b, and you are going to prompt for a, b, etc, then you might as well use a and b as the variable names.

If you are going to go to the trouble of creating an integer input function then you might as well use it. And on that note, your input function should have a descriptive name. I suggest

def getInteger(prompt='Enter a number: '):
    while True:
        number = (input(prompt))
        try :
            return int (number)
        except ValueError:
            print("That is not a number. Try again.")

Note that getInteger accepts the prompt as a parameter.

The line

while jarda <= 0 or jarda == 1:

can be replaced with

while jarda <= 1:

since jarda is an integer value. And if you are going to restrict the input to integers > 1 you should tell the user what is expected. I suggest

while jarda <= 1:
    jarda = getInteger("Enter an integer value > 1 for a: ")

I think this is a typo. Change

barca = b()

to

barca = getInteger("Enter an integer value for b: ")

Replace

A = int (input("zadej pocátecní hodnotu def.oboru "))
B = int (input("zadej konecnou hodnotu def.oboru "))

with calls to getInteger

You are using jarda0 without having initialized it.

Start with this and get back to us with further questions.

commented: Thank you Reverend Kim +15
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.