You are on page 1of 2

Suleyman Demirel University

MAT 122 / MCM 104 / SDS 105


Algorithms and programming 1
Laboratory work 1
Task 1
1. We’ve declared variables n = 109 and uni = ‘SDU’, area = 4.3454,
val = int(‘100000000000000000000000009’) in python programming language. Which
type of variables n, uni, area, val?

2. You already know how to calculate Area of a circle on paper. Can you calculate it in
the Python programming language? (You can use math class or declare as variable)

3. How to concatenate two strings in the python programming language? (For example
str1 = ‘Java’, str2 = ‘C++’)

4. How to calculate any power of any number in the python programming language?
(For example power = 8, number = 2)

5. How to increment to one int value in python? (For example we can increment in C++
or Java like val++ or val += 1)

6. Write a program that calculate sum from 1 to n.

7. The length L of the circle is given. Find its radius R and the
area S of the circle bounded by this circle, given that L=2⋅π⋅R,
S=π⋅R2. Use 3.14 as the value of π.
Task 2
1. In math notation, leading zeros are ok, as in 02. What happens if you try it in
Python?

2. If you are trying to print a string, what happens if you leave out one of the
quotation marks, or both?

3. What happens if you multiply a string by an integer? (For example str1 * 100)

Task 3
Draw flowchart for this algorithm :
Step 1: Initialize any X as integer.
Step 2: If value of X between and 500 print “Low level”.
Step 3: If value of X between 501 and 1000 print “Medium level”.
Step 4: if value of X between 1001 and print “High level”

You might also like