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

Assignment_1_Basic_Python

The document outlines an assignment consisting of five tasks related to basic Python programming. Tasks include creating a prime number checker, generating the Fibonacci sequence, reversing a string, calculating factorial using recursion, and performing list operations to filter and square numbers. Each task provides specific requirements and examples for implementation.
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)
3 views

Assignment_1_Basic_Python

The document outlines an assignment consisting of five tasks related to basic Python programming. Tasks include creating a prime number checker, generating the Fibonacci sequence, reversing a string, calculating factorial using recursion, and performing list operations to filter and square numbers. Each task provides specific requirements and examples for implementation.
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/ 6

Assignment 1: Basic Python

### Task 1: Prime Number Checker

Write a function that checks whether a given number is prime.

- A prime number is only divisible by 1 and itself.

- Your function should return True if the number is prime, otherwise False.

- Example: is_prime(7) -> True

### Task 2: Fibonacci Sequence

Write a loop that prints the first 10 Fibonacci numbers.

- The Fibonacci sequence starts with 0 and 1.

- Each subsequent number is the sum of the two preceding ones.

- Example output: 0, 1, 1, 2, 3, 5, 8, 13, 21, 34

### Task 3: String Reversal

Write a function that reverses a string.

- Example: reverse_string("hello") -> "olleh"

### Task 4: Factorial Calculation

Write a function to calculate the factorial of a number using recursion.

- Example: factorial(5) -> 120

### Task 5: List Operations

Write a Python program that does the following:

- Creates a list of numbers from 1 to 10.

- Filters out even numbers.

- Squares the remaining numbers.


Assignment 1: Basic Python

### Task 1: Prime Number Checker

Write a function that checks whether a given number is prime.

- A prime number is only divisible by 1 and itself.

- Your function should return True if the number is prime, otherwise False.

- Example: is_prime(7) -> True

### Task 2: Fibonacci Sequence

Write a loop that prints the first 10 Fibonacci numbers.

- The Fibonacci sequence starts with 0 and 1.

- Each subsequent number is the sum of the two preceding ones.

- Example output: 0, 1, 1, 2, 3, 5, 8, 13, 21, 34

### Task 3: String Reversal

Write a function that reverses a string.

- Example: reverse_string("hello") -> "olleh"

### Task 4: Factorial Calculation

Write a function to calculate the factorial of a number using recursion.

- Example: factorial(5) -> 120

### Task 5: List Operations

Write a Python program that does the following:

- Creates a list of numbers from 1 to 10.


- Filters out even numbers.

- Squares the remaining numbers.

Assignment 1: Basic Python

### Task 1: Prime Number Checker

Write a function that checks whether a given number is prime.

- A prime number is only divisible by 1 and itself.

- Your function should return True if the number is prime, otherwise False.

- Example: is_prime(7) -> True

### Task 2: Fibonacci Sequence

Write a loop that prints the first 10 Fibonacci numbers.

- The Fibonacci sequence starts with 0 and 1.

- Each subsequent number is the sum of the two preceding ones.

- Example output: 0, 1, 1, 2, 3, 5, 8, 13, 21, 34

### Task 3: String Reversal

Write a function that reverses a string.

- Example: reverse_string("hello") -> "olleh"

### Task 4: Factorial Calculation

Write a function to calculate the factorial of a number using recursion.

- Example: factorial(5) -> 120

### Task 5: List Operations


Write a Python program that does the following:

- Creates a list of numbers from 1 to 10.

- Filters out even numbers.

- Squares the remaining numbers.

Assignment 1: Basic Python

### Task 1: Prime Number Checker

Write a function that checks whether a given number is prime.

- A prime number is only divisible by 1 and itself.

- Your function should return True if the number is prime, otherwise False.

- Example: is_prime(7) -> True

### Task 2: Fibonacci Sequence

Write a loop that prints the first 10 Fibonacci numbers.

- The Fibonacci sequence starts with 0 and 1.

- Each subsequent number is the sum of the two preceding ones.

- Example output: 0, 1, 1, 2, 3, 5, 8, 13, 21, 34

### Task 3: String Reversal

Write a function that reverses a string.

- Example: reverse_string("hello") -> "olleh"

### Task 4: Factorial Calculation

Write a function to calculate the factorial of a number using recursion.

- Example: factorial(5) -> 120


### Task 5: List Operations

Write a Python program that does the following:

- Creates a list of numbers from 1 to 10.

- Filters out even numbers.

- Squares the remaining numbers.

Assignment 1: Basic Python

### Task 1: Prime Number Checker

Write a function that checks whether a given number is prime.

- A prime number is only divisible by 1 and itself.

- Your function should return True if the number is prime, otherwise False.

- Example: is_prime(7) -> True

### Task 2: Fibonacci Sequence

Write a loop that prints the first 10 Fibonacci numbers.

- The Fibonacci sequence starts with 0 and 1.

- Each subsequent number is the sum of the two preceding ones.

- Example output: 0, 1, 1, 2, 3, 5, 8, 13, 21, 34

### Task 3: String Reversal

Write a function that reverses a string.

- Example: reverse_string("hello") -> "olleh"

### Task 4: Factorial Calculation


Write a function to calculate the factorial of a number using recursion.

- Example: factorial(5) -> 120

### Task 5: List Operations

Write a Python program that does the following:

- Creates a list of numbers from 1 to 10.

- Filters out even numbers.

- Squares the remaining numbers.

You might also like