Python Math: Create a dot string
67. Dot String Generator
Write a Python program to create a dot string.
Sample Solution:
Python Code:
from math import sin, cos, radians
import sys
for i in range(1000):
    print(' '*int(10*cos(radians(i))+10) + '.')
	
Sample Output:
                    .
                   .
                   .
                   .
                   .
                   .
                   .
                   .
                   .
                   .
                   .
                   .
                   .
                   .
                   .
                   .
                   .
                   .
                   .
                   .
                   .
                   .
                   .
                   .
                   .
                   .
                  .
                  .
                  .
                  .
                  .
                  .
                  .
                  .
                  .
                  .
                  .
                 .
                 .
                 .
                 .
                 .
                 .
                 .
                 .
                 .
                .
                .
                .
                .
                .
                .
                .
                .
               .
               .
               .
               .
               .
               .
               .
              .
              .
              .
              .
              .
              .
             .
             .
             .
             .
             .
             .
            .
            .
            .
            .
            .
            .
           .
           .
           .
           .
           .
           .
          .
          .
          .
          .
          .
          .
         .
         .
         .
         .
         .
        .
        .
        .
        .
        .
        .
       .
       .
       .
       .
       .
       .
      .
      .
      .
      .
      .
      .
     .
     .
     .
     .
     .
     .
     .
    .
    .
    .
    .
    .
    .
   .
   .
   .
   .
   .
   .
   .
   .
  .
  .
  .
  .
  .
  .
  .
  .
  .
 .
 .
 .
 .
 .
 .
 .
 .
 .
 .
 .
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
 .
 .
 .
 .
 .
 .
 .
 .
 .
 .
 .
  .
  .
  .
  .
  .
  .
  .
  .
  .
   .
   .
   .
   .
   .
   .
   .
   .
    .
    .
    .
    .
    .
    .
    .
     .
     .
     .
     .
     .
     .
      .
      .
      .
      .
      .
      .
       .
       .
       .
       .
       .
       .
        .
        .
        .
        .
        .
        .
         .
         .
         .
         .
         .
         .
          .
          .
          .
          .
          .
           .
           .
           .
           .
           .
           .
            .
            .
            .
            .
            .
            .
             .
             .
             .
             .
             .
             .
              .
              .
              .
              .
              .
              .
               .
               .
               .
               .
               .
               .
               .
                .
                .
                .
                .
                .
                .
                .
                .
                 .
                 .
                 .
                 .
                 .
                 .
                 .
                 .
                 .
                  .
                  .
                  .
                  .
                  .
                  .
                  .
                  .
                  .
                  .
                  .
                   .
                   .
                   .
                   .
                   .
                   .
                   .
                   .
                   .
                   .
                   .
                   .
                   .
                   .
                   .
                   .
                   .
                   .
                   .
                   .
                   .
                   .
                   .
                   .
                   .
                    .
                   .
                   .
                   .
                   .
                   .
                   .
                   .
                   .
                   .
                   .
                   .
                   .
                   .
                   .
                   .
                   .
                   .
                   .
                   .
                   .
                   .
                   .
                   .
                   .
                   .
                  .
                  .
                  .
                  .
                  .
                  .
                  .
                  .
                  .
                  .
                  .
                 .
                 .
                 .
                 .
                 .
                 .
                 .
                 .
                 .
                .
                .
                .
                .
                .
                .
                .
                .
               .
               .
               .
               .
               .
               .
              .
              .
              .
              .
              .
              .
              .
             .
             .
             .
             .
             .
             .
            .
            .
            .
            .
            .
            .
           .
           .
           .
           .
           .
           .
          .
          .
          .
          .
          .
          .
         .
         .
         .
         .
         .
        .
        .
        .
        .
        .
        .
       .
       .
       .
       .
       .
       .
      .
      .
      .
      .
      .
      .
     .
     .
     .
     .
     .
     .
     .
    .
    .
    .
    .
    .
    .
   .
   .
   .
   .
   .
   .
   .
   .
  .
  .
  .
  .
  .
  .
  .
  .
  .
 .
 .
 .
 .
 .
 .
 .
 .
 .
 .
 .
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
 .
 .
 .
 .
 .
 .
 .
 .
 .
 .
 .
  .
  .
  .
  .
  .
  .
  .
  .
  .
   .
   .
   .
   .
   .
   .
   .
   .
    .
    .
    .
    .
    .
    .
     .
     .
     .
     .
     .
     .
     .
      .
      .
      .
      .
      .
      .
       .
       .
       .
       .
       .
       .
        .
        .
        .
        .
        .
        .
         .
         .
         .
         .
         .
         .
          .
          .
          .
          .
          .
           .
           .
           .
           .
           .
           .
            .
            .
            .
            .
            .
            .
             .
             .
             .
             .
             .
             .
              .
              .
              .
              .
              .
              .
              .
               .
               .
               .
               .
               .
               .
                .
                .
                .
                .
                .
                .
                .
                .
                 .
                 .
                 .
                 .
                 .
                 .
                 .
                 .
                 .
                  .
                  .
                  .
                  .
                  .
                  .
                  .
                  .
                  .
                  .
                  .
                   .
                   .
                   .
                   .
                   .
                   .
                   .
                   .
                   .
                   .
                   .
                   .
                   .
                   .
                   .
                   .
                   .
                   .
                   .
                   .
                   .
                   .
                   .
                   .
                   .
                    .
                   .
                   .
                   .
                   .
                   .
                   .
                   .
                   .
                   .
                   .
                   .
                   .
                   .
                   .
                   .
                   .
                   .
                   .
                   .
                   .
                   .
                   .
                   .
                   .
                   .
                  .
                  .
                  .
                  .
                  .
                  .
                  .
                  .
                  .
                  .
                  .
                 .
                 .
                 .
                 .
                 .
                 .
                 .
                 .
                 .
                .
                .
                .
                .
                .
                .
                .
                .
               .
               .
               .
               .
               .
               .
               .
              .
              .
              .
              .
              .
              .
             .
             .
             .
             .
             .
             .
            .
            .
            .
            .
            .
            .
           .
           .
           .
           .
           .
           .
          .
          .
          .
          .
          .
          .
         .
         .
         .
         .
         .
        .
        .
        .
        .
        .
        .
       .
       .
       .
       .
       .
       .
      .
      .
      .
      .
      .
      .
     .
     .
     .
     .
     .
     .
    .
    .
    .
    .
    .
    .
    .
   .
   .
   .
   .
   .
   .
   .
   .
  .
  .
  .
  .
  .
  .
  .
  .
  .
 .
 .
 .
 .
 .
 .
 .
 .
 .
 .
 .
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
 .
 .
 .
 .
 .
 .
 .
 .
 .
 .
 .
  .
  .
  .
  .
  .
  .
  .
  .
  .
   .
   .
   .
   .
   .
   .
   .
   .
    .
    .
    .
    .
    .
    .
    .
     .
     .
     .
     .
     .
     .
      .
      .
      .
      .
      .
      .
       .
       .
       .
       .
       .
       .
        .
        .
        .
        .
        .
        .
         .
         .
         .
         .
         .
          .
          .
          .
          .
          .
          .
           .
           .
           .
           .
Flowchart:
 
For more Practice: Solve these Related Problems:
- Write a Python program to generate a dot string of a given length and then print the string.
- Write a Python function that prints a pattern of dots over multiple lines, with each line having a different number of dots.
- Write a Python script to create a grid pattern using dot strings and display the grid in a formatted manner.
- Write a Python program to generate a dot string that increases by one dot per line and then resets after a specified number of lines.
Go to:
Previous:  Write a Python program to create an ASCII waveform.
  Next:  Write a Python program to create a Pythagorean theorem calculator.
Python Code Editor:
Have another way to solve this solution? Contribute your code (and comments) through Disqus.
What is the difficulty level of this exercise?
Test your Programming skills with w3resource's quiz.
