Podcast
Questions and Answers
What type of programming is Python?
What type of programming is Python?
- Hello
- Lower
- Relational
- Interpreted (correct)
Who created Python?
Who created Python?
Guidovan Rossum
What function is used to output information in Python?
What function is used to output information in Python?
print()
What does the modulus operator calculate?
What does the modulus operator calculate?
What does IDE stand for?
What does IDE stand for?
What library is commonly used for mathematical operations in Python?
What library is commonly used for mathematical operations in Python?
What is a statement that assigns a value to a name?
What is a statement that assigns a value to a name?
What id the statement that assigns a value?
What id the statement that assigns a value?
What is the process of detecting and removing existing and potential errors in a software code that can cause it to behave unexpectedly or crash?
What is the process of detecting and removing existing and potential errors in a software code that can cause it to behave unexpectedly or crash?
What is a decision table?
What is a decision table?
In Python, what symbol is used for the addition operator?
In Python, what symbol is used for the addition operator?
In Python, what symbol represents the subtraction operator?
In Python, what symbol represents the subtraction operator?
In Python, what symbol is used as the multiplication operator?
In Python, what symbol is used as the multiplication operator?
In Python, what symbol represents the division operator?
In Python, what symbol represents the division operator?
In Python, what symbol represents the modulus operator?
In Python, what symbol represents the modulus operator?
List some of the features of python programming.
List some of the features of python programming.
What is a variable?
What is a variable?
Explain the syntax of if
statement
Explain the syntax of if
statement
What is Break statement?
What is Break statement?
Match global variable with local variable properties:
Match global variable with local variable properties:
What is math.acos()?
What is math.acos()?
Explain python Dictionary
Explain python Dictionary
What is a function?
What is a function?
What are keyword name with values?
What are keyword name with values?
What is a variable length argument?
What is a variable length argument?
Differentiate between pass by reference and pass by value
Differentiate between pass by reference and pass by value
What is while loop?
What is while loop?
What are comments section?
What are comments section?
Explain The precedence of an operator
Explain The precedence of an operator
Flashcards
Relational Operator
Relational Operator
Used to determine the relationship between two values.
lower() Method
lower() Method
A string method that converts a string to lowercase.
Interpreted Language
Interpreted Language
A type of programming language that executes code line by line.
Guido van Rossum
Guido van Rossum
Signup and view all the flashcards
print() Function
print() Function
Signup and view all the flashcards
Modulus Operator (%)
Modulus Operator (%)
Signup and view all the flashcards
Integrated Development Environment (IDE)
Integrated Development Environment (IDE)
Signup and view all the flashcards
Assignment Statement
Assignment Statement
Signup and view all the flashcards
del Keyword
del Keyword
Signup and view all the flashcards
Debugging
Debugging
Signup and view all the flashcards
Decision Table
Decision Table
Signup and view all the flashcards
Addition Operator (+)
Addition Operator (+)
Signup and view all the flashcards
Subtraction Operator (-)
Subtraction Operator (-)
Signup and view all the flashcards
Multiplication Operator (*)
Multiplication Operator (*)
Signup and view all the flashcards
Division Operator (/)
Division Operator (/)
Signup and view all the flashcards
Features of Python
Features of Python
Signup and view all the flashcards
Variable
Variable
Signup and view all the flashcards
Variable Naming Rules
Variable Naming Rules
Signup and view all the flashcards
if...else Statement
if...else Statement
Signup and view all the flashcards
Break Statement
Break Statement
Signup and view all the flashcards
Global Variable
Global Variable
Signup and view all the flashcards
Local Variable
Local Variable
Signup and view all the flashcards
math.acos()
math.acos()
Signup and view all the flashcards
math.acosh()
math.acosh()
Signup and view all the flashcards
math.asin()
math.asin()
Signup and view all the flashcards
Dictionary
Dictionary
Signup and view all the flashcards
Dictionary Items
Dictionary Items
Signup and view all the flashcards
User-Defined Functions
User-Defined Functions
Signup and view all the flashcards
Default Argument
Default Argument
Signup and view all the flashcards
Keyword Argument
Keyword Argument
Signup and view all the flashcards
Study Notes
- The exam was for B.Sc 3rd semester students
- The subject was Computer
- The paper title was "Programming Computer"
- The exam was in December 2021
- The date of the exam was 23/8/2022
- The paper code was GCS-005
Relational Operators
- Used for relational operations.
Lower() Function
- Refers to the lower function.
Interpreted Languages
- The code is executed line by line.
- The Hello
- The creator of Python is Guidovan Rossum.
- Functions: print().
- The operation of getting the remainder of a division problem.
- IDE stands for Integrated Development Learning Environment.
- Functions: Math.
Assigning values to names
- A statement that assigns a value to a name.
- The variable name is is to the left of equals sign (=), the assignment operator.
- To the right of the assignment operator is an expression.
- The expression is evaluated by the Python interpreter then assigned to the name.
- The keyword "del" erases objects
- "del" keyword can also be used to delete variables, lists, or parts of a list
- Everything in Python is an object
Debugging
- Debugging identifies, removes existing and potential errors in a software code, preventing unexpected behavior or crashes.
Decision Table
- A scheduled rule logic entry in table format.
- Conditions are represented on the row and column headings.
- Actions are represented as the intersection points of the condition cases in the table.
Addition Operator in Python (+)
- Used to add two values.
Subtraction Operator in Python (-)
- Used to subtract the second value from the first value.
Multiplication Operator in Python (*)
- Used to find the product of two values.
Division Operator in Python (/)
- Used to find the quotient when the first operand as divided by the second operand.
Modulus Operator in Python (%)
- Used to find the remainder where the first operand is divided by the second operand.
Features of Python
- Easy to learn and understand.
- Cross-platform programming language, usable with operating systems like Windows and Linus
- Interpreted language which executes code line by line.
- Object-oriented, procedural, and functional programming language.
- High-level programming language.
- Large global community.
- Large ecosystem of libraries, frameworks, and tools.
Variables
- A named place in memory that holds any type of data which the program can assign and modify.
- In Python there is no need to declare a variable explicitly by specifying whether the variable is an integer, float, or any other type.
- Variable names are case-sensitive.
- Python keywords are not allowed as a variable name.
- Variables should not start with a number.
- Variable names can consist of any number of letters, underscores, or digits.
- No white space is allowed within the variable name.
"if" Condition
- The syntax of the "if" statement is given by:
- "if" Boolean - expression: Statement 1 else: Statement 2
- The if statement evaluates the "Boolean-expression."
- If the condition is true, Statement 1 of the if statement is executed.
- Otherwise, the else statement executes if the first condition is false.
Break Statement
- A loop control statement that terminates the loop.
- once its encountered.
- The loop interaction stops, and control returns immediately to the first statement.
- Syntax: Break ;
- Example provided in the text for illustrating the use of Break statement
Global Variables
- Global variables are declared outside all the function blocks.
- The scope of variables remains throughout the program.
- Any changes affect the entire program wherever it is used.
- Global variables exist in the program for the entire runtime of when the program executed.
- If the global variable is not initialized, it takes it.
Local Variables
- Local variable are declared within a function block.
- The scope is limited and remains within the function only in which they are declared.
- Any changes in the local variable do not offset other function of the Program.
- A local variable is created when the function is created.
- Once the execution is finished, the variable is destroyed.
- If the local variable is not initialized, it takes it.
Python Math Functions
- math.acos() returns are cosine of a number
- math.acosh() returns inverse hyperbolic Cosine of a number
- math.asin() Return arc sine of a number
- math.asinh() Return inverse hyperbolic sine of a number
- math.atan() return arc tangent of the number in radian
- math.atan2() return arc tangent of y/x in radians.
Dictionaries
- Python's implementation of a data structure.
- Dictionaries are generally known as an associate way.
- A dictionary consists of a collection of key-value pairs.
- Each key-value pair maps the key to its associated value.
- A dictionary is a collection which is ordered changeable and does not allow duplicates
- Written with curly brackets and have keys and values.
- Dictionary items are presented in key: valued pairs and can be referred to by using key names.
- It means that the dictionary item have defined order, and that order will not change.
- Unordered means that the items does not haved a defined ordered and cannot refer to at item, therefore you cannot use using an index
- You cannot have two items with the same key
- Dictionaries are changeable, which means we change, add or remove items after creating the dictionary.
Dictionary Length
- To determine how many items a dictionary has, use the len() function.
Functions
- Defined by the users to perform specific tasks, are user-defined functions.
- Written by the users using the syntax: def function_name(): Statement
- We can pass parameters when defining a function.
Default Arguments
- A parameter that assumes a default value if a value is not provided in the function call for that argument.
Keyword Arguments
- Allows the caller to to specify argument names with values so that the caller does not need to remember the order of the parameters
Variable Length Arguments
- The special syntax *args in a function definition in Python is used to pass a variable number of arrangements to a function, in order pass a non-keyword, variable length argument
- The spectal syntax **kwargs in a function definition is used to parsed *keywords, variable - length argument
- Pass by reference or pass by value:
By Reference
- In pass by reference, teh address of the variable is directly passed as the and then the operation is done on the value stored at these address
By Value
- In pass by value, the value of the variable is directly passed as the value to
While Loops
- Used to repeat a section of code an unknown number to times until a specific condition is met.
- For example, to know how many times a given number can divide by to before it is less than or equal to one
- For a given symbolic variable "NUMBER" which represents any number in the world, how many times it is not known a priori.
- We could use a while loop to determine that answer.
- A recommended "pseudocode" for such an algorithm to keep dividing if is bigger by 2 or more keep a count of how many divisions there are.
Python Comments
- Can be used to explain python code
Operator Precedence
- Specifies how "tightly" binds less expressins together"
- For example, in the expression 1 +4*3, then answer is 13, the multiplication has is has a higher precedence than addition
- Parenthesis forces operator precedence (1+5)*3 evaluates to 18
- When operators have equal precedence, associativity of the operator determines the order of evalution
- Left associative example, 14-2-3 grouped as (14-2)-3 and evaluates to 9
- Non-associative operands cannot be neach to each other, for example 4 < 2 > 1 is illegal
Studying That Suits You
Use AI to generate personalized quizzes and flashcards to suit your learning preferences.
Related Documents
Description
Lecture notes for B.Sc 3rd semester computer students covering relational operators, lower() function, interpreted languages and assigning values to names, including the use of the 'del' keyword. It also mentions Python's creator Guido van Rossum and commonly used functions.