Swapna Kumar Panda
Swapna Kumar Panda

@swapnakpanda

24 Tweets 3 reads Oct 15, 2022
Quickly learn both Python & JavaScript?
❍ Data Science
❍ AI/ML
❍ Web Development
Exciting career choices. Wanna join?
💭 Thoughts behind this series
⬘ Python and JavaScript are undoubtedly like 2 sides of the same coin.
⬗ Having knowledge of both would make for an exciting future. You can choose various career options.
⬙ Through this series, we will learn both side-by-side.
Today's Topics:
➊ Variables
➋ Data Types
➌ Operators
➊ Variables
➀ Variable Naming
➁ Variable Declaration
➂ Variable Assignment
➊.➀ Variable Naming
⬘ Python and JavaScript are almost similar in variable naming conventions except that JavaScript allows $ in variable names.
⬙ Python has a convention of using snake_case while JavaScript prefers camelCase naming.
➊.➁ Variable Declaration
⬘ Python doesn't have any syntax to declare a variable while JavaScript has 3 keywords.
⬗ Type Declaration: Python introduced it in v3.5, but doesn't enforce it. JavaScript doesn't have any.
⬙ Both allow changing the variable type dynamically.
➊.➂ Variable Assignment
Both Python and JavaScript have multiple syntaxes for assigning values to variables.
➋ Data Types
➀ Built-In Data Types
➁ Finding Type
➂ Checking Instance Type
➃ Type Casting
➋.➀ Built-In Data Types
⬘ Both Python and JavaScript provide some common data types.
⬙ Each has its own set of unique featured data types.
➋.➁ Finding Type
⬘ As both Python and JavaScript are dynamically typed, finding the type of a variable at runtime is a common practice.
Both provide a way to do this.
➋.➂ Checking Instance Type
⬘ On some occasions, we need to check if a variable is of a particular type or not.
Both Python and JavaScript have options to do this.
➋.➃ Type Casting
⬘ Data sometimes come in different formats and need to be converted to appropriate types at run-time.
Both Python and JavaScript support typecasting.
➌ Operators
➀ Arithmetic Operators
➁ Comparison Operators
➂ Logical Operators
➃ Bitwise Operators
➄ Assignment Operators
➅ Ternary Operator
➆ Membership Operators
➇ Type Checking Operators
➈ Operator Overloading
➌.➀ Arithmetic Operators
➌.➁ Comparison Operators
➌.➂ Logical Operators
➌.➃ Bitwise Operators
➌.➄ Assignment Operators
➌.➅ Ternary Operator
⬘ JavaScript has a ternary operator ?:
⇥ x > 5 ? 2 : 4
⬙ Though Python doesn't have any such operator, it has similar functionality.
⇥ 2 if x > 5 else 4
➌.➆ Membership Operators
⬘ Python provides 2 membership operators ("in" and "not in") that check whether an element exists in a sequence (list, tuple, etc).
⬙ JavaScript has an "in" operator which is used inside for..in loop and for object property checks.
➌.➇ Type Checking Operators
⬘ JavaScript provides 2 type checking operators (typeof and instanceof). It's discussed in ➋.➁ & ➋.➂.
⬙ Python doesn't have any equivalent operators. But it provides 2 functions to do these. type() and isinstance()
➌.➈ Operator Overloading
⬘ Python allows operator overloading. Python doesn’t do type conversion during evaluation.
⬙ JavaScript doesn’t have support for operator overloading. It auto-converts the operands to the required type during evaluation.
🚥 Disclaimer
⬘ I have tried to show a way of learning multiple languages at the same time by comparing their syntax.
⬗ This thread is part of a series and may not contain all the information in detail.
⬙ These illustrations are part of my original series "PJSython".
Hey 👋
I am a Tech Writer, Educator, and Mentor from India 🇮🇳, here sharing
✰ Tutorials
✰ Tricks
✰ Career Tips
✰ Cheat Sheets
✰ Interview Questions
✰ Project Ideas
on
➠ Web Development
➠ Data Structures and Algorithms
➠ Databases
Thanks for reading. 🙏

Loading suggestions...