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.