File tree Expand file tree Collapse file tree 4 files changed +61
-0
lines changed
Expand file tree Collapse file tree 4 files changed +61
-0
lines changed Original file line number Diff line number Diff line change 1+ # Conditional statement
2+ num = int (input ("Enter a number: " ))
3+ if num > 0 :
4+ print ("Positive number" )
5+ elif num == 0 :
6+ print ("Zero" )
7+ else :
8+ print ("Negative number" )
9+
10+ # For loop
11+ print ("\n Counting from 1 to 5:" )
12+ for i in range (1 , 6 ):
13+ print (i )
14+
15+ # While loop
16+ count = 0
17+ print ("\n Counting with while loop:" )
18+ while count < 5 :
19+ print ("Count is" , count )
20+ count += 1
Original file line number Diff line number Diff line change 1+ # Getting user input
2+ name = input ("Enter your name: " )
3+ age = int (input ("Enter your age: " ))
4+ my_name = "Hugo"
5+ my_age = 22
6+
7+ # Displaying output
8+ print ("\n Hello" , name + " !" )
9+ print ("\n You are" , age , "years old." )
10+
11+ if my_age == age :
12+ print (f"\n And my name is { my_name } , I am { my_age } years old too !" )
13+ else :
14+ print (f"\n And my name is { my_name } , I am { my_age } years old !" )
Original file line number Diff line number Diff line change 1+ isType = "is of type"
2+
3+ a = 5
4+ print (a , isType , type (a ))
5+
6+ b = 5.6
7+ print (b , isType , type (b ))
8+
9+ c = "Hello"
10+ print (c , isType , type (c ))
11+
12+ d = True
13+ print (d , isType , type (d ))
14+
15+ e = [1 , 2 , 3 ]
16+ print (e , isType , type (e ))
Original file line number Diff line number Diff line change 1+ name = "Hugo"
2+ age = 22
3+ is_student = True
4+
5+ # Displaying variables
6+ print ("Name:" , name )
7+ print ("Age:" , age )
8+ print ("Student:" , is_student )
9+
10+
11+ print (f"{ name } is { age } years old and he is student." )
You can’t perform that action at this time.
0 commit comments