Which are valid variable names?

My variable 1variable variable$ myvariable myvariable1 A variable name cannot start with a number and cannot have spaces in its name. A variable name must contain only letters, digits or underscores and should start with a letter or underscore

From naming conventions perspective, which variable name would you choose to hold the value of total number of students in a class?

c studentsCount students_count counting From recommended naming conventions perspective a variable name should start with a small case and every word should be separated by underscore. Although camel casing is used as a norm in OOP, in data analytics you see words separated by underscore. Use noun forms of the word and not verbs for variables

Variable names are case sensitive in Python

False True Yes. Mean != mean When used they will treated as two separate variables

Choose all the ways you can represent a String value

name = 'joe' name = "joe" name = '''joe''' name = """joe""" name = joe Although the first four are valid, three single or double quotes are mostly used for documentation which you will learn later

A programmer named a variable 'lambda'. Is this possible?

Yes No lambda is one of keywords and cannot be used as a variable name

A Cloud Computer is actually in the cloud above

Yes No HaHa no! A cloud computer is kept in huge data centers of cloud providers where you find thousands of such computers. Popular cloud vendors are Google, Amazon, Microsoft

You have declared a variable `a = 10` and want to know the type assigned. You would use which statement to find that

type(a) type a type

A data type assigned to a variable will change when the literal value assigned to it changes

Yes No Yes, for e.g., if age = 10 is reassigned as age = '10 years' then the datatype of 'age' changes from 'int' to 'str'

You are making a lot of changes to different code cells of your Jupyter notebook and all of sudden you see results which do not make any logical sense. What would you do?

Restart the runtime as you think the many changes that you made are still held in memory and are messing you up Delete code cells and reinsert them Remember when ever a code cell is run, it will hold all the variables declared in that code block in memory. Even if you remove the variables or delete a code block on your .ipynb file, the variables are still held in memory which are not shown in the code and may be potentially messing you up. Once you restart your runtime, memory will be wiped clean and you start with a clean slate. Deleting a code block and reinserting does not help when you are in this situation

Exercise

results matching ""

    No results matching ""