python programming gcse

Solutions on MaxInterview for python programming gcse by the best coders in the world

showing results for - "python programming gcse"
Klara
24 Jan 2018
1Chapter 01 Worksheet
2 
3     
4    When writing answers to questions, please use proper grammar, capitalization,
5    and punctuation. Please limit the length of each line to 80 characters.
6     
7 1. Write a line of code that will print your name.
8 
9 2. How do you enter a comment in a program?
10 
11 3. What do the following lines of code output?
12       ALSO: Why do they give a different answer?
13     
14    print(2 / 3)
15    print(2 // 3)
16     
17 4. Write a line of code that creates a variable called pi and sets
18       it to an appropriate value.
19 
20 5. Why does this code not work?
21     
22    A = 22
23    print(a)
24     
25 6. All of the variable names below can be used. But which ONE of these is
26       the better variable name to use?
27     
28    a
29    A
30    Area
31    AREA
32    area
33    area_of_rectangle
34    Area_Of_Rectangle
35     
36 7. Which of these variables names are not allowed in Python? (More than one
37    might be wrong. Also, this question is not asking about improper names, just
38    names that aren't allowed. Test them if you aren't sure.)
39     
40    apple
41    Apple
42    APPLE
43    Apple2
44    1Apple
45    account number
46    account_number
47    account.number
48    accountNumber
49    account#
50    pi
51    PI
52    fred
53    Fred
54    GreatBigVariable
55    greatBigVariable
56    great_big_variable
57    great.big.variable
58    2x
59    x2x
60    total%
61    #left
62     
63 8. Why does this code not work?
64     
65    print(a)
66    a = 45
67     
68 9. Explain the mistake in this code:
69     
70    pi = float(3.14)
71     
7210. This program runs, but the code still could be better. Explain what is
73    wrong with the code.
74     
75    radius = float(input("Radius:"))
76    x = 3.14
77    pi = x
78    area = pi  * radius ** 2
79    print(area)
80     
8111. Explain the mistake in the following code:
82     
83    x = 4
84    y = 5
85    a = ((x) * (y))
86    print(a)
87     
8812. Explain the mistake in the following code:
89     
90    x = 4
91    y = 5
92    a = 3(x + y)
93    print(a)
94     
9513. Explain the mistake in the following code:
96     
97    radius = input(float("Enter the radius:"))
98     
9914. Do all these print the same value? Which one is better to use and why?
100     
101    print(2/3+4)
102    print(2 / 3 + 4)
103    print(   2 /    3+    4  )
104     
10515. What is a constant?
106 
10716. How are variable names for constants different than other variable names?
108 
10917. What is a single quote and what is a double quote?
110    Give and label an example of both.
111 
11218. Write a Python program that will use escape codes to print a double-quote
113    and a new line using the Window's standard. (Note: I'm asking for the Window's
114    standard here. Look it up out of Chapter 1.)
115 
11619. Can a Python program print text to the screen using single quotes instead
117    of double quotes?
118 
11920. Why does this code not calculate the average?
120     
121    print(3 + 4 + 5 / 3)
122     
123 
12421. What is an ``operator'' in Python?
125 
12622. What does the following program print out?
127     
128    x = 3
129    x + 1
130    print(x)
131     
132 
13323. Correct the following code:
134     
135    user_name = input("Enter your name: )"
136     
137 
13824. Correct the following code:
139     
140    value = int(input(print("Enter your age")))
141