Intro To Programming Python
INTRO TO PROGRAMMING PYTHON List - CORRECT ANSWER-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 ANSWER-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 ANSWER-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 ANSWER-Strings store characters and have many built-in convenience methods that let you modify their content. The len() Function - CORRECT ANSWER-Using len(some_object) returns the number of _top-level_ items contained in the object being queried. Length of string Print - CORRECT ANSWER-A function to display the output of a program. Using the parenthesized version is arguably more consistent. The range() Function - CORRECT ANSWER-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 ANSWER-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 ANSWER-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 ANSWER-function that enabled the user to insert their string. Now obsolete input() - CORRECT ANSWER-function that enables user to insert data as a string sort method - CORRECT ANSWER-() method is used to sort a list. Distinguish method vs. a built in function - CORRECT ANSWER-function has curly braces after it, method has .'dot' notation. Why use classes? - CORRECT ANSWER-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 ANSWER-•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 ANSWER-When a class has its own functions, those functions are called methods. You've already seen one such method: __init__(). Functions - CORRECT ANSWER-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 ANSWER-Objects are an encapsulation of variables and functions into a single entity. Objects get their variables and functions from classes. Classes are essentially a template to create your objects. List - CORRECT ANSWER-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 ANSWER-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 ANSWER-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 ANSWER-Strings store characters and have many built-in convenience methods that let you modify their content. The len() Function - CORRECT ANSWER-Using len(some_object) returns the number of _top-level_ items contained in the object being queried. Length of string Print - CORRECT ANSWER-A function to display the output of a program. Using the parenthesized version is arguably more consistent. The range() Function - CORRECT ANSWER-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 ANSWER-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 ANSWER-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 ANSWER-function that enabled the user to insert their string. Now obsolete input() - CORRECT ANSWER-function that enables user to insert data as a string sort method - CORRECT ANSWER-() method is used to sort a list. Distinguish method vs. a built in function - CORRECT ANSWER-function has curly braces after it, method has .'dot' notation. Why use classes? - CORRECT ANSWER-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 ANSWER-•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 ANSWER-When a class has its own functions, those functions are called methods. You've already seen one such method: __init__(). Functions - CORRECT ANSWER-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 ANSWER-Objects are an encapsulation of variables and functions into a single entity. Objects get their variables and functions from classes. Classes are essentially a template to create your objec
Información del documento
- Subido en
- 20 de noviembre de 2023
- Número de páginas
- 4
- Escrito en
- 2023/2024
- Tipo
- Examen
- Contiene
- Preguntas y respuestas