Tutor profile: Cyan K.
Subject: Python Programming
As an example of how function execution works with imported modules, take two scripts, testmain.py and testmain2.py. Here is testmain: def main(): print("Hello World!") main() print("Hello World!") And here is testmain2: import testmain testmain.main() print("Hello World!") How many times does "Hello World" appear when you run testmain.py? How many times does "Hello World" appear when you run testmain2.py?
For testmain.py, twice. 1. The main() function executes first. 2. Then the print statement is executed second. For testmain2.py, four times. 1. The testmain script is imported, and with it, the main() function executes 2. Then testmain's print statement executes. 3. Testmain2 invokes the main function of testmain, which prints it again. 4. Finally the print statement in testmain2 executes. Follow up question: How would you modify testmain.py so that "Hello World!" prints twice when you run it directly, but three times when you run testmain2.py? Answer: Move the second print statement underneath an if __name__=='__main__': statement
Repmat is a function that repeats an array or matrix. Let's define a variable 'a': >> a = [1:3; 4:6]; Write a statement using repmat and 'a' as the matrix to be copied, to create the following output: 2 2 5 5 2 2 5 5
Possible answers are: >> repmat(a(:,2), 2, 2) or >> repmat(a(:,2), [2 2]) or >> repmat(a(:,2), [2, 2])
Subject: Human-computer Interaction
Fitt's law is a model which predicts that the time it takes for a user to point to a target. The pointing can be done either physically with hands and fingers, or virtually using a pointing device (i.e. a mouse) on a computer screen. The amount of time it takes to point to a target relies on a few factors: one is the distance to the object. Use your intuition and name two other factors that would affect the movement time.
The pointing device or interface can affect the movement time. For most people with normal movement, pointing with one's finger is much easier than, say, pointing with a mouse or a joystick. The size of the target also will affect the time to target. Targets with a larger area will be easier to point to than smaller ones.
needs and Cyan will reply soon.