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.
Variables across languages - Python Tutorial
From the course: Programming Foundations: Fundamentals
Variables across languages
- Depending on the programming language that you're working with, variables can behave in different ways. Some languages require that you define your variables and their types before you can use them, like Java, C#, and C++. For example, if we want to store the name of a cookie in Java, we would have to first declare that it's going to be of type string and then give our variable a name, cookie. When we run this code, we get sugar as our output. Since we've defined our variable as type string, we can't then later decide to set this variable to a different type. Let's say an integer. When we compile our program, we'll receive an error because Java is a strict programming language. It doesn't allow you to reassign data types in this way. But if we were to compare this to a more relaxed language like Python, we don't need to declare a variable's type before using it. Here, we declare the variable and use it at the same…
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.
Contents
-
-
-
-
-
Introduction to variables and data types3m 37s
-
(Locked)
Variables across languages3m 27s
-
(Locked)
Working with numbers4m 48s
-
(Locked)
Working with strings2m 29s
-
(Locked)
Properly using whitespace4m 22s
-
(Locked)
Working with comments3m 26s
-
(Locked)
Challenge: What's the output?49s
-
(Locked)
Solution: What's the output?5m 14s
-
-
-
-
-