Worksheet - Python Basics (1)

.docx

School

George Washington University *

*We aren’t endorsed by this school

Course

3119

Subject

Computer Science

Date

Apr 3, 2024

Type

docx

Pages

2

Uploaded by BrigadierTroutPerson755

Report
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 = “ ” x = ‘a’ x = False x = 100 x = -0.5 x = -37 x = ‘123’ x = ’True’ 3 - Name 4 built-in functions: 4 – True or False: Python is an interpreted language. 5 – True or False: Python is case-sensitive. 6 – True or False: Variable names can have spaces. 7 – True or False: For variable names, lower case is frequently used. 8 – True or False: For variable names, underscores can be used. 9 –The proper style for variable names in Python is: a) camel case, as in acctName b ) snake case, as in acct_name 10 – True or False: This is a proper variable name: value1 11 – True or False: This is a proper variable name: 1value 12 – True or False: Data types must be stated when declaring variables. 13 – True or False: We can use single quotes or double quotes for strings. 14– True or False: It is possible to change the data type of a variable. 15 - What are the two reserve word values for the bool data type? _________ _________ 16 - What data type must we always pass to the input() function? ________________________ 17 - What data type does the input() function always return? ___________________________ 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.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=1234 print(‘Joe’,’Smith’) stuName=input( ‘Enter your name: ‘ ) x=2 print(‘x is’,x) 21 – Describe the steps (in order) that are performed for this line of code: z = float(input(‘Enter your gpa: ’))
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help