Skip to content

Commit 28681c1

Browse files
committed
add comments to code 4.3
1 parent 1b45938 commit 28681c1

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

source/ch4_conditionals.ptx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ if score >= 90: # Note the colon at the end of the line
6060
<program interactive="activecode" language="python">
6161
<code>
6262
age = 16
63-
if age &gt;= 18:
63+
if age &gt;= 18: # notice the semicolon
6464
print("You can vote.")
6565
else: # notice the semicolon
6666
print("You are not yet eligible to vote.")
@@ -75,7 +75,7 @@ if score &gt;= 90: # Note the colon at the end of the line
7575
public class IfElseExample {
7676
public static void main(String[] args) {
7777
int age = 16;
78-
if (age &gt;= 18) {
78+
if (age &gt;= 18) {
7979
System.out.println("You can vote.");
8080
} else { // else has its own block.
8181
System.out.println("You are not yet eligible to vote.");
@@ -102,7 +102,7 @@ if score &gt;= 90: # Note the colon at the end of the line
102102
grade = int(input('enter a grade'))
103103
if grade &lt; 60:
104104
print('F')
105-
elif grade &lt; 70:
105+
elif grade &lt; 70: # notice the semicolon
106106
print('D')
107107
elif grade &lt; 80:
108108
print('C')
@@ -126,7 +126,7 @@ public class ElseIf {
126126
int grade = 85;
127127
if (grade &lt; 60) {
128128
System.out.println('F');
129-
} else {
129+
} else { // else has its own block.
130130
if (grade &lt; 70) {
131131
System.out.println('D');
132132
} else {
@@ -160,7 +160,7 @@ public class ElseIf {
160160
int grade = 85;
161161
if (grade &lt; 60) {
162162
System.out.println('F');
163-
} else if (grade &lt; 70) {
163+
} else if (grade &lt; 70) { // notice how we got rid of the curly braces.
164164
System.out.println('D');
165165
} else if (grade &lt; 80) {
166166
System.out.println('C');

0 commit comments

Comments
 (0)