-
Notifications
You must be signed in to change notification settings - Fork 1
/
10_condtion.py
60 lines (43 loc) · 1.47 KB
/
10_condtion.py
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
49
50
51
52
53
54
55
56
57
58
59
60
# Condtion: keyword= if / else / elif (elseif)
# name is variable
# Daksh is value
# = assignment operator
# from curses.ascii import isalpha
name = 'Daksh'
name = input('\nEnter your name: ')
# Check value is equal or not
if name == 'Daks':
# output: print()
print('\nHello,', name)
else:
print('\nName is not matching.')
# print('\nChck aplha: ', name.isalpha());exit()
# Check if name is stirng or not
if name.isalpha() == True:
print('\nHi,', name ,'\n')
else:
print('\nName must be only follow alphabets.\n')
# Add two number getting by user:
num_1 = input('\nEnter first number: ')
num_2 = input('\nEnter second number: ')
print('\nSum: ', num_1 + num_2)
# How to prevent user input only to int numebr
num_1 = input('\nEnter first number: ')
num_2 = input('\nEnter second number: ')
# print(num_1.isdigit())
if num_1.isdigit() == True:
print('\nSum of num1 and num2: ', num_1 + num_2)
else:
print('\nNon-interger number not allowed try again.')
# Home work:
# Check how many keyword availabale in Python/C/C++
# Linke number 28 to 32. perform sum
# Line number 35 to 43.
# Duble condtion lagan hai line number 40 par ki num 1 and num 2 dono hi jab inter ho tab if me aaye aur waha input print karana hai.
# Condtion bana hai odd aur even number chaeck karnke ke liye.
# 2n-1 / 2n %
# Note:
# Programming languages:
# machine level lan. | binary
# Low language | nimonic mul=multiplication sum=additin sub
# High Lev. lan |