I want to check if the input of the user for n is a number, and if it isnt I want to ask…
- User
I want to check if the input of the user for n is a number, and if it isnt I want to ask again for input: if 2 <= n <= 12 and math.isnan(n) == True: # Iterate x and y starting from 10 up to k+1 where k is determined by the user for x in range(10, k+1): for y in range(10, k+1): # Calculate the miss size for the current x, y, and n miss, sum_xy, z = miss_size(x, y, n) # Calculate the relative miss relative_miss = miss/sum_xy print("for x: ", x) print("for y: ", y) print("for z: ", z) print("Miss: ", miss) # Update the smallest relative miss if the current one is smaller if relative_miss < smallest_relative_miss: smallest_relative_miss = relative_miss print("Smallest Miss: ", smallest_relative_miss) print() else: print("Please enter a number between 2 and 12") # Recursive call to user_input if the input is not valid user_input() print("The smallest possible miss: ", smallest_relative_miss) return smallest_relative_miss
- Assistant
- User
im coding in python
- Assistant
I see that you're coding in Python, and from your message, it seems like you're looking to implement a user input validation loop. Below is an example of a Python function that prompts the user for a number, checks if it's within a specific range, and keeps asking until a valid input is provided:
- User
generate a response to this discussion post. Try not to use too many big words: Things like performance, usability, reliability are defined by the NFRs, so its very important for the engineer to know the constraint and parameters they have to work in. It ensure that the system meets criteria that are needed beyond just the functional features of the code.
The customer needs to know because of the impact they have on a system. They are a direct contributor to the cost of a project. Ensuring your customer understands them helps to manage their expectations and ensures the projects goals are met while helping to mitigate miscommunication. It also keeps the customer informed about the trade offs that may arise from different requirements.
- Assistant
You're absolutely right. Non-functional requirements (NFRs) are super important because they tell us about the quality of the system, not just what it does. It's kind of like knowing not only that a car can drive but also how fast, how safe it is, and how easy it is to drive.
For engineers, knowing these rules and limits they need to stay within helps make sure they build the system right. It's like knowing the rules of a game before you start playing.
And for the customer, understanding these non-functional stuff is key because it affects how much the project will cost and what they can expect at the end. Being clear about this from the beginning stops any surprises later on and helps everybody stay on the same page. Plus, customers get why sometimes you have to balance different things—like whether to make something super fast or a bit cheaper.
It's all about making sure everyone involved knows what's going on and what they're getting into.