Joy of Computing Using Python NPTEL Assignment Answers: Some FAQs

Shubham
By -
0

The Joy of Computing Using Python NPTEL Assignment Answers

Introduction

    The NPTEL (National Programme on Technology Enhanced Learning) is a joint initiative by the Indian Institutes of Technology (IITs) and the Indian Institute of Science (IISc) aimed at providing quality education in engineering and science to students across India through online courses. One such course is "The Joy of Computing Using Python," which is a beginner-level programming course aimed at teaching Python programming language.

   In this article, we will provide answers to the NPTEL "Joy of Computing Using Python assignment answers", which will help you understand the concepts better and score better in the course.


Week 1 Assignment

Question 1    What is the output of the following code?

print("Hello, World!")

Solution:

The output of the above code is Hello, World! .


Question 2    What is the output of the following code?

x = 5

print(x)

Solution:

The output of the above code is 5.


Question 3    Write a program that takes two integers as input and prints their sum.

Solution:

a = int(input())

b = int(input())

print(a+b)


Week 2 Assignment

Question 1    Write a program to convert Celsius to Fahrenheit.

Solution:

celsius = float(input())

fahrenheit = (celsius * 9/5) + 32

print(fahrenheit)


Question 2    Write a program to find the largest among three numbers.

Solution:

a = int(input())

b = int(input())

c = int(input())

if a>b and a>c:

    print(a)

elif b>c:

    print(b)

else:

    print(c)


Question 3    Write a program to check if a number is even or odd.

Solution:

n = int(input())

if n%2 == 0:

    print("Even")

else:

    print("Odd")


Week 3 Assignment

Question 1    Write a program to count the number of digits in a number.

Solution:

n = int(input())

count = 0

while n!=0:

    count += 1

    n //= 10

print(count)


Question 2    Write a program to find the sum of digits of a number.

Solution:

n = int(input())

sum = 0

while n!=0:

    sum += n%10

    n //= 10

print(sum)


Question 3    Write a program to find the reverse of a number.

Solution:

n = int(input())

rev = 0

while n!=0:

    rev = rev*10 + n%10

    n //= 10

print(rev)


Week 4 Assignment

Question 1    Write a program to check if a given number is prime or not.

Solution:

n = int(input())

flag = True

for i in range(2, int(n**0.5)+1):

    if n%i == 0:

        flag = False

        break

if n<=1:

    flag = False

if flag:

    print("Prime")

else:

    print("Not Prime")


Question 2    Write a program to find the factorial of a number.

Solution:

n = int(input())

fact = 1

for i in range(1, n)


Question 3    Write a program to find the GCD (Greatest Common Divisor) of two numbers.

Solution:

a = int(input())

b = int(input())

while b!=0:

    temp = b

    b = a%b

    a = temp

print(a)


Week 5 Assignment

Question 1     Write a program to check if a given string is a palindrome or not.

Solution:

s = input()

if s == s[::-1]:

    print("Palindrome")

else:

    print("Not Palindrome")


Question 2    Write a program to find the second largest number in a list.

Solution:

n = int(input())

arr = list(map(int, input().split()))

arr.sort()

print(arr[-2])


Question 3    Write a program to find the sum of all prime numbers in a list.

Solution:

n = int(input())

arr = list(map(int, input().split()))


def is_prime(n):

    if n<=1:

        return False

    for i in range(2, int(n**0.5)+1):

        if n%i == 0:

            return False

    return True


sum = 0

for num in arr:

    if is_prime(num):

        sum += num

print(sum)


Week 6 Assignment

Question 1    Write a program to find the LCM (Least Common Multiple) of two numbers.

Solution:

a = int(input())

b = int(input())

temp = max(a, b)

while True:

    if temp%a==0 and temp%b==0:

        print(temp)

        break

    temp += 1


Question 2    Write a program to find the number of occurrences of a character in a string.

Solution:

s = input()

c = input()

count = s.count(c)

print(count)


Question 3    Write a program to check if a given number is a perfect square or not.

Solution:

n = int(input())

if int(n**0.5)**2 == n:

    print("Perfect Square")

else:

    print("Not Perfect Square")


Conclusion

    In this article, we have provided the answers to the NPTEL "Joy of Computing Using Python" assignment questions for the first six weeks. We hope that this article has helped you in understanding the concepts better and scoring better in the course. It is essential to practice programming regularly to improve your skills, and we encourage you to keep practicing.


FAQs

Q1. What is NPTEL?

Ans. NPTEL (National Programme on Technology Enhanced Learning) is a joint initiative by the Indian Institutes of Technology (IITs) and the Indian Institute of Science (IISc) aimed at providing quality education in engineering and science to students across India through online courses.

Q2. What is "The Joy of Computing Using Python" course?

Ans. "The Joy of Computing Using Python" is a beginner-level programming course aimed at teaching Python programming language.

Q3. Are the assignments in the "Joy of Computing Using Python" course difficult?

Ans. The difficulty level of the assignments depends on your prior knowledge and experience with programming. However, the course is designed for beginners, and the assignments are structured in a way that will help you learn and grow your skills gradually.

Q4. How important is it to practice programming regularly to excel in this course?

Ans. Practicing programming regularly is crucial to excel in this course. The more you practice, the better you will get at writing code and solving problems. Consistent practice will also help you gain confidence and improve your problem-solving abilities.

Q5. What are some tips for beginners to score well in the "Joy of Computing Using Python" course?

Ans. Some tips for beginners to score well in the "Joy of Computing Using Python" course include practicing regularly, understanding the basics of programming concepts, analyzing and understanding the problems before writing code, testing and debugging your code thoroughly, and seeking help from your peers or the course instructors whenever needed.

Q6. Can I use the solutions provided in this article as my own solutions for the assignments?

Ans. While you can refer to the solutions provided in this article for understanding the concepts and the approach, it is essential to write your solutions to the assignments. Copying or submitting the solutions provided in this article as your own work will be considered plagiarism and may lead to consequences.

Q7. What are some resources that I can use to learn more about Python programming?

Ans. There are many resources available online to learn Python programming, including online courses, tutorials, blogs, and forums. Some popular resources include Codeacademy, Coursera, Udemy, Python.org, and Stack Overflow. It is essential to choose a resource that matches your learning style and provides clear explanations and examples.

Tags:

Post a Comment

0Comments

Post a Comment (0)