GOVERNMENT OF KARNATAKA
DEPARTMENT OF COLLEGIATE & TECHNICAL EDUCATION
BANGALORE- 560001
Laboratory Portfolio & Online Course Report
Thinking Programming with Python – 25CS21I
Submitted by
Name :- _________________________________________________________
Register Number :- ________________________________________________
Semester :- _______________________________________________________
DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING
GOVERNMENT POLYTECHNIC RAICHUR – 584103
2025-2026
DEPARTMENT OF COMPUTER SCIENCE & ENGINEERING
GOVERNMENT POLYTECHNIC
RAICHUR - 584103
This is to certify that, Kumar/Kumari.
bearing Reg. No. : of Computer Science and Engineering
Department has successfully completed the Laboratory Course in Thinking
Programming with Python (25CS21I) along with the prescribed Online Courses from
Infosys Spring Board as per C-25 Curriculum during the Academic Year 2025-2026.
ONLINE COURSE DETAILS
Sl.
Online Course Name Hours
No.
1 Basics of Python. 1 Hr 18 Min
Programming Fundamentals using Python - Science
2 66 Hr 10 Min
Graduates - Foundation Program.
Total hours 67 Hr 28 Min
TOTAL MARKS:
50
COURSE COORDINATOR HOD
INDEX
SL. Page
Experiment Name Signature
No. No.
Improving the Transport System in the Countryside.
1. Smart Irrigation System for Optimal Water Usage. 1
Impact of Social Media on Students.
2. Algorithms and Flowcharts. 7
3. Think Like a Programmer. 18
4. Download and Install necessary Compiler or Interpreter 19
Create variables, assign values, and display their data
5.
types.
Assignment Statements 25
Type Conversion
Write a program that:
6.
Accepts user input for name and age.
Prints a formatted message using different string
formatting methods.
31
Read message from the user and Format it with different
methods and display.
Demonstrate swapping the values(numerical) of two
variables using a temporary variable.
Write python equivalent expressions for math expressions
such as
f = ax +b
f = a2 + b2 + 2ab.
7.
f = a3 + b3 + 3ab(a + b)
area = πr2
37
Write a program that:
Accepts two numbers from the user.
Converts them to integers (if they are not already).
Performs arithmetic operations (add, subtract, multiply,
divide) and displays the results with the data types and
appropriate message.
Calculate the total cost of an item after applying a 15%
discount to its original price of Rs150.
Calculate the compound interest on a principal of
Rs10000 at an annual interest rate of 5% for 3 years,
compounded annually.
Compute area of triangle, rectangle.
Swapping values of two variables without using a
temporary variable.
Create a program to manage airline ticket bookings based
on the passenger's selected class: "economy", "business",
or "first".
Prompt the user to input details such as name, age,
destination, and class preference (economy, business, or
first).
Validate inputs (e.g., ensure the name contains only
letters, age is a positive integer, and class selection is
valid).
Display appropriate error messages for invalid entries and
allow the user to reenter the data.
Build a system to suggest clothing based on the
temperature.
If temperature ≥30°C, suggest "Wear light clothes."
8. If 20°C ≤ temperature < 30°C, suggest "Wear moderate 49
clothing."
If temperature < 20°C, suggest "Wear warm clothes."
Implement a discount system for an e-commerce website.
If the total purchase is ≥Rs5000, apply a 20% discount.
If Rs2000 ≤ total < Rs5000, apply a 10% discount.
If total < Rs2000, no discount is applied.
Create a program that simulates an ATM machine to
check:
If the entered PIN is correct, allow the user to proceed.
Validate that the withdrawal amount doesn’t exceed the
account balance.
Ensure that the withdrawal amount is in multiples of a
specific denomination (e.g., Rs100).
Generate numbers from 1 to 10 using range().
9 Generate numbers for a given range. 59
Write a program to display square numbers from 1 to 10.
Write a Python program that accepts an integer input from
the user and determines whether the number is a prime
number or not. If the number is prime, display an
appropriate message; otherwise, indicate that it is not
prime.
Write a Python program that accepts a message and a
number from the user. The program should then print the
specified message the given number of times.
Write a Python program to calculate the factorial of a
given number. The program should:
Accept a non-negative integer as input.
Use an iterative approach to compute the factorial.
Handle invalid inputs (e.g., negative numbers or non-
numeric inputs) by displaying appropriate error messages
Implement the Euclidean algorithm to find the GCD of
two integers using a while loop.
Collect daily weather data (e.g., temperature, humidity)
from the user. Allow data entry to continue until the user
decides to stop or inputs a sentinel value.
10. 67
Write a program that simulates a countdown timer. Start
with a given number of seconds and decrement until it
reaches zero, displaying the countdown at each step.
Write a program that takes an integer and calculates the
sum of its digits using a while loop.
Write a program to identify all prime numbers within a
user-defined range. The program should:
List all the prime numbers within the range.
Calculate and display the total count of prime numbers
found.
Compute and display the sum of these prime numbers
Write a Python program to perform the following tasks
11. for a user-defined range of integers: 75
Identify and list all non-prime numbers within the given
range.
Categorize the non-prime numbers into even and odd.
Count the total number of even and odd non-prime
numbers.
Calculate and display the sum of even and odd non-prime
numbers separately.
Write a Python program to perform the following tasks
for a user-defined range of integers:
Identify and list all palindrome numbers within the
specified range.
Count the total number of palindrome numbers found.
Display the results in a user-friendly format.
Write a program to generate and display a multiplication
table for numbers 1 to 10.
Write simple functions for arithmetic calculations (e.g.,
addition, factorial)
Define a function assign_priority() for ticketing system
which assigns priorities to support tickets based on the
issue type (low, medium, high and returns a priority level.
12. Define function calculate_interest() for banking system, 83
to calculate the interest on savings accounts based on the
principal amount, rate, and time period.
An online store offers a discount based on the total
purchase amount. If the customer’s total purchase
exceeds a certain threshold, they get a percentage
discount. Define a function apply_discount() that accepts
the total amount and returns the final price after discount.
Create a module that includes a function to calculate the
13. 91
area of a circle and use it in another script.
LABORATORY PORTFOLIO MARKS:
20
WEEK - 01
Page 1
Thinking Programming with Python 25CS21I
Case Based Learning:
1a. Improving the Transport System in the Countryside.
Case Description:
In many rural areas, transportation facilities are limited. Buses do not follow proper timings
and passengers face difficulty due to lack of schedule information and seat availability. Using
Python, we can create a simple system to display route information, bus timings, and available
seats.
Program:
Output:
Outcome:
Passengers can easily check bus schedules, reducing waiting time and improving travel
experience in rural areas.
Government Polytechnic Raichur. Department of Computer Science & Engg.
Page 2
Thinking Programming with Python 25CS21I
Program Implementation and Expected Output
Government Polytechnic Raichur. Department of Computer Science & Engg.
Page 3
Thinking Programming with Python 25CS21I
1b. Smart Irrigation System for Optimal Water Usage.
Case Description:
Water is wasted in traditional irrigation systems when pumps run continuously. Using Python-
based automation, irrigation can be controlled according to soil moisture levels.
Program:
Output:
Outcome:
Automated control saves water, reduces electricity usage, and increases crop production.
Government Polytechnic Raichur. Department of Computer Science & Engg.
Page 4
Thinking Programming with Python 25CS21I
Program Implementation and Expected Output
Government Polytechnic Raichur. Department of Computer Science & Engg.
Page 5
Thinking Programming with Python 25CS21I
1c. Impact of Social Media on Students.
Case Description:
Students spend many hours on social media, which affects their academic performance. Using
Python, we can analyze weekly usage and understand how much time is spent online.
Program:
Output:
Outcome:
Students can observe their usage pattern and take corrective actions to balance studies and
social media.
Conclusion of All Case-Based Learning Activities.
Case-based learning enables students to use Python for solving real-world problems
effectively. These programs demonstrate how Python can be applied in public service,
agriculture, data analysis, and social awareness to improve decision-making and problem-
solving.
Government Polytechnic Raichur. Department of Computer Science & Engg.
Page 6
Thinking Programming with Python 25CS21I
Program Implementation and Expected Output
Government Polytechnic Raichur. Department of Computer Science & Engg.
WEEK - 02
Page 7
Thinking Programming with Python 25CS21I
Problem / use case based learning:
Devise an Algorithm and draw flowchart for problems such as Swapping two values
Algorithm:
Step 1: start
Step 2: read 2 numbers and store in A and B.
Step 3: swap the numbers
A=A+B
B=A–B
A=A-B
Step 4: display A and B.
Step 5: stop
Flowchart:
Government Polytechnic Raichur. Department of Computer Science & Engg.
Page 8
Thinking Programming with Python 25CS21I
Finding largest / smallest among two/three number
Algorithm:
Largest of 2 numbers:
Step 1: start
Step 2: read two numbers a, b
Step 3: if a > b
display “a is largest”
else
display “b is largest”
Step 4: stop.
Flowchart:
Government Polytechnic Raichur. Department of Computer Science & Engg.
Page 9
Thinking Programming with Python 25CS21I
Algorithm:
Smallest of 3 numbers:
Step 1: Start
Step 2: Read 3 numbers a, b, c.
Step 3: Compare a with b and c. If a is smaller than b and c then a is smallest among three numbers.
Step 4: Compare b with a and c. If b is smaller than a and c then b is smallest among three numbers.
Step 5: Compare c with a and b. If c is smaller than a and b then c is smallest among three numbers.
Step 6: Stop
Flowchart:
Government Polytechnic Raichur. Department of Computer Science & Engg.
Page 10
Thinking Programming with Python 25CS21I
Computing area/ perimeter of given shape (circle, triangle, rectangle, square)
Algorithm:
Area of a Circle:
Step 1: Start
Step 2: read radius r
Step 3: calculate the area of a circle
area = П r2
Step 4: display area
Step 5: Stop.
Flowchart:
Government Polytechnic Raichur. Department of Computer Science & Engg.
Page 11
Thinking Programming with Python 25CS21I
Algorithm:
Area of a triangle:
Step 1: Start
Step 2: read base and height
Step 3: calculate the area of a triangle
area = 1/2 * base * height
Step 4: display area
Step 5: Stop.
Flowchart:
Government Polytechnic Raichur. Department of Computer Science & Engg.
Page 12
Thinking Programming with Python 25CS21I
Algorithm:
Area of a rectangle:
Step 1: Start
Step 2: read length and width
Step 3: calculate the area of a rectangle
area = length * width
Step 4: display area
Step 5: Stop.
Flowchart:
Government Polytechnic Raichur. Department of Computer Science & Engg.
Page 13
Thinking Programming with Python 25CS21I
Metric conversion (meter – KM, pound – kilo gram, Celsius – Fahrenheit)
Algorithm:
1. Meter – KM
Step 1: start.
Step 2: read the distance in meters (e.g., dist_m).
Step 3: calculate the distance in kilometer.
dist_km = dist_m / 1000.
Step 4: display the distance in kilometer dist_km
Step 5: stop.
Flowchart:
Government Polytechnic Raichur. Department of Computer Science & Engg.
Page 14
Thinking Programming with Python 25CS21I
2. Pound – kilo gram
Algorithm:
Step 1: start.
Step 2: read the weight in pound (e.g., wt_p).
Step 3: calculate the weight in kilogram.
wt_kg = wt_p * 0.45359237.
Step 4: display the weight in kilogram wt_kg
Step 5: stop.
Flowchart:
Government Polytechnic Raichur. Department of Computer Science & Engg.
Page 15
Thinking Programming with Python 25CS21I
3. Celsius – Fahrenheit
Algorithm:
Step 1: start.
Step 2: read the temperature in Celsius (e.g., C).
Step 3: calculate the temperature in Fahrenheit.
F = (C * 9/5) + 32.
Step 4: display the temperature in Fahrenheit F
Step 5: stop.
Flowchart:
Government Polytechnic Raichur. Department of Computer Science & Engg.
Page 16
Thinking Programming with Python 25CS21I
Determine given number is even or odd, positive or negative.
Even or Odd:
Algorithm:
Step 1: Start
Step 2: read one number (num)
Step 3: calculate the remainder using modulo operator
rem = num % 2
Step 4: if rem == 0
display “given number is even”
else
display “given number is odd”
Step 5: Stop.
Flowchart:
Government Polytechnic Raichur. Department of Computer Science & Engg.
Page 17
Thinking Programming with Python 25CS21I
Positive or negative:
Algorithm:
Step 1: Start
Step 2: read one number (x)
Step 3: if x < 0
display “positive number”
else
display “negative number”
Step 4: Stop.
Flowchart:
Government Polytechnic Raichur. Department of Computer Science & Engg.
WEEK - 03
Page 18
Thinking Programming with Python 25CS21I
Think Like a Programmer.
Think Like a Programmer is a mindset that focuses on solving problems logically, systematically,
and efficiently rather than just writing code. It emphasizes understanding a problem deeply, breaking
it into manageable parts, and designing a clear solution before implementation. This way of thinking
is essential not only for programmers but also for anyone involved in analytical or technical problem-
solving.
At the core of thinking like a programmer is problem analysis. Before jumping to a solution, a
programmer carefully studies the problem statement, identifies inputs and outputs, and understands
constraints. This helps avoid confusion and reduces errors during implementation. A well-understood
problem is already half solved.
Another important aspect is Decomposition. Complex problems are divided into smaller, simpler
tasks that are easier to handle. Each sub problem can be solved independently, tested, and then
combined to form the complete solution. This approach improves clarity, accuracy, and reusability.
Logical thinking and algorithms play a key role in this mindset. Programmers design step-by-step
procedures (algorithms) to solve problems in a structured manner. They also consider efficiency by
choosing solutions that save time and memory, especially when dealing with large data.
Debugging and learning from mistakes are also part of thinking like a programmer. Errors are
treated as learning opportunities. Programmers analyze why something failed, fix it logically, and
improve their solution. This builds patience, persistence, and confidence.
Finally, thinking like a programmer encourages continuous Learning and Adaptability.
Technology evolves rapidly, so programmers must be open to learning new tools, languages, and
approaches. This mindset helps individuals approach challenges with curiosity and creativity.
In conclusion, Think Like a Programmer is about developing a structured, logical, and patient
approach to problem-solving. It goes beyond coding and helps build strong analytical skills that are
valuable in academics, professional life, and everyday decision-making.
Think Like a Programmer - Google Books.
Think Like a Programmer: Introdu ction ([Link])
General problem solving techniques- refer the book or you tube videos.
Think like a Programmer (Simple Tips)
Government Polytechnic Raichur. Department of Computer Science & Engg.
WEEK - 04
Page 19
Thinking Programming with Python 25CS21I
Download and Install the necessary Compiler or Interpreter.
Prepare Your Development Environment:
Python is a widely used high-level programming language. To write and execute
code in python, we first need to install Python on our system.
Installing Python on Windows takes a series of few easy steps.
Step 1: Download the Full Installer
Follow these steps to download the full installer:
Open a browser window and navigate to the [Link] Downloads page
for Windows.
Under the “Python Releases for Windows” heading, click the link for the
Latest Python 3 Release - Python 3.x.x. As of this writing, the latest
version was Python 3.10.
Scroll to the bottom and select either Windows x86-64 executable installer
for 64-bit or Windows x86 executable installer for 32-bit.
Step 2 − Run Executable Installer
We downloaded the Python 3.10 Windows 64 bit installer.
Run the installer. Make sure to select both the checkboxes at the bottom and
then click Install New.
On clicking the Install Now, The installation process starts.
Government Polytechnic Raichur. Department of Computer Science & Engg.
Page 20
Thinking Programming with Python 25CS21I
The installation process will take few minutes to complete and once the installation
is successful, the following screen is displayed.
Step 3 − Verify Python is installed on Windows
To ensure if Python is successfully installed on your system. Follow the
given steps
Open the command prompt.
Type ‘python’ and press enter.
The version of the python which you have installed will be displayed if the
python is successfully installed on your windows.
Government Polytechnic Raichur. Department of Computer Science & Engg.
Page 21
Thinking Programming with Python 25CS21I
PyCharm is a cross-platform editor developed by JetBrains. Pycharm
provides all the tools you need for productive Python development.
Below are the detailed steps for installing PyCharm.
Step1: To download PyCharm visit the website [Link] and
Click the “DOWNLOAD” link under the Community Section.
Step 2) Once the download is complete, run the exe for install PyCharm.
The setup wizard should have started. Click “Next”.
Step 3) On the next screen, Change the installation path if required.
Click “Next”.
Government Polytechnic Raichur. Department of Computer Science & Engg.
Page 22
Thinking Programming with Python 25CS21I
Step 4) On the next screen, you can create a desktop shortcut if you
want and click on “Next”.
Step 5) Choose the start menu folder. Keep selected JetBrains and
click on “Install”.
Government Polytechnic Raichur. Department of Computer Science & Engg.
Page 23
Thinking Programming with Python 25CS21I
Step 6) Wait for the installation to finish.
Step 7) Once installation finished, you should receive a message screen
that PyCharm is installed. If you want to go ahead and run it, click the
“Run PyCharm Community Edition” box first and click “Finish”.
Government Polytechnic Raichur. Department of Computer Science & Engg.
Page 24
Thinking Programming with Python 25CS21I
Step 8) After you click on “Finish,” the Following screen will appear.
Government Polytechnic Raichur. Department of Computer Science & Engg.
WEEK - 05
Page 25
Thinking Programming with Python 25CS21I
1. Create variables, assign values, and display their data types:
a. Create variables of different data types and assign values
b. Display the values and their respective data types using the type() function.
Program:
Output:
Government Polytechnic Raichur. Department of Computer Science & Engg.
Page 26
Thinking Programming with Python 25CS21I
Program Implementation and Expected Output
Government Polytechnic Raichur. Department of Computer Science & Engg.
Page 27
Thinking Programming with Python 25CS21I
2. Assignment Statements:
a. Single variable assignment: Assign a value to a single variable.
b. Multiple variable assignment: Assign values to multiple variables in one statement.
c. Assign the same value to multiple variables.
Program:
Output:
Government Polytechnic Raichur. Department of Computer Science & Engg.
Page 28
Thinking Programming with Python 25CS21I
Program Implementation and Expected Output
Government Polytechnic Raichur. Department of Computer Science & Engg.
Page 29
Thinking Programming with Python 25CS21I
3. Type Conversion
a. Demonstrate Python's ability to convert types automatically during operations.
b. Use functions like int(), float(), str(), or bool() to explicitly convert data types.
Program:
Output:
Government Polytechnic Raichur. Department of Computer Science & Engg.
Page
Page30
1
Thinking Programming with Python 25CS21I
Program Implementation and Expected Output
Government Polytechnic Raichur. Department of Computer Science & Engg.
WEEK - 06
Page 31
Thinking Programming with Python 25CS21I
1. Write a program that:
a. Accepts user input for name and age.
b. Prints a formatted message using different string formatting methods.
Program:
Output:
Government Polytechnic Raichur. Department of Computer Science & Engg.
Page 32
Thinking Programming with Python 25CS21I
Program Implementation and Expected Output
Government Polytechnic Raichur. Department of Computer Science & Engg.
Page 33
Thinking Programming with Python 25CS21I
2. Read message from the user and Format it with different methods and display.
Program:
Output:
Government Polytechnic Raichur. Department of Computer Science & Engg.
Page 34
Thinking Programming with Python 25CS21I
Program Implementation and Expected Output
Government Polytechnic Raichur. Department of Computer Science & Engg.
Page 35
Thinking Programming with Python 25CS21I
3. Demonstrate swapping the values(numerical) of two variables using a temporary variable.
Program:
Output:
Government Polytechnic Raichur. Department of Computer Science & Engg.
Page 36
Thinking Programming with Python 25CS21I
Program Implementation and Expected Output
Government Polytechnic Raichur. Department of Computer Science & Engg.
WEEK - 07
Page 37
Thinking Programming with Python 25CS21I
1. Write python equivalent expressions for math expressions such as
a. f = ax +b
b. f = a2 + b2 + 2ab.
c. f = a3 + b3 + 3ab(a + b)
d. area = πr2
Program:
Output:
Government Polytechnic Raichur. Department of Computer Science & Engg.
Page 38
Thinking Programming with Python 25CS21I
Program Implementation and Expected Output
Government Polytechnic Raichur. Department of Computer Science & Engg.
Page 39
Thinking Programming with Python 25CS21I
2. Write a program that:
a. Accepts two numbers from the user.
b. Converts them to integers (if they are not already).
Performs arithmetic operations (add, subtract, multiply, divide) and displays the results
with the data types and appropriate message.
Program:
Output:
Government Polytechnic Raichur. Department of Computer Science & Engg.
Page 40
Thinking Programming with Python 25CS21I
Program Implementation and Expected Output
Government Polytechnic Raichur. Department of Computer Science & Engg.
Page 41
Thinking Programming with Python 25CS21I
3. Calculate the total cost of an item after applying a 15% discount to its original price of Rs150.
Program:
Output:
Government Polytechnic Raichur. Department of Computer Science & Engg.
Page 42
Thinking Programming with Python 25CS21I
Program Implementation and Expected Output
Government Polytechnic Raichur. Department of Computer Science & Engg.
Page 43
Thinking Programming with Python 25CS21I
4. Calculate the compound interest on a principal of Rs10000 at an annual interest rate of 5%
for 3 years, compounded annually.
Program:
Output:
Government Polytechnic Raichur. Department of Computer Science & Engg.
Page 44
Thinking Programming with Python 25CS21I
Program Implementation and Expected Output
Government Polytechnic Raichur. Department of Computer Science & Engg.
Page 45
Thinking Programming with Python 25CS21I
5. Compute area of triangle, rectangle.
Program:
Output:
Government Polytechnic Raichur. Department of Computer Science & Engg.
Page 46
Thinking Programming with Python 25CS21I
Program Implementation and Expected Output
Government Polytechnic Raichur. Department of Computer Science & Engg.
Page 47
Thinking Programming with Python 25CS21I
6. Swapping values of two variables without using a temporary variable
Program:
Output:
Government Polytechnic Raichur. Department of Computer Science & Engg.
Page 48
Thinking Programming with Python 25CS21I
Program Implementation and Expected Output
Government Polytechnic Raichur. Department of Computer Science & Engg.
WEEK - 08
Page 49
Thinking Programming with Python 25CS21I
1. Create a program to manage airline ticket bookings based on the passenger's selected
class: "economy", "business", or "first".
a. Prompt the user to input details such as name, age, destination, and class preference
(economy, business, or first).
b. Validate inputs (e.g., ensure the name contains only letters, age is a positive integer, and
class selection is valid).
Display appropriate error messages for invalid entries and allow the user to reenter the data.
Program:
Government Polytechnic Raichur. Department of Computer Science & Engg.
Page 50
Thinking Programming with Python 25CS21I
Output:
Government Polytechnic Raichur. Department of Computer Science & Engg.
Page 51
Thinking Programming with Python 25CS21I
Program Implementation and Expected Output
Government Polytechnic Raichur. Department of Computer Science & Engg.
Page 52
Thinking Programming with Python 25CS21I
2. Build a system to suggest clothing based on the temperature.
a. If temperature ≥30°C, suggest "Wear light clothes."
b. If 20°C ≤ temperature < 30°C, suggest "Wear moderate clothing."
c. If temperature < 20°C, suggest "Wear warm clothes."
Program:
Output:
Government Polytechnic Raichur. Department of Computer Science & Engg.
Page 53
Thinking Programming with Python 25CS21I
Program Implementation and Expected Output
Government Polytechnic Raichur. Department of Computer Science & Engg.
Page 54
Thinking Programming with Python 25CS21I
3. Implement a discount system for an e-commerce website.
a. If the total purchase is ≥Rs5000, apply a 20% discount.
b. If Rs2000 ≤ total < Rs5000, apply a 10% discount.
c. If total < Rs2000, no discount is applied.
Program:
Output:
Government Polytechnic Raichur. Department of Computer Science & Engg.
Page 55
Thinking Programming with Python 25CS21I
Program Implementation and Expected Output
Government Polytechnic Raichur. Department of Computer Science & Engg.
Page 56
Thinking Programming with Python 25CS21I
4. Create a program that simulates an ATM machine to check:
a. If the entered PIN is correct, allow the user to proceed.
b. Validate that the withdrawal amount doesn’t exceed the account balance.
c. Ensure that the withdrawal amount is in multiples of a specific denomination (e.g.,
Rs100).
Program:
Government Polytechnic Raichur. Department of Computer Science & Engg.
Page 57
Thinking Programming with Python 25CS21I
Output:
Government Polytechnic Raichur. Department of Computer Science & Engg.
Page 58
Thinking Programming with Python 25CS21I
Program Implementation and Expected Output
Government Polytechnic Raichur. Department of Computer Science & Engg.
WEEK - 09
Page 59
Thinking Programming with Python 25CS21I
1. Generate numbers from 1 to 10 using range().
Program:
Output:
2. Generate numbers for a given range.
Program:
Government Polytechnic Raichur. Department of Computer Science & Engg.
Page 60
Thinking Programming with Python 25CS21I
Output:
3. Write a program to display square numbers from 1 to 10.
Program:
Output:
Government Polytechnic Raichur. Department of Computer Science & Engg.
Page 61
Thinking Programming with Python 25CS21I
Program Implementation and Expected Output
Government Polytechnic Raichur. Department of Computer Science & Engg.
Page 62
Thinking Programming with Python 25CS21I
4. Write a Python program that accepts an integer input from the user and determines whether
the number is a prime number or not. If the number is prime, display an appropriate message;
otherwise, indicate that it is not prime.
Program:
Output:
Government Polytechnic Raichur. Department of Computer Science & Engg.
Page 63
Thinking Programming with Python 25CS21I
Program Implementation and Expected Output
Government Polytechnic Raichur. Department of Computer Science & Engg.
Page 64
Thinking Programming with Python 25CS21I
5. Write a Python program that accepts a message and a number from the user. The
program should then print the specified message the given number of times.
Program:
Output:
Government Polytechnic Raichur. Department of Computer Science & Engg.
Page 65
Thinking Programming with Python 25CS21I
6. Write a Python program to calculate the factorial of a given number. The program should:
a. Accept a non-negative integer as input.
b. Use an iterative approach to compute the factorial.
c. Handle invalid inputs (e.g., negative numbers or non-numeric inputs) by
displaying appropriate error messages.
Program:
Output:
Government Polytechnic Raichur. Department of Computer Science & Engg.
Page 66
Thinking Programming with Python 25CS21I
Program Implementation and Expected Output
Government Polytechnic Raichur. Department of Computer Science & Engg.
WEEK - 10
Page 67
Thinking Programming with Python 25CS21I
1. Implement the Euclidean algorithm to find the GCD of two integers using a while loop.
Program:
Output:
Government Polytechnic Raichur. Department of Computer Science & Engg.
Page 68
Thinking Programming with Python 25CS21I
Program Implementation and Expected Output
Government Polytechnic Raichur. Department of Computer Science & Engg.
Page 69
Thinking Programming with Python 25CS21I
2. Collect daily weather data (e.g., temperature, humidity) from the user. Allow data
entry to continue until the user decides to stop or inputs a sentinel value.
Program:
Output:
Government Polytechnic Raichur. Department of Computer Science & Engg.
Page 70
Thinking Programming with Python 25CS21I
Program Implementation and Expected Output
Government Polytechnic Raichur. Department of Computer Science & Engg.
Page 71
Thinking Programming with Python 25CS21I
3. Write a program that simulates a countdown timer. Start with a given number of seconds
and decrement until it reaches zero, displaying the countdown at each step.
Program:
Output:
Government Polytechnic Raichur. Department of Computer Science & Engg.
Page 72
Thinking Programming with Python 25CS21I
Program Implementation and Expected Output
Government Polytechnic Raichur. Department of Computer Science & Engg.
Page 73
Thinking Programming with Python 25CS21I
4. Write a program that takes an integer and calculates the sum of its digits using a while
loop.
Program:
Output:
Government Polytechnic Raichur. Department of Computer Science & Engg.
Page 74
Thinking Programming with Python 25CS21I
Program Implementation and Expected Output
Government Polytechnic Raichur. Department of Computer Science & Engg.
WEEK - 11
Page 75
Thinking Programming with Python 25CS21I
1. Write a program to identify all prime numbers within a user-defined range. The program
should:
a. List all the prime numbers within the range.
b. Calculate and display the total count of prime numbers found.
c. Compute and display the sum of these prime numbers
Program:
Output:
Government Polytechnic Raichur. Department of Computer Science & Engg.
Page 76
Thinking Programming with Python 25CS21I
Program Implementation and Expected Output
Government Polytechnic Raichur. Department of Computer Science & Engg.
Page 77
Thinking Programming with Python 25CS21I
2. Write a Python program to perform the following tasks for a user-defined range of integers:
a. Identify and list all non-prime numbers within the given range.
b. Categorize the non-prime numbers into even and odd.
c. Count the total number of even and odd non-prime numbers.
d. Calculate and display the sum of even and odd non-prime numbers separately.
Program:
Output:
Government Polytechnic Raichur. Department of Computer Science & Engg.
Page 78
Thinking Programming with Python 25CS21I
Program Implementation and Expected Output
Government Polytechnic Raichur. Department of Computer Science & Engg.
Page 79
Thinking Programming with Python 25CS21I
3. Write a Python program to perform the following tasks for a user-defined range of
integers:
a) Identify and list all palindrome numbers within the specified range.
b) Count the total number of palindrome numbers found.
c) Display the results in a user-friendly format.
Program:
Output:
Government Polytechnic Raichur. Department of Computer Science & Engg.
Page 80
Thinking Programming with Python 25CS21I
Program Implementation and Expected Output
Government Polytechnic Raichur. Department of Computer Science & Engg.
Page 81
Thinking Programming with Python 25CS21I
4. Write a program to generate and display a multiplication table for numbers 1 to 10.
Program:
Output:
Government Polytechnic Raichur. Department of Computer Science & Engg.
Page 82
Thinking Programming with Python 25CS21I
Program Implementation and Expected Output
Government Polytechnic Raichur. Department of Computer Science & Engg.
WEEK - 12
Page 83
Thinking Programming with Python 25CS21I
1. Write simple functions for arithmetic calculations (e.g., addition, factorial)
Program:
Output:
Government Polytechnic Raichur. Department of Computer Science & Engg.
Page 84
Thinking Programming with Python 25CS21I
Program Implementation and Expected Output
Government Polytechnic Raichur. Department of Computer Science & Engg.
Page 85
Thinking Programming with Python 25CS21I
2. Define a function assign_priority() for ticketing system which assigns priorities to
support tickets based on the issue type (low, medium, high and returns a priority level.
Program:
Output:
Government Polytechnic Raichur. Department of Computer Science & Engg.
Page 86
Thinking Programming with Python 25CS21I
Program Implementation and Expected Output
Government Polytechnic Raichur. Department of Computer Science & Engg.
Page 87
Thinking Programming with Python 25CS21I
3. Define function calculate_interest() for banking system, to calculate the interest on
savings accounts based on the principal amount, rate, and time period.
Program:
Output:
Government Polytechnic Raichur. Department of Computer Science & Engg.
Page 88
Thinking Programming with Python 25CS21I
Program Implementation and Expected Output
Government Polytechnic Raichur. Department of Computer Science & Engg.
Page 89
Thinking Programming with Python 25CS21I
4. An online store offers a discount based on the total purchase amount. If the customer’s
total purchase exceeds a certain threshold, they get a percentage discount. Define a function
apply_discount() that accepts the total amount and returns the final price after discount..
Program:
Output:
Government Polytechnic Raichur. Department of Computer Science & Engg.
Page 90
Thinking Programming with Python 25CS21I
Program Implementation and Expected Output
Government Polytechnic Raichur. Department of Computer Science & Engg.
WEEK - 13
Page 91
Thinking Programming with Python 25CS21I
1. Create a module that includes a function to calculate the area of a circle and use it in another
script.
Program:
Output:
Government Polytechnic Raichur. Department of Computer Science & Engg.
Page 92
Thinking Programming with Python 25CS21I
Program Implementation and Expected Output
Government Polytechnic Raichur. Department of Computer Science & Engg.
INFOSYS SPRING BOARD
ONLINE COURSES
SL.
Online Course Name Hours Signature
No.
1 Basics of Python. 1 Hr 18 Min
Programming Fundamentals using Python - Science
2 66 Hr 10 Min
Graduates - Foundation Program.
Total Hours 67 Hr 28 Min
ONLINE COURSES MARKS:
30
Thinking Programming with Python 25CS21I
Basics of Python (Online Course): - Notes
Government Polytechnic Raichur. Department of Computer Science & Engg.
Thinking Programming with Python 25CS21I
Government Polytechnic Raichur. Department of Computer Science & Engg.
Thinking Programming with Python 25CS21I
Government Polytechnic Raichur. Department of Computer Science & Engg.
Thinking Programming with Python 25CS21I
Government Polytechnic Raichur. Department of Computer Science & Engg.
Thinking Programming with Python 25CS21I
Programming Fundamentals using Python (Online Course): - Notes
Government Polytechnic Raichur. Department of Computer Science & Engg.
Thinking Programming with Python 25CS21I
Government Polytechnic Raichur. Department of Computer Science & Engg.
Thinking Programming with Python 25CS21I
Government Polytechnic Raichur. Department of Computer Science & Engg.
Thinking Programming with Python 25CS21I
Government Polytechnic Raichur. Department of Computer Science & Engg.
Thinking Programming with Python 25CS21I
Government Polytechnic Raichur. Department of Computer Science & Engg.