• Wrong document? Swap it for free
  • Written by students who passed
  • Immediately available after payment
  • Read online or as PDF
Sell
Where do you study
Your language
Document preview thumbnail
Preview 1 out of 2 pages
Exam (elaborations)

Intro To Programming Python Question $ Correct Answers

Document preview thumbnail
Preview 1 out of 2 pages

NTRO TO PROGRAMMING PYTHON QUESTION $ CORRECT ANSWERS List - CORRECT ANSWERS-A Python data type that holds an ordered collection of values, which can be of any type. This is equivalant to an "array" in many other languages. Python lists are "mutable," implying that they can be changed once created. Variables - CORRECT ANSWERS-Variables are assigned values using the '=' operator, which is not to be confused with the '==' sign used for testing equality. A variable can hold almost any type of value such as lists, dictionaries, functions. Functions - CORRECT ANSWERS-Python builds functions using the syntax: def function_name(variable): Functions can be stand-alone or can return values. Functions can also contain other functions. Strings - CORRECT ANSWERS-Strings store characters and have many built-in convenience methods that let you modify their content. The len() Function - CORRECT ANSWERS-Using len(some_object) returns the number of _top-level_ items contained in the object being queried. Length of string Print - CORRECT ANSWERS-A function to display the output of a program. Using the parenthesized version is arguably more consistent. The range() Function - CORRECT ANSWERS-The range() function returns a list of integers, the sequence of which is defined by the arguments passed to it. Used in for loops. While Loops - CORRECT ANSWERS-A While loop permits code to execute repeatedly until a certain condition is met. This is useful if the number of iterations required to complete a task is unknown prior to flow entering the loop. The str() Function - CORRECT ANSWERS-Using the str() function allows you to represent the content of a variable as a string, provided that the data type of the variable provides a neat way to do so. str() does not change the variable in place, it returns a 'stringified' version of it. raw_input() - CORRECT ANSWERS-function that enabled the user to insert their string. Now obsolete input() - CORRECT ANSWERS-function that enables user to insert data as a string sort method - CORRECT ANSWERS-() method is used to sort a list. Distinguish method vs. a built in function - CORRECT ANSWERS-function has curly braces after it, method has .'dot' notation. Why use classes? - CORRECT ANSWERS-Python is an object-oriented programming language, which means it manipulates programming constructs called objects. You can think of an object as a single data structure that contains data as well as functions Class Syntax - CORRECT ANSWERS-•call class then class name (parameter) • then create a function def__init with 'self' as the 1st parameter comma then 2nd parameters. •call = name and ation = occupation •create a new variable and have it equal to your example object and use built in parameters to build your objects parameters. Methods - CORRECT ANSWERS-When a class has its own functions, those functions are called methods. You've already seen one such method: __init__(). Functions - CORRECT ANSWERS-Functions are a convenient way to divide your code into useful blocks, allowing us to order our code, make it more readable, reuse it and save some time. Also functions are a key way to define interfaces so programmers can share their code. Objects - CORRECT ANSWERS-Objects are an encapsulation of variables and functions into a single entity. Objects get their variables and functions from classes. Classes are essentially a templ


Document information

Uploaded on
November 20, 2023
Number of pages
2
Written in
2023/2024
Type
Exam (elaborations)
Contains
Questions & answers
$8.99

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

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.
Bestcontents
4.5
(8)
Sold
34
Followers
13
Items
2030
Last sold
10 months ago




Why students choose Stuvia

Created by fellow students, verified by reviews

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

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right 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 aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions

Whoops! We can’t load your doc right now. Try again or contact support.