• Wrong document? Swap it for free
  • Written by students who passed
  • Immediately available after payment
  • Read online or as PDF
Sell
Where do you study
Your language
Document preview thumbnail
Preview 1 out of 1 pages
Exam (elaborations)

Vm1602 Variables And Data Types

Document preview thumbnail
Preview 1 out of 1 pages

VM1602 VARIABLES AND DATA TYPES

Content preview

Exam: Variables and Data Types
Instructions: Answer all questions. Each question tests your understanding of variables and
data types in programming.

1. What is a variable in programming?
Answer: A variable is a named storage that can hold a value which can be changed#$%^&*(
during
the execution of a program. *&^%
2. What are the common data types in Python?
Answer: Common data types in Python include int, float, str, bool, list, tuple, set, and dict.

3. What is the difference between an integer and a float?
Answer: An integer (int) is a whole number without a decimal point, while a float is a
number that includes a decimal point.

4. How do you declare a string variable in Python?
Answer: You declare a string variable by assigning a sequence of characters enclosed in
quotes to a variable. For example: name = 'Alice'

5. What is the output of the following code: x = 5; y = '5'; print(x + int(y))?
Answer: The output is 10. The string '5' is converted to an integer before addition.

6. What is a boolean data type and what values can it hold?
Answer: A boolean data type can hold only two values: True or False.

7. Explain the difference between a list and a tuple.
Answer: A list is mutable, meaning its elements can be changed, while a tuple is immutable
and cannot be changed after creation.

8. What will be the type of variable x if we write: x = 3.14?
Answer: The type of x will be float.

9. How can you find out the type of a variable in Python?
Answer: You can use the type() function. For example: type(x)

10. Can variable names start with a number in Python? Explain.
Answer: No, variable names cannot start with a number. They must begin with a letter or an
underscore.

Document information

Uploaded on
April 22, 2025
Number of pages
1
Written in
2024/2025
Type
Exam (elaborations)
Contains
Questions & answers
$18.49

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Seller avatar
Reputation scores are based on the amount of documents a seller has sold for a fee and the reviews they have received for those documents. There are three levels: Bronze, Silver and Gold. The better the reputation, the more your can rely on the quality of the sellers work.
QuickFixer
3.6
(19)
Sold
2075
Followers
7
Items
1194
Last sold
1 month ago



Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions