koder i Python

Pataasin ang iyong marka sa homework at exams ngayon gamit ang Quizwiz!

Comments in Python are written with a special character, which one? .......This is a comment

#

The following code example would print the data type of x, what data type would that be? x = True print(type(x))

bool

Create a variable named carname and assign the value Volvo to it: ...................= "............"

carname = "Volvo"

Insert the correct syntax to convert x into a complex number. x = 5 x = ...........(x)

complex

The following code example would print the data type of x, what data type would that be? x = {"name" : "John", "age" : 36} print(type(x))

dict

The following code example would print the data type of x, what data type would that be? x = 20.5 print(type(x))

float

Insert the correct keyword to make the variable x belong to the global scope. def myfunc(): ......... x x = "fantastic"

global

Insert the correct syntax to convert x into a integer. x = 5.5 x = ............(x)

int

The following code example would print the data type of x, what data type would that be? x = 5 print(type(x))

int

The following code example would print the data type of x, what data type would that be? x = ["apple", "banana", "cherry"] print(type(x))

list

Remove the illegal characters in the variable name: 2my-first_name = "John"

myfirst_name = "John"

Insert the missing part of the code below to output "Hello World": ................. ("Hello World")

print

Use the len method to print the length of the string. x = "Hello World" print(...... )

print(len(x))

The following code example would print the data type of x, what data type would that be? x = "Hello World" print(type(x))

str

The following code example would print the data type of x, what data type would that be? x = ("apple", "banana", "cherry") print(type(x))

tuple

Convert the value of txt to lower case. txt = "Hello World" txt =................

txt = txt.lower()

Convert the value of txt to upper case. txt = "Hello World" txt =..............

txt = txt.upper()

Insert the correct syntax to convert x into a floating point number. x = 5 x = .........(x)

x = 5 x = float(x)

Display the sum of 5 + 10, using two variables: x and y. .....= .... y = 10 print(x y)

x = 5 y = 10 print (x+y)

Create a variable called z, assign x + y to it, and display the result. x = 5 y = 10 ....= x + y print()

x = 5 y = 10 z = x + y print (z)

Create a variable named x and assign the value 50 to it. ....... = ......

x = 50

Return the string without any whitespace at the beginning or the end. txt = " Hello World " x =......................

x = txt.strip()

Get the characters from index 2 to index 4 (llo). txt = "Hello World" x = ............

x = txt[2:5]

Get the first character of the string txt. txt = "Hello World" x =..............

x =txt[0]

Insert the correct syntax to assign the same value to all three variables in one code line. x.. y ...z ...."Orange"

x=y=z="Orange"


Kaugnay na mga set ng pag-aaral

Chapter 28: Growth and Development of the School-Age Child

View Set

CHAPTER 1: MATHEMATICAL ESSENTIALS

View Set

Elements, Compounds and Mixtures Test

View Set

Superficial Structures: Chapter 23 - Scrotum

View Set

APUSH American Revolution Review

View Set

Applied Business Ethics - Exam 3

View Set