Shakhzod Tojiyev
shakhzodtojiyev

shakhzodtojiyev

Python VS JavaScript – What are the Key Differences Between The Two Popular Programming Languages?

Python VS JavaScript – What are the Key Differences Between The Two Popular Programming Languages?

Shakhzod Tojiyev's photo
Shakhzod Tojiyev
·Sep 30, 2021·

2 min read

#0 Python :

# Output
print("Hello World...")   # Hello World...

#0 JavaScript :

// Output
console.log("Hello World...");   // Hello World...

#1 Python :

# Variable
userName = "Jhon"
print(userName)   # Jhon

# Change value
userJob = "Programmer"
userJob = "Teacher"
print(userJob)   # Teacher

# Change type value
userJob = "Programmer"
userJob = 200
print(userJob)   # 200

# Python don't using const value

#1 JavaScript :

// Variable
let userName = "Jhon";
console.log(userName);   // Jhon

// Change value
let userJob = "Programmer";
userJob = "Teacher";
console.log(userJob);   // Teacher

// Change type value
let userJob = "Programmer";
userJob = 200;
console.log(userJob);   // 200

// JavaScript using const value
const userJob = "Programmer";
userJob = "Teacher";
console.log(userJob);   // TypeError: Assignment to constant variable.

const userJob = "Programmer";
userJob = 200;
console.log(userJob);   // TypeError: Assignment to constant variable.

#2 Python :

# Type
userJob = "Programmer"
print(type(userJob))   # <class 'str'>

#2 JavaScript :

// Type
const userJob = "Programmer";
console.log(typeof userJob)   // string

#3 Python :

# String methods
userFirstName = "Jhon"
print("User first name: " + userFirstName)   # User first name: Jhon
print(f"User first name: {userFirstName}")   # User first name: Jhon

userFirstName = "Jhon"
userLastName = "Doe"
print("User full name: " + userFirstName + " " + userLastName)   # User full name: Jhon Doe
print(f"User full name: {userFirstName} {userLastName}")   # User full name: Jhon Doe

userFullName = "jhon doe"
print(userFullName.upper())   # JHON DOE

userFullName = "JHON DOE"
print(userFullName.lower())   # jhon doe

userFullName = "jhon doe"
print(userFullName.title())   # Jhon Doe

# And more string methods...

#3 JavaScript :

// String methods
const userFirstName = "Jhon";
console.log("User first name: " + userFirstName);   // User first name: Jhon
console.log(`User first name: ${userFirstName}`);    // User first name: Jhon

const userFirstName = "Jhon";
const userLastName = "Doe";
console.log("User full name: " + userFirstName + " " + userLastName);   // User full name: Jhon Doe
console.log(`User full name: ${userFirstName} ${userLastName}`);   // User full name: Jhon Doe

const userFullName = "jhon doe";
console.log(userFullName.toUpperCase());   // JHON DOE

const userFullName = "JHON DOE";
console.log(userFullName.toLowerCase());   // jhon doe

// And more string methods...

#4 Python :

# Input
print(input("Input value: "))   # Input value: {Your value}

#4 JavaScript :

// Input
prompt("Input value: ");

image.png

#5 Python :

# Input

#5 JavaScript :

// Input
 
Share this