100% satisfaction guarantee Immediately available after payment Both online and in PDF No strings attached 4.6 TrustPilot
logo-home
Exam (elaborations)

Test Bank Questions and Answers for Computer programming Unit 3 Already Passed

Rating
-
Sold
-
Pages
9
Grade
A+
Uploaded on
08-10-2024
Written in
2024/2025

Test Bank Questions and Answers for Computer programming Unit 3 Already Passed def functionname(): →function_body - Answers #creates a function def (for "define") after def goes the name of the function Remember - Python reads your code from top to bottom. It's not going to look ahead in order to find a function you forgot to put in the right place ("right" means "before invocation") You mustn't have a function and a variable of the same name. Assigning a value to the name message causes Python to forget its previous role. The function named message becomes unavailable. def message(): →print("Enter next value") print("We start here") message() print("The end is here") - Answers We start here Enter next value The end is here def message(who,no): →print("'s favorite number is", no) message("Satan", 666) - Answers Satan's favorite number is 666 def introduction(first,last): →print("Hello, my name is ", first, last, ".") introduction(first="James", last="Bond") introduction(last="Skywalker", first="Luke") - Answers Hello, my name is James Bond. Hello, my name is Luke Skywalker. #You can mix both fashions if you want - there is only one unbreakable rule: you have to put positional arguments before keyword ones. def introduction(first, last="Adams"): →print("Hello, my name is ", first, last, ".") introduction("James") introduction("Hunter", "Skywalker") - Answers Hello, my name is James Adams . Hello, my name is Hunter Skywalker . def strange (n): →if(n % 2 == ): →→return True print(strange(2)) print(strange(1)) - Answers True None def sumoflist(l): →sum = 0 →for el in l: →→sum += el →return sum print(sumoflist([5,4,3])) - Answers 12

Show more Read less
Institution
Coding.
Module
Coding.

Content preview

Test Bank Questions and Answers for Computer programming Unit 3 Already Passed

def functionname():

→function_body - Answers #creates a function

def (for "define")

after def goes the name of the function



Remember - Python reads your code from top to bottom. It's not going to look ahead in order to find a
function you forgot to put in the right place ("right" means "before invocation")



You mustn't have a function and a variable of the same name. Assigning a value to the name message
causes Python to forget its previous role. The function named message becomes unavailable.

def message():

→print("Enter next value")



print("We start here")

message()

print("The end is here") - Answers We start here

Enter next value

The end is here

def message(who,no):

→print("'s favorite number is", no)



message("Satan", 666) - Answers Satan's favorite number is 666

def introduction(first,last):

→print("Hello, my name is ", first, last, ".")

, introduction(first="James", last="Bond")

introduction(last="Skywalker", first="Luke") - Answers Hello, my name is James Bond.

Hello, my name is Luke Skywalker.



#You can mix both fashions if you want - there is only one unbreakable rule: you have to put positional
arguments before keyword ones.

def introduction(first, last="Adams"):

→print("Hello, my name is ", first, last, ".")



introduction("James")

introduction("Hunter", "Skywalker") - Answers Hello, my name is James Adams .

Hello, my name is Hunter Skywalker .

def strange (n):

→if(n % 2 == ):

→→return True



print(strange(2))

print(strange(1)) - Answers True

None

def sumoflist(l):

→sum = 0

→for el in l:

→→sum += el

→return sum



print(sumoflist([5,4,3])) - Answers 12

Written for

Institution
Coding.
Module
Coding.

Document information

Uploaded on
October 8, 2024
Number of pages
9
Written in
2024/2025
Type
Exam (elaborations)
Contains
Questions & answers

Subjects

Get to know the seller

Seller avatar
Reputation scores are based on the amount of documents a seller has sold for a fee and the reviews they have received for those documents. There are three levels: Bronze, Silver and Gold. The better the reputation, the more your can rely on the quality of the sellers work.
TutorJosh Chamberlain College Of Nursing
View profile
Follow You need to be logged in order to follow users or courses
Sold
400
Member since
1 year
Number of followers
17
Documents
30833
Last sold
15 hours ago
Tutor Joshua

Here You will find all Documents and Package Deals Offered By Tutor Joshua.

3.4

66 reviews

5
23
4
15
3
12
2
0
1
16

Trending documents

Recently viewed by you

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their exams and reviewed by others who've used these revision notes.

Didn't get what you expected? Choose another document

No problem! You can straightaway pick a different document that better suits what you're after.

Pay as you like, start learning straight away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and smashed it. It really can be that simple.”

Alisha Student

Frequently asked questions