Skip to content
View in the app

A better way to browse. Learn more.

GAMELIFE România

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

[Python] Bucle condiționale

1280px-Python_logo_and_wordmark.svg.png

 

Bucle condiționale

Introducere

Buclele condiționale sunt un mod de a repeta ceva atâta vreme cât o condiție este satisfăcută, sau Adevărată. Dacă condiția este întotdeauna satisfăcută (nu devine niciodată Falsă), atunci bucla poate deveni infinită. Dacă condiția este falsă la început, codul din buclă nu va rula niciodată! În Python buclele condiționale sunt definite folosind declarația while:

word = ''
sentence = ''
print('Please enter some words.')
print('Include a period (.) when you are finished.')
while '.' not in word:
    word = input('next word: ')
    sentence = word + ' ' + sentence
print()
print('Aha! You said:')
print(sentence)

Numim această parte a codului ‘condițional’: '.' not in word

De valoarea Adevărat sau nu întoarsă de condiție depinde executarea codului din bucla while.

Citește codul de mai sus și încearcă să rezumi în minte ce face (care va fi rezultatul final).

Apoi copiază într-un fișier, cum ar fi sentence.py și rulează-l - vezi exact ce face. Seamănă cu ce credeai tu ?

Quote

NOTE!

Dacă folosești Python 2, atunci trebuie să înlocuiești input cu raw_input pentru ca programul să se execute corect.

 

76561198361326087.png

TS3 SERVER : 193.84.64.140:10017

174855.png  facebook-new.png

#statiincasa

Featured Replies

No posts to show

Create an account or sign in to comment

Recently Browsing 0

  • No registered users viewing this page.

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.