0% found this document useful (0 votes)
3 views

BIS4+ +Programming+ +Python+%28no+Solutions%29

The document outlines a Business Information Systems course for the academic year 2023-2024, covering topics such as programming in Python, algorithms, databases, and current IT trends. It includes exercises for practical programming skills, including converting miles to kilometers and calculating student grades. Additionally, it discusses the use of functions and procedures in Python for various calculations and programming tasks.

Uploaded by

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

BIS4+ +Programming+ +Python+%28no+Solutions%29

The document outlines a Business Information Systems course for the academic year 2023-2024, covering topics such as programming in Python, algorithms, databases, and current IT trends. It includes exercises for practical programming skills, including converting miles to kilometers and calculating student grades. Additionally, it discusses the use of functions and procedures in Python for various calculations and programming tasks.

Uploaded by

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

Business Information Systems

Academic year 2023 - 2024

Prof. dr. Alexandre Thys


Overview course :

1. Introduction
2. Goal - Basic concepts
3. Algorithm
4. Programming
Python in a Nutshell
5. Functionalities
6. Project management
7. Databases

8. Informatics in a business context


9. Enterprise applications
10. New business models
11. Current trend in IT

Overview
Download: https://www.anaconda.com/products/individual
Python Single Predefined Types

• Integer: Whole numbers (positive and negative)


• Float (real): With numbers after the comma (floating point)
• String: Symbol (e.g. a letter)
• Boolean: True / false

Programming
Exercise:
Program “miles in km” from chapter 3 (algorithm): the input is a given
distance in miles. The desired result is the same distance but in
kilometers. The relationship between the two is: 1 mile = 1,609 km
Exercise:
Program “miles in km” from chapter 3 (algorithm): the input is a given
distance in miles. The desired result is the same distance but in
kilometers. The relationship between the two is: 1 mile = 1,609 km
Step4: Put the algorithm in Python
Transform the algorithm from slide 49 (from BIS3 – Algorithms) into a Python program.
Read the Marks and give an error when >100!
mark = int(input("Give the mark of the student: "))
if mark < 60:
grade = "F"
elif mark < 70:
grade = "D"
elif mark < 80:
grade = "C"
elif mark < 90:
grade = "B"
elif mark <= 100:
grade = "A"
else:
grade = "Error! Mark is maximum 100!!!"
print ("The grade =", grade)
Exercise:
Write a Python program where a counter starts with the
value 1 and stops when the counter has the value 6.
After this, the value of the counter is displayed.
Infinite loop!!!
PseudoCode

Begin
sum ← 0
write ‘Give number: ‘
read number
While number <> 0
do sum ← sum + number
write ‘Give number: ‘
read number
EndDo
write ‘The sum is ‘, sum
End
From algorithm (step 3) to programme (step 4)

PseudoCode Python

Begin
sum ← 0
write ‘Give number: ‘
sum = 0
read number number = int(input("Give number: "))
While number <> 0
while (number != 0):
do sum ← sum + number
write ‘Give number: ‘ sum = sum + number
read number number = int(input("Give number: "))
EndDo
write ‘The sum is ‘, sum print(“The sum is ", sum)
End
Or….. Solution with a counter

sum = 0
counter = 1
number = int(input("Give number n° " + str(counter) + ": "))
while (number != 0):
sum = sum + number
number = number + 1
number = int(input("Give number n° " + str(counter) + ": "))
print(“The sum is ", sum)
Python doesn't know this kind of loop!!!
The FOR-loop (in Python)
How would you
write a for-loop if
PseudoCode the for structure
did not exist?

Python (example previous slide)


The FOR (in a list)
Python has the predefined function pow (power).

In case this function was not predefined, how should you write it?
Example: pow(5,2) with the result 25
Python has the predefined function pow (power).

In case this function was not predefined, how should you write it?
General case:

With a function/procedure
Python has the predefined function pow (power).

In case this function was not predefined, how should you write it?
General case:

With a function /procedure


Task: write the program from slide 21 with a Function
(function/function) called "gradeConverter".
The supplied grade must be written subsequently
Solution:
Write a function/procedure “investment” that calculates the capital of an investment
on x-number years. We want to see the current balance for each year. Make two tests!
test1: 1000, 4, 0.1
test2: 12500,10, 0.15

Formula: Kn = K0 * (1 + i)n
Same question as previous but the 3 parameters are read!!
Write a function/procedure that calculates the capital of an investment on x-number years.
We want to see the current balance for each year. Instead of one interest rate the
function makes the calculation for a list of several interest rates! Make two tests!!
Tip: use a function that calls another function (the one on slide 46)!
Input – Output Question

What is the value of b after executing following code?

a = [1, 2, 3]
b=0
for i in a:
b=b+2*i
print(b)
Input – Output Question

What is the value of a and b after executing following code?

a=1
b=3
for i in range(1,6):
if (a == i):
b = (i * 4) / a
else:
a=a*2
print(a,b)
Input – Output Question

How will the list “numbers” look like after executing following code?

numbers = [14, 2, 26, 45, 42, 1, 26, 5, 9, 11]

if numbers[2] > numbers[6]:


numbers[4] = numbers[1] * numbers[9]
else:
numbers[6] = numbers[3] / numbers[7]
Transform next FOR-code with a while?

list = [1, 7, 5, 4]
for item in list:
print(item)
Solution(s): see file on Canvas: ATM in Python

You might also like