Home » Python programs

Python | Declare any variable without assigning any value



Here, we will learn how to declare any variable without assigning any value in Python?
Submitted by IncludeHelp, on July 30, 2018

Since, Python is a dynamic programming language so there is no need to declare such type of variable, it automatically declares when first time value assign in it.

Still, this is a common question asked by many programmers that can we declare any variable without any value?

The answer is: "Yes! We can declare such type of variable". To declare a variable without any variable, just assign None.

Syntax:

 variable_name = None

Example:

 num = None

Let’s understand through a program:

# Python program to declare a 
# variable without assigning any value 

# declare variable 
num = None

# print the value
print "value of num: ", num

# checking variable
if (num==None):
	print "Nothing"
else:	
	print "Something"
	
# assign some value
num = 100

# print the value
print "value of num: ", num

# checking variable
if (num==None):
	print "Nothing"
else:	
	print "Something"

Output

    value of num:  None
    Nothing
    value of num:  100
    Something





Comments and Discussions

Ad: Are you a blogger? Join our Blogging forum.




Quick links
Latest articles, Internship, Members
New...
Coding problems, Algorithms, Discrete Mathematics, Big data
Languages
C, C++, C++ STL, Java, Data Structure, C#.Net, Android, Kotlin, SQL
Web
PHP, Python, JavaScript, CSS, Ajax, Node.js, Web prog.
Programs
C, C++, DS, Java, C#, Python
Aptitude
C, C++, Java, DBMS
Interview
C, Embedded C, Java, SEO, HR
CS Subjects
CS Basics O.S. Networks DBMS Embedded Systems Cloud Computing Machine learning CS Organizations Linux DOS
More...
Articles, Puzzles, News/Updates


Recommended posts
C Tips & Tricks, C++ Tips & Tricks
Introduction to Linux (Its modes, Safety, Most popular Applications)
Linux Best Distros of 2018
C programming optimization techniques
Differences b/w C & Embedded C?
Embedded C Interview Q. & A.
C programming tips for Embedded Development
Basic rules of writing a C program
Important points (rules) to remember while writing C/C++ program
Top 5 Websites for solving programming challenges
Read more...


Others...
Computer G.K. (MCQ)
Most viewed pages...
Categories...



Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing » Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates

© https://www.includehelp.com some rights reserved.