0% found this document useful (0 votes)
16 views2 pages

Dart Programming Practice Exercises

Uploaded by

sasuken3411
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views2 pages

Dart Programming Practice Exercises

Uploaded by

sasuken3411
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Dart Practice programs

Foundational Concepts & User Interaction

1. Let’s Talk, Dart!


Write a Dart program that asks your name and favorite number, then prints a
personalized greeting using both.
2. Odd or Even Secret?
Ask the user for a number and let Dart reveal whether it's odd or even—with a fun
twist message.

Loops & Sequences

3. What’s in the Series?


Dart wants to build a series of numbers up to your input. Can you show all even
numbers from 1 to that number?
4. Multiply the Fun!
Build a multiplication table generator. Input any number, and print its table up to 10.

Conditions & Decision Making

5. The Number Oracle


Can your program judge whether a number is positive, negative, or zero?
6. Teen or Not?
Create a program that checks if the given age is in the teenage range (13–19). Return
a cool message.

Math & Functions

7. Dart's Power Calculator


Create a function that raises one number to the power of another (base and exponent
given by user).
8. Mystery Math Duel!
Take two numbers from the user. Offer them choices to add, subtract, multiply, or
divide—and show the result.

List & Loop Challenges

9. Dart’s Shopping Cart!


Ask the user to enter 5 item prices one by one. Store them in a list and print the total
and average price.
10. Guess the Smallest!
Input a series of numbers (space-separated), then let Dart find and display the
smallest.

Date, Time & Duration

11. How Many Days Left?


Let the user enter today’s date and a future goal date. Calculate and display the
number of days remaining.
Strings & Patterns

12. Spy Code Reverser!


Input a secret message. Reverse the string and print it backwards.
13. How Loud is Your Text?
Count how many uppercase and lowercase characters are in a sentence entered by the
user.

Character Classification

14. Code Inspector 007


Ask for a string and let Dart count how many are digits, alphabets, and special
characters.

Conversions & Utilities

15. From Meters to Magic


Convert meters to feet and vice versa based on the user's choice.
16. Temperature Spy Tool
Ask for a temperature in Celsius. Convert it to Fahrenheit—and vice versa!
17. Binary Decoder!
Input a decimal number and convert it to binary. Also, try the reverse!

Functions & Recursion

18. The Recursive Climber


Write a recursive function to calculate the factorial of a number.

Patterns and Visual Logic

19. Stairway of Stars


Input a number. Print a right-angled triangle made of stars (*) of that height.
20. Mirror Numbers
Input a number and print a diamond-shaped pattern using that number.

More programs can be seen at

[Link]

Common questions

Powered by AI

In Dart, a function can be created to calculate the power of a number using basic loop iteration or the built-in `pow` function from the `dart:math` library. This task is essential as it allows for the execution of exponentiation which is a fundamental mathematical operation used extensively in algorithms and data analysis .

Environmental conditions can be simulated in Dart by converting temperatures between Celsius and Fahrenheit using the formulae: `C = (F-32)*(5/9)` and `F = C*(9/5)+32`. This exercise provides educational outcomes by teaching students about temperature scales, units conversion, and reinforcing mathematical skills through programming .

A multiplication table generator in Dart can be implemented by allowing user input for a base number and iteratively multiplying it by numbers from 1 to 10 using a loop. This program is educationally important as it helps users practice multiplication and understand the concept of scaling through iteration .

In Dart, the `DateTime` class can be used to create date objects and calculate the difference in days between two dates by subtracting them and accessing the `inDays` property of the resulting `Duration` object. This capability is crucial in project management, event planning, and countdown applications .

To convert a decimal number to binary in Dart, repeatedly divide the number by 2, keeping track of the remainders. Construct the binary number by reversing the sequence of remainders. This knowledge is valuable because binary is a foundational numeral system in computer science, crucial for understanding data representation and logic gates .

A string in Dart can be reversed by converting it into a list of characters, reversing that list, and then joining the characters back together. This can be achieved using the `split`, `reverse`, and `join` methods. Reversing strings has practical applications in areas like cybersecurity (decryption), data validation, and palindrome checking .

A Dart program can determine if a number is odd or even by checking the remainder of the number divided by 2. If the remainder is zero, the number is even; otherwise, it is odd. To enhance user interaction, the program can include a creative message, such as congratulating the user on finding 'a mysterious even number' or 'an odd champion number' .

A Dart program can identify the smallest number in a space-separated list by converting the input string into an integer list, then iterating through the list to compare values and find the minimum. This functionality is beneficial in sorting algorithms, data analysis, and optimization problems .

Dart can handle user input using the `stdin.readLineSync()` function, which reads input as a string and can be converted to a number. The program can then apply conditional checks: if the number is greater than zero, it's positive; if it's less than zero, it's negative; else, it's zero. This classification is significant for decision making in programs, such as directing flow or validating user data .

A Dart program can classify characters by iterating over each character of a string and using conditional checks to determine if it's a digit, alphabet, or special character through ASCII value ranges or regular expressions. This classification is significant in data processing for validation, parsing, and formatting purposes .

You might also like