Question

In: Computer Science

Python. 1.Why is it a good idea to write and test the code for laying out...

Python.

1.Why is it a good idea to write and test the code for laying out a window's components before you add the methods that perform computations in response to events?

2.Explain why you would not use a text field to perform input and output of numbers.

3.Write a line of code that adds a FloatField to a window, at position (1, 1) in the grid, with an initial value of 0.0, a width of 15, and a precision of 2.

4.What happens when you enter a number with a decimal point into an IntegerField?

5.When would you make a data field read-only, and how would you do this?

Solutions

Expert Solution

1.Window components are often laid and tested before adding to the computation in perform of events so that its feel and look can be checked individually and the corresponding event handlers performance can also be reviewed

2.If the text field is used for input and output of numbers, the data needs to be converted to string after the input is stored and also before output is produced. To simplify this task of the compiler, the IntegerField and FloatField are used which provides a value attribute in advance to the data.

3.The correct code for displaying this is

self.addFloatField(initial value,row grid value, column grid value,width, precision,type)

here initial value=(0,0)

row grid value=1

column grid value=1

width=15

precision=2

Therefore, the code becomes

self.addFloatField(value=0.0,row=1,column=1,width=15,precision=2);

4. The only difference between the integerfield and floatfield is the amount of characters it can take. IntegerField can take width of 10 whereas FloatField can take value of 20. Moreover float field has an additional precision element . The data is processed equally by both of them.


Related Solutions

why is it often a good idea to group particular elements together in a scene. write...
why is it often a good idea to group particular elements together in a scene. write the code in jsGraph
please answer this in a simple python code 1. Write a Python program to construct the...
please answer this in a simple python code 1. Write a Python program to construct the following pattern (with alphabets in the reverse order). It will print the following if input is 5 that is, print z one time, y two times … v five times. The maximum value of n is 26. z yy xxx wwww vvvvvv
#python #code #AP class #Tech write a function code script which will print out number pyramid...
#python #code #AP class #Tech write a function code script which will print out number pyramid in the form of * so the output will be made up of **** resting on top of each other to form a pyramid shape. Bottom layer should be made of 5 multiplication signs like ***** then next 4 multiplication signs and so on. Top part should have only one *
write code in python and test Conversation with an AI ChatBot Learning Outcomes: Use the print()...
write code in python and test Conversation with an AI ChatBot Learning Outcomes: Use the print() function to output a variety of data Use the input() function to ask for multiple data types Use basic arithmetic operations in a program Use string methods and operations Use if/else if/else statements to determine the flow of the program Comment your code Debug your code Test your code Scenario A new marketing company is launching an Artificial Intelligence (AI) ChatBot for their website...
Please write in beginner level PYTHON code! Your job is to write a Python program that...
Please write in beginner level PYTHON code! Your job is to write a Python program that asks the user to make one of two choices: destruct or construct. - If the user chooses to destruct, prompt them for an alternade, and then output the 2 words from that alternade. - If the user chooses construct, prompt them for 2 words, and then output the alternade that would have produced those words. - You must enforce that the users enter real...
CODE IN PYTHON 1. Write a program that asks the user for the number of slices...
CODE IN PYTHON 1. Write a program that asks the user for the number of slices of pizza they want to order and displays the total number of dollar bills they owe given pizza costs 3 dollars a slice.  Note: You may print the value an integer value. 2. Assume that y, a and b have already been defined, display the value of x: x =   ya+b    3. The variable start_tees refers to the number of UD T-shirts at the start...
Describe what a pro se action is. Is it a good idea?Why or why not?...
Describe what a pro se action is. Is it a good idea? Why or why not?(This is in relation to criminal justice)
Is unionization a good idea for nursing homes? Why or why not? If you were an...
Is unionization a good idea for nursing homes? Why or why not? If you were an administrator, how would unionized workers on your staff affect your ability to run the nursing facility? If you were a facility administrator, what measures would you take to ensure the safety of your employees?
1. Write Python code to - (a) ask user to enter a list of animals, one...
1. Write Python code to - (a) ask user to enter a list of animals, one item at a time, until “done” to terminate input (b) randomly display a selected item from the list, starting with “I like ______”. When run, the output should look something like this: Enter an item; 'done' when finished: cats Enter an item; 'done' when finished: dogs Enter an item; 'done' when finished: guinea pigs Enter an item; 'done' when finished: done You are done...
4.9 Branching Practice - Python Exercise #Write the code for the following # Exercise 1 #...
4.9 Branching Practice - Python Exercise #Write the code for the following # Exercise 1 # Ask user for a number using an input statement (no prompt) & assign the input to a variable # Convert the user entry to an integer and assign it to a variable # Condition: user entry is greater than zero # Action: display the following word on screen: positive # Exercise 2 # Ask user for a number using an input statement (no prompt)...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT