-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhello.py
More file actions
50 lines (35 loc) · 1.32 KB
/
hello.py
File metadata and controls
50 lines (35 loc) · 1.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# Write a program to display the messages “Hello”, “World” and “Good Bye”. Each of the three
# messages should get displayed on a different line.
print("Hello")
print("World")
print("Good Bye")
#Write a basic program to make use of the end key and display the messages “Hello” “World”
#and “Good Bye” in one line
print('hello', end=' ')
print('world', end=' ')
print('good bye')
#Write a program to calculate the area of a rectangle.
length = 10
breadth = 5
area = length * breadth
print('Length =', length, 'Breadth =', breadth)
print ('The area of the rectangle is', area)
#Write a program to read strings from the keyboard
String1= input('Enter a string: ')
String2 = input('Enter another string: ')
print('String1 =', String1,'String2 =', String2)
#PROGRAM 2.5 Write a program to enter digits instead of characters.
print('Enter a digit: ')
x = input()
print('You entered:', x)
print('The type of the input is:')
print(type(x))
#PROGRAM 2.6 Write a program to demonstrate the use of int and input function.
print('Please Enter Number')
Num1 = input() #Get input from user
print('Num1 = ',Num1) #Print value of Num1
print(type(Num1)) #Check type of Num1
print('Converting type of Num1 to int')
Num1 = int(Num1) #Convert type of Num1 from str to int
print(Num1) #print the value of Num1
print(type(Num1))