We will talk about the use of "semicolon" in Python.
- The general meaning of semicolon ( ; ) in various programming languages is to put an end to or discontinue the current statement.
- In programming languages like C, C++, and Java, using a semicolon is necessary to terminate the line of code. However, that is not the case with Python.
βββ
Why are semicolons allowed in Python?
- Python does not require semi-colons to terminate statements.
- Semicolons can be used to delimit statements if you wish to put multiple statements on the same line.
- A semicolon in Python denotes separation, rather than termination.
- It allows you to write multiple statements on the same line.
- This syntax also makes it legal to put a semicolon at the end of a single statement. So, itβs actually two statements where the second one is empty.
βββ
Split Statements with Semicolons
statement1; statement2
Example:
print('Hi'); print('Everyone!')
Output:
Hi
Everyone!
- As we can see, Python executes the three statements individually after we split them with semicolons.
βββ
Using Semicolons with Loops in Python
Example:
for i in range (3): print ('Hi') ; print('Everyone!')
Output:
Hi
Everyone!
Hi
Everyone!
Hi
Everyone!
βββ
Python will throw an error if you use semicolon to separate a normal expression from a block statement i.e loop.
Example:
print('Hi') ; for i in range (3): print ('Everyone!')
βββ
Thanks for reading β₯οΈ
- The general meaning of semicolon ( ; ) in various programming languages is to put an end to or discontinue the current statement.
- In programming languages like C, C++, and Java, using a semicolon is necessary to terminate the line of code. However, that is not the case with Python.
βββ
Why are semicolons allowed in Python?
- Python does not require semi-colons to terminate statements.
- Semicolons can be used to delimit statements if you wish to put multiple statements on the same line.
- A semicolon in Python denotes separation, rather than termination.
- It allows you to write multiple statements on the same line.
- This syntax also makes it legal to put a semicolon at the end of a single statement. So, itβs actually two statements where the second one is empty.
βββ
Split Statements with Semicolons
statement1; statement2
Example:
print('Hi'); print('Everyone!')
Output:
Hi
Everyone!
- As we can see, Python executes the three statements individually after we split them with semicolons.
βββ
Using Semicolons with Loops in Python
Example:
for i in range (3): print ('Hi') ; print('Everyone!')
Output:
Hi
Everyone!
Hi
Everyone!
Hi
Everyone!
βββ
Python will throw an error if you use semicolon to separate a normal expression from a block statement i.e loop.
Example:
print('Hi') ; for i in range (3): print ('Everyone!')
βββ
Thanks for reading β₯οΈ
I found these two great websites and am pleased to share them with you. β₯οΈ
- Top CV
https://www.topcv.com/
- Value My CV
https://www.adzuna.com.au/
- Top CV
https://www.topcv.com/
- Value My CV
https://www.adzuna.com.au/
UAE-Companies.xls
2.2 MB
More than 6000 emails to work in the United Arab Emirates.
- React-Date-Picker
https://bit.ly/3KJhtbP
- React-Dates
https://bit.ly/3RrAmlQ
- React Datepicker
https://bit.ly/3cEWQRE
- React-Day-Picker
https://bit.ly/3cHzV8l
@phoenixcoding
- React-Date-Range
https://bit.ly/3wPBtUs
- React-Infinite-Calendar
https://bit.ly/3TDh5Qj
https://bit.ly/3KJhtbP
- React-Dates
https://bit.ly/3RrAmlQ
- React Datepicker
https://bit.ly/3cEWQRE
- React-Day-Picker
https://bit.ly/3cHzV8l
@phoenixcoding
- React-Date-Range
https://bit.ly/3wPBtUs
- React-Infinite-Calendar
https://bit.ly/3TDh5Qj
React Native Example
- A nice collection of often useful examples done in React Native.
https://reactnativeexample.com/
#react_native
- A nice collection of often useful examples done in React Native.
https://reactnativeexample.com/
#react_native
DevGuide π΅πΈ pinned Β«Internships https://jobs.lever.co/brainnest #internshipΒ»
DevGuide π΅πΈ pinned Β«Jobs & Internships https://bit.ly/3eFqFlz #job #internshipΒ»
The 2022 Android Developer Roadmap: Part 1
https://getstream.io/blog/android-developer-roadmap/
-----
The 2022 Android Developer Roadmap: Part 2
https://getstream.io/blog/android-developer-roadmap-part-2/
-----
The 2022 Android Developer Roadmap: Part 3
https://getstream.io/blog/android-developer-roadmap-part-3/
https://getstream.io/blog/android-developer-roadmap/
-----
The 2022 Android Developer Roadmap: Part 2
https://getstream.io/blog/android-developer-roadmap-part-2/
-----
The 2022 Android Developer Roadmap: Part 3
https://getstream.io/blog/android-developer-roadmap-part-3/
Get instant, lifetime access to five popular courses.
- Complete Intro to Web Development, v3
- Getting Started with CSS
- Getting Started with JavaScript, v2
- A Practical Guide to Algorithms with JavaScript
- Visual Studio Code Can Do That?
https://frontendmasters.com/trial/
- Complete Intro to Web Development, v3
- Getting Started with CSS
- Getting Started with JavaScript, v2
- A Practical Guide to Algorithms with JavaScript
- Visual Studio Code Can Do That?
https://frontendmasters.com/trial/
Frontendmasters
Trial
FREE WEEKEND
For the first time ever, watch ALL available Vue School courses and the Vue.js Master Class for FREE!
https://vueschool.io/free-weekend
For the first time ever, watch ALL available Vue School courses and the Vue.js Master Class for FREE!
https://vueschool.io/free-weekend
Let's Grow More
Current Internship Opportunities:
---
- LGM-EDUCATE (Trainings)
- LGMVIP
- LGMSoC'21
- LGMWEP(For Girls-Only)
- Web Development
- Tech Intern
- Campus Ambassador
- Social Media Marketing
- Content Writing Intern
- Graphic Designer
Apply Here: https://letsgrowmore.in/opportunities/
Current Internship Opportunities:
---
- LGM-EDUCATE (Trainings)
- LGMVIP
- LGMSoC'21
- LGMWEP(For Girls-Only)
- Web Development
- Tech Intern
- Campus Ambassador
- Social Media Marketing
- Content Writing Intern
- Graphic Designer
Apply Here: https://letsgrowmore.in/opportunities/