Type Declaration


Why variable is not given a data type while initializing like in C language?
And if we want to declare a variable and declare it later what will we do…?


python handles type declarations, which is why python is referred to as dynamic typed programming language, python handles data types for you

where as in C, its static typed (you have to specify data types)

if you want an empty variable, you can just give it a value of None in python. Declaring variables before hand is really uncommon practice within python


C has a very raw memory model, the way to figure out what something at all means/is, is by treating it like a particular type. If you have a pair (two values) in C, the way to get the first value is to look at the start of that piece of memory, and the way to get the second one is to look a particular distance further ahead (and you need to know the types to figure out that distance)
A string in C is nothing but a location, and then you simply read until you hit a special value, and that’s where the string ends. If you keep reading (forgot that special value when creating the string?) then you’ll start reading… other stuff, possibly reading code instead of values, maybe reading something your program doesn’t even own (the os might kill your program when trying to do that)


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.