What Is The Difference Between A String And A Variable? - Codecademy
Maybe your like
I am a little confused on knowing what a string or variable is. Is a string just a variable with multiple words in it?
Such as
Variable is my_var= 3 or “hello’
String is my_var= “my name is terry’
Also, how do you know when to use quotes in your variable such as my_var =3 and my_var = ‘hello’
Do you use quotes for words only?
Answer 54a0d14f76b8fee741013ca7
0 votesPermalink
a string is a value representing text
a variable is a name that can refer to any value
quotes, double or single, (they mean the same, but can’t be matched with each other) are used to create string literals, the quotes are there to indicate that the text that they enclose is not code, it is a value
4 comments
In python with these examples, there is little difference. They are both variables. Regular variables in Python are actually objects, you are just assigning different data to them. This is much easier to see in a language such as Java since there is a clear difference between primitives and wrappers, you may want to look into Java at some point, teaches A LOT about basic computer science. My opinion of course :P
not so sure about this statement: “Regular variables in Python are actually objects” (i doubt that is true, but i also don’t know exactly how variables are implemented in python. i know there are dictionaries where the variable names are the keys an the objects are the values, but if i recall correctly that is not the whole story of it) but all values are indeed objects. Java is very far away from the hardware, sitting on top of the monster that is jvm, so if by basics you mean the low-level workings of a computer then i’ll definitely suggest C instead (C also happens to be very simple, as in, it has very few features)
feel free to direct me to some valid source (i.e. not some blog or tutorial, more like python.org) that explains how variables work, i’d love to get that straightened out, but googling it turned out tricky, i’ll have to look into that later
If you think Java is far from the hardware you should see how far Python is haha. I get most my knowledge from studying Software Engineering, I think this link should explain what I mean clearer though: https://docs.python.org/3/reference/datamodel.html section 3.1 and http://www.learnpython.org/en/Variables_and_Types Sorry for laaaate reply, been busy :) Also I agree with the comment on C that it is definitely lower level, however Java (in my opinion once again) is a more useful and easier to use modern language while still feeling of C, at the beginner level anyway.
Popular free courses
- Free course
Learn SQL
In this SQL course, you'll learn how to manage large datasets and analyze real data using the standard data management language.- Checker DenseBeginner Friendly.4 Lessons
- Free course
Learn JavaScript
Learn how to use JavaScript — a powerful and flexible programming language for adding website interactivity.- Checker DenseBeginner Friendly.11 Lessons
- Free course
Learn HTML
Start at the beginning by learning HTML basics — an important foundation for building and editing web pages.- Checker DenseBeginner Friendly.6 Lessons
Tag » What Is A String Variable
-
SPSS Tutorials: Variable Types - LibGuides - Kent State University
-
What Are String Variables? - Kodable Help Center
-
String Variables
-
String Variables - Stata Guide
-
String Variables
-
What Are String Variables?
-
String Variables - F-Chart Software
-
String Variable Definition And Meaning | Collins English Dictionary
-
SPSS String Variables - Quick Introduction
-
Strings, Types, And Variables - WebInSight
-
String Basics - Visual Basic | Microsoft Learn
-
SPSS String Variable - Javatpoint
-
Strings In C: How To Declare & Initialize A String Variables In C
-
String Variable Formats - IBM