Module 2 Python Exercises, Exercises of Programming Languages

Module 2 Python worksheet exercises

Typology: Exercises

2024/2025

Uploaded on 08/30/2025

Excislor
Excislor 🇺🇸

1 document

1 / 2

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

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: ’))