0% found this document useful (0 votes)
6 views4 pages

ECE Applied Python Practice Programs Page No 7-10

The document contains various Python programming exercises including generating the Fibonacci series using a while loop, checking for palindromes, printing Pascal's Triangle, reversing an integer, and converting decimal numbers to binary, octal, and hexadecimal. It also covers the basics of defining and calling functions in Python, along with examples of function arguments. Additionally, it mentions creating a simple calculator and displaying the Fibonacci sequence using recursion.

Uploaded by

Shanawaz Basha
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)
6 views4 pages

ECE Applied Python Practice Programs Page No 7-10

The document contains various Python programming exercises including generating the Fibonacci series using a while loop, checking for palindromes, printing Pascal's Triangle, reversing an integer, and converting decimal numbers to binary, octal, and hexadecimal. It also covers the basics of defining and calling functions in Python, along with examples of function arguments. Additionally, it mentions creating a simple calculator and displaying the Fibonacci sequence using recursion.

Uploaded by

Shanawaz Basha
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/ 4

Write a python program to generate the Fibonacci series using While Loop.

Write a python program to check whether a given number is palindrome or not.

Write a python program to print the Pascal Triangle

Write a python program to Reverse an Integer

S. SHANAWAZ BASHA 7
Write a Python program to convert Decimal to Binary, Octal and Hexadecimal.
dec_num = int(input('Enter a decimal number: '))
print("The decimal value of", dec_num, "is:")
print(bin(dec_num), "in binary.")
print(oct(dec_num), "in octal.")
print(hex(dec_num), "in hexadecimal.")

Output:

Enter a decimal number: 27

The decimal value of 27 is:

0b11011 in binary.

0o33 in octal.

0x1b in hexadecimal.

Python Functions
A function is a block of code which only runs when it is called. We can pass data, known as parameters,
into a function. A function can return data as a result.

Declaring a Function
In Python a function is defined using the def keyword.

Example

def my_function():

print("Hello World")

Calling a Function
To call a function, we can use the function name followed by parenthesis.

Example

def my_function():

print("Hello World")

my_function()

Function Arguments or Parameters


Information can be passed into functions as arguments. Arguments are specified after the function
name, inside the parentheses. We can add as many arguments as we want, the function arguments can
be separated with a comma.

S. SHANAWAZ BASHA 8
The following example has a function with one argument (funcname). When the function is called, we
pass along a first name, which is used inside the function to print the full name:

Example

def my_function(funcname):
print(fname + "Engineering")
my_function("Computer Science")
my_function("Electronics and Communication")
my_function("Civil")
Output:

Computer Science Engineering


Electronics and Communication Engineering
Civil Engineering

Write a Python Program to make a Simple Calculator with basic arithmetic / mathematical operations.

S. SHANAWAZ BASHA 9
Output

Write a Python Program to Display Fibonacci Sequence Using Recursion

Output

S. SHANAWAZ BASHA 10

You might also like