Survey
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
Python Crash Course dd 02-09-2013 Hour 6, Intro/scripts 1. Start Ipython and type 3+4. Also enter command help(). You entered the help mode. How do you generate a list with Python keywords in this mode? Quit the help with ctrl-d. What is the configuration file directory structure for Ipython in the .ipython directory in your home and what is the purpose of this file? 2. Use all necessary steps, gibven in the sheets, to make a script that prints the result of the expression: (3+4)**11. Show script and result. 3. In computations we have to use expressions to evaluate numbers. In your script you could have used the expression. e.g.: 3*4+5. and you printed the result on screen. What if you changed the expression to: 3*(4+5). Include these expressions in your script, run it and explain the difference between these two expressions. 4. Explain what the following command will do in python. print "I will now count my chickens:" print "Hens", 25 + 30 / 6 print "Roosters", 100 - 25 * 3 % 4 print "Now I will count the eggs:" print 3 + 2 + 1 - 5 + 4 % 2 - 1 / 4 + 6 print "Is it true that 3 + 2 < 5 - 7?" print 3 + 2 < 5 - 7 print "What is 3 + 2?", 3 + 2 print "What is 5 - 7?", 5 - 7 print "Oh, that's why it's False." print "How about some more." print "Is it greater?", 5 > -2 print "Is it greater or equal?", 5 >= -2 print "Is it less or equal?", 5 <= -2 5. Show the result and explain what the operators % and ** do in the command below? x = 10.0 y = 2.0 print x + y print x - y print x * y print x / y print x % y print x**y 6. xc = 8.3 , xxc = 3.0 -5.0j, print xc * xxc. Include the three lines in this example in your own program and show the result. What is the conclusion about: a. the multiplication? b. the type of the result? 7. a = 10, a += 1, a -= 2, a *= 20, a /= 9, a **= 2 ; print a. Include the lines of this last example in your program. What is the output? Did you expect this? 8. Take a number and use that number of sides on a polygon and find the number of diagonals within the polygon. 9. Take the lengths of two sides of a right-angle triangle from the user and apply the Pythagorean Theorem to find the hypotenuse.