-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathvalues-types-and-variables.yaml
78 lines (61 loc) · 4.8 KB
/
values-types-and-variables.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
- Category: text
Output: "This interactive tutorial is the first in a series based on Alan Downey's book, Think Python."
- Category: command
Output: "The prompt, >>>, below indicates that you should enter a Python command. Enter print('Hello, world!')."
Answer: print('Hello, world!')
Hint: "Type print('Hello, world!') and hit the Enter key."
- Category: text
Output: "The command, print('Hello, world!'), which you typed is called source code. The result, Hello, World!, which appeared after you entered the command is called output. The Python interpreter converted your source code to output."
- Category: multiplechoice
Output: "If you wanted the output, Jinkies!, which of the following commands should you type?"
Choices:
- print('Jinkies!')
- print('Jinkies')
- print('Scooby-dooby-do, where are you?')
- print('If it weren't for those meddling kids!')
Answer: print('Jinkies!')
Hint: "Look for the command, print, and the word, 'Jinkies!' (with an !)"
- Category: command
Output: "The command which you typed consists of a function name, print, and an argument, 'Hello, world!' inside the parentheses. The print command can take any quoted sequence, such as 'Jinkies!', as an argument. The help command is another which takes a quoted argument. To see what it does, enter help('keywords') at the prompt (>>>) below."
Answer: help('keywords')
Hint: "Type help('keywords') and hit the Enter key."
- Category: text
Output: "The help command listed all the special words which Python reserves for its own use. Among them are the words, True and False. More about these later."
- Category: text
Output: "Everything in Python has a type. For instance, 'Hello, world!' is a string, and print is a built-in function. Other types are integers like 1 and -44, and floating point numbers like 3.14 and -1.5. The type command returns the type of its argument. A few exercises with the type command follow."
- Category: command
Output: "Enter the command, type('Hello, world!'), to determine the type of the quoted sequence of letters and punctuation."
Answer: type('Hello, world!')
Hint: "Enter type('Hello, world!')"
- Category: command
Output: 'Double quotes may also be used to create a string, type("Hello, world!"), to demonstrate this.'
Answer: type("Hello, world!")
Hint: Enter type("Hello, world!")
- Category: command
Output: "Find the type of the integer, 17, being careful not to enclose the number in quotes. Enclosing it in quotes would make it a string."
Answer: type(17)
Hint: Enter type(17), being careful not to quote the argument.
- Category: command
Output: "The type of a number with a decimal point will be floating point or float. Enter type(17.) to demonstrate this."
Answer: type(17.)
Hint: Enter type(17.), being careful to include the decimal point.
- Category: text
Output: "Python’s syntax for math operations is almost the same as standard mathematical notation. For example, the symbols + , -, *, and / denote addition, subtraction, multiplcation and division."
- Category: text
Output: "We can use these operations to solve a problem such as this: If you run a 10 kilometer race in 43 minutes 30 seconds, what is your average time per mile? (Hint: there are 1.61 kilometers in a mile)."
- Category: multiplechoice
Output: "Since we want time per mile rather than time per kilometer, we can first convert 10 kilometers to equivalent miles, using one of the four arithmetic operators just mentioned. Which of the following expressions would we use?"
Choices: [ 10/1.61, 10*1.61, 10+1.61, 10-1.61 ]
Answer: 10/1.61
Hint: "Since miles are longer than kilometers, the answer will be less than 10. If you run 1.61 kilometers, you have run 1 mile. If you run 2*1.61 kilometers, you have run 2 miles, and so on."
- Category: multiplechoice
Output: "Ten kilometers is about 10/1.61, or 6.2, miles. Your total time was 43 minutes and 30 seconds so your time in minutes per mile would be given by which of the following?"
Choices: [ 6.2/43.5, 43.5/6.2, 6.2*43.5 ]
Answer: 43.5/6.2
Hint: "43 minutes and 30 seconds are 43.5 minutes. Since you took 43.5 minutes to run 6.2 miles, how many minutes did each of those miles take?"
- Category: command
Output: "There is one more kind of division in Python. It is called floor division and rounds down to the nearest integer. It is represented by a double slash, //. Enter 10//1.61 to demonstrate this."
Answer: 10//1.61
Hint: Enter 10//1.61 at the prompt (>>>).
- Category: text
Output: "This concludes our very gentle, interactive introduction to Python 3. Of course, we have just introduced a few basics and have so far shown little of the real power of the language. However, swirlypy itself is written in Python 3, which may provide some idea, and by the end of this course you should be able to completely understand how swirlypy works."