Computer Assignment

अब Quizwiz के साथ अपने होमवर्क और परीक्षाओं को एस करें!

The function int() can be used to turn input into a number

int()

A variable that can only have two values, True or False. Boolean if else elif

Boolean

Returns a set, that is the intersection of two other sets

intersection()

Removes the specified element

remove()

Evaluate (to true or false) each of the following expressions: 14 <= 14 14 < 14 -9 > -25 -25 > -9

. true false true false

Returns a copy of the set

copy()

Which of the following are valid if/else statements in Python, assuming x and y are defined appropriately: if x < y: if x > 10: print('foo') if x < y: print('foo'); print('bar'); print('baz') if x < y: print('foo') else: print('bar') print("foo") if x > y else print("bar")

if x < y: print('foo'); print('bar'); print('baz') print("foo") if x > y else print("bar")

constructs a string from a wide variety of data types, including strings, integer literals and float literals

str()

Is Python case sensitive while dealing with identifiers ? True False

true

How to swap two variables in one line ? x=y x,y=y,x You have to create a temporary variable to swap two values

x,y=y,x

A function which outputs information to the console

print()

How do you create a variable with the numeric value 5? A. x=int(5) B. x=5 C. Both the other answers are correct

C. Both the other answers are correct

Removes an element from the set

pop()

Removes the items in this set that are also included in another, specified set

difference_update()

Returns whether another set contains this set or not

issubset()

Update the set with the union of this set and others

update()

constructs an integer number from an integer literal, a float literal (by rounding down to the previous whole number), or a string literal (providing the string represents a whole number)

int()

Used to mark a line in the programme as a comment

#

What signifies the end of a statement block or suite in Python?

A line that is indented less than the previous line

3. Which statement is used to stop a loop? A.stop B.break C.exit D.pass

B.break

Removes all the elements from the set

clear()

Remove the specified item

discard()

an object-orientated language, and as such it uses classes to define data types, including its primitive types.

Python

when dealing with whitespaces, indent the code with the use of __ spaces.

4

A test for equality

==

What is the correct file extension for Python files? A. .py B. .pt C. .pyth D. .pyt

A. .py

Which of these collections defines a LIST? A. ["apple", "banana", "cherry"] B. ("apple", "banana", "cherry") C. {"name": "apple", "color": "green"} D. {"apple", "banana", "cherry"}

A. ["apple", "banana", "cherry"]

4. Select which is true for for loop A.Python's for loop used to iterates over the items of list, tuple, dictionary, set, or string B.else clause of for loop is executed when the loop terminates naturally C.else clause of for loop is executed when the loop terminates abruptly D.using for loop when we want to perform a task indefinitely until a particular condition is met E.With the for loop we can execute a set of statements, once for each item in a list, tuple, set etc.

A.Python's for loop used to iterates over the items of list, tuple, dictionary, set, or string, E.With the for loop we can execute a set of statements, once for each item in a list, tuple, set etc.

Which one is NOT a legal variable name? Choose all the answers apply A. Myvar B. My-var C. _myvar D. My_var E. myVar1 F. 1myVar G. True

B. My-var F. 1myVar G. True

How do you start writing an if statement in Python? A.if x>y then: B. if x>y: C. if (x>y) D. IF x>y:

B. if x>y:

. How do you start writing a for loop in Python? A.for each x in y: B.for x in y: C.for x>y: D.For x In y:

B.for x in y:

How do you insert COMMENTS in Python code? A. /* This is a comment */ B. // This is a comment C. # This is a comment

C. # This is a comment

What is a correct syntax to output "Hello World" in Python? A. echo "Hello World" B. p("Hello World") C. print("Hello World") D. print('Hello World')

C. print("Hello World") D. print('Hello World')

Which operator can be used to compare two values? A> B. = C. == D.><

C. ==

If the condition is evaluated to true, the statement(s) of if block will be executed, otherwise the statement(s) in else block(if else is specified) will be executed. True or False

True

A _____ is like a light switch. It can only have two values. Just like a light switch can only be on or off, a boolean can only be True or False

boolean

Returns a set containing the difference between two or more sets

difference()

constructs a float number from an integer literal, a float literal or a string literal (providing the string represents a float or an integer)

float()


संबंधित स्टडी सेट्स

Lab Final Exam (Digestive & Urinary System)

View Set

Chapter 31: Skin Integrity and Wound Care (Questions)

View Set

Chapter 16 Goal Setting question

View Set

MGT 629 - Leadership & Theory & Practice Course - Exam 1

View Set