Thread Reader

Swapna Kumar Panda

@swapnakpanda

Jul 13

24 tweets
Twitter

Learning Python & JavaScript? โ Data Science โ AI/ML โ Web Development Yes, it opens the door๐Ÿšช to an exciting world!!! Wanna join? Let's start. ๐Ÿงต

๐Ÿ’ญ Thoughts behind this thread โฌ˜ Python and JavaScript are undoubtedly the 2 most dominating languages. โฌ— Having knowledge of both would make an exciting future. You can choose various career options. โฌ™ Through this (series of) thread(s), we will learn both side-by-side.

Topics for today โžŠ 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 a variable.

โž‹ 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, 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 doing 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 syntaxes. โฌ— This thread may not contain all the information in detail. โฌ™ These illustrations are part of my series "PJSython".

Hey ๐Ÿ‘‹ I am a Tech Educator and, Mentor from India ๐Ÿ‡ฎ๐Ÿ‡ณ I am sharing Tutorials, Tips, Techniques, Infographics, Cheat Sheets, Practice Questions, Project Ideas and Roadmaps on Web Development, DSA and, Databases. To never miss anything, Follow Me โœ…

Swapna Kumar Panda

@swapnakpanda

| Professional Tech Writer | Authoring 5 eBooks | JavaScript, Data Structures, SQL/NoSQL | Daily ๐Ÿงต | DM for collaborations ๐Ÿ“ฉ |

Follow on Twitter