Computer Science, asked by angel74939, 1 month ago

Ques 1.

Rectify the given errors given in the screenshot.

Ques 2.

Write a python program to print the table of a number in reverse order using for loop.

Please help me with this question.​



I will definitely mark brainliest for the correct and complete answer.

Attachments:

Answers

Answered by kanpas7
110

Answer:

Explanation:

I couldn't send typed answer because it was showing improper so plz adjust with screenshot mark me best

Attachments:
Answered by Equestriadash
140

1. Error rectification

Co‎de 1:

Given snippet:

\tt x\ =\ 10\\while\ (x\ ==>\ 5:\\{\ \ \ \ \ }print(X)\\{\ \ \ \ \ }x\ =\ X\ +\ 1:

Corrected snippet:

\tt x\ =\ 10\ \longrightarrow\ \sf Correction\ 1\\\tt while\ (x\ <=\ 5):\ \longrightarrow\ \sf Correction\ 2\ \&\ 3\\\tt {\ \ \ \ \ }print(x)\ \longrightarrow\ \sf Correction\ 4\\\tt {\ \ \ \ \ }x\ =\ x\ +\ 1\ \longrightarrow\ \sf Correction\ 5\ \&\ 6

Explanation:

  • Correction 1: To assign a value to a variable, a single '=' (equal to) operator is used. '==' is used to test for equality and not assigning.
  • Correction 2: The symbol for lesser than or equal to is '<='.
  • Correction 3: The closing bracket was missing.
  • Correction 4: Since Python is a case-sensitive program, x and X are both different variables. The variable we need for this program is the one that was given as the first command, i.e., x = 10.
  • Correction 5: Same as correction 4, x and X are both different.
  • Correction 6: The use of colon was not needed.

Co‎de 2:

Given snippet:

\tt a\ =\ int(in put("Enter\ a\ number"))\\i\ ==\ a\\while\ (i\ &gt;=\ 0:)\\{\ \ \ \ \ }Print(ixa)\\{\ \ \ \ \ }i\ =\ i\ +\ 2

Corrected snippet:

\tt a\ =\ int(in put("Enter\ a\ number"))\\i\ =\ a\ \longrightarrow\ \sf Correction\ 1\\\tt {\ \ \ \ \ }while\ (i\ &gt;=\ 0):\ \longrightarrow\ \sf Correction\ 2\\\tt {\ \ \ \ \ }print(i*a)\ \longrightarrow\ \sf Correction\ 3\\\tt {\ \ \ \ \ }i\ =\ i\ +\ 2

Explanation:

  • Correction 1: The symbol to use for assigning values into variables is '='.
  • Correction 2: The colon must appear at the end of the statement.
  • Correction 3: The symbol for multiplication is an asterisk (*).

Co‎de 3:

Given snippet:

\tt a\ =\ in put(INT("Enter\ the\ first\ number"))\\b\ =\ in put(INT("Enter\ the\ second\ number"))\\For\ i\ in\ range(a:b:,1):\\{\ \ \ \ \ }print(a*i)

Corrected snippet:

\tt a\ =\ int(in put("Enter\ a\ number"))\ \longrightarrow\ \sf Correction\ 1\\\tt b\ =\ int(in put("Enter\ a\ number"))\ \longrightarrow\ \sf Correction\ 2\\\tt for\ i\ in\ range(a,\ b,\ 1):\ \longrightarrow\ \sf Correction\ 3\ \&amp;\ 4\\\tt {\ \ \ \ \ }print(a*i)

Explanation:

  • Correction 1: The data type must be called out first before the \tt in put() function.
  • Correction 2: The same as correction 1.
  • Correction 3: Since Python is a case-sensitive language, 'for' and 'For' will be considered different.
  • Correction 4: The syntax of the range function is \tt range(start,\ stop,\ step).

Co‎de 4:

Given snippet:

\tt a\ =\ integer(in put("Enter\ number:\ "))\\b\ =\ 10\\for\ i\ in\ range(a:b):\\{\ \ \ \ \ }PRINT\ (a)\\if\ (a\ &gt;\ b)\ then:\\{\ \ \ \ \ }Print(a)

Corrected snippet:

\tt a\ =\ int(in put("Enter\ number:\ "))\ \longrightarrow\ \sf Correction\ 1\\\tt b\ =\ 10\\for\ i\ in\ range(a, b):\ \longrightarrow\ \sf Correction\ 2\\\tt {\ \ \ \ \ }print\ (a)\ \longrightarrow\ \sf Correction\ 3\\\tt if\ (a\ &gt;\ b):\ \longrightarrow\ \sf Correction\ 4\\\tt {\ \ \ \ \ }print(a)\ \longrightarrow\ \sf Correction\ 5

Explanation:

  • Correction 1: The appropriate syntax to call out the integer data type is \tt int().
  • Correction 2: The syntax of the range function is \tt range(start,\ stop,\ step).
  • Correction 3: Since Python is a case-sensitive language, 'PRINT' and 'print' will be considered different.
  • Correction 4: The use of 'then' is not needed in an if conditional statement.
  • Correction 5: The same reasoning as correction 3.

2. Python program

\tt n\ =\ int(in put("Enter\ a\ number:\ "))\\for\ i\ in\ range(10,\ -1,\ -1):\\{\ \ \ \ \ }print(n,\ "*",\ i,\ "=",\ n*i)

Similar questions