Mooc - Nptel - Aakash Sagar

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

A Report on

The Joy of Computing using Python

Submitted in partial fulfilment of the requirement Seminar for the 2nd Semester
MCA

BY- Under the guidance of


Aakash Sagar Dr. JK Chaudhary
Roll No - 2251001 (Assistant Professor)

SCHOOL OF COMPUTING
GRAPHIC ERA HILL UNIVERSITY BHIMTAL
CAMPUS SATTAL ROAD, P.O. BHOWALI
DISTRICT- NAINITAL-263136
2022 – 2023

1
STUDENT’S DECLARATION

I, Aakash Sagar hereby declare the work, which is being presented


in the mooc training report entitled “The Joy of Computing using
Python” in partial fulfilment of the requirement for the award of the
degree MCA in the session 2022-2023, is an authentic record of my
own work carried out under the supervision of “Dr. JK
Chaudhary”, Assistant Professor, School of Computing, Graphic
Era Hill University, Bhimtal. The matter embodied in this report has
not been submitted by us for the award of any other degree.

Date - Aakash Sagar

2
CERTIFICATE

THIS IS TO CERTIFY THAT Mr. AAKASH SAGAR HAS


SATISFACTORILY PRESENTED MOOC BASED SEMINAR.
THE COURSE OF THE MOOC “THE JOY OF COMPUTING
USING PYTHON” IN PARTIAL FULFILMENT OF THE
SEMINAR PRESENTATION REQUIREMENT IN 2 nd
SEMESTER M.C.A. DEGREE COURSE PRESCRIBED BY
GRAPHIC ERA HILL UNIVERSITY, BHIMTAL CAMPUS
DURING THE YEAR 2022-2023.

Dr. JK Chaudhary Dr. Sandeep Budhani


Signature Signature

3
ACKNOWLEDGEMENT

I would like to express my profound gratitude to Dr. Sandeep


Kumar Budhani (HOD) of School of Computing, for giving me a
chance to complete a certification course titled “The Joy of
Computing using Python” other than academic studies.

I would like to express my special thanks to our mentor Dr. JK


Chaudhary for their time and efforts he provided throughout the
semester. Your useful advice and suggestions were really helpful to
me during the project’s completion. In this aspect, I am eternally
grateful to you.

I would like to acknowledge that this project was completed entirely


by me and not by someone else.

Aakash Sagar

4
Copy of confirmation/ Certification of Course Completion

5
Modules Attended

Weeks Page No.


S.No.
1. Week 1 7
2. Week 2 9
3. Week 3 11
4. Week 4 15
5. Week 5 20
6. Week 6 23
7. Week 7 25
8. Week 8 28
9. Week 9 33
10. Week 10 35
11. Week 11 37
12. Week 12 40

6
Week 1

Introduction to Programming

 Why Programming

Programming is a powerful tool that enables us to create, automate, and


solve a wide range of problems using computer code. It allows us to
communicate with computers, instructing them to perform specific tasks
and processes. Programming empowers us to build applications, websites,
games, and software solutions that impact various aspects of our lives. It
provides us with the ability to automate repetitive tasks, analyze data,
make informed decisions, and design innovative solutions.

 Introduction to Scratch

7
Scratch is a beginner-friendly programming language and online
platform developed by the Lifelong Kindergarten Group at the MIT
Media Lab. It is designed to introduce programming concepts and
computational thinking to people of all ages, especially children and
beginners.
With Scratch, users can create interactive stories, animations, games, and
more by simply dragging and dropping colorful blocks of code. It uses a
visual programming approach, where users can snap together blocks that
represent different programming commands and actions. This block-based
interface makes it easy for beginners to understand and experiment with
programming concepts without the need for complex syntax or typing.

 Scratch Animations

8
Week 2

 Introduction to Anaconda

Anaconda is a popular open-source distribution platform for


Python and R programming languages. It provides a
comprehensive and user-friendly environment for data
science, machine learning, and scientific computing.
Anaconda simplifies package management by offering a
vast collection of pre-built libraries and tools, making it easier
to set up and manage the dependencies required for data
analysis projects.

 Introduction to Spyder IDE

Spyder is an integrated development environment (IDE) specifically


designed for scientific computing and data analysis using Python. It
provides a powerful and interactive environment for writing, debugging,

9
and running Python code. Spyder offers a range of features tailored to the
needs of data scientists and researchers, making it a popular choice among
professionals in these fields.
One of the key advantages of Spyder is its user-friendly interface, which
includes a code editor, variable explorer, and interactive console. This
allows users to write and execute Python code in a single environment,
making it convenient to explore and analyze data. Spyder also provides
features like code autocompletion, syntax highlighting, and code
navigation, which enhance productivity and efficiency.

• Understanding Python

The Python basics module in our MOOC covers the fundamental concepts
of programming using Python. It begins by introducing the basic syntax
and structure of Python code, including variables, data types, operators,
and control flow statements.

10
Week 3

 Operations, Manipulation & Slicing

Operations refer to the actions or computations performed on data. In


programming, various operations can be applied to manipulate and
transform data. For example, arithmetic operations such as addition
(+), subtraction (-), multiplication (*), and division (/) are used to
perform calculations on numerical data.

Manipulation involves modifying or transforming data according to


specific requirements. This can include tasks like changing the case
of characters, extracting substrings, concatenating strings, or
modifying elements in a list.

Slicing is a technique used to extract a portion or a subset of a string,


list, or other sequence-like data structure. It allows you to specify a
range of indices to extract a contiguous section of the data.

 Fizzbuzz
FizzBuzz is a classic programming problem that helps developers
practice fundamental programming concepts, such as conditionals,
loops, and basic arithmetic operations. It involves iterating through a
sequence of numbers and applying certain rules to determine what to
output for each number.

Problem Statement:

11
Write a program that prints the numbers from 1 to n, but for multiples of 3,
it prints "Fizz" instead of the number, and for multiples of 5, it prints
"Buzz" instead. For numbers that are multiples of both 3 and 5, print
"FizzBuzz".
def fizzbuzz(n):
for i in range(1, n+1):
if i % 3 == 0 and i % 5 == 0:
print("FizzBuzz")
elif i % 3 == 0:
print("Fizz")
elif i % 5 == 0:
print("Buzz")
else:
print(i)

# Example usage
fizzbuzz(15)

 Crowd Computing

Crowd computing is the practice of using a crowd of individuals,


often through online platforms, to solve complex tasks or generate
valuable information. It involves breaking down tasks into smaller
units, called microtasks, which are performed by individuals in the
crowd. Crowd computing benefits from the scalability, flexibility,
and human intelligence of the crowd. However, ensuring quality
control, addressing privacy and security concerns, and motivating
contributors can be challenges. Overall, crowd computing harnesses
collective intelligence to accomplish tasks that traditional computing
systems cannot handle alone.

12
 Jumbled Words

Problem: You are given a string of characters that represents a jumbled


or scrambled word. Your task is to create a program that can unscramble
the word and determine all possible valid words that can be formed from
the given jumbled letters.

Input: A string of characters representing a jumbled word.


Output: A list of valid words that can be formed from the jumbled letters.
Example: Input: "tegndil"
Output: ["tingled", "glinted"]

13
• Theory of Evolution

The theory of evolution is a scientific explanation for the diversity of life


on Earth. It proposes that all living organisms have descended from a
common ancestor and have gradually changed over time through a process
called natural selection.

14
Week 4

• Magic Square
The Magic Square game is a puzzle where the objective is to arrange a set
of numbers in a square grid such that the sum of each row, column, and
diagonal is the same. It tests your ability to think logically and
strategically.
To play the game, you are presented with an empty square grid. Your task
is to fill in the grid with numbers, usually from 1 to n^2, where n
represents the size of the grid. The numbers should be placed in such a
way that the sum of each row, column, and diagonal is equal to a constant
value, which is often referred to as the "magic sum."

15
 Dobble Game
Dobble is a popular card game that tests your observation and speed skills.
It is a fast-paced game that can be enjoyed by people of all ages. The
objective of the game is to spot the matching symbols between two cards
as quickly as possible. Here's how the Dobble game works:
Components:
• The game consists of a set of cards. Each card has several symbols
printed on it.
• There are multiple symbols on each card, and any two cards in the
deck have exactly one symbol in common.

16
 Birthday Paradox

The birthday paradox is a fascinating mathematical phenomenon that


highlights the surprising probability of shared birthdays in a group of
people. Contrary to what one might expect, it shows that the probability of
two or more people sharing the same birthday increases significantly with
a relatively small number of individuals.

The paradox can be explained as follows: Suppose there are N people in a


room, and we want to calculate the probability that at least two of them
have the same birthday. To simplify the problem, let's assume that all
birthdays are equally likely and that there are 365 possible birthdays
(ignoring leap years).
At first glance, one might assume that with 365 possible birthdays, it
would take at least 365 people for there to be a 100% chance of shared
birthdays. However, the birthday paradox reveals that the number of
people required is much smaller.

17
• Guess the movie name

18
In the "Guess the Movie Name" game, players are presented with clues or
hints related to a particular movie, and they have to guess the name of the
movie based on those clues. It's a fun and engaging game that tests your
knowledge of movies across different genres and eras.

19
Week 5

• Monte Hall Problem


The Monte Hall Problem is a famous probability puzzle named after the
television game show host, Monte Hall. The problem gained widespread
attention when it was featured in the "Ask Marilyn" column of Parade
magazine in 1990.
The problem is as follows:
You are a contestant on a game show, and there are three doors in front of
you. Behind one door is a valuable prize, such as a car, and behind the
other two doors are less desirable prizes, such as goats. The host, Monte
Hall, knows what's behind each door.
Here's the sequence of events:

1. You initially choose one of the three doors, let's say Door #1.

2. Before revealing what's behind your chosen door, Monte Hall, who
knows what's behind each door, opens one of the remaining two
doors to reveal a goat. Let's say he opens Door #3.

3. Now, you are faced with a choice: stick with your original choice
(Door #1) or switch to the other unopened door (Door #2).
4.

• Rock Paper Scissors

Rock Paper Scissors is a classic hand game where two players make a
hand gesture representing either rock, paper, or scissors. The game follows
a set of rules, where rock beats scissors, scissors beat paper, and paper
beats rock. The players simultaneously reveal their chosen gesture, and the
winner is determined based on the outcome of their gestures according to
the rules.

20
• Binary Search

Binary search is a searching algorithm commonly used to find a specific


element in a sorted list or array. It works by repeatedly dividing the search
space in half and comparing the target element with the middle element.
Here's how binary search works:
1. Start with a sorted list or array.
2. Set the left pointer to the first element and the right pointer to the last
element of the list.
3. Calculate the middle element by taking the average of the left and
right pointers.
4. Compare the target element with the middle element:
• If they are equal, the element is found.
• If the target element is less than the middle element, move the
right pointer to the middle - 1 position and repeat from step 3.
• If the target element is greater than the middle element, move
the left pointer to the middle + 1 position and repeat from
step 3.

21
5. Continue dividing the search space in half and updating the pointers
until the target element is found or the search space is empty.
Binary search is an efficient algorithm with a time complexity of O(log n),
where n is the number of elements in the sorted list. It is widely used in
various applications, including searching in databases, finding elements in
sorted arrays, and more.

22
Week 6

 Substitution Cipher

A substitution cipher is a method of encryption where each letter in the


plaintext (original message) is replaced with another letter or symbol
according to a fixed rule or key. This type of cipher is a form of symmetric
encryption, meaning the same key is used for both encryption and
decryption.
In a simple substitution cipher, each letter of the alphabet is mapped to a
different letter or symbol. For example, the letter 'A' might be replaced
with 'D', 'B' with 'R', 'C' with 'G', and so on. The specific mapping of letters
is determined by the chosen key.

23
 Tic-Tac-Toe
Tic-tac-toe, also known as noughts and crosses or Xs and Os, is a classic
paper-and-pencil game played on a 3x3 grid. The objective of the game is
to be the first player to get three of their marks (either X or O) in a
horizontal, vertical, or diagonal row.
The game starts with an empty grid. Players take
turns, with one player using X and the other using
O. They alternate placing their marks in empty
cells of the grid. The first player typically starts
by placing an X in any cell of their choice.
The game continues until one of the players has
three of their marks in a row, or all cells on the grid are filled without a
winner, resulting in a tie. A winning combination can be a horizontal,
vertical, or diagonal line of three Xs or three Os.

• Recursion

Recursion is a programming technique where a function calls itself


repeatedly to solve a problem by breaking it down into smaller, more
manageable sub-problems. It is based on the idea of solving a complex
problem by solving simpler versions of the same problem.
In a recursive function, the function invokes itself with a different set of
input parameters each time, progressing towards a base case where the
function does not make any further recursive calls. The base case defines
the simplest form of the problem that can be solved directly without
recursion.

24
Week 7

• Snakes and Ladders - Not on the Board

"Snakes and Ladders - Not on the Board" is a modification of the


traditional Snakes and Ladders game where players engage in a virtual
version of the game without using an actual physical board. Instead, the
game is implemented through software or digital means.

• Spiral Traversing

Spiral traversing, also known as spiral matrix traversal, is a technique used


to visit each element in a two-dimensional matrix in a spiral pattern. The
matrix can be represented as a grid of rows and columns, and the spiral
traversal involves moving in a clockwise or counterclockwise spiral
pattern starting from the outermost layer towards the center.

25
The spiral traversing algorithm follows the following steps:
1. Define the boundaries: Set the initial boundaries of the matrix. These
boundaries represent the outermost layer of the matrix and will
shrink as the traversal progresses.
2. Traverse the top row: Starting from the leftmost column of the top
row, visit each element in the top row from left to right.
3. Traverse the right column: Move down to the next row and visit each
element in the rightmost column from top to bottom.
4. Traverse the bottom row: Move from the rightmost column to the
leftmost column of the next row and visit each element in the bottom
row from right to left.
5. Traverse the left column: Move up to the previous row and visit each
element in the leftmost column from bottom to top.
6. Update the boundaries: Shrink the boundaries inward by
incrementing the starting row and column, and decrementing the
ending row and column.
7. Repeat: Repeat steps 2 to 6 until all elements in the matrix have been
visited.

26
 GPS-Track the route

you must be aware of gps the global positioning system it is


something it will let you share your location on whatsapp or track
your route using goggle maps. Gps is actually a network of
satellites that help tracking the geographical locations of an
individual, keeping the technical stuff aside let me give you a nice
motivation about this joy. Assuming this story some time back one
of my friends owning a pizza delivery companycalls me, he has
complaints of late deliveries from is customers and he installs a gps
tracker on the delivery bikes hoping that this would solve his
problems but instead of giving the location name gps tracker gives
raw information in the form of latitude and longitude information
in order to help my friend I need to write a code that helps him track the
route of his delivery boys we can do it using python.

27
Week 8

 Lottery Simulation-Profit or Loss

In a lottery simulation program, the objective is to simulate the process of


participating in a lottery and determine whether the player incurs a profit
or a loss based on the outcome.
Set up the simulation parameters: Define the rules and parameters of the
lottery, such as the cost of a lottery ticket, the total number of tickets
available, the jackpot amount, and any additional prizes or probabilities.
1. Prompt user input: Ask the user if they would like to participate in the lottery and
how many tickets they would like to purchase.
2. Calculate the cost: Multiply the number of tickets by the cost per ticket to determine
the total cost incurred by the player.
3. Randomly determine the outcome: Simulate the lottery drawing by randomly
selecting winning numbers or tickets based on the predefined probabilities. This can
be done using random number generation or any other suitable method.
4. Evaluate the outcome: Compare the winning numbers or tickets with the player's
tickets to determine if they have won any prizes.
5. Calculate the winnings: Based on the outcome, calculate the total winnings earned
by the player, considering the jackpot amount and any additional prizes won.
6. Determine profit or loss: Subtract the total cost of tickets from the total winnings. If
the result is positive, it indicates a profit. If the result is negative, it indicates a loss.
7. Display the result: Show the player's total cost, total winnings, and whether they
made a profit or incurred a loss.
8. Repeat or exit: Ask the user if they want to participate again and loop back to the
beginning if they do, or exit the program if they don't.

28
• Image Processing-Enhance your images

Image enhancement is a fundamental task in the field of image processing,


allowing you to improve the visual quality and details of an image. Python
provides several powerful libraries, such as OpenCV and PIL (Python
Imaging Library), that can be used to enhance images. Here's an overview
of how you can enhance your images using Python:
1. Import the necessary libraries: Start by importing the required
libraries for image processing. For example, you can import the cv2
module from OpenCV or the Image class from PIL.
2. Load the image: Use the library functions to load the image into your
Python program. This can be done by providing the path to the image
file or by capturing an image from a camera.
3. Preprocess the image (optional): Depending on the specific
requirements, you may need to preprocess the image before applying
enhancement techniques. Preprocessing can involve resizing,
cropping, or converting the image to a specific color space.

29
4. Enhance the image: There are various techniques you can use to
enhance your images. Some commonly used techniques include:
• Adjusting brightness and contrast: Modify the brightness and
contrast of the image to improve its overall appearance. This
can be done by applying simple arithmetic operations on the
pixel values.
• Sharpening: Enhance the image's edges and details to make it
appear sharper. Techniques such as unsharp masking or high-
pass filtering can be employed to achieve this.
• Denoising: Remove noise from the image to improve its clarity.
Techniques like Gaussian blur or median filtering can be used
to reduce the effects of noise.
• Color correction: Adjust the color balance, saturation, or hue of
the image to improve its color representation. This can be
achieved through techniques such as histogram equalization or
color mapping.
5. Save or display the enhanced image: Once the desired enhancements
are applied, you can save the enhanced image to a file or display it on
the screen using library functions provided by OpenCV or PIL.
6. Experiment and fine-tune: Image enhancement is a subjective
process, and the optimal parameters may vary based on the specific
image and desired outcome. Experiment with different techniques
and parameters to achieve the desired results.

• Anagrams

An anagram is a word or phrase formed by rearranging the letters of


another word or phrase. It is a fun and interesting problem to solve using
programming. In the context of anagrams, the goal is to find all possible
combinations of letters that form valid words or phrases.
Here's a general approach to solving the anagram problem:
1. Input a word or phrase
2. Generate permutations
3. Check for valid words
4. Display or store anagrams

30
• Facebook Sentiment Analysis

Sentiment analysis is a technique used to determine the sentiment or


emotion expressed in a piece of text. In the context of Facebook, sentiment
analysis can be applied to analyze the sentiment of user comments, posts,
or messages. By analyzing the sentiment, we can gain insights into the
overall opinion, emotions, or attitudes of users towards specific topics or
content.

31
To store data from Facebook and save it in an Excel file, you can follow
these general steps:
1. Obtain the necessary permissions and access tokens from Facebook's
API to retrieve the desired data.
2. Use a suitable Python library, such as facebook-sdk or python-
facebook-api, to interact with the Facebook API and retrieve the data
you need.
3. Preprocess and organize the retrieved data into a structured format
that can be easily saved in an Excel file.
4. Use a Python library like pandas to create a DataFrame from the
structured data.
5. Export the DataFrame to an Excel file using the to_excel() method
provided by the pandas library.

32
Week 9

• Natural Language Processing-Author Stylometry


Author stylometry is a branch of Natural Language Processing (NLP) that
focuses on analyzing and identifying the writing style or characteristics of
different authors. It involves using computational techniques to extract
various features from texts and then applying statistical and machine
learning algorithms to classify or differentiate between authors based on
those features.

The process of author stylometry typically involves the following steps:

1. Data Collection: Gather a dataset of texts written by different authors that you
want to analyze.
2. Text Preprocessing: Clean and preprocess the texts by removing punctuation,
stopwords, and other irrelevant information. Normalize the text by converting
it to lowercase and handling any special characters.

33
3. Feature Extraction: Extract relevant features from the preprocessed texts.
Some common features used in author stylometry include word frequencies,
character n-grams, sentence lengths, syntactic features, and semantic features.
4. Feature Selection: Select the most informative and discriminative features to
reduce the dimensionality of the data and improve the accuracy of the
stylometric analysis. This step helps in removing irrelevant or redundant
features.
5. Model Training: Split the dataset into training and testing sets. Use the training
set to train a machine learning model, such as a classifier or clustering
algorithm, using the extracted and selected features.
6. Model Evaluation: Evaluate the performance of the trained model on the
testing set. Use appropriate evaluation metrics, such as accuracy, precision,
recall, and F1-score, to assess the model's effectiveness in distinguishing
between authors.
7. Prediction and Attribution: Apply the trained model to new or unseen texts to
predict the most likely author or attribute authorship to unknown texts based
on their writing style.

• Six Degrees of Separation


The concept of "Six Degrees of Separation" is a theory that
suggests that any two people in the world can be connected
through a chain of acquaintances with no more than six
intermediate connections. It implies that there is a relatively
small number of social connections that separate individuals
across the globe.

34
Week 10

• FLAMES
FLAMES is a popular game or algorithm used to determine the
relationship or compatibility between two people. It is often played by
individuals who are curious about their romantic prospects or
compatibility with someone else.
The acronym FLAMES stands for Friends, Lovers, Affectionate, Marriage,
Enemies, and Siblings. The game works by comparing the letters in the
names of the two individuals and eliminating common letters until only
one category remains. Each letter corresponds to one of the categories, and
the final category represents the relationship or connection between the
two people.

• Data Compression

Data compression is the process of reducing the size of data files to save storage
space or to transmit data more efficiently. In Python, there are various
techniques and libraries available for data compression. One popular library is

35
the gzip module, which provides functionality for compressing and
decompressing files using the gzip algorithm.
To compress data using gzip in Python, you can follow these steps:
1.Import the gzip module:
import gzip
2. Open the input file in binary mode and the output file in gzip mode:
with open('input_file.txt', 'rb') as file_in, gzip.open('compressed_file.gz',
'wb') as file_out:
3. Read the data from the input file and write it to the compressed file:
file_out.write(file_in.read())
4. The compressed file will be created with the extension ".gz" (e.g.,
compressed_file.gz).

36
Week 11

• Browser Automation Whatsapp using Python

1. Install Selenium library using pip install selenium.


2. Download the appropriate web driver for your chosen browser and
add it to the system's PATH.
3. Import Selenium and instantiate the WebDriver object for your
browser (e.g., Chrome).
4. Open WhatsApp Web using driver.get("https://web.whatsapp.com/").
5. Manually scan the QR code with your phone's WhatsApp app.
6. Use WebDriver methods to locate and interact with elements on the
WhatsApp Web page.
7. Perform desired actions such as sending messages or reading
messages.
8. Close the WebDriver using driver.quit() when finished.

37
• Fun with Calendar

calendar arithmetic involves performing mathematical operations on dates and


manipulating them based on various criteria. Here are some common operations
in calendar arithmetic:
1. Adding or subtracting days: You can add or subtract a certain number of
days from a given date. For example, if you want to find the date that is 5
days after a specific date, you simply add 5 to the day component of the
date.
2. Adding or subtracting months: Similarly, you can add or subtract a
certain number of months from a date. If you add or subtract more
months than there are in the current year, the year component may need
to be adjusted accordingly.
3. Adding or subtracting years: You can add or subtract a certain number of
years from a date. This operation is straightforward as it only involves
modifying the year component while keeping the month and day the
same.

38
4. Calculating the difference between two dates: You can find the number of
days, months, or years between two given dates. This can be useful for
determining durations or calculating age, for example.
5. Day of the week calculations: You can determine the day of the week for
a given date. This can be done using various algorithms, such as Zeller's
Congruence or Sakamoto's Algorithm, which provide a formula to
calculate the day of the week based on the year, month, and day
components of a date.

39
Week 12

• Page rank – How does Google Work ?

PageRank is an algorithm used by Google to determine the relevance and


importance of web pages. It is based on the concept of "drunkard's walk"
or random walk, which simulates the behavior of a person randomly
navigating through a network of interconnected pages.
The basic idea behind PageRank is that a page is considered more
important if it is linked to by other important pages. It assumes that a user,
randomly clicking on links, is more likely to end up on an important page
than on a less important one.

Crawlers, also known as web spiders, web robots, or web crawlers, are
automated programs that systematically browse the internet and collect
information from web pages. They play a crucial role in the operation of
search engines, as well as in various web scraping and data mining
applications.

40
The primary purpose of crawlers is to discover and index web content.
They start by visiting a set of seed URLs and then follow the hyperlinks
on those pages to find and retrieve additional pages. Crawlers use a
process called crawling or spidering to traverse the web, going from one
page to another in a methodical and automated manner.

 Collatz Conjecture

The Collatz Conjecture is a famous mathematical problem that involves a


sequence of numbers defined by a specific rule. The conjecture states that
for any positive integer value of n, the following sequence will always
reach the number 1:
1. Start with any positive integer n.
2. If n is even, divide it by 2 to get n/2.
3. If n is odd, multiply it by 3 and add 1 to get 3n + 1.
4. Repeat the process with the resulting value, and continue iterating
until reaching 1.
For example, let's start with n = 6:
6, 3, 10, 5, 16, 8, 4, 2, 1.

41
The sequence eventually reaches 1. The Collatz Conjecture suggests that
this pattern will always occur regardless of the starting value of n.

END OF COURSE.

42

You might also like