-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvariables.py
154 lines (100 loc) · 3.6 KB
/
variables.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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
#Data Types we use type()function
#to know which class a variable or value belong
#num1=5
#print(num1,'is a type',type(num1))
#num2=2.5
#print(num2,'is a type of',type(num2))
#num4=1+4j
#print(num4,'is a type of',type(num4))
#List of Datatype
#languages=["swift","java","python"]#we have created a list name languages with three string value inside it
#we use index to acces the element
#print(languages[2])
#print(languages[1])
#print(languages[0])
#Tuple of Data type
#tuple is the an ordered sequence of item same as list immutable
#product=('Microsoft','xbox',499.90)
#Access the elemnt through index
#print(product[0])
#print(product[2])
#Datatype of String
#name='python lovers'
#print(name)
#message='python for begginers'
#print(message)
#Set Datatype
#student_id={121,12,422,456}
#print(student_id)
#Dictionary Datatype
#capital_city={'nepal':'kathmandu','italy':'Rome','Tanzania':'Dar-es-salaam'}
#We can retrieve value through keys
#print(capital_city['nepal'])
#Conversion of Data type
#num1=5
#num2=7.90
#new_numx=num1+num2
#print('The value of new no is',new_numx)
#num_string='12'
#num_integer=56
#num_string=int(num_string)
#num_sum= num_integer + num_string
#print('The value of num_sum is :',num_sum)
#Read the value from the keyboard and printout
#number=int(input('Enter the value of x :'))
#if number < 65: {
# # print('You still young :',number,'Years Old')
#}
#else:{
# print('Your are Old & still Beautiful/Handsome :',number,'Years Old')
# }
#name=input('Enter your name..:')
#age=input('Enter your age...:')
#location=input('Enter your location...:')
#print('hello',name,'yours',age,'years old','your location is at',location)
#num=input('Enter the values :')
#my_list=input("Enter the values :")
#print('\n')
#user_list=my_list.split()
#print('List :',user_list)
#Convert each item into int type
#for i in user_list:
#user_list[i]=int(user_list[i])
#sum +=([i])
#print('\n')
#input_string = input("Enter a list element separated by space ")
#input_string=input("Enter the list with different Element :")
#user_list = input_string.split()
#sum=0
#for i in user_list:
# sum += int (i)
#print('List :',user_list,'\n','Sum of the List= :',sum)
#Create a tuple containing the names of five of your favorite books. Then, use a for loop to print each book name on a separate line.
#Books = ('Python with Django', 'Darts with Flutter', 'Website Dev with Java Script', 'Cisco with CCNA','Database Managemnt sytstem')
#print('-------------------------------------')
#print('List of my Favorite Books')
#print('-------------------------------------')
#for i in range(5):
# print(Books[i])
#Write a program that uses a dictionary to store information about a person, such as their name, age, and favorite color.
#Ask the user for input and store the information in the dictionary. Then, print the dictionary to the console.
#person=dict {
# name=input('Enter the person name,age, & color key with its value:').split()
#for _ in range (2):
# print(person)
#}
#
#person={}
#for i in range(1):
#name=input('Enter the person name :')
#person['Name']=name
#age=int(input('Enter a person age :'))
#person['Age']=age
#color=input('Enter person favorite color :')
#person['Color']=color
#print(person)
#Write a program that accepts user input to create two sets of integers. Then,
# create a new set that contains only the elements that are common to both sets.
#Create a program that stores a list of words. Then,
# use list comprehension to create a new list that contains only
# the words that have an odd number of characters.