B.Sc Computer: Programming Concepts
29 Questions
0 Views

Choose a study mode

Play Quiz
Study Flashcards
Spaced Repetition
Chat to Lesson

Podcast

Play an AI-generated podcast conversation about this lesson

Questions and Answers

What type of programming is Python?

  • Hello
  • Lower
  • Relational
  • Interpreted (correct)

Who created Python?

Guidovan Rossum

What function is used to output information in Python?

print()

What does the modulus operator calculate?

<p>getting the remainder of a division problem</p> Signup and view all the answers

What does IDE stand for?

<p>Integrated Development Learning Environment</p> Signup and view all the answers

What library is commonly used for mathematical operations in Python?

<p>Math</p> Signup and view all the answers

What is a statement that assigns a value to a name?

<p>A statement that assign a value to a name. To the left of the assignment operator, =, is a name. To the right of the assignment operator is an expression which is evaluated by the python enterpreter and then assigned to the name</p> Signup and view all the answers

What id the statement that assigns a value?

<p>del keyword</p> Signup and view all the answers

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?

<p>Debugging is the process of detecting and removing of existing and potential errors in a software code that can cause it to behave uncapexpectedly or crash.</p> Signup and view all the answers

What is a decision table?

<p>A decision table is a scheduled rule logic entry in table format that consist of condition represented on the scow and column heading and action's represented as the intersection points of the condition cases im the table.</p> Signup and view all the answers

In Python, what symbol is used for the addition operator?

<ul> <li></li> </ul> Signup and view all the answers

In Python, what symbol represents the subtraction operator?

<ul> <li></li> </ul> Signup and view all the answers

In Python, what symbol is used as the multiplication operator?

<ul> <li></li> </ul> Signup and view all the answers

In Python, what symbol represents the division operator?

<p>/</p> Signup and view all the answers

In Python, what symbol represents the modulus operator?

<p>%</p> Signup and view all the answers

List some of the features of python programming.

<p>The features of a python programming ane:</p> <ol> <li>It is cary to learn and eary to understand</li> <li>Il is an interpreted programming language. It executes the code line by line</li> </ol> <p>in) It is a cross-platfotem programming language operating system like windows, Linux,Mac OS etc.</p> <p>iv) It is object oriented, procedure and fanctional programming language.</p> <p>v) It is a high level programming language vi) It has a huge community to get help all over the globe</p> <p>vi) It has large ecosystem of libraries, Frameworder and tools to work with</p> Signup and view all the answers

What is a variable?

<p>Variable is a name place holder to hold any type of data arhich the program can are to assign and modify the course of execution.</p> <p>In python, there is no need to dulove a variable explicitly by specifying achither the variable is an integer or float or any other type.</p> <p>The rules and convention for declaring</p> Signup and view all the answers

Explain the syntax of if statement

<pre><code class="language-python">if Boolean - expression: $ lalement I else: Statement 2. </code></pre> Signup and view all the answers

What is Break statement?

<p>Break statement in a loop control statement that is used to terminate the loop. As soon as the break statement is encountered from achithin a loop, she ecop enteraction stops enore, and contool returns from the loop immediately to the Bicest statement of een the loop.</p> <p>Syntax of break. statement. Break</p> <p>Example</p> Signup and view all the answers

Match global variable with local variable properties:

<p>Global variable = If the global variable is not initialized, it. Local variable = If the local variable in not initialized it fakes id</p> Signup and view all the answers

What is math.acos()?

<p>Returns the actiots and corime of a number</p> Signup and view all the answers

Explain python Dictionary

<p>Dictionaries are python's implementa. tion of a data structure that is more genereally Known as an associate way. A dictionary consist of a collection of key value paites. Each key value pair maps the key to il associated valur</p> Signup and view all the answers

What is a function?

<p>Function that we define ourselues to do certain specific bask are referred to as aser defined fanction They are aur then by the users using the syntani</p> <p>def function-name() il can statement</p> Signup and view all the answers

What are keyword name with values?

<p>It allocus caller to specify argument name with values so that caller does not need to remember order of parameter</p> Signup and view all the answers

What is a variable length argument?

<p>The special syntax * args in fanction defimtion in python is used to pars a variable namber of arrangement to a fanction. It is used to pass a non Keyword, variable length argument</p> Signup and view all the answers

Differentiate between pass by reference and pass by value

<ul> <li> <p>In pass by reference, the address of the variable is directly passed as the and thors the operation is done on the value stored at chere addresses.</p> </li> <li> <p>In pass by value, the value of the variable in directly parsed to as the value</p> </li> </ul> Signup and view all the answers

What is while loop?

<p>The while loop is used to repeat a rection an anknown mamber of cumes antill a specific condition is met. For example, say are want to can be divided by 2 before it is less Chan De equal to 1.</p> Signup and view all the answers

What are comments section?

<p>Comments can be sed to explain python code.</p> Signup and view all the answers

Explain The precedence of an operator

<p>The precedence of an operator species how lightly&quot; it binds lees expression together for example, in the expression not is Because the multiplication (nom) operator has a higher precedence than the addilion (&quot;) operator</p> Signup and view all the answers

Flashcards

Relational Operator

Used to determine the relationship between two values.

lower() Method

A string method that converts a string to lowercase.

Interpreted Language

A type of programming language that executes code line by line.

Guido van Rossum

The creator of the Python programming language.

Signup and view all the flashcards

print() Function

A function used to display output in Python.

Signup and view all the flashcards

Modulus Operator (%)

Returns the remainder of a division.

Signup and view all the flashcards

Integrated Development Environment (IDE)

An application that provides comprehensive facilities to computer programmers for software development.

Signup and view all the flashcards

Assignment Statement

A declaration that associates a name with a value.

Signup and view all the flashcards

del Keyword

A keyword used to remove objects (variables, lists, etc.).

Signup and view all the flashcards

Debugging

The process of identifying and removing errors from code.

Signup and view all the flashcards

Decision Table

A structured table that outlines conditions and actions in a decision-making process.

Signup and view all the flashcards

Addition Operator (+)

Adds two values together.

Signup and view all the flashcards

Subtraction Operator (-)

Subtracts the second value from the first.

Signup and view all the flashcards

Multiplication Operator (*)

Finds the product of two values.

Signup and view all the flashcards

Division Operator (/)

Finds the quotient of two values.

Signup and view all the flashcards

Features of Python

Easy to learn, interpreted, cross-platform, object-oriented, high-level.

Signup and view all the flashcards

Variable

A named storage location that holds data.

Signup and view all the flashcards

Variable Naming Rules

Case-sensitive, no keywords, starts with letter/underscore.

Signup and view all the flashcards

if...else Statement

Executes one block of code if a condition is true, otherwise another block.

Signup and view all the flashcards

Break Statement

Terminates a loop prematurely.

Signup and view all the flashcards

Global Variable

Declared outside functions; accessible everywhere.

Signup and view all the flashcards

Local Variable

Declared inside functions; accessible only within that function.

Signup and view all the flashcards

math.acos()

Returns the arc cosine of a number.

Signup and view all the flashcards

math.acosh()

Returns the inverse hyperbolic cosine of a number.

Signup and view all the flashcards

math.asin()

Returns the arc sine of a number.

Signup and view all the flashcards

Dictionary

A data structure of key-value pairs.

Signup and view all the flashcards

Dictionary Items

Ordered, changeable collections of key-value pairs.

Signup and view all the flashcards

User-Defined Functions

Functions created by the programmer for specific tasks.

Signup and view all the flashcards

Default Argument

A parameter with a predefined value if none is provided.

Signup and view all the flashcards

Keyword Argument

Arguments passed with their names.

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.

Quiz Team

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.

More Like This

Mastering Automation
7 questions

Mastering Automation

EagerErudition avatar
EagerErudition
Python Overview and Benefits
40 questions
Use Quizgecko on...
Browser
Browser