[go: up one dir, main page]

0% found this document useful (0 votes)
10 views5 pages

01 - Python - Installation - Basics

python basics on some course

Uploaded by

Arda Sarıtaş
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views5 pages

01 - Python - Installation - Basics

python basics on some course

Uploaded by

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

Department of Information Systems and Technologies

CTIS264 – Computer Algorithms


SPRING 2023 - 2024
Lab Guide 1 - Week 2
Instructor : Erkan UÇAR
Assistant : Leyla SEZER
Objectives:
 Installation of python and packages
 Python basics
 Types
 How to get an input
 String operations
 Slicing
 Arithmetic expressions
 Built-in functions
 Math module
 User-defined functions
 If statement
 For and While Loops

For this course, you can use any python editor but Visual Studio Code is installed all our labs.

https://code.visualstudio.com/download or python idle https://www.python.org/downloads/


Then, you need some python packages, these are; numpy, pandas, matplotlib, xlrd and openpyxl.
Make the following instructions, to install the given packages.

 Open the command prompt, by writing cmd to the start menu.

 Write the following commands to install the given packages (numpy, pandas, matplotlib, xlrd ,
openpyxl) . For the MAC users if you have problem with the following command lines you can
use pip3 command instead of pip.
o pip install numpy
o pip install pandas
o pip install matplotlib.
o pip install openpyxl
o pip install xlrd
Q1. Write a Python code segment; to make soft introduction to Python.

 To get an input from the user, write the following code segment.

Code segment:

Q2. Write a Python code segment that;


 Defines a string as shown below, then gets some part of the string and shows in the
screen which is named slicing in python.

Code segment:
Q3. Write a Python code segment that uses the following arithmetic expressions;
Use the given table to remind for the arithmetic expressions;

Code segment:

Q4. Write a Python code segment that;


 Uses the following built-in functions (round, abs, len),
 Then uses the math module to see the functions (sqrt, ceil, floor, pi).

Code segment:
Q5. Write a Python program that makes following operations, using the string functions.
 Input a full name from the user,
 Count the number of characters in the full name,
 Count the number of ‘a’ in the full name,
 Find the position of blank from the start,
 Find the position of the surname from the beginning,
 Change the full name to uppercase and lowercase format,
 Find the length of name and surname separately,
 Replace all ‘e’ to ‘w’.

Output:
Enter your name: Beren Saat
Your name has 10 characters
Your name contains 2 'a' characters
Position of blank from start: 5
Surname is Saat
Position of your surname from beginning: 6
Your name in lowercase: beren saat
Your name in uppercase: BEREN SAAT
Length of name is 5 Length of surname is 4
After replace all 'e' to 'w' Bwrwn Saat

Q6. Write a Python program that defines a function that;


 Gets several integers from the user until ‘0’ is entered, finds the sum of odd numbers
as in the output.

Output:
Enter an integer value except (0):6
Enter an integer value except (0):5
Enter an integer value except (0):3
Enter an integer value except (0):2
Enter an integer value except (0):1
Enter an integer value except (0):7
Enter an integer value except (0):8
Enter an integer value except (0):0
16

You might also like