0% found this document useful (0 votes)
3 views25 pages

ch6 Cs

Uploaded by

slaygirl337
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views25 pages

ch6 Cs

Uploaded by

slaygirl337
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 25

Ch6

=eg of compound statement

Eg of 2nd-
If statement true to yeh kaam
hojayega warna normal bahar
aajayega

If age greater than or equal to 18 it


will print he is eligible else it will
print nothing
if age bhi print karani hai baad mei to aise
In this we check multiple conditions
like if not one other will work if not
that too other will work and if not
that too else one will work
same code but now u are asking user to give input-for
better understanding see video 37 again
list are same as variables but can store multiple values
If we only want to print even numbers :-

If divide by 2 and remainder is 0


then print it (%)

If want only odd:-


start means first value stop means last value and step means
kitna kitna step beechme chorenge numbers ko print karane me

1 to 20 print karna hai to 21 end value hogi

3 steps chor ke number line likhni hai

To get even number in range do same like we did earlier


like this yk

For printing tables:-

to print table of every digit


WHILE LOOP
code repeat karta rheta hai jab tak koi condition true nhi ho jaati

i=i+1 isliye likha taai har ek baar increment ho 5 tak aur naaki infinte tak
chalta jaaye one one hi
first prit i means 1 print hoga then i=1 hai neeche to i+1 print hoga and
condition will satisfy to 2 print hoga assa 20 tak hoga

To print even numbers


How to print factorial using while loop-video 39
TO PRINT SAME HORIZONTALLY

Now lets use nested loop


Till inner loop isn’t completed
outside wont start
If we want that loop should terminate after 5
Creating vending machine concept with help of break statement :

We have candies available (av)=10


we asked user how many candies do
they need and if the exceed 10 it will
get break and if not they will get
that many candies

Aur agar 15 baar manga to 15 ke


baad hi loop terminate hogya

Now if we do this program more formally


Continue=if loop mei sei kuch show
nhi karna to we use this
puri list mei se 5 nhi print karna bas

if pure numbers mei se number jo 3 se divisible hai wo nhi


aaye
3 se or 5 se divisible waali values will not print

hamne ek code likha fir suddenly hame laga who nhi likhna
then we write pass and it executes and proceeds then we can write a new code

You might also like