Learning coding means GreatToCode Be more than a Coder ! Greattocode , Join GreatToCode Community,1000+ Students Trusted On Us .If You want to learn coding, Then GreatToCode Help You.No matter what It Takes !


CODE YOUR WAY TO A MORE FULFILLING And HIGHER PAYING CAREER IN TECH, START CODING FOR FREE Camp With GreatToCode - Join the Thousands learning to code with GreatToCode
Interactive online coding classes for at-home learning with GreatToCode . Try ₹Free Per Month Coding Classes With The Top Teachers . 5 python Programs for range () function.

5 python Programs for range () function.

Become More Then A coder | Learn & Start Coding Now.
Here are five Python programs that utilize the `range()` function for various tasks:

### 1. Printing Numbers in a Range:

```python
# Program 1: Printing numbers from 1 to 5 using range()
for num in range(1, 6):
    print(num)
```

### 2. Sum of Odd Numbers:

```python
# Program 2: Calculating the sum of odd numbers from 1 to 10 using range()
start, end = 1, 10
sum_odd = sum(range(start, end + 1, 2))
print(f"Sum of odd numbers from {start} to {end}: {sum_odd}")
```

### 3. Squares of Numbers:

```python
# Program 3: Printing squares of numbers from 1 to 5 using range()
for num in range(1, 6):
    square = num ** 2
    print(f"{num} squared is {square}")
```

### 4. Countdown:

```python
# Program 4: Countdown from 5 to 1 using range()
for num in range(5, 0, -1):
    print(num)
```

### 5. Creating a List of Multiples:

```python
# Program 5: Creating a list of multiples of 3 from 3 to 30 using range()
multiples_of_three = list(range(3, 31, 3))
print("Multiples of 3:", multiples_of_three)
```

Feel free to run these programs and explore the outcomes. They showcase different use cases of the `range()` function, from simple iterations to more complex tasks like calculating sums and creating lists.

Post a Comment

0 Comments

•Give The opportunity to your child with GreatToCode Kid's • Online Coding Classes for Your Kid • Introduce Your kid To the world's of coding
•Fuel You Career with our 100+ Hiring Partners, Advance Your Career in Tech with GreatToCode. •Join The Largest Tech and coding Community and Fast Forward Your career with GreatToCode. •10000+ Learner's+ 90 % placement Guarantee. • Learning Coding is Better with the GreatToCode community .
•Greattocode Kid's •GreatToCode Career •GreatToCode Interview •GreatToCode Professional •GreatToCode for schools •GreatToCode For colleges •GreatToCods For Businesses.
Are you ready to join the millions of people learning to code? GreatToCode Pass is your one-stop-shop to get access to 1000+ courses, top-notch support, and successful job placement. What are you waiting for? Sign up now and get your future in motion with GreatToCode Pass.