Revision (1)

Download as pdf or txt
Download as pdf or txt
You are on page 1of 19

PROGRAMMING FOR MANAGERIAL APPLICATION

REVISION NOTES
Unit 1

1. Structured v/s Unstructured Data

• Structured Data: Data that is highly organized and easily searchable in a


tabular format (rows and columns). Examples: databases, spreadsheets (e.g.,
Excel), relational databases (SQL).
• Unstructured Data: Data that lacks a predefined structure and is often stored
in its native format. Difficult to analyze using traditional tools. Examples: text
documents, emails, images, videos, social media posts.

Key Differences:

• Searchability: Structured data is easily searchable, while unstructured data


requires advanced tools like natural language processing (NLP) to extract
information.
• Storage: Structured data is stored in databases, while unstructured data is
stored in various formats like text files, images, or multimedia.

2. Information v/s Data

• Data: Raw, unprocessed facts and figures (e.g., numbers, text, images). Data
itself has no context or meaning.
• Information: Data that has been processed, organized, or structured in a way
that adds meaning and context, making it useful for decision-making.

Key Differences:

• Raw vs. Processed: Data is raw, whereas information is processed and ready
to be used.
• Meaning: Information has meaning and can be acted upon, while data may
need to be processed to derive meaning.

3. How is data science transforming different industries? Elaborate on its role in personalized
recommendations, targeted advertising, smart devices, health monitoring applications, and
fraud detection.

• Personalized Recommendations: Used by platforms like Netflix, Amazon to


suggest content or products based on user behavior, preferences, and history.
• Targeted Advertising: Advertisements are displayed to users based on their
browsing patterns and preferences, ensuring higher conversion rates (e.g.,
Facebook ads).

NOTE : Only pointers / hints are given below each question. Students are expected to elaborate
the answers and give examples or code wherever necessary to get maximum marks.
• Smart Devices: Internet of Things (IoT) devices use data science to optimize
performance, automate tasks, and enhance user experience (e.g., smart
thermostats, wearable devices).
• Health Monitoring Applications: Apps like Fitbit and Apple Health track
physical activities and vital signs, using data science to provide personalized
health insights.
• Fraud Detection: In finance, data science helps detect fraudulent activities by
analyzing transaction patterns and identifying anomalies (e.g., unusual spending
patterns).

4. What is Data science


• • Definition: Data science is an interdisciplinary field that uses scientific
methods, processes, algorithms, and systems to extract insights from
structured and unstructured data.
• • Components: It integrates techniques from mathematics, statistics, artificial
intelligence (AI), and computer science to analyze data and make informed
decisions.
• • Applications: Data science is applied in various fields like healthcare,
finance, e-commerce, marketing, and more.
5. DS in Day-to-Day Activities :- personalized recommendations, targeted advertising, smart
devices, health monitoring applications, and fraud detection
• • Personalized Recommendations: Algorithms track user preferences and
suggest movies, products, or content (e.g., Netflix, YouTube).
• • Targeted Advertising: Ads are delivered to users based on browsing
habits, demographic data, and previous purchases.
• • Smart Devices: Devices like smart speakers (Alexa, Google Home) use
data science to provide personalized responses, automate tasks, and control
other devices.
• • Health Monitoring Applications: Track physical activity, sleep patterns,
and vital signs, and provide insights to users on their health.
• • Fraud Detection: In banks and online platforms, algorithms detect
fraudulent transactions by identifying irregular patterns in data.
6. Relation of DS with ML, AI, and Big Data

• Data Science: Focuses on extracting insights from data.


• Machine Learning (ML): A subset of AI that enables systems to learn from data
and make decisions without explicit programming.
• Artificial Intelligence (AI): Broad field aimed at creating machines that can
mimic human intelligence.
• Big Data: Refers to large, complex datasets that traditional processing tools
cannot handle. Data science techniques are often used to analyze and process big
data.

Relationship:

• Data science uses machine learning algorithms to analyze big data.


• AI technologies often rely on data science techniques to improve decision-making
processes.
NOTE : Only pointers / hints are given below each question. Students are expected to elaborate
the answers and give examples or code wherever necessary to get maximum marks.
7. Applications of DS in Finance, Politics, Health Care, Urban Planning

• 1. Finance:

• Fraud Detection: Identifies unusual transaction patterns to prevent fraud.


• Risk Management: Predicts credit risk, market volatility, and helps in
investment decisions.
• Algorithmic Trading: Uses data-driven models to execute trades at optimal
times.

2. Politics:

• Sentiment Analysis: Analyzes public opinion from social media and polls.
• Voter Behavior Prediction: Predicts voting patterns based on demographics
and previous elections.
• Campaign Targeting: Identifies key voter groups to target for election
campaigns.

3. Health Care:

• Disease Prediction: Predicts the likelihood of diseases based on patient data


(e.g., diabetes prediction).
• Personalized Medicine: Tailors treatments to individual patient profiles.
• Medical Imaging: Analyzes scans and images for early diagnosis of
conditions like cancer.

4. Urban Planning:

• Traffic Management: Uses data to optimize traffic flow and reduce


congestion.
• Infrastructure Development: Predicts population growth to plan city
infrastructure.
• Environmental Monitoring: Analyzes data to improve air quality and
manage resources.

8. Types of data : Open Data, Social Media Data, Multimodal Data


• Open Data: Freely available data for public use. Governments and
organizations release open datasets for transparency and research (e.g., World
Bank datasets).
• Social Media Data: Data generated from social media platforms such as posts,
likes, shares, and comments. Can be analyzed for trends, sentiments, and user
behavior.
• Multimodal Data: Data from multiple sources or formats (e.g., text, audio,
video) used to gain a comprehensive understanding of a topic or scenario.
9. Data Preprocessing - Data Cleaning, Data Transformation & Reduction

• Data Cleaning: Involves handling missing data, removing duplicates, fixing


inconsistencies, and correcting errors.
NOTE : Only pointers / hints are given below each question. Students are expected to elaborate
the answers and give examples or code wherever necessary to get maximum marks.
• Data Transformation: Converts data into a suitable format for analysis (e.g.,
normalizing, encoding categorical data, scaling features).
• Data Reduction: Reduces the volume of data to improve analysis efficiency
(e.g., feature selection, dimensionality reduction using PCA).

UNIT II

1. Explain the concept of Data Validation in Excel. Why is it important in data


management?

• Data Validation: A feature in Excel that restricts the type of data or values users
can enter into a cell. It ensures data consistency and accuracy.
• Importance:

• Prevents invalid data entry.


• Helps maintain data integrity by ensuring correct data types, ranges, or
formats are input.
• Simplifies data entry and reduces errors in large datasets (e.g., limiting input
to specific dates, numbers, or text).

2. How can you use Data Validation to restrict input to a specific range of numbers in
Excel? Provide the steps involved.

Steps to restrict input to a number range:

• Select the cell(s) where you want to apply validation.


• Go to the Data tab → Data Validation.
• In the Allow dropdown, choose Whole Number or Decimal.
• Set the Minimum and Maximum values.
• Click OK to apply the validation.

Example: Restricting a cell to accept only numbers between 10 and 100.

3. Explain how Data Validation can be used to create a drop-down list in Excel. Why
would you use a drop-down list in a data entry form?

• Steps to create a drop-down list:

• Select the cell(s).


• Go to Data tab → Data Validation.
• Under Allow, choose List.
• In the Source box, either manually enter values (separated by commas) or
refer to a cell range.
• Click OK.
NOTE : Only pointers / hints are given below each question. Students are expected to elaborate
the answers and give examples or code wherever necessary to get maximum marks.
• Use Case:

• Drop-down lists simplify data entry by allowing users to choose from


predefined options, reducing the chance of input errors (e.g., selecting
departments from a list).

4. What is Conditional Formatting in Excel, and why is it useful for data analysis?

• Conditional Formatting: A feature that changes the appearance (color,


font, etc.) of cells based on their values.
• Usefulness in Data Analysis:

• Helps identify patterns, trends, or outliers quickly.


• Highlights key data points (e.g., sales targets met or exceeded, negative
values).
• Provides visual cues for decision-making.

5. Describe the different types of Conditional Formatting rules available in Excel.


Provide examples of how each type can be used.

Types of Conditional Formatting:

a. Highlight Cells Rules: Highlights cells based on specific


conditions (e.g., values greater than 50).
b. Top/Bottom Rules: Highlights the highest or lowest values in a
range (e.g., top 10% performers).
c. Data Bars: Adds gradient bars inside cells to show relative values
(e.g., budget usage).
d. Color Scales: Applies a color gradient to cells based on their
values (e.g., visualizing sales data distribution).
e. Icon Sets: Adds icons (e.g., arrows, stars) based on value ranges
(e.g., traffic light system for performance).

Example: Highlight all cells with sales greater than $1000 using "Highlight Cells
Rules."

6. Explain the steps to apply Conditional Formatting to highlight cells that contain
values greater than a specific number.

Steps:

• Select the range of cells.


• Go to the Home tab → Conditional Formatting.

NOTE : Only pointers / hints are given below each question. Students are expected to elaborate
the answers and give examples or code wherever necessary to get maximum marks.
• Choose Highlight Cells Rules → Greater Than.
• Enter the value (e.g., 50).
• Choose a format (e.g., bold red text).
• Click OK to apply the formatting.

7. How can you use Conditional Formatting to highlight duplicate values in a dataset?
What are the practical benefits of this feature?

Steps to highlight duplicate values:

• Select the range of cells.


• Go to Conditional Formatting → Highlight Cells Rules → Duplicate
Values.
• Choose a format (e.g., fill with color).
• Click OK.

Practical Benefits:

• Helps detect and resolve duplicate entries in large datasets.


• Improves data accuracy and prevents incorrect calculations or reportin

8. Describe a scenario where Conditional Formatting can be used to create a visual


representation of data trends, such as highlighting the top 10% of values in a list

Example Scenario:

• In a sales dataset, you want to highlight the top 10% of sales performers.
Steps:
• Select the data range.
• Go to Conditional Formatting → Top/Bottom Rules → Top 10%.
• Choose a color format (e.g., green fill).
• Click OK.

Benefit: Visually identify top-performing employees or products

9. What is a Nested IF function in Excel? Explain its syntax and provide an example of
how it can be used to evaluate multiple conditions.

• Nested IF: An IF function inside another IF function to evaluate multiple


conditions.
• Syntax: =IF(condition1, value_if_true, IF(condition2,
value_if_true, value_if_false))
• Example:

NOTE : Only pointers / hints are given below each question. Students are expected to elaborate
the answers and give examples or code wherever necessary to get maximum marks.
• If a student’s score is 90 or above, assign "A"; if between 70-89, assign
"B"; otherwise, assign "C".
• =IF(A1>=90, "A", IF(A1>=70, "B", "C"))

10. Explain the difference between the IF function and the IFS function in Excel. In
which scenarios is the IFS function preferred over Nested IF?

• IF Function: Used to test a single condition and return one value if TRUE,
another if FALSE.
• IFS Function: Allows testing multiple conditions without needing to nest
IF statements.
• IFS is Preferred:

• When there are multiple conditions to check.


• Simplifies syntax, making it easier to read and maintain.

• Example: =IFS(A1>=90, "A", A1>=70, "B", A1>=50, "C").

11. What is the purpose of the COUNTIF function in Excel? Explain how it can be used
to count cells that meet specific criteria, with an example.

• COUNTIF: Counts the number of cells that meet a specified condition.


• Example: Count how many times "Completed" appears in a range.

• =COUNTIF(B1:B10, "Completed").

12. Differentiate between COUNTIF and COUNTIFS functions in Excel. Provide an


example where COUNTIFS would be more appropriate to use than COUNTIF.

• COUNTIF: Counts cells based on a single condition.


• COUNTIFS: Counts cells based on multiple conditions.
• Example:

• COUNTIFS is useful when you want to count sales greater than $1000
made by a specific salesperson:
• =COUNTIFS(Sales, ">1000", Salesperson, "John").

13. What are Filters in Excel? How can filters be used to organize and analyze large
datasets? Provide an example.

• Filters: Tools that allow you to view only the data that meets specific
criteria while hiding the rest.
• Usage: Organizes data by showing relevant records, simplifying analysis.
NOTE : Only pointers / hints are given below each question. Students are expected to elaborate
the answers and give examples or code wherever necessary to get maximum marks.
• Example:

• Filter a sales report to display only records where sales are greater than
$5000.
• Steps: Select data → Data tab → Filter → Choose filter criteria.

14. How do you create a Pivot Table in Excel, and what are some of the common
operations (such as filtering, sorting, and grouping) that can be performed on Pivot
Table data?

• Steps to Create a Pivot Table:

• Select data → Insert tab → Pivot Table.


• Choose the data range and location for the table.
• Drag fields into Rows, Columns, and Values areas.

• Common Operations:

• Filtering: Focus on specific data subsets.


• Sorting: Arrange data in ascending or descending order.
• Grouping: Group data by categories (e.g., by months or product types)

15. How can you use Excel's Solver to solve a system of simultaneous equations? Walk
through the steps required to set up and solve the equations.

• Solver: A tool for solving optimization problems, including systems of


simultaneous equations.
• Steps:

1. Enter the equations into cells in Excel.


2. Define the objective function (e.g., minimize or maximize).
3. Set the variables that Solver should adjust.
4. Specify constraints for the variables.
5. Run Solver to find the solution.

16. Explain how the Solver tool in Excel can be used to solve Linear Programming
Problems (LPP). Provide an example.

• Linear Programming: Optimization of an objective function subject to


constraints.
• Example: Maximize profit where profit = 5x + 3y, subject to constraints (e.g., x +
y ≤ 10, x ≥ 0, y ≥ 0).
• Steps:
NOTE : Only pointers / hints are given below each question. Students are expected to elaborate
the answers and give examples or code wherever necessary to get maximum marks.
1. Enter objective function and constraints.
2. Define decision variables.
3. Use Solver to maximize or minimize the objective function.

17. Explain how the LEFT, MID, and RIGHT functions are used in Excel to extract parts
of a text string. Provide examples of each function.

• LEFT: Extracts characters from the start of a string.

• Example: =LEFT("Apple", 3) returns "App".

• MID: Extracts characters from the middle of a string.

• Example: =MID("Apple", 2, 3) returns "ppl".

• RIGHT: Extracts characters from the end of a string.

• Example: =RIGHT("Apple", 2) returns "le"

18. In what scenarios would you use the MID function over the LEFT or RIGHT
function? Provide an example where the MID function is essential.
a. • Scenario: When you need to extract characters from the middle of a string,
particularly when both the start and end are irrelevant.
b. • Example: Extracting a date from a string such as "Order1234567" (extract
"1234" starting from the 6th character using MID).
19. What is the INDEX MATCH combination in Excel, and how does it work?

• INDEX MATCH: A combination of two functions that retrieves values from a


table based on a lookup.
• How It Works:

• MATCH: Finds the position of a value in a row or column.


• INDEX: Retrieves the value from the corresponding position found by
MATCH.

• Example: Look up the price of a product based on its name.

20. Explain how the VLOOKUP function works. What are its limitations, and how can
these limitations be overcome using other functions?

• VLOOKUP: Searches for a value vertically in a table and returns a corresponding


value from a specified column.
• Syntax: =VLOOKUP(lookup_value, table_array, col_index_num,
range_lookup).
• Limitations:
NOTE : Only pointers / hints are given below each question. Students are expected to elaborate
the answers and give examples or code wherever necessary to get maximum marks.
• Can only search from left to right.
• Slower with large datasets.
• Overcome with INDEX MATCH, which allows flexible searches and better
performance.

21. What is the difference between VLOOKUP and HLOOKUP in Excel? Provide
examples of when each function is applicable.

• VLOOKUP: Looks for a value in the first column and retrieves corresponding
values from the same row.
• HLOOKUP: Looks for a value in the first row and retrieves corresponding values
from the same column.
• Example:

• Use VLOOKUP for a vertical table (e.g., finding prices by product name).
• Use HLOOKUP for a horizontal table (e.g., finding values across different
years).

22. Explain the purpose of the AND and OR functions in Excel. How can they be used to
evaluate multiple conditions in a formula?

• AND: Returns TRUE if all conditions are met.


• OR: Returns TRUE if at least one condition is met.
• Usage: Combine with IF to create complex logic.

• Example: =IF(AND(A1>10, B1<20), "Valid", "Invalid").

23. Provide an example where you would use the AND function to return TRUE if
multiple conditions are met.

You want to check if a student passes based on two conditions: the student must score
above 50 in both Math and Science to pass.

Formula:

=AND(A2>50, B2>50)

• A2: Cell containing the Math score.


• B2: Cell containing the Science score.

Explanation:

NOTE : Only pointers / hints are given below each question. Students are expected to elaborate
the answers and give examples or code wherever necessary to get maximum marks.
• This formula returns TRUE if both conditions (Math > 50 and Science > 50) are
met, indicating the student passed both subjects.
• If one or both conditions are false, it returns FALSE.

24. How can AND and OR functions be combined with IF statements in Excel to create
more complex logical tests? Provide an example.

• IF(AND(condition1, condition2), value_if_true, IF(OR(condition3,


condition4), value_if_true, value_if_false)).
• Example:

• Check if a student passes either subject A or B, and if the total score is greater
than 150:
• Formula: =IF(AND(A1+B1>150, OR(A1>40, B1>40)), "Pass", "Fail")

UNIT III

1. Define machine learning. How does it differ from traditional programming? Provide
examples of real-world applications of machine learning.

• Definition: Machine learning (ML) is a subset of artificial intelligence (AI) that


enables computers to learn from data and make predictions or decisions without
explicit programming.
• Difference from Traditional Programming:

• Traditional Programming: Involves explicitly writing rules for tasks (input +


rules = output).
• Machine Learning: Learns rules from data (input + output = learns rules).

• Examples:

• Recommendation Systems: Netflix recommends shows based on users' watch


history.
• Image Recognition: Identifying objects in photos (e.g., Google Photos).
• Fraud Detection: Detects fraudulent credit card transactions

2. What is supervised learning in machine learning? Provide examples of supervised


learning tasks and the types of algorithms used.

• Definition: Supervised learning is a type of machine learning where the model is


trained on labeled data, meaning the input data has corresponding output labels.
• Examples:

NOTE : Only pointers / hints are given below each question. Students are expected to elaborate
the answers and give examples or code wherever necessary to get maximum marks.
• Classification: Predicting categories (e.g., spam detection in emails).
• Regression: Predicting continuous values (e.g., predicting house prices).

• Algorithms:

• Linear Regression: Used for regression tasks.


• Decision Trees: Used for both classification and regression.
• Support Vector Machines (SVM): Used for classification

3. Explain the difference between classification and regression tasks in supervised


learning. Provide an example of each.

1. Classification:

• Definition: Predicts categorical labels or classes.


• Output: Discrete values (e.g., "Spam" or "Not Spam").
• Algorithms: Logistic regression, decision trees, SVM, KNN.
• Example: Email spam detection (predicts if an email is spam or not).

2. Regression:

• Definition: Predicts continuous numerical values.


• Output: Continuous values (e.g., house price predictions).
• Algorithms: Linear regression, SVR, ridge regression.
• Example: Predicting house prices based on features like size and location.

Key Differences:

• Output Type: Classification outputs categories, regression outputs continuous


values.
• Goal: Classification assigns labels, regression predicts a numerical outcome.

4. What are the advantages and limitations of supervised learning algorithms?

• Advantages:

• High accuracy with labeled data.


• Clear separation of training and prediction phases.
• Easy to interpret models like decision trees or linear regression.

• Limitations:

• Requires large amounts of labeled data.


• Overfitting: The model may perform well on training data but poorly on
unseen data.

NOTE : Only pointers / hints are given below each question. Students are expected to elaborate
the answers and give examples or code wherever necessary to get maximum marks.
• Expensive and time-consuming to label data.

5. What is classification in machine learning? Explain the concept using a real-world


example where classification is applicable.
a. • Definition: Classification is the task of predicting a discrete label or
category for an input.
b. • Example: Email spam detection where emails are classified into "spam" or
"not spam" categories based on features like the presence of certain keywords
or sender information.
6. Describe the different types of classification algorithms used in supervised learning.

Types of Classification Algorithms:

1. Logistic Regression: Predicts binary outcomes (e.g., yes/no, spam/not spam).


2. Decision Trees: Splits data based on features to make predictions.
3. Support Vector Machines (SVM): Finds the optimal boundary between
different classes.
4. k-Nearest Neighbors (KNN): Classifies based on the majority vote of nearest
neighbors.
5. Naive Bayes: Based on Bayes' theorem, assumes independence among
features.

7. What is the K-Nearest Neighbour (KNN) algorithm? Explain how the algorithm
works with the help of an example.

• K-Nearest Neighbour (KNN):

• A non-parametric, instance-based algorithm used for both classification


and regression tasks.

• How It Works:

• For a given test point, KNN identifies the "k" closest points (neighbors)
from the training data.
• In classification, it assigns the most common class among these neighbors.

• Example:

• Classifying a new animal as a "cat" or "dog" based on the characteristics of


its nearest neighbors (e.g., fur type, size)

8. Discuss how the value of K (in KNN) influences the model’s performance. What
happens if K is too small or too large?
NOTE : Only pointers / hints are given below each question. Students are expected to elaborate
the answers and give examples or code wherever necessary to get maximum marks.
• Influence of K:

• Small K (e.g., K=1): The model may be sensitive to noise and overfit, leading
to poor generalization.
• Large K (e.g., K=20): The model may generalize too much, leading to
underfitting and losing the fine details in the data.

• Choosing K: Typically, K is chosen based on trial and error or using cross-


validation.

9. Explain the concept of linear regression. What is the role of the slope and intercept in
the linear regression equation?

• Linear Regression:

• A regression algorithm that models the relationship between a dependent


variable (Y) and one or more independent variables (X).

• Equation: Y=b0+b1X
Slope (b1): The rate of change of Y with respect to X. It shows how much Y changes
for a one-unit change in X.

• Intercept (b0): The value of Y when X is 0. It is the point where the line
crosses the Y-axis

10. What is K-Means clustering? Describe the algorithm and explain how it works to
group data points into clusters.

• K-Means Clustering:

• An unsupervised learning algorithm used to group data points into K distinct


clusters.

• How It Works:

1. Select K initial cluster centroids.


2. Assign each data point to the nearest centroid (forming clusters).
3. Recalculate the centroids based on the mean of points in each cluster.
4. Repeat the process until the centroids stop changing.

• Application: Customer segmentation, where similar customers are grouped


based on purchasing behavior.

UNIT IV

1. What is Python, and why is it widely used in programming?

NOTE : Only pointers / hints are given below each question. Students are expected to elaborate
the answers and give examples or code wherever necessary to get maximum marks.
• Python:

• A high-level, interpreted programming language known for its simplicity and


readability.

• Why Widely Used:

• Easy to learn and use, with simple syntax.


• Extensive libraries for various domains (e.g., NumPy for math, Pandas for data
manipulation, TensorFlow for machine learning).
• Popular in fields like data science, web development, and automation.

2. Explain the advantages of Python over other programming languages like Java or
C++. Why is Python popular in data science and machine learning?

• Advantages Over Java/C++:

• Simpler Syntax: Easier to write and read code.


• Fewer Lines of Code: More concise for performing the same task.
• Dynamic Typing: No need to declare variable types.

• Popularity in Data Science:

• Large ecosystem of libraries (e.g., Pandas, NumPy, Scikit-learn).


• Integration with machine learning frameworks (e.g., TensorFlow, PyTorch).
• Great for rapid prototyping and experimentation.

3. Explain the different data types available in Python. Provide examples for each type
(e.g., integer, float, string, boolean).

Data Types in Python:

1. Integer (int): Whole numbers, e.g., x = 10.


2. Float: Numbers with decimals, e.g., x = 10.5.
3. String (str): Sequence of characters, e.g., x = "Hello".
4. Boolean (bool): Logical values, True or False, e.g., x = True.

4. Explain the importance of conditional statements in programming. How do if, elif,


and else statements work in Python?

• Importance of Conditional Statements:

• Allows decision-making in code based on conditions.


NOTE : Only pointers / hints are given below each question. Students are expected to elaborate
the answers and give examples or code wherever necessary to get maximum marks.
• Executes specific code blocks when certain conditions are true or false.

• if: Tests a condition, runs code if the condition is true.


• elif: Tests another condition if the previous if was false.
• else: Executes code if none of the conditions are true

Code:

if x > 10:

print("Greater than 10")

elif x == 10:

print("Equal to 10")

else:

print("Less than 10")

5. Write a Python code snippet that uses nested conditional statements to classify an
integer as positive, negative, or zero.

x = int(input("Enter a number: "))

if x > 0:

print("Positive")

elif x < 0:

print("Negative")

else:

print("Zero")

6. What is R programming? Discuss its primary applications in data analysis and


statistics.

• R Programming:

• R is a programming language and software environment specifically designed


for statistical computing and graphics.

• Primary Applications:

• Data Analysis: Used for exploring, visualizing, and analyzing large datasets.
• Statistics: Used in hypothesis testing, linear models, and regression analysis.

NOTE : Only pointers / hints are given below each question. Students are expected to elaborate
the answers and give examples or code wherever necessary to get maximum marks.
• Data Visualization: Extensive libraries like ggplot2 make it easy to create
informative and aesthetically pleasing graphs and charts.
• Machine Learning: R is widely used in predictive modeling and machine
learning algorithms (e.g., randomForest, caret).

7. Write a Python code to find area of a circle

# Program to calculate the area of a circle


import math

radius = float(input("Enter the radius of the circle: "))


area = math.pi * radius ** 2

print(f"The area of the circle is: {area}")

8. Write a Python code to perform basic mathematical operations like add, subtract,
multiply, divide

num1 = float(input("Enter first number: "))


num2 = float(input("Enter second number: "))

print(f"Sum: {num1 + num2}")


print(f"Difference: {num1 - num2}")
print(f"Product: {num1 * num2}")
print(f"Quotient: {num1 / num2}")

9. Write a Python code to check whether number is even or odd

num = int(input("Enter a number: "))

if num % 2 == 0:
print(f"{num} is an even number.")
else:
print(f"{num} is an odd number.")

10. Write a Python code to find largest of three numbers

num1 = float(input("Enter first number: "))


num2 = float(input("Enter second number: "))
num3 = float(input("Enter third number: "))

if num1 >= num2 and num1 >= num3:


print(f"The largest number is: {num1}")
elif num2 >= num1 and num2 >= num3:
print(f"The largest number is: {num2}")
else:
print(f"The largest number is: {num3}")

11. Write a Python code to find simple interest using formula I=PRT/100

P = float(input("Enter the principal amount: "))


R = float(input("Enter the rate of interest: "))
T = float(input("Enter the time in years: "))

SI = (P * R * T) / 100

NOTE : Only pointers / hints are given below each question. Students are expected to elaborate
the answers and give examples or code wherever necessary to get maximum marks.
print(f"The Simple Interest is: {SI}")

12. Write a Python code to display table of a number

num = int(input("Enter a number: "))


for i in range(1, 11):
print(f"{num} x {i} = {num*i}")

13. Write a R code to find area of a circle

radius <- as.numeric(readline(prompt = "Enter the radius of the circle: "))


area <- pi * radius^2
cat("The area of the circle is:", area, "\n")

14. Write a R code to perform basic mathematical operations like add, subtract, multiply,
divide

num1 <- 10
num2 <- 5
sum <- num1 + num2
difference <- num1 - num2
product <- num1 * num2
quotient <- num1 / num2

cat("Sum:", sum)
cat("Difference:", difference)
cat("Product:", product)

cat("Quotient:", quotient)

15. Write a R code to check whether number is even or odd

# Program to check if a number is even or odd


num <- as.integer(readline(prompt="Enter a number "))
if (num %% 2 == 0) {
cat("Even")
} else {
cat("Odd")
}

16. Write a R code to find largest and smallest of numbers from a list

# Program to find the largest and smallest number in a list


numbers <- c(23, 12, 45, 67, 34)
largest <- max(numbers)
cat("Largest number:", largest)
smallest <- min(numbers)
cat("Smallest number:", smallest)

17. Write a R code to count numbers in a list

# Program to count numbers in a list


numbers <- c(23, 12, 45, 67, 34)
count <- length(numbers)

NOTE : Only pointers / hints are given below each question. Students are expected to elaborate
the answers and give examples or code wherever necessary to get maximum marks.
cat("Count of numbers:", count)

18. Write a R code to find mean and median of numbers from a list

# Program to calculate mean, median


numbers <- c(5, 10, 15, 10, 20)

mean_value <- mean(numbers)


median_value <- median(numbers)

cat("Mean:", mean_value)
cat("Median:", median_value)

19. Write a R code to find standard deviation of numbers from a list

# Program to calculate standard deviation


data <- c(10, 20, 30, 40, 50)
sd_value <- sd(data)
cat("Standard Deviation:", sd_value)

20. Write a R code to find correlation between two variables

# Program to calculate correlation between two variables


x <- c(10, 20, 30, 40, 50)
y <- c(15, 25, 35, 45, 55)
correlation <- cor(x, y)
cat("Correlation:", correlation)

21. Write a R program to perform linear regression analysis

# Program for linear regression analysis


x <- c(1, 2, 3, 4, 5)
y <- c(2, 4, 6, 8, 10)

model <- lm(y ~ x)


print(summary(model)

NOTE : Only pointers / hints are given below each question. Students are expected to elaborate
the answers and give examples or code wherever necessary to get maximum marks.

You might also like