For Loop:-
पाइथन मे for loop का syntax बाकि ओर प्रोग्रामिंग लैंग्वेज से काफी अलग होता है। for loop का प्रयोग किसी sequence ( जैसे की list, tuples, dictionaries और set आदि) को iterate करने के लिए किया जाता है। इन sequences को iterate करने के लिए हम membership operator in का use करते हैं।
Syntax:-
for < Variable_Name > in < Sequence_Name >:
statements
Important Point:-
- while is used to conditional repeated a block of code
- for iterates n times, where n is number of elements in a sequence.
Example:-
a = [5, 6, 9, 8, 5, 7] for num in a : print(num)
Output
5 6 9 8 5 7 |
str = “Hello World” for a in str: print(a) Output H e l l o W o r l d |
Question 1:- wap to print python with Unicode.
Question 2:- wap to print your name with Unicode.
For Loop:-
The syntax of for loop in Python is quite different from other programming languages. The for loop is used to iterate a sequence (such as lists, tuples, dictionaries and sets etc.). To iterate these sequences we use membership operator in.
Syntax:-
for < Variable_Name > in < Sequence_Name >:
statements
Important Point:-
- while is used to conditional repeated a block of code
- for iterates n times, where n is number of elements in a sequence.
Example:-
a = [5, 6, 9, 8, 5, 7] for num in a : print(num)
Output
5 6 9 8 5 7 |
str = “Hello World” for a in str: print(a) Output H e l l o W o r l d |
Question 1:- wap to print python with Unicode.
Question 2:- wap to print your name with Unicode.