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

Python_Hands_On_Exercises

The document outlines hands-on exercises for learning Python, covering various topics such as compiling scripts, portability across systems, memory management, print functionality, variable manipulation, indentation, reserved keywords, data types, comments, arithmetic operations, type conversion, and user input. Each section includes specific tasks to practice and reinforce understanding of Python programming concepts. The exercises are designed for learners to gain practical experience with Python syntax and functionality.

Uploaded by

rajsinghan388
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)
2 views

Python_Hands_On_Exercises

The document outlines hands-on exercises for learning Python, covering various topics such as compiling scripts, portability across systems, memory management, print functionality, variable manipulation, indentation, reserved keywords, data types, comments, arithmetic operations, type conversion, and user input. Each section includes specific tasks to practice and reinforce understanding of Python programming concepts. The exercises are designed for learners to gain practical experience with Python syntax and functionality.

Uploaded by

rajsinghan388
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/ 2

Python Hands-On Exercises

Compile
1. Try writing a simple Python script and execute it using the command line.
2. Use the py_compile module to compile a Python script to a .pyc file.

Portable

1. Write a Python script on Windows and try running it on a Linux system.


2. Install Python on a USB drive and run a script from it on different systems.

High Level

1. Write a Python program that dynamically allocates memory (e.g., using a list).
2. Compare memory management in Python with C using a simple example.

print()

1. Write a program that prints 'Welcome to Python' using print().


2. Modify print() to display output with different separators and end characters.

Variables

1. Create variables of different types and print their values and types.
2. Swap two variables without using a third variable.

Indentation

1. Write a function with proper indentation and execute it.


2. Remove indentation from a Python script and observe the error.

Reserved Keywords

1. Try using a Python keyword as a variable name and observe the error.
2. Use the 'keyword' module to list all Python reserved keywords.

Data Types

1. Write a Python program to check the data type of a given variable.


2. Convert a given list into a tuple and vice versa.

Comments in Python

1. Write a Python script with both single-line and multi-line comments.


2. Use docstrings to document a function and print the docstring.

Arithmetic Operators

1. Write a Python program to perform basic arithmetic operations.


2. Take two numbers as input and calculate their sum, difference, product, and quotient.

Type Conversion and Type Casting

1. Convert a string containing a number into an integer and float.


2. Take user input as a string and explicitly cast it to an integer.

Input in Python

1. Write a program that takes user input and prints it.


2. Take two numbers as input from the user and print their sum.

You might also like