Skip to content
Pooja Bhatia Classes Hari Nagar
  • We teach following classes
    • Class 12
    • Class 11
    • Class 10
    • Class 9
  • Sumita Arora IP/CS Solutions
  • Jobs/Internship
Pooja Bhatia Classes Hari Nagar

Author name: PythonCSIP CS IP

7. Write a program that reads an integer N from the keyboard computes and displays the sum of the numbers from N to (2 * N) if N is nonnegative. If N is a negative number, then it’s the sum of the numbers from (2 * N) to N. The starting and ending points are included in the sum.

sa 12 cs chapter 1 / PythonCSIP CS IP

# Code n = int(input()) x = 0 if n > 0: for i in range(n, 2*n+1): x += i else: for i in range(2*n, n+1): # for negative n, we need to reverse start & end of range x += i print(x)

7. Write a program that reads an integer N from the keyboard computes and displays the sum of the numbers from N to (2 * N) if N is nonnegative. If N is a negative number, then it’s the sum of the numbers from (2 * N) to N. The starting and ending points are included in the sum. Read More »

1. Write a program to print one of the words negative, zero, or positive, according to whether variable x is less than zero, zero, or greater than zero, respectively.

sa 12 cs chapter 1 / PythonCSIP CS IP

1. Write a program to print one of the words negative, zero, or positive, according to whether variable x is less than zero, zero, or greater than zero, respectively. Read More »

Post pagination
← Previous 1 … 195 196 197 … 554 Next →
  • We teach following classes
    • Class 12
    • Class 11
    • Class 10
    • Class 9
  • Sumita Arora IP/CS Solutions
  • Jobs/Internship
  • We teach following classes
  • Sumita Arora IP/CS Solutions
  • Jobs/Internship

Copyright © 2026 Pooja Bhatia Classes Hari Nagar | Powered by Pooja Bhatia Classes Hari Nagar.