codegamy_logo

CODELAB

. Distance Traveled Under Constant Acceleration

An object starts from rest and moves in a straight line with a constant acceleration. Your task is to calculate the distance traveled by the object at each second for a given duration. The formula for distance under constant acceleration is: s = 0.5*at² Where: s = distance (meters) a = acceleration (m/s²) t = time (seconds) You need to display the results in a tabular format showing the time and corresponding distance traveled.

Input Format

A single integer a — the acceleration of the object in m/s². A single integer t_max the total time duration in seconds.

Output Format

Print a table with two columns: Time (s) — time from 0 to t_max Distance (m) — distance traveled at that time Use a neatly formatted table.

Sample Input

2 10

Sample Output

+-----------+------------+ | Time (s) | Distance (m) | +-----+------+ | 0 | 0 | | 1 | 1 | | 2 | 4 | | 3 | 9 | | 4 | 16 | | 5 | 25 | | 6 | 36 | | 7 | 49 | | 8 | 64 | | 9 | 81 | | 10 | 100 | +-----+-------+

Constraints:

1≤a≤100 1≤𝑡_𝑚𝑎𝑥≤100
Python
Dark
14

Custom Input

Output

Custom Input

Output

. Distance Traveled Under Constant Acceleration

An object starts from rest and moves in a straight line with a constant acceleration. Your task is to calculate the distance traveled by the object at each second for a given duration. The formula for distance under constant acceleration is: s = 0.5*at² Where: s = distance (meters) a = acceleration (m/s²) t = time (seconds) You need to display the results in a tabular format showing the time and corresponding distance traveled.

Input Format

A single integer a — the acceleration of the object in m/s². A single integer t_max the total time duration in seconds.

Output Format

Print a table with two columns: Time (s) — time from 0 to t_max Distance (m) — distance traveled at that time Use a neatly formatted table.

Sample Input

2 10

Sample Output

+-----------+------------+ | Time (s) | Distance (m) | +-----+------+ | 0 | 0 | | 1 | 1 | | 2 | 4 | | 3 | 9 | | 4 | 16 | | 5 | 25 | | 6 | 36 | | 7 | 49 | | 8 | 64 | | 9 | 81 | | 10 | 100 | +-----+-------+

Constraints:

1≤a≤100 1≤𝑡_𝑚𝑎𝑥≤100
Python
Dark
14

Custom Input

Output

Custom Input

Output

2025 © CodeLab(PSTU) | All Rights Reserved.

Developed by Hasib-17❤️