From the course: Programming Foundations: Fundamentals
Unlock this course with a free trial
Join today to access over 25,300 courses taught by industry experts.
Conditionals across languages - Python Tutorial
From the course: Programming Foundations: Fundamentals
Conditionals across languages
- By now you're pretty familiar with conditionals in Python. We start with an if, followed by our condition, then we end the condition with a colon. Then on the next line we indent the block of code that we want executed. And the else is very similar, except there's no condition to check. In the Java programming language, the if else statement has a slightly different syntax. Remember, syntax is just the same thing as saying rules for how a programming language expects its code to be written. After the if keyword, there's a set of opening and closing parentheses. Inside these parentheses is where you put the condition you want to be tested. And instead of a colon after the condition, a pair of opening and closing curly braces are used to denote the code block for the if. The same thing is true for the else clause. Now although it's customary to indent the statements in the code blocks, it's not a requirement the way it…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.