Recent Changes - Search:

Oktatás

* Programozás 1
  + feladatsor
  + GitHub oldal

* Szkriptnyelvek
  + feladatsor
  + quick link

Teaching

* Programming 1 (BI)
  ◇ exercises
  ◇ quick link

* Scripting Languages
  ◇ exercises
  ◇ quick link

teaching assets


Félévek

* aktuális (2023/24/2)
* archívum


Linkek

* kalendárium
   - munkaszüneti napok '20
* tételsorok
* jegyzetek
* szakdolgozat / PhD
* ösztöndíjak
* certificates
* C lang.
* C++
* C#
* Clojure
* D lang.
* Java
* Nim
* Scala


[ edit | logout ]
[ sandbox | passwd ]

20121001a

String method

Select an arbitrary string method and write a little script that demonstrates it.

Some important points:

  • The script should do something useful. Be able to describe the script in a sentence. Put a comment to the beginning of the script and explain what it does.
  • put the main part of the script in a main() function
  • The main() function should be executed only if the script is called directly. If the script is called as a module, then the main() function shouldn't be executed automatically.

Here is how to read from the standard input (i.e. keyboard):

>>> s = input("Name: ")
Name: Laszlo
>>> s
'Laszlo'
>>>

Concrete exercise

Let's see a concrete exercise too. Write a program that works the following way:

$ ./name.py
Name:         Fred           <E>
Hello Fred!

That is, the program asks our name interactively. Leave some spaces before and after the name. In the example, "<E>" represents the Enter key. The program must greet us, as can be seen in the example.

Python 2

In Python 2, instead of input() use the raw_input() function.

Cloud City

  

Blogjaim, hobbi projektjeim

* The Ubuntu Incident
* Python Adventures
* @GitHub
* heroku
* extra
* haladó Python
* YouTube listák


Debrecen | la France


[ edit ]

Edit - History - Print *** Report - Recent Changes - Search
Page last modified on 2017 September 20, 12:54