Docsity

Module 2 Python Exercises, Exercises of Programming Languages

Toggle sidebar
bg1
ITP 150 โ€“ Worksheet โ€“ Python Basics
1 - Name 4 built-in data types: ____________ ____________ ____________ ____________
2 โ€“ In each example, we create a variable x. What is the data type of our variable x?
x = 3.9
x = โ€œabc123โ€
x = False
x = โ€˜aโ€™
x = 100
x = -0.5
x = -37
x = โ€˜Trueโ€™
3 - Name 6 built-in functions:
4 - What data type must we always pass to the input() function? _________________________
5 - What data type does the input() function always return? ___________________________
6 - What are the two reserve words for bool? _________________ _________________
7 โ€“ True or False: Python is an interpreted language.
8 โ€“ True or False: Python is case-sensitive.
9 โ€“ True or False: Variable names can have spaces.
10 โ€“ True or False: The proper style for variable names in Python is camelCase.
11 โ€“ True or False: For variable names, underscores can be used.
12 โ€“ True or False: For variable names, lower case is frequently used.
13 โ€“ True or False: This is a proper variable name: value1
14 โ€“ True or False: This is a proper variable name: 1value
15 โ€“ True or False: Data types must be stated when declaring variables.
16 โ€“ True or False: We can use single quotes or double quotes for strings.
17โ€“ True or False: It is possible to change the data type of a variable.
18- Given the following code, list the following:
z = float(input(โ€˜Enter your gpa: โ€™))
variable(s): ______________ literal(s): ___________________________________________
function(s) called: _____________________________________________________
data types used: ______________________________________________
pf2

Partial preview of the text

Download Module 2 Python Exercises and more Exercises Programming Languages in PDF only on Docsity!

ITP 150 โ€“ Worksheet โ€“ Python Basics

1 - Name 4 built-in data types: ____________ ____________ ____________ ____________ 2 โ€“ In each example, we create a variable x. What is the data type of our variable x?

x = 3.9 x = โ€œabc123โ€ x = False x = โ€˜aโ€™

x = 100 x = - 0.5 x = - 37 x = โ€˜Trueโ€™

3 - Name 6 built-in functions: 4 - What data type must we always pass to the input() function? _________________________ 5 - What data type does the input() function always return? ___________________________ 6 - What are the two reserve words for bool? _________________ _________________ 7 โ€“ True or False: Python is an interpreted language. 8 โ€“ True or False: Python is case-sensitive. 9 โ€“ True or False: Variable names can have spaces. 10 โ€“ True or False: The proper style for variable names in Python is camelCase. 11 โ€“ True or False: For variable names, underscores can be used. 12 โ€“ True or False: For variable names, lower case is frequently used. 13 โ€“ True or False: This is a proper variable name: value 14 โ€“ True or False: This is a proper variable name: 1value 15 โ€“ True or False: Data types must be stated when declaring variables. 16 โ€“ True or False: We can use single quotes or double quotes for strings. 17 โ€“ True or False: It is possible to change the data type of a variable. 18 - Given the following code, list the following:

z = float(input(โ€˜Enter your gpa: โ€™))

variable(s): ______________ literal(s): ___________________________________________ function(s) called: _____________________________________________________ data types used: ______________________________________________

19 - Given the following code, list the following:

x = 5 ; y = 6.

print(x, y); z = input(โ€˜Enter a num: โ€™)

variable(s): _____________________________________________________ literal(s): _____________________________________________________ function(s) called: _________________________________________________ argument(s): _____________________________________________________ data types used: ______________________________________________ 20 โ€“ All code below works, but there are style rules not followed. Rewrite the statements:

acctNumber = 1234

acct_number=

print(โ€˜Joeโ€™,โ€™Smithโ€™)

stuName=input( โ€˜Enter your name: โ€˜ )

x=

print(โ€˜x isโ€™,x)

21 โ€“ Describe the steps (in order) that are performed for this line of code:

z = float(input(โ€˜Enter your gpa: โ€™))