Git Product home page Git Product logo

variables's Introduction

Variables

Swapping neighbors

File name: swap_neighbors.py

Please write a program that reads data separated by spaces from the keyboard. Then it prints the data, swapped pairwise (i.e. data[0] is swapped with data[1], data[2] swapped with data[3], etc.). If the number of data items is odd, the last item should remain in place.

Example:

Enter the data: 1 2 3 4 5 6 7 8 9
2 1 4 3 6 5 8 7 9

Delete every third

File name: remove3.py

Please write a program that reads some text from the keyboard and then deletes every third character (starting with the third). The remaining characters should be printed on the screen.

Example:

Enter text: To be or not to be...
Tobeorno t b..

The most frequent letter

File name: most_frequent.py

Please write a program that reads a line of text, and then prints the most frequent letter in it. The program should ignore case, and the most frequent letter should be capitalized. If there is more than one letter that appears most frequently, it is enough to print any of them. (for those of you who are ambitious: in such case, write down all the letters that appear most of the times, each in a separate line)

Example:

Write the text: To be or not to be
O

In the advanced version:

Enter text: Abba
A
B

Tip: I suggest creating a dictionary that stores for each letter the number of its occurrences. The number of occurrences of a given letter can be found using the count method for a text string (please search for its documentation yourself).

variables's People

Contributors

aveemperror avatar macdems avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.