Anasayfa
/
Teknoloji
/
i x=1 2 while xlt 10 : 3 x+=2 4 prin t(x, e nd= () 1 3579 2 1357911 3

Soru

I x=1 2 while xlt 10 : 3 x+=2 4 prin t(x, e nd= () 1 3579 2 1357911 3

Çözüm

4.4 (327 Oylar)
Okan
Uzman doğrulaması
Usta · 5 yıl öğretmeni

Cevap

The given code is a Python script that uses a while loop to print numbers from 1 to 10 with a step of 2. Here's the corrected version of the code:```pythonx = 1while x < 10: x += 2 print(x, end=' ')```Output:```1 3 5 7 9```Explanation:- The variable `x` is initialized to 1.- The while loop runs as long as `x` is less than 10.- Inside the loop, `x` is incremented by 2 using the `+=` operator.- The current value of `x` is printed followed by a space.- The loop continues until `x` becomes 10, at which point the loop stops.