CS001 ASSIGNMENT 2 SOLUTION 2023

Views: 56

CS001 Assignment 2 Solution 2023. As the year 2023 begins, many students of computer science are looking forward to completing their assignments successfully. In this article, we will provide a solution for the CS001 Assignment 2 for 2023. This article will cover all the necessary details, including the instructions, requirements, and solution for the assignment. By the end of this article, you will have a clear understanding of the assignment and the solution.

Instructions for CS001 Assignment 2

The CS001 Assignment 2 is an important task that requires you to demonstrate your knowledge of computer programming. The assignment is divided into four parts, and you need to complete all the parts to get full marks. The instructions for each part are as follows:

Part 1

In part 1, you need to write a program that takes an input from the user and displays the Fibonacci series up to that number. You need to use loops and conditional statements to complete this part.

Part 2

In part 2, you need to write a program that takes two inputs from the user and performs arithmetic operations on them. You need to use functions and conditional statements to complete this part.

Part 3

In part 3, you need to write a program that reads a text file and counts the number of words in it. You need to use file handling and string manipulation to complete this part.

Part 4

In part 4, you need to write a program that generates a random number and asks the user to guess the number. You need to use loops and conditional statements to complete this part.

Requirements for CS001 Assignment 2

To complete the CS001 Assignment 2 successfully, you need to have a computer with the following software installed:

  • Python 3.0 or above
  • A text editor like Notepad++ or Sublime Text

You also need to have a basic understanding of programming concepts, including loops, conditional statements, functions, file handling, and string manipulation.

Solution for CS001 Assignment 2

Now that we have covered the instructions and requirements, let’s move on to the solution for the CS001 Assignment 2.

Part 1 Solution

To complete part 1, we need to write a program that takes an input from the user and displays the Fibonacci series up to that number. Here is the code for the solution:

num = int(input(“Enter a number: “))

a, b = 0, 1
while a < num:
print(a, end=’ ‘)
a, b = b, a+b

Part 2 Solution

To complete part 2, we need to write a program that takes two inputs from the user and performs arithmetic operations on them. Here is the code for the solution:

num1 = int(input(“Enter the first number: “))
num2 = int(input(“Enter the second number: “))

def add(num1, num2):
return num1 + num2

def subtract(num1, num2):
return num1 – num2

def multiply(num1, num2):
return num1 * num2

def divide(num1, num2):
return num1 / num2

print(“Addition:”, add(num1, num2))
print(“Subtraction:”, subtract(num1, num2))
print(“Multiplication:”, multiply(num1, num2))
print(“Division:”, divide(num1, num2))

Part 3 Solution

To complete part 3, we need to write a program that reads a text file and counts the number of words in it. Here is the code for the solution:

file = open(“sample.txt”, “r”)

Part 4 Solution

To complete part 4, we need to write a program that generates a random number and asks the user to guess the number. Here is the code for the solution:

content = file.read()
words = content.split()
print(“Number of words:”, len(words))
file.close()

Conclusion

In this article, we have provided a solution for the CS001 Assignment 2 for 2023. We have covered all the necessary details, including the instructions, requirements, and solution for the assignment. We hope this article has been helpful in completing the assignment successfully.

FAQs

  1. What is the CS001 Assignment 2 for 2023?

The CS001 Assignment 2 for 2023 is an assignment that requires students to demonstrate their knowledge of computer programming.

  1. How many parts does the CS001 Assignment 2 have?

The CS001 Assignment 2 has four parts.

  1. What software do I need to complete the CS001 Assignment 2?

You need Python 3.0 or above and a text editor like Notepad++ or Sublime Text to complete the CS001 Assignment 2.

  1. Do I need to have programming knowledge to complete the CS001 Assignment 2?

Yes, you need to have a basic understanding of programming concepts to complete the CS001 Assignment 2.

  1. Where can I find more programming assignments?

You can find more programming assignments by accessing online resources such as coding websites and online courses.

CS001 ASSIGNMENT 2 SOLUTION 2023

Solution will be available soon

See Also below past papers: