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

Nafay Ur Rehman

02-134201-042
BS(CS) – 6B

Lab 01: Introduction to Python IDEs, Data Types, and basic control
statements

Exercise 1

Write a Python program to replace the last element in a list with another list.

Expected output:

Solution:

Exercise 2

Write a Python program to get a string made of the first 2 and the last 2 chars from a given a string. If
the string length is less than 2, return instead of the empty string
Expected output:

Introduction to Computer Science Lab


Miss Salas Akbar
Nafay Ur Rehman
02-134201-042
BS(CS) – 6B

Solution:

Exercise 3

Create a python program that takes user input and prints square, square root of that number, number
powered to 3 (num^3).

Expected output:

Solution:

Exercise 4

Write a Python function to get a string made of 6 copies of the last three characters concatenated with
the string. Minimum length of string must be

Introduction to Computer Science Lab


Miss Salas Akbar
Nafay Ur Rehman
02-134201-042
BS(CS) – 6B

Expected Output:

Solution:

Introduction to Computer Science Lab


Miss Salas Akbar

You might also like