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

lesson1 python

Uploaded by

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

lesson1 python

Uploaded by

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

Data Types and Variables

1.Identify the Data Type:


What will be the data type of the following values?
a) 42
b) 3.14
c) "Hello, World!"
d) True

2. Assign and Print Variables:


Assign the following values to variables and print them:
name = "John"
age = 30
is_student = False

3.Variable Swapping:
Swap the values of two variables x and y without using a third variable.
Example:

x = 5
y = 10
# Swap the values

Arithmetic Operations

4.Basic Calculations:
Write a program that assigns a = 15 and b = 4 and performs the following
operations:
Sum (a + b)
Difference (a - b)
Multiplication (a * b)
Division (a / b)
Floor Division (a // b)
Modulus (a % b)
Power (a ** b)

5.Calculate Perimeter and Area:


Write a Python program to calculate the perimeter and area of a rectangle
with the following dimensions:
Length = 10, Width = 5.

Type Conversion

7.Convert Data Types:


Convert the following:
a) String "100" to an integer.
b) Integer 42 to a string.
c) Floating-point number 3.14 to an integer.
Print the results and their new data types.

8.Input and Conversion:


Write a program that asks the user for a number as input, doubles it, and
prints the result.
Example:

Enter a number: 7
Output: The double of your number is 14
9.Find the Square:
Write a program to take a number as input from the user and print its
square.
Example:

You might also like