[go: up one dir, main page]

0% found this document useful (0 votes)
12 views30 pages

BBA IV Sem Notes

Computer programming involves writing code to instruct computers on performing specific tasks, utilizing various programming languages such as procedural, object-oriented, and scripting. Key components include translators like compilers, assemblers, and interpreters that convert source code into machine-readable formats. Python is highlighted as a versatile programming language with features like ease of learning, portability, and a large standard library, along with its data types, operators, and control statements.

Uploaded by

diariesdoodling
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views30 pages

BBA IV Sem Notes

Computer programming involves writing code to instruct computers on performing specific tasks, utilizing various programming languages such as procedural, object-oriented, and scripting. Key components include translators like compilers, assemblers, and interpreters that convert source code into machine-readable formats. Python is highlighted as a versatile programming language with features like ease of learning, portability, and a large standard library, along with its data types, operators, and control statements.

Uploaded by

diariesdoodling
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 30

What is Computer Programming Language?

Computer programming is the process of writing instructions, or code, that tells a computer,
application, or software program how to perform specific actions. Programmers use programming
languages to write, test, revise, and update code.

Some types of programming languages include:

• Procedural: Follows a sequence of statements or commands to achieve a desired output

• Object-oriented: Helps manage complexity in large programs by packaging data and


operations into objects

• Scripting: Allows programmers to implement complex features on web pages

Some of the most popular programming languages include: JavaScript, HTML/CSS, SQL, Python, and
TypeScript.

Computer programmers work across industries, including: finance, insurance, manufacturing, and
tech.

Some related careers include:

• Data scientist

• Data analyst

• Machine learning engineer

• Full stack developer

• Project manager

• Product manager

• Data engineer

• Digital marketing specialist

• Cybersecurity analyst

here are several types of programming languages, including:

• Machine language
The lowest-level programming language, which is made up of bits and is easier for computers to
understand than programmers

• Procedural programming language

A language that follows a sequence of statements or commands to achieve a desired


output. Examples include C, C++, Java, and Pascal

• Functional programming language

A language that uses stored data to perform recursive functions. Examples include Agda, Cuneiform,
PureScript, and APL

• Object-oriented programming language

A language that treats a program as a group of objects, each with its own properties and
methods. Examples include Java, Python, PHP, and C++

Other types of programming languages include: Assembly language, Scripting languages, and Logic
programming language.

Some popular programming languages include:

JavaScript, Python, HTML, CSS, Java, SQL, NoSQL, C#, SCALA, and R.

What is translator ?
A translator is a computer program that converts source code into object code, which is a form that
a computer can understand and execute. Translators are also known as language processors

1. Compiler

The language processor that reads the complete source program written in high-level language as a
whole in one go and translates it into an equivalent program in machine language is called a
Compiler. Example: C, C++, C#.

In a compiler, the source code is translated to object code successfully if it is free of errors. The
compiler specifies the errors at the end of the compilation with line numbers when there are any
errors in the source code. The errors must be removed before the compiler can successfully
recompile the source code again the object program can be executed number of times without
translating it again.
2. Assembler

The Assembler is used to translate the program written in Assembly language into machine code. The
source program is an input of an assembler that contains assembly language instructions. The
output generated by the assembler is the object code or machine code understandable by the
computer. Assembler is basically the 1st interface that is able to communicate humans with the
machine. We need an assembler to fill the gap between human and machine so that they can
communicate with each other. code written in assembly language is some sort of
mnemonics(instructions) like ADD, MUL, MUX, SUB, DIV, MOV and so on. and the assembler is
basically able to convert these mnemonics in binary code. Here, these mnemonics also depend
upon the architecture of the machine.

For example, the architecture of intel 8085 and intel 8086 are different.

3. Interpreter

The translation of a single statement of the source program into machine code is done by a language
processor and executes immediately before moving on to the next line is called an interpreter. If there
is an error in the statement, the interpreter terminates its translating process at that statement and
displays an error message. The interpreter moves on to the next line for execution only after the
removal of the error. An Interpreter directly executes instructions written in a programming
or scripting language without previously converting them to an object code or machine code. An
interpreter translates one line at a time and then executes it.

Example: Perl, Python and Matlab.


What is Python?
Python is a general-purpose programming language that is used to create software and websites,
analyze data, and automate tasks. It is an interpreted, object-oriented, and high-level language
Features of Python
• Easy to learn: Python has a simple syntax and is easy to use.

• Open source: Python is free and open source, including its source code.:-
Python is open source because it's developed under an OSI-approved license that
allows it to be:
• Freely used and distributed: Python is free to use for personal or commercial purposes,
without any licensing fees.

• Publicly available: The source code for Python is open and accessible to the public.

• Object-oriented: Python is an object-oriented programming language.

• Portable: Python is a highly portable language.

• Large standard library: Python has a large standard library.

• Interpreted: Python is an interpreted programming language, so you can


run the same code on multiple platforms without recompiling.

What is IDE ?
An IDE (Integrated Development Environment) is a software application that
helps developers write, debug, and test code for Python:

Features of IDE

IDEs combine common developer tools into a single application with a


graphical user interface (GUI). They typically include features like a source
code editor, compiler or interpreter, debugger, syntax highlighting, code
completion, and version control integration.
What is Python Spyder IDE?

1. Spyder is an open-source cross-platform IDE. The Python Spyder IDE is written


completely in Python. It is designed by scientists and is exclusively for
scientists, data analysts, and engineers. It is also known as the Scientific
Python Development IDE and has a huge set of remarkable features which are
discussed below.
2. PyCharm is an integrated development environment (IDE) for Python that
provides a variety of tools for writing Python code, including:

• Code analysis

• Graphical debugger
• Smart code editor

• Fast navigation and search

• Autocompletion

• Error and redundancy detection and suggestions

3. A Jupyter Notebook is a web-based application that allows users to create


and share interactive documents that contain code, text, data visualizations,
and other resources:

• Features

Jupyter Notebooks support over 40 programming languages, including


Python, R, Julia, and Scala. They can be used for a variety of data science
tasks, such as exploratory data analysis, data cleaning, and machine
learning.

• Flexibility

Notebooks can be run cell by cell, and users can configure workflows to suit
their needs. They can also be converted to a number of standard output
formats, including HTML, PDF, and PowerPoint.

• Sharing

Notebooks can be shared with others using email, Dropbox, GitHub, or the
Jupyter Notebook Viewer.

• Open source

Jupyter Notebook is a fully open-source product, and users can use all of its
functionality for free.

Data types in python


Python has the following data types built-in by default, in these categories:

Text Str
Type:

Numeric int, float, complex


Types:

Sequence list, tuple, range


Types:

Mapping Dict
Type:

Set set, frozenset


Types:

Boolean Bool
Type:

Binary bytes, bytearray, memoryview


Types:

1.) Integer :- Int, or integer, is a whole number, positive or negative, without decimals, of
unlimited length.
2. Float:- Numbers with a decimal point or numbers written in exponential form, e.g., 3.14

3. Str:- strings are used for representing textual data. A string is a sequence of characters
enclosed in either single quotes ('') or double quotes (“”)

4. Dictionary :- built-in dictionary data type to create a Python dictionary. This type stores
all kinds of data, from integers to strings to lists. The dictionary data type is similar to a
list but uses keys instead of indexes to look up values. You use the dict() function in
Python to create a dictionary.

5 Complex:- The complex data type in python consists of two values, the first one is the
real part of the complex number, and the second one is the imaginary part of the complex
number. We usually denote the real part using i and the imaginary part with j. For example,
(3 + 7j)

6. Boolean:- The boolean data type is either True or False. In Python, boolean variables
are defined by the True and False keywords.

7. List :- List is a collection of things, enclosed in [ ] and separated by commas. The list
is a sequence data type which is used to store the collection of data.

8. Tuple:- Python tuples are a type of data structure that is very similar to lists. The main
difference between the two is that tuples are immutable, meaning they cannot be changed
once they are created.

9. Set :- Set is a data type in python used to store several items in a single variable. It is
one of the four built-in data types (List, Dictionary, Tuple, and Set) having qualities and
usage different from the other three. It is a collection that is written with curly brackets and
is both unindexed and unordered.

Python Operators

Operators are used to perform operations on variables and values.


Types of Operators in Python

1. Arithmetic Operators
2. Comparison Operators
3. Logical Operators
4. Assignment Operators

Python Arithmetic Operators

Arithmetic operators are used with numeric values to perform common mathematical
operations:

Operator Name Example

+ Addition x+y

- Subtraction x-y

* Multiplication x*y

/ Division x/y

% Modulus x%y

** Exponentiation x ** y

Python Assignment Operators

Assignment operators are used to assign values to variables:


Operator Example Same As

= x=5 x=5

+= x += 3 x=x+3

-= x -= 3 x=x-3

*= x *= 3 x=x*3

/= x /= 3 x=x/3

%= x %= 3 x=x%3

//= x //= 3 x = x // 3

**= x **= 3 x = x ** 3
Python Comparison Operators
Comparison operators are used to compare two values:

Operator Name Example

== Equal x == y

!= Not equal x != y

> Greater than x>y

< Less than x<y

>= Greater than or equal to x >= y

<= Less than or equal to x <= y

Python Logical Operators


Logical operators are used to combine conditional statements:

Operator Description Example

and Returns True if both statements are true x < 5 and x < 10

Or Returns True if one of the statements is true x < 5 or x < 4

Control Statements in Python

Control statements direct the flow of a Python program's execution.


They introduce logic, decision-making, and looping. Key control
statements in Python include if/else, for/while, break/continue.
if condition

if condition

The if condition is considered the simplest of the three and makes a decision based on
whether the condition is true or not. If the condition is true, it prints out the indented
expression. If the condition is false, it skips printing the indented expression.

if condition:

expression

if condition

if age >= 18:


print("You are eligible to vote")

if else condition

The if-else condition adds an additional step in the decision-making process compared to the
simple if statement. The beginning of an if-else statement operates similar to a simple if statement;
however, if the condition is false, instead of printing nothing, the indented expression under else will
be printed.
if (condition):
expression;
else:
expression

int age = 24
if age >= 18:
print("candidate is eligible”
else:
print("candidate is not eligible”)

4. if Elif else condition

if-elif-else condition
The most complex of these conditions is the if-elif-else condition. When you run into a
situation where you have several conditions, you can place as many elif conditions as
necessary between the if condition and the else condition.
if condition:
expression
elif condition:
expression
else:
expression

Example
z=3
if z % 2 == 0:
print("z is divisible by 2")
elif z % 3 == 0:
print("z is divisible by 3")
else:
print("z is neither divisible by 2 nor by 3")
Loop Control Statement
Loop Control Statements in Python

Loop control statements in python are control structures in programming that allow a
piece of code to be executed repeatedly, either a specific number of times or until a
particular condition is met

For Loop

for i in range(11):
print(i)

While Loop

num = 1
while num <= 10:
print(num)
num = num + 1

This program prints the numbers from 1 to 10 using a while loop. The loop starts at 1 and
continues until it reaches 10. The loop terminates when the value of num is greater than
10.

What is Pandas?
Pandas is a powerful and versatile library that simplifies the tasks of data manipulation
in Python. Pandas is well-suited for working with tabular data, such
as spreadsheets or SQL tables.Pandas is a Python library used for working with data
sets.

It has functions for analyzing, cleaning, exploring, and manipulating data.

Pandas allows us to analyze big data and make conclusions based on statistical
theories.Pandas can clean messy data sets, and make them readable and relevant.

• Import pandas as pd: Imports the Pandas package


• Df.sample(): Selects a random row, column, or both from a dataset
• Df.drop(): Removes rows or columns from a DataFrame by specifying their labels
• Df.head(): Displays the top five rows of a DataFrame in a formatted way
• Df.drop_duplicates(): Removes duplicate rows from a DataFrame based on the values in
all columns or a subset of column indices
• Df.to_csv("output.csv"): Saves a DataFrame as a CSV file
• Dataframe applymap(): Applies a given operation to all elements in a DataFrame

What is list in Python?

Lists can contain heterogeneous data types and objects. For instance, integers,
strings, and even functions can be stored within the same list. Different
elements of a list can be accessed by integer indices where the first element of
a list has the index of 0. This property derives from the fact that in Python, lists
are ordered, which means they retain the order in which you insert the elements
into the list.

Tuples
Tuples are almost identical to lists, so they contain an ordered collection of
elements, except for one property: they are immutable. We would use tuples
if we needed a data structure that, once created, cannot be modified anymore

Dictionaries

Dictionaries in Python are very similar to real-world dictionaries. These


are mutable data structures that contain a collection of keys and, associated
with them, values. This structure makes them very similar to word-definition
dictionaries.

Sets

Sets contain unique elements, so no duplicates are allowed. Thus, sets can
be used to remove duplicates from a list.

Mutability:

• List: Mutable (modifiable).

• Tuple: Immutable (non-modifiable).

• Set: Mutable, but elements inside must be immutable.

• Dictionary: Mutable; keys are immutable, but values can change.

Order:

• List: Maintains order of elements.

• Tuple: Maintains order of elements.

• Set: No guaranteed order.

• Dictionary: As of Python 3.7+, insertion order is preserved.


Uniqueness:

• List: Allows duplicates.

• Tuple: Allows duplicates.

• Set: Only unique elements.

• Dictionary: Unique keys, values can be duplicated.

List Comprehension in python

List comprehension is a way to create lists using a concise syntax. It allows us to


generate a new list by applying an expression to each item in an existing iterable (such
as a list or range). This helps us to write cleaner, more readable code compared to traditi
techniques.

For example, if we have a list of integers and want to create a new list containing the
square of each element, we can easily achieve this using list comprehension.

a = [2,3,4,5]

res = [val ** 2 for val in a]

print(res)
What is NumPy

NumPy stands for numeric python which is a python package for the computation and
processing of the multidimensional and single dimensional array elements.
What is function ?

a function is a block of organized code that can be reused to perform a specific


task. Functions are a way to avoid writing the same code repeatedly, which can save
time and effort.
Python | Pandas Merging, Joining, and Concatenating
Pandas DataFrame is a two-dimensional size-mutable, potentially heterogeneous tabular
data structure with labelled axes (rows and columns). A Data frame is a two-dimensional
data structure, i.e., data is aligned in a tabular fashion in rows and columns. We can join,
merge, and concat dataframe using different methods.

In Dataframe df.merge(),df.join(), and df.concat() methods help in joining, merging and


concating different dataframe.

# importing pandas module

import pandas as pd

# Define a dictionary containing employee data

data1 = {'Name': ['Jai', 'Princi', 'Gaurav', 'Anuj'],

'Age': [27, 24, 22, 32],

'Address': ['Nagpur', 'Kanpur', 'Allahabad', 'Kannuaj'],

'Qualification': ['Msc', 'MA', 'MCA', 'Phd']}

# Define a dictionary containing employee data

data2 = {'Name': ['Abhi', 'Ayushi', 'Dhiraj', 'Hitesh'],

'Age': [17, 14, 12, 52],

'Address': ['Nagpur', 'Kanpur', 'Allahabad', 'Kannuaj'],

'Qualification': ['Btech', 'B.A', 'Bcom', 'B.hons']}

# Convert the dictionary into DataFrame

df = pd.DataFrame(data1, index=[0, 1, 2, 3])


# Convert the dictionary into DataFrame

df1 = pd.DataFrame(data2, index=[4, 5, 6, 7])

print(df, "\n\n", df1)

Now we apply .concat function in order to concat two dataframe.


Python
# using a .concat() method
frames = [df, df1]

res1 = pd.concat(frames)
res1

You might also like